QGIS API Documentation  2.99.0-Master (009e47e)
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 "qgis.h"
23 #include <QDialog>
24 #include "qgspanelwidget.h"
25 #include "qgssymbol.h"
26 #include "ui_qgsunitselectionwidget.h"
27 #include "ui_qgsmapunitscalewidgetbase.h"
28 #include "qgis_gui.h"
29 
30 class QgsMapCanvas;
31 
41 class GUI_EXPORT QgsMapUnitScaleWidget : public QgsPanelWidget, private Ui::QgsMapUnitScaleWidgetBase
42 {
43  Q_OBJECT
44  Q_PROPERTY( QgsMapUnitScale mapUnitScale READ mapUnitScale WRITE setMapUnitScale NOTIFY mapUnitScaleChanged )
45 
46  public:
47 
51  QgsMapUnitScaleWidget( QWidget *parent SIP_TRANSFERTHIS = 0 );
52 
58  QgsMapUnitScale mapUnitScale() const;
59 
66  void setMapUnitScale( const QgsMapUnitScale &scale );
67 
72  void setMapCanvas( QgsMapCanvas *canvas );
73 
74  signals:
75 
79  void mapUnitScaleChanged( const QgsMapUnitScale &scale );
80 
81  private slots:
82  void configureMinComboBox();
83  void configureMaxComboBox();
84  void settingsChanged();
85 
86  private:
87 
88  bool mBlockSignals;
89 
90 };
91 
100 class GUI_EXPORT QgsMapUnitScaleDialog : public QDialog
101 {
102  Q_OBJECT
103  Q_PROPERTY( QgsMapUnitScale mapUnitScale READ getMapUnitScale WRITE setMapUnitScale )
104 
105  public:
106 
110  QgsMapUnitScaleDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr );
111 
116  QgsMapUnitScale getMapUnitScale() const;
117 
123  void setMapUnitScale( const QgsMapUnitScale &scale );
124 
130  void setMapCanvas( QgsMapCanvas *canvas );
131 
132  private:
133 
134  QgsMapUnitScaleWidget *mWidget = nullptr;
135 
136 };
137 
146 class GUI_EXPORT QgsUnitSelectionWidget : public QWidget, private Ui::QgsUnitSelectionWidget
147 {
148  Q_OBJECT
149 
150  public:
151 
155  QgsUnitSelectionWidget( QWidget *parent SIP_TRANSFERTHIS = 0 );
156 
161  void setUnits( const QStringList &units, int mapUnitIdx );
162 
167  void setUnits( const QgsUnitTypes::RenderUnitList &units );
168 
170  int getUnit() const { return mUnitCombo->currentIndex(); }
171 
176  QgsUnitTypes::RenderUnit unit() const;
177 
182  void setUnit( int unitIndex ) SIP_PYNAME( setUnitIndex );
183 
187  void setUnit( QgsUnitTypes::RenderUnit unit );
188 
190  QgsMapUnitScale getMapUnitScale() const { return mMapUnitScale; }
191 
193  void setMapUnitScale( const QgsMapUnitScale &scale ) { mMapUnitScale = scale; }
194 
200  void setMapCanvas( QgsMapCanvas *canvas );
201 
202  signals:
203  void changed();
204 
205  private slots:
206  void showDialog();
207  void toggleUnitRangeButton();
208  void widgetChanged( const QgsMapUnitScale &scale );
209 
210  private:
211  QgsMapUnitScale mMapUnitScale;
212  int mMapUnitIdx;
213  QgsMapCanvas *mCanvas = nullptr;
214 
215 };
216 
217 #endif // QGSUNITSELECTIONWIDGET_H
A widget which allows the user to choose the minimum and maximum scale of an object in map units and ...
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:34
Base class for any widget that can be shown as a inline panel.
QList< QgsUnitTypes::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:73
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
#define SIP_PYNAME(name)
Definition: qgis_sip.h:62