15 #ifndef QGSLAYOUTRULER_H
16 #define QGSLAYOUTRULER_H
26 class QGraphicsLineItem;
49 QSize minimumSizeHint()
const override;
56 void setSceneTransform(
const QTransform &transform );
80 void setContextMenu( QMenu *menu );
89 void setCursorPosition( QPointF position );
93 void cursorPosChanged( QPointF );
96 void paintEvent( QPaintEvent *event )
override;
97 void mouseMoveEvent( QMouseEvent *event )
override;
98 void mousePressEvent( QMouseEvent *event )
override;
99 void mouseReleaseEvent( QMouseEvent *event )
override;
102 static const int VALID_SCALE_MULTIPLES[];
103 static const int VALID_SCALE_MAGNITUDES[];
105 Qt::Orientation mOrientation = Qt::Horizontal;
108 QTransform mTransform;
112 std::unique_ptr< QFontMetrics > mRulerFontMetrics;
114 double mScaleMinPixelsWidth = 0.0;
116 int mMinPixelsPerDivision;
117 int mPixelsBetweenLineAndText;
119 int mMinSpacingVerticalLabels;
121 int mDragGuideTolerance = 0;
123 double mDraggingGuideOldPosition = 0.0;
126 bool mCreatingGuide =
false;
127 QGraphicsLineItem *mGuideItem =
nullptr;
130 QPolygonF mGuideMarker;
132 QPointer< QMenu > mMenu;
135 int optimumScale(
double minPixelDiff,
int &magnitude,
int &multiple );
141 int optimumNumberDivisions(
double rulerScale,
int scaleMultiple );
144 void drawRotatedText( QPainter *painter, QPointF pos,
const QString &text );
151 void drawSmallDivisions( QPainter *painter,
double startPos,
int numDivisions,
double rulerScale,
double maxPos = 0 );
154 void drawMarkerPos( QPainter *painter );
156 void drawGuideMarkers( QPainter *painter,
QgsLayout *layout );
159 void drawGuideAtPos( QPainter *painter, QPoint pos );
161 void createTemporaryGuideItem();
163 QPointF convertLocalPointToLayout( QPoint localPoint )
const;
165 QPoint convertLayoutPointToLocal( QPointF layoutPoint )
const;
175 #endif // QGSLAYOUTRULER_H