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 );
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;
125 bool mCreatingGuide =
false;
126 QGraphicsLineItem *mGuideItem =
nullptr;
129 QPolygonF mGuideMarker;
131 QPointer< QMenu > mMenu;
134 int optimumScale(
double minPixelDiff,
int &magnitude,
int &multiple );
140 int optimumNumberDivisions(
double rulerScale,
int scaleMultiple );
143 void drawRotatedText( QPainter *painter, QPointF pos,
const QString &text );
150 void drawSmallDivisions( QPainter *painter,
double startPos,
int numDivisions,
double rulerScale,
double maxPos = 0 );
153 void drawMarkerPos( QPainter *painter );
155 void drawGuideMarkers( QPainter *painter,
QgsLayout *layout );
158 void drawGuideAtPos( QPainter *painter, QPoint pos );
160 void createTemporaryGuideItem();
162 QPointF convertLocalPointToLayout( QPoint localPoint )
const;
164 QPoint convertLayoutPointToLocal( QPointF layoutPoint )
const;
Contains the configuration for a single snap guide used by a layout.
A custom ruler widget for use with QgsLayoutView, displaying the current zoom and position of the vis...
void cursorPosChanged(QPointF)
Emitted when mouse cursor coordinates change.
QgsLayoutView * layoutView()
Returns the current layout view associated with the ruler.
int rulerSize() const
Returns the ruler size (either the height of a horizontal ruler or the width of a vertical rule).
A graphical widget to display and interact with QgsLayouts.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.