QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsextentwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsextentwidget.cpp
3  ---------------------
4  begin : March 2020
5  copyright : (C) 2020 by Nyall Dawson
6  email : nyall dot dawson 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 #include "qgsextentwidget.h"
17 
18 #include "qgslogger.h"
19 #include "qgscoordinatetransform.h"
20 #include "qgsmapcanvas.h"
21 #include "qgsmaplayermodel.h"
22 #include "qgsexception.h"
23 #include "qgsproject.h"
24 
25 #include <QMenu>
26 #include <QAction>
27 #include <QDoubleValidator>
28 #include <QRegularExpression>
29 
31  : QWidget( parent )
32 {
33  setupUi( this );
34  connect( mXMinLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
35  connect( mXMaxLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
36  connect( mYMinLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
37  connect( mYMaxLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
38 
39  mCondensedRe = QRegularExpression( QStringLiteral( "\\s*([\\d\\.\\-]+)\\s*,\\s*([\\d\\.\\-]+)\\s*,\\s*([\\d\\.\\-]+)\\s*,\\s*([\\d\\.\\-]+)\\s*(?:\\[(.*?)\\])?" ) );
40  mCondensedLineEdit->setValidator( new QRegularExpressionValidator( mCondensedRe, this ) );
41  mCondensedLineEdit->setShowClearButton( false );
42  connect( mCondensedLineEdit, &QgsFilterLineEdit::cleared, this, &QgsExtentWidget::clear );
43  connect( mCondensedLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromCondensedLineEdit );
44 
45  mLayerMenu = new QMenu( tr( "Calculate from Layer" ) );
46  mButtonCalcFromLayer->setMenu( mLayerMenu );
47  connect( mLayerMenu, &QMenu::aboutToShow, this, &QgsExtentWidget::layerMenuAboutToShow );
48  mMapLayerModel = new QgsMapLayerModel( this );
49 
50  mMenu = new QMenu( this );
51  mUseCanvasExtentAction = new QAction( tr( "Use Map Canvas Extent" ), this );
52  connect( mUseCanvasExtentAction, &QAction::triggered, this, &QgsExtentWidget::setOutputExtentFromCurrent );
53 
54  mUseCurrentExtentAction = new QAction( tr( "Use Current Layer Extent" ), this );
55  connect( mUseCurrentExtentAction, &QAction::triggered, this, &QgsExtentWidget::setOutputExtentFromCurrent );
56 
57  mDrawOnCanvasAction = new QAction( tr( "Draw on Canvas" ), this );
58  connect( mDrawOnCanvasAction, &QAction::triggered, this, &QgsExtentWidget::setOutputExtentFromDrawOnCanvas );
59 
60  mMenu->addMenu( mLayerMenu );
61 
62  mCondensedToolButton->setMenu( mMenu );
63  mCondensedToolButton->setPopupMode( QToolButton::InstantPopup );
64 
65  mXMinLineEdit->setValidator( new QDoubleValidator( this ) );
66  mXMaxLineEdit->setValidator( new QDoubleValidator( this ) );
67  mYMinLineEdit->setValidator( new QDoubleValidator( this ) );
68  mYMaxLineEdit->setValidator( new QDoubleValidator( this ) );
69 
70  mOriginalExtentButton->setVisible( false );
71  mButtonDrawOnCanvas->setVisible( false );
72  mCurrentExtentButton->setVisible( false );
73 
74  connect( mCurrentExtentButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromCurrent );
75  connect( mOriginalExtentButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromOriginal );
76  connect( mButtonDrawOnCanvas, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromDrawOnCanvas );
77 
78  switch ( style )
79  {
80  case CondensedStyle:
81  mExpandedWidget->hide();
82  break;
83 
84  case ExpandedStyle:
85  mCondensedFrame->hide();
86  break;
87  }
88 
89  setAcceptDrops( true );
90 }
91 
92 void QgsExtentWidget::setOriginalExtent( const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs )
93 {
94  mOriginalExtent = originalExtent;
95  mOriginalCrs = originalCrs;
96 
97  mOriginalExtentButton->setVisible( true );
98 }
99 
100 
101 void QgsExtentWidget::setCurrentExtent( const QgsRectangle &currentExtent, const QgsCoordinateReferenceSystem &currentCrs )
102 {
103  mCurrentExtent = currentExtent;
104  mCurrentCrs = currentCrs;
105 
106  mCurrentExtentButton->setVisible( true );
107  mMenu->addAction( mUseCurrentExtentAction );
108 }
109 
111 {
112  mHasFixedOutputCrs = true;
113  if ( mOutputCrs != outputCrs )
114  {
115  bool prevExtentEnabled = mIsValid;
116  switch ( mExtentState )
117  {
118  case CurrentExtent:
119  mOutputCrs = outputCrs;
121  break;
122 
123  case OriginalExtent:
124  mOutputCrs = outputCrs;
126  break;
127 
128  case ProjectLayerExtent:
129  mOutputCrs = outputCrs;
130  setOutputExtentFromLayer( mExtentLayer.data() );
131  break;
132 
133  case DrawOnCanvas:
134  mOutputCrs = outputCrs;
135  extentDrawn( outputExtent() );
136  break;
137 
138  case UserExtent:
139  try
140  {
143  mOutputCrs = outputCrs;
145  }
146  catch ( QgsCsException & )
147  {
148  // can't reproject
149  mOutputCrs = outputCrs;
150  }
151  break;
152  }
153 
154  if ( !prevExtentEnabled )
155  setValid( false );
156  }
157 }
158 
159 void QgsExtentWidget::setOutputExtent( const QgsRectangle &r, const QgsCoordinateReferenceSystem &srcCrs, ExtentState state )
160 {
161  QgsRectangle extent;
162  if ( !mHasFixedOutputCrs )
163  {
164  mOutputCrs = srcCrs;
165  extent = r;
166  }
167  else
168  {
169  if ( mOutputCrs == srcCrs )
170  {
171  extent = r;
172  }
173  else
174  {
175  try
176  {
177  QgsCoordinateTransform ct( srcCrs, mOutputCrs, QgsProject::instance() );
178  extent = ct.transformBoundingBox( r );
179  }
180  catch ( QgsCsException & )
181  {
182  // can't reproject
183  extent = r;
184  }
185  }
186  }
187 
188  int decimals = 4;
189  switch ( mOutputCrs.mapUnits() )
190  {
193  decimals = 9;
194  break;
203  decimals = 4;
204  break;
205  }
206  mXMinLineEdit->setText( QString::number( extent.xMinimum(), 'f', decimals ) );
207  mXMaxLineEdit->setText( QString::number( extent.xMaximum(), 'f', decimals ) );
208  mYMinLineEdit->setText( QString::number( extent.yMinimum(), 'f', decimals ) );
209  mYMaxLineEdit->setText( QString::number( extent.yMaximum(), 'f', decimals ) );
210 
211  QString condensed = QStringLiteral( "%1,%2,%3,%4" ).arg( mXMinLineEdit->text(),
212  mXMaxLineEdit->text(),
213  mYMinLineEdit->text(),
214  mYMaxLineEdit->text() );
215  condensed += QStringLiteral( " [%1]" ).arg( mOutputCrs.userFriendlyIdentifier( QgsCoordinateReferenceSystem::ShortString ) );
216  mCondensedLineEdit->setText( condensed );
217 
218  mExtentState = state;
219 
220  if ( !mIsValid )
221  setValid( true );
222 
223  emit extentChanged( extent );
224 }
225 
226 void QgsExtentWidget::setOutputExtentFromLineEdit()
227 {
228  mExtentState = UserExtent;
229  emit extentChanged( outputExtent() );
230 }
231 
232 void QgsExtentWidget::setOutputExtentFromCondensedLineEdit()
233 {
234  const QString text = mCondensedLineEdit->text();
235  if ( text.isEmpty() )
236  {
237  clear();
238  }
239  else
240  {
241  const QRegularExpressionMatch match = mCondensedRe.match( text );
242  if ( match.hasMatch() )
243  {
244  whileBlocking( mXMinLineEdit )->setText( match.captured( 1 ) );
245  whileBlocking( mXMaxLineEdit )->setText( match.captured( 2 ) );
246  whileBlocking( mYMinLineEdit )->setText( match.captured( 3 ) );
247  whileBlocking( mYMaxLineEdit )->setText( match.captured( 4 ) );
248  if ( !match.captured( 5 ).isEmpty() )
249  {
250  mOutputCrs = QgsCoordinateReferenceSystem( match.captured( 5 ) );
251  }
252 
253  emit extentChanged( outputExtent() );
254  if ( !mIsValid )
255  setValid( true );
256  }
257  }
258 }
259 
261 {
262  bool prevWasNull = mIsValid;
263 
264  whileBlocking( mXMinLineEdit )->clear();
265  whileBlocking( mXMaxLineEdit )->clear();
266  whileBlocking( mYMinLineEdit )->clear();
267  whileBlocking( mYMaxLineEdit )->clear();
268  whileBlocking( mCondensedLineEdit )->clearValue();
269  setValid( false );
270 
271  if ( prevWasNull )
272  emit extentChanged( outputExtent() );
273 }
274 
276 {
277  return mExtentLayerName;
278 }
279 
281 {
282  return mIsValid;
283 }
284 
285 void QgsExtentWidget::setNullValueAllowed( bool allowed, const QString &notSetText )
286 {
287  mCondensedLineEdit->setShowClearButton( allowed );
288  mCondensedLineEdit->setNullValue( notSetText );
289 }
290 
291 void QgsExtentWidget::setValid( bool valid )
292 {
293  if ( valid == mIsValid )
294  return;
295 
296  mIsValid = valid;
297  emit validationChanged( mIsValid );
298 }
299 
300 void QgsExtentWidget::layerMenuAboutToShow()
301 {
302  qDeleteAll( mLayerMenuActions );
303  mLayerMenuActions.clear();
304  mLayerMenu->clear();
305  for ( int i = 0; i < mMapLayerModel->rowCount(); ++i )
306  {
307  QModelIndex index = mMapLayerModel->index( i, 0 );
308  QIcon icon = qvariant_cast<QIcon>( mMapLayerModel->data( index, Qt::DecorationRole ) );
309  QString text = mMapLayerModel->data( index, Qt::DisplayRole ).toString();
310  QAction *act = new QAction( icon, text, mLayerMenu );
311  act->setToolTip( mMapLayerModel->data( index, Qt::ToolTipRole ).toString() );
312  QString layerId = mMapLayerModel->data( index, QgsMapLayerModel::LayerIdRole ).toString();
313  if ( mExtentState == ProjectLayerExtent && mExtentLayer && mExtentLayer->id() == layerId )
314  {
315  act->setCheckable( true );
316  act->setChecked( true );
317  }
318  connect( act, &QAction::triggered, this, [this, layerId]
319  {
320  setExtentToLayerExtent( layerId );
321  } );
322  mLayerMenu->addAction( act );
323  mLayerMenuActions << act;
324  }
325 }
326 
327 void QgsExtentWidget::setExtentToLayerExtent( const QString &layerId )
328 {
329  QgsMapLayer *layer = QgsProject::instance()->mapLayer( layerId );
330  if ( !layer )
331  return;
332 
333  setOutputExtentFromLayer( layer );
334 }
335 
336 QgsMapLayer *QgsExtentWidget::mapLayerFromMimeData( const QMimeData *data ) const
337 {
339  for ( const QgsMimeDataUtils::Uri &u : uriList )
340  {
341  // is this uri from the current project?
342  if ( QgsMapLayer *layer = u.mapLayer() )
343  {
344  return layer;
345  }
346  }
347  return nullptr;
348 }
349 
351 {
352  if ( mCanvas )
353  {
354  // Use unrotated visible extent to insure output size and scale matches canvas
355  QgsMapSettings ms = mCanvas->mapSettings();
356  ms.setRotation( 0 );
357  setOutputExtent( ms.visibleExtent(), ms.destinationCrs(), CurrentExtent );
358  }
359  else
360  {
361  setOutputExtent( mCurrentExtent, mCurrentCrs, CurrentExtent );
362  }
363 }
364 
365 
367 {
368  setOutputExtent( mOriginalExtent, mOriginalCrs, OriginalExtent );
369 }
370 
372 {
373  setOutputExtent( extent, crs, UserExtent );
374 }
375 
377 {
378  if ( !layer )
379  return;
380 
381  mExtentLayer = layer;
382  mExtentLayerName = layer->name();
383 
384  setOutputExtent( layer->extent(), layer->crs(), ProjectLayerExtent );
385 }
386 
388 {
389  if ( mCanvas )
390  {
391  mMapToolPrevious = mCanvas->mapTool();
392  if ( !mMapToolExtent )
393  {
394  mMapToolExtent.reset( new QgsMapToolExtent( mCanvas ) );
395  connect( mMapToolExtent.get(), &QgsMapToolExtent::extentChanged, this, &QgsExtentWidget::extentDrawn );
396  connect( mMapToolExtent.get(), &QgsMapTool::deactivated, this, [ = ]
397  {
398  emit toggleDialogVisibility( true );
399  mMapToolPrevious = nullptr;
400  } );
401  }
402  mMapToolExtent->setRatio( mRatio );
403  mCanvas->setMapTool( mMapToolExtent.get() );
404 
405  emit toggleDialogVisibility( false );
406  }
407 }
408 
409 void QgsExtentWidget::extentDrawn( const QgsRectangle &extent )
410 {
411  setOutputExtent( extent, mCanvas->mapSettings().destinationCrs(), DrawOnCanvas );
412  mCanvas->setMapTool( mMapToolPrevious );
413  emit toggleDialogVisibility( true );
414  mMapToolPrevious = nullptr;
415 }
416 
418 {
419  return QgsRectangle( mXMinLineEdit->text().toDouble(), mYMinLineEdit->text().toDouble(),
420  mXMaxLineEdit->text().toDouble(), mYMaxLineEdit->text().toDouble() );
421 }
422 
424 {
425  if ( canvas )
426  {
427  mCanvas = canvas;
428  mButtonDrawOnCanvas->setVisible( true );
429  mCurrentExtentButton->setVisible( true );
430 
431  mMenu->addAction( mUseCanvasExtentAction );
432  mMenu->addAction( mDrawOnCanvasAction );
433  }
434  else
435  {
436  mButtonDrawOnCanvas->setVisible( false );
437  mCurrentExtentButton->setVisible( false );
438  mMenu->removeAction( mUseCanvasExtentAction );
439  mMenu->removeAction( mDrawOnCanvasAction );
440  }
441 }
442 
443 void QgsExtentWidget::dragEnterEvent( QDragEnterEvent *event )
444 {
445  if ( !( event->possibleActions() & Qt::CopyAction ) )
446  {
447  event->ignore();
448  return;
449  }
450 
451  if ( mapLayerFromMimeData( event->mimeData() ) )
452  {
453  // dragged an acceptable layer, phew
454  event->setDropAction( Qt::CopyAction );
455  event->accept();
456  mCondensedLineEdit->setHighlighted( true );
457  update();
458  }
459  else
460  {
461  event->ignore();
462  }
463 }
464 
465 void QgsExtentWidget::dragLeaveEvent( QDragLeaveEvent *event )
466 {
467  if ( mCondensedLineEdit->isHighlighted() )
468  {
469  event->accept();
470  mCondensedLineEdit->setHighlighted( false );
471  update();
472  }
473  else
474  {
475  event->ignore();
476  }
477 }
478 
479 void QgsExtentWidget::dropEvent( QDropEvent *event )
480 {
481  if ( !( event->possibleActions() & Qt::CopyAction ) )
482  {
483  event->ignore();
484  return;
485  }
486 
487  if ( QgsMapLayer *layer = mapLayerFromMimeData( event->mimeData() ) )
488  {
489  // dropped a map layer
490  setFocus( Qt::MouseFocusReason );
491  event->setDropAction( Qt::CopyAction );
492  event->accept();
493 
494  setOutputExtentFromLayer( layer );
495  }
496  else
497  {
498  event->ignore();
499  }
500  mCondensedLineEdit->setHighlighted( false );
501  update();
502 }
QgsMapLayer::crs
QgsCoordinateReferenceSystem crs
Definition: qgsmaplayer.h:89
QgsMapToolExtent::extentChanged
void extentChanged(const QgsRectangle &extent)
signal emitted on extent change
QgsExtentWidget::currentCrs
QgsCoordinateReferenceSystem currentCrs() const
Returns the coordinate reference system for the current extent set for the widget.
Definition: qgsextentwidget.h:121
outputCrs
const QgsCoordinateReferenceSystem & outputCrs
Definition: qgswfsgetfeature.cpp:61
QgsCoordinateReferenceSystem::mapUnits
Q_GADGET QgsUnitTypes::DistanceUnit mapUnits
Definition: qgscoordinatereferencesystem.h:209
QgsExtentWidget::originalCrs
QgsCoordinateReferenceSystem originalCrs() const
Returns the original coordinate reference system set for the widget.
Definition: qgsextentwidget.h:97
QgsExtentWidget::CurrentExtent
@ CurrentExtent
Map canvas extent.
Definition: qgsextentwidget.h:60
QgsExtentWidget::DrawOnCanvas
@ DrawOnCanvas
Extent taken from a rectangled drawn onto the map canvas.
Definition: qgsextentwidget.h:63
qgsmapcanvas.h
QgsMapSettings::setRotation
void setRotation(double rotation)
Sets the rotation of the resulting map image, in degrees clockwise.
Definition: qgsmapsettings.cpp:106
QgsMapCanvas::mapTool
QgsMapTool * mapTool()
Returns the currently active tool.
Definition: qgsmapcanvas.cpp:2281
QgsCoordinateReferenceSystem::userFriendlyIdentifier
QString userFriendlyIdentifier(IdentifierType type=MediumString) const
Returns a user friendly identifier for the CRS.
Definition: qgscoordinatereferencesystem.cpp:1338
QgsUnitTypes::DistanceUnknownUnit
@ DistanceUnknownUnit
Unknown distance unit.
Definition: qgsunittypes.h:78
QgsExtentWidget::OriginalExtent
@ OriginalExtent
Layer's extent.
Definition: qgsextentwidget.h:59
QgsExtentWidget::clear
void clear()
Clears the widget, setting it to a null value.
Definition: qgsextentwidget.cpp:260
QgsExtentWidget::outputExtent
QgsRectangle outputExtent() const
Returns the extent shown in the widget - in output CRS coordinates.
Definition: qgsextentwidget.cpp:417
QgsExtentWidget::setOutputExtentFromOriginal
void setOutputExtentFromOriginal()
Sets the output extent to be the same as original extent (may be transformed to output CRS).
Definition: qgsextentwidget.cpp:366
QgsExtentWidget::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *event) override
Definition: qgsextentwidget.cpp:443
QgsMapCanvas::mapSettings
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
Definition: qgsmapcanvas.cpp:391
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:51
QgsRectangle::yMinimum
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:177
QgsExtentWidget::setCurrentExtent
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 whenev...
Definition: qgsextentwidget.cpp:101
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:85
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:468
QgsMapLayerModel::data
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: qgsmaplayermodel.cpp:241
QgsMapLayerModel::LayerIdRole
@ LayerIdRole
Stores the map layer ID.
Definition: qgsmaplayermodel.h:50
QgsMimeDataUtils::UriList
QList< QgsMimeDataUtils::Uri > UriList
Definition: qgsmimedatautils.h:156
QgsProject::mapLayer
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
Definition: qgsproject.cpp:3208
QgsUnitTypes::DistanceKilometers
@ DistanceKilometers
Kilometers.
Definition: qgsunittypes.h:70
qgsextentwidget.h
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsExtentWidget::UserExtent
@ UserExtent
Extent manually entered/modified by the user.
Definition: qgsextentwidget.h:61
QgsCoordinateTransform::transformBoundingBox
QgsRectangle transformBoundingBox(const QgsRectangle &rectangle, TransformDirection direction=ForwardTransform, bool handle180Crossover=false) const SIP_THROW(QgsCsException)
Transforms a rectangle from the source CRS to the destination CRS.
Definition: qgscoordinatetransform.cpp:511
QgsExtentWidget::setOutputExtentFromDrawOnCanvas
void setOutputExtentFromDrawOnCanvas()
Sets the output extent by dragging on the canvas.
Definition: qgsextentwidget.cpp:387
QgsExtentWidget::CondensedStyle
@ CondensedStyle
Shows a compressed widget, for use when available space is minimal.
Definition: qgsextentwidget.h:69
QgsExtentWidget::outputCrs
QgsCoordinateReferenceSystem outputCrs() const
Returns the current output CRS, used in the display.
Definition: qgsextentwidget.h:140
QgsRectangle::xMaximum
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
Definition: qgsrectangle.h:162
QgsExtentWidget::setOutputExtentFromUser
void setOutputExtentFromUser(const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs)
Sets the output extent to a custom extent (may be transformed to output CRS).
Definition: qgsextentwidget.cpp:371
QgsMapLayerModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: qgsmaplayermodel.cpp:226
QgsExtentWidget::setOutputCrs
void setOutputCrs(const QgsCoordinateReferenceSystem &outputCrs)
Sets the output CRS - may need to be used for transformation from original/current extent.
Definition: qgsextentwidget.cpp:110
QgsCsException
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:66
QgsExtentWidget::extentChanged
void extentChanged(const QgsRectangle &r)
Emitted when the widget's extent is changed.
QgsUnitTypes::DistanceDegrees
@ DistanceDegrees
Degrees, for planar geographic CRS distance measurements.
Definition: qgsunittypes.h:75
whileBlocking
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:262
QgsExtentWidget::toggleDialogVisibility
void toggleDialogVisibility(bool visible)
Emitted when the parent dialog visibility must be changed (e.g.
QgsExtentWidget::setOutputExtentFromCurrent
void setOutputExtentFromCurrent()
Sets the output extent to be the same as current extent (may be transformed to output CRS).
Definition: qgsextentwidget.cpp:350
QgsExtentWidget::ExpandedStyle
@ ExpandedStyle
Shows an expanded widget, for use when space is not constrained.
Definition: qgsextentwidget.h:70
QgsMapLayer::extent
virtual QgsRectangle extent() const
Returns the extent of the layer.
Definition: qgsmaplayer.cpp:197
QgsExtentWidget::setOriginalExtent
void setOriginalExtent(const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs)
Sets the original extent and coordinate reference system for the widget.
Definition: qgsextentwidget.cpp:92
QgsExtentWidget::setMapCanvas
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas to enable dragging of extent on a canvas.
Definition: qgsextentwidget.cpp:423
QgsExtentWidget::QgsExtentWidget
QgsExtentWidget(QWidget *parent=nullptr, WidgetStyle style=CondensedStyle)
Constructor for QgsExtentWidget.
Definition: qgsextentwidget.cpp:30
QgsUnitTypes::DistanceFeet
@ DistanceFeet
Imperial feet.
Definition: qgsunittypes.h:71
QgsUnitTypes::DistanceMeters
@ DistanceMeters
Meters.
Definition: qgsunittypes.h:69
qgscoordinatetransform.h
QgsExtentWidget::WidgetStyle
WidgetStyle
Widget styles.
Definition: qgsextentwidget.h:68
QgsRectangle::xMinimum
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
Definition: qgsrectangle.h:167
QgsExtentWidget::extentLayerName
QString extentLayerName() const
Returns the name of the extent layer.
Definition: qgsextentwidget.cpp:275
QgsMapCanvas::setMapTool
void setMapTool(QgsMapTool *mapTool, bool clean=false)
Sets the map tool currently being used on the canvas.
Definition: qgsmapcanvas.cpp:2006
QgsMimeDataUtils::Uri
Definition: qgsmimedatautils.h:41
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsMapSettings::destinationCrs
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
Definition: qgsmapsettings.cpp:318
QgsCoordinateReferenceSystem::ShortString
@ ShortString
A heavily abbreviated string, for use when a compact representation is required.
Definition: qgscoordinatereferencesystem.h:631
QgsExtentWidget::dragLeaveEvent
void dragLeaveEvent(QDragLeaveEvent *event) override
Definition: qgsextentwidget.cpp:465
QgsRectangle::yMaximum
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
Definition: qgsrectangle.h:172
QgsMimeDataUtils::decodeUriList
static UriList decodeUriList(const QMimeData *data)
Definition: qgsmimedatautils.cpp:211
QgsUnitTypes::DistanceMillimeters
@ DistanceMillimeters
Millimeters.
Definition: qgsunittypes.h:77
qgsmaplayermodel.h
QgsUnitTypes::DistanceCentimeters
@ DistanceCentimeters
Centimeters.
Definition: qgsunittypes.h:76
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
QgsExtentWidget::validationChanged
void validationChanged(bool valid)
Emitted when the widget's validation state changes.
QgsMapToolExtent
A map tool that emits an extent from a rectangle drawn onto the map canvas.
Definition: qgsmaptoolextent.h:34
QgsExtentWidget::setOutputExtentFromLayer
void setOutputExtentFromLayer(const QgsMapLayer *layer)
Sets the output extent to match a layer's extent (may be transformed to output CRS).
Definition: qgsextentwidget.cpp:376
QgsMapLayer::name
QString name
Definition: qgsmaplayer.h:86
QgsUnitTypes::DistanceYards
@ DistanceYards
Imperial yards.
Definition: qgsunittypes.h:73
QgsUnitTypes::DistanceMiles
@ DistanceMiles
Terrestrial miles.
Definition: qgsunittypes.h:74
QgsFilterLineEdit::cleared
void cleared()
Emitted when the widget is cleared.
QgsExtentWidget::setNullValueAllowed
void setNullValueAllowed(bool allowed, const QString &notSetText=QString())
Sets whether the widget can be set to a "not set" (null) state.
Definition: qgsextentwidget.cpp:285
QgsExtentWidget::originalExtent
QgsRectangle originalExtent() const
Returns the original extent set for the widget.
Definition: qgsextentwidget.h:90
qgsexception.h
QgsUnitTypes::DistanceNauticalMiles
@ DistanceNauticalMiles
Nautical miles.
Definition: qgsunittypes.h:72
QgsMapLayerModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: qgsmaplayermodel.cpp:200
QgsExtentWidget::currentExtent
QgsRectangle currentExtent() const
Returns the current extent set for the widget.
Definition: qgsextentwidget.h:113
QgsExtentWidget::dropEvent
void dropEvent(QDropEvent *event) override
Definition: qgsextentwidget.cpp:479
qgslogger.h
QgsMapSettings
The QgsMapSettings class contains configuration for rendering of the map.
Definition: qgsmapsettings.h:88
QgsMapSettings::visibleExtent
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes takes output image size into accou...
Definition: qgsmapsettings.cpp:371
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:53
QgsExtentWidget::ProjectLayerExtent
@ ProjectLayerExtent
Extent taken from a layer within the project.
Definition: qgsextentwidget.h:62
qgsproject.h
QgsMapLayerModel
The QgsMapLayerModel class is a model to display layers in widgets.
Definition: qgsmaplayermodel.h:37
QgsMapTool::deactivated
void deactivated()
signal emitted once the map tool is deactivated
QgsExtentWidget::isValid
bool isValid() const
Returns true if the widget is in a valid state, i.e.
Definition: qgsextentwidget.cpp:280