QGIS API Documentation  2.99.0-Master (b058df7)
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 
47 class GUI_EXPORT QgsExtentGroupBox : public QgsCollapsibleGroupBox, private Ui::QgsExtentGroupBoxWidget
48 {
49  Q_OBJECT
50  Q_PROPERTY( QString titleBase READ titleBase WRITE setTitleBase )
51 
52  public:
53 
56  {
62  };
63 
67  explicit QgsExtentGroupBox( QWidget *parent SIP_TRANSFERTHIS = 0 );
68 
74  void setOriginalExtent( const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs );
75 
81  QgsRectangle originalExtent() const { return mOriginalExtent; }
82 
88  QgsCoordinateReferenceSystem originalCrs() const { return mOriginalCrs; }
89 
96  void setCurrentExtent( const QgsRectangle &currentExtent, const QgsCoordinateReferenceSystem &currentCrs );
97 
104  QgsRectangle currentExtent() const { return mCurrentExtent; }
105 
112  QgsCoordinateReferenceSystem currentCrs() const { return mCurrentCrs; }
113 
119  void setOutputCrs( const QgsCoordinateReferenceSystem &outputCrs );
120 
124  QgsRectangle outputExtent() const;
125 
129  QgsExtentGroupBox::ExtentState extentState() const { return mExtentState; }
130 
136  void setTitleBase( const QString &title );
137 
143  QString titleBase() const;
144 
150  void setMapCanvas( QgsMapCanvas *canvas );
151 
157  QSize ratio() const { return mRatio; }
158 
159  public slots:
160 
164  void setOutputExtentFromOriginal();
165 
169  void setOutputExtentFromCurrent();
170 
174  void setOutputExtentFromUser( const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs );
175 
180  void setOutputExtentFromLayer( const QgsMapLayer *layer );
181 
186  void setOutputExtentFromDrawOnCanvas();
187 
194  void setRatio( QSize ratio ) { mRatio = ratio; }
195 
196  signals:
197 
201  void extentChanged( const QgsRectangle &r );
202 
203  private slots:
204 
205  void groupBoxClicked();
206  void layerMenuAboutToShow();
207 
208  void extentDrawn( const QgsRectangle &extent );
209 
210  private:
211  void setOutputExtent( const QgsRectangle &r, const QgsCoordinateReferenceSystem &srcCrs, QgsExtentGroupBox::ExtentState state );
212  void setOutputExtentFromLineEdit();
213  void updateTitle();
214 
216  QString mTitleBase;
217 
218  ExtentState mExtentState = OriginalExtent;
219 
220  QgsCoordinateReferenceSystem mOutputCrs;
221 
222  QgsRectangle mCurrentExtent;
223  QgsCoordinateReferenceSystem mCurrentCrs;
224 
225  QgsRectangle mOriginalExtent;
226  QgsCoordinateReferenceSystem mOriginalCrs;
227 
228  QMenu *mLayerMenu = nullptr;
229  QgsMapLayerModel *mMapLayerModel = nullptr;
230  QList< QAction * > mMenuActions;
231  QPointer< const QgsMapLayer > mExtentLayer;
232  QString mExtentLayerName;
233 
234  std::unique_ptr< QgsMapToolExtent > mMapToolExtent;
235  QPointer< QgsMapTool > mMapToolPrevious = nullptr;
236  QgsMapCanvas *mCanvas = nullptr;
237  QSize mRatio;
238 
239  void setExtentToLayerExtent( const QString &layerId );
240 
241 };
242 
243 #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:39
Base class for all map layer types.
Definition: qgsmaplayer.h:56
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:74
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.