QGIS API Documentation 3.27.0-Master (1d7a28cfd2)
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
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:
50
55 QgsMapUnitScaleWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
56
63 QgsMapUnitScale mapUnitScale() const;
64
72 void setMapUnitScale( const QgsMapUnitScale &scale );
73
79 void setMapCanvas( QgsMapCanvas *canvas );
80
81 signals:
82
88
89 private slots:
90 void configureMinComboBox();
91 void configureMaxComboBox();
92 void settingsChanged();
93
94 private:
95
96 bool mBlockSignals = true;
97
98};
99
109class GUI_EXPORT QgsMapUnitScaleDialog : public QDialog
110{
111 Q_OBJECT
112 Q_PROPERTY( QgsMapUnitScale mapUnitScale READ getMapUnitScale WRITE setMapUnitScale )
113
114 public:
115
120 QgsMapUnitScaleDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr );
121
127 QgsMapUnitScale getMapUnitScale() const;
128
135 void setMapUnitScale( const QgsMapUnitScale &scale );
136
143 void setMapCanvas( QgsMapCanvas *canvas );
144
145 private slots:
146
147 void showHelp();
148
149
150 private:
151
152 QgsMapUnitScaleWidget *mWidget = nullptr;
153
154};
155
165class GUI_EXPORT QgsUnitSelectionWidget : public QWidget, private Ui::QgsUnitSelectionWidget
166{
167 Q_OBJECT
168
169 public:
170
175 QgsUnitSelectionWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
176
182 void setUnits( const QStringList &units, int mapUnitIdx );
183
189 void setUnits( const QgsUnitTypes::RenderUnitList &units );
190
192 int getUnit() const { return mUnitCombo->currentIndex(); }
193
199 QgsUnitTypes::RenderUnit unit() const;
200
206 void setUnit( int unitIndex ) SIP_PYNAME( setUnitIndex );
207
212 void setUnit( QgsUnitTypes::RenderUnit unit );
213
215 QgsMapUnitScale getMapUnitScale() const { return mMapUnitScale; }
216
218 void setMapUnitScale( const QgsMapUnitScale &scale ) { mMapUnitScale = scale; }
219
226 void setMapCanvas( QgsMapCanvas *canvas );
227
234 bool showMapScaleButton() const;
235
242 void setShowMapScaleButton( bool show );
243
244 signals:
245 void changed();
246
247 private slots:
248 void showDialog();
249 void toggleUnitRangeButton();
250 void widgetChanged( const QgsMapUnitScale &scale );
251
252 private:
253 QgsMapUnitScale mMapUnitScale;
254 int mMapUnitIdx;
255 QgsMapCanvas *mCanvas = nullptr;
256 bool mShowMapScaleButton = true;
257
258};
259
260#endif // QGSUNITSELECTIONWIDGET_H
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:90
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< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:240
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_PYNAME(name)
Definition: qgis_sip.h:81