QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
qgsscalewidget.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsscalewidget.h
3
--------------------------------------
4
Date : 08.01.2015
5
Copyright : (C) 2014 Denis Rouzaud
6
Email : denis.rouzaud@gmail.com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#ifndef QGSSCALEWIDGET_H
17
#define QGSSCALEWIDGET_H
18
19
#include "qgis_gui.h"
20
#include "
qgis_sip.h
"
21
#include "
qgsscalecombobox.h
"
22
23
#include <QToolButton>
24
#include <QWidget>
25
26
class
QgsMapCanvas
;
27
33
class
GUI_EXPORT
QgsScaleWidget
:
public
QWidget
34
{
35
Q_OBJECT
36
Q_PROPERTY(
bool
showCurrentScaleButton
READ
showCurrentScaleButton
WRITE
setShowCurrentScaleButton
)
37
Q_PROPERTY(
bool
scale
READ
scale
WRITE
setScale
NOTIFY
scaleChanged
)
38
Q_PROPERTY(
bool
minScale
READ
minScale
WRITE
setMinScale
)
39
40
public:
45
explicit
QgsScaleWidget
( QWidget *parent
SIP_TRANSFERTHIS
=
nullptr
);
46
53
void
setShowCurrentScaleButton
(
bool
showCurrentScaleButton
);
54
59
bool
showCurrentScaleButton
()
const
{
return
mShowCurrentScaleButton; }
60
64
void
setMapCanvas(
QgsMapCanvas
*canvas );
65
70
QString
scaleString
()
const
{
return
mScaleComboBox->scaleString(); }
71
76
bool
setScaleString
(
const
QString &
string
) {
return
mScaleComboBox->setScaleString(
string
); }
77
83
double
scale
()
const
{
return
mScaleComboBox->scale(); }
84
92
bool
isNull()
const
;
93
100
double
minScale
()
const
{
return
mScaleComboBox->minScale(); }
101
109
static
QString
toString
(
double
scale
) {
return
QgsScaleComboBox::toString
(
scale
); }
110
117
static
double
toDouble
(
const
QString &
scaleString
,
bool
*ok =
nullptr
) {
return
QgsScaleComboBox::toDouble
(
scaleString
, ok ); }
118
126
void
setAllowNull(
bool
allowNull );
127
135
bool
allowNull()
const
;
136
145
void
setPredefinedScales(
const
QVector<double> &scales );
146
147
public
slots:
148
154
void
setScale(
double
scale );
155
160
void
updateScales
(
const
QStringList &scales = QStringList() ) { mScaleComboBox->updateScales( scales ); }
161
166
void
setScaleFromCanvas();
167
174
void
setMinScale
(
double
scale
) { mScaleComboBox->setMinScale(
scale
); }
175
185
void
setNull();
186
187
signals:
188
193
void
scaleChanged
(
double
scale
);
194
195
private
slots:
196
197
void
menuAboutToShow();
198
199
private
:
200
QgsScaleComboBox
*mScaleComboBox =
nullptr
;
201
QToolButton *mCurrentScaleButton =
nullptr
;
202
QgsMapCanvas
*mCanvas =
nullptr
;
203
QMenu *mMenu =
nullptr
;
204
bool
mShowCurrentScaleButton =
false
;
205
};
206
207
#endif
// QGSSCALEWIDGET_H
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition
qgsmapcanvas.h:96
QgsScaleComboBox
A combobox which lets the user select map scale from predefined list and highlights nearest to curren...
Definition
qgsscalecombobox.h:32
QgsScaleComboBox::toDouble
static double toDouble(const QString &string, bool *ok=nullptr)
Helper function to convert a scale string to double.
Definition
qgsscalecombobox.cpp:294
QgsScaleComboBox::toString
static QString toString(double scale, QgsScaleComboBox::RatioMode mode=QgsScaleComboBox::RatioMode::ForceUnitNumerator)
Helper function to convert a scale double to scale string.
Definition
qgsscalecombobox.cpp:260
QgsScaleWidget::scaleChanged
void scaleChanged(double scale)
Emitted when user has finished editing/selecting a new scale.
QgsScaleWidget::updateScales
void updateScales(const QStringList &scales=QStringList())
Sets the list of predefined scales to show in the widget.
Definition
qgsscalewidget.h:160
QgsScaleWidget::setShowCurrentScaleButton
void setShowCurrentScaleButton(bool showCurrentScaleButton)
Sets whether to show a button to set the scale to the current scale of the map canvas next to the com...
Definition
qgsscalewidget.cpp:59
QgsScaleWidget::minScale
double minScale() const
Returns the minimum scale, or 0 if no minimum scale set.
Definition
qgsscalewidget.h:100
QgsScaleWidget::setMinScale
void setMinScale(double scale)
Set the minimum allowed scale.
Definition
qgsscalewidget.h:174
QgsScaleWidget::scaleString
QString scaleString() const
Returns the selected scale as a string, e.g.
Definition
qgsscalewidget.h:70
QgsScaleWidget::scale
double scale() const
Returns the selected scale as a double.
Definition
qgsscalewidget.h:83
QgsScaleWidget::toString
static QString toString(double scale)
Helper function to convert a scale double to scale string.
Definition
qgsscalewidget.h:109
QgsScaleWidget::toDouble
static double toDouble(const QString &scaleString, bool *ok=nullptr)
Helper function to convert a scale string to double.
Definition
qgsscalewidget.h:117
QgsScaleWidget::minScale
bool minScale
Definition
qgsscalewidget.h:38
QgsScaleWidget::showCurrentScaleButton
bool showCurrentScaleButton
Definition
qgsscalewidget.h:36
QgsScaleWidget::setScale
void setScale(double scale)
Set the selected scale from a double.
Definition
qgsscalewidget.cpp:104
QgsScaleWidget::QgsScaleWidget
QgsScaleWidget(QWidget *parent=nullptr)
QgsScaleWidget creates a combobox which lets the user select map scale from predefined list and highl...
Definition
qgsscalewidget.cpp:33
QgsScaleWidget::setScaleString
bool setScaleString(const QString &string)
Set the selected scale from a string, e.g.
Definition
qgsscalewidget.h:76
QgsScaleWidget::scale
bool scale
Definition
qgsscalewidget.h:37
qgis_sip.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
qgsscalecombobox.h
Generated on
for QGIS API Documentation by
1.17.0