41 #include <QGraphicsScene>
42 #include <QGraphicsView>
52 , mEvaluatedMapRotation( 0 )
53 , mKeepLayerSet( false )
54 , mKeepLayerStyles( false )
55 , mUpdatesEnabled( true )
57 , mDrawCanvasItems( true )
58 , mAtlasDriven( false )
59 , mAtlasScalingMode( Auto )
60 , mAtlasMargin( 0.10 )
68 mCurrentRectangle =
rect();
71 mCacheUpdated =
false;
97 , mEvaluatedMapRotation( 0 )
98 , mKeepLayerSet( false )
99 , mKeepLayerStyles( false )
100 , mUpdatesEnabled( true )
102 , mDrawCanvasItems( true )
103 , mAtlasDriven( false )
104 , mAtlasScalingMode( Auto )
105 , mAtlasMargin( 0.10 )
114 mCurrentRectangle =
rect();
120 void QgsComposerMap::init()
136 void QgsComposerMap::updateToolTip()
141 void QgsComposerMap::adjustExtentToItemShape(
double itemWidth,
double itemHeight,
QgsRectangle& extent )
const
143 double itemWidthHeightRatio = itemWidth / itemHeight;
144 double newWidthHeightRatio = extent.
width() / extent.
height();
146 if ( itemWidthHeightRatio <= newWidthHeightRatio )
149 double newHeight = extent.
width() / itemWidthHeightRatio;
150 double deltaHeight = newHeight - extent.
height();
157 double newWidth = itemWidthHeightRatio * extent.
height();
158 double deltaWidth = newWidth - extent.
width();
166 delete mOverviewStack;
174 Q_UNUSED( forceWidthScale );
205 jobMapSettings.
setRotation( mEvaluatedMapRotation );
214 ( layerIdx >= 0 && layerIdx < theLayerSet.length() )
215 ?
QStringList( theLayerSet[ theLayerSet.length() - layerIdx - 1 ] )
242 return jobMapSettings;
260 if ( horizontalVScaleFactor < 0 )
270 int w = widthMM * horizontalVScaleFactor;
271 int h = heightMM * horizontalVScaleFactor;
274 if ( w > 5000 || h > 5000 )
279 h = w * heightMM / widthMM;
284 w = h * widthMM / heightMM;
288 mCacheImage =
QImage( w, h, QImage::Format_ARGB32 );
303 mCacheImage.
fill(
QColor( 255, 255, 255, 0 ).rgba() );
310 mCacheUpdated =
true;
336 QFont messageFont(
"", 12 );
337 painter->
setFont( messageFont );
339 painter->
drawText( thisPaintRect,
tr(
"Map will be printed here" ) );
350 double imagePixelWidth = mCacheImage.
width();
355 painter->
translate( mXOffset, mYOffset );
356 painter->
scale( scale, scale );
375 if ( !thePaintDevice )
381 if ( shouldDrawPart( Background ) )
391 painter->
translate( mXOffset, mYOffset );
393 double dotsPerMM = thePaintDevice->
logicalDpiX() / 25.4;
394 theSize *= dotsPerMM;
395 painter->
scale( 1 / dotsPerMM, 1 / dotsPerMM );
408 if ( shouldDrawPart( OverviewMapExtent ) &&
413 if ( shouldDrawPart( Grid ) &&
418 if ( shouldDrawPart( Frame ) )
422 if (
isSelected() && shouldDrawPart( SelectionBoxes ) )
434 + layersToRender().
length()
442 bool QgsComposerMap::shouldDrawPart( PartType part )
const
454 if ( SelectionBoxes == part )
469 if ( OverviewMapExtent == part )
480 if ( Background == part )
491 mCacheUpdated =
false;
498 if ( mPreviewMode ==
Render )
528 renderLayerSet = mLayerSet;
543 if ( removeAt != -1 )
545 renderLayerSet.
removeAt( removeAt );
550 return renderLayerSet;
557 calculator.
setDpi( 25.4 );
574 transformShift( dx, dy );
602 double zoomFactor = settings.
value(
"/qgis/zoom_factor", 2.0 ).
toDouble();
603 zoomFactor = delta > 0 ? zoomFactor : 1 / zoomFactor;
638 centerX = mapX + ( centerX - mapX ) * ( 1.0 / factor );
639 centerY = mapY + ( centerY - mapY ) * ( 1.0 / factor );
643 double newIntervalX, newIntervalY;
667 calculator.
setDpi( 25.4 );
669 mExtent.
scale( scaleRatio );
683 double w = rectangle.
width();
684 double h = rectangle.
height();
690 double newHeight = mExtent.
width() * h / w;
695 mCacheUpdated =
false;
729 double newWidthHeightRatio = newExtent.
width() / newExtent.
height();
731 if ( currentWidthHeightRatio < newWidthHeightRatio )
734 double newHeight = newExtent.
width() / currentWidthHeightRatio;
735 double deltaHeight = newHeight - newExtent.
height();
742 double newWidth = currentWidthHeightRatio * newExtent.
height();
743 double deltaWidth = newWidth - newExtent.
width();
757 mCacheUpdated =
false;
765 if ( mAtlasFeatureExtent != extent )
772 double newWidthHeightRatio = newExtent.
width() / newExtent.
height();
774 if ( currentWidthHeightRatio < newWidthHeightRatio )
777 double newHeight = newExtent.
width() / currentWidthHeightRatio;
778 double deltaHeight = newHeight - newExtent.
height();
782 else if ( currentWidthHeightRatio >= newWidthHeightRatio )
785 double newWidth = currentWidthHeightRatio * newExtent.
height();
786 double deltaWidth = newWidth - newExtent.
width();
791 mAtlasFeatureExtent = newExtent;
797 mCacheUpdated =
false;
811 return &mAtlasFeatureExtent;
827 return &mAtlasFeatureExtent;
838 double currentScaleDenominator =
scale();
840 if ( scaleDenominator == currentScaleDenominator || scaleDenominator == 0 )
845 double scaleRatio = scaleDenominator / currentScaleDenominator;
855 calculator.
setDpi( 25.4 );
856 scaleRatio = scaleDenominator / calculator.
calculate( mExtent,
rect().width() );
857 mExtent.
scale( scaleRatio );
860 mCacheUpdated =
false;
891 mEvaluatedMapRotation = mMapRotation;
902 void QgsComposerMap::refreshMapExtents()
908 bool useDdXMin =
false;
909 bool useDdXMax =
false;
910 bool useDdYMin =
false;
911 bool useDdYMax =
false;
922 if ( ok && !exprVal.
isNull() )
933 if ( ok && !exprVal.
isNull() )
944 if ( ok && !exprVal.
isNull() )
955 if ( ok && !exprVal.
isNull() )
969 double newWidthHeightRatio = newExtent.
width() / newExtent.
height();
971 if ( currentWidthHeightRatio < newWidthHeightRatio )
974 double newHeight = newExtent.
width() / currentWidthHeightRatio;
975 double deltaHeight = newHeight - newExtent.
height();
982 double newWidth = currentWidthHeightRatio * newExtent.
height();
983 double deltaWidth = newWidth - newExtent.
width();
997 double scaleD = exprVal.
toDouble( &ok );
999 if ( ok && !exprVal.
isNull() )
1006 if ( useDdXMax || useDdXMin || useDdYMax || useDdYMin )
1010 if ( useDdXMin && !useDdXMax )
1016 else if ( !useDdXMin && useDdXMax )
1022 if ( useDdYMin && !useDdYMax )
1028 else if ( !useDdYMin && useDdYMax )
1048 double rotationD = exprVal.
toDouble( &ok );
1050 if ( ok && !exprVal.
isNull() )
1052 mapRotation = rotationD;
1056 if ( mEvaluatedMapRotation != mapRotation )
1066 if ( !mUpdatesEnabled )
1085 for ( ; layer_it != layers.
constEnd(); ++layer_it )
1091 if ( currentRasterLayer )
1094 if (( rasterProvider = currentRasterLayer->
dataProvider() ) )
1096 if ( rasterProvider->
name() ==
"wms" )
1130 for ( ; layer_it != layers.
constEnd(); ++layer_it )
1135 if ( currentLayer->
blendMode() != QPainter::CompositionMode_SourceOver )
1141 if ( currentVectorLayer )
1147 if ( currentVectorLayer->
featureBlendMode() != QPainter::CompositionMode_SourceOver )
1156 if (( layerSettings.
blendMode != QPainter::CompositionMode_SourceOver ) ||
1171 void QgsComposerMap::connectUpdateSlot()
1175 if ( layerRegistry )
1193 if ( mPreviewMode ==
Cache )
1195 composerMapElem.
setAttribute(
"previewMode",
"Cache" );
1197 else if ( mPreviewMode ==
Render )
1199 composerMapElem.
setAttribute(
"previewMode",
"Render" );
1203 composerMapElem.
setAttribute(
"previewMode",
"Rectangle" );
1206 if ( mKeepLayerSet )
1208 composerMapElem.
setAttribute(
"keepLayerSet",
"true" );
1212 composerMapElem.
setAttribute(
"keepLayerSet",
"false" );
1215 if ( mDrawCanvasItems )
1217 composerMapElem.
setAttribute(
"drawCanvasItems",
"true" );
1221 composerMapElem.
setAttribute(
"drawCanvasItems",
"false" );
1238 for ( ; layerIt != mLayerSet.
constEnd(); ++layerIt )
1248 if ( mKeepLayerStyles )
1252 for ( ; styleIt != mLayerStyleOverrides.
constEnd(); ++styleIt )
1268 mGridStack->
writeXML( composerMapElem, doc );
1271 mOverviewStack->
writeXML( composerMapElem, doc );
1276 atlasElem.
setAttribute(
"scalingMode", mAtlasScalingMode );
1281 return _writeXML( composerMapElem, doc );
1292 if ( idRead !=
"not found" )
1294 mId = idRead.
toInt();
1301 if ( previewMode ==
"Cache" )
1303 mPreviewMode =
Cache;
1305 else if ( previewMode ==
"Render" )
1316 if ( extentNodeList.
size() > 0 )
1319 double xmin, xmax, ymin, ymax;
1335 if ( keepLayerSetFlag.
compare(
"true", Qt::CaseInsensitive ) == 0 )
1337 mKeepLayerSet =
true;
1341 mKeepLayerSet =
false;
1344 QString drawCanvasItemsFlag = itemElem.
attribute(
"drawCanvasItems",
"true" );
1345 if ( drawCanvasItemsFlag.
compare(
"true", Qt::CaseInsensitive ) == 0 )
1347 mDrawCanvasItems =
true;
1351 mDrawCanvasItems =
false;
1354 mLayerStyleOverrides.
clear();
1359 if ( layerSetNodeList.
size() > 0 )
1363 for (
int i = 0; i < layerIdNodeList.
size(); ++i )
1366 layerSet << layerIdElement.
text();
1373 mKeepLayerStyles = layerStylesNodeList.
size() > 0;
1374 if ( mKeepLayerStyles )
1378 for (
int i = 0; i < layerStyleNodeList.
size(); ++i )
1383 style.
readXml( layerStyleElement );
1389 mNumCachedLayers = 0;
1390 mCacheUpdated =
false;
1393 mOverviewStack->
readXML( itemElem, doc );
1396 mGridStack->
readXML( itemElem, doc );
1402 if ( mGridStack->
size() == 0 && gridNodeList.
size() > 0 )
1422 if ( gridSymbolElem.
isNull() )
1433 lineSymbol = QgsSymbolLayerV2Utils::loadSymbol<QgsLineSymbolV2>( gridSymbolElem );
1439 if ( annotationNodeList.
size() > 0 )
1453 QFont annotationFont;
1460 mGridStack->
addGrid( mapGrid );
1465 if ( !overviewFrameElem.
isNull() )
1476 if ( !overviewFrameSymbolElem.
isNull() )
1478 fillSymbol = QgsSymbolLayerV2Utils::loadSymbol<QgsFillSymbolV2>( overviewFrameSymbolElem );
1486 if ( atlasNodeList.
size() > 0 )
1489 mAtlasDriven = ( atlasElem.
attribute(
"atlasDriven",
"0" ) !=
"0" );
1492 mAtlasScalingMode = ( atlasElem.
attribute(
"fixedScale",
"0" ) !=
"0" ) ?
Fixed :
Auto;
1503 if ( composerItemList.
size() > 0 )
1525 if ( mKeepLayerStyles )
1535 if ( overrides == mLayerStyleOverrides )
1538 mLayerStyleOverrides = overrides;
1545 mLayerStyleOverrides.
clear();
1546 foreach (
const QString& layerID, mLayerSet )
1557 void QgsComposerMap::syncLayerSet()
1559 if ( mLayerSet.
size() < 1 )
1566 if ( mKeepLayerSet )
1575 for (
int i = mLayerSet.
size() - 1; i >= 0; --i )
1577 if ( !currentLayerSet.
contains( mLayerSet.
at( i ) ) )
1579 mLayerStyleOverrides.
remove( mLayerSet.
at( i ) );
1587 if ( mGridStack->
size() < 1 )
1592 return mGridStack->
grid( 0 );
1904 if ( mOverviewStack->
size() < 1 )
1909 return mOverviewStack->
overview( 0 );
1931 return mCurrentRectangle;
1940 double maxExtension = qMax( frameExtension, maxGridExtension );
1942 rectangle.
setLeft( rectangle.
left() - maxExtension );
1944 rectangle.
setTop( rectangle.
top() - maxExtension );
1946 if ( rectangle != mCurrentRectangle )
1949 mCurrentRectangle = rectangle;
1961 double dx = mXOffset;
1962 double dy = mYOffset;
1963 transformShift( dx, dy );
1969 double dx = mXOffset;
1970 double dy = mYOffset;
1974 transformShift( dx, dy );
1986 if ( mEvaluatedMapRotation == 0 )
2002 dx = rotationPoint.x() - extent.
xMinimum();
2003 dy = rotationPoint.y() - extent.
yMaximum();
2005 poly <<
QPointF( rotationPoint.x() - dx, rotationPoint.y() - dy );
2008 dx = rotationPoint.
x() - extent.
xMaximum();
2009 dy = rotationPoint.y() - extent.
yMaximum();
2011 poly <<
QPointF( rotationPoint.x() - dx, rotationPoint.y() - dy );
2014 dx = rotationPoint.
x() - extent.
xMaximum();
2015 dy = rotationPoint.y() - extent.
yMinimum();
2017 poly <<
QPointF( rotationPoint.x() - dx, rotationPoint.y() - dy );
2020 dx = rotationPoint.
x() - extent.
xMinimum();
2021 dy = rotationPoint.y() - extent.
yMinimum();
2023 poly <<
QPointF( rotationPoint.x() - dx, rotationPoint.y() - dy );
2043 return tr(
"Map %1" ).
arg( mId );
2049 if ( mEvaluatedMapRotation == 0 )
2056 mapPolygon( newExtent, poly );
2068 if ( extentWidth <= 0 )
2097 refreshMapExtents();
2106 mCacheUpdated =
false;
2184 void QgsComposerMap::transformShift(
double& xShift,
double& yShift )
const
2187 double dxScaled = xShift * mmToMapUnits;
2188 double dyScaled = - yShift * mmToMapUnits;
2199 if ( mapPoly.
size() < 1 )
2206 double dx = mapCoords.
x() - rotationPoint.
x();
2207 double dy = mapCoords.
y() - rotationPoint.
y();
2209 QgsPoint backRotatedCoords( rotationPoint.
x() + dx, rotationPoint.
y() + dy );
2212 double xItem =
rect().
width() * ( backRotatedCoords.x() - unrotatedExtent.xMinimum() ) / unrotatedExtent.width();
2213 double yItem =
rect().
height() * ( 1 - ( backRotatedCoords.y() - unrotatedExtent.yMinimum() ) / unrotatedExtent.height() );
2214 return QPointF( xItem, yItem );
2224 if ( !mMapCanvas || !mDrawCanvasItems )
2230 if ( itemList.
size() < 1 )
2236 for (
int i = itemList.
size() - 1; i >= 0; --i )
2238 currentItem = itemList.
at( i );
2240 if ( !currentItem || currentItem->
data( 0 ).
toString() !=
"AnnotationItem" )
2244 drawCanvasItem( currentItem, painter, itemStyle );
2250 if ( !item || !mMapCanvas || !item->
isVisible() )
2259 double scaleFactor = 1.0 / mMapCanvas->
logicalDpiX() * 25.4;
2261 double itemX, itemY;
2265 QPointF mapPos = composerMapPosForItem( item );
2274 QPointF mapPos = composerMapPosForItem( parent );
2276 itemX = mapPos.
x() + ( itemScenePos.
x() - parentScenePos.
x() ) * scaleFactor;
2277 itemY = mapPos.
y() + ( itemScenePos.
y() - parentScenePos.
y() ) * scaleFactor;
2281 painter->
scale( scaleFactor, scaleFactor );
2284 item->
setData( 1,
"composer" );
2285 item->
paint( painter, itemStyle, 0 );
2292 if ( !item || !mMapCanvas )
2306 double mapX = itemScenePos.
x() / graphicsSceneRect.
width() * mapRendererExtent.
width() + mapRendererExtent.
xMinimum();
2307 double mapY = mapRendererExtent.
yMaximum() - itemScenePos.
y() / graphicsSceneRect.
height() * mapRendererExtent.
height();
2327 for ( ; mapIt != mapList.
constEnd(); ++mapIt )
2329 if (( *mapIt )->id() > maxId )
2331 maxId = ( *mapIt )->id();
2364 mAtlasDriven = enabled;
2370 refreshMapExtents();
2376 return mAtlasScalingMode ==
Fixed;
2382 mAtlasScalingMode = fixed ?
Fixed :
Auto;
2392 double margin = mAtlasMargin;
2397 double ddMargin = exprVal.
toDouble( &ok );
2399 if ( ok && !exprVal.
isNull() )
2402 margin = ddMargin / 100;
2409 return mAtlasMargin;
Q_DECL_DEPRECATED void setGridFrameWidth(double w)
Set grid frame width.
void setMapUnits(QGis::UnitType mapUnits)
Set the map units.
void setStyle(const GridStyle style)
Sets the grid style, which controls how the grid is drawn over the map's contents.
void preparedForAtlas()
Is emitted when the map has been prepared for atlas rendering, just before actual rendering...
void updateItem() override
Updates item, with the possibility to do custom update for subclasses.
void addGrid(QgsComposerMapGrid *grid)
Adds a new map grid to the stack and takes ownership of the grid.
AtlasScalingMode
Scaling modes used for the serial rendering (atlas)
QgsComposition::AtlasMode atlasMode() const
Returns the current atlas mode of the composition.
QDomNodeList elementsByTagName(const QString &tagname) const
const QgsDatumTransformStore & datumTransformStore() const
QColor frameFillColor1() const
Retrieves the first fill color for the grid frame.
void draw(QPainter *painter, const QgsRectangle &extent, const QSizeF &size, double dpi, double *forceWidthScale=0)
Draw to paint device.
Q_DECL_DEPRECATED bool imageSizeConsideringRotation(double &width, double &height, double rotation) const
Calculates width and hight of the picture (in mm) such that it fits into the item frame with the give...
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
A rectangle specified with double values.
Base class for all map layer types.
void setDotsPerMeterX(int x)
void setDotsPerMeterY(int y)
Job implementation that renders everything sequentially using a custom painter.
void setAnnotationDirection(const AnnotationDirection direction, const BorderSide border)
Sets the direction for drawing frame annotations.
double intervalX() const
Gets the interval between grid lines in the x-direction.
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blending mode used for drawing the grid.
Q_DECL_DEPRECATED GridAnnotationDirection gridAnnotationDirection(QgsComposerMap::Border border) const
Q_DECL_DEPRECATED QgsLineSymbolV2 * gridLineSymbol()
double atlasMargin(const QgsComposerObject::PropertyValueType valueType=QgsComposerObject::EvaluatedValue)
Returns the margin size (percentage) used when the map is in atlas mode.
Q_DECL_DEPRECATED void setGridIntervalY(double interval)
Sets coordinate interval in y-direction for composergrid.
Q_DECL_DEPRECATED void setOverviewCentered(bool centered)
Set the overview's centering mode.
void setLineSymbol(QgsLineSymbolV2 *symbol)
Sets the line symbol used for drawing grid lines.
GridStyle
Grid drawing style.
bool containsWMSLayer() const
True if composer map renders a WMS layer.
QgsComposerMapGrid * grid(const QString &gridId) const
Returns a reference to a grid within the stack.
QList< QGraphicsItem * > items() const
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)=0
Q_DECL_DEPRECATED void setGridAnnotationFormat(GridAnnotationFormat f)
Q_DECL_DEPRECATED void setGridFrameFillColor1(const QColor &c)
Sets first fill color for grid zebra frame.
bool containsAdvancedEffects() const
Returns whether any items within the stack contain advanced effects, such as blending modes...
void setRenderHint(RenderHint hint, bool on)
Q_DECL_DEPRECATED double gridIntervalX() const
void setOffsetY(const double offset)
Sets the offset for grid lines in the y-direction.
QDomNode appendChild(const QDomNode &newChild)
void setXMaximum(double x)
Set the maximum x value.
double mapUnitsToMM() const
Returns the conversion factor map units -> mm.
bool hideCoverage() const
Returns true if the atlas is set to hide the coverage layer.
Q_DECL_DEPRECATED void setGridEnabled(bool enabled)
Enables a coordinate grid that is shown on top of this composermap.
const QgsLineSymbolV2 * lineSymbol() const
Gets the line symbol used for drawing grid lines.
Q_DECL_DEPRECATED double gridFramePenSize() const
void setFramePenSize(const double width)
Sets the width of the outline drawn in the grid frame.
void assignFreeId()
Sets mId to a number not yet used in the composition.
int size() const
Returns the number of items in the stack.
void setNewAtlasFeatureExtent(const QgsRectangle &extent)
Sets new Extent for the current atlas preview and changes width, height (and implicitely also scale)...
void readXml(const QDomElement &styleElement)
Read style configuration (for project file reading)
QString attribute(const QString &name, const QString &defValue) const
void setOffset(double xOffset, double yOffset)
Sets offset values to shift image (useful for live updates when moving item content) ...
Q_DECL_DEPRECATED QgsMapRenderer * mapRenderer()
Returns pointer to map renderer of qgis map canvas.
void setData(int key, const QVariant &value)
double yMaximum() const
Get the y maximum value (top side of rectangle)
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
void setOutputDpi(int dpi)
Set DPI used for conversion between real world units (e.g. mm) and pixels.
void itemChanged()
Emitted when the item changes.
void requestedExtent(QgsRectangle &extent) const
Calculates the extent to request and the yShift of the top-left point in case of rotation.
Q_DECL_DEPRECATED QColor gridFrameFillColor1() const
Get first fill color for grid zebra frame.
void addOverview(QgsComposerMapOverview *overview)
Adds a new map overview to the stack and takes ownership of the overview.
Q_DECL_DEPRECATED void connectMapOverviewSignals()
const QgsMapSettings & mapSettings() const
Return setting of QGIS map canvas.
QPainter::CompositionMode bufferBlendMode
ZoomMode
Modes for zooming item content.
A collection of grids which is drawn above the map content in a QgsComposerMap.
FrameStyle
Style for grid frame.
QStringList layerSet() const
Getter for stored layer set that is used if mKeepLayerSet is true.
Q_DECL_DEPRECATED void setAnnotationFontColor(const QColor &c)
Sets font color for grid annotations.
void scale(qreal sx, qreal sy)
void cache()
Create cache image.
Q_DECL_DEPRECATED bool showGridAnnotation() const
const_iterator constBegin() const
bool centered() const
Returns whether the extent of the map is forced to center on the overview.
const T & at(int i) const
Q_DECL_DEPRECATED void setGridStyle(GridStyle style)
Sets coordinate grid style to solid or cross.
Q_DECL_DEPRECATED bool imageSizeConsideringRotation(double &width, double &height) const
Calculates width and hight of the picture (in mm) such that it fits into the item frame with the give...
QList< const QgsComposerMap * > composerMapItems() const
Returns pointers to all composer maps in the scene.
QMap< QgsComposerObject::DataDefinedProperty, QString > mDataDefinedNames
Map of data defined properties for the item to string name to use when exporting item to xml...
A item that forms part of a map composition.
#define Q_NOWARN_DEPRECATED_PUSH
bool contains(const QString &str, Qt::CaseSensitivity cs) const
Border
Enum for different frame borders.
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
double annotationFrameDistance() const
Gets the distance between the map frame and annotations.
void setDpi(double dpi)
Set the dpi to be used in scale calculations.
double mLastValidViewScaleFactor
Backup to restore item appearance if no view scale factor is available.
QColor frameFillColor2() const
Retrieves the second fill color for the grid frame.
void drawItems(QPainter *painter)
Draws the items from the stack on a specified painter.
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
void mapRotationChanged(double newRotation)
Is emitted on rotation change to notify north arrow pictures.
static QgsPalLayerSettings fromLayer(QgsVectorLayer *layer)
FrameStyle frameStyle() const
Gets the grid frame style.
static QColor decodeColor(QString str)
virtual void drawFrame(QPainter *p)
Draw black frame around item.
void updateCachedImage()
Forces an update of the cached map image.
void setAnnotationFont(const QFont &font)
Sets the font used for drawing grid annotations.
Flags flags() const
Return combination of flags used for rendering.
Q_DECL_DEPRECATED double annotationFrameDistance() const
void setLayerStyleOverrides(const QMap< QString, QString > &overrides)
Set map of map layer style overrides (key: layer ID, value: style name) where a different style shoul...
QColor framePenColor() const
Retrieves the color of the outline drawn in the grid frame.
Q_DECL_DEPRECATED bool cornerPointOnRotatedAndScaledRect(double &x, double &y, double width, double height) const
Calculates corner point after rotation and scaling.
QPolygonF transformedMapPolygon() const
Returns extent that considers rotation and shift with mOffsetX / mOffsetY.
QColor backgroundColor() const
Gets the background color for this item.
A non GUI class for rendering a map layer set onto a QPainter.
AnnotationDirection
Direction of grid annotations.
void setLayers(const QStringList &layers)
Set list of layer IDs for map rendering.
Enable layer transparency and blending effects.
double toDouble(bool *ok) const
void setGridLineColor(const QColor &color)
Sets color of grid lines.
Q_DECL_DEPRECATED double gridOffsetX() const
bool containsAdvancedEffects() const
True if composer map contains layers with blend modes or flattened layers for vectors.
AnnotationFormat annotationFormat() const
Gets the format for drawing grid annotations.
QString tr(const char *sourceText, const char *disambiguation, int n)
QMap< QString, QString > QgsStringMap
void setAnnotationDisplay(const DisplayMode display, const BorderSide border)
Sets what types of grid annotations should be drawn for a specified side of the map frame...
Q_DECL_DEPRECATED GridFrameStyle gridFrameStyle() const
AnnotationFormat
Format for displaying grid annotations.
int readNumEntry(const QString &scope, const QString &key, int def=0, bool *ok=0) const
Q_DECL_DEPRECATED void zoomContent(int delta, double x, double y) override
Zoom content of map.
void update(const QRectF &rect)
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer...
DataDefinedProperty
Data defined properties for different item types.
AnnotationPosition annotationPosition(const BorderSide border) const
Gets the position for the grid annotations on a specified side of the map frame.
Q_DECL_DEPRECATED void setGridPenColor(const QColor &c)
Sets the color of the grid pen.
virtual QString name() const =0
return a provider name
void setWidth(double width)
double intervalY() const
Gets the interval between grid lines in the y-direction.
void setCrossLength(const double length)
Sets the length of the cross segments drawn for the grid.
QFont annotationFont() const
Gets the font used for drawing grid annotations.
bool dataDefinedEvaluate(const QgsComposerObject::DataDefinedProperty property, QVariant &expressionValue)
Evaluate a data defined property and return the calculated value.
Vector graphics should not be cached and drawn as raster images.
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
Q_DECL_DEPRECATED void setGridAnnotationPrecision(int p)
Sets coordinate precision for grid annotations.
Q_DECL_DEPRECATED QFont gridAnnotationFont() const
The QgsMapSettings class contains configuration for rendering of the map.
Q_DECL_DEPRECATED bool overviewInverted() const
Returns true if the overview frame is inverted.
bool _readXML(const QDomElement &itemElem, const QDomDocument &doc)
Reads parameter that are not subclass specific in document.
static bool staticWillUseLayer(QgsVectorLayer *layer)
called to find out whether the layer is used for labeling
QDomElement toElement() const
void readFromLayer(QgsMapLayer *layer)
Store layer's active style information in the instance.
void zoomToExtent(const QgsRectangle &extent)
Zooms the map so that the specified extent is fully visible within the map item.
void setCapStyle(Qt::PenCapStyle style)
Q_DECL_DEPRECATED const QgsMapRenderer * mapRenderer() const
Q_DECL_DEPRECATED QPainter::CompositionMode gridBlendMode() const
Returns the grid's blending mode.
void storeCurrentLayerSet()
Stores the current layer set of the qgis mapcanvas in mLayerSet.
virtual void setFrameOutlineWidth(const double outlineWidth) override
Sets frame outline width.
void setColor(const QColor &color)
Stores style information (renderer, transparency, labeling, diagrams etc.) applicable to a map layer...
Q_DECL_DEPRECATED QColor gridFrameFillColor2() const
Get second fill color for grid zebra frame.
void setFont(const QFont &font)
Q_DECL_DEPRECATED int overviewFrameMapId() const
Returns id of overview frame (or -1 if no overfiew frame)
QString number(int n, int base)
double scale() const
Scale.
Q_DECL_DEPRECATED double gridFrameWidth() const
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
double horizontalViewScaleFactor() const
Returns the zoom factor of the graphics view.
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 featureBlendMode() const
Returns the current blending mode for features.
double calculate(const QgsRectangle &mapExtent, int canvasWidth)
Calculate the scale denominator.
QgsFillSymbolV2 * frameSymbol()
Gets the fill symbol used for drawing the overview extent.
void updateBoundingRect()
Updates the bounding rect of this item.
Q_DECL_DEPRECATED void setGridAnnotationFont(const QFont &f)
Sets font for grid annotations.
bool fromString(const QString &descrip)
int toInt(bool *ok) const
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the overview.
void fill(uint pixelValue)
Q_DECL_DEPRECATED QColor annotationFontColor() const
Get font color for grid annotations.
bool hasAttribute(const QString &name) const
double xMaximum() const
Get the x maximum value (right side of rectangle)
virtual void updateItem()
Updates item, with the possibility to do custom update for subclasses.
virtual void drawSelectionBoxes(QPainter *p)
Draws additional graphics on selected items.
void setRotation(double degrees)
Set the rotation of the resulting map image Units are clockwise degrees.
static QgsLineSymbolV2 * createSimple(const QgsStringMap &properties)
Create a line symbol with one symbol layer: SimpleLine with specified properties. ...
QPainter::CompositionMode blendMode
friend class QgsComposerMapOverview
void setPen(const QColor &color)
void setNewScale(double scaleDenominator, bool forceUpdate=true)
Sets new scale and changes only mExtent.
bool mFrame
True if item fram needs to be painted.
Q_DECL_DEPRECATED QPainter::CompositionMode overviewBlendMode() const
Returns the overview's blending mode.
Whether vector selections should be shown in the rendered map.
void setAttribute(const QString &name, const QString &value)
void setMapUnits(QGis::UnitType u)
Set units of map's geographical coordinates - used for scale calculation.
void layersChanged()
Called when layers are added or removed from the layer registry.
const QgsComposition * composition() const
Returns the composition the item is attached to.
bool drawCanvasItems() const
void setCacheUpdated(bool u=false)
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
int toInt(bool *ok, int base) const
void setYMinimum(double y)
Set the minimum y value.
virtual void setEnabled(const bool enabled)
Controls whether the item will be drawn.
Q_DECL_DEPRECATED void setAnnotationFrameDistance(double d)
Sets distance between map frame and annotations.
void setAnnotationFormat(const AnnotationFormat format)
Sets the format for drawing grid annotations.
bool readXML(const QDomElement &elem, const QDomDocument &doc) override
Sets the grid stack's state from a DOM document.
AnnotationPosition
Position for grid annotations.
const_iterator constEnd() const
double offsetX() const
Gets the offset for grid lines in the x-direction.
void setCentered(const bool centered)
Sets whether the extent of the map is forced to center on the overview.
QPaintDevice * device() const
void setAnnotationEnabled(const bool enabled)
Sets whether annotations should be shown for the grid.
void setNewExtent(const QgsRectangle &extent)
Sets new extent for the map.
void translate(qreal dx, qreal dy)
Q_DECL_DEPRECATED void setGridPen(const QPen &p)
Sets the pen to draw composer grid.
void setWidthF(qreal width)
Q_DECL_DEPRECATED void setGridFrameFillColor2(const QColor &c)
Sets second fill color for grid zebra frame.
Q_DECL_DEPRECATED void setGridIntervalX(double interval)
Sets coordinate interval in x-direction for composergrid.
void drawText(const QPointF &position, const QString &text)
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
GridStyle style() const
Gets the grid's style, which controls how the grid is drawn over the map's contents.
Q_DECL_DEPRECATED bool atlasFixedScale() const
Returns true if the map uses a fixed scale when in atlas mode.
QGis::UnitType mapUnits() const
Get units of map's geographical coordinates - used for scale calculation.
void moveContent(double dx, double dy) override
Move content of map.
An individual grid which is drawn above the map content in a QgsComposerMap.
PropertyValueType
Specifies whether the value returned by a function should be the original, user set value...
QPainter::CompositionMode shapeBlendMode
bool shouldDrawItem() const
Returns whether the item should be drawn in the current context.
void setOutputImageFormat(QImage::Format format)
sets format of internal QImage
Q_DECL_DEPRECATED void sizeChangedByRotation(double &width, double &height)
Calculates width / height of the bounding box of a rotated rectangle.
void setColor(const QColor &color)
Q_DECL_DEPRECATED void setOverviewFrameMapSymbol(QgsFillSymbolV2 *symbol)
double offsetY() const
Gets the offset for grid lines in the y-direction.
Q_DECL_DEPRECATED void setGridFramePenSize(double w)
Set grid frame pen thickness.
void setGridLineWidth(const double width)
Sets width of grid lines.
double mapRotation(QgsComposerObject::PropertyValueType valueType=QgsComposerObject::EvaluatedValue) const
Returns the rotation used for drawing the map within the composer item.
double framePenSize() const
Retrieves the width of the outline drawn in the grid frame.
PreviewMode
Preview style.
Q_DECL_DEPRECATED GridAnnotationPosition gridAnnotationPosition(QgsComposerMap::Border border) const
QPolygonF visibleExtentPolygon() const
Returns a polygon representing the current visible map extent, considering map extents and rotation...
A class to represent a point.
void setFrameWidth(const double width)
Sets the grid frame width.
void setAnnotationFontColor(const QColor &color)
Sets the font color used for drawing grid annotations.
void prepareGeometryChange()
Graphics scene for map printing.
Q_DECL_DEPRECATED QColor gridFramePenColor() const
Get pen color for grid frame.
This class tracks map layers that are currently loaded and provides a means to fetch a pointer to a m...
Object representing map window.
Enable drawing of vertex markers for layers in editing mode.
QDomText createTextNode(const QString &value)
static void rotate(const double angle, double &x, double &y)
Rotates a point / vector around the origin.
Q_DECL_DEPRECATED QPen gridPen() const
QgsRectangle * currentMapExtent()
Returns a pointer to the current map extent, which is either the original user specified extent or th...
QString xmlData() const
Return XML content of the style.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) override
Reimplementation of QCanvasItem::paint - draw on canvas.
void renderModeUpdateCachedImage()
Updates the cached map image if the map is set to Render mode.
BorderSide
Border sides for annotations.
QString qgsDoubleToString(const double &a, const int &precision=17)
PreviewMode previewMode() const
void setFrameFillColor1(const QColor &color)
Sets the first fill color used for the grid frame.
void setFramePenColor(const QColor &color)
Sets the color of the outline drawn in the grid frame.
void setAnnotationPosition(const AnnotationPosition position, const BorderSide border)
Sets the position for the grid annotations on a specified side of the map frame.
virtual ~QgsComposerMap()
Q_DECL_DEPRECATED int gridAnnotationPrecision() const
Q_DECL_DEPRECATED void setGridAnnotationDirection(GridAnnotationDirection d, QgsComposerMap::Border border)
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
sets state from Dom document
Calculates scale for a given combination of canvas size, map extent, and monitor dpi.
Q_DECL_DEPRECATED void setCrossLength(double l)
Sets length of the cross segments (if grid style is cross)
int layerTransparency() const
Returns the current transparency for the vector layer.
Q_DECL_DEPRECATED bool gridEnabled() const
static QPainter::CompositionMode getCompositionMode(const QgsMapRenderer::BlendMode &blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
int annotationPrecision() const
Returns the coordinate precision for grid annotations.
virtual void setFrameOutlineWidth(const double outlineWidth)
Sets frame outline width.
#define Q_NOWARN_DEPRECATED_POP
const Key key(const T &value) const
bool useAdvancedEffects() const
Returns true if a composition should use advanced effects such as blend modes.
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the grid.
QgsComposition * mComposition
void layerStyleOverridesChanged()
Emitted when layer style overrides are changed...
virtual bool enabled() const
Returns whether the item will be drawn.
void setBackgroundColor(const QColor &color)
Set the background color of the map.
QColor annotationFontColor() const
Gets the font color used for drawing grid annotations.
const T & at(int i) const
QVariant value(const QString &key, const QVariant &defaultValue) const
void writeXml(QDomElement &styleElement) const
Write style configuration (for project file writing)
QVariant data(int key) const
QgsComposerMapOverview * overview(const QString &overviewId) const
Returns a reference to an overview within the stack.
Q_DECL_DEPRECATED bool cornerPointOnRotatedAndScaledRect(double &x, double &y, double width, double height, double rotation) const
Calculates corner point after rotation and scaling.
QRectF boundingRect() const
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, QFlags< Qt::ImageConversionFlag > flags)
void setClipRect(const QRectF &rectangle, Qt::ClipOperation operation)
int numberExportLayers() const override
Get the number of layers that this item requires for exporting as layers.
void setBackgroundColor(const QColor &backgroundColor)
Sets the background color for this item.
Q_DECL_DEPRECATED void setOverviewInverted(bool inverted)
Sets the overview's inversion mode.
bool _writeXML(QDomElement &itemElem, QDomDocument &doc) const
Writes parameter that are not subclass specific in document.
int mCurrentExportLayer
The layer that needs to be exported.
virtual void refreshDataDefinedProperty(const QgsComposerObject::DataDefinedProperty property=QgsComposerObject::AllProperties) override
Refreshes a data defined property for the item by reevaluating the property's value and redrawing the...
QgsRectangle extent() const
virtual QString displayName() const override
Get item display name.
void setOutputSize(const QSize &size)
Set the size of the resulting map image.
void setYMaximum(double y)
Set the maximum y value.
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const
Stores the state of the item stack in a DOM node.
virtual void drawBackground(QPainter *p)
Draw background.
bool hasFrame() const
Whether this item has a frame or not.
QImage::Format outputImageFormat() const
format of internal QImage, default QImage::Format_ARGB32_Premultiplied
Q_DECL_DEPRECATED void setShowGridAnnotation(bool show)
Sets flag if grid annotation should be shown.
static QgsProject * instance()
access to canonical QgsProject instance
QDomElement firstChildElement(const QString &tagName) const
void setExtent(const QgsRectangle &rect)
Set coordinates of the rectangle which should be rendered.
void setMapRotation(double r)
Sets rotation for the map - this does not affect the composer item shape, only the way the map is dra...
virtual void setSceneRect(const QRectF &rectangle)
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
void setAnnotationPrecision(const int precision)
Sets the coordinate precision for grid annotations.
Q_DECL_DEPRECATED void setGridAnnotationPosition(GridAnnotationPosition p, QgsComposerMap::Border border)
Q_DECL_DEPRECATED double gridIntervalY() const
bool hasBackground() const
Whether this item has a Background or not.
void setIntervalY(const double interval)
Sets the interval between grid lines in the y-direction.
const QMap< QString, QgsMapLayer * > & mapLayers()
Retrieve the mapLayers collection (mainly intended for use by projection)
bool annotationEnabled() const
Gets whether annotations are shown for the grid.
QgsComposerMap(QgsComposition *composition, int x, int y, int width, int height)
Constructor.
void translate(const QPointF &offset)
void setInverted(const bool inverted)
Sets whether the overview frame is inverted, ie, whether the shaded area is drawn outside the extent ...
Q_DECL_DEPRECATED void setAtlasFixedScale(bool fixed)
Set to true if the map should use a fixed scale when in atlas mode.
void setFrameMap(const int mapId)
Sets overview frame map.
void resize(double dx, double dy)
resizes an item in x- and y direction (canvas coordinates)
void setSceneRect(const QRectF &rectangle) override
Sets new scene rectangle bounds and recalculates hight and extent.
Q_DECL_DEPRECATED void setRotation(double r) override
Sets rotation for the map - this does not affect the composer item shape, only the way the map is dra...
double crossLength() const
Retrieves the length of the cross segments drawn for the grid.
virtual void refreshDataDefinedProperty(const QgsComposerObject::DataDefinedProperty property=QgsComposerObject::AllProperties) override
QStringList layers() const
Get list of layer IDs for map rendering The layers are stored in the reverse order of how they are re...
QgsAtlasComposition & atlasComposition()
Q_DECL_DEPRECATED double crossLength()
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
Q_DECL_DEPRECATED double gridOffsetY() const
int indexOf(const QRegExp &rx, int from) const
double toDouble(bool *ok) const
QGraphicsItem * parentItem() const
Q_DECL_DEPRECATED void setGridOffsetX(double offset)
Sets x-coordinate offset for composer grid.
iterator insert(const Key &key, const T &value)
Enable vector simplification and other rendering optimizations.
QPainter::CompositionMode shadowBlendMode
QgsRasterDataProvider * dataProvider()
Returns the data provider.
Q_DECL_DEPRECATED QgsFillSymbolV2 * overviewFrameMapSymbol()
Q_DECL_DEPRECATED void setOverviewBlendMode(QPainter::CompositionMode blendMode)
Sets the overview's blending mode.
QgsVectorLayer * coverageLayer() const
Returns the coverage layer used for the atlas features.
Q_DECL_DEPRECATED void setGridLineSymbol(QgsLineSymbolV2 *symbol)
Q_DECL_DEPRECATED void setGridPenWidth(double w)
Sets width of grid pen.
static void setSpecialColumn(const QString &name, QVariant value)
Assign a special column.
void setAtlasDriven(bool enabled)
Sets whether the map extent will follow the current atlas feature.
const_iterator constEnd() const
double maxGridExtension() const
Calculates the maximum distance grids within the stack extend beyond the QgsComposerMap's item rect...
QDomElement createElement(const QString &tagName)
void setFrameFillColor2(const QColor &color)
Sets the second fill color used for the grid frame.
const_iterator constBegin() const
void setLayerStyleOverrides(const QMap< QString, QString > &overrides)
Setter for stored overrides of styles for layers.
void setFrameStyle(const FrameStyle style)
Sets the grid frame style.
Q_DECL_DEPRECATED void setGridOffsetY(double offset)
Sets y-coordinate offset for composer grid.
QPointF mapToItemCoords(const QPointF &mapCoords) const
Transforms map coordinates to item coordinates (considering rotation and move offset) ...
const QgsComposerMap * getComposerMapById(const int id) const
Returns the composer map with specified id.
void setPreviewMode(PreviewMode m)
QgsComposition::PlotStyle plotStyle() const
double width() const
Width of the rectangle.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
AnnotationDirection annotationDirection(const BorderSide border) const
Gets the direction for drawing frame annotations.
QRectF boundingRect() const override
In case of annotations, the bounding rectangle can be larger than the map item rectangle.
bool writeXML(QDomElement &elem, QDomDocument &doc) const override
stores state in Dom node
Represents a vector layer which manages a vector based data sets.
void storeCurrentLayerStyles()
Stores the current layer styles into style overrides.
int compare(const QString &other) const
Q_DECL_DEPRECATED void setGridFrameStyle(GridFrameStyle style)
Set grid frame style (NoGridFrame or Zebra)
virtual QgsSymbolV2 * clone() const override
void setFlags(Flags flags)
Set combination of flags that will be used for rendering.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
double xMinimum() const
Get the x minimum value (left side of rectangle)
Q_DECL_DEPRECATED GridAnnotationFormat gridAnnotationFormat() const
void renderSynchronously()
Render the map synchronously in this thread.
void setIntervalX(const double interval)
Sets the interval between grid lines in the x-direction.
int frameMapId() const
Returns id of source map.
bool readXML(const QDomElement &elem, const QDomDocument &doc) override
Sets the overview stack's state from a DOM document.
void setOffsetX(const double offset)
Sets the offset for grid lines in the x-direction.
Q_DECL_DEPRECATED void setGridBlendMode(QPainter::CompositionMode blendMode)
Sets the grid's blending mode.
Q_DECL_DEPRECATED void setOverviewFrameMap(int mapId)
Sets overview frame map.
void setBlendMode(const QPainter::CompositionMode blendMode)
Sets the blending mode used for drawing the overview.
void setXMinimum(double x)
Set the minimum x value.
QgsComposerMapGrid * grid()
Returns the map item's first grid.
Q_DECL_DEPRECATED void setGridFramePenColor(const QColor &c)
Sets pen color for grid frame.
void setAnnotationFrameDistance(const double distance)
Sets the distance between the map frame and annotations.
Q_DECL_DEPRECATED void sizeChangedByRotation(double &width, double &height, double rotation)
Calculates width / height of the bounding box of a rotated rectangle.
double frameWidth() const
Gets the grid frame width.
double height() const
Height of the rectangle.
void setCrsTransformEnabled(bool enabled)
sets whether to use projections for this layer set
QDomNode at(int index) const
const T value(const Key &key) const
Q_DECL_DEPRECATED GridStyle gridStyle() const
Base class for raster data providers.
uint toUInt(bool *ok, int base) const
int remove(const Key &key)
QgsMapSettings mapSettings(const QgsRectangle &extent, const QSizeF &size, int dpi) const
Return map settings that would be used for drawing of the map.
bool inverted() const
Returns whether the overview frame is inverted, ie, whether the shaded area is drawn outside the exte...
QList< Key > uniqueKeys() const
QgsComposerMapOverview * overview()
Returns the map item's first overview.
void scale(double scaleFactor, const QgsPoint *c=0)
Scale the rectangle around its center point.
Q_DECL_DEPRECATED bool overviewCentered() const
Returns true if the extent is forced to center on the overview.
A collection of overviews which are drawn above the map content in a QgsComposerMap.
QString id() const
Get item's id (which is not necessarly unique)