30 , mBlendMode(
QPainter::CompositionMode_SourceOver )
34 createDefaultFrameSymbol();
37 QgsComposerMapOverview::QgsComposerMapOverview()
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 )
104 painter->
scale( 1 / dotsPerMM, 1 / dotsPerMM );
121 intersectPolygon = mapTransform.
map( intersectExtent );
127 mFrameSymbol->
renderPolygon( intersectPolygon, &rings, 0, context );;
134 outerPolygon <<
QPointF( 0, 0 )
141 rings.
append( intersectPolygon );
142 mFrameSymbol->
renderPolygon( outerPolygon, &rings, 0, context );
159 overviewFrameElem.
setAttribute(
"frameMap", mFrameMapId );
161 overviewFrameElem.
setAttribute(
"inverted", mInverted );
162 overviewFrameElem.
setAttribute(
"centered", mCentered );
184 mInverted = ( itemElem.
attribute(
"inverted",
"0" ) !=
"0" );
185 mCentered = ( itemElem.
attribute(
"centered",
"0" ) !=
"0" );
188 if ( !frameStyleElem.
isNull() )
191 mFrameSymbol = QgsSymbolLayerV2Utils::loadSymbol<QgsFillSymbolV2>( frameStyleElem );
198 return mBlendMode != QPainter::CompositionMode_SourceOver;
203 if ( mFrameMapId == mapId )
243 mFrameSymbol = symbol;
275 if ( !overviewFrameMap )
285 center.
y() - extent.
height() / 2,
384 for (
int i = 0; i < mapOverviewNodeList.
size(); ++i )
388 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.
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.
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.
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)
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer...
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
static QDomElement saveSymbol(QString symbolName, QgsSymbolV2 *symbol, QDomDocument &doc)
void append(const T &value)
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.
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the overview.
bool mEnabled
True if item is to be displayed on map.
void startRender(QgsRenderContext &context, const QgsFields *fields=0)
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
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.
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.
QgsRectangle * currentMapExtent()
Returns a pointer to the current map extent, which is either the original user specified extent or th...
void draw(QPainter *painter) override
Draws an overview.
static QPainter::CompositionMode getCompositionMode(const QgsMapRenderer::BlendMode &blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
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.
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.
void setOutputSize(const QSize &size)
Set the size of the resulting map image.
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.
virtual void refreshDataDefinedProperty(const QgsComposerObject::DataDefinedProperty property=QgsComposerObject::AllProperties) override
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)
static QgsMapRenderer::BlendMode getBlendModeEnum(const QPainter::CompositionMode &blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
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.
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.
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...