QGIS API Documentation
3.22.4-Białowieża (ce8e65e95e)
|
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... | |
~QgsExtentWidget () override | |
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, bool drawOnCanvasOption=true) |
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.
|
override |
Definition at line 92 of file qgsextentwidget.cpp.
|
slot |
Clears the widget, setting it to a null value.
Definition at line 274 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 123 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 115 of file qgsextentwidget.h.
|
overrideprotected |
Definition at line 460 of file qgsextentwidget.cpp.
|
overrideprotected |
Definition at line 482 of file qgsextentwidget.cpp.
|
overrideprotected |
Definition at line 496 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 289 of file qgsextentwidget.cpp.
|
inline |
Returns the currently selected state for the widget's extent.
Definition at line 147 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 294 of file qgsextentwidget.cpp.
|
inline |
Returns the original coordinate reference system set for the widget.
Definition at line 99 of file qgsextentwidget.h.
|
inline |
Returns the original extent set for the widget.
Definition at line 92 of file qgsextentwidget.h.
|
inline |
Returns the current output CRS, used in the display.
Definition at line 142 of file qgsextentwidget.h.
QgsRectangle QgsExtentWidget::outputExtent | ( | ) | const |
Returns the extent shown in the widget - in output CRS coordinates.
Definition at line 433 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 160 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 112 of file qgsextentwidget.cpp.
void QgsExtentWidget::setMapCanvas | ( | QgsMapCanvas * | canvas, |
bool | drawOnCanvasOption = true |
||
) |
Sets the map canvas to enable dragging of extent on a canvas.
canvas | the map canvas |
drawOnCanvasOption | set to false to disable to draw on canvas option |
Definition at line 439 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 299 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 103 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 121 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 364 of file qgsextentwidget.cpp.
|
slot |
Sets the output extent by dragging on the canvas.
Definition at line 401 of file qgsextentwidget.cpp.
|
slot |
Sets the output extent to match a layer's extent (may be transformed to output CRS).
Definition at line 390 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 380 of file qgsextentwidget.cpp.
|
slot |
Sets the output extent to a custom extent (may be transformed to output CRS).
Definition at line 385 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 213 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.