QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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
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 "qgsmapunitscale.h"
26#include "qgsunittypes.h"
27
28#include "ui_qgsunitselectionwidget.h"
29#include "ui_qgsmapunitscalewidgetbase.h"
30#include "qgis_gui.h"
31
32class QgsMapCanvas;
33
43class GUI_EXPORT QgsMapUnitScaleWidget : public QgsPanelWidget, private Ui::QgsMapUnitScaleWidgetBase
44{
45 Q_OBJECT
46 Q_PROPERTY( QgsMapUnitScale mapUnitScale READ mapUnitScale WRITE setMapUnitScale NOTIFY mapUnitScaleChanged )
47
48 public:
49
54 QgsMapUnitScaleWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
55
62 QgsMapUnitScale mapUnitScale() const;
63
71 void setMapUnitScale( const QgsMapUnitScale &scale );
72
78 void setMapCanvas( QgsMapCanvas *canvas );
79
80 signals:
81
87
88 private slots:
89 void configureMinComboBox();
90 void configureMaxComboBox();
91 void settingsChanged();
92
93 private:
94
95 bool mBlockSignals = true;
96
97};
98
108class GUI_EXPORT QgsMapUnitScaleDialog : public QDialog
109{
110 Q_OBJECT
111 Q_PROPERTY( QgsMapUnitScale mapUnitScale READ getMapUnitScale WRITE setMapUnitScale )
112
113 public:
114
119 QgsMapUnitScaleDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr );
120
126 QgsMapUnitScale getMapUnitScale() const;
127
134 void setMapUnitScale( const QgsMapUnitScale &scale );
135
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
163class 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
186 void setUnits( const QgsUnitTypes::RenderUnitList &units );
187
189 int getUnit() const { return mUnitCombo->currentIndex(); }
190
195 Qgis::RenderUnit unit() const;
196
202 void setUnit( int unitIndex ) SIP_PYNAME( setUnitIndex );
203
208 void setUnit( Qgis::RenderUnit unit );
209
211 QgsMapUnitScale getMapUnitScale() const { return mMapUnitScale; }
212
214 void setMapUnitScale( const QgsMapUnitScale &scale ) { mMapUnitScale = scale; }
215
221 void setMapCanvas( QgsMapCanvas *canvas );
222
229 bool showMapScaleButton() const;
230
237 void setShowMapScaleButton( bool show );
238
239 signals:
240 void changed();
241
242 private slots:
243 void showDialog();
244 void toggleUnitRangeButton();
245 void widgetChanged( const QgsMapUnitScale &scale );
246
247 private:
248 QgsMapUnitScale mMapUnitScale;
249 int mMapUnitIdx;
250 QgsMapCanvas *mCanvas = nullptr;
251 bool mShowMapScaleButton = true;
252
253};
254
255#endif // QGSUNITSELECTIONWIDGET_H
RenderUnit
Rendering size units.
Definition: qgis.h:4255
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:93
A dialog which allows the user to choose the minimum and maximum scale of an object in map units and ...
A widget which allows the user to choose the minimum and maximum scale of an object in map units and ...
void mapUnitScaleChanged(const QgsMapUnitScale &scale)
Emitted when the settings in the widget are modified.
Struct for storing maximum and minimum scales for measurements in map units.
Base class for any widget that can be shown as a inline panel.
void widgetChanged()
Emitted when the widget state changes.
A widget displaying a combobox allowing the user to choose between various display units,...
QgsMapUnitScale getMapUnitScale() const
Returns the map unit scale.
int getUnit() const
Gets the selected unit index.
void setMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale.
QList< Qgis::RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:81
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_PYNAME(name)
Definition: qgis_sip.h:81