QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
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#include "moc_qgsextentwidget.cpp"
18
19#include "qgsapplication.h"
21#include "qgsmapcanvas.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"
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 );
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
129void QgsExtentWidget::setOriginalExtent( const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs )
130{
131 mOriginalExtent = originalExtent;
132 mOriginalCrs = originalCrs;
133
134 mOriginalExtentButton->setVisible( true );
135}
136
137
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
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
197void 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;
282 decimals = 4;
283 break;
284 }
285 mXMinLineEdit->setText( QLocale().toString( extent.xMinimum(), 'f', decimals ) );
286 mXMaxLineEdit->setText( QLocale().toString( extent.xMaximum(), 'f', decimals ) );
287 mYMinLineEdit->setText( QLocale().toString( extent.yMinimum(), 'f', decimals ) );
288 mYMaxLineEdit->setText( QLocale().toString( extent.yMaximum(), 'f', decimals ) );
289
290 QString condensed = QStringLiteral( "%1,%2,%3,%4" ).arg( QString::number( extent.xMinimum(), 'f', decimals ),
291 QString::number( extent.xMaximum(), 'f', decimals ),
292 QString::number( extent.yMinimum(), 'f', decimals ),
293 QString::number( extent.yMaximum(), 'f', decimals ) );
294 condensed += QStringLiteral( " [%1]" ).arg( mOutputCrs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ) );
295 mCondensedLineEdit->setText( condensed );
296
297 mExtentState = state;
298
299 if ( !mIsValid )
300 setValid( true );
301
302 emit extentChanged( extent );
303}
304
305void QgsExtentWidget::setOutputExtentFromLineEdit()
306{
307 mExtentState = UserExtent;
308 emit extentChanged( outputExtent() );
309}
310
311void QgsExtentWidget::setOutputExtentFromCondensedLineEdit()
312{
313 const QString text = mCondensedLineEdit->text();
314 if ( text.isEmpty() )
315 {
316 clear();
317 }
318 else
319 {
320 const QRegularExpressionMatch match = mCondensedRe.match( text );
321 if ( match.hasMatch() )
322 {
323 // Localization
324 whileBlocking( mXMinLineEdit )->setText( QLocale().toString( match.captured( 1 ).toDouble(), 'f', 10 ) );
325 whileBlocking( mXMaxLineEdit )->setText( QLocale().toString( match.captured( 2 ).toDouble(), 'f', 10 ) );
326 whileBlocking( mYMinLineEdit )->setText( QLocale().toString( match.captured( 3 ).toDouble(), 'f', 10 ) );
327 whileBlocking( mYMaxLineEdit )->setText( QLocale().toString( match.captured( 4 ).toDouble(), 'f', 10 ) );
328 if ( !match.captured( 5 ).isEmpty() )
329 {
330 mOutputCrs = QgsCoordinateReferenceSystem( match.captured( 5 ) );
331 }
332
333 emit extentChanged( outputExtent() );
334 if ( !mIsValid )
335 setValid( true );
336 }
337 }
338}
339
341{
342 const bool prevWasNull = mIsValid;
343
344 whileBlocking( mXMinLineEdit )->clear();
345 whileBlocking( mXMaxLineEdit )->clear();
346 whileBlocking( mYMinLineEdit )->clear();
347 whileBlocking( mYMaxLineEdit )->clear();
348 whileBlocking( mCondensedLineEdit )->clearValue();
349 setValid( false );
350
351 if ( prevWasNull )
352 emit extentChanged( outputExtent() );
353}
354
356{
357 return mExtentLayerName;
358}
359
361{
362 return mIsValid;
363}
364
365void QgsExtentWidget::setNullValueAllowed( bool allowed, const QString &notSetText )
366{
367 mCondensedLineEdit->setShowClearButton( allowed );
368 mCondensedLineEdit->setNullValue( notSetText );
369}
370
371void QgsExtentWidget::setValid( bool valid )
372{
373 if ( valid == mIsValid )
374 return;
375
376 mIsValid = valid;
377 emit validationChanged( mIsValid );
378}
379
380void QgsExtentWidget::layerMenuAboutToShow()
381{
382 qDeleteAll( mLayerMenuActions );
383 mLayerMenuActions.clear();
384 mLayerMenu->clear();
385 for ( int i = 0; i < mMapLayerModel->rowCount(); ++i )
386 {
387 const QModelIndex index = mMapLayerModel->index( i, 0 );
388 const QIcon icon = qvariant_cast<QIcon>( mMapLayerModel->data( index, Qt::DecorationRole ) );
389 const QString text = mMapLayerModel->data( index, Qt::DisplayRole ).toString();
390 QAction *act = new QAction( icon, text, mLayerMenu );
391 act->setToolTip( mMapLayerModel->data( index, Qt::ToolTipRole ).toString() );
392 const QString layerId = mMapLayerModel->data( index, static_cast< int >( QgsMapLayerModel::CustomRole::LayerId ) ).toString();
393 if ( mExtentState == ProjectLayerExtent && mExtentLayer && mExtentLayer->id() == layerId )
394 {
395 act->setCheckable( true );
396 act->setChecked( true );
397 }
398 connect( act, &QAction::triggered, this, [this, layerId]
399 {
400 setExtentToLayerExtent( layerId );
401 } );
402 mLayerMenu->addAction( act );
403 mLayerMenuActions << act;
404 }
405}
406
407void QgsExtentWidget::layoutMenuAboutToShow()
408{
409 mLayoutMenu->clear();
410
411 if ( QgsLayoutManager *manager = QgsProject::instance()->layoutManager() )
412 {
413 const QList<QgsPrintLayout *> layouts = manager->printLayouts();
414 for ( const QgsPrintLayout *layout : layouts )
415 {
416 QList< QgsLayoutItemMap * > maps;
417 layout->layoutItems( maps );
418 if ( maps.empty() )
419 continue;
420
421 QMenu *layoutMenu = new QMenu( layout->name(), mMenu );
422 for ( const QgsLayoutItemMap *map : std::as_const( maps ) )
423 {
424 QgsRectangle extent = map->extent();
426 QAction *mapExtentAction = new QAction( tr( "%1" ).arg( map->displayName() ), mLayoutMenu );
427 connect( mapExtentAction, &QAction::triggered, this, [this, extent, crs] { setOutputExtentFromUser( extent, crs ); } );
428 layoutMenu->addAction( mapExtentAction );
429 }
430 mLayoutMenu->addMenu( layoutMenu );
431 }
432 }
433}
434
435void QgsExtentWidget::bookmarkMenuAboutToShow()
436{
437 mBookmarkMenu->clear();
438
439 if ( !mBookmarkModel )
440 mBookmarkModel = new QgsBookmarkManagerProxyModel( QgsApplication::bookmarkManager(), QgsProject::instance()->bookmarkManager(), this );
441
442 QMap< QString, QMenu * > groupMenus;
443 for ( int i = 0; i < mBookmarkModel->rowCount(); ++i )
444 {
445 const QString group = mBookmarkModel->data( mBookmarkModel->index( i, 0 ), static_cast< int >( QgsBookmarkManagerModel::CustomRole::Group ) ).toString();
446 QMenu *destMenu = mBookmarkMenu;
447 if ( !group.isEmpty() )
448 {
449 destMenu = groupMenus.value( group );
450 if ( !destMenu )
451 {
452 destMenu = new QMenu( group, mBookmarkMenu );
453 groupMenus[ group ] = destMenu;
454 }
455 }
456 QAction *action = new QAction( mBookmarkModel->data( mBookmarkModel->index( i, 0 ), static_cast< int >( QgsBookmarkManagerModel::CustomRole::Name ) ).toString(), mBookmarkMenu );
457 const QgsReferencedRectangle extent = mBookmarkModel->data( mBookmarkModel->index( i, 0 ), static_cast< int >( QgsBookmarkManagerModel::CustomRole::Extent ) ).value< QgsReferencedRectangle >();
458 connect( action, &QAction::triggered, this, [ = ] { setOutputExtentFromUser( extent, extent.crs() ); } );
459 destMenu->addAction( action );
460 }
461
462 QStringList groupKeys = groupMenus.keys();
463 groupKeys.sort( Qt::CaseInsensitive );
464 for ( int i = 0; i < groupKeys.count(); ++i )
465 {
466 if ( mBookmarkMenu->actions().value( i ) )
467 mBookmarkMenu->insertMenu( mBookmarkMenu->actions().at( i ), groupMenus.value( groupKeys.at( i ) ) );
468 else
469 mBookmarkMenu->addMenu( groupMenus.value( groupKeys.at( i ) ) );
470 }
471}
472
473void QgsExtentWidget::setExtentToLayerExtent( const QString &layerId )
474{
475 QgsMapLayer *layer = QgsProject::instance()->mapLayer( layerId );
476 if ( !layer )
477 return;
478
480}
481
482QgsMapLayer *QgsExtentWidget::mapLayerFromMimeData( const QMimeData *data ) const
483{
485 for ( const QgsMimeDataUtils::Uri &u : uriList )
486 {
487 // is this uri from the current project?
488 if ( QgsMapLayer *layer = u.mapLayer() )
489 {
490 return layer;
491 }
492 }
493 return nullptr;
494}
495
497{
498 if ( mCanvas )
499 {
500 // Use unrotated visible extent to insure output size and scale matches canvas
501 QgsMapSettings ms = mCanvas->mapSettings();
502 ms.setRotation( 0 );
503 setOutputExtent( ms.visibleExtent(), ms.destinationCrs(), CurrentExtent );
504 }
505 else
506 {
507 setOutputExtent( mCurrentExtent, mCurrentCrs, CurrentExtent );
508 }
509}
510
511
513{
514 setOutputExtent( mOriginalExtent, mOriginalCrs, OriginalExtent );
515}
516
518{
519 setOutputExtent( extent, crs, UserExtent );
520}
521
523{
524 if ( !layer )
525 return;
526
527 mExtentLayer = layer;
528 mExtentLayerName = layer->name();
529
530 setOutputExtent( layer->extent(), layer->crs(), ProjectLayerExtent );
531}
532
534{
535 if ( mCanvas )
536 {
537 mMapToolPrevious = mCanvas->mapTool();
538 if ( !mMapToolExtent )
539 {
540 mMapToolExtent.reset( new QgsMapToolExtent( mCanvas ) );
541 connect( mMapToolExtent.get(), &QgsMapToolExtent::extentChanged, this, &QgsExtentWidget::extentDrawn );
542 connect( mMapToolExtent.get(), &QgsMapTool::deactivated, this, &QgsExtentWidget::mapToolDeactivated );
543 }
544 mMapToolExtent->setRatio( mRatio );
545 mCanvas->setMapTool( mMapToolExtent.get() );
546
547 emit toggleDialogVisibility( false );
548 }
549}
550
551void QgsExtentWidget::extentDrawn( const QgsRectangle &extent )
552{
553 setOutputExtent( extent, mCanvas->mapSettings().destinationCrs(), DrawOnCanvas );
554 mCanvas->setMapTool( mMapToolPrevious );
555 emit toggleDialogVisibility( true );
556 mMapToolPrevious = nullptr;
557}
558
559void QgsExtentWidget::mapToolDeactivated()
560{
561 emit toggleDialogVisibility( true );
562 mMapToolPrevious = nullptr;
563}
564
566{
567 bool ok;
568 const double xmin = QgsDoubleValidator::toDouble( mXMinLineEdit->text(), &ok );
569 if ( ! ok ) return QgsRectangle();
570 const double ymin = QgsDoubleValidator::toDouble( mYMinLineEdit->text(), &ok );
571 if ( ! ok ) return QgsRectangle();
572 const double xmax = QgsDoubleValidator::toDouble( mXMaxLineEdit->text(), &ok );
573 if ( ! ok ) return QgsRectangle();
574 const double ymax = QgsDoubleValidator::toDouble( mYMaxLineEdit->text(), &ok );
575 if ( ! ok ) return QgsRectangle();
576
577 return QgsRectangle( xmin, ymin, xmax, ymax );
578}
579
580void QgsExtentWidget::setMapCanvas( QgsMapCanvas *canvas, bool drawOnCanvasOption )
581{
582 if ( canvas )
583 {
584 mCanvas = canvas;
585 mButtonDrawOnCanvas->setVisible( drawOnCanvasOption );
586 mCurrentExtentButton->setVisible( true );
587
588 mUseCanvasExtentAction->setVisible( true );
589 mDrawOnCanvasAction->setVisible( drawOnCanvasOption && !mBlockDrawOnCanvas );
590
591 mCondensedToolButton->setToolTip( tr( "Set to current map canvas extent" ) );
592 mCondensedToolButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionMapIdentification.svg" ) ) );
593 connect( mCondensedToolButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromCurrent );
594 mCondensedToolButton->setPopupMode( QToolButton::MenuButtonPopup );
595 }
596 else
597 {
598 mButtonDrawOnCanvas->setVisible( false );
599 mCurrentExtentButton->setVisible( false );
600 mUseCanvasExtentAction->setVisible( false );
601 mUseCanvasExtentAction->setVisible( false );
602
603 mCondensedToolButton->setToolTip( QString() );
604 mCondensedToolButton->setIcon( QIcon() );
605 disconnect( mCondensedToolButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromCurrent );
606 mCondensedToolButton->setPopupMode( QToolButton::InstantPopup );
607 }
608}
609
610void QgsExtentWidget::dragEnterEvent( QDragEnterEvent *event )
611{
612 if ( !( event->possibleActions() & Qt::CopyAction ) )
613 {
614 event->ignore();
615 return;
616 }
617
618 if ( mapLayerFromMimeData( event->mimeData() ) )
619 {
620 // dragged an acceptable layer, phew
621 event->setDropAction( Qt::CopyAction );
622 event->accept();
623 mCondensedLineEdit->setHighlighted( true );
624 update();
625 }
626 else
627 {
628 event->ignore();
629 }
630}
631
632void QgsExtentWidget::dragLeaveEvent( QDragLeaveEvent *event )
633{
634 if ( mCondensedLineEdit->isHighlighted() )
635 {
636 event->accept();
637 mCondensedLineEdit->setHighlighted( false );
638 update();
639 }
640 else
641 {
642 event->ignore();
643 }
644}
645
646void QgsExtentWidget::dropEvent( QDropEvent *event )
647{
648 if ( !( event->possibleActions() & Qt::CopyAction ) )
649 {
650 event->ignore();
651 return;
652 }
653
654 if ( QgsMapLayer *layer = mapLayerFromMimeData( event->mimeData() ) )
655 {
656 // dropped a map layer
657 setFocus( Qt::MouseFocusReason );
658 event->setDropAction( Qt::CopyAction );
659 event->accept();
660
662 }
663 else
664 {
665 event->ignore();
666 }
667 mCondensedLineEdit->setHighlighted( false );
668 update();
669}
670
671void QgsExtentWidget::showEvent( QShowEvent * )
672{
673 if ( mFirstShow )
674 {
675 // we don't support select on canvas if the dialog is modal
676 if ( QWidget *parentWindow = window() )
677 {
678 if ( parentWindow->isModal() )
679 {
680 mBlockDrawOnCanvas = true;
681 mDrawOnCanvasAction->setVisible( false );
682 }
683 }
684 mFirstShow = false;
685 }
686}
@ ShortString
A heavily abbreviated string, for use when a compact representation is required.
@ YardsBritishSears1922Truncated
British yards (Sears 1922 truncated)
@ Feet
Imperial feet.
@ MilesUSSurvey
US Survey miles.
@ LinksBritishSears1922
British links (Sears 1922)
@ YardsBritishBenoit1895A
British yards (Benoit 1895 A)
@ LinksBritishBenoit1895A
British links (Benoit 1895 A)
@ Centimeters
Centimeters.
@ YardsIndian1975
Indian yards (1975)
@ FeetUSSurvey
US Survey feet.
@ Millimeters
Millimeters.
@ FeetBritishSears1922
British feet (Sears 1922)
@ YardsClarkes
Clarke's yards.
@ YardsIndian
Indian yards.
@ FeetBritishBenoit1895B
British feet (Benoit 1895 B)
@ Miles
Terrestrial miles.
@ LinksUSSurvey
US Survey links.
@ ChainsUSSurvey
US Survey chains.
@ FeetClarkes
Clarke's feet.
@ Unknown
Unknown distance unit.
@ Yards
Imperial yards.
@ FeetBritish1936
British feet (1936)
@ FeetIndian1962
Indian feet (1962)
@ YardsBritishSears1922
British yards (Sears 1922)
@ FeetIndian1937
Indian feet (1937)
@ YardsIndian1937
Indian yards (1937)
@ Degrees
Degrees, for planar geographic CRS distance measurements.
@ ChainsBritishBenoit1895B
British chains (Benoit 1895 B)
@ LinksBritishSears1922Truncated
British links (Sears 1922 truncated)
@ ChainsBritishBenoit1895A
British chains (Benoit 1895 A)
@ YardsBritishBenoit1895B
British yards (Benoit 1895 B)
@ FeetBritish1865
British feet (1865)
@ YardsIndian1962
Indian yards (1962)
@ FeetBritishSears1922Truncated
British feet (Sears 1922 truncated)
@ MetersGermanLegal
German legal meter.
@ LinksBritishBenoit1895B
British links (Benoit 1895 B)
@ ChainsInternational
International chains.
@ LinksInternational
International links.
@ ChainsBritishSears1922Truncated
British chains (Sears 1922 truncated)
@ FeetIndian
Indian (geodetic) feet.
@ NauticalMiles
Nautical miles.
@ ChainsClarkes
Clarke's chains.
@ LinksClarkes
Clarke's links.
@ ChainsBritishSears1922
British chains (Sears 1922)
@ Kilometers
Kilometers.
@ FeetIndian1975
Indian feet (1975)
@ FeetGoldCoast
Gold Coast feet.
@ FeetBritishBenoit1895A
British feet (Benoit 1895 A)
@ SpatialLayer
All spatial layers.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsBookmarkManager * bookmarkManager()
Returns the application's bookmark manager, used for storing installation-wide bookmarks.
@ Extent
Bookmark extent as a QgsReferencedRectangle.
A QSortFilterProxyModel subclass for sorting the entries in a QgsBookmarkManagerModel.
This class represents a coordinate reference system (CRS).
QString userFriendlyIdentifier(Qgis::CrsIdentifierType type=Qgis::CrsIdentifierType::MediumString) const
Returns a user friendly identifier for the CRS.
Class for doing transforms between two map coordinate systems.
void setBallparkTransformsAreAppropriate(bool appropriate)
Sets whether approximate "ballpark" results are appropriate for this coordinate transform.
QgsRectangle transformBoundingBox(const QgsRectangle &rectangle, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool handle180Crossover=false) const
Transforms a rectangle from the source CRS to the destination CRS.
Custom exception class for Coordinate Reference System related exceptions.
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
QgsCoordinateReferenceSystem currentCrs() const
Returns the coordinate reference system for the current extent set for the widget.
void setOutputExtentFromOriginal()
Sets the output extent to be the same as original extent (may be transformed to output CRS).
void setOutputExtentFromCurrent()
Sets the output extent to be the same as current extent (may be transformed to output CRS).
void setOutputExtentFromDrawOnCanvas()
Sets the output extent by dragging on the canvas.
void setOriginalExtent(const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs)
Sets the original extent and coordinate reference system for the widget.
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...
bool isValid() const
Returns true if the widget is in a valid state, i.e.
void toggleDialogVisibility(bool visible)
Emitted when the parent dialog visibility must be changed (e.g.
void setNullValueAllowed(bool allowed, const QString &notSetText=QString())
Sets whether the widget can be set to a "not set" (null) state.
QgsRectangle originalExtent() const
Returns the original extent set for the widget.
void dragEnterEvent(QDragEnterEvent *event) override
@ UserExtent
Extent manually entered/modified by the user.
@ OriginalExtent
Layer's extent.
@ ProjectLayerExtent
Extent taken from a layer within the project.
@ CurrentExtent
Map canvas extent.
@ DrawOnCanvas
Extent taken from a rectangled drawn onto the map canvas.
void validationChanged(bool valid)
Emitted when the widget's validation state changes.
void dropEvent(QDropEvent *event) override
void clear()
Clears the widget, setting it to a null value.
QgsCoordinateReferenceSystem outputCrs() const
Returns the current output CRS, used in the display.
void setMapCanvas(QgsMapCanvas *canvas, bool drawOnCanvasOption=true)
Sets the map canvas to enable dragging of extent on a canvas.
~QgsExtentWidget() override
QgsRectangle currentExtent() const
Returns the current extent set for the widget.
void extentChanged(const QgsRectangle &r)
Emitted when the widget's extent is changed.
WidgetStyle
Widget styles.
@ CondensedStyle
Shows a compressed widget, for use when available space is minimal.
@ ExpandedStyle
Shows an expanded widget, for use when space is not constrained.
QgsExtentWidget(QWidget *parent=nullptr, WidgetStyle style=CondensedStyle)
Constructor for QgsExtentWidget.
QgsRectangle outputExtent() const
Returns the extent shown in the widget - in output CRS coordinates.
void dragLeaveEvent(QDragLeaveEvent *event) override
QgsCoordinateReferenceSystem originalCrs() const
Returns the original coordinate reference system set for the widget.
void showEvent(QShowEvent *event) override
void setOutputCrs(const QgsCoordinateReferenceSystem &outputCrs)
Sets the output CRS - may need to be used for transformation from original/current extent.
void setOutputExtentFromLayer(const QgsMapLayer *layer)
Sets the output extent to match a layer's extent (may be transformed to output CRS).
void setOutputExtentFromUser(const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs)
Sets the output extent to a custom extent (may be transformed to output CRS).
QString extentLayerName() const
Returns the name of the extent layer.
void cleared()
Emitted when the widget is cleared.
Layout graphical items for displaying a map.
Manages storage of a set of layouts.
Map canvas is a class for displaying all GIS data types on a canvas.
QgsMapTool * mapTool() const
Returns the currently active tool.
void setMapTool(QgsMapTool *mapTool, bool clean=false)
Sets the map tool currently being used on the canvas.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
@ LayerId
Stores the map layer ID.
The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widget...
QgsMapLayerProxyModel * setFilters(Qgis::LayerFilters filters)
Sets filter flags which affect how layers are filtered within the model.
Base class for all map layer types.
Definition qgsmaplayer.h:76
QString name
Definition qgsmaplayer.h:80
virtual QgsRectangle extent() const
Returns the extent of the layer.
QgsCoordinateReferenceSystem crs
Definition qgsmaplayer.h:83
The QgsMapSettings class contains configuration for rendering of the map.
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes output image size into account.
void setRotation(double rotation)
Sets the rotation of the resulting map image, in degrees clockwise.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
A map tool that emits an extent from a rectangle drawn onto the map canvas.
void extentChanged(const QgsRectangle &extent)
signal emitted on extent change
void deactivated()
signal emitted once the map tool is deactivated
QList< QgsMimeDataUtils::Uri > UriList
static UriList decodeUriList(const QMimeData *data)
Print layout, a QgsLayout subclass for static or atlas-based layouts.
static QgsProject * instance()
Returns the QgsProject singleton instance.
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
A rectangle specified with double values.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set.
A QgsRectangle with associated coordinate reference system.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition qgis.h:5862
const QgsCoordinateReferenceSystem & outputCrs
const QgsCoordinateReferenceSystem & crs