QGIS API Documentation 3.43.0-Master (32433f7016e)
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 : smani@sourcepole.ch
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
44class GUI_EXPORT QgsMapUnitScaleWidget : public QgsPanelWidget, private Ui::QgsMapUnitScaleWidgetBase
45{
46 Q_OBJECT
47 Q_PROPERTY( QgsMapUnitScale mapUnitScale READ mapUnitScale WRITE setMapUnitScale NOTIFY mapUnitScaleChanged )
48
49 public:
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 bool mBlockSignals = true;
95};
96
107class GUI_EXPORT QgsMapUnitScaleDialog : public QDialog
108{
109 Q_OBJECT
110 Q_PROPERTY( QgsMapUnitScale mapUnitScale READ getMapUnitScale WRITE setMapUnitScale )
111
112 public:
117 QgsMapUnitScaleDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr );
118
124 QgsMapUnitScale getMapUnitScale() const;
125
132 void setMapUnitScale( const QgsMapUnitScale &scale );
133
139 void setMapCanvas( QgsMapCanvas *canvas );
140
141 private slots:
142
143 void showHelp();
144
145
146 private:
147 QgsMapUnitScaleWidget *mWidget = nullptr;
148};
149
161class GUI_EXPORT QgsUnitSelectionWidget : public QWidget, private Ui::QgsUnitSelectionWidget
162{
163 Q_OBJECT
164
165 public:
170 QgsUnitSelectionWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
171
177 void setUnits( const QStringList &units, int mapUnitIdx );
178
183 void setUnits( const QgsUnitTypes::RenderUnitList &units );
184
186 int getUnit() const { return mUnitCombo->currentIndex(); }
187
192 Qgis::RenderUnit unit() const;
193
199 void setUnit( int unitIndex ) SIP_PYNAME( setUnitIndex );
200
205 void setUnit( Qgis::RenderUnit unit );
206
208 QgsMapUnitScale getMapUnitScale() const { return mMapUnitScale; }
209
211 void setMapUnitScale( const QgsMapUnitScale &scale ) { mMapUnitScale = scale; }
212
218 void setMapCanvas( QgsMapCanvas *canvas );
219
226 bool showMapScaleButton() const;
227
234 void setShowMapScaleButton( bool show );
235
236 signals:
237
241 void changed();
242
243 private slots:
244 void showDialog();
245 void toggleUnitRangeButton();
246 void widgetChanged( const QgsMapUnitScale &scale );
247
248 private:
249 QgsMapUnitScale mMapUnitScale;
250 int mMapUnitIdx;
251 QgsMapCanvas *mCanvas = nullptr;
252 bool mShowMapScaleButton = true;
253};
254
255#endif // QGSUNITSELECTIONWIDGET_H
RenderUnit
Rendering size units.
Definition qgis.h:5013
Map canvas is a class for displaying all GIS data types on a canvas.
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 an inline panel.
void widgetChanged()
Emitted when the widget state changes.
A widget displaying a combobox allowing the user to choose between various display units,...
void changed()
Emitted when the selected unit is changed, or the definition of the map unit scale is changed.
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.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_PYNAME(name)
Definition qgis_sip.h:81