QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 "qgsapplication.h"
19 #include "qgslogger.h"
20 #include "qgscoordinatetransform.h"
21 #include "qgsmapcanvas.h"
22 #include "qgsmaplayerproxymodel.h"
23 #include "qgsmaplayermodel.h"
24 #include "qgsexception.h"
25 #include "qgsproject.h"
26 #include "qgsdoublevalidator.h"
27 #include "qgslayoutmanager.h"
28 #include "qgslayoutitemmap.h"
29 #include "qgsprintlayout.h"
30 #include "qgsbookmarkmodel.h"
31 #include "qgsreferencedgeometry.h"
32 
33 #include <QMenu>
34 #include <QAction>
35 #include <QRegularExpression>
36 
38  : QWidget( parent )
39 {
40  setupUi( this );
41  connect( mXMinLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
42  connect( mXMaxLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
43  connect( mYMinLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
44  connect( mYMaxLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
45 
46  mCondensedRe = QRegularExpression( QStringLiteral( "\\s*([\\d\\.\\-]+)\\s*,\\s*([\\d\\.\\-]+)\\s*,\\s*([\\d\\.\\-]+)\\s*,\\s*([\\d\\.\\-]+)\\s*(?:\\[(.*?)\\])?" ) );
47  mCondensedLineEdit->setValidator( new QRegularExpressionValidator( mCondensedRe, this ) );
48  mCondensedLineEdit->setShowClearButton( false );
49  connect( mCondensedLineEdit, &QgsFilterLineEdit::cleared, this, &QgsExtentWidget::clear );
50  connect( mCondensedLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromCondensedLineEdit );
51 
52  mLayerMenu = new QMenu( tr( "Calculate from Layer" ), this );
53  mButtonCalcFromLayer->setMenu( mLayerMenu );
54  connect( mLayerMenu, &QMenu::aboutToShow, this, &QgsExtentWidget::layerMenuAboutToShow );
55  mMapLayerModel = new QgsMapLayerProxyModel( this );
56  mMapLayerModel->setFilters( QgsMapLayerProxyModel::Filter::SpatialLayer );
57 
58  mLayoutMenu = new QMenu( tr( "Calculate from Layout Map" ), this );
59  mButtonCalcFromLayout->setMenu( mLayoutMenu );
60  connect( mLayoutMenu, &QMenu::aboutToShow, this, &QgsExtentWidget::layoutMenuAboutToShow );
61 
62  mBookmarkMenu = new QMenu( tr( "Calculate from Bookmark" ), this );
63  mButtonCalcFromBookmark->setMenu( mBookmarkMenu );
64  connect( mBookmarkMenu, &QMenu::aboutToShow, this, &QgsExtentWidget::bookmarkMenuAboutToShow );
65 
66  mMenu = new QMenu( this );
67  mUseCanvasExtentAction = new QAction( tr( "Use Current Map Canvas Extent" ), this );
68  mUseCanvasExtentAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionMapIdentification.svg" ) ) );
69  mUseCanvasExtentAction->setVisible( false );
70  connect( mUseCanvasExtentAction, &QAction::triggered, this, &QgsExtentWidget::setOutputExtentFromCurrent );
71 
72  mUseCurrentExtentAction = new QAction( tr( "Use Current Layer/Default Extent" ), this );
73  mUseCurrentExtentAction->setVisible( false );
74  connect( mUseCurrentExtentAction, &QAction::triggered, this, &QgsExtentWidget::setOutputExtentFromCurrent );
75 
76  mDrawOnCanvasAction = new QAction( tr( "Draw on Map Canvas" ), this );
77  mDrawOnCanvasAction->setVisible( false );
78  connect( mDrawOnCanvasAction, &QAction::triggered, this, &QgsExtentWidget::setOutputExtentFromDrawOnCanvas );
79 
80  mMenu->addMenu( mLayerMenu );
81  mMenu->addMenu( mLayoutMenu );
82  mMenu->addMenu( mBookmarkMenu );
83  mMenu->addSeparator();
84  mMenu->addAction( mUseCanvasExtentAction );
85  mMenu->addAction( mDrawOnCanvasAction );
86  mMenu->addAction( mUseCurrentExtentAction );
87 
88  mCondensedToolButton->setMenu( mMenu );
89  mCondensedToolButton->setPopupMode( QToolButton::InstantPopup );
90 
91  mXMinLineEdit->setValidator( new QgsDoubleValidator( this ) );
92  mXMaxLineEdit->setValidator( new QgsDoubleValidator( this ) );
93  mYMinLineEdit->setValidator( new QgsDoubleValidator( this ) );
94  mYMaxLineEdit->setValidator( new QgsDoubleValidator( this ) );
95 
96  mOriginalExtentButton->setVisible( false );
97  mButtonDrawOnCanvas->setVisible( false );
98  mCurrentExtentButton->setVisible( false );
99 
100  connect( mCurrentExtentButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromCurrent );
101  connect( mOriginalExtentButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromOriginal );
102  connect( mButtonDrawOnCanvas, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromDrawOnCanvas );
103 
104  switch ( style )
105  {
106  case CondensedStyle:
107  mExpandedWidget->hide();
108  break;
109 
110  case ExpandedStyle:
111  mCondensedFrame->hide();
112  break;
113  }
114 
115  setAcceptDrops( true );
116 }
117 
119 {
120  if ( mMapToolExtent )
121  {
122  // disconnect from deactivated signal -- this will be called when the map tool is being destroyed,
123  // and we don't want to act on that anymore (the mapToolDeactivated slot tries to show the widget again, but
124  // that's being destroyed!)
125  disconnect( mMapToolExtent.get(), &QgsMapToolExtent::deactivated, this, &QgsExtentWidget::mapToolDeactivated );
126  }
127 }
128 
129 void QgsExtentWidget::setOriginalExtent( const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs )
130 {
131  mOriginalExtent = originalExtent;
132  mOriginalCrs = originalCrs;
133 
134  mOriginalExtentButton->setVisible( true );
135 }
136 
137 
138 void QgsExtentWidget::setCurrentExtent( const QgsRectangle &currentExtent, const QgsCoordinateReferenceSystem &currentCrs )
139 {
140  mCurrentExtent = currentExtent;
141  mCurrentCrs = currentCrs;
142 
143  mCurrentExtentButton->setVisible( true );
144  mUseCurrentExtentAction->setVisible( true );
145 }
146 
148 {
149  mHasFixedOutputCrs = true;
150  if ( mOutputCrs != outputCrs )
151  {
152  const bool prevExtentEnabled = mIsValid;
153  switch ( mExtentState )
154  {
155  case CurrentExtent:
156  mOutputCrs = outputCrs;
158  break;
159 
160  case OriginalExtent:
161  mOutputCrs = outputCrs;
163  break;
164 
165  case ProjectLayerExtent:
166  mOutputCrs = outputCrs;
167  setOutputExtentFromLayer( mExtentLayer.data() );
168  break;
169 
170  case DrawOnCanvas:
171  mOutputCrs = outputCrs;
172  extentDrawn( outputExtent() );
173  break;
174 
175  case UserExtent:
176  try
177  {
180  const QgsRectangle extent = ct.transformBoundingBox( outputExtent() );
181  mOutputCrs = outputCrs;
183  }
184  catch ( QgsCsException & )
185  {
186  // can't reproject
187  mOutputCrs = outputCrs;
188  }
189  break;
190  }
191 
192  if ( !prevExtentEnabled )
193  setValid( false );
194  }
195 }
196 
197 void QgsExtentWidget::setOutputExtent( const QgsRectangle &r, const QgsCoordinateReferenceSystem &srcCrs, ExtentState state )
198 {
199  QgsRectangle extent;
200  if ( !mHasFixedOutputCrs )
201  {
202  mOutputCrs = srcCrs;
203  extent = r;
204  }
205  else
206  {
207  if ( mOutputCrs == srcCrs )
208  {
209  extent = r;
210  }
211  else
212  {
213  try
214  {
215  QgsCoordinateTransform ct( srcCrs, mOutputCrs, QgsProject::instance() );
216  ct.setBallparkTransformsAreAppropriate( true );
217  extent = ct.transformBoundingBox( r );
218  }
219  catch ( QgsCsException & )
220  {
221  // can't reproject
222  extent = r;
223  }
224  }
225  }
226 
227  int decimals = 4;
228  switch ( mOutputCrs.mapUnits() )
229  {
232  decimals = 9;
233  break;
242  decimals = 4;
243  break;
244  }
245  mXMinLineEdit->setText( QLocale().toString( extent.xMinimum(), 'f', decimals ) );
246  mXMaxLineEdit->setText( QLocale().toString( extent.xMaximum(), 'f', decimals ) );
247  mYMinLineEdit->setText( QLocale().toString( extent.yMinimum(), 'f', decimals ) );
248  mYMaxLineEdit->setText( QLocale().toString( extent.yMaximum(), 'f', decimals ) );
249 
250  QString condensed = QStringLiteral( "%1,%2,%3,%4" ).arg( QString::number( extent.xMinimum(), 'f', decimals ),
251  QString::number( extent.xMaximum(), 'f', decimals ),
252  QString::number( extent.yMinimum(), 'f', decimals ),
253  QString::number( extent.yMaximum(), 'f', decimals ) );
254  condensed += QStringLiteral( " [%1]" ).arg( mOutputCrs.userFriendlyIdentifier( QgsCoordinateReferenceSystem::ShortString ) );
255  mCondensedLineEdit->setText( condensed );
256 
257  mExtentState = state;
258 
259  if ( !mIsValid )
260  setValid( true );
261 
262  emit extentChanged( extent );
263 }
264 
265 void QgsExtentWidget::setOutputExtentFromLineEdit()
266 {
267  mExtentState = UserExtent;
268  emit extentChanged( outputExtent() );
269 }
270 
271 void QgsExtentWidget::setOutputExtentFromCondensedLineEdit()
272 {
273  const QString text = mCondensedLineEdit->text();
274  if ( text.isEmpty() )
275  {
276  clear();
277  }
278  else
279  {
280  const QRegularExpressionMatch match = mCondensedRe.match( text );
281  if ( match.hasMatch() )
282  {
283  // Localization
284  whileBlocking( mXMinLineEdit )->setText( QLocale().toString( match.captured( 1 ).toDouble(), 'f', 10 ) );
285  whileBlocking( mXMaxLineEdit )->setText( QLocale().toString( match.captured( 2 ).toDouble(), 'f', 10 ) );
286  whileBlocking( mYMinLineEdit )->setText( QLocale().toString( match.captured( 3 ).toDouble(), 'f', 10 ) );
287  whileBlocking( mYMaxLineEdit )->setText( QLocale().toString( match.captured( 4 ).toDouble(), 'f', 10 ) );
288  if ( !match.captured( 5 ).isEmpty() )
289  {
290  mOutputCrs = QgsCoordinateReferenceSystem( match.captured( 5 ) );
291  }
292 
293  emit extentChanged( outputExtent() );
294  if ( !mIsValid )
295  setValid( true );
296  }
297  }
298 }
299 
301 {
302  const bool prevWasNull = mIsValid;
303 
304  whileBlocking( mXMinLineEdit )->clear();
305  whileBlocking( mXMaxLineEdit )->clear();
306  whileBlocking( mYMinLineEdit )->clear();
307  whileBlocking( mYMaxLineEdit )->clear();
308  whileBlocking( mCondensedLineEdit )->clearValue();
309  setValid( false );
310 
311  if ( prevWasNull )
312  emit extentChanged( outputExtent() );
313 }
314 
316 {
317  return mExtentLayerName;
318 }
319 
321 {
322  return mIsValid;
323 }
324 
325 void QgsExtentWidget::setNullValueAllowed( bool allowed, const QString &notSetText )
326 {
327  mCondensedLineEdit->setShowClearButton( allowed );
328  mCondensedLineEdit->setNullValue( notSetText );
329 }
330 
331 void QgsExtentWidget::setValid( bool valid )
332 {
333  if ( valid == mIsValid )
334  return;
335 
336  mIsValid = valid;
337  emit validationChanged( mIsValid );
338 }
339 
340 void QgsExtentWidget::layerMenuAboutToShow()
341 {
342  qDeleteAll( mLayerMenuActions );
343  mLayerMenuActions.clear();
344  mLayerMenu->clear();
345  for ( int i = 0; i < mMapLayerModel->rowCount(); ++i )
346  {
347  const QModelIndex index = mMapLayerModel->index( i, 0 );
348  const QIcon icon = qvariant_cast<QIcon>( mMapLayerModel->data( index, Qt::DecorationRole ) );
349  const QString text = mMapLayerModel->data( index, Qt::DisplayRole ).toString();
350  QAction *act = new QAction( icon, text, mLayerMenu );
351  act->setToolTip( mMapLayerModel->data( index, Qt::ToolTipRole ).toString() );
352  const QString layerId = mMapLayerModel->data( index, QgsMapLayerModel::LayerIdRole ).toString();
353  if ( mExtentState == ProjectLayerExtent && mExtentLayer && mExtentLayer->id() == layerId )
354  {
355  act->setCheckable( true );
356  act->setChecked( true );
357  }
358  connect( act, &QAction::triggered, this, [this, layerId]
359  {
360  setExtentToLayerExtent( layerId );
361  } );
362  mLayerMenu->addAction( act );
363  mLayerMenuActions << act;
364  }
365 }
366 
367 void QgsExtentWidget::layoutMenuAboutToShow()
368 {
369  mLayoutMenu->clear();
370 
371  if ( QgsLayoutManager *manager = QgsProject::instance()->layoutManager() )
372  {
373  const QList<QgsPrintLayout *> layouts = manager->printLayouts();
374  for ( const QgsPrintLayout *layout : layouts )
375  {
376  QList< QgsLayoutItemMap * > maps;
377  layout->layoutItems( maps );
378  if ( maps.empty() )
379  continue;
380 
381  QMenu *layoutMenu = new QMenu( layout->name(), mMenu );
382  for ( const QgsLayoutItemMap *map : std::as_const( maps ) )
383  {
384  QgsRectangle extent = map->extent();
385  QgsCoordinateReferenceSystem crs = map->crs();
386  QAction *mapExtentAction = new QAction( tr( "%1" ).arg( map->displayName() ), mLayoutMenu );
387  connect( mapExtentAction, &QAction::triggered, this, [this, extent, crs] { setOutputExtentFromUser( extent, crs ); } );
388  layoutMenu->addAction( mapExtentAction );
389  }
390  mLayoutMenu->addMenu( layoutMenu );
391  }
392  }
393 }
394 
395 void QgsExtentWidget::bookmarkMenuAboutToShow()
396 {
397  mBookmarkMenu->clear();
398 
399  if ( !mBookmarkModel )
400  mBookmarkModel = new QgsBookmarkManagerProxyModel( QgsApplication::bookmarkManager(), QgsProject::instance()->bookmarkManager(), this );
401 
402  QMap< QString, QMenu * > groupMenus;
403  for ( int i = 0; i < mBookmarkModel->rowCount(); ++i )
404  {
405  const QString group = mBookmarkModel->data( mBookmarkModel->index( i, 0 ), QgsBookmarkManagerModel::RoleGroup ).toString();
406  QMenu *destMenu = mBookmarkMenu;
407  if ( !group.isEmpty() )
408  {
409  destMenu = groupMenus.value( group );
410  if ( !destMenu )
411  {
412  destMenu = new QMenu( group, mBookmarkMenu );
413  groupMenus[ group ] = destMenu;
414  }
415  }
416  QAction *action = new QAction( mBookmarkModel->data( mBookmarkModel->index( i, 0 ), QgsBookmarkManagerModel::RoleName ).toString(), mBookmarkMenu );
417  const QgsReferencedRectangle extent = mBookmarkModel->data( mBookmarkModel->index( i, 0 ), QgsBookmarkManagerModel::RoleExtent ).value< QgsReferencedRectangle >();
418  connect( action, &QAction::triggered, this, [ = ] { setOutputExtentFromUser( extent, extent.crs() ); } );
419  destMenu->addAction( action );
420  }
421 
422  QStringList groupKeys = groupMenus.keys();
423  groupKeys.sort( Qt::CaseInsensitive );
424  for ( int i = 0; i < groupKeys.count(); ++i )
425  {
426  if ( mBookmarkMenu->actions().value( i ) )
427  mBookmarkMenu->insertMenu( mBookmarkMenu->actions().at( i ), groupMenus.value( groupKeys.at( i ) ) );
428  else
429  mBookmarkMenu->addMenu( groupMenus.value( groupKeys.at( i ) ) );
430  }
431 }
432 
433 void QgsExtentWidget::setExtentToLayerExtent( const QString &layerId )
434 {
435  QgsMapLayer *layer = QgsProject::instance()->mapLayer( layerId );
436  if ( !layer )
437  return;
438 
439  setOutputExtentFromLayer( layer );
440 }
441 
442 QgsMapLayer *QgsExtentWidget::mapLayerFromMimeData( const QMimeData *data ) const
443 {
445  for ( const QgsMimeDataUtils::Uri &u : uriList )
446  {
447  // is this uri from the current project?
448  if ( QgsMapLayer *layer = u.mapLayer() )
449  {
450  return layer;
451  }
452  }
453  return nullptr;
454 }
455 
457 {
458  if ( mCanvas )
459  {
460  // Use unrotated visible extent to insure output size and scale matches canvas
461  QgsMapSettings ms = mCanvas->mapSettings();
462  ms.setRotation( 0 );
463  setOutputExtent( ms.visibleExtent(), ms.destinationCrs(), CurrentExtent );
464  }
465  else
466  {
467  setOutputExtent( mCurrentExtent, mCurrentCrs, CurrentExtent );
468  }
469 }
470 
471 
473 {
474  setOutputExtent( mOriginalExtent, mOriginalCrs, OriginalExtent );
475 }
476 
478 {
479  setOutputExtent( extent, crs, UserExtent );
480 }
481 
483 {
484  if ( !layer )
485  return;
486 
487  mExtentLayer = layer;
488  mExtentLayerName = layer->name();
489 
490  setOutputExtent( layer->extent(), layer->crs(), ProjectLayerExtent );
491 }
492 
494 {
495  if ( mCanvas )
496  {
497  mMapToolPrevious = mCanvas->mapTool();
498  if ( !mMapToolExtent )
499  {
500  mMapToolExtent.reset( new QgsMapToolExtent( mCanvas ) );
501  connect( mMapToolExtent.get(), &QgsMapToolExtent::extentChanged, this, &QgsExtentWidget::extentDrawn );
502  connect( mMapToolExtent.get(), &QgsMapTool::deactivated, this, &QgsExtentWidget::mapToolDeactivated );
503  }
504  mMapToolExtent->setRatio( mRatio );
505  mCanvas->setMapTool( mMapToolExtent.get() );
506 
507  emit toggleDialogVisibility( false );
508  }
509 }
510 
511 void QgsExtentWidget::extentDrawn( const QgsRectangle &extent )
512 {
513  setOutputExtent( extent, mCanvas->mapSettings().destinationCrs(), DrawOnCanvas );
514  mCanvas->setMapTool( mMapToolPrevious );
515  emit toggleDialogVisibility( true );
516  mMapToolPrevious = nullptr;
517 }
518 
519 void QgsExtentWidget::mapToolDeactivated()
520 {
521  emit toggleDialogVisibility( true );
522  mMapToolPrevious = nullptr;
523 }
524 
526 {
527  return QgsRectangle( QgsDoubleValidator::toDouble( mXMinLineEdit->text() ), QgsDoubleValidator::toDouble( mYMinLineEdit->text() ),
528  QgsDoubleValidator::toDouble( mXMaxLineEdit->text() ), QgsDoubleValidator::toDouble( mYMaxLineEdit->text() ) );
529 }
530 
531 void QgsExtentWidget::setMapCanvas( QgsMapCanvas *canvas, bool drawOnCanvasOption )
532 {
533  if ( canvas )
534  {
535  mCanvas = canvas;
536  mButtonDrawOnCanvas->setVisible( drawOnCanvasOption );
537  mCurrentExtentButton->setVisible( true );
538 
539  mUseCanvasExtentAction->setVisible( true );
540  if ( drawOnCanvasOption )
541  mDrawOnCanvasAction->setVisible( true );
542 
543  mCondensedToolButton->setToolTip( tr( "Set to current map canvas extent" ) );
544  mCondensedToolButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionMapIdentification.svg" ) ) );
545  connect( mCondensedToolButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromCurrent );
546  mCondensedToolButton->setPopupMode( QToolButton::MenuButtonPopup );
547  }
548  else
549  {
550  mButtonDrawOnCanvas->setVisible( false );
551  mCurrentExtentButton->setVisible( false );
552  mUseCanvasExtentAction->setVisible( false );
553  mUseCanvasExtentAction->setVisible( false );
554 
555  mCondensedToolButton->setToolTip( QString() );
556  mCondensedToolButton->setIcon( QIcon() );
557  disconnect( mCondensedToolButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromCurrent );
558  mCondensedToolButton->setPopupMode( QToolButton::InstantPopup );
559  }
560 }
561 
562 void QgsExtentWidget::dragEnterEvent( QDragEnterEvent *event )
563 {
564  if ( !( event->possibleActions() & Qt::CopyAction ) )
565  {
566  event->ignore();
567  return;
568  }
569 
570  if ( mapLayerFromMimeData( event->mimeData() ) )
571  {
572  // dragged an acceptable layer, phew
573  event->setDropAction( Qt::CopyAction );
574  event->accept();
575  mCondensedLineEdit->setHighlighted( true );
576  update();
577  }
578  else
579  {
580  event->ignore();
581  }
582 }
583 
584 void QgsExtentWidget::dragLeaveEvent( QDragLeaveEvent *event )
585 {
586  if ( mCondensedLineEdit->isHighlighted() )
587  {
588  event->accept();
589  mCondensedLineEdit->setHighlighted( false );
590  update();
591  }
592  else
593  {
594  event->ignore();
595  }
596 }
597 
598 void QgsExtentWidget::dropEvent( QDropEvent *event )
599 {
600  if ( !( event->possibleActions() & Qt::CopyAction ) )
601  {
602  event->ignore();
603  return;
604  }
605 
606  if ( QgsMapLayer *layer = mapLayerFromMimeData( event->mimeData() ) )
607  {
608  // dropped a map layer
609  setFocus( Qt::MouseFocusReason );
610  event->setDropAction( Qt::CopyAction );
611  event->accept();
612 
613  setOutputExtentFromLayer( layer );
614  }
615  else
616  {
617  event->ignore();
618  }
619  mCondensedLineEdit->setHighlighted( false );
620  update();
621 }
QgsMapLayer::crs
QgsCoordinateReferenceSystem crs
Definition: qgsmaplayer.h:79
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:124
outputCrs
const QgsCoordinateReferenceSystem & outputCrs
Definition: qgswfsgetfeature.cpp:115
QgsLayoutManager
Manages storage of a set of layouts.
Definition: qgslayoutmanager.h:44
QgsExtentWidget::originalCrs
QgsCoordinateReferenceSystem originalCrs() const
Returns the original coordinate reference system set for the widget.
Definition: qgsextentwidget.h:100
QgsExtentWidget::CurrentExtent
@ CurrentExtent
Map canvas extent.
Definition: qgsextentwidget.h:61
QgsExtentWidget::DrawOnCanvas
@ DrawOnCanvas
Extent taken from a rectangled drawn onto the map canvas.
Definition: qgsextentwidget.h:64
qgsmapcanvas.h
QgsMapSettings::setRotation
void setRotation(double rotation)
Sets the rotation of the resulting map image, in degrees clockwise.
Definition: qgsmapsettings.cpp:107
QgsMapCanvas::mapTool
QgsMapTool * mapTool()
Returns the currently active tool.
Definition: qgsmapcanvas.cpp:2769
QgsCoordinateReferenceSystem::userFriendlyIdentifier
QString userFriendlyIdentifier(IdentifierType type=MediumString) const
Returns a user friendly identifier for the CRS.
Definition: qgscoordinatereferencesystem.cpp:1212
QgsReferencedRectangle
A QgsRectangle with associated coordinate reference system.
Definition: qgsreferencedgeometry.h:73
QgsUnitTypes::DistanceUnknownUnit
@ DistanceUnknownUnit
Unknown distance unit.
Definition: qgsunittypes.h:78
QgsExtentWidget::OriginalExtent
@ OriginalExtent
Layer's extent.
Definition: qgsextentwidget.h:60
QgsBookmarkManagerModel::RoleExtent
@ RoleExtent
Bookmark extent as a QgsReferencedRectangle.
Definition: qgsbookmarkmodel.h:50
QgsExtentWidget::clear
void clear()
Clears the widget, setting it to a null value.
Definition: qgsextentwidget.cpp:300
QgsExtentWidget::outputExtent
QgsRectangle outputExtent() const
Returns the extent shown in the widget - in output CRS coordinates.
Definition: qgsextentwidget.cpp:525
QgsExtentWidget::setOutputExtentFromOriginal
void setOutputExtentFromOriginal()
Sets the output extent to be the same as original extent (may be transformed to output CRS).
Definition: qgsextentwidget.cpp:472
QgsExtentWidget::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *event) override
Definition: qgsextentwidget.cpp:562
QgsMapCanvas::mapSettings
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
Definition: qgsmapcanvas.cpp:437
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsRectangle::yMinimum
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:198
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:138
QgsCoordinateTransform::transformBoundingBox
QgsRectangle transformBoundingBox(const QgsRectangle &rectangle, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool handle180Crossover=false) const SIP_THROW(QgsCsException)
Transforms a rectangle from the source CRS to the destination CRS.
Definition: qgscoordinatetransform.cpp:560
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:89
qgslayoutmanager.h
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:480
QgsMapLayerProxyModel::setFilters
QgsMapLayerProxyModel * setFilters(QgsMapLayerProxyModel::Filters filters)
Sets filter flags which affect how layers are filtered within the model.
Definition: qgsmaplayerproxymodel.cpp:39
QgsExtentWidget::~QgsExtentWidget
~QgsExtentWidget() override
Definition: qgsextentwidget.cpp:118
QgsMapLayerModel::LayerIdRole
@ LayerIdRole
Stores the map layer ID.
Definition: qgsmaplayermodel.h:51
QgsMimeDataUtils::UriList
QList< QgsMimeDataUtils::Uri > UriList
Definition: qgsmimedatautils.h:164
QgsProject::mapLayer
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
Definition: qgsproject.cpp:3680
QgsUnitTypes::DistanceKilometers
@ DistanceKilometers
Kilometers.
Definition: qgsunittypes.h:70
qgsextentwidget.h
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsExtentWidget::UserExtent
@ UserExtent
Extent manually entered/modified by the user.
Definition: qgsextentwidget.h:62
QgsExtentWidget::setOutputExtentFromDrawOnCanvas
void setOutputExtentFromDrawOnCanvas()
Sets the output extent by dragging on the canvas.
Definition: qgsextentwidget.cpp:493
QgsExtentWidget::CondensedStyle
@ CondensedStyle
Shows a compressed widget, for use when available space is minimal.
Definition: qgsextentwidget.h:70
qgsapplication.h
QgsExtentWidget::outputCrs
QgsCoordinateReferenceSystem outputCrs() const
Returns the current output CRS, used in the display.
Definition: qgsextentwidget.h:143
QgsRectangle::xMaximum
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
Definition: qgsrectangle.h:183
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:477
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:147
QgsCsException
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:65
QgsPrintLayout
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Definition: qgsprintlayout.h:30
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
QgsMapLayerProxyModel
The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widget...
Definition: qgsmaplayerproxymodel.h:34
QgsCoordinateTransform::setBallparkTransformsAreAppropriate
void setBallparkTransformsAreAppropriate(bool appropriate)
Sets whether approximate "ballpark" results are appropriate for this coordinate transform.
Definition: qgscoordinatetransform.cpp:939
whileBlocking
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:2191
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:456
QgsExtentWidget::ExpandedStyle
@ ExpandedStyle
Shows an expanded widget, for use when space is not constrained.
Definition: qgsextentwidget.h:71
QgsMapLayer::extent
virtual QgsRectangle extent() const
Returns the extent of the layer.
Definition: qgsmaplayer.cpp:305
QgsExtentWidget::setOriginalExtent
void setOriginalExtent(const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs)
Sets the original extent and coordinate reference system for the widget.
Definition: qgsextentwidget.cpp:129
QgsDoubleValidator
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
Definition: qgsdoublevalidator.h:40
QgsExtentWidget::QgsExtentWidget
QgsExtentWidget(QWidget *parent=nullptr, WidgetStyle style=CondensedStyle)
Constructor for QgsExtentWidget.
Definition: qgsextentwidget.cpp:37
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:188
QgsApplication::bookmarkManager
static QgsBookmarkManager * bookmarkManager()
Returns the application's bookmark manager, used for storing installation-wide bookmarks.
Definition: qgsapplication.cpp:2425
QgsExtentWidget::extentLayerName
QString extentLayerName() const
Returns the name of the extent layer.
Definition: qgsextentwidget.cpp:315
QgsMapCanvas::setMapTool
void setMapTool(QgsMapTool *mapTool, bool clean=false)
Sets the map tool currently being used on the canvas.
Definition: qgsmapcanvas.cpp:2475
QgsMimeDataUtils::Uri
Definition: qgsmimedatautils.h:40
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsBookmarkManagerModel::RoleGroup
@ RoleGroup
Bookmark group.
Definition: qgsbookmarkmodel.h:53
QgsMapSettings::destinationCrs
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
Definition: qgsmapsettings.cpp:358
QgsLayoutItemMap
Layout graphical items for displaying a map.
Definition: qgslayoutitemmap.h:317
QgsCoordinateReferenceSystem::ShortString
@ ShortString
A heavily abbreviated string, for use when a compact representation is required.
Definition: qgscoordinatereferencesystem.h:632
QgsReferencedGeometryBase::crs
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set.
Definition: qgsreferencedgeometry.h:53
qgsbookmarkmodel.h
qgsreferencedgeometry.h
QgsExtentWidget::dragLeaveEvent
void dragLeaveEvent(QDragLeaveEvent *event) override
Definition: qgsextentwidget.cpp:584
QgsCoordinateReferenceSystem::mapUnits
QgsUnitTypes::DistanceUnit mapUnits
Definition: qgscoordinatereferencesystem.h:215
QgsRectangle::yMaximum
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
Definition: qgsrectangle.h:193
QgsMimeDataUtils::decodeUriList
static UriList decodeUriList(const QMimeData *data)
Definition: qgsmimedatautils.cpp:229
QgsUnitTypes::DistanceMillimeters
@ DistanceMillimeters
Millimeters.
Definition: qgsunittypes.h:77
qgsmaplayermodel.h
QgsExtentWidget::setMapCanvas
void setMapCanvas(QgsMapCanvas *canvas, bool drawOnCanvasOption=true)
Sets the map canvas to enable dragging of extent on a canvas.
Definition: qgsextentwidget.cpp:531
QgsUnitTypes::DistanceCentimeters
@ DistanceCentimeters
Centimeters.
Definition: qgsunittypes.h:76
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
QgsDoubleValidator::toDouble
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
Definition: qgsdoublevalidator.cpp:134
QgsExtentWidget::validationChanged
void validationChanged(bool valid)
Emitted when the widget's validation state changes.
qgsprintlayout.h
QgsMapToolExtent
A map tool that emits an extent from a rectangle drawn onto the map canvas.
Definition: qgsmaptoolextent.h:33
qgsmaplayerproxymodel.h
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:482
QgsMapLayer::name
QString name
Definition: qgsmaplayer.h:76
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:325
QgsExtentWidget::originalExtent
QgsRectangle originalExtent() const
Returns the original extent set for the widget.
Definition: qgsextentwidget.h:93
qgsexception.h
QgsUnitTypes::DistanceNauticalMiles
@ DistanceNauticalMiles
Nautical miles.
Definition: qgsunittypes.h:72
QgsApplication::getThemeIcon
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Definition: qgsapplication.cpp:693
QgsExtentWidget::currentExtent
QgsRectangle currentExtent() const
Returns the current extent set for the widget.
Definition: qgsextentwidget.h:116
QgsExtentWidget::dropEvent
void dropEvent(QDropEvent *event) override
Definition: qgsextentwidget.cpp:598
qgsdoublevalidator.h
qgslogger.h
QgsMapSettings
The QgsMapSettings class contains configuration for rendering of the map. The rendering itself is don...
Definition: qgsmapsettings.h:88
QgsMapSettings::visibleExtent
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes output image size into account.
Definition: qgsmapsettings.cpp:411
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:57
QgsBookmarkManagerProxyModel
A QSortFilterProxyModel subclass for sorting the entries in a QgsBookmarkManagerModel.
Definition: qgsbookmarkmodel.h:108
QgsBookmarkManagerModel::RoleName
@ RoleName
Bookmark name.
Definition: qgsbookmarkmodel.h:51
QgsExtentWidget::ProjectLayerExtent
@ ProjectLayerExtent
Extent taken from a layer within the project.
Definition: qgsextentwidget.h:63
qgsproject.h
QgsMapTool::deactivated
void deactivated()
signal emitted once the map tool is deactivated
qgslayoutitemmap.h
QgsExtentWidget::isValid
bool isValid() const
Returns true if the widget is in a valid state, i.e.
Definition: qgsextentwidget.cpp:320