QGIS API Documentation  2.99.0-Master (314842d)
qgsunitselectionwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsunitselectionwidget.h
3  -------------------
4  begin : Mar 24, 2014
5  copyright : (C) 2014 Sandro Mani
6  email : [email protected]
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 #ifndef QGSUNITSELECTIONWIDGET_H
19 #define QGSUNITSELECTIONWIDGET_H
20 
21 #include <QWidget>
22 #include <QDialog>
23 #include "qgspanelwidget.h"
24 #include "qgssymbol.h"
25 #include "ui_qgsunitselectionwidget.h"
26 #include "ui_qgsmapunitscalewidgetbase.h"
27 #include "qgis_gui.h"
28 
29 class QgsMapCanvas;
30 
40 class GUI_EXPORT QgsMapUnitScaleWidget : public QgsPanelWidget, private Ui::QgsMapUnitScaleWidgetBase
41 {
42  Q_OBJECT
43  Q_PROPERTY( QgsMapUnitScale mapUnitScale READ mapUnitScale WRITE setMapUnitScale NOTIFY mapUnitScaleChanged )
44 
45  public:
46 
50  QgsMapUnitScaleWidget( QWidget *parent = nullptr );
51 
57  QgsMapUnitScale mapUnitScale() const;
58 
65  void setMapUnitScale( const QgsMapUnitScale &scale );
66 
71  void setMapCanvas( QgsMapCanvas *canvas );
72 
73  signals:
74 
78  void mapUnitScaleChanged( const QgsMapUnitScale &scale );
79 
80  private slots:
81  void configureMinComboBox();
82  void configureMaxComboBox();
83  void settingsChanged();
84 
85  private:
86 
87  bool mBlockSignals;
88 
89 };
90 
99 class GUI_EXPORT QgsMapUnitScaleDialog : public QDialog
100 {
101  Q_OBJECT
102  Q_PROPERTY( QgsMapUnitScale mapUnitScale READ getMapUnitScale WRITE setMapUnitScale )
103 
104  public:
105 
109  QgsMapUnitScaleDialog( QWidget *parent = nullptr );
110 
115  QgsMapUnitScale getMapUnitScale() const;
116 
122  void setMapUnitScale( const QgsMapUnitScale &scale );
123 
129  void setMapCanvas( QgsMapCanvas *canvas );
130 
131  private:
132 
133  QgsMapUnitScaleWidget *mWidget = nullptr;
134 
135 };
136 
145 class GUI_EXPORT QgsUnitSelectionWidget : public QWidget, private Ui::QgsUnitSelectionWidget
146 {
147  Q_OBJECT
148 
149  public:
150 
154  QgsUnitSelectionWidget( QWidget *parent = nullptr );
155 
160  void setUnits( const QStringList &units, int mapUnitIdx );
161 
166  void setUnits( const QgsUnitTypes::RenderUnitList &units );
167 
169  int getUnit() const { return mUnitCombo->currentIndex(); }
170 
175  QgsUnitTypes::RenderUnit unit() const;
176 
181  void setUnit( int unitIndex );
182 
186  void setUnit( QgsUnitTypes::RenderUnit unit );
187 
189  QgsMapUnitScale getMapUnitScale() const { return mMapUnitScale; }
190 
192  void setMapUnitScale( const QgsMapUnitScale &scale ) { mMapUnitScale = scale; }
193 
199  void setMapCanvas( QgsMapCanvas *canvas );
200 
201  signals:
202  void changed();
203 
204  private slots:
205  void showDialog();
206  void toggleUnitRangeButton();
207  void widgetChanged( const QgsMapUnitScale &scale );
208 
209  private:
210  QgsMapUnitScale mMapUnitScale;
211  int mMapUnitIdx;
212  QgsMapCanvas *mCanvas = nullptr;
213 
214 };
215 
216 #endif // QGSUNITSELECTIONWIDGET_H
A widget which allows the user to choose the minimum and maximum scale of an object in map units and ...
Base class for any widget that can be shown as a inline panel.
QList< RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:145
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:72
A dialog which allows the user to choose the minimum and maximum scale of an object in map units and ...
void setMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale.
QgsMapUnitScale getMapUnitScale() const
Returns the map unit scale.
Struct for storing maximum and minimum scales for measurements in map units.
int getUnit() const
Get the selected unit index.
A widget displaying a combobox allowing the user to choose between various display units...
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:95