17 #ifndef QGSCOMPOSERMAP_H
18 #define QGSCOMPOSERMAP_H
24 #include <QGraphicsRectItem>
114 void draw( QPainter *painter,
const QgsRectangle& extent,
const QSizeF&
size,
double dpi,
double* forceWidthScale = 0 );
117 void paint( QPainter* painter,
const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
129 void resize(
double dx,
double dy );
146 double scale()
const;
149 void setNewScale(
double scaleDenominator );
157 void setNewAtlasFeatureExtent(
const QgsRectangle& extent );
160 void toggleAtlasPreview();
169 void setPreviewMode( PreviewMode m );
183 void setLayerSet(
const QStringList& layerSet ) {mLayerSet = layerSet;}
185 void storeCurrentLayerSet();
188 void setCacheUpdated(
bool u =
false );
195 void setOffset(
double xOffset,
double yOffset );
198 bool containsWMSLayer()
const;
201 bool containsAdvancedEffects()
const;
207 bool writeXML( QDomElement& elem, QDomDocument & doc )
const;
213 bool readXML(
const QDomElement& itemElem,
const QDomDocument& doc );
247 void setGridPen(
const QPen& p );
248 QPen gridPen()
const;
252 void setGridPenWidth(
double w );
256 void setGridPenColor(
const QColor& c );
332 QRectF boundingRect()
const;
335 void updateBoundingRect();
358 void setMapRotation(
double r );
371 double mapUnitsToMM()
const;
375 void setOverviewFrameMap(
int mapId );
386 void setOverviewBlendMode( QPainter::CompositionMode blendMode );
391 void setOverviewInverted(
bool inverted );
396 void setOverviewCentered(
bool centered );
404 void setGridBlendMode( QPainter::CompositionMode blendMode );
442 void extentChanged();
445 void mapRotationChanged(
double newRotation );
450 void updateCachedImage( );
452 void renderModeUpdateCachedImage();
454 void overviewExtentChanged();
522 void connectUpdateSlot();
590 void adjustExtentToItemShape(
double itemWidth,
double itemHeight,
QgsRectangle& extent )
const;
600 QStringList layersToRender();
603 void drawGrid( QPainter* p );
604 void drawGridFrame( QPainter* p,
const QList< QPair< double, QLineF > >& hLines,
const QList< QPair< double, QLineF > >& vLines );
609 void drawCoordinateAnnotations( QPainter* p,
const QList< QPair< double, QLineF > >& hLines,
const QList< QPair< double, QLineF > >& vLines );
610 void drawCoordinateAnnotation( QPainter* p,
const QPointF& pos, QString annotationString );
616 void drawAnnotation( QPainter* p,
const QPointF& pos,
int rotation,
const QString& annotationText );
620 int xGridLines( QList< QPair< double, QLineF > >& lines )
const;
623 int yGridLines( QList< QPair< double, QLineF > >& lines )
const;
627 QPolygonF transformedMapPolygon()
const;
628 double maxExtension()
const;
632 void mapPolygon( QPolygonF& poly )
const;
634 void mapPolygon(
const QgsRectangle& extent, QPolygonF& poly )
const;
641 void transformShift(
double& xShift,
double& yShift )
const;
643 QPointF mapToItemCoords(
const QPointF& mapCoords )
const;
645 Border borderForLineCoord(
const QPointF& p )
const;
647 void drawCanvasItems( QPainter* painter,
const QStyleOptionGraphicsItem* itemStyle );
648 void drawCanvasItem( QGraphicsItem* item, QPainter* painter,
const QStyleOptionGraphicsItem* itemStyle );
649 QPointF composerMapPosForItem(
const QGraphicsItem* item )
const;
650 void sortGridLinesOnBorders(
const QList< QPair< double, QLineF > >& hLines,
const QList< QPair< double, QLineF > >& vLines, QMap< double, double >& leftFrameEntries,
651 QMap< double, double >& rightFrameEntries, QMap< double, double >& topFrameEntries, QMap< double, double >& bottomFrameEntries )
const;
652 void drawGridFrameBorder( QPainter* p,
const QMap< double, double >& borderPos,
Border border );
653 void drawGridLine(
const QLineF& line, QPainter* p );
654 void drawOverviewMapExtent( QPainter* p );
655 void createDefaultOverviewFrameSymbol();
656 void createDefaultGridLineSymbol();
657 void initGridAnnotationFormatFromProject();
void setGridFrameWidth(double w)
Set grid frame width.
bool mAtlasFixedScale
True if map uses a fixed scale when controlled by an atlas.
int mOverviewFrameMapId
Id of map which displays its extent rectangle into this composer map (overview map functionality)...
double mXOffset
Offset in x direction for showing map cache image.
bool mGridEnabled
True if coordinate grid has to be displayed.
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...
A rectangle specified with double values.
bool mDrawing
set to true if in state of drawing.
double mGridIntervalY
Grid line interval in y-direction (map units)
double mMapRotation
Map rotation.
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc)=0
sets state from Dom document
void setGridIntervalY(double interval)
Sets coordinate interval in y-direction for composergrid.
QgsLineSymbolV2 * gridLineSymbol()
void setGridAnnotationFormat(GridAnnotationFormat f)
void setGridFrameFillColor1(const QColor &c)
Sets first fill color for grid zebra frame.
double gridIntervalX() const
virtual void setRotation(double r)
Sets the item rotation.
void setGridEnabled(bool enabled)
Enables a coordinate grid that is shown on top of this composermap.
double gridFramePenSize() const
QStringList mLayerSet
Stored layer list (used if layer live-link mKeepLayerSet is disabled)
QFont mGridAnnotationFont
Font for grid line annotation.
double atlasMargin() const
Returns the margin size (percentage) used when the map is in atlas mode.
QColor gridFrameFillColor1() const
Get first fill color for grid zebra frame.
bool mDrawCanvasItems
True if annotation items, rubber band, etc.
QStringList layerSet() const
Getter for stored layer set that is used if mKeepLayerSet is true.
void setAnnotationFontColor(const QColor &c)
Sets font color for grid annotations.
bool showGridAnnotation() const
void setGridStyle(GridStyle style)
Sets coordinate grid style to solid or cross.
A item that forms part of a map composition.
Border
Enum for different frame borders.
QPainter::CompositionMode mOverviewBlendMode
Blend mode for overview.
QGraphicsView * mMapCanvas
void setMapCanvas(QGraphicsView *canvas)
Sets canvas pointer (necessary to query and draw map canvas items)
double annotationFrameDistance() const
A non GUI class for rendering a map layer set onto a QPainter.
bool mShowGridAnnotation
True if coordinate values should be drawn.
double gridOffsetX() const
double mapRotation() const
Returns the rotation used for drawing the map within the composer item.
bool mOverviewCentered
Centering mode for overview.
GridFrameStyle mGridFrameStyle
QColor mGridFrameFillColor1
QColor mGridFramePenColor
void setGridAnnotationPrecision(int p)
Sets coordinate precision for grid annotations.
bool isDrawing() const
True if a draw is already in progress.
int mGridAnnotationPrecision
Digits after the dot.
QFont gridAnnotationFont() const
void setAtlasMargin(double margin)
Sets the margin size (percentage) used when the map is in atlas mode.
bool overviewInverted() const
Returns true if the overview frame is inverted.
virtual int type() const
return correct graphics item type.
QPainter::CompositionMode gridBlendMode() const
Returns the grid's blending mode.
Perform transforms between map coordinates and device coordinates.
QgsLineSymbolV2 * mGridLineSymbol
GridAnnotationDirection mLeftGridAnnotationDirection
Annotation direction on left side ( horizontal or vertical )
virtual void moveContent(double dx, double dy)
Move Content of item.
QColor gridFrameFillColor2() const
Get second fill color for grid zebra frame.
double mAnnotationFrameDistance
Distance between map frame and annotation.
int overviewFrameMapId() const
Returns id of overview frame (or -1 if no overfiew frame)
double gridFrameWidth() const
GridAnnotationDirection mRightGridAnnotationDirection
Annotation direction on right side ( horizontal or vertical )
QRectF mCurrentRectangle
Current bounding rectangle.
double mCrossLength
The length of the cross sides for mGridStyle Cross.
double mGridFramePenThickness
void setGridAnnotationFont(const QFont &f)
Sets font for grid annotations.
double mGridOffsetY
Grid line offset in y-direction.
QColor annotationFontColor() const
Get font color for grid annotations.
virtual void updateItem()
Updates item, with the possibility to do custom update for subclasses.
QPainter::CompositionMode overviewBlendMode() const
Returns the overview's blending mode.
bool drawCanvasItems() const
void setAnnotationFrameDistance(double d)
Sets distance between map frame and annotations.
const QgsMapRenderer * mapRenderer() const
double rotation() const
Returns the rotation used for drawing the map within the composer item.
double mYOffset
Offset in y direction for showing map cache image.
virtual void setFrameOutlineWidth(double outlineWidth)
Sets frame outline width.
QColor mGridFrameFillColor2
void setGridFrameFillColor2(const QColor &c)
Sets second fill color for grid zebra frame.
void setGridIntervalX(double interval)
Sets coordinate interval in x-direction for composergrid.
GridFrameStyle gridFrameStyle() const
bool atlasFixedScale() const
Returns true if the map uses a fixed scale when in atlas mode.
double mGridIntervalX
Grid line interval in x-direction (map units)
GridAnnotationPosition mTopGridAnnotationPosition
Annotation position for top map side (inside / outside / not shown)
void setGridFramePenSize(double w)
Set grid frame pen thickness.
bool mAtlasDriven
True if map is being controlled by an atlas.
PreviewMode
Preview style.
GridAnnotationPosition mLeftGridAnnotationPosition
Annotation position for left map side (inside / outside / not shown)
GridAnnotationFormat mGridAnnotationFormat
Graphics scene for map printing.
QColor gridFramePenColor() const
Get pen color for grid frame.
GridAnnotationFormat gridAnnotationFormat() const
Object representing map window.
GridStyle mGridStyle
Solid or crosses.
GridStyle gridStyle() const
QgsFillSymbolV2 * mOverviewFrameMapSymbol
Drawing style for overview farme.
GridAnnotationPosition mRightGridAnnotationPosition
Annotation position for right map side (inside / outside / not shown)
GridAnnotationDirection mTopGridAnnotationDirection
Annotation direction on top side ( horizontal or vertical )
PreviewMode previewMode() const
int gridAnnotationPrecision() const
void setCrossLength(double l)
Sets length of the cros segments (if grid style is cross)
virtual void zoomContent(int delta, double x, double y)
Zoom content of item.
int id() const
Get identification number.
double mAtlasMargin
Margin size for atlas driven extents (percentage of feature size)
bool mKeepLayerSet
Flag if layers to be displayed should be read from qgis canvas (true) or from stored list in mLayerSe...
bool cornerPointOnRotatedAndScaledRect(double &x, double &y, double width, double height, double rotation) const
Calculates corner point after rotation and scaling.
double mGridOffsetX
Grid line offset in x-direction.
QgsFillSymbolV2 * overviewFrameMapSymbol()
QgsMapRenderer * mMapRenderer
QgsRectangle extent() const
GridAnnotationDirection mBottomGridAnnotationDirection
Annotation direction on bottom side ( horizontal or vertical )
int mId
Unique identifier.
void setLayerSet(const QStringList &layerSet)
Setter for stored layer set that is used if mKeepLayerSet is true.
void setShowGridAnnotation(bool show)
Sets flag if grid annotation should be shown.
void setDrawCanvasItems(bool b)
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...
double gridIntervalY() const
QgsRectangle mAtlasFeatureExtent
void setAtlasFixedScale(bool fixed)
Set to true if the map should use a fixed scale when in atlas mode.
void setKeepLayerSet(bool enabled)
Setter for flag that determines if the stored layer set should be used or the current layer set of th...
double gridOffsetY() const
void setGridOffsetX(double offset)
Sets x-coordinate offset for composer grid.
bool atlasDriven() const
Returns true if the map extent is set to follow the current atlas feature.
GridAnnotationPosition mBottomGridAnnotationPosition
Annotation position for bottom map side (inside / outside / not shown)
void setAtlasDriven(bool enabled)
Set to true if the map extents should be set by the current atlas feature.
QColor mGridAnnotationFontColor
Font color for grid line annotation.
void setGridOffsetY(double offset)
Sets y-coordinate offset for composer grid.
bool keepLayerSet() const
Getter for flag that determines if the stored layer set should be used or the current layer set of th...
Represents a vector layer which manages a vector based data sets.
void setGridFrameStyle(GridFrameStyle style)
Set grid frame style (NoGridFrame or Zebra)
PreviewMode mPreviewMode
Preview style.
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const =0
stores state in Dom element
QPainter::CompositionMode mGridBlendMode
Blend mode for grid.
int mNumCachedLayers
Number of layers when cache was created.
void setGridFramePenColor(const QColor &c)
Sets pen color for grid frame.
void sizeChangedByRotation(double &width, double &height, double rotation)
Calculates width / height of the bounding box of a rotated rectangle.
bool overviewCentered() const
Returns true if the extent is forced to center on the overview.