QGIS API Documentation  2.99.0-Master (9caa722)
qgsextentgroupbox.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsextentgroupbox.h
3  ---------------------
4  begin : March 2014
5  copyright : (C) 2014 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSEXTENTGROUPBOX_H
17 #define QGSEXTENTGROUPBOX_H
18 
19 #include "qgscollapsiblegroupbox.h"
20 #include "qgsmaptool.h"
21 #include "qgsmaptoolextent.h"
22 #include "qgis.h"
23 
24 #include "ui_qgsextentgroupboxwidget.h"
25 
27 #include "qgsrectangle.h"
28 #include "qgis_gui.h"
29 
30 #include <memory>
31 
33 class QgsMapLayerModel;
34 class QgsMapLayer;
35 
46 class GUI_EXPORT QgsExtentGroupBox : public QgsCollapsibleGroupBox, private Ui::QgsExtentGroupBoxWidget
47 {
48  Q_OBJECT
49  Q_PROPERTY( QString titleBase READ titleBase WRITE setTitleBase )
50 
51  public:
52 
55  {
61  };
62 
66  explicit QgsExtentGroupBox( QWidget *parent SIP_TRANSFERTHIS = 0 );
67 
73  void setOriginalExtent( const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs );
74 
80  QgsRectangle originalExtent() const { return mOriginalExtent; }
81 
87  QgsCoordinateReferenceSystem originalCrs() const { return mOriginalCrs; }
88 
95  void setCurrentExtent( const QgsRectangle &currentExtent, const QgsCoordinateReferenceSystem &currentCrs );
96 
103  QgsRectangle currentExtent() const { return mCurrentExtent; }
104 
111  QgsCoordinateReferenceSystem currentCrs() const { return mCurrentCrs; }
112 
118  void setOutputCrs( const QgsCoordinateReferenceSystem &outputCrs );
119 
123  QgsRectangle outputExtent() const;
124 
128  QgsExtentGroupBox::ExtentState extentState() const { return mExtentState; }
129 
135  void setTitleBase( const QString &title );
136 
142  QString titleBase() const;
143 
149  void setMapCanvas( QgsMapCanvas *canvas );
150 
151  public slots:
152 
156  void setOutputExtentFromOriginal();
157 
161  void setOutputExtentFromCurrent();
162 
166  void setOutputExtentFromUser( const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs );
167 
172  void setOutputExtentFromLayer( const QgsMapLayer *layer );
173 
178  void setOutputExtentFromDrawOnCanvas();
179 
185  void setRatio( QSize ratio ) { mRatio = ratio; }
186 
191  QSize ratio() const { return mRatio; }
192 
193  signals:
194 
198  void extentChanged( const QgsRectangle &r );
199 
200  private slots:
201 
202  void on_mXMinLineEdit_textEdited( const QString & ) { setOutputExtentFromLineEdit(); }
203  void on_mXMaxLineEdit_textEdited( const QString & ) { setOutputExtentFromLineEdit(); }
204  void on_mYMinLineEdit_textEdited( const QString & ) { setOutputExtentFromLineEdit(); }
205  void on_mYMaxLineEdit_textEdited( const QString & ) { setOutputExtentFromLineEdit(); }
206 
207  void groupBoxClicked();
208  void layerMenuAboutToShow();
209 
210  void extentDrawn( const QgsRectangle &extent );
211 
212  private:
213  void setOutputExtent( const QgsRectangle &r, const QgsCoordinateReferenceSystem &srcCrs, QgsExtentGroupBox::ExtentState state );
214  void setOutputExtentFromLineEdit();
215  void updateTitle();
216 
218  QString mTitleBase;
219 
220  ExtentState mExtentState;
221 
222  QgsCoordinateReferenceSystem mOutputCrs;
223 
224  QgsRectangle mCurrentExtent;
225  QgsCoordinateReferenceSystem mCurrentCrs;
226 
227  QgsRectangle mOriginalExtent;
228  QgsCoordinateReferenceSystem mOriginalCrs;
229 
230  QMenu *mLayerMenu = nullptr;
231  QgsMapLayerModel *mMapLayerModel = nullptr;
232  QList< QAction * > mMenuActions;
233  QPointer< const QgsMapLayer > mExtentLayer;
234  QString mExtentLayerName;
235 
236  std::unique_ptr< QgsMapToolExtent > mMapToolExtent;
237  QPointer< QgsMapTool > mMapToolPrevious = nullptr;
238  QgsMapCanvas *mCanvas = nullptr;
239  QSize mRatio;
240 
241  void setExtentToLayerExtent( const QString &layerId );
242 
243 };
244 
245 #endif // QGSEXTENTGROUPBOX_H
QSize ratio() const
Returns the current fixed aspect ratio to be used when dragging extent onto the canvas.
Extent manually entered/modified by the user.
A rectangle specified with double values.
Definition: qgsrectangle.h:38
Base class for all map layer types.
Definition: qgsmaplayer.h:54
QgsRectangle originalExtent() const
Returns the original extent set for the widget.
void setRatio(QSize ratio)
Sets a fixed aspect ratio to be used when dragging extent onto the canvas.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
A groupbox that collapses/expands when toggled and can save its collapsed and checked states...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:73
ExtentState
Available states for the current extent selection in the widget.
Extent taken from a rectangled drawn onto the map canvas.
Extent taken from a layer within the project.
The QgsMapLayerModel class is a model to display layers in widgets.
QgsRectangle currentExtent() const
Returns the current extent set for the widget.
This class represents a coordinate reference system (CRS).
QgsCoordinateReferenceSystem originalCrs() const
Returns the original coordinate reference system set for the widget.
QgsExtentGroupBox::ExtentState extentState() const
Returns the currently selected state for the widget&#39;s extent.
QgsCoordinateReferenceSystem currentCrs() const
Returns the coordinate reference system for the current extent set for the widget.
Collapsible group box for configuration of extent, typically for a save operation.