QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 slots:
144 
145  void showHelp();
146 
147 
148  private:
149 
150  QgsMapUnitScaleWidget *mWidget = nullptr;
151 
152 };
153 
163 class GUI_EXPORT QgsUnitSelectionWidget : public QWidget, private Ui::QgsUnitSelectionWidget
164 {
165  Q_OBJECT
166 
167  public:
168 
173  QgsUnitSelectionWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
174 
180  void setUnits( const QStringList &units, int mapUnitIdx );
181 
187  void setUnits( const QgsUnitTypes::RenderUnitList &units );
188 
190  int getUnit() const { return mUnitCombo->currentIndex(); }
191 
197  QgsUnitTypes::RenderUnit unit() const;
198 
204  void setUnit( int unitIndex ) SIP_PYNAME( setUnitIndex );
205 
210  void setUnit( QgsUnitTypes::RenderUnit unit );
211 
213  QgsMapUnitScale getMapUnitScale() const { return mMapUnitScale; }
214 
216  void setMapUnitScale( const QgsMapUnitScale &scale ) { mMapUnitScale = scale; }
217 
224  void setMapCanvas( QgsMapCanvas *canvas );
225 
226  signals:
227  void changed();
228 
229  private slots:
230  void showDialog();
231  void toggleUnitRangeButton();
232  void widgetChanged( const QgsMapUnitScale &scale );
233 
234  private:
235  QgsMapUnitScale mMapUnitScale;
236  int mMapUnitIdx;
237  QgsMapCanvas *mCanvas = nullptr;
238 
239 };
240 
241 #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:53
Base class for any widget that can be shown as a inline panel.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:218
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:75
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.
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:145
#define SIP_PYNAME(name)
Definition: qgis_sip.h:81