QGIS API Documentation 3.41.0-Master (af5edcb665c)
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:
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
86
87 private slots:
88 void configureMinComboBox();
89 void configureMaxComboBox();
90 void settingsChanged();
91
92 private:
93 bool mBlockSignals = true;
94};
95
105class GUI_EXPORT QgsMapUnitScaleDialog : public QDialog
106{
107 Q_OBJECT
108 Q_PROPERTY( QgsMapUnitScale mapUnitScale READ getMapUnitScale WRITE setMapUnitScale )
109
110 public:
115 QgsMapUnitScaleDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr );
116
122 QgsMapUnitScale getMapUnitScale() const;
123
130 void setMapUnitScale( const QgsMapUnitScale &scale );
131
137 void setMapCanvas( QgsMapCanvas *canvas );
138
139 private slots:
140
141 void showHelp();
142
143
144 private:
145 QgsMapUnitScaleWidget *mWidget = nullptr;
146};
147
159class GUI_EXPORT QgsUnitSelectionWidget : public QWidget, private Ui::QgsUnitSelectionWidget
160{
161 Q_OBJECT
162
163 public:
168 QgsUnitSelectionWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
169
175 void setUnits( const QStringList &units, int mapUnitIdx );
176
181 void setUnits( const QgsUnitTypes::RenderUnitList &units );
182
184 int getUnit() const { return mUnitCombo->currentIndex(); }
185
190 Qgis::RenderUnit unit() const;
191
197 void setUnit( int unitIndex ) SIP_PYNAME( setUnitIndex );
198
203 void setUnit( Qgis::RenderUnit unit );
204
206 QgsMapUnitScale getMapUnitScale() const { return mMapUnitScale; }
207
209 void setMapUnitScale( const QgsMapUnitScale &scale ) { mMapUnitScale = scale; }
210
216 void setMapCanvas( QgsMapCanvas *canvas );
217
224 bool showMapScaleButton() const;
225
232 void setShowMapScaleButton( bool show );
233
234 signals:
235
239 void changed();
240
241 private slots:
242 void showDialog();
243 void toggleUnitRangeButton();
244 void widgetChanged( const QgsMapUnitScale &scale );
245
246 private:
247 QgsMapUnitScale mMapUnitScale;
248 int mMapUnitIdx;
249 QgsMapCanvas *mCanvas = nullptr;
250 bool mShowMapScaleButton = true;
251};
252
253#endif // QGSUNITSELECTIONWIDGET_H
RenderUnit
Rendering size units.
Definition qgis.h:4910
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