QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
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
31
class
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
)
36
Q_PROPERTY(
RatioMode
ratioMode
READ
ratioMode
WRITE
setRatioMode
NOTIFY
ratioModeChanged
)
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
161
void
ratioModeChanged
(
QgsScaleComboBox::RatioMode
mode );
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
203
void
setRatioMode
(
QgsScaleComboBox::RatioMode
mode );
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
;
215
QgsScaleComboBox::RatioMode
mMode =
QgsScaleComboBox::RatioMode::ForceUnitNumerator
;
216
};
217
218
#endif
// QGSSCALECOMBOBOX_H
QgsScaleComboBox
A combobox which lets the user select map scale from predefined list and highlights nearest to curren...
Definition
qgsscalecombobox.h:32
QgsScaleComboBox::scale
double scale
Definition
qgsscalecombobox.h:34
QgsScaleComboBox::updateScales
void updateScales(const QStringList &scales=QStringList())
Sets the list of predefined scales to show in the combobox.
Definition
qgsscalecombobox.cpp:47
QgsScaleComboBox::QgsScaleComboBox
QgsScaleComboBox(QWidget *parent=nullptr)
Constructor for QgsScaleComboBox.
Definition
qgsscalecombobox.cpp:34
QgsScaleComboBox::setScale
void setScale(double scale)
Set the selected scale from a double.
Definition
qgsscalecombobox.cpp:200
QgsScaleComboBox::ratioModeChanged
void ratioModeChanged(QgsScaleComboBox::RatioMode mode)
Emitted when the ratio mode for the widget is changed.
QgsScaleComboBox::showPopup
void showPopup() override
Definition
qgsscalecombobox.cpp:115
QgsScaleComboBox::minScale
double minScale
Definition
qgsscalecombobox.h:35
QgsScaleComboBox::setNull
void setNull()
Sets the combo box to the null value.
Definition
qgsscalecombobox.cpp:355
QgsScaleComboBox::ratioMode
RatioMode ratioMode
Definition
qgsscalecombobox.h:36
QgsScaleComboBox::RatioMode
RatioMode
Scale ratio modes.
Definition
qgsscalecombobox.h:45
QgsScaleComboBox::RatioMode::ForceUnitNumerator
@ ForceUnitNumerator
Default mode, forces the scale numerator to be 1, e.g. "1:1000".
Definition
qgsscalecombobox.h:46
QgsScaleComboBox::setRatioMode
void setRatioMode(QgsScaleComboBox::RatioMode mode)
Sets the ratio mode for the scale.
Definition
qgsscalecombobox.cpp:250
QgsScaleComboBox::setMinScale
void setMinScale(double scale)
Set the minimum allowed scale.
Definition
qgsscalecombobox.cpp:346
QgsScaleComboBox::minScale
double minScale() const
Returns the minimum scale, or 0 if no minimum scale set.
Definition
qgsscalecombobox.h:90
QgsScaleComboBox::scaleChanged
void scaleChanged(double scale)
Emitted when user has finished editing/selecting a new scale.
qgis_sip.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
Generated on
for QGIS API Documentation by
1.17.0