QGIS API Documentation  2.99.0-Master (37c43df)
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 
28 class QgsMapCanvas;
29 
39 class GUI_EXPORT QgsMapUnitScaleWidget : public QgsPanelWidget, private Ui::QgsMapUnitScaleWidgetBase
40 {
41  Q_OBJECT
42  Q_PROPERTY( QgsMapUnitScale mapUnitScale READ mapUnitScale WRITE setMapUnitScale NOTIFY mapUnitScaleChanged )
43 
44  public:
45 
49  QgsMapUnitScaleWidget( QWidget* parent = nullptr );
50 
56  QgsMapUnitScale mapUnitScale() const;
57 
64  void setMapUnitScale( const QgsMapUnitScale& scale );
65 
70  void setMapCanvas( QgsMapCanvas* canvas );
71 
72  signals:
73 
77  void mapUnitScaleChanged( const QgsMapUnitScale& scale );
78 
79  private slots:
80  void configureMinComboBox();
81  void configureMaxComboBox();
82  void settingsChanged();
83 
84  private:
85 
86  bool mBlockSignals;
87 
88 };
89 
98 class GUI_EXPORT QgsMapUnitScaleDialog : public QDialog
99 {
100  Q_OBJECT
101  Q_PROPERTY( QgsMapUnitScale mapUnitScale READ getMapUnitScale WRITE setMapUnitScale )
102 
103  public:
104 
108  QgsMapUnitScaleDialog( QWidget* parent = nullptr );
109 
114  QgsMapUnitScale getMapUnitScale() const;
115 
121  void setMapUnitScale( const QgsMapUnitScale& scale );
122 
128  void setMapCanvas( QgsMapCanvas* canvas );
129 
130  private:
131 
132  QgsMapUnitScaleWidget* mWidget;
133 
134 };
135 
144 class GUI_EXPORT QgsUnitSelectionWidget : public QWidget, private Ui::QgsUnitSelectionWidget
145 {
146  Q_OBJECT
147 
148  public:
149 
153  QgsUnitSelectionWidget( QWidget* parent = nullptr );
154 
159  void setUnits( const QStringList& units, int mapUnitIdx );
160 
165  void setUnits( const QgsUnitTypes::RenderUnitList& units );
166 
168  int getUnit() const { return mUnitCombo->currentIndex(); }
169 
174  QgsUnitTypes::RenderUnit unit() const;
175 
180  void setUnit( int unitIndex );
181 
185  void setUnit( QgsUnitTypes::RenderUnit unit );
186 
188  QgsMapUnitScale getMapUnitScale() const { return mMapUnitScale; }
189 
191  void setMapUnitScale( const QgsMapUnitScale& scale ) { mMapUnitScale = scale; }
192 
198  void setMapCanvas( QgsMapCanvas* canvas );
199 
200  signals:
201  void changed();
202 
203  private slots:
204  void showDialog();
205  void toggleUnitRangeButton();
206  void widgetChanged( const QgsMapUnitScale& scale );
207 
208  private:
209  QgsMapUnitScale mMapUnitScale;
210  int mMapUnitIdx;
211  QgsMapCanvas* mCanvas;
212 
213 };
214 
215 #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:102
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:106
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:91