/
qgsadvanceddigitizingfloater.h
128 lines (107 loc) · 4.17 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
/***************************************************************************
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"
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:
/**
* 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();
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 );
private slots:
void changeX( const QString &text );
void changeY( const QString &text );
void changeDistance( const QString &text );
void changeAngle( const QString &text );
void changeLockX( bool locked );
void changeLockY( bool locked );
void changeLockDistance( bool locked );
void changeLockAngle( bool locked );
void changeRelativeX( bool relative );
void changeRelativeY( bool relative );
// void changeRelativeDistance( bool relative ); // doesn't happen
void changeRelativeAngle( bool relative );
void focusOnX();
void focusOnY();
void focusOnAngle();
void focusOnDistance();
void enabledChangedX( bool enabled );
void enabledChangedY( bool enabled );
void enabledChangedAngle( bool enabled );
void enabledChangedDistance( bool enabled );
private:
//! pointer to map canvas
QgsMapCanvas *mMapCanvas = nullptr;
//! pointer to map cad docker widget
QgsAdvancedDigitizingDockWidget *mCadDockWidget = nullptr;
/**
* event filter to track mouse position
* \note defined as private in Python bindings
*/
bool eventFilter( QObject *obj, QEvent *event ) override SIP_SKIP;
/**
* 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;
private:
#ifdef SIP_RUN
//! event filter to track mouse position
bool eventFilter( QObject *obj, QEvent *event );
#endif
};
#endif // QGSADVANCEDDIGITIZINGFLOATER_H