QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
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
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
188 void setUnits( const QgsUnitTypes::RenderUnitList &units );
189
191 int getUnit() const { return mUnitCombo->currentIndex(); }
192
197 Qgis::RenderUnit unit() const;
198
204 void setUnit( int unitIndex ) SIP_PYNAME( setUnitIndex );
205
210 void setUnit( Qgis::RenderUnit unit );
211
213 QgsMapUnitScale getMapUnitScale() const { return mMapUnitScale; }
214
216 void setMapUnitScale( const QgsMapUnitScale &scale ) { mMapUnitScale = scale; }
217
223 void setMapCanvas( QgsMapCanvas *canvas );
224
231 bool showMapScaleButton() const;
232
239 void setShowMapScaleButton( bool show );
240
241 signals:
242
246 void changed();
247
248 private slots:
249 void showDialog();
250 void toggleUnitRangeButton();
251 void widgetChanged( const QgsMapUnitScale &scale );
252
253 private:
254 QgsMapUnitScale mMapUnitScale;
255 int mMapUnitIdx;
256 QgsMapCanvas *mCanvas = nullptr;
257 bool mShowMapScaleButton = true;
258
259};
260
261#endif // QGSUNITSELECTIONWIDGET_H
RenderUnit
Rendering size units.
Definition qgis.h:4839
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 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,...
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