QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Friends | List of all members
QgsExtentWidget Class Reference

A widget for configuration of a map extent. More...

#include <qgsextentwidget.h>

Inheritance diagram for QgsExtentWidget:
Inheritance graph
[legend]

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.
 
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.
 

Signals

void extentChanged (const QgsRectangle &r)
 Emitted when the widget's extent is changed.
 
void toggleDialogVisibility (bool visible)
 Emitted when the parent dialog visibility must be changed (e.g.
 
void validationChanged (bool valid)
 Emitted when the widget's validation state changes.
 

Public Member Functions

 QgsExtentWidget (QWidget *parent=nullptr, WidgetStyle style=CondensedStyle)
 Constructor for QgsExtentWidget.
 
 ~QgsExtentWidget () override
 
QgsCoordinateReferenceSystem currentCrs () const
 Returns the coordinate reference system for the current extent set for the widget.
 
QgsRectangle currentExtent () const
 Returns the current extent set for the widget.
 
QString extentLayerName () const
 Returns the name of the extent layer.
 
QgsExtentWidget::ExtentState extentState () const
 Returns the currently selected state for the widget's extent.
 
bool isValid () const
 Returns true if the widget is in a valid state, i.e.
 
QgsCoordinateReferenceSystem originalCrs () const
 Returns the original coordinate reference system set for the widget.
 
QgsRectangle originalExtent () const
 Returns the original extent set for the widget.
 
QgsCoordinateReferenceSystem outputCrs () const
 Returns the current output CRS, used in the display.
 
QgsRectangle outputExtent () const
 Returns the extent shown in the widget - in output CRS coordinates.
 
QSize ratio () const
 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, bool drawOnCanvasOption=true)
 Sets the map canvas to enable dragging of extent on a canvas.
 
void setNullValueAllowed (bool allowed, const QString &notSetText=QString())
 Sets whether the widget can be set to a "not set" (null) state.
 
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.
 

Protected Member Functions

void dragEnterEvent (QDragEnterEvent *event) override
 
void dragLeaveEvent (QDragLeaveEvent *event) override
 
void dropEvent (QDropEvent *event) override
 
void showEvent (QShowEvent *event) override
 

Friends

class TestProcessingGui
 

Detailed Description

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.

See also
QgsExtentGroupBox
Since
QGIS 3.14

Definition at line 51 of file qgsextentwidget.h.

Member Enumeration Documentation

◆ ExtentState

Available states for the current extent selection in the widget.

Enumerator
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.

Definition at line 58 of file qgsextentwidget.h.

◆ WidgetStyle

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 68 of file qgsextentwidget.h.

Constructor & Destructor Documentation

◆ QgsExtentWidget()

QgsExtentWidget::QgsExtentWidget ( QWidget *  parent = nullptr,
WidgetStyle  style = CondensedStyle 
)
explicit

Constructor for QgsExtentWidget.

Definition at line 37 of file qgsextentwidget.cpp.

◆ ~QgsExtentWidget()

QgsExtentWidget::~QgsExtentWidget ( )
override

Definition at line 118 of file qgsextentwidget.cpp.

Member Function Documentation

◆ clear

void QgsExtentWidget::clear ( )
slot

Clears the widget, setting it to a null value.

Definition at line 340 of file qgsextentwidget.cpp.

◆ currentCrs()

QgsCoordinateReferenceSystem QgsExtentWidget::currentCrs ( ) const
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.

See also
setCurrentExtent()
currentExtent()

Definition at line 124 of file qgsextentwidget.h.

◆ currentExtent()

QgsRectangle QgsExtentWidget::currentExtent ( ) const
inline

Returns the current extent set for the widget.

The current extent is usually set to match the current map canvas extent.

See also
setCurrentExtent()
currentCrs()

Definition at line 116 of file qgsextentwidget.h.

◆ dragEnterEvent()

void QgsExtentWidget::dragEnterEvent ( QDragEnterEvent *  event)
overrideprotected

Definition at line 610 of file qgsextentwidget.cpp.

◆ dragLeaveEvent()

void QgsExtentWidget::dragLeaveEvent ( QDragLeaveEvent *  event)
overrideprotected

Definition at line 632 of file qgsextentwidget.cpp.

◆ dropEvent()

void QgsExtentWidget::dropEvent ( QDropEvent *  event)
overrideprotected

Definition at line 646 of file qgsextentwidget.cpp.

◆ extentChanged

void QgsExtentWidget::extentChanged ( const QgsRectangle r)
signal

Emitted when the widget's extent is changed.

◆ extentLayerName()

QString QgsExtentWidget::extentLayerName ( ) const

Returns the name of the extent layer.

Definition at line 355 of file qgsextentwidget.cpp.

◆ extentState()

QgsExtentWidget::ExtentState QgsExtentWidget::extentState ( ) const
inline

Returns the currently selected state for the widget's extent.

Definition at line 148 of file qgsextentwidget.h.

◆ isValid()

bool QgsExtentWidget::isValid ( ) const

Returns true if the widget is in a valid state, i.e.

has an extent set.

Definition at line 360 of file qgsextentwidget.cpp.

◆ originalCrs()

QgsCoordinateReferenceSystem QgsExtentWidget::originalCrs ( ) const
inline

Returns the original coordinate reference system set for the widget.

See also
originalExtent()
setOriginalExtent()

Definition at line 100 of file qgsextentwidget.h.

◆ originalExtent()

QgsRectangle QgsExtentWidget::originalExtent ( ) const
inline

Returns the original extent set for the widget.

See also
setOriginalExtent()
originalCrs()

Definition at line 93 of file qgsextentwidget.h.

◆ outputCrs()

QgsCoordinateReferenceSystem QgsExtentWidget::outputCrs ( ) const
inline

Returns the current output CRS, used in the display.

See also
outputExtent

Definition at line 143 of file qgsextentwidget.h.

◆ outputExtent()

QgsRectangle QgsExtentWidget::outputExtent ( ) const

Returns the extent shown in the widget - in output CRS coordinates.

See also
outputCrs

Definition at line 565 of file qgsextentwidget.cpp.

◆ ratio()

QSize QgsExtentWidget::ratio ( ) const
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 161 of file qgsextentwidget.h.

◆ setCurrentExtent()

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.

See also
currentExtent()
currentCrs()

Definition at line 138 of file qgsextentwidget.cpp.

◆ setMapCanvas()

void QgsExtentWidget::setMapCanvas ( QgsMapCanvas canvas,
bool  drawOnCanvasOption = true 
)

Sets the map canvas to enable dragging of extent on a canvas.

Parameters
canvasthe map canvas
drawOnCanvasOptionset to false to disable to draw on canvas option

Definition at line 580 of file qgsextentwidget.cpp.

◆ setNullValueAllowed()

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.

Note
This mode only applies to widgets in the condensed state!

Definition at line 365 of file qgsextentwidget.cpp.

◆ setOriginalExtent()

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.

See also
originalExtent()
originalCrs()

Definition at line 129 of file qgsextentwidget.cpp.

◆ setOutputCrs()

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 147 of file qgsextentwidget.cpp.

◆ setOutputExtentFromCurrent

void QgsExtentWidget::setOutputExtentFromCurrent ( )
slot

Sets the output extent to be the same as current extent (may be transformed to output CRS).

Definition at line 496 of file qgsextentwidget.cpp.

◆ setOutputExtentFromDrawOnCanvas

void QgsExtentWidget::setOutputExtentFromDrawOnCanvas ( )
slot

Sets the output extent by dragging on the canvas.

Definition at line 533 of file qgsextentwidget.cpp.

◆ setOutputExtentFromLayer

void QgsExtentWidget::setOutputExtentFromLayer ( const QgsMapLayer layer)
slot

Sets the output extent to match a layer's extent (may be transformed to output CRS).

Definition at line 522 of file qgsextentwidget.cpp.

◆ setOutputExtentFromOriginal

void QgsExtentWidget::setOutputExtentFromOriginal ( )
slot

Sets the output extent to be the same as original extent (may be transformed to output CRS).

Definition at line 512 of file qgsextentwidget.cpp.

◆ setOutputExtentFromUser

void QgsExtentWidget::setOutputExtentFromUser ( const QgsRectangle extent,
const QgsCoordinateReferenceSystem crs 
)
slot

Sets the output extent to a custom extent (may be transformed to output CRS).

Definition at line 517 of file qgsextentwidget.cpp.

◆ setRatio

void QgsExtentWidget::setRatio ( QSize  ratio)
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.

Parameters
ratioaspect ratio's width and height

Definition at line 214 of file qgsextentwidget.h.

◆ showEvent()

void QgsExtentWidget::showEvent ( QShowEvent *  event)
overrideprotected

Definition at line 671 of file qgsextentwidget.cpp.

◆ toggleDialogVisibility

void QgsExtentWidget::toggleDialogVisibility ( bool  visible)
signal

Emitted when the parent dialog visibility must be changed (e.g.

to permit access to the map canvas)

◆ validationChanged

void QgsExtentWidget::validationChanged ( bool  valid)
signal

Emitted when the widget's validation state changes.

Friends And Related Symbol Documentation

◆ TestProcessingGui

friend class TestProcessingGui
friend

Definition at line 306 of file qgsextentwidget.h.


The documentation for this class was generated from the following files: