QGIS API Documentation 3.99.0-Master (d270888f95f)
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
18#include <memory>
19
20#include "qgsapplication.h"
21#include "qgsbookmarkmodel.h"
23#include "qgsdoublevalidator.h"
24#include "qgsexception.h"
25#include "qgslayoutitemmap.h"
26#include "qgslayoutmanager.h"
27#include "qgsmapcanvas.h"
28#include "qgsmaplayermodel.h"
30#include "qgsprintlayout.h"
31#include "qgsproject.h"
33
34#include <QAction>
35#include <QMenu>
36#include <QRegularExpression>
37#include <QString>
38
39#include "moc_qgsextentwidget.cpp"
40
41using namespace Qt::StringLiterals;
42
44 : QWidget( parent )
45{
46 setupUi( this );
47 connect( mXMinLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
48 connect( mXMaxLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
49 connect( mYMinLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
50 connect( mYMaxLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
51
52 mCondensedRe = QRegularExpression( u"\\s*([\\d\\.\\-]+)\\s*,\\s*([\\d\\.\\-]+)\\s*,\\s*([\\d\\.\\-]+)\\s*,\\s*([\\d\\.\\-]+)\\s*(?:\\[(.*?)\\])?"_s );
53 mCondensedLineEdit->setValidator( new QRegularExpressionValidator( mCondensedRe, this ) );
54 mCondensedLineEdit->setShowClearButton( false );
55 connect( mCondensedLineEdit, &QgsFilterLineEdit::cleared, this, &QgsExtentWidget::clear );
56 connect( mCondensedLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromCondensedLineEdit );
57
58 mLayerMenu = new QMenu( tr( "Calculate from Layer" ), this );
59 mButtonCalcFromLayer->setMenu( mLayerMenu );
60 connect( mLayerMenu, &QMenu::aboutToShow, this, &QgsExtentWidget::layerMenuAboutToShow );
61 mMapLayerModel = new QgsMapLayerProxyModel( this );
62 mMapLayerModel->setFilters( Qgis::LayerFilter::SpatialLayer );
63
64 mLayoutMenu = new QMenu( tr( "Calculate from Layout Map" ), this );
65 mButtonCalcFromLayout->setMenu( mLayoutMenu );
66 connect( mLayoutMenu, &QMenu::aboutToShow, this, &QgsExtentWidget::layoutMenuAboutToShow );
67
68 mBookmarkMenu = new QMenu( tr( "Calculate from Bookmark" ), this );
69 mButtonCalcFromBookmark->setMenu( mBookmarkMenu );
70 connect( mBookmarkMenu, &QMenu::aboutToShow, this, &QgsExtentWidget::bookmarkMenuAboutToShow );
71
72 mMenu = new QMenu( this );
73 mUseCanvasExtentAction = new QAction( tr( "Use Current Map Canvas Extent" ), this );
74 mUseCanvasExtentAction->setIcon( QgsApplication::getThemeIcon( u"/mActionMapIdentification.svg"_s ) );
75 mUseCanvasExtentAction->setVisible( false );
76 connect( mUseCanvasExtentAction, &QAction::triggered, this, &QgsExtentWidget::setOutputExtentFromCurrent );
77
78 mUseCurrentExtentAction = new QAction( tr( "Use Current Layer/Default Extent" ), this );
79 mUseCurrentExtentAction->setVisible( false );
80 connect( mUseCurrentExtentAction, &QAction::triggered, this, &QgsExtentWidget::setOutputExtentFromCurrent );
81
82 mDrawOnCanvasAction = new QAction( tr( "Draw on Map Canvas" ), this );
83 mDrawOnCanvasAction->setVisible( false );
84 connect( mDrawOnCanvasAction, &QAction::triggered, this, &QgsExtentWidget::setOutputExtentFromDrawOnCanvas );
85
86 mMenu->addMenu( mLayerMenu );
87 mMenu->addMenu( mLayoutMenu );
88 mMenu->addMenu( mBookmarkMenu );
89 mMenu->addSeparator();
90 mMenu->addAction( mUseCanvasExtentAction );
91 mMenu->addAction( mDrawOnCanvasAction );
92 mMenu->addAction( mUseCurrentExtentAction );
93
94 mCondensedToolButton->setMenu( mMenu );
95 mCondensedToolButton->setPopupMode( QToolButton::InstantPopup );
96
97 mXMinLineEdit->setValidator( new QgsDoubleValidator( this ) );
98 mXMaxLineEdit->setValidator( new QgsDoubleValidator( this ) );
99 mYMinLineEdit->setValidator( new QgsDoubleValidator( this ) );
100 mYMaxLineEdit->setValidator( new QgsDoubleValidator( this ) );
101
102 mOriginalExtentButton->setVisible( false );
103 mButtonDrawOnCanvas->setVisible( false );
104 mCurrentExtentButton->setVisible( false );
105
106 connect( mCurrentExtentButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromCurrent );
107 connect( mOriginalExtentButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromOriginal );
108 connect( mButtonDrawOnCanvas, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromDrawOnCanvas );
109
110 switch ( style )
111 {
112 case CondensedStyle:
113 mExpandedWidget->hide();
114 break;
115
116 case ExpandedStyle:
117 mCondensedFrame->hide();
118 break;
119 }
120
121 setAcceptDrops( true );
122}
123
125{
126 if ( mMapToolExtent )
127 {
128 // disconnect from deactivated signal -- this will be called when the map tool is being destroyed,
129 // and we don't want to act on that anymore (the mapToolDeactivated slot tries to show the widget again, but
130 // that's being destroyed!)
131 disconnect( mMapToolExtent.get(), &QgsMapToolExtent::deactivated, this, &QgsExtentWidget::mapToolDeactivated );
132 }
133}
134
136{
137 mOriginalExtent = originalExtent;
138 mOriginalCrs = originalCrs;
139
140 mOriginalExtentButton->setVisible( true );
141}
142
143
145{
146 mCurrentExtent = currentExtent;
147 mCurrentCrs = currentCrs;
148
149 mCurrentExtentButton->setVisible( true );
150 mUseCurrentExtentAction->setVisible( true );
151}
152
154{
155 mHasFixedOutputCrs = true;
156 if ( mOutputCrs != outputCrs )
157 {
158 const bool prevExtentEnabled = mIsValid;
159 switch ( mExtentState )
160 {
161 case CurrentExtent:
162 mOutputCrs = outputCrs;
164 break;
165
166 case OriginalExtent:
167 mOutputCrs = outputCrs;
169 break;
170
172 mOutputCrs = outputCrs;
173 setOutputExtentFromLayer( mExtentLayer.data() );
174 break;
175
176 case DrawOnCanvas:
177 mOutputCrs = outputCrs;
178 extentDrawn( outputExtent() );
179 break;
180
181 case UserExtent:
182 try
183 {
186 const QgsRectangle extent = ct.transformBoundingBox( outputExtent() );
187 mOutputCrs = outputCrs;
189 }
190 catch ( QgsCsException & )
191 {
192 // can't reproject
193 mOutputCrs = outputCrs;
194 }
195 break;
196 }
197
198 if ( !prevExtentEnabled )
199 setValid( false );
200 }
201}
202
203void QgsExtentWidget::setOutputExtent( const QgsRectangle &r, const QgsCoordinateReferenceSystem &srcCrs, ExtentState state )
204{
205 QgsRectangle extent;
206 if ( !mHasFixedOutputCrs )
207 {
208 mOutputCrs = srcCrs;
209 extent = r;
210 }
211 else
212 {
213 if ( mOutputCrs == srcCrs )
214 {
215 extent = r;
216 }
217 else
218 {
219 try
220 {
221 QgsCoordinateTransform ct( srcCrs, mOutputCrs, QgsProject::instance() );
222 ct.setBallparkTransformsAreAppropriate( true );
223 extent = ct.transformBoundingBox( r );
224 }
225 catch ( QgsCsException & )
226 {
227 // can't reproject
228 extent = r;
229 }
230 }
231 }
232
233 int decimals = 4;
234 switch ( mOutputCrs.mapUnits() )
235 {
238 decimals = 9;
239 break;
288 decimals = 4;
289 break;
290 }
291 mXMinLineEdit->setText( QLocale().toString( extent.xMinimum(), 'f', decimals ) );
292 mXMaxLineEdit->setText( QLocale().toString( extent.xMaximum(), 'f', decimals ) );
293 mYMinLineEdit->setText( QLocale().toString( extent.yMinimum(), 'f', decimals ) );
294 mYMaxLineEdit->setText( QLocale().toString( extent.yMaximum(), 'f', decimals ) );
295
296 QString condensed = u"%1,%2,%3,%4"_s.arg( QString::number( extent.xMinimum(), 'f', decimals ), QString::number( extent.xMaximum(), 'f', decimals ), QString::number( extent.yMinimum(), 'f', decimals ), QString::number( extent.yMaximum(), 'f', decimals ) );
297 condensed += u" [%1]"_s.arg( mOutputCrs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ) );
298 mCondensedLineEdit->setText( condensed );
299
300 mExtentState = state;
301
302 if ( !mIsValid )
303 setValid( true );
304
305 emit extentChanged( extent );
306}
307
308void QgsExtentWidget::setOutputExtentFromLineEdit()
309{
310 mExtentState = UserExtent;
311 emit extentChanged( outputExtent() );
312}
313
314void QgsExtentWidget::setOutputExtentFromCondensedLineEdit()
315{
316 const QString text = mCondensedLineEdit->text();
317 if ( text.isEmpty() )
318 {
319 clear();
320 }
321 else
322 {
323 const QRegularExpressionMatch match = mCondensedRe.match( text );
324 if ( match.hasMatch() )
325 {
326 // Localization
327 whileBlocking( mXMinLineEdit )->setText( QLocale().toString( match.captured( 1 ).toDouble(), 'f', 10 ) );
328 whileBlocking( mXMaxLineEdit )->setText( QLocale().toString( match.captured( 2 ).toDouble(), 'f', 10 ) );
329 whileBlocking( mYMinLineEdit )->setText( QLocale().toString( match.captured( 3 ).toDouble(), 'f', 10 ) );
330 whileBlocking( mYMaxLineEdit )->setText( QLocale().toString( match.captured( 4 ).toDouble(), 'f', 10 ) );
331 if ( !match.captured( 5 ).isEmpty() )
332 {
333 mOutputCrs = QgsCoordinateReferenceSystem( match.captured( 5 ) );
334 }
335
336 emit extentChanged( outputExtent() );
337 if ( !mIsValid )
338 setValid( true );
339 }
340 }
341}
342
344{
345 const bool prevWasNull = mIsValid;
346
347 whileBlocking( mXMinLineEdit )->clear();
348 whileBlocking( mXMaxLineEdit )->clear();
349 whileBlocking( mYMinLineEdit )->clear();
350 whileBlocking( mYMaxLineEdit )->clear();
351 whileBlocking( mCondensedLineEdit )->clearValue();
352 setValid( false );
353
354 if ( prevWasNull )
355 emit extentChanged( outputExtent() );
356}
357
359{
360 return mExtentLayerName;
361}
362
364{
365 return mIsValid;
366}
367
368void QgsExtentWidget::setNullValueAllowed( bool allowed, const QString &notSetText )
369{
370 mCondensedLineEdit->setShowClearButton( allowed );
371 mCondensedLineEdit->setNullValue( notSetText );
372}
373
374void QgsExtentWidget::setValid( bool valid )
375{
376 if ( valid == mIsValid )
377 return;
378
379 mIsValid = valid;
380 emit validationChanged( mIsValid );
381}
382
383void QgsExtentWidget::layerMenuAboutToShow()
384{
385 qDeleteAll( mLayerMenuActions );
386 mLayerMenuActions.clear();
387 mLayerMenu->clear();
388 for ( int i = 0; i < mMapLayerModel->rowCount(); ++i )
389 {
390 const QModelIndex index = mMapLayerModel->index( i, 0 );
391 const QIcon icon = qvariant_cast<QIcon>( mMapLayerModel->data( index, Qt::DecorationRole ) );
392 const QString text = mMapLayerModel->data( index, Qt::DisplayRole ).toString();
393 QAction *act = new QAction( icon, text, mLayerMenu );
394 act->setToolTip( mMapLayerModel->data( index, Qt::ToolTipRole ).toString() );
395 const QString layerId = mMapLayerModel->data( index, static_cast<int>( QgsMapLayerModel::CustomRole::LayerId ) ).toString();
396 if ( mExtentState == ProjectLayerExtent && mExtentLayer && mExtentLayer->id() == layerId )
397 {
398 act->setCheckable( true );
399 act->setChecked( true );
400 }
401 connect( act, &QAction::triggered, this, [this, layerId] {
402 setExtentToLayerExtent( layerId );
403 } );
404 mLayerMenu->addAction( act );
405 mLayerMenuActions << act;
406 }
407}
408
409void QgsExtentWidget::layoutMenuAboutToShow()
410{
411 mLayoutMenu->clear();
412
413 if ( QgsLayoutManager *manager = QgsProject::instance()->layoutManager() )
414 {
415 const QList<QgsPrintLayout *> layouts = manager->printLayouts();
416 for ( const QgsPrintLayout *layout : layouts )
417 {
418 QList<QgsLayoutItemMap *> maps;
419 layout->layoutItems( maps );
420 if ( maps.empty() )
421 continue;
422
423 QMenu *layoutMenu = new QMenu( layout->name(), mMenu );
424 for ( const QgsLayoutItemMap *map : std::as_const( maps ) )
425 {
426 QgsRectangle extent = map->extent();
427 QgsCoordinateReferenceSystem crs = map->crs();
428 QAction *mapExtentAction = new QAction( tr( "%1" ).arg( map->displayName() ), mLayoutMenu );
429 connect( mapExtentAction, &QAction::triggered, this, [this, extent, crs] { setOutputExtentFromUser( extent, crs ); } );
430 layoutMenu->addAction( mapExtentAction );
431 }
432 mLayoutMenu->addMenu( layoutMenu );
433 }
434 }
435}
436
437void QgsExtentWidget::bookmarkMenuAboutToShow()
438{
439 mBookmarkMenu->clear();
440
441 if ( !mBookmarkModel )
442 mBookmarkModel = new QgsBookmarkManagerProxyModel( QgsApplication::bookmarkManager(), QgsProject::instance()->bookmarkManager(), this );
443
444 QMap<QString, QMenu *> groupMenus;
445 for ( int i = 0; i < mBookmarkModel->rowCount(); ++i )
446 {
447 const QString group = mBookmarkModel->data( mBookmarkModel->index( i, 0 ), static_cast<int>( QgsBookmarkManagerModel::CustomRole::Group ) ).toString();
448 QMenu *destMenu = mBookmarkMenu;
449 if ( !group.isEmpty() )
450 {
451 destMenu = groupMenus.value( group );
452 if ( !destMenu )
453 {
454 destMenu = new QMenu( group, mBookmarkMenu );
455 groupMenus[group] = destMenu;
456 }
457 }
458 QAction *action = new QAction( mBookmarkModel->data( mBookmarkModel->index( i, 0 ), static_cast<int>( QgsBookmarkManagerModel::CustomRole::Name ) ).toString(), mBookmarkMenu );
459 const QgsReferencedRectangle extent = mBookmarkModel->data( mBookmarkModel->index( i, 0 ), static_cast<int>( QgsBookmarkManagerModel::CustomRole::Extent ) ).value<QgsReferencedRectangle>();
460 connect( action, &QAction::triggered, this, [this, extent] { setOutputExtentFromUser( extent, extent.crs() ); } );
461 destMenu->addAction( action );
462 }
463
464 QStringList groupKeys = groupMenus.keys();
465 groupKeys.sort( Qt::CaseInsensitive );
466 for ( int i = 0; i < groupKeys.count(); ++i )
467 {
468 if ( mBookmarkMenu->actions().value( i ) )
469 mBookmarkMenu->insertMenu( mBookmarkMenu->actions().at( i ), groupMenus.value( groupKeys.at( i ) ) );
470 else
471 mBookmarkMenu->addMenu( groupMenus.value( groupKeys.at( i ) ) );
472 }
473}
474
475void QgsExtentWidget::setExtentToLayerExtent( const QString &layerId )
476{
477 QgsMapLayer *layer = QgsProject::instance()->mapLayer( layerId );
478 if ( !layer )
479 return;
480
481 emit extentLayerChanged( layer );
483}
484
485QgsMapLayer *QgsExtentWidget::mapLayerFromMimeData( const QMimeData *data ) const
486{
488 for ( const QgsMimeDataUtils::Uri &u : uriList )
489 {
490 // is this uri from the current project?
491 if ( QgsMapLayer *layer = u.mapLayer() )
492 {
493 return layer;
494 }
495 }
496 return nullptr;
497}
498
500{
501 if ( mCanvas )
502 {
503 // Use unrotated visible extent to insure output size and scale matches canvas
504 QgsMapSettings ms = mCanvas->mapSettings();
505 ms.setRotation( 0 );
506 setOutputExtent( ms.visibleExtent(), ms.destinationCrs(), CurrentExtent );
507 }
508 else
509 {
510 setOutputExtent( mCurrentExtent, mCurrentCrs, CurrentExtent );
511 }
512}
513
514
516{
517 setOutputExtent( mOriginalExtent, mOriginalCrs, OriginalExtent );
518}
519
521{
522 setOutputExtent( extent, crs, UserExtent );
523}
524
526{
527 if ( !layer )
528 return;
529
530 mExtentLayer = layer;
531 mExtentLayerName = layer->name();
532
533 setOutputExtent( layer->extent(), layer->crs(), ProjectLayerExtent );
534}
535
537{
538 if ( mCanvas )
539 {
540 mMapToolPrevious = mCanvas->mapTool();
541 if ( !mMapToolExtent )
542 {
543 mMapToolExtent = std::make_unique<QgsMapToolExtent>( mCanvas );
544 connect( mMapToolExtent.get(), &QgsMapToolExtent::extentChanged, this, &QgsExtentWidget::extentDrawn );
545 connect( mMapToolExtent.get(), &QgsMapTool::deactivated, this, &QgsExtentWidget::mapToolDeactivated );
546 }
547 mMapToolExtent->setRatio( mRatio );
548 mCanvas->setMapTool( mMapToolExtent.get() );
549
550 emit toggleDialogVisibility( false );
551 }
552}
553
554void QgsExtentWidget::extentDrawn( const QgsRectangle &extent )
555{
556 setOutputExtent( extent, mCanvas->mapSettings().destinationCrs(), DrawOnCanvas );
557 mCanvas->setMapTool( mMapToolPrevious );
558 emit toggleDialogVisibility( true );
559 mMapToolPrevious = nullptr;
560}
561
562void QgsExtentWidget::mapToolDeactivated()
563{
564 emit toggleDialogVisibility( true );
565 mMapToolPrevious = nullptr;
566}
567
569{
570 bool ok;
571 const double xmin = QgsDoubleValidator::toDouble( mXMinLineEdit->text(), &ok );
572 if ( !ok )
573 return QgsRectangle();
574 const double ymin = QgsDoubleValidator::toDouble( mYMinLineEdit->text(), &ok );
575 if ( !ok )
576 return QgsRectangle();
577 const double xmax = QgsDoubleValidator::toDouble( mXMaxLineEdit->text(), &ok );
578 if ( !ok )
579 return QgsRectangle();
580 const double ymax = QgsDoubleValidator::toDouble( mYMaxLineEdit->text(), &ok );
581 if ( !ok )
582 return QgsRectangle();
583
584 return QgsRectangle( xmin, ymin, xmax, ymax );
585}
586
587void QgsExtentWidget::setMapCanvas( QgsMapCanvas *canvas, bool drawOnCanvasOption )
588{
589 if ( canvas )
590 {
591 mCanvas = canvas;
592 mButtonDrawOnCanvas->setVisible( drawOnCanvasOption );
593 mCurrentExtentButton->setVisible( true );
594
595 mUseCanvasExtentAction->setVisible( true );
596 mDrawOnCanvasAction->setVisible( drawOnCanvasOption && !mBlockDrawOnCanvas );
597
598 mCondensedToolButton->setToolTip( tr( "Set to current map canvas extent" ) );
599 mCondensedToolButton->setIcon( QgsApplication::getThemeIcon( u"/mActionMapIdentification.svg"_s ) );
600 connect( mCondensedToolButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromCurrent );
601 mCondensedToolButton->setPopupMode( QToolButton::MenuButtonPopup );
602 }
603 else
604 {
605 mButtonDrawOnCanvas->setVisible( false );
606 mCurrentExtentButton->setVisible( false );
607 mUseCanvasExtentAction->setVisible( false );
608 mUseCanvasExtentAction->setVisible( false );
609
610 mCondensedToolButton->setToolTip( QString() );
611 mCondensedToolButton->setIcon( QIcon() );
612 disconnect( mCondensedToolButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromCurrent );
613 mCondensedToolButton->setPopupMode( QToolButton::InstantPopup );
614 }
615}
616
617void QgsExtentWidget::dragEnterEvent( QDragEnterEvent *event )
618{
619 if ( !( event->possibleActions() & Qt::CopyAction ) )
620 {
621 event->ignore();
622 return;
623 }
624
625 if ( mapLayerFromMimeData( event->mimeData() ) )
626 {
627 // dragged an acceptable layer, phew
628 event->setDropAction( Qt::CopyAction );
629 event->accept();
630 mCondensedLineEdit->setHighlighted( true );
631 update();
632 }
633 else
634 {
635 event->ignore();
636 }
637}
638
639void QgsExtentWidget::dragLeaveEvent( QDragLeaveEvent *event )
640{
641 if ( mCondensedLineEdit->isHighlighted() )
642 {
643 event->accept();
644 mCondensedLineEdit->setHighlighted( false );
645 update();
646 }
647 else
648 {
649 event->ignore();
650 }
651}
652
653void QgsExtentWidget::dropEvent( QDropEvent *event )
654{
655 if ( !( event->possibleActions() & Qt::CopyAction ) )
656 {
657 event->ignore();
658 return;
659 }
660
661 if ( QgsMapLayer *layer = mapLayerFromMimeData( event->mimeData() ) )
662 {
663 // dropped a map layer
664 setFocus( Qt::MouseFocusReason );
665 event->setDropAction( Qt::CopyAction );
666 event->accept();
667
669 }
670 else
671 {
672 event->ignore();
673 }
674 mCondensedLineEdit->setHighlighted( false );
675 update();
676}
677
678void QgsExtentWidget::showEvent( QShowEvent * )
679{
680 if ( mFirstShow )
681 {
682 // we don't support select on canvas if the dialog is modal
683 if ( QWidget *parentWindow = window() )
684 {
685 if ( parentWindow->isModal() )
686 {
687 mBlockDrawOnCanvas = true;
688 mDrawOnCanvasAction->setVisible( false );
689 }
690 }
691 mFirstShow = false;
692 }
693}
@ ShortString
A heavily abbreviated string, for use when a compact representation is required.
Definition qgis.h:2476
@ YardsBritishSears1922Truncated
British yards (Sears 1922 truncated).
Definition qgis.h:5125
@ Feet
Imperial feet.
Definition qgis.h:5088
@ MilesUSSurvey
US Survey miles.
Definition qgis.h:5132
@ LinksBritishSears1922
British links (Sears 1922).
Definition qgis.h:5120
@ YardsBritishBenoit1895A
British yards (Benoit 1895 A).
Definition qgis.h:5123
@ LinksBritishBenoit1895A
British links (Benoit 1895 A).
Definition qgis.h:5117
@ Centimeters
Centimeters.
Definition qgis.h:5093
@ YardsIndian1975
Indian yards (1975).
Definition qgis.h:5131
@ FeetUSSurvey
US Survey feet.
Definition qgis.h:5115
@ Millimeters
Millimeters.
Definition qgis.h:5094
@ FeetBritishSears1922
British feet (Sears 1922).
Definition qgis.h:5108
@ YardsClarkes
Clarke's yards.
Definition qgis.h:5127
@ YardsIndian
Indian yards.
Definition qgis.h:5128
@ FeetBritishBenoit1895B
British feet (Benoit 1895 B).
Definition qgis.h:5106
@ Miles
Terrestrial miles.
Definition qgis.h:5091
@ LinksUSSurvey
US Survey links.
Definition qgis.h:5122
@ Meters
Meters.
Definition qgis.h:5086
@ ChainsUSSurvey
US Survey chains.
Definition qgis.h:5102
@ FeetClarkes
Clarke's feet.
Definition qgis.h:5109
@ Unknown
Unknown distance unit.
Definition qgis.h:5135
@ Yards
Imperial yards.
Definition qgis.h:5090
@ FeetBritish1936
British feet (1936).
Definition qgis.h:5104
@ FeetIndian1962
Indian feet (1962).
Definition qgis.h:5113
@ YardsBritishSears1922
British yards (Sears 1922).
Definition qgis.h:5126
@ FeetIndian1937
Indian feet (1937).
Definition qgis.h:5112
@ YardsIndian1937
Indian yards (1937).
Definition qgis.h:5129
@ Degrees
Degrees, for planar geographic CRS distance measurements.
Definition qgis.h:5092
@ ChainsBritishBenoit1895B
British chains (Benoit 1895 B).
Definition qgis.h:5098
@ LinksBritishSears1922Truncated
British links (Sears 1922 truncated).
Definition qgis.h:5119
@ ChainsBritishBenoit1895A
British chains (Benoit 1895 A).
Definition qgis.h:5097
@ YardsBritishBenoit1895B
British yards (Benoit 1895 B).
Definition qgis.h:5124
@ FeetBritish1865
British feet (1865).
Definition qgis.h:5103
@ YardsIndian1962
Indian yards (1962).
Definition qgis.h:5130
@ FeetBritishSears1922Truncated
British feet (Sears 1922 truncated).
Definition qgis.h:5107
@ MetersGermanLegal
German legal meter.
Definition qgis.h:5134
@ LinksBritishBenoit1895B
British links (Benoit 1895 B).
Definition qgis.h:5118
@ ChainsInternational
International chains.
Definition qgis.h:5096
@ Inches
Inches.
Definition qgis.h:5095
@ Fathoms
Fathoms.
Definition qgis.h:5133
@ LinksInternational
International links.
Definition qgis.h:5116
@ ChainsBritishSears1922Truncated
British chains (Sears 1922 truncated).
Definition qgis.h:5099
@ FeetIndian
Indian (geodetic) feet.
Definition qgis.h:5111
@ NauticalMiles
Nautical miles.
Definition qgis.h:5089
@ ChainsClarkes
Clarke's chains.
Definition qgis.h:5101
@ LinksClarkes
Clarke's links.
Definition qgis.h:5121
@ ChainsBritishSears1922
British chains (Sears 1922).
Definition qgis.h:5100
@ Kilometers
Kilometers.
Definition qgis.h:5087
@ FeetIndian1975
Indian feet (1975).
Definition qgis.h:5114
@ FeetGoldCoast
Gold Coast feet.
Definition qgis.h:5110
@ FeetBritishBenoit1895A
British feet (Benoit 1895 A).
Definition qgis.h:5105
@ SpatialLayer
All spatial layers.
Definition qgis.h:228
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.
Represents a coordinate reference system (CRS).
Handles coordinate transforms between two 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.
A custom validator which allows entry of doubles in a locale-tolerant way.
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 extentLayerChanged(QgsMapLayer *layer)
Emitted when the extent layer is changed.
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.
Map canvas is a class for displaying all GIS data types on a canvas.
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.
A proxy model which provides an easy to use model to display the list of layers in widgets.
Base class for all map layer types.
Definition qgsmaplayer.h:83
QString name
Definition qgsmaplayer.h:87
virtual QgsRectangle extent() const
Returns the extent of the layer.
QgsCoordinateReferenceSystem crs
Definition qgsmaplayer.h:90
Contains configuration for rendering maps.
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.
void extentChanged(const QgsRectangle &extent)
signal emitted on extent change
void deactivated()
Emitted when the map tool is deactivated.
QList< QgsMimeDataUtils::Uri > UriList
static UriList decodeUriList(const QMimeData *data)
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
double yMinimum
double xMaximum
double yMaximum
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition qgis.h:6804