QGIS API Documentation  3.6.0-Noosa (5873452)
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_sip.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 
42 class GUI_EXPORT QgsMapUnitScaleWidget : public QgsPanelWidget, private Ui::QgsMapUnitScaleWidgetBase
43 {
44  Q_OBJECT
45  Q_PROPERTY( QgsMapUnitScale mapUnitScale READ mapUnitScale WRITE setMapUnitScale NOTIFY mapUnitScaleChanged )
46 
47  public:
48 
53  QgsMapUnitScaleWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
54 
61  QgsMapUnitScale mapUnitScale() const;
62 
70  void setMapUnitScale( const QgsMapUnitScale &scale );
71 
77  void setMapCanvas( QgsMapCanvas *canvas );
78 
79  signals:
80 
85  void mapUnitScaleChanged( const QgsMapUnitScale &scale );
86 
87  private slots:
88  void configureMinComboBox();
89  void configureMaxComboBox();
90  void settingsChanged();
91 
92  private:
93 
94  bool mBlockSignals = true;
95 
96 };
97 
107 class GUI_EXPORT QgsMapUnitScaleDialog : public QDialog
108 {
109  Q_OBJECT
110  Q_PROPERTY( QgsMapUnitScale mapUnitScale READ getMapUnitScale WRITE setMapUnitScale )
111 
112  public:
113 
118  QgsMapUnitScaleDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr );
119 
125  QgsMapUnitScale getMapUnitScale() const;
126 
133  void setMapUnitScale( const QgsMapUnitScale &scale );
134 
141  void setMapCanvas( QgsMapCanvas *canvas );
142 
143  private:
144 
145  QgsMapUnitScaleWidget *mWidget = nullptr;
146 
147 };
148 
158 class GUI_EXPORT QgsUnitSelectionWidget : public QWidget, private Ui::QgsUnitSelectionWidget
159 {
160  Q_OBJECT
161 
162  public:
163 
168  QgsUnitSelectionWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
169 
175  void setUnits( const QStringList &units, int mapUnitIdx );
176 
182  void setUnits( const QgsUnitTypes::RenderUnitList &units );
183 
185  int getUnit() const { return mUnitCombo->currentIndex(); }
186 
192  QgsUnitTypes::RenderUnit unit() const;
193 
199  void setUnit( int unitIndex ) SIP_PYNAME( setUnitIndex );
200 
205  void setUnit( QgsUnitTypes::RenderUnit unit );
206 
208  QgsMapUnitScale getMapUnitScale() const { return mMapUnitScale; }
209 
211  void setMapUnitScale( const QgsMapUnitScale &scale ) { mMapUnitScale = scale; }
212 
219  void setMapCanvas( QgsMapCanvas *canvas );
220 
221  signals:
222  void changed();
223 
224  private slots:
225  void showDialog();
226  void toggleUnitRangeButton();
227  void widgetChanged( const QgsMapUnitScale &scale );
228 
229  private:
230  QgsMapUnitScale mMapUnitScale;
231  int mMapUnitIdx;
232  QgsMapCanvas *mCanvas = nullptr;
233 
234 };
235 
236 #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:46
Base class for any widget that can be shown as a inline panel.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:184
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
Gets 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:111
#define SIP_PYNAME(name)
Definition: qgis_sip.h:74