QGIS API Documentation 4.3.0-Master (90cb4ecf9ef)
Loading...
Searching...
No Matches
qgselevationcontrollerwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgselevationcontrollerwidget.h
3 ---------------
4 begin : March 2024
5 copyright : (C) 2024 by Nyall Dawson
6 email : nyall dot dawson 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 QGSELEVATIONCONTROLLERWIDGET_H
19#define QGSELEVATIONCONTROLLERWIDGET_H
20
21#include "qgis_gui.h"
22#include "qgis_sip.h"
23#include "qgsrange.h"
24
25#include <QPointer>
26#include <QWidget>
27#include <QWidgetAction>
28
29class QgsMapCanvas;
30class QgsMapLayer;
31class QgsRangeSlider;
33class QToolButton;
34class QMenu;
35
37
38class GUI_EXPORT QgsElevationControllerLabels : public QWidget SIP_SKIP
39{
40 Q_OBJECT
41
42 public:
43 QgsElevationControllerLabels( QWidget *parent SIP_TRANSFERTHIS = nullptr );
44
45 void paintEvent( QPaintEvent *event ) override;
46
47 void setLimits( const QgsDoubleRange &limits );
48 void setRange( const QgsDoubleRange &range );
49 void setInverted( bool inverted );
50 void setSignificantElevations( const QList<double> &elevations );
51
52 private:
53 QgsDoubleRange mLimits;
54 QgsDoubleRange mRange;
55 bool mInverted = false;
56 QList<double> mSignificantElevations;
57};
58
59class GUI_EXPORT QgsElevationControllerSettingsAction : public QWidgetAction SIP_SKIP
60{
61 Q_OBJECT
62
63 public:
64 QgsElevationControllerSettingsAction( QWidget *parent = nullptr );
65
67 QMenu *limitsMenu();
68
70 void setLimits( const QgsDoubleRange &limits );
71
73 void setFixedRangeSize( double size );
74
76 void updateRangeSize( double size );
77
78 signals:
79
81 void limitsChanged( const QgsDoubleRange &limits );
82
84 void fixedRangeSizeChanged( double size );
85
87 void fullRangeRequested();
88
89 protected:
90 bool eventFilter( QObject *watched, QEvent *event ) override;
91
92 private:
93 void onHover();
94
95 QMenu *mMenu = nullptr;
96 bool mSuppressRecurse = false;
97 QgsDoubleSpinBox *mLowerSpin = nullptr;
98 QgsDoubleSpinBox *mUpperSpin = nullptr;
99 QToolButton *mLimitsButton = nullptr;
100 QMenu *mLimitsMenu = nullptr;
101 QgsDoubleSpinBox *mSizeSpin = nullptr;
102 QToolButton *mLockButton = nullptr;
103};
104
105
107
114class GUI_EXPORT QgsElevationControllerWidget : public QWidget
115{
116#ifdef SIP_RUN
118 if ( qobject_cast<QgsElevationControllerWidget *>( sipCpp ) != nullptr )
119 sipType = sipType_QgsElevationControllerWidget;
120 else
121 sipType = nullptr;
122 SIP_END
123#endif
124
125 Q_OBJECT
126
127 public:
131 QgsElevationControllerWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
132
133 void resizeEvent( QResizeEvent *event ) override;
134
141 QgsDoubleRange range() const;
142
149
154
159 QMenu *menu();
160
167 QgsMapCanvas *mapCanvas() const;
168
177 double fixedRangeSize() const;
178
179 public slots:
180
187 void setRange( const QgsDoubleRange &range );
188
194 void setRangeLimits( const QgsDoubleRange &limits );
195
205 void setFixedRangeSize( double size );
206
212 void setInverted( bool inverted );
213
217 void setSignificantElevations( const QList<double> &elevations );
218
229 void setMapCanvas( QgsMapCanvas *canvas );
230
231 signals:
232
240
247 void fixedRangeSizeChanged( double size );
248
254 void invertedChanged( bool inverted );
255
256 private:
257 void updateWidgetMask();
258
260 void setLimitsFromRange( const QgsDoubleRange &range );
261
263 void setLimitsFromLayers( const QList<QgsMapLayer *> &layers );
264
265 static bool layerHasElevation( QgsMapLayer *layer );
266
271 QgsDoubleRange snappedRange( const QgsDoubleRange &range ) const;
272
274 double snapValue( double value ) const;
275
277 QgsDoubleRange sliderRange() const;
278
283 QgsDoubleRange fixedSizeRangeFrom( double lower ) const;
284
285 QToolButton *mConfigureButton = nullptr;
286 QgsElevationControllerSettingsAction *mSettingsAction = nullptr;
287 QMenu *mMenu = nullptr;
288 QAction *mInvertDirectionAction = nullptr;
289 QgsRangeSlider *mSlider = nullptr;
290 QgsElevationControllerLabels *mSliderLabels = nullptr;
291 QPointer<QgsMapCanvas> mMapCanvas;
292 QgsDoubleRange mRangeLimits;
293 QgsDoubleRange mCurrentRange;
294 QList<double> mSignificantElevations;
295 double mSnapInterval = 0;
296 int mSnapDecimals = 0;
297 double mFixedRangeSize = -1;
298 int mBlockSliderChanges = 0;
299 double mSliderPrecision = 100;
300};
301
302#endif // QGSELEVATIONCONTROLLERWIDGET_H
QgsRange which stores a range of double values.
Definition qgsrange.h:217
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
double fixedRangeSize() const
Returns the fixed range size, or -1 if no fixed size is set.
QgsRangeSlider * slider()
Returns a reference to the slider component of the widget.
void setSignificantElevations(const QList< double > &elevations)
Sets a list of significant elevations to highlight in the widget.
void resizeEvent(QResizeEvent *event) override
void setRange(const QgsDoubleRange &range)
Sets the current visible range for the widget.
QgsDoubleRange rangeLimits() const
Returns the limits of the elevation range which can be selected by the widget.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas the widget takes its layers from.
QgsMapCanvas * mapCanvas() const
Returns the map canvas the widget takes its layers from.
void setInverted(bool inverted)
Sets whether the elevation slider should be inverted.
void setFixedRangeSize(double size)
Sets the fixed range size.
void invertedChanged(bool inverted)
Emitted when the elevation filter slider is inverted.
void fixedRangeSizeChanged(double size)
Emitted when the fixed range size is changed from the widget.
void setRangeLimits(const QgsDoubleRange &limits)
Sets the limits of the elevation range which can be selected by the widget.
void rangeChanged(const QgsDoubleRange &range)
Emitted when the visible range from the widget is changed.
QgsElevationControllerWidget(QWidget *parent=nullptr)
Constructor for QgsElevationControllerWidget, with the specified parent widget.
QgsDoubleRange range() const
Returns the current visible range from the widget.
QMenu * menu()
Returns a reference to the widget's configuration menu, which can be used to add actions to the menu.
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
Definition qgsmaplayer.h:83
A slider control with two interactive endpoints, for interactive selection of a range of values.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:203
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_SKIP
Definition qgis_sip.h:138
#define SIP_END
Definition qgis_sip.h:220