QgsExtentGroupBox class
Collapsible group box for configuration of extent, typically for a save operation.
Contents
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.
Base classes
- class QgsCollapsibleGroupBox
- A groupbox that collapses/expands when toggled and can save its collapsed and checked states.
Public types
- enum ExtentState { OriginalExtent, CurrentExtent, UserExtent, ProjectLayerExtent, DrawOnCanvas }
- Available states for the current extent selection in the widget.
Constructors, destructors, conversion operators
- QgsExtentGroupBox(QWidget* parent = nullptr) explicit
- Constructor for QgsExtentGroupBox.
Public functions
- auto currentCrs() const -> QgsCoordinateReferenceSystem
- Returns the coordinate reference system for the current extent set for the widget.
- auto currentExtent() const -> QgsRectangle
- Returns the current extent set for the widget.
-
auto extentState() const -> QgsExtentGroupBox::
ExtentState - Returns the currently selected state for the widget's extent.
- auto originalCrs() const -> QgsCoordinateReferenceSystem
- Returns the original coordinate reference system set for the widget.
- auto originalExtent() const -> QgsRectangle
- Returns the original extent set for the widget.
- auto outputCrs() const -> QgsCoordinateReferenceSystem
- Returns the current output CRS, used in the display.
- auto outputExtent() const -> QgsRectangle
- Returns the extent shown in the widget - in output CRS coordinates.
- auto ratio() const -> QSize
- Returns the current fixed aspect ratio to be used when dragging extent onto the canvas.
- void 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).
- void setMapCanvas(QgsMapCanvas* canvas)
- Sets the map canvas to enable dragging of extent on a canvas.
- void setOriginalExtent(const QgsRectangle& originalExtent, const QgsCoordinateReferenceSystem& originalCrs)
- Sets the original extent and coordinate reference system for the widget.
- void setOutputCrs(const QgsCoordinateReferenceSystem& outputCrs)
- Sets the output CRS - may need to be used for transformation from original/current extent.
- void setTitleBase(const QString& title)
- Sets the base part of title of the group box (will be appended with extent state)
- auto titleBase() const -> QString
- Returns the base part of title of the group box (will be appended with extent state).
Signals
- void extentChanged(const QgsRectangle& r)
- Emitted when the widget's extent is changed.
Public slots
- void setOutputExtentFromCurrent()
- Sets the output extent to be the same as current extent (may be transformed to output CRS).
- void setOutputExtentFromDrawOnCanvas()
- Sets the output extent by dragging on the canvas.
- void setOutputExtentFromLayer(const QgsMapLayer* layer)
- Sets the output extent to match a layer's extent (may be transformed to output CRS).
- void setOutputExtentFromOriginal()
- Sets the output extent to be the same as original extent (may be transformed to output CRS).
- void setOutputExtentFromUser(const QgsRectangle& extent, const QgsCoordinateReferenceSystem& crs)
- Sets the output extent to a custom extent (may be transformed to output CRS).
- void setRatio(QSize ratio)
- Sets a fixed aspect ratio to be used when dragging extent onto the canvas.
Enum documentation
enum QgsExtentGroupBox:: ExtentState
Available states for the current extent selection in the widget.
| Enumerators | |
|---|---|
| OriginalExtent |
Layer's extent. |
| CurrentExtent |
Map canvas extent. |
| UserExtent |
Extent manually entered/modified by the user. |
| ProjectLayerExtent |
Extent taken from a layer within the project. |
| DrawOnCanvas |
Extent taken from a rectangled drawn onto the map canvas. |
Function documentation
QgsCoordinateReferenceSystem QgsExtentGroupBox:: currentCrs() const
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.
QgsRectangle QgsExtentGroupBox:: currentExtent() const
Returns the current extent set for the widget.
The current extent is usually set to match the current map canvas extent.
QgsCoordinateReferenceSystem QgsExtentGroupBox:: originalCrs() const
Returns the original coordinate reference system set for the widget.
QgsRectangle QgsExtentGroupBox:: originalExtent() const
Returns the original extent set for the widget.
QgsCoordinateReferenceSystem QgsExtentGroupBox:: outputCrs() const
Returns the current output CRS, used in the display.
QgsRectangle QgsExtentGroupBox:: outputExtent() const
Returns the extent shown in the widget - in output CRS coordinates.
QSize QgsExtentGroupBox:: ratio() const
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.
void QgsExtentGroupBox:: 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.
void QgsExtentGroupBox:: setMapCanvas(QgsMapCanvas* canvas)
Sets the map canvas to enable dragging of extent on a canvas.
| Parameters | |
|---|---|
| canvas | the map canvas |
void QgsExtentGroupBox:: 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.
void QgsExtentGroupBox:: 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.
void QgsExtentGroupBox:: setTitleBase(const QString& title)
Sets the base part of title of the group box (will be appended with extent state)
QString QgsExtentGroupBox:: titleBase() const
Returns the base part of title of the group box (will be appended with extent state).
void QgsExtentGroupBox:: setOutputExtentFromDrawOnCanvas() public slot
Sets the output extent by dragging on the canvas.
void QgsExtentGroupBox:: setOutputExtentFromLayer(const QgsMapLayer* layer) public slot
Sets the output extent to match a layer's extent (may be transformed to output CRS).
void QgsExtentGroupBox:: setRatio(QSize ratio) public slot
Sets a fixed aspect ratio to be used when dragging extent onto the canvas.
| Parameters | |
|---|---|
| ratio | aspect ratio's width and height |
To unset a fixed aspect ratio, set the width and height to zero.