QGIS API Documentation 4.3.0-Master (0cfde48c85b)
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
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 "ui_qgsmapunitscalewidgetbase.h"
22#include "ui_qgsunitselectionwidget.h"
23
24#include "qgis_gui.h"
25#include "qgis_sip.h"
26#include "qgsmapunitscale.h"
27#include "qgspanelwidget.h"
28#include "qgsunittypes.h"
29
30#include <QDialog>
31#include <QWidget>
32
33class QgsMapCanvas;
34
45class GUI_EXPORT QgsMapUnitScaleWidget : public QgsPanelWidget, private Ui::QgsMapUnitScaleWidgetBase
46{
47 Q_OBJECT
49
50 public:
55 QgsMapUnitScaleWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
56
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 bool mBlockSignals = true;
96};
97
108class GUI_EXPORT QgsMapUnitScaleDialog : public QDialog
109{
110 Q_OBJECT
112
113 public:
118 QgsMapUnitScaleDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr );
119
126
133 void setMapUnitScale( const QgsMapUnitScale &scale );
134
140 void setMapCanvas( QgsMapCanvas *canvas );
141
142 private slots:
143
144 void showHelp();
145
146
147 private:
148 QgsMapUnitScaleWidget *mWidget = nullptr;
149};
150
162class GUI_EXPORT QgsUnitSelectionWidget : public QWidget, private Ui::QgsUnitSelectionWidget
163{
164 Q_OBJECT
165
166 public:
171 QgsUnitSelectionWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
172
178 void setUnits( const QStringList &units, int mapUnitIdx );
179
184 void setUnits( const QgsUnitTypes::RenderUnitList &units );
185
187 int getUnit() const { return mUnitCombo->currentIndex(); }
188
193 Qgis::RenderUnit unit() const;
194
200 void setUnit( int unitIndex ) SIP_PYNAME( setUnitIndex );
201
206 void setUnit( Qgis::RenderUnit unit );
207
209 QgsMapUnitScale getMapUnitScale() const { return mMapUnitScale; }
210
212 void setMapUnitScale( const QgsMapUnitScale &scale ) { mMapUnitScale = scale; }
213
219 void setMapCanvas( QgsMapCanvas *canvas );
220
227 bool showMapScaleButton() const;
228
235 void setShowMapScaleButton( bool show );
236
237 signals:
238
242 void changed();
243
244 private slots:
245 void showDialog();
246 void toggleUnitRangeButton();
247 void widgetChanged( const QgsMapUnitScale &scale );
248
249 private:
250 QgsMapUnitScale mMapUnitScale;
251 int mMapUnitIdx;
252 QgsMapCanvas *mCanvas = nullptr;
253 bool mShowMapScaleButton = true;
254};
255
256#endif // QGSUNITSELECTIONWIDGET_H
RenderUnit
Rendering size units.
Definition qgis.h:5758
Map canvas is a class for displaying all GIS data types on a canvas.
QgsMapUnitScale getMapUnitScale() const
Returns a QgsMapUnitScale representing the settings shown in the dialog.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the dialog.
void setMapUnitScale(const QgsMapUnitScale &scale)
Updates the dialog to reflect the settings from the specified QgsMapUnitScale object.
QgsMapUnitScaleDialog(QWidget *parent=nullptr)
Constructor for QgsMapUnitScaleDialog.
A widget which allows the user to choose the minimum and maximum scale of an object in map units and ...
QgsMapUnitScaleWidget(QWidget *parent=nullptr)
Constructor for QgsMapUnitScaleWidget.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
void mapUnitScaleChanged(const QgsMapUnitScale &scale)
Emitted when the settings in the widget are modified.
void setMapUnitScale(const QgsMapUnitScale &scale)
Updates the widget to reflect the settings from the specified QgsMapUnitScale object.
Struct for storing maximum and minimum scales for measurements in map units.
QgsPanelWidget(QWidget *parent=nullptr)
Base class for any widget that can be shown as an inline panel.
Q_DECL_DEPRECATED void widgetChanged()
Emitted when the widget state changes.
void changed()
Emitted when the selected unit is changed, or the definition of the map unit scale is changed.
QgsUnitSelectionWidget(QWidget *parent=nullptr)
Constructor for QgsUnitSelectionWidget.
QgsMapUnitScale getMapUnitScale() const
Returns the map unit scale.
int getUnit() const
Gets the selected unit index.
void setUnits(const QStringList &units, int mapUnitIdx)
Sets the units which the user can choose from in the combobox.
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:52
#define SIP_PYNAME(name)
Definition qgis_sip.h:88