29 , mFrameSymbol( nullptr )
30 , mBlendMode(
QPainter::CompositionMode_SourceOver )
34 createDefaultFrameSymbol();
40 , mFrameSymbol(
nullptr )
41 , mBlendMode( QPainter::CompositionMode_SourceOver )
47 void QgsComposerMapOverview::createDefaultFrameSymbol()
51 properties.
insert(
"color",
"255,0,0,255" );
52 properties.
insert(
"style",
"solid" );
53 properties.
insert(
"style_border",
"no" );
75 if ( !overviewFrameMap )
102 delete expressionContext;
107 painter->
scale( 1 / dotsPerMM, 1 / dotsPerMM );
124 intersectPolygon = mapTransform.
map( intersectExtent );
130 mFrameSymbol->
renderPolygon( intersectPolygon, &rings,
nullptr, context );
137 outerPolygon <<
QPointF( 0, 0 )
144 rings.
append( intersectPolygon );
145 mFrameSymbol->
renderPolygon( outerPolygon, &rings,
nullptr, context );
162 overviewFrameElem.
setAttribute(
"frameMap", mFrameMapId );
164 overviewFrameElem.
setAttribute(
"inverted", mInverted );
165 overviewFrameElem.
setAttribute(
"centered", mCentered );
187 mInverted = ( itemElem.
attribute(
"inverted",
"0" ) !=
"0" );
188 mCentered = ( itemElem.
attribute(
"centered",
"0" ) !=
"0" );
191 if ( !frameStyleElem.
isNull() )
194 mFrameSymbol = QgsSymbolLayerV2Utils::loadSymbol<QgsFillSymbolV2>( frameStyleElem );
201 return mBlendMode != QPainter::CompositionMode_SourceOver;
206 if ( mFrameMapId == mapId )
246 mFrameSymbol = symbol;
278 if ( !overviewFrameMap )
288 center.
y() - extent.
height() / 2,
387 for (
int i = 0; i < mapOverviewNodeList.
size(); ++i )
391 mapOverview->
readXML( mapOverviewElem, doc );
void connectSignals()
Reconnects signals for overview map, so that overview correctly follows changes to source map's exten...
void setForceVectorOutput(bool force)
QDomNodeList elementsByTagName(const QString &tagname) const
A rectangle specified with double values.
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
void setCompositionMode(CompositionMode mode)
void addItem(QgsComposerMapItem *item)
Adds a new map item to the stack and takes ownership of the item.
void setRenderHint(RenderHint hint, bool on)
QDomNode appendChild(const QDomNode &newChild)
QString attribute(const QString &name, const QString &defValue) const
void setOutputDpi(int dpi)
Set DPI used for conversion between real world units (e.g. mm) and pixels.
void addOverview(QgsComposerMapOverview *overview)
Adds a new map overview to the stack and takes ownership of the overview.
const QgsMapSettings & mapSettings() const
Return setting of QGIS map canvas.
QgsComposerMapItem(const QString &name, QgsComposerMap *map)
Constructor for QgsComposerMapItem.
void scale(qreal sx, qreal sy)
static QgsFillSymbolV2 * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
void cache()
Create cache image.
const T & at(int i) const
bool centered() const
Returns whether the extent of the map is forced to center on the overview.
void moveOverviewDown(const QString &overviewId)
Moves an overview down the stack, causing it to be rendered below other overviews.
static QgsMapRenderer::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
static QDomElement saveSymbol(const QString &symbolName, QgsSymbolV2 *symbol, QDomDocument &doc)
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
Sets overview state from a DOM document.
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
void update(const QRectF &rect)
double x() const
Get the x value of the point.
An item which is drawn inside a QgsComposerMap, eg a grid or map overview.
The QgsMapSettings class contains configuration for rendering of the map.
const QgsComposerMapItem * constItem(const QString &itemId) const
Returns a const reference to an item within the stack.
QDomElement toElement() const
virtual QgsExpressionContext * createExpressionContext() const
Creates an expression context relating to the objects' current state.
void append(const T &value)
void setOutputSize(QSize size)
Set the size of the resulting map image.
An individual overview which is drawn above the map content in a QgsComposerMap, and shows the extent...
void setFrameSymbol(QgsFillSymbolV2 *symbol)
Sets the fill symbol used for drawing the overview extent.
void startRender(QgsRenderContext &context, const QgsFields *fields=nullptr)
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the overview.
bool mEnabled
True if item is to be displayed on map.
QgsComposerMapOverview & operator[](int idx)
Returns a reference to an overview within the stack.
void setAttribute(const QString &name, const QString &value)
const QgsComposition * composition() const
Returns the composition the item is attached to.
void removeItem(const QString &itemId)
Removes an item from the stack and deletes the corresponding QgsComposerMapItem.
int toInt(bool *ok, int base) const
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void moveItemUp(const QString &itemId)
Moves an item up the stack, causing it to be rendered above other items.
void setCentered(const bool centered)
Sets whether the extent of the map is forced to center on the overview.
QPaintDevice * device() const
void setPainter(QPainter *p)
void removeOverview(const QString &overviewId)
Removes an overview from the stack and deletes the corresponding QgsComposerMapOverview.
QgsComposerMapOverview(const QString &name, QgsComposerMap *map)
Constructor for QgsComposerMapOverview.
QgsComposerMap * mComposerMap
Associated composer map.
static QPainter::CompositionMode getCompositionMode(BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
QPolygonF visibleExtentPolygon() const
Returns a polygon representing the current visible map extent, considering map extents and rotation...
const QgsComposerMapOverview * constOverview(const QString &overviewId) const
Returns a const reference to an overview within the stack.
A class to represent a point.
QgsComposerMapItem * item(const QString &itemId) const
Returns a reference to an item within the stack.
bool usesAdvancedEffects() const override
Returns true if the item is drawn using advanced effects, such as blend modes.
Object representing map window.
void moveItemDown(const QString &itemId)
Moves an item up the stack, causing it to be rendered above other items.
void draw(QPainter *painter) override
Draws an overview.
QList< QgsComposerMapItem * > mItems
bool writeXML(QDomElement &elem, QDomDocument &doc) const override
Stores overview state in DOM element.
virtual ~QgsComposerMapOverview()
Contains information about the context of a rendering operation.
virtual void refreshDataDefinedProperty(const QgsComposerObject::DataDefinedProperty property=QgsComposerObject::AllProperties, const QgsExpressionContext *context=nullptr) override
QgsComposerMapOverview * overview(const QString &overviewId) const
Returns a reference to an overview within the stack.
void overviewExtentChanged()
Handles recentering of the map and redrawing of the map's overview.
void stopRender(QgsRenderContext &context)
void moveOverviewUp(const QString &overviewId)
Moves an overview up the stack, causing it to be rendered above other overviews.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
A collection of map items which are drawn above the map content in a QgsComposerMap.
QList< QgsComposerMapOverview * > asList() const
Returns a list of QgsComposerMapOverviews contained by the stack.
QDomElement firstChildElement(const QString &tagName) const
void setExtent(const QgsRectangle &rect)
Set coordinates of the rectangle which should be rendered.
void translate(const QPointF &offset)
QPolygonF intersected(const QPolygonF &r) const
void setInverted(const bool inverted)
Sets whether the overview frame is inverted, ie, whether the shaded area is drawn outside the extent ...
void setFrameMap(const int mapId)
Sets overview frame map.
double y() const
Get the y value of the point.
virtual ~QgsComposerMapOverviewStack()
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
Sets map item state from a DOM document.
iterator insert(const Key &key, const T &value)
QDomElement createElement(const QString &tagName)
void removeItems()
Clears the item stack and deletes all QgsComposerMapItems contained by the stack. ...
const QgsComposerMap * getComposerMapById(const int id) const
Returns the composer map with specified id.
double width() const
Width of the rectangle.
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const override
Stores map item state in DOM element.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QgsComposerMapOverviewStack(QgsComposerMap *map)
Constructor for QgsComposerMapOverviewStack.
QgsPoint center() const
Center point of the rectangle.
const QgsRectangle * currentMapExtent() const
Returns a pointer to the current map extent, which is either the original user specified extent or th...
void setAlpha(qreal alpha)
Set alpha transparency 1 for opaque, 0 for invisible.
bool readXML(const QDomElement &elem, const QDomDocument &doc) override
Sets the overview stack's state from a DOM document.
void setBlendMode(const QPainter::CompositionMode blendMode)
Sets the blending mode used for drawing the overview.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
double height() const
Height of the rectangle.
QDomNode at(int index) const
QgsComposerMap * mComposerMap
uint toUInt(bool *ok, int base) const
bool inverted() const
Returns whether the overview frame is inverted, ie, whether the shaded area is drawn outside the exte...