18 #ifndef QGSCOMPOSERMAPGRID_H 19 #define QGSCOMPOSERMAPGRID_H 72 void removeGrid(
const QString& gridId );
80 void moveGridUp(
const QString& gridId );
88 void moveGridDown(
const QString& gridId );
122 QList< QgsComposerMapGrid* >
asList()
const;
130 bool readXML(
const QDomElement& elem,
const QDomDocument& doc )
override;
136 double maxGridExtension()
const;
218 DegreeMinuteSecondPadded
273 void draw( QPainter* painter )
override;
280 bool writeXML( QDomElement& elem, QDomDocument & doc )
const override;
287 bool readXML(
const QDomElement& itemElem,
const QDomDocument& doc )
override;
305 void setBlendMode(
const QPainter::CompositionMode mode ) { mBlendMode = mode; }
311 QPainter::CompositionMode
blendMode()
const {
return mBlendMode; }
319 double maxExtension()
const;
330 void setUnits(
const GridUnit unit );
345 void setIntervalX(
const double interval );
361 void setIntervalY(
const double interval );
377 void setOffsetX(
const double offset );
385 double offsetX()
const {
return mGridOffsetX; }
393 void setOffsetY(
const double offset );
401 double offsetY()
const {
return mGridOffsetY; }
442 void setGridLineWidth(
const double width );
451 void setGridLineColor(
const QColor& color );
677 void setFrameSideFlags(
const FrameSideFlags flags );
686 void setFrameSideFlag(
const FrameSideFlag flag,
bool on =
true );
695 FrameSideFlags frameSideFlags()
const;
792 bool mTransformDirty;
797 double mGridIntervalX;
799 double mGridIntervalY;
805 QFont mGridAnnotationFont;
807 QColor mGridAnnotationFontColor;
809 int mGridAnnotationPrecision;
811 bool mShowGridAnnotation;
832 double mAnnotationFrameDistance;
844 FrameSideFlags mGridFrameSides;
845 double mGridFrameWidth;
846 double mGridFramePenThickness;
847 QColor mGridFramePenColor;
848 QColor mGridFrameFillColor1;
849 QColor mGridFrameFillColor2;
868 QPainter::CompositionMode mBlendMode;
870 QList< QPair< double, QPolygonF > > mTransformedXLines;
871 QList< QPair< double, QPolygonF > > mTransformedYLines;
872 QList< QgsPoint > mTransformedIntersections;
873 QRectF mPrevPaintRect;
874 QPolygonF mPrevMapPolygon;
876 class QgsMapAnnotation
880 QPointF itemPosition;
887 void drawGridFrame( QPainter* p,
const QList< QPair< double, QLineF > >& hLines,
const QList< QPair< double, QLineF > >& vLines )
const;
893 void drawCoordinateAnnotations( QPainter* p,
const QList< QPair< double, QLineF > >& hLines,
const QList< QPair< double, QLineF > >& vLines )
const;
895 void drawCoordinateAnnotation( QPainter* p,
const QPointF& pos, QString annotationString,
const AnnotationCoordinate coordinateType )
const;
903 void drawAnnotation( QPainter* p,
const QPointF& pos,
int rotation,
const QString& annotationText )
const;
909 int xGridLines( QList< QPair< double, QLineF > >& lines )
const;
913 int yGridLines( QList< QPair< double, QLineF > >& lines )
const;
921 void drawGridLine(
const QPolygonF& line,
QgsRenderContext &context )
const;
923 void sortGridLinesOnBorders(
const QList< QPair< double, QLineF > >& hLines,
const QList< QPair< double, QLineF > >& vLines, QMap< double, double >& leftFrameEntries,
924 QMap< double, double >& rightFrameEntries, QMap< double, double >& topFrameEntries, QMap< double, double >& bottomFrameEntries )
const;
926 void drawGridFrameBorder( QPainter* p,
const QMap< double, double >& borderPos,
BorderSide border )
const;
937 static QList<QPolygonF> trimLinesToMap(
const QPolygonF &line,
const QgsRectangle &rect );
939 QPolygonF scalePolygon(
const QPolygonF &polygon,
const double scale )
const;
942 void drawGridCRSTransform(
QgsRenderContext &context,
double dotsPerMM, QList< QPair< double, QLineF > > &horizontalLines,
943 QList< QPair< double, QLineF > > &verticalLines );
945 void drawGridNoTransform(
QgsRenderContext &context,
double dotsPerMM, QList<QPair<double, QLineF> > &horizontalLines, QList<QPair<double, QLineF> > &verticalLines )
const;
947 void createDefaultGridLineSymbol();
949 void createDefaultGridMarkerSymbol();
951 void drawGridMarker(
const QPointF &point,
QgsRenderContext &context )
const;
953 void drawGridFrameZebraBorder( QPainter *p,
const QMap<double, double> &borderPos,
BorderSide border )
const;
955 void drawGridFrameTicks( QPainter *p,
const QMap<double, double> &borderPos,
BorderSide border )
const;
957 void drawGridFrameLineBorder( QPainter *p,
BorderSide border )
const;
959 void calculateCRSTransformLines();
964 friend class TestQgsComposerMapGrid;
967 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsComposerMapGrid::FrameSideFlags )
969 #endif // QGSCOMPOSERMAPGRID_H QColor frameFillColor1() const
Retrieves the first fill color for the grid frame.
A rectangle specified with double values.
const QgsMarkerSymbolV2 * markerSymbol() const
Gets the marker symbol used for drawing grid points.
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.
GridStyle
Grid drawing style.
virtual void draw(QPainter *painter)=0
Draws the item on to a painter.
const QgsLineSymbolV2 * lineSymbol() const
Gets the line symbol used for drawing grid lines.
void setFramePenSize(const double width)
Sets the width of the outline drawn in the grid frame.
A collection of grids which is drawn above the map content in a QgsComposerMap.
FrameStyle
Style for grid frame.
double annotationFrameDistance() const
Gets the distance between the map frame and annotations.
QColor frameFillColor2() const
Retrieves the second fill color for the grid frame.
FrameStyle frameStyle() const
Gets the grid frame style.
void setAnnotationFont(const QFont &font)
Sets the font used for drawing grid annotations.
QColor framePenColor() const
Retrieves the color of the outline drawn in the grid frame.
AnnotationDirection
Direction of grid annotations.
QgsMarkerSymbolV2 * markerSymbol()
Gets the marker symbol used for drawing grid points.
AnnotationFormat annotationFormat() const
Gets the format for drawing grid annotations.
AnnotationFormat
Format for displaying grid annotations.
An item which is drawn inside a QgsComposerMap, eg a grid or map overview.
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.
QList< QgsComposerMapItem * > asList() const
Returns a list of QgsComposerMapItems contained by the stack.
DisplayMode
Display settings for grid annotations and frames.
void setAnnotationFormat(const AnnotationFormat format)
Sets the format for drawing grid annotations.
AnnotationPosition
Position for grid annotations.
double offsetX() const
Gets the offset for grid lines in the x-direction.
void setAnnotationEnabled(const bool enabled)
Sets whether annotations should be shown for the grid.
QgsComposerMapItem & operator[](int idx)
Returns a reference to an item within the stack.
GridStyle style() const
Gets the grid's style, which controls how the grid is drawn over the map's contents.
FrameSideFlag
Flags for controlling which side of the map a frame is drawn on.
An individual grid which is drawn above the map content in a QgsComposerMap.
QgsLineSymbolV2 * lineSymbol()
Gets the line symbol used for drawing grid lines.
double offsetY() const
Gets the offset for grid lines in the y-direction.
double framePenSize() const
Retrieves the width of the outline drawn in the grid frame.
GridUnit units() const
Gets the units used for grid measurements such as the interval and offset for grid lines...
void setFrameWidth(const double width)
Sets the grid frame width.
void setAnnotationFontColor(const QColor &color)
Sets the font color used for drawing grid annotations.
Object representing map window.
BorderSide
Border sides for annotations.
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.
int annotationPrecision() const
Returns the coordinate precision for grid annotations.
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the grid.
virtual bool enabled() const
Returns whether the item will be drawn.
QColor annotationFontColor() const
Gets the font color used for drawing grid annotations.
Contains information about the context of a rendering operation.
A collection of map items which are drawn above the map content in a QgsComposerMap.
Class for storing a coordinate reference system (CRS)
void setAnnotationPrecision(const int precision)
Sets the coordinate precision for grid annotations.
bool annotationEnabled() const
Gets whether annotations are shown for the grid.
double crossLength() const
Retrieves the length of the cross segments drawn for the grid.
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
Sets map item state from a DOM document.
virtual bool usesAdvancedEffects() const
Returns true if the item is drawn using advanced effects, such as blend modes.
void setFrameFillColor2(const QColor &color)
Sets the second fill color used for the grid frame.
void setFrameStyle(const FrameStyle style)
Sets the grid frame style.
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const override
Stores map item state in DOM element.
virtual bool readXML(const QDomElement &elem, const QDomDocument &doc)=0
Sets the item stack's state from a DOM document.
QgsCoordinateReferenceSystem crs() const
Retrieves the CRS for the grid.
GridUnit
Unit for grid values.
AnnotationCoordinate
Annotation coordinate type.
void setAnnotationFrameDistance(const double distance)
Sets the distance between the map frame and annotations.
double frameWidth() const
Gets the grid frame width.