/
qgsadvanceddigitizingfloater.h
173 lines (147 loc) · 5.5 KB
/
qgsadvanceddigitizingfloater.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/***************************************************************************
qgsadvanceddigitizingfloater.cpp - floater for CAD tools
----------------------
begin : May 2019
copyright : (C) Olivier Dalang
email : olivier.dalang@gmail.com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSADVANCEDDIGITIZINGFLOATER
#define QGSADVANCEDDIGITIZINGFLOATER
#include <QWidget>
#include <QString>
#include "ui_qgsadvanceddigitizingfloaterbase.h"
#include "qgsadvanceddigitizingdockwidget.h"
#include "qgis_gui.h"
#include "qgis_sip.h"
#include <QPointer>
class QgsMapCanvas;
class QgsAdvancedDigitizingDockWidget;
/**
* \ingroup gui
* \brief The QgsAdvancedDigitizingFloater class is widget that floats
* next to the mouse pointer, and allow interaction with the AdvancedDigitizing
* feature. It proxies display and actions to QgsMapToolAdvancedDigitizingDockWidget.
* \note This class is a technology preview and unstable API.
* \since QGIS 3.8
*/
class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsAdvancedDigitizingFloaterBase
{
Q_OBJECT
public:
//! Available floater items
enum class FloaterItem : int
{
XCoordinate = 1 << 1,
YCoordinate = 1 << 2,
MCoordinate = 1 << 3,
ZCoordinate = 1 << 4,
Angle = 1 << 5,
CommonAngleSnapping = 1 << 6,
Distance = 1 << 7,
Bearing = 1 << 8,
};
Q_DECLARE_FLAGS( FloaterItems, FloaterItem )
Q_FLAG( FloaterItem )
/**
* Create an advanced digitizing floater widget
* \param canvas The map canvas on which the widget operates
* \param cadDockWidget The cadDockWidget to which the floater belongs
* \since QGIS 3.8
*/
explicit QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget );
/**
* Whether the floater is active or not.
* Note that the floater may be active but not visible (e.g. if the mouse is not over the canvas).
* \since QGIS 3.8
*/
bool active();
/**
* Returns TRUE if the floater \a item visibility setting is enabled.
*
* \param item floater item
* \since QGIS 3.32
*/
bool itemVisibility( const QgsAdvancedDigitizingFloater::FloaterItem &item ) const;
public slots:
/**
* Set whether the floater should be active or not.
* Note that the floater may be active but not visible (e.g. if the mouse is not over the canvas).
*
* \param active
* \since QGIS 3.8
*/
void setActive( bool active );
/**
* Set whether the floater \a item should be visible or not.
*
* \param item floater item
* \param visible
* \since QGIS 3.32
*/
void setItemVisibility( const QgsAdvancedDigitizingFloater::FloaterItem &item, bool visible );
private slots:
void changeX( const QString &text );
void changeY( const QString &text );
void changeZ( const QString &text );
void changeM( const QString &text );
void changeCommonAngleSnapping( double angle );
void changeDistance( const QString &text );
void changeAngle( const QString &text );
void changeBearing( const QString &text );
void changeLockX( bool locked );
void changeLockY( bool locked );
void changeLockZ( bool locked );
void changeLockM( bool locked );
void changeLockDistance( bool locked );
void changeLockAngle( bool locked );
void changeRelativeX( bool relative );
void changeRelativeY( bool relative );
void changeRelativeZ( bool relative );
void changeRelativeM( bool relative );
// void changeRelativeDistance( bool relative ); // doesn't happen
void changeRelativeAngle( bool relative );
void focusOnX();
void focusOnY();
void focusOnZ();
void focusOnM();
void focusOnAngle();
void focusOnDistance();
void enabledChangedX( bool enabled );
void enabledChangedY( bool enabled );
void enabledChangedZ( bool enabled );
void enabledChangedM( bool enabled );
void enabledChangedAngle( bool enabled );
void enabledChangedDistance( bool enabled );
void enabledCommonAngleSnapping( bool enabled );
void enabledChangedBearing( bool enabled );
private:
//! pointer to map canvas
QgsMapCanvas *mMapCanvas = nullptr;
//! pointer to map cad docker widget
QPointer< QgsAdvancedDigitizingDockWidget > mCadDockWidget;
/**
* event filter to track mouse position
* \note defined as private in Python bindings
*/
bool eventFilter( QObject *obj, QEvent *event ) override SIP_FORCE;
/**
* Move the widget to a new cursor position. A hard-coded offset will be added.
* \param pos position of the cursor
*/
void updatePos( const QPoint &pos );
/**
* Hides the widget if either the floater or the cadDockWidget is disabled.
*/
void hideIfDisabled();
//! Whether the floater is enabled.
bool mActive = false;
FloaterItems mItemsVisibility;
};
#endif // QGSADVANCEDDIGITIZINGFLOATER_H