QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsscalecombobox.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsscalecombobox.h
3 ------------------------
4 begin : January 7, 2012
5 copyright : (C) 2012 by Alexander Bruy
6 email : alexander dot bruy at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSSCALECOMBOBOX_H
19#define QGSSCALECOMBOBOX_H
20
21#include "qgis_gui.h"
22#include "qgis_sip.h"
23
24#include <QComboBox>
25
31class GUI_EXPORT QgsScaleComboBox : public QComboBox
32{
33 Q_OBJECT
34 Q_PROPERTY( double scale READ scale WRITE setScale NOTIFY scaleChanged )
35 Q_PROPERTY( double minScale READ minScale WRITE setMinScale )
37
38 public:
44 enum class RatioMode : int
45 {
46 ForceUnitNumerator,
47 Flexible,
48 };
49 Q_ENUM( RatioMode )
50
51
54 QgsScaleComboBox( QWidget *parent SIP_TRANSFERTHIS = nullptr );
55
60 QString scaleString() const;
61
66 bool setScaleString( const QString &string );
67
73 double scale() const;
74
82 bool isNull() const;
83
90 double minScale() const { return mMinScale; }
91
102 static QString toString( double scale, QgsScaleComboBox::RatioMode mode = QgsScaleComboBox::RatioMode::ForceUnitNumerator );
103
110 static double toDouble( const QString &string, bool *ok = nullptr );
111
119 void setAllowNull( bool allowNull );
120
128 bool allowNull() const;
129
138 void setPredefinedScales( const QVector<double> &scales );
139
146 QgsScaleComboBox::RatioMode ratioMode() const;
147
148 signals:
149
154 void scaleChanged( double scale );
155
162
163 public slots:
164
169 void updateScales( const QStringList &scales = QStringList() );
170
176 void setScale( double scale );
177
184 void setMinScale( double scale );
185
195 void setNull();
196
204
205 protected:
206 void showPopup() override;
207
208 private slots:
209 void fixupScale();
210
211 private:
212 double mScale = 1.0;
213 double mMinScale = 0.0;
214 bool mAllowNull = false;
216};
217
218#endif // QGSSCALECOMBOBOX_H
A combobox which lets the user select map scale from predefined list and highlights nearest to curren...
void updateScales(const QStringList &scales=QStringList())
Sets the list of predefined scales to show in the combobox.
QgsScaleComboBox(QWidget *parent=nullptr)
Constructor for QgsScaleComboBox.
void setScale(double scale)
Set the selected scale from a double.
void ratioModeChanged(QgsScaleComboBox::RatioMode mode)
Emitted when the ratio mode for the widget is changed.
void showPopup() override
void setNull()
Sets the combo box to the null value.
RatioMode
Scale ratio modes.
@ ForceUnitNumerator
Default mode, forces the scale numerator to be 1, e.g. "1:1000".
void setRatioMode(QgsScaleComboBox::RatioMode mode)
Sets the ratio mode for the scale.
void setMinScale(double scale)
Set the minimum allowed scale.
double minScale() const
Returns the minimum scale, or 0 if no minimum scale set.
void scaleChanged(double scale)
Emitted when user has finished editing/selecting a new scale.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53