QGIS API Documentation 3.99.0-Master (26c88405ac0)
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
38#include "moc_qgsextentwidget.cpp"
39
41 : QWidget( parent )
42{
43 setupUi( this );
44 connect( mXMinLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
45 connect( mXMaxLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
46 connect( mYMinLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
47 connect( mYMaxLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromLineEdit );
48
49 mCondensedRe = QRegularExpression( QStringLiteral( "\\s*([\\d\\.\\-]+)\\s*,\\s*([\\d\\.\\-]+)\\s*,\\s*([\\d\\.\\-]+)\\s*,\\s*([\\d\\.\\-]+)\\s*(?:\\[(.*?)\\])?" ) );
50 mCondensedLineEdit->setValidator( new QRegularExpressionValidator( mCondensedRe, this ) );
51 mCondensedLineEdit->setShowClearButton( false );
52 connect( mCondensedLineEdit, &QgsFilterLineEdit::cleared, this, &QgsExtentWidget::clear );
53 connect( mCondensedLineEdit, &QLineEdit::textEdited, this, &QgsExtentWidget::setOutputExtentFromCondensedLineEdit );
54
55 mLayerMenu = new QMenu( tr( "Calculate from Layer" ), this );
56 mButtonCalcFromLayer->setMenu( mLayerMenu );
57 connect( mLayerMenu, &QMenu::aboutToShow, this, &QgsExtentWidget::layerMenuAboutToShow );
58 mMapLayerModel = new QgsMapLayerProxyModel( this );
59 mMapLayerModel->setFilters( Qgis::LayerFilter::SpatialLayer );
60
61 mLayoutMenu = new QMenu( tr( "Calculate from Layout Map" ), this );
62 mButtonCalcFromLayout->setMenu( mLayoutMenu );
63 connect( mLayoutMenu, &QMenu::aboutToShow, this, &QgsExtentWidget::layoutMenuAboutToShow );
64
65 mBookmarkMenu = new QMenu( tr( "Calculate from Bookmark" ), this );
66 mButtonCalcFromBookmark->setMenu( mBookmarkMenu );
67 connect( mBookmarkMenu, &QMenu::aboutToShow, this, &QgsExtentWidget::bookmarkMenuAboutToShow );
68
69 mMenu = new QMenu( this );
70 mUseCanvasExtentAction = new QAction( tr( "Use Current Map Canvas Extent" ), this );
71 mUseCanvasExtentAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionMapIdentification.svg" ) ) );
72 mUseCanvasExtentAction->setVisible( false );
73 connect( mUseCanvasExtentAction, &QAction::triggered, this, &QgsExtentWidget::setOutputExtentFromCurrent );
74
75 mUseCurrentExtentAction = new QAction( tr( "Use Current Layer/Default Extent" ), this );
76 mUseCurrentExtentAction->setVisible( false );
77 connect( mUseCurrentExtentAction, &QAction::triggered, this, &QgsExtentWidget::setOutputExtentFromCurrent );
78
79 mDrawOnCanvasAction = new QAction( tr( "Draw on Map Canvas" ), this );
80 mDrawOnCanvasAction->setVisible( false );
81 connect( mDrawOnCanvasAction, &QAction::triggered, this, &QgsExtentWidget::setOutputExtentFromDrawOnCanvas );
82
83 mMenu->addMenu( mLayerMenu );
84 mMenu->addMenu( mLayoutMenu );
85 mMenu->addMenu( mBookmarkMenu );
86 mMenu->addSeparator();
87 mMenu->addAction( mUseCanvasExtentAction );
88 mMenu->addAction( mDrawOnCanvasAction );
89 mMenu->addAction( mUseCurrentExtentAction );
90
91 mCondensedToolButton->setMenu( mMenu );
92 mCondensedToolButton->setPopupMode( QToolButton::InstantPopup );
93
94 mXMinLineEdit->setValidator( new QgsDoubleValidator( this ) );
95 mXMaxLineEdit->setValidator( new QgsDoubleValidator( this ) );
96 mYMinLineEdit->setValidator( new QgsDoubleValidator( this ) );
97 mYMaxLineEdit->setValidator( new QgsDoubleValidator( this ) );
98
99 mOriginalExtentButton->setVisible( false );
100 mButtonDrawOnCanvas->setVisible( false );
101 mCurrentExtentButton->setVisible( false );
102
103 connect( mCurrentExtentButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromCurrent );
104 connect( mOriginalExtentButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromOriginal );
105 connect( mButtonDrawOnCanvas, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromDrawOnCanvas );
106
107 switch ( style )
108 {
109 case CondensedStyle:
110 mExpandedWidget->hide();
111 break;
112
113 case ExpandedStyle:
114 mCondensedFrame->hide();
115 break;
116 }
117
118 setAcceptDrops( true );
119}
120
122{
123 if ( mMapToolExtent )
124 {
125 // disconnect from deactivated signal -- this will be called when the map tool is being destroyed,
126 // and we don't want to act on that anymore (the mapToolDeactivated slot tries to show the widget again, but
127 // that's being destroyed!)
128 disconnect( mMapToolExtent.get(), &QgsMapToolExtent::deactivated, this, &QgsExtentWidget::mapToolDeactivated );
129 }
130}
131
133{
134 mOriginalExtent = originalExtent;
135 mOriginalCrs = originalCrs;
136
137 mOriginalExtentButton->setVisible( true );
138}
139
140
142{
143 mCurrentExtent = currentExtent;
144 mCurrentCrs = currentCrs;
145
146 mCurrentExtentButton->setVisible( true );
147 mUseCurrentExtentAction->setVisible( true );
148}
149
151{
152 mHasFixedOutputCrs = true;
153 if ( mOutputCrs != outputCrs )
154 {
155 const bool prevExtentEnabled = mIsValid;
156 switch ( mExtentState )
157 {
158 case CurrentExtent:
159 mOutputCrs = outputCrs;
161 break;
162
163 case OriginalExtent:
164 mOutputCrs = outputCrs;
166 break;
167
169 mOutputCrs = outputCrs;
170 setOutputExtentFromLayer( mExtentLayer.data() );
171 break;
172
173 case DrawOnCanvas:
174 mOutputCrs = outputCrs;
175 extentDrawn( outputExtent() );
176 break;
177
178 case UserExtent:
179 try
180 {
183 const QgsRectangle extent = ct.transformBoundingBox( outputExtent() );
184 mOutputCrs = outputCrs;
186 }
187 catch ( QgsCsException & )
188 {
189 // can't reproject
190 mOutputCrs = outputCrs;
191 }
192 break;
193 }
194
195 if ( !prevExtentEnabled )
196 setValid( false );
197 }
198}
199
200void QgsExtentWidget::setOutputExtent( const QgsRectangle &r, const QgsCoordinateReferenceSystem &srcCrs, ExtentState state )
201{
202 QgsRectangle extent;
203 if ( !mHasFixedOutputCrs )
204 {
205 mOutputCrs = srcCrs;
206 extent = r;
207 }
208 else
209 {
210 if ( mOutputCrs == srcCrs )
211 {
212 extent = r;
213 }
214 else
215 {
216 try
217 {
218 QgsCoordinateTransform ct( srcCrs, mOutputCrs, QgsProject::instance() );
219 ct.setBallparkTransformsAreAppropriate( true );
220 extent = ct.transformBoundingBox( r );
221 }
222 catch ( QgsCsException & )
223 {
224 // can't reproject
225 extent = r;
226 }
227 }
228 }
229
230 int decimals = 4;
231 switch ( mOutputCrs.mapUnits() )
232 {
235 decimals = 9;
236 break;
285 decimals = 4;
286 break;
287 }
288 mXMinLineEdit->setText( QLocale().toString( extent.xMinimum(), 'f', decimals ) );
289 mXMaxLineEdit->setText( QLocale().toString( extent.xMaximum(), 'f', decimals ) );
290 mYMinLineEdit->setText( QLocale().toString( extent.yMinimum(), 'f', decimals ) );
291 mYMaxLineEdit->setText( QLocale().toString( extent.yMaximum(), 'f', decimals ) );
292
293 QString condensed = QStringLiteral( "%1,%2,%3,%4" ).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 ) );
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 setExtentToLayerExtent( layerId );
400 } );
401 mLayerMenu->addAction( act );
402 mLayerMenuActions << act;
403 }
404}
405
406void QgsExtentWidget::layoutMenuAboutToShow()
407{
408 mLayoutMenu->clear();
409
410 if ( QgsLayoutManager *manager = QgsProject::instance()->layoutManager() )
411 {
412 const QList<QgsPrintLayout *> layouts = manager->printLayouts();
413 for ( const QgsPrintLayout *layout : layouts )
414 {
415 QList<QgsLayoutItemMap *> maps;
416 layout->layoutItems( maps );
417 if ( maps.empty() )
418 continue;
419
420 QMenu *layoutMenu = new QMenu( layout->name(), mMenu );
421 for ( const QgsLayoutItemMap *map : std::as_const( maps ) )
422 {
423 QgsRectangle extent = map->extent();
424 QgsCoordinateReferenceSystem crs = map->crs();
425 QAction *mapExtentAction = new QAction( tr( "%1" ).arg( map->displayName() ), mLayoutMenu );
426 connect( mapExtentAction, &QAction::triggered, this, [this, extent, crs] { setOutputExtentFromUser( extent, crs ); } );
427 layoutMenu->addAction( mapExtentAction );
428 }
429 mLayoutMenu->addMenu( layoutMenu );
430 }
431 }
432}
433
434void QgsExtentWidget::bookmarkMenuAboutToShow()
435{
436 mBookmarkMenu->clear();
437
438 if ( !mBookmarkModel )
439 mBookmarkModel = new QgsBookmarkManagerProxyModel( QgsApplication::bookmarkManager(), QgsProject::instance()->bookmarkManager(), this );
440
441 QMap<QString, QMenu *> groupMenus;
442 for ( int i = 0; i < mBookmarkModel->rowCount(); ++i )
443 {
444 const QString group = mBookmarkModel->data( mBookmarkModel->index( i, 0 ), static_cast<int>( QgsBookmarkManagerModel::CustomRole::Group ) ).toString();
445 QMenu *destMenu = mBookmarkMenu;
446 if ( !group.isEmpty() )
447 {
448 destMenu = groupMenus.value( group );
449 if ( !destMenu )
450 {
451 destMenu = new QMenu( group, mBookmarkMenu );
452 groupMenus[group] = destMenu;
453 }
454 }
455 QAction *action = new QAction( mBookmarkModel->data( mBookmarkModel->index( i, 0 ), static_cast<int>( QgsBookmarkManagerModel::CustomRole::Name ) ).toString(), mBookmarkMenu );
456 const QgsReferencedRectangle extent = mBookmarkModel->data( mBookmarkModel->index( i, 0 ), static_cast<int>( QgsBookmarkManagerModel::CustomRole::Extent ) ).value<QgsReferencedRectangle>();
457 connect( action, &QAction::triggered, this, [this, extent] { setOutputExtentFromUser( extent, extent.crs() ); } );
458 destMenu->addAction( action );
459 }
460
461 QStringList groupKeys = groupMenus.keys();
462 groupKeys.sort( Qt::CaseInsensitive );
463 for ( int i = 0; i < groupKeys.count(); ++i )
464 {
465 if ( mBookmarkMenu->actions().value( i ) )
466 mBookmarkMenu->insertMenu( mBookmarkMenu->actions().at( i ), groupMenus.value( groupKeys.at( i ) ) );
467 else
468 mBookmarkMenu->addMenu( groupMenus.value( groupKeys.at( i ) ) );
469 }
470}
471
472void QgsExtentWidget::setExtentToLayerExtent( const QString &layerId )
473{
474 QgsMapLayer *layer = QgsProject::instance()->mapLayer( layerId );
475 if ( !layer )
476 return;
477
478 emit extentLayerChanged( layer );
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 = std::make_unique<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 )
570 return QgsRectangle();
571 const double ymin = QgsDoubleValidator::toDouble( mYMinLineEdit->text(), &ok );
572 if ( !ok )
573 return QgsRectangle();
574 const double xmax = QgsDoubleValidator::toDouble( mXMaxLineEdit->text(), &ok );
575 if ( !ok )
576 return QgsRectangle();
577 const double ymax = QgsDoubleValidator::toDouble( mYMaxLineEdit->text(), &ok );
578 if ( !ok )
579 return QgsRectangle();
580
581 return QgsRectangle( xmin, ymin, xmax, ymax );
582}
583
584void QgsExtentWidget::setMapCanvas( QgsMapCanvas *canvas, bool drawOnCanvasOption )
585{
586 if ( canvas )
587 {
588 mCanvas = canvas;
589 mButtonDrawOnCanvas->setVisible( drawOnCanvasOption );
590 mCurrentExtentButton->setVisible( true );
591
592 mUseCanvasExtentAction->setVisible( true );
593 mDrawOnCanvasAction->setVisible( drawOnCanvasOption && !mBlockDrawOnCanvas );
594
595 mCondensedToolButton->setToolTip( tr( "Set to current map canvas extent" ) );
596 mCondensedToolButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionMapIdentification.svg" ) ) );
597 connect( mCondensedToolButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromCurrent );
598 mCondensedToolButton->setPopupMode( QToolButton::MenuButtonPopup );
599 }
600 else
601 {
602 mButtonDrawOnCanvas->setVisible( false );
603 mCurrentExtentButton->setVisible( false );
604 mUseCanvasExtentAction->setVisible( false );
605 mUseCanvasExtentAction->setVisible( false );
606
607 mCondensedToolButton->setToolTip( QString() );
608 mCondensedToolButton->setIcon( QIcon() );
609 disconnect( mCondensedToolButton, &QAbstractButton::clicked, this, &QgsExtentWidget::setOutputExtentFromCurrent );
610 mCondensedToolButton->setPopupMode( QToolButton::InstantPopup );
611 }
612}
613
614void QgsExtentWidget::dragEnterEvent( QDragEnterEvent *event )
615{
616 if ( !( event->possibleActions() & Qt::CopyAction ) )
617 {
618 event->ignore();
619 return;
620 }
621
622 if ( mapLayerFromMimeData( event->mimeData() ) )
623 {
624 // dragged an acceptable layer, phew
625 event->setDropAction( Qt::CopyAction );
626 event->accept();
627 mCondensedLineEdit->setHighlighted( true );
628 update();
629 }
630 else
631 {
632 event->ignore();
633 }
634}
635
636void QgsExtentWidget::dragLeaveEvent( QDragLeaveEvent *event )
637{
638 if ( mCondensedLineEdit->isHighlighted() )
639 {
640 event->accept();
641 mCondensedLineEdit->setHighlighted( false );
642 update();
643 }
644 else
645 {
646 event->ignore();
647 }
648}
649
650void QgsExtentWidget::dropEvent( QDropEvent *event )
651{
652 if ( !( event->possibleActions() & Qt::CopyAction ) )
653 {
654 event->ignore();
655 return;
656 }
657
658 if ( QgsMapLayer *layer = mapLayerFromMimeData( event->mimeData() ) )
659 {
660 // dropped a map layer
661 setFocus( Qt::MouseFocusReason );
662 event->setDropAction( Qt::CopyAction );
663 event->accept();
664
666 }
667 else
668 {
669 event->ignore();
670 }
671 mCondensedLineEdit->setHighlighted( false );
672 update();
673}
674
675void QgsExtentWidget::showEvent( QShowEvent * )
676{
677 if ( mFirstShow )
678 {
679 // we don't support select on canvas if the dialog is modal
680 if ( QWidget *parentWindow = window() )
681 {
682 if ( parentWindow->isModal() )
683 {
684 mBlockDrawOnCanvas = true;
685 mDrawOnCanvasAction->setVisible( false );
686 }
687 }
688 mFirstShow = false;
689 }
690}
@ ShortString
A heavily abbreviated string, for use when a compact representation is required.
Definition qgis.h:2418
@ YardsBritishSears1922Truncated
British yards (Sears 1922 truncated).
Definition qgis.h:5053
@ Feet
Imperial feet.
Definition qgis.h:5016
@ MilesUSSurvey
US Survey miles.
Definition qgis.h:5060
@ LinksBritishSears1922
British links (Sears 1922).
Definition qgis.h:5048
@ YardsBritishBenoit1895A
British yards (Benoit 1895 A).
Definition qgis.h:5051
@ LinksBritishBenoit1895A
British links (Benoit 1895 A).
Definition qgis.h:5045
@ Centimeters
Centimeters.
Definition qgis.h:5021
@ YardsIndian1975
Indian yards (1975).
Definition qgis.h:5059
@ FeetUSSurvey
US Survey feet.
Definition qgis.h:5043
@ Millimeters
Millimeters.
Definition qgis.h:5022
@ FeetBritishSears1922
British feet (Sears 1922).
Definition qgis.h:5036
@ YardsClarkes
Clarke's yards.
Definition qgis.h:5055
@ YardsIndian
Indian yards.
Definition qgis.h:5056
@ FeetBritishBenoit1895B
British feet (Benoit 1895 B).
Definition qgis.h:5034
@ Miles
Terrestrial miles.
Definition qgis.h:5019
@ LinksUSSurvey
US Survey links.
Definition qgis.h:5050
@ Meters
Meters.
Definition qgis.h:5014
@ ChainsUSSurvey
US Survey chains.
Definition qgis.h:5030
@ FeetClarkes
Clarke's feet.
Definition qgis.h:5037
@ Unknown
Unknown distance unit.
Definition qgis.h:5063
@ Yards
Imperial yards.
Definition qgis.h:5018
@ FeetBritish1936
British feet (1936).
Definition qgis.h:5032
@ FeetIndian1962
Indian feet (1962).
Definition qgis.h:5041
@ YardsBritishSears1922
British yards (Sears 1922).
Definition qgis.h:5054
@ FeetIndian1937
Indian feet (1937).
Definition qgis.h:5040
@ YardsIndian1937
Indian yards (1937).
Definition qgis.h:5057
@ Degrees
Degrees, for planar geographic CRS distance measurements.
Definition qgis.h:5020
@ ChainsBritishBenoit1895B
British chains (Benoit 1895 B).
Definition qgis.h:5026
@ LinksBritishSears1922Truncated
British links (Sears 1922 truncated).
Definition qgis.h:5047
@ ChainsBritishBenoit1895A
British chains (Benoit 1895 A).
Definition qgis.h:5025
@ YardsBritishBenoit1895B
British yards (Benoit 1895 B).
Definition qgis.h:5052
@ FeetBritish1865
British feet (1865).
Definition qgis.h:5031
@ YardsIndian1962
Indian yards (1962).
Definition qgis.h:5058
@ FeetBritishSears1922Truncated
British feet (Sears 1922 truncated).
Definition qgis.h:5035
@ MetersGermanLegal
German legal meter.
Definition qgis.h:5062
@ LinksBritishBenoit1895B
British links (Benoit 1895 B).
Definition qgis.h:5046
@ ChainsInternational
International chains.
Definition qgis.h:5024
@ Inches
Inches.
Definition qgis.h:5023
@ Fathoms
Fathoms.
Definition qgis.h:5061
@ LinksInternational
International links.
Definition qgis.h:5044
@ ChainsBritishSears1922Truncated
British chains (Sears 1922 truncated).
Definition qgis.h:5027
@ FeetIndian
Indian (geodetic) feet.
Definition qgis.h:5039
@ NauticalMiles
Nautical miles.
Definition qgis.h:5017
@ ChainsClarkes
Clarke's chains.
Definition qgis.h:5029
@ LinksClarkes
Clarke's links.
Definition qgis.h:5049
@ ChainsBritishSears1922
British chains (Sears 1922).
Definition qgis.h:5028
@ Kilometers
Kilometers.
Definition qgis.h:5015
@ FeetIndian1975
Indian feet (1975).
Definition qgis.h:5042
@ FeetGoldCoast
Gold Coast feet.
Definition qgis.h:5038
@ FeetBritishBenoit1895A
British feet (Benoit 1895 A).
Definition qgis.h:5033
@ SpatialLayer
All spatial layers.
Definition qgis.h:225
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:80
QString name
Definition qgsmaplayer.h:84
virtual QgsRectangle extent() const
Returns the extent of the layer.
QgsCoordinateReferenceSystem crs
Definition qgsmaplayer.h:87
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:6511