QGIS API Documentation  2.99.0-Master (c4aa4d0)
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 = nullptr );
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 
125  QgsRectangle outputExtent() const;
126 
132  QgsCoordinateReferenceSystem outputCrs() const { return mOutputCrs; }
133 
137  QgsExtentGroupBox::ExtentState extentState() const { return mExtentState; }
138 
144  void setTitleBase( const QString &title );
145 
151  QString titleBase() const;
152 
158  void setMapCanvas( QgsMapCanvas *canvas );
159 
165  QSize ratio() const { return mRatio; }
166 
167  public slots:
168 
172  void setOutputExtentFromOriginal();
173 
177  void setOutputExtentFromCurrent();
178 
182  void setOutputExtentFromUser( const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs );
183 
188  void setOutputExtentFromLayer( const QgsMapLayer *layer );
189 
194  void setOutputExtentFromDrawOnCanvas();
195 
202  void setRatio( QSize ratio ) { mRatio = ratio; }
203 
204  signals:
205 
209  void extentChanged( const QgsRectangle &r );
210 
211  private slots:
212 
213  void groupBoxClicked();
214  void layerMenuAboutToShow();
215 
216  void extentDrawn( const QgsRectangle &extent );
217 
218  private:
219  void setOutputExtent( const QgsRectangle &r, const QgsCoordinateReferenceSystem &srcCrs, QgsExtentGroupBox::ExtentState state );
220  void setOutputExtentFromLineEdit();
221  void updateTitle();
222 
224  QString mTitleBase;
225 
226  ExtentState mExtentState = OriginalExtent;
227 
228  QgsCoordinateReferenceSystem mOutputCrs;
229 
230  QgsRectangle mCurrentExtent;
231  QgsCoordinateReferenceSystem mCurrentCrs;
232 
233  QgsRectangle mOriginalExtent;
234  QgsCoordinateReferenceSystem mOriginalCrs;
235 
236  QMenu *mLayerMenu = nullptr;
237  QgsMapLayerModel *mMapLayerModel = nullptr;
238  QList< QAction * > mMenuActions;
239  QPointer< const QgsMapLayer > mExtentLayer;
240  QString mExtentLayerName;
241 
242  std::unique_ptr< QgsMapToolExtent > mMapToolExtent;
243  QPointer< QgsMapTool > mMapToolPrevious = nullptr;
244  QgsMapCanvas *mCanvas = nullptr;
245  QSize mRatio;
246 
247  void setExtentToLayerExtent( const QString &layerId );
248 
249 };
250 
251 #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.
QgsCoordinateReferenceSystem outputCrs() const
Returns the current output CRS, used in the display.
Collapsible group box for configuration of extent, typically for a save operation.