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
252 Q_DECLARE_FLAGS( FrameSideFlags, FrameSideFlag )
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; }
412 void setStyle(
const GridStyle style );
442 void setGridLineWidth(
const double width );
451 void setGridLineColor(
const QColor& color );
566 void setAnnotationDisplay(
const DisplayMode display,
const BorderSide border );
576 DisplayMode annotationDisplay(
const BorderSide border )
const;
584 void setAnnotationPosition(
const AnnotationPosition position,
const BorderSide border );
592 AnnotationPosition annotationPosition(
const BorderSide border )
const;
611 void setAnnotationDirection(
const AnnotationDirection direction,
const BorderSide border );
617 void setAnnotationDirection(
const AnnotationDirection direction );
624 AnnotationDirection annotationDirection(
const BorderSide border )
const;
660 void setFrameDivisions(
const DisplayMode divisions,
const BorderSide border );
668 DisplayMode frameDivisions(
const BorderSide border )
const;
677 void setFrameSideFlags(
const FrameSideFlags flags );
686 void setFrameSideFlag(
const FrameSideFlag flag,
bool on =
true );
695 FrameSideFlags frameSideFlags()
const;
705 bool testFrameSideFlag(
const FrameSideFlag flag )
const;
792 bool mTransformDirty;
795 GridStyle mGridStyle;
797 double mGridIntervalX;
799 double mGridIntervalY;
805 QFont mGridAnnotationFont;
807 QColor mGridAnnotationFontColor;
809 int mGridAnnotationPrecision;
811 bool mShowGridAnnotation;
814 DisplayMode mLeftGridAnnotationDisplay;
816 DisplayMode mRightGridAnnotationDisplay;
818 DisplayMode mTopGridAnnotationDisplay;
820 DisplayMode mBottomGridAnnotationDisplay;
823 AnnotationPosition mLeftGridAnnotationPosition;
825 AnnotationPosition mRightGridAnnotationPosition;
827 AnnotationPosition mTopGridAnnotationPosition;
829 AnnotationPosition mBottomGridAnnotationPosition;
832 double mAnnotationFrameDistance;
835 AnnotationDirection mLeftGridAnnotationDirection;
837 AnnotationDirection mRightGridAnnotationDirection;
839 AnnotationDirection mTopGridAnnotationDirection;
841 AnnotationDirection mBottomGridAnnotationDirection;
842 AnnotationFormat mGridAnnotationFormat;
843 FrameStyle mGridFrameStyle;
844 FrameSideFlags mGridFrameSides;
845 double mGridFrameWidth;
846 double mGridFramePenThickness;
847 QColor mGridFramePenColor;
848 QColor mGridFrameFillColor1;
849 QColor mGridFrameFillColor2;
853 DisplayMode mLeftFrameDivisions;
855 DisplayMode mRightFrameDivisions;
857 DisplayMode mTopFrameDivisions;
859 DisplayMode mBottomFrameDivisions;
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;
905 QString gridAnnotationString(
double value, AnnotationCoordinate coord )
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;
932 BorderSide borderForLineCoord(
const QPointF& p,
const AnnotationCoordinate coordinateType )
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