QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
layout
qgslayoutruler.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgslayoutruler.h
3
----------------
4
Date : July 2017
5
Copyright : (C) 2017 Nyall Dawson
6
Email : nyall dot dawson at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
#ifndef QGSLAYOUTRULER_H
16
#define QGSLAYOUTRULER_H
17
18
#include <memory>
19
20
#include "qgis_gui.h"
21
#include "
qgis_sip.h
"
22
23
#include <QMenu>
24
#include <QPointer>
25
#include <QWidget>
26
27
class
QgsLayout
;
28
class
QGraphicsLineItem;
29
class
QgsLayoutView
;
30
class
QgsLayoutGuide
;
31
39
class
GUI_EXPORT
QgsLayoutRuler
:
public
QWidget
40
{
41
Q_OBJECT
42
43
public
:
47
explicit
QgsLayoutRuler
( QWidget *parent
SIP_TRANSFERTHIS
=
nullptr
, Qt::Orientation orientation = Qt::Horizontal );
48
49
QSize
minimumSizeHint
()
const override
;
50
56
void
setSceneTransform
(
const
QTransform &transform );
57
62
QgsLayoutView
*
layoutView
() {
return
mView; }
63
68
void
setLayoutView(
QgsLayoutView
*view );
69
74
int
rulerSize
()
const
{
return
mRulerMinSize; }
75
80
void
setContextMenu( QMenu *menu );
81
82
public
slots:
83
89
void
setCursorPosition( QPointF position );
90
91
signals:
93
void
cursorPosChanged
( QPointF position );
94
95
protected
:
96
void
paintEvent
( QPaintEvent *event )
override
;
97
void
mouseMoveEvent
( QMouseEvent *event )
override
;
98
void
mousePressEvent
( QMouseEvent *event )
override
;
99
void
mouseReleaseEvent
( QMouseEvent *event )
override
;
100
101
private
:
102
static
const
int
VALID_SCALE_MULTIPLES[];
103
static
const
int
VALID_SCALE_MAGNITUDES[];
104
105
Qt::Orientation mOrientation = Qt::Horizontal;
106
QgsLayoutView
*mView =
nullptr
;
107
108
QTransform mTransform;
109
QPoint mMarkerPos;
110
111
QFont mRulerFont;
112
std::unique_ptr<QFontMetrics> mRulerFontMetrics;
113
114
double
mScaleMinPixelsWidth = 0.0;
115
int
mRulerMinSize;
116
int
mMinPixelsPerDivision;
117
int
mPixelsBetweenLineAndText;
118
int
mTextBaseline;
119
int
mMinSpacingVerticalLabels;
120
121
int
mDragGuideTolerance = 0;
122
QgsLayoutGuide
*mDraggingGuide =
nullptr
;
123
double
mDraggingGuideOldPosition = 0.0;
124
QgsLayoutGuide
*mHoverGuide =
nullptr
;
125
126
bool
mCreatingGuide =
false
;
127
QGraphicsLineItem *mGuideItem =
nullptr
;
128
130
QPolygonF mGuideMarker;
131
132
QPointer<QMenu> mMenu;
133
135
int
optimumScale(
double
minPixelDiff,
int
&magnitude,
int
&multiple );
136
141
int
optimumNumberDivisions(
double
rulerScale,
int
scaleMultiple );
142
144
void
drawRotatedText( QPainter *painter, QPointF pos,
const
QString &text );
145
151
void
drawSmallDivisions( QPainter *painter,
double
startPos,
int
numDivisions,
double
rulerScale,
double
maxPos = 0 );
152
154
void
drawMarkerPos( QPainter *painter );
155
156
void
drawGuideMarkers( QPainter *painter,
QgsLayout
*layout );
157
159
void
drawGuideAtPos( QPainter *painter, QPoint pos );
160
161
void
createTemporaryGuideItem();
162
163
QPointF convertLocalPointToLayout( QPoint localPoint )
const
;
164
165
QPoint convertLayoutPointToLocal( QPointF layoutPoint )
const
;
166
171
QgsLayoutGuide
*guideAtPoint( QPoint localPoint )
const
;
172
};
173
174
#endif
// QGSLAYOUTRULER_H
QgsLayoutGuide
Contains the configuration for a single snap guide used by a layout.
Definition
qgslayoutguidecollection.h:47
QgsLayoutRuler::cursorPosChanged
void cursorPosChanged(QPointF position)
Emitted when mouse cursor coordinates change.
QgsLayoutRuler::paintEvent
void paintEvent(QPaintEvent *event) override
Definition
qgslayoutruler.cpp:88
QgsLayoutRuler::layoutView
QgsLayoutView * layoutView()
Returns the current layout view associated with the ruler.
Definition
qgslayoutruler.h:62
QgsLayoutRuler::rulerSize
int rulerSize() const
Returns the ruler size (either the height of a horizontal ruler or the width of a vertical rule).
Definition
qgslayoutruler.h:74
QgsLayoutRuler::setSceneTransform
void setSceneTransform(const QTransform &transform)
Sets the current scene transform.
Definition
qgslayoutruler.cpp:564
QgsLayoutRuler::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) override
Definition
qgslayoutruler.cpp:727
QgsLayoutRuler::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event) override
Definition
qgslayoutruler.cpp:587
QgsLayoutRuler::QgsLayoutRuler
QgsLayoutRuler(QWidget *parent=nullptr, Qt::Orientation orientation=Qt::Horizontal)
Constructor for QgsLayoutRuler, with the specified parent widget and orientation.
Definition
qgslayoutruler.cpp:43
QgsLayoutRuler::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition
qgslayoutruler.cpp:692
QgsLayoutRuler::minimumSizeHint
QSize minimumSizeHint() const override
Definition
qgslayoutruler.cpp:83
QgsLayoutView
A graphical widget to display and interact with QgsLayouts.
Definition
qgslayoutview.h:52
QgsLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition
qgslayout.h:51
qgis_sip.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
Generated on
for QGIS API Documentation by
1.17.0