QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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. 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 &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). 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 &notSetText=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
 

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

◆ ~QgsExtentWidget()

QgsExtentWidget::~QgsExtentWidget ( )
override

Definition at line 117 of file qgsextentwidget.cpp.

Member Function Documentation

◆ clear

void QgsExtentWidget::clear ( )
slot

Clears the widget, setting it to a null value.

Definition at line 300 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 571 of file qgsextentwidget.cpp.

◆ dragLeaveEvent()

void QgsExtentWidget::dragLeaveEvent ( QDragLeaveEvent *  event)
overrideprotected

Definition at line 593 of file qgsextentwidget.cpp.

◆ dropEvent()

void QgsExtentWidget::dropEvent ( QDropEvent *  event)
overrideprotected

Definition at line 607 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 315 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 320 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 525 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 137 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 540 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 325 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 128 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 146 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 456 of file qgsextentwidget.cpp.

◆ setOutputExtentFromDrawOnCanvas

void QgsExtentWidget::setOutputExtentFromDrawOnCanvas ( )
slot

Sets the output extent by dragging on the canvas.

Definition at line 493 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 482 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 472 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 477 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.

◆ 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 Function Documentation

◆ TestProcessingGui

friend class TestProcessingGui
friend

Definition at line 301 of file qgsextentwidget.h.


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