QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
A widget for configuration of a map extent. More...
#include <qgsextentwidget.h>
Public Types | |
enum | ExtentState { OriginalExtent, CurrentExtent, UserExtent, ProjectLayerExtent, DrawOnCanvas } |
Available states for the current extent selection in the widget. More... | |
enum | WidgetStyle { CondensedStyle, ExpandedStyle } |
Widget styles. More... | |
Public Slots | |
void | clear () |
Clears the widget, setting it to a null value. More... | |
void | setOutputExtentFromCurrent () |
Sets the output extent to be the same as current extent (may be transformed to output CRS). More... | |
void | setOutputExtentFromDrawOnCanvas () |
Sets the output extent by dragging on the canvas. More... | |
void | setOutputExtentFromLayer (const QgsMapLayer *layer) |
Sets the output extent to match a layer's extent (may be transformed to output CRS). More... | |
void | setOutputExtentFromOriginal () |
Sets the output extent to be the same as original extent (may be transformed to output CRS). More... | |
void | setOutputExtentFromUser (const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs) |
Sets the output extent to a custom extent (may be transformed to output CRS). More... | |
void | setRatio (QSize ratio) |
Sets a fixed aspect ratio to be used when dragging extent onto the canvas. More... | |
Signals | |
void | extentChanged (const QgsRectangle &r) |
Emitted when the widget's extent is changed. More... | |
void | toggleDialogVisibility (bool visible) |
Emitted when the parent dialog visibility must be changed (e.g. More... | |
void | validationChanged (bool valid) |
Emitted when the widget's validation state changes. More... | |
Public Member Functions | |
QgsExtentWidget (QWidget *parent=nullptr, WidgetStyle style=CondensedStyle) | |
Constructor for QgsExtentWidget. More... | |
QgsCoordinateReferenceSystem | currentCrs () const |
Returns the coordinate reference system for the current extent set for the widget. More... | |
QgsRectangle | currentExtent () const |
Returns the current extent set for the widget. More... | |
QString | extentLayerName () const |
Returns the name of the extent layer. More... | |
QgsExtentWidget::ExtentState | extentState () const |
Returns the currently selected state for the widget's extent. More... | |
bool | isValid () const |
Returns true if the widget is in a valid state, i.e. More... | |
QgsCoordinateReferenceSystem | originalCrs () const |
Returns the original coordinate reference system set for the widget. More... | |
QgsRectangle | originalExtent () const |
Returns the original extent set for the widget. More... | |
QgsCoordinateReferenceSystem | outputCrs () const |
Returns the current output CRS, used in the display. More... | |
QgsRectangle | outputExtent () const |
Returns the extent shown in the widget - in output CRS coordinates. More... | |
QSize | ratio () const |
Returns the current fixed aspect ratio to be used when dragging extent onto the canvas. More... | |
void | setCurrentExtent (const QgsRectangle ¤tExtent, const QgsCoordinateReferenceSystem ¤tCrs) |
Sets the current extent to show in the widget - should be called as part of initialization (or whenever current extent changes). More... | |
void | setMapCanvas (QgsMapCanvas *canvas) |
Sets the map canvas to enable dragging of extent on a canvas. More... | |
void | setNullValueAllowed (bool allowed, const QString ¬SetText=QString()) |
Sets whether the widget can be set to a "not set" (null) state. More... | |
void | setOriginalExtent (const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs) |
Sets the original extent and coordinate reference system for the widget. More... | |
void | setOutputCrs (const QgsCoordinateReferenceSystem &outputCrs) |
Sets the output CRS - may need to be used for transformation from original/current extent. More... | |
Protected Member Functions | |
void | dragEnterEvent (QDragEnterEvent *event) override |
void | dragLeaveEvent (QDragLeaveEvent *event) override |
void | dropEvent (QDropEvent *event) override |
A widget for configuration of a map extent.
Besides allowing the user to enter the extent manually, it comes with options to use original extent or extent defined by the current view in map canvas.
When using the widget, make sure to call setOriginalExtent(), setCurrentExtent() and setOutputCrs() during initialization.
Definition at line 50 of file qgsextentwidget.h.
Available states for the current extent selection in the widget.
Definition at line 57 of file qgsextentwidget.h.
Widget styles.
Enumerator | |
---|---|
CondensedStyle | Shows a compressed widget, for use when available space is minimal. |
ExpandedStyle | Shows an expanded widget, for use when space is not constrained. |
Definition at line 67 of file qgsextentwidget.h.
|
explicit |
Constructor for QgsExtentWidget.
Definition at line 30 of file qgsextentwidget.cpp.
|
slot |
Clears the widget, setting it to a null value.
Definition at line 260 of file qgsextentwidget.cpp.
|
inline |
Returns the coordinate reference system for the current extent set for the widget.
The current extent and CRS usually reflects the map canvas extent and CRS.
Definition at line 121 of file qgsextentwidget.h.
|
inline |
Returns the current extent set for the widget.
The current extent is usually set to match the current map canvas extent.
Definition at line 113 of file qgsextentwidget.h.
|
overrideprotected |
Definition at line 443 of file qgsextentwidget.cpp.
|
overrideprotected |
Definition at line 465 of file qgsextentwidget.cpp.
|
overrideprotected |
Definition at line 479 of file qgsextentwidget.cpp.
|
signal |
Emitted when the widget's extent is changed.
QString QgsExtentWidget::extentLayerName | ( | ) | const |
Returns the name of the extent layer.
Definition at line 275 of file qgsextentwidget.cpp.
|
inline |
Returns the currently selected state for the widget's extent.
Definition at line 145 of file qgsextentwidget.h.
bool QgsExtentWidget::isValid | ( | ) | const |
Returns true
if the widget is in a valid state, i.e.
has an extent set.
Definition at line 280 of file qgsextentwidget.cpp.
|
inline |
Returns the original coordinate reference system set for the widget.
Definition at line 97 of file qgsextentwidget.h.
|
inline |
Returns the original extent set for the widget.
Definition at line 90 of file qgsextentwidget.h.
|
inline |
Returns the current output CRS, used in the display.
Definition at line 140 of file qgsextentwidget.h.
QgsRectangle QgsExtentWidget::outputExtent | ( | ) | const |
Returns the extent shown in the widget - in output CRS coordinates.
Definition at line 417 of file qgsextentwidget.cpp.
|
inline |
Returns the current fixed aspect ratio to be used when dragging extent onto the canvas.
If the aspect ratio isn't fixed, the width and height will be set to zero.
Definition at line 157 of file qgsextentwidget.h.
void QgsExtentWidget::setCurrentExtent | ( | const QgsRectangle & | currentExtent, |
const QgsCoordinateReferenceSystem & | currentCrs | ||
) |
Sets the current extent to show in the widget - should be called as part of initialization (or whenever current extent changes).
The current extent is usually set to match the current map canvas extent.
Definition at line 101 of file qgsextentwidget.cpp.
void QgsExtentWidget::setMapCanvas | ( | QgsMapCanvas * | canvas | ) |
Sets the map canvas to enable dragging of extent on a canvas.
canvas | the map canvas |
Definition at line 423 of file qgsextentwidget.cpp.
void QgsExtentWidget::setNullValueAllowed | ( | bool | allowed, |
const QString & | notSetText = QString() |
||
) |
Sets whether the widget can be set to a "not set" (null) state.
The specified notSetText will be used for showing null values.
Definition at line 285 of file qgsextentwidget.cpp.
void QgsExtentWidget::setOriginalExtent | ( | const QgsRectangle & | originalExtent, |
const QgsCoordinateReferenceSystem & | originalCrs | ||
) |
Sets the original extent and coordinate reference system for the widget.
This should be called as part of initialization.
Definition at line 92 of file qgsextentwidget.cpp.
void QgsExtentWidget::setOutputCrs | ( | const QgsCoordinateReferenceSystem & | outputCrs | ) |
Sets the output CRS - may need to be used for transformation from original/current extent.
Should be called as part of initialization and whenever the the output CRS is changed. The current extent will be reprojected into the new output CRS.
Definition at line 110 of file qgsextentwidget.cpp.
|
slot |
Sets the output extent to be the same as current extent (may be transformed to output CRS).
Definition at line 350 of file qgsextentwidget.cpp.
|
slot |
Sets the output extent by dragging on the canvas.
Definition at line 387 of file qgsextentwidget.cpp.
|
slot |
Sets the output extent to match a layer's extent (may be transformed to output CRS).
Definition at line 376 of file qgsextentwidget.cpp.
|
slot |
Sets the output extent to be the same as original extent (may be transformed to output CRS).
Definition at line 366 of file qgsextentwidget.cpp.
|
slot |
Sets the output extent to a custom extent (may be transformed to output CRS).
Definition at line 371 of file qgsextentwidget.cpp.
|
inlineslot |
Sets a fixed aspect ratio to be used when dragging extent onto the canvas.
To unset a fixed aspect ratio, set the width and height to zero.
ratio | aspect ratio's width and height |
Definition at line 210 of file qgsextentwidget.h.
|
signal |
Emitted when the parent dialog visibility must be changed (e.g.
to permit access to the map canvas)
|
signal |
Emitted when the widget's validation state changes.