23#include "moc_qgsextentgroupbox.cpp"
25using namespace Qt::StringLiterals;
29 , mTitleBase( tr(
"Extent" ) )
32 QVBoxLayout *layout =
new QVBoxLayout();
33 layout->addWidget( mWidget );
36 connect(
this, &QGroupBox::toggled,
this, &QgsExtentGroupBox::groupBoxClicked );
42 QWidget *w = window();
44 if ( w->objectName() ==
"QgisApp"_L1 )
46 w->setVisible( visible );
57 return mWidget->originalExtent();
62 return mWidget->originalCrs();
72 return mWidget->currentExtent();
77 return mWidget->currentCrs();
85void QgsExtentGroupBox::updateTitle()
94 msg = tr(
"map view" );
97 msg = tr(
"user defined" );
103 msg = tr(
"drawn on canvas" );
106 if ( isCheckable() && !isChecked() )
108 msg = tr(
"%1 (current: %2)" ).arg( mTitleBase, msg );
115 mWidget->setOutputExtentFromCurrent();
120 mWidget->setOutputExtentFromOriginal();
125 mWidget->setOutputExtentFromUser( extent, crs );
130 mWidget->setOutputExtentFromLayer( layer );
135 mWidget->setOutputExtentFromDrawOnCanvas();
140 mWidget->setRatio(
ratio );
143void QgsExtentGroupBox::groupBoxClicked()
145 if ( !isCheckable() )
154void QgsExtentGroupBox::widgetExtentChanged()
161void QgsExtentGroupBox::validationChanged(
bool valid )
165 if ( isCheckable() && !isChecked() )
168 else if ( isCheckable() && isChecked() )
174 if ( isCheckable() && !isChecked() )
177 return mWidget->outputExtent();
182 return mWidget->outputCrs();
203 mWidget->setMapCanvas( canvas, drawOnCanvasOption );
208 return mWidget->ratio();
QgsCollapsibleGroupBox(QWidget *parent=nullptr, QgsSettings *settings=nullptr)
Represents a coordinate reference system (CRS).
ExtentState
Available states for the current extent selection in the widget.
void setOutputExtentFromLayer(const QgsMapLayer *layer)
Sets the output extent to match a layer's extent (may be transformed to output CRS).
QSize ratio() const
Returns the current fixed aspect ratio to be used when dragging extent onto the canvas.
void setOutputExtentFromUser(const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs)
Sets the output extent to a custom extent (may be transformed to output CRS).
QgsExtentGroupBox::ExtentState extentState() const
Returns the currently selected state for the widget's extent.
void setOriginalExtent(const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs)
Sets the original extent and coordinate reference system for the widget.
QgsExtentGroupBox(QWidget *parent=nullptr)
Constructor for QgsExtentGroupBox.
QgsRectangle originalExtent() const
Returns the original extent set for the widget.
void extentLayerChanged(QgsMapLayer *layer)
Emitted when the extent layer is changed.
void setOutputExtentFromCurrent()
Sets the output extent to be the same as current extent (may be transformed to output CRS).
QgsCoordinateReferenceSystem outputCrs() const
Returns the current output CRS, used in the display.
void extentChanged(const QgsRectangle &r)
Emitted when the widget's extent is changed.
QgsCoordinateReferenceSystem originalCrs() const
Returns the original coordinate reference system set for the widget.
void setOutputCrs(const QgsCoordinateReferenceSystem &outputCrs)
Sets the output CRS - may need to be used for transformation from original/current extent.
QgsCoordinateReferenceSystem currentCrs() const
Returns the coordinate reference system for the current extent set for the widget.
void setMapCanvas(QgsMapCanvas *canvas, bool drawOnCanvasOption=true)
Sets the map canvas to enable dragging of extent on a canvas.
QgsRectangle currentExtent() const
Returns the current extent set for the widget.
void setOutputExtentFromDrawOnCanvas()
Sets the output extent by dragging on the canvas.
void setOutputExtentFromOriginal()
Sets the output extent to be the same as original extent (may be transformed to output CRS).
void setTitleBase(const QString &title)
Sets the base part of title of the group box (will be appended with extent state).
QgsRectangle outputExtent() const
Returns the extent shown in the widget - in output CRS coordinates.
void setRatio(QSize ratio)
Sets a fixed aspect ratio to be used when dragging extent onto the canvas.
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 whenev...
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
A rectangle specified with double values.