41#include <QStringListModel>
43#include "moc_qgslayoutmapwidget.cpp"
48 , mMapCanvas( mapCanvas )
53 connect( mScaleLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mScaleLineEdit_editingFinished );
54 connect( mActionSetToCanvasExtent, &QAction::triggered,
this, &QgsLayoutMapWidget::setToMapCanvasExtent );
55 connect( mActionViewExtentInCanvas, &QAction::triggered,
this, &QgsLayoutMapWidget::viewExtentInCanvas );
56 connect( mActionSetToCanvasScale, &QAction::triggered,
this, &QgsLayoutMapWidget::setToMapCanvasScale );
57 connect( mActionViewScaleInCanvas, &QAction::triggered,
this, &QgsLayoutMapWidget::viewScaleInCanvas );
58 connect( mActionUpdatePreview, &QAction::triggered,
this, &QgsLayoutMapWidget::updatePreview );
59 connect( mFollowVisibilityPresetCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMapWidget::mFollowVisibilityPresetCheckBox_stateChanged );
60 connect( mKeepLayerListCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMapWidget::mKeepLayerListCheckBox_stateChanged );
61 connect( mKeepLayerStylesCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMapWidget::mKeepLayerStylesCheckBox_stateChanged );
62 connect( mDrawCanvasItemsCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMapWidget::mDrawCanvasItemsCheckBox_stateChanged );
63 connect( mOverviewBlendModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapWidget::mOverviewBlendModeComboBox_currentIndexChanged );
64 connect( mOverviewInvertCheckbox, &QCheckBox::toggled,
this, &QgsLayoutMapWidget::mOverviewInvertCheckbox_toggled );
65 connect( mOverviewCenterCheckbox, &QCheckBox::toggled,
this, &QgsLayoutMapWidget::mOverviewCenterCheckbox_toggled );
66 connect( mOverviewPositionComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapWidget::overviewStackingChanged );
68 connect( mXMinLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mXMinLineEdit_editingFinished );
69 connect( mXMaxLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mXMaxLineEdit_editingFinished );
70 connect( mYMinLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mYMinLineEdit_editingFinished );
71 connect( mYMaxLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mYMaxLineEdit_editingFinished );
72 connect( mAtlasMarginRadio, &QRadioButton::toggled,
this, &QgsLayoutMapWidget::mAtlasMarginRadio_toggled );
73 connect( mAtlasCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutMapWidget::mAtlasCheckBox_toggled );
74 connect( mAtlasMarginSpinBox,
static_cast<void ( QSpinBox::* )(
int )
>( &QSpinBox::valueChanged ),
this, &QgsLayoutMapWidget::mAtlasMarginSpinBox_valueChanged );
75 connect( mAtlasFixedScaleRadio, &QRadioButton::toggled,
this, &QgsLayoutMapWidget::mAtlasFixedScaleRadio_toggled );
76 connect( mAtlasPredefinedScaleRadio, &QRadioButton::toggled,
this, &QgsLayoutMapWidget::mAtlasPredefinedScaleRadio_toggled );
77 connect( mAddGridPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mAddGridPushButton_clicked );
78 connect( mRemoveGridPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mRemoveGridPushButton_clicked );
79 connect( mCopyGridPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mCopyGridPushButton_clicked );
80 connect( mGridUpButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mGridUpButton_clicked );
81 connect( mGridDownButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mGridDownButton_clicked );
82 connect( mGridListWidget, &QListWidget::currentItemChanged,
this, &QgsLayoutMapWidget::mGridListWidget_currentItemChanged );
83 connect( mGridListWidget, &QListWidget::itemChanged,
this, &QgsLayoutMapWidget::mGridListWidget_itemChanged );
84 connect( mGridPropertiesButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mGridPropertiesButton_clicked );
85 connect( mAddOverviewPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mAddOverviewPushButton_clicked );
86 connect( mRemoveOverviewPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mRemoveOverviewPushButton_clicked );
87 connect( mOverviewUpButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mOverviewUpButton_clicked );
88 connect( mOverviewDownButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mOverviewDownButton_clicked );
89 connect( mOverviewCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutMapWidget::mOverviewCheckBox_toggled );
90 connect( mOverviewListWidget, &QListWidget::currentItemChanged,
this, &QgsLayoutMapWidget::mOverviewListWidget_currentItemChanged );
91 connect( mOverviewListWidget, &QListWidget::itemChanged,
this, &QgsLayoutMapWidget::mOverviewListWidget_itemChanged );
92 connect( mActionLabelSettings, &QAction::triggered,
this, &QgsLayoutMapWidget::showLabelSettings );
93 connect( mActionClipSettings, &QAction::triggered,
this, &QgsLayoutMapWidget::showClipSettings );
95 connect( mTemporalCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutMapWidget::mTemporalCheckBox_toggled );
96 connect( mStartDateTime, &QDateTimeEdit::dateTimeChanged,
this, &QgsLayoutMapWidget::updateTemporalExtent );
97 connect( mEndDateTime, &QDateTimeEdit::dateTimeChanged,
this, &QgsLayoutMapWidget::updateTemporalExtent );
101 connect( mElevationRangeCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutMapWidget::mElevationRangeCheckBox_toggled );
102 connect( mZLowerSpin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapWidget::updateZRange );
103 connect( mZUpperSpin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapWidget::updateZRange );
105 mStartDateTime->setDateTimeRange( QDateTime( QDate( 1, 1, 1 ), QTime( 0, 0, 0 ) ), mStartDateTime->maximumDateTime() );
106 mEndDateTime->setDateTimeRange( QDateTime( QDate( 1, 1, 1 ), QTime( 0, 0, 0 ) ), mStartDateTime->maximumDateTime() );
107 mStartDateTime->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
108 mEndDateTime->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
110 connect( mActionMoveContent, &QAction::triggered,
this, &QgsLayoutMapWidget::switchToMoveContentTool );
112 mMapRotationSpinBox->setClearValue( 0 );
116 mLayersMenu =
new QMenu(
this );
117 QToolButton *btnLayers =
new QToolButton(
this );
118 btnLayers->setAutoRaise(
true );
119 btnLayers->setToolTip( tr(
"Set Map Extent to Layer Extent" ) );
121 btnLayers->setPopupMode( QToolButton::InstantPopup );
122 btnLayers->setMenu( mLayersMenu );
124 mDockToolbar->insertWidget( mActionMoveContent, btnLayers );
125 connect( mLayersMenu, &QMenu::aboutToShow,
this, &QgsLayoutMapWidget::aboutToShowLayersMenu );
127 mBookmarkMenu =
new QMenu(
this );
128 QToolButton *btnBookmarks =
new QToolButton(
this );
129 btnBookmarks->setAutoRaise(
true );
130 btnBookmarks->setToolTip( tr(
"Set Map Extent to Bookmark Extent" ) );
132 btnBookmarks->setPopupMode( QToolButton::InstantPopup );
133 btnBookmarks->setMenu( mBookmarkMenu );
135 mDockToolbar->insertWidget( mActionMoveContent, btnBookmarks );
136 connect( mBookmarkMenu, &QMenu::aboutToShow,
this, &QgsLayoutMapWidget::aboutToShowBookmarkMenu );
140 mainLayout->addWidget( mItemPropertiesWidget );
142 mScaleLineEdit->setValidator(
new QDoubleValidator( mScaleLineEdit ) );
144 mXMinLineEdit->setValidator(
new QDoubleValidator( mXMinLineEdit ) );
145 mXMaxLineEdit->setValidator(
new QDoubleValidator( mXMaxLineEdit ) );
146 mYMinLineEdit->setValidator(
new QDoubleValidator( mYMinLineEdit ) );
147 mYMaxLineEdit->setValidator(
new QDoubleValidator( mYMaxLineEdit ) );
155 blockAllSignals(
true );
158 mCrsSelector->setNotSetText( tr(
"Use Project CRS" ) );
159 mCrsSelector->setDialogTitle( tr(
"Map Item CRS" ) );
164 mFollowVisibilityPresetCombo->setModel(
new QStringListModel( mFollowVisibilityPresetCombo ) );
165 connect( mFollowVisibilityPresetCombo,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapWidget::followVisibilityPresetSelected );
167 onMapThemesChanged();
170 QMenu *menuKeepLayers =
new QMenu(
this );
171 mLayerListFromPresetButton->setMenu( menuKeepLayers );
173 mLayerListFromPresetButton->setToolTip( tr(
"Set layer list from a map theme" ) );
174 connect( menuKeepLayers, &QMenu::aboutToShow,
this, &QgsLayoutMapWidget::aboutToShowKeepLayersVisibilityPresetsMenu );
182 compositionAtlasToggled( atlas->enabled() );
185 mOverviewFrameMapComboBox->setCurrentLayout( item->
layout() );
187 mOverviewFrameStyleButton->registerExpressionContextGenerator( item );
193 mOverviewFrameStyleButton->registerExpressionContextGenerator( item );
218 loadOverviewEntries();
220 connect( mMapRotationSpinBox,
static_cast<void (
QgsDoubleSpinBox::* )(
double )
>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapWidget::rotationChanged );
224 blockAllSignals(
false );
229 if ( mItemPropertiesWidget )
230 mItemPropertiesWidget->setMasterLayout( masterLayout );
235 mReportTypeString = string;
236 mAtlasCheckBox->setTitle( tr(
"Controlled by %1" ).arg(
string == tr(
"atlas" ) ? tr(
"Atlas" ) : tr(
"Report" ) ) );
237 mAtlasPredefinedScaleRadio->setToolTip( tr(
"Use one of the predefined scales of the project where the %1 feature best fits." ).arg(
string ) );
240 mClipWidget->setReportTypeString(
string );
242 mLabelWidget->setReportTypeString(
string );
263 mMapItem = qobject_cast<QgsLayoutItemMap *>( item );
264 mItemPropertiesWidget->setItem( mMapItem );
266 mLabelWidget->setItem( mMapItem );
268 mClipWidget->setItem( mMapItem );
275 mOverviewFrameStyleButton->registerExpressionContextGenerator( mMapItem );
299void QgsLayoutMapWidget::compositionAtlasToggled(
bool atlasEnabled )
301 if ( atlasEnabled && mMapItem && mMapItem->layout() && mMapItem->layout()->reportContext().layer()
304 mAtlasCheckBox->setEnabled(
true );
308 mAtlasCheckBox->setEnabled(
false );
309 mAtlasCheckBox->setChecked(
false );
313void QgsLayoutMapWidget::aboutToShowKeepLayersVisibilityPresetsMenu()
318 QMenu *menu = qobject_cast<QMenu *>( sender() );
324 for (
const QString &presetName : constMapThemes )
326 menu->addAction( presetName,
this, &QgsLayoutMapWidget::keepLayersVisibilityPresetSelected );
329 if ( menu->actions().isEmpty() )
330 menu->addAction( tr(
"No presets defined" ) )->setEnabled(
false );
333void QgsLayoutMapWidget::followVisibilityPresetSelected(
int currentIndex )
338 if ( mBlockThemeComboChanges != 0 )
341 if ( currentIndex == -1 )
345 if ( currentIndex != 0 )
347 presetName = mFollowVisibilityPresetCombo->currentText();
350 if ( presetName == mMapItem->followVisibilityPresetName() )
353 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
354 mFollowVisibilityPresetCheckBox->setChecked(
true );
355 mMapItem->setFollowVisibilityPresetName( presetName );
356 mMapItem->layout()->undoStack()->endCommand();
358 mMapItem->invalidateCache();
361void QgsLayoutMapWidget::keepLayersVisibilityPresetSelected()
363 QAction *action = qobject_cast<QAction *>( sender() );
367 const QString presetName = action->text();
368 const QList<QgsMapLayer *> lst = orderedPresetVisibleLayers( presetName );
371 mKeepLayerListCheckBox->setChecked(
true );
372 mMapItem->setLayers( lst );
374 mKeepLayerStylesCheckBox->setChecked(
true );
376 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
377 mMapItem->setLayerStyleOverrides(
QgsProject::instance()->mapThemeCollection()->mapThemeStyleOverrides( presetName ) );
378 mMapItem->layout()->undoStack()->endCommand();
380 mMapItem->invalidateCache();
384void QgsLayoutMapWidget::onMapThemesChanged()
386 if ( QStringListModel *model = qobject_cast<QStringListModel *>( mFollowVisibilityPresetCombo->model() ) )
388 mBlockThemeComboChanges++;
390 lst.append( tr(
"(none)" ) );
392 model->setStringList( lst );
395 const int presetModelIndex = mFollowVisibilityPresetCombo->findText( mMapItem->followVisibilityPresetName() );
396 mFollowVisibilityPresetCombo->blockSignals(
true );
397 mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 );
398 mFollowVisibilityPresetCombo->blockSignals(
false );
399 mBlockThemeComboChanges--;
410 if ( mMapItem->presetCrs() == crs )
414 const QgsCoordinateReferenceSystem oldCrs = mMapItem->crs();
416 bool updateExtent =
false;
417 QgsRectangle newExtent;
421 xForm.setBallparkTransformsAreAppropriate(
true );
422 const QgsRectangle prevExtent = mMapItem->extent();
423 newExtent = xForm.transformBoundingBox( prevExtent );
426 catch ( QgsCsException & )
431 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map CRS" ) );
432 mMapItem->setCrs( crs );
434 mMapItem->zoomToExtent( newExtent );
435 mMapItem->layout()->undoStack()->endCommand();
436 mMapItem->invalidateCache();
439void QgsLayoutMapWidget::overviewSymbolChanged()
441 QgsLayoutItemMapOverview *overview = currentOverview();
446 overview->
setFrameSymbol( mOverviewFrameStyleButton->clonedSymbol<QgsFillSymbol>() );
447 mMapItem->endCommand();
448 mMapItem->invalidateCache();
451void QgsLayoutMapWidget::showLabelSettings()
453 mLabelWidget =
new QgsLayoutMapLabelingWidget( mMapItem );
455 if ( !mReportTypeString.isEmpty() )
456 mLabelWidget->setReportTypeString( mReportTypeString );
461void QgsLayoutMapWidget::showClipSettings()
463 mClipWidget =
new QgsLayoutMapClippingWidget( mMapItem );
464 if ( !mReportTypeString.isEmpty() )
465 mClipWidget->setReportTypeString( mReportTypeString );
469void QgsLayoutMapWidget::switchToMoveContentTool()
475void QgsLayoutMapWidget::aboutToShowLayersMenu()
477 mLayersMenu->clear();
479 if ( !mMapLayerModel )
481 mMapLayerModel =
new QgsMapLayerProxyModel(
this );
485 if ( mMapLayerModel->rowCount() == 0 )
487 QAction *action =
new QAction( tr(
"No spatial layers available" ) );
488 action->setEnabled(
false );
489 mLayersMenu->addAction( action );
493 for (
int i = 0; i < mMapLayerModel->rowCount(); ++i )
495 const QModelIndex index = mMapLayerModel->index( i, 0 );
496 const QIcon icon = qvariant_cast<QIcon>( mMapLayerModel->data( index, Qt::DecorationRole ) );
497 const QString text = mMapLayerModel->data( index, Qt::DisplayRole ).toString();
498 const QString tooltip = mMapLayerModel->data( index, Qt::ToolTipRole ).toString();
501 QAction *action =
new QAction( icon, text, mLayersMenu );
502 action->setToolTip( tooltip );
503 connect( action, &QAction::triggered,
this, [
this, layerId] {
506 setToCustomExtent( QgsReferencedRectangle( layer->extent(), layer->crs() ) );
509 mLayersMenu->addAction( action );
513void QgsLayoutMapWidget::aboutToShowBookmarkMenu()
515 mBookmarkMenu->clear();
519 if ( !mBookmarkModel )
524 if ( mBookmarkModel->rowCount() == 0 )
526 QAction *action =
new QAction( tr(
"No bookmarks available" ) );
527 action->setEnabled(
false );
528 mBookmarkMenu->addAction( action );
532 QMap<QString, QMenu *> groupMenus;
533 for (
int i = 0; i < mBookmarkModel->rowCount(); ++i )
536 QMenu *destMenu = mBookmarkMenu;
537 if ( !group.isEmpty() )
539 destMenu = groupMenus.value( group );
542 destMenu =
new QMenu( group, mBookmarkMenu );
543 groupMenus[group] = destMenu;
548 connect( action, &QAction::triggered,
this, [
this, extent] {
549 setToCustomExtent( extent );
551 destMenu->addAction( action );
554 QStringList groupKeys = groupMenus.keys();
555 groupKeys.sort( Qt::CaseInsensitive );
556 for (
int i = 0; i < groupKeys.count(); ++i )
558 if ( mBookmarkMenu->actions().value( i ) )
559 mBookmarkMenu->insertMenu( mBookmarkMenu->actions().at( i ), groupMenus.value( groupKeys.at( i ) ) );
561 mBookmarkMenu->addMenu( groupMenus.value( groupKeys.at( i ) ) );
567 if ( !mMapItem || referencedExtent.
isEmpty() )
572 QgsRectangle extent = referencedExtent;
573 if ( referencedExtent.
crs() != mMapItem->crs() )
578 coordinateTransform.setBallparkTransformsAreAppropriate(
true );
579 extent = coordinateTransform.transformBoundingBox( extent );
581 catch ( QgsCsException & )
588 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Extent" ) );
589 mMapItem->zoomToExtent( extent );
590 mMapItem->layout()->undoStack()->endCommand();
593void QgsLayoutMapWidget::mTemporalCheckBox_toggled(
bool checked )
600 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Toggle Temporal Range" ) );
601 mMapItem->setIsTemporal( checked );
602 mMapItem->layout()->undoStack()->endCommand();
606 whileBlocking( mStartDateTime )->setDateTime( mMapItem->temporalRange().begin() );
607 whileBlocking( mEndDateTime )->setDateTime( mMapItem->temporalRange().end() );
613void QgsLayoutMapWidget::updateTemporalExtent()
620 const QDateTime begin = mStartDateTime->dateTime();
621 const QDateTime end = mEndDateTime->dateTime();
624 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Set Temporal Range" ) );
625 mMapItem->setTemporalRange( range );
626 mMapItem->layout()->undoStack()->endCommand();
631void QgsLayoutMapWidget::mElevationRangeCheckBox_toggled(
bool checked )
638 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Toggle Z Range" ) );
639 mMapItem->setZRangeEnabled( checked );
640 mMapItem->layout()->undoStack()->endCommand();
645void QgsLayoutMapWidget::updateZRange()
652 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Set Z Range" ) );
653 double zLower = mZLowerSpin->value();
654 if ( zLower == mZLowerSpin->clearValue() )
655 zLower = std::numeric_limits<double>::lowest();
656 double zUpper = mZUpperSpin->value();
657 if ( zUpper == mZUpperSpin->clearValue() )
658 zUpper = std::numeric_limits<double>::max();
660 mMapItem->setZRange( QgsDoubleRange( zLower, zUpper ) );
661 mMapItem->layout()->undoStack()->endCommand();
666void QgsLayoutMapWidget::mAtlasCheckBox_toggled(
bool checked )
673 mAtlasFixedScaleRadio->setEnabled( checked );
674 mAtlasMarginRadio->setEnabled( checked );
676 if ( mAtlasMarginRadio->isEnabled() && mAtlasMarginRadio->isChecked() )
678 mAtlasMarginSpinBox->setEnabled(
true );
682 mAtlasMarginSpinBox->setEnabled(
false );
685 mAtlasPredefinedScaleRadio->setEnabled( checked );
690 if ( mMapItem->layout() )
692 toggleAtlasScalingOptionsByLayerType();
697 if ( !hasPredefinedScales() )
699 mAtlasPredefinedScaleRadio->setEnabled(
false );
702 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Set Atlas Driven" ) );
703 mMapItem->setAtlasDriven( checked );
704 mMapItem->layout()->undoStack()->endCommand();
708void QgsLayoutMapWidget::updateMapForAtlas()
711 if ( mMapItem->atlasDriven() )
718 mMapItem->invalidateCache();
722void QgsLayoutMapWidget::mAtlasMarginRadio_toggled(
bool checked )
724 mAtlasMarginSpinBox->setEnabled( checked );
726 if ( checked && mMapItem )
728 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Atlas Mode" ) );
730 mMapItem->layout()->undoStack()->endCommand();
735void QgsLayoutMapWidget::mAtlasMarginSpinBox_valueChanged(
int value )
743 mMapItem->setAtlasMargin( value / 100. );
744 mMapItem->layout()->undoStack()->endCommand();
748void QgsLayoutMapWidget::mAtlasFixedScaleRadio_toggled(
bool checked )
757 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Atlas Mode" ) );
759 mMapItem->layout()->undoStack()->endCommand();
764void QgsLayoutMapWidget::mAtlasPredefinedScaleRadio_toggled(
bool checked )
771 if ( hasPredefinedScales() )
775 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Atlas Scales" ) );
777 mMapItem->layout()->undoStack()->endCommand();
785 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Atlas Mode" ) );
787 mMapItem->layout()->undoStack()->endCommand();
791void QgsLayoutMapWidget::mScaleLineEdit_editingFinished()
798 bool conversionSuccess =
false;
799 const double scaleDenominator = QLocale().toDouble( mScaleLineEdit->text(), &conversionSuccess );
800 if ( !conversionSuccess )
808 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Scale" ) );
809 mMapItem->setScale( scaleDenominator );
810 mMapItem->layout()->undoStack()->endCommand();
813void QgsLayoutMapWidget::rotationChanged(
double value )
821 mMapItem->setMapRotation( value );
822 mMapItem->layout()->undoStack()->endCommand();
823 mMapItem->invalidateCache();
826void QgsLayoutMapWidget::setToMapCanvasExtent()
833 QgsRectangle newExtent = mMapCanvas->mapSettings().visibleExtent();
836 if ( mMapCanvas->mapSettings().destinationCrs()
841 QgsCoordinateTransform xForm( mMapCanvas->mapSettings().destinationCrs(), mMapItem->crs(),
QgsProject::instance() );
842 xForm.setBallparkTransformsAreAppropriate(
true );
843 newExtent = xForm.transformBoundingBox( newExtent );
845 catch ( QgsCsException & )
852 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Extent" ) );
853 mMapItem->zoomToExtent( newExtent );
854 mMapItem->layout()->undoStack()->endCommand();
857void QgsLayoutMapWidget::setToMapCanvasScale()
864 const double newScale = mMapCanvas->
scale();
866 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Scale" ) );
867 mMapItem->setScale( newScale );
868 mMapItem->layout()->undoStack()->endCommand();
871void QgsLayoutMapWidget::viewExtentInCanvas()
878 const QgsRectangle currentMapExtent = mMapItem->extent();
880 if ( !currentMapExtent.
isEmpty() )
884 mMapCanvas->setReferencedExtent( QgsReferencedRectangle( currentMapExtent, mMapItem->crs() ) );
886 catch ( QgsCsException & )
891 mMapCanvas->refresh();
895void QgsLayoutMapWidget::viewScaleInCanvas()
902 const double currentScale = mMapItem->scale();
903 mMapCanvas->zoomScale( currentScale,
true );
906void QgsLayoutMapWidget::mXMinLineEdit_editingFinished()
908 updateComposerExtentFromGui();
911void QgsLayoutMapWidget::mXMaxLineEdit_editingFinished()
913 updateComposerExtentFromGui();
916void QgsLayoutMapWidget::mYMinLineEdit_editingFinished()
918 updateComposerExtentFromGui();
921void QgsLayoutMapWidget::mYMaxLineEdit_editingFinished()
923 updateComposerExtentFromGui();
926void QgsLayoutMapWidget::updateGuiElements()
933 blockAllSignals(
true );
934 mLabel->setText( mMapItem->displayName() );
936 whileBlocking( mCrsSelector )->setCrs( mMapItem->presetCrs() );
939 const double scale = mMapItem->scale();
942 if ( scale >= 10000 )
945 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 0 ) );
947 else if ( scale >= 10 )
949 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 3 ) );
951 else if ( scale >= 1 )
954 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 4 ) );
959 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 10 ) );
963 const QgsRectangle composerMapExtent = mMapItem->extent();
964 mXMinLineEdit->setText( QLocale().toString( composerMapExtent.
xMinimum(),
'f', 3 ) );
965 mXMaxLineEdit->setText( QLocale().toString( composerMapExtent.
xMaximum(),
'f', 3 ) );
966 mYMinLineEdit->setText( QLocale().toString( composerMapExtent.
yMinimum(),
'f', 3 ) );
967 mYMaxLineEdit->setText( QLocale().toString( composerMapExtent.
yMaximum(),
'f', 3 ) );
972 mFollowVisibilityPresetCheckBox->setCheckState(
973 mMapItem->followVisibilityPreset() ? Qt::Checked : Qt::Unchecked
975 const int presetModelIndex = mFollowVisibilityPresetCombo->findText( mMapItem->followVisibilityPresetName() );
976 mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 );
979 if ( mMapItem->keepLayerSet() )
981 mKeepLayerListCheckBox->setCheckState( Qt::Checked );
985 mKeepLayerListCheckBox->setCheckState( Qt::Unchecked );
988 mKeepLayerStylesCheckBox->setEnabled( mMapItem->keepLayerSet() );
989 mKeepLayerStylesCheckBox->setCheckState( mMapItem->keepLayerStyles() ? Qt::Checked : Qt::Unchecked );
992 if ( mMapItem->drawAnnotations() )
994 mDrawCanvasItemsCheckBox->setCheckState( Qt::Checked );
998 mDrawCanvasItemsCheckBox->setCheckState( Qt::Unchecked );
1002 mAtlasCheckBox->setChecked( mMapItem->atlasDriven() );
1005 mAtlasFixedScaleRadio->setEnabled( mMapItem->atlasDriven() );
1008 mAtlasMarginRadio->setEnabled( mMapItem->atlasDriven() );
1010 mAtlasPredefinedScaleRadio->setEnabled( mMapItem->atlasDriven() );
1013 if ( mMapItem->atlasDriven() )
1015 toggleAtlasScalingOptionsByLayerType();
1018 if ( !hasPredefinedScales() )
1020 mAtlasPredefinedScaleRadio->setEnabled(
false );
1023 mTemporalCheckBox->setChecked( mMapItem->isTemporal() );
1024 mTemporalCheckBox->setCollapsed( !mMapItem->isTemporal() );
1025 mStartDateTime->setEnabled( mMapItem->isTemporal() );
1026 mEndDateTime->setEnabled( mMapItem->isTemporal() );
1027 if ( mMapItem->isTemporal() )
1029 mStartDateTime->setDateTime( mMapItem->temporalRange().begin() );
1030 mEndDateTime->setDateTime( mMapItem->temporalRange().end() );
1033 whileBlocking( mElevationRangeCheckBox )->setChecked( mMapItem->zRangeEnabled() );
1034 mElevationRangeCheckBox->setCollapsed( !mMapItem->zRangeEnabled() );
1035 if ( mMapItem->zRange().lower() != std::numeric_limits<double>::lowest() )
1036 whileBlocking( mZLowerSpin )->setValue( mMapItem->zRange().lower() );
1039 if ( mMapItem->zRange().upper() != std::numeric_limits<double>::max() )
1040 whileBlocking( mZUpperSpin )->setValue( mMapItem->zRange().upper() );
1046 loadOverviewEntries();
1048 blockAllSignals(
false );
1051void QgsLayoutMapWidget::toggleAtlasScalingOptionsByLayerType()
1069 mAtlasFixedScaleRadio->setChecked(
true );
1070 mAtlasMarginRadio->setEnabled(
false );
1075 mAtlasMarginRadio->setEnabled(
true );
1079void QgsLayoutMapWidget::updateComposerExtentFromGui()
1086 double xmin, ymin, xmax, ymax;
1087 bool conversionSuccess;
1089 xmin = QLocale().toDouble( mXMinLineEdit->text(), &conversionSuccess );
1090 if ( !conversionSuccess )
1092 xmax = QLocale().toDouble( mXMaxLineEdit->text(), &conversionSuccess );
1093 if ( !conversionSuccess )
1095 ymin = QLocale().toDouble( mYMinLineEdit->text(), &conversionSuccess );
1096 if ( !conversionSuccess )
1098 ymax = QLocale().toDouble( mYMaxLineEdit->text(), &conversionSuccess );
1099 if ( !conversionSuccess )
1102 const QgsRectangle newExtent( xmin, ymin, xmax, ymax );
1104 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Extent" ) );
1105 mMapItem->setExtent( newExtent );
1106 mMapItem->layout()->undoStack()->endCommand();
1109void QgsLayoutMapWidget::blockAllSignals(
bool b )
1111 mScaleLineEdit->blockSignals( b );
1112 mXMinLineEdit->blockSignals( b );
1113 mXMaxLineEdit->blockSignals( b );
1114 mYMinLineEdit->blockSignals( b );
1115 mYMaxLineEdit->blockSignals( b );
1116 mDrawCanvasItemsCheckBox->blockSignals( b );
1117 mOverviewFrameMapComboBox->blockSignals( b );
1118 mOverviewFrameStyleButton->blockSignals( b );
1119 mOverviewBlendModeComboBox->blockSignals( b );
1120 mOverviewInvertCheckbox->blockSignals( b );
1121 mOverviewCenterCheckbox->blockSignals( b );
1122 mAtlasCheckBox->blockSignals( b );
1123 mAtlasMarginSpinBox->blockSignals( b );
1124 mAtlasFixedScaleRadio->blockSignals( b );
1125 mAtlasMarginRadio->blockSignals( b );
1126 mFollowVisibilityPresetCheckBox->blockSignals( b );
1127 mFollowVisibilityPresetCombo->blockSignals( b );
1128 mKeepLayerListCheckBox->blockSignals( b );
1129 mKeepLayerStylesCheckBox->blockSignals( b );
1130 mActionSetToCanvasExtent->blockSignals( b );
1131 mActionUpdatePreview->blockSignals( b );
1132 mTemporalCheckBox->blockSignals( b );
1133 mStartDateTime->blockSignals( b );
1134 mEndDateTime->blockSignals( b );
1136 blockOverviewItemsSignals( b );
1139void QgsLayoutMapWidget::updatePreview()
1145 mMapItem->refresh();
1148void QgsLayoutMapWidget::mFollowVisibilityPresetCheckBox_stateChanged(
int state )
1155 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
1156 if ( state == Qt::Checked )
1158 mMapItem->setFollowVisibilityPreset(
true );
1161 mKeepLayerListCheckBox->setCheckState( Qt::Unchecked );
1162 mKeepLayerStylesCheckBox->setCheckState( Qt::Unchecked );
1164 mMapItem->invalidateCache();
1168 mMapItem->setFollowVisibilityPreset(
false );
1170 mMapItem->layout()->undoStack()->endCommand();
1173void QgsLayoutMapWidget::mKeepLayerListCheckBox_stateChanged(
int state )
1181 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Map Preset Changed" ) );
1182 storeCurrentLayerSet();
1183 mMapItem->setKeepLayerSet( state == Qt::Checked );
1184 if ( state == Qt::Unchecked )
1186 mMapItem->setLayers( QList<QgsMapLayer *>() );
1188 mMapItem->layout()->undoStack()->endCommand();
1191 if ( state == Qt::Checked )
1194 mFollowVisibilityPresetCheckBox->setCheckState( Qt::Unchecked );
1198 mKeepLayerStylesCheckBox->setChecked( Qt::Unchecked );
1199 mMapItem->invalidateCache();
1202 mKeepLayerStylesCheckBox->setEnabled( state == Qt::Checked );
1205void QgsLayoutMapWidget::mKeepLayerStylesCheckBox_stateChanged(
int state )
1212 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
1213 if ( state == Qt::Checked )
1215 mMapItem->storeCurrentLayerStyles();
1216 mMapItem->setKeepLayerStyles(
true );
1220 mMapItem->setLayerStyleOverrides( QMap<QString, QString>() );
1221 mMapItem->setKeepLayerStyles(
false );
1223 mMapItem->layout()->undoStack()->endCommand();
1226void QgsLayoutMapWidget::mDrawCanvasItemsCheckBox_stateChanged(
int state )
1233 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Toggle Map Item" ) );
1234 mMapItem->setDrawAnnotations( state == Qt::Checked );
1235 mMapItem->invalidateCache();
1236 mMapItem->layout()->undoStack()->endCommand();
1239void QgsLayoutMapWidget::atlasLayerChanged(
QgsVectorLayer *layer )
1244 mAtlasCheckBox->setChecked(
false );
1245 mAtlasCheckBox->setEnabled(
false );
1250 mAtlasCheckBox->setEnabled(
true );
1254 if ( mAtlasCheckBox->isChecked() )
1255 toggleAtlasScalingOptionsByLayerType();
1258bool QgsLayoutMapWidget::hasPredefinedScales()
const
1263 if ( !hasProjectScales || scales.isEmpty() )
1266 const QgsSettings settings;
1268 return !scales.isEmpty() && !scales[0].isEmpty();
1273void QgsLayoutMapWidget::mAddGridPushButton_clicked()
1280 const QString itemName = tr(
"Grid %1" ).arg( mMapItem->grids()->size() + 1 );
1281 QgsLayoutItemMapGrid *grid =
new QgsLayoutItemMapGrid( itemName, mMapItem );
1282 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Add Map Grid" ) );
1283 mMapItem->grids()->addGrid( grid );
1284 mMapItem->layout()->undoStack()->endCommand();
1285 mMapItem->updateBoundingRect();
1288 addGridListItem( grid->
id(), grid->
name() );
1289 mGridListWidget->setCurrentRow( 0 );
1290 mGridListWidget_currentItemChanged( mGridListWidget->currentItem(),
nullptr );
1293void QgsLayoutMapWidget::mRemoveGridPushButton_clicked()
1295 QListWidgetItem *item = mGridListWidget->currentItem();
1301 mMapItem->beginCommand( tr(
"Remove Grid" ) );
1302 mMapItem->grids()->removeGrid( item->data( Qt::UserRole ).toString() );
1303 QListWidgetItem *delItem = mGridListWidget->takeItem( mGridListWidget->row( item ) );
1305 mMapItem->endCommand();
1306 mMapItem->updateBoundingRect();
1310void QgsLayoutMapWidget::mCopyGridPushButton_clicked()
1312 QListWidgetItem *item = mGridListWidget->currentItem();
1318 QgsLayoutItemMapGrid *sourceGrid = mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
1324 QString itemName = tr(
"%1 - Copy" ).arg( sourceGrid->
name() );
1325 QList<QgsLayoutItemMapGrid *> grids = mMapItem->grids()->asList();
1328 const auto it = std::find_if( grids.begin(), grids.end(), [&itemName](
const QgsLayoutItemMapGrid *grd ) { return grd->name() == itemName; } );
1329 if ( it != grids.end() )
1332 itemName = tr(
"%1 - Copy %2" ).arg( sourceGrid->
name() ).arg( i );
1337 QgsLayoutItemMapGrid *grid =
new QgsLayoutItemMapGrid( itemName, mMapItem );
1340 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Duplicate Map Grid" ) );
1341 mMapItem->grids()->addGrid( grid );
1342 mMapItem->layout()->undoStack()->endCommand();
1343 mMapItem->updateBoundingRect();
1346 addGridListItem( grid->
id(), grid->
name() );
1347 mGridListWidget->setCurrentRow( 0 );
1348 mGridListWidget_currentItemChanged( mGridListWidget->currentItem(),
nullptr );
1351void QgsLayoutMapWidget::mGridUpButton_clicked()
1353 QListWidgetItem *item = mGridListWidget->currentItem();
1359 const int row = mGridListWidget->row( item );
1364 mGridListWidget->takeItem( row );
1365 mGridListWidget->insertItem( row - 1, item );
1366 mGridListWidget->setCurrentItem( item );
1367 mMapItem->beginCommand( tr(
"Move Grid Up" ) );
1368 mMapItem->grids()->moveGridUp( item->data( Qt::UserRole ).toString() );
1369 mMapItem->endCommand();
1373void QgsLayoutMapWidget::mGridDownButton_clicked()
1375 QListWidgetItem *item = mGridListWidget->currentItem();
1381 const int row = mGridListWidget->row( item );
1382 if ( mGridListWidget->count() <= row )
1386 mGridListWidget->takeItem( row );
1387 mGridListWidget->insertItem( row + 1, item );
1388 mGridListWidget->setCurrentItem( item );
1389 mMapItem->beginCommand( tr(
"Move Grid Down" ) );
1390 mMapItem->grids()->moveGridDown( item->data( Qt::UserRole ).toString() );
1391 mMapItem->endCommand();
1402 QListWidgetItem *item = mGridListWidget->currentItem();
1407 return mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
1410void QgsLayoutMapWidget::mGridListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem * )
1412 mGridPropertiesButton->
setEnabled(
static_cast<bool>( current ) );
1415void QgsLayoutMapWidget::mGridListWidget_itemChanged( QListWidgetItem *item )
1422 QgsLayoutItemMapGrid *grid = mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
1428 mMapItem->beginCommand( tr(
"Rename Grid" ) );
1429 grid->
setName( item->text() );
1430 mMapItem->endCommand();
1433void QgsLayoutMapWidget::mGridPropertiesButton_clicked()
1439 QgsLayoutItemMapGrid *grid = currentGrid();
1445 QgsLayoutMapGridWidget *w =
new QgsLayoutMapGridWidget( grid, mMapItem );
1450QListWidgetItem *QgsLayoutMapWidget::addGridListItem(
const QString &
id,
const QString &name )
1452 QListWidgetItem *item =
new QListWidgetItem( name,
nullptr );
1453 item->setData( Qt::UserRole,
id );
1454 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
1455 mGridListWidget->insertItem( 0, item );
1459void QgsLayoutMapWidget::loadGridEntries()
1462 QSet<QString> selectedIds;
1463 const QList<QListWidgetItem *> itemSelection = mGridListWidget->selectedItems();
1464 QList<QListWidgetItem *>::const_iterator sIt = itemSelection.constBegin();
1465 for ( ; sIt != itemSelection.constEnd(); ++sIt )
1467 selectedIds.insert( ( *sIt )->data( Qt::UserRole ).toString() );
1470 mGridListWidget->clear();
1476 const QList<QgsLayoutItemMapGrid *> grids = mMapItem->grids()->asList();
1477 QList<QgsLayoutItemMapGrid *>::const_iterator gridIt = grids.constBegin();
1478 for ( ; gridIt != grids.constEnd(); ++gridIt )
1480 QListWidgetItem *item = addGridListItem( ( *gridIt )->id(), ( *gridIt )->name() );
1481 if ( selectedIds.contains( ( *gridIt )->id() ) )
1483 item->setSelected(
true );
1484 mGridListWidget->setCurrentItem( item );
1488 if ( mGridListWidget->currentItem() )
1490 mGridListWidget_currentItemChanged( mGridListWidget->currentItem(),
nullptr );
1494 mGridListWidget_currentItemChanged(
nullptr,
nullptr );
1498void QgsLayoutMapWidget::mAddOverviewPushButton_clicked()
1505 const QString itemName = tr(
"Overview %1" ).arg( mMapItem->overviews()->size() + 1 );
1506 QgsLayoutItemMapOverview *overview =
new QgsLayoutItemMapOverview( itemName, mMapItem );
1507 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Add Map Overview" ) );
1508 mMapItem->overviews()->addOverview( overview );
1509 mMapItem->layout()->undoStack()->endCommand();
1510 mMapItem->invalidateCache();
1512 addOverviewListItem( overview->
id(), overview->
name() );
1514 mOverviewListWidget->setCurrentRow( 0 );
1517void QgsLayoutMapWidget::mRemoveOverviewPushButton_clicked()
1519 QListWidgetItem *item = mOverviewListWidget->currentItem();
1524 mMapItem->beginCommand( tr(
"Remove Map Overview" ) );
1525 mMapItem->overviews()->removeOverview( item->data( Qt::UserRole ).toString() );
1526 mMapItem->endCommand();
1527 QListWidgetItem *delItem = mOverviewListWidget->takeItem( mOverviewListWidget->row( item ) );
1529 mMapItem->invalidateCache();
1532void QgsLayoutMapWidget::mOverviewUpButton_clicked()
1534 QListWidgetItem *item = mOverviewListWidget->currentItem();
1540 const int row = mOverviewListWidget->row( item );
1545 mOverviewListWidget->takeItem( row );
1546 mOverviewListWidget->insertItem( row - 1, item );
1547 mOverviewListWidget->setCurrentItem( item );
1548 mMapItem->beginCommand( tr(
"Move Overview Up" ) );
1549 mMapItem->overviews()->moveOverviewUp( item->data( Qt::UserRole ).toString() );
1550 mMapItem->endCommand();
1551 mMapItem->invalidateCache();
1554void QgsLayoutMapWidget::mOverviewDownButton_clicked()
1556 QListWidgetItem *item = mOverviewListWidget->currentItem();
1562 const int row = mOverviewListWidget->row( item );
1563 if ( mOverviewListWidget->count() <= row )
1567 mOverviewListWidget->takeItem( row );
1568 mOverviewListWidget->insertItem( row + 1, item );
1569 mOverviewListWidget->setCurrentItem( item );
1570 mMapItem->beginCommand( tr(
"Move Overview Down" ) );
1571 mMapItem->overviews()->moveOverviewDown( item->data( Qt::UserRole ).toString() );
1572 mMapItem->endCommand();
1573 mMapItem->invalidateCache();
1583 QListWidgetItem *item = mOverviewListWidget->currentItem();
1589 return mMapItem->overviews()->overview( item->data( Qt::UserRole ).toString() );
1592void QgsLayoutMapWidget::mOverviewListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous )
1594 Q_UNUSED( previous )
1597 mOverviewCheckBox->setEnabled(
false );
1602 setOverviewItems( mMapItem->overviews()->overview( current->data( Qt::UserRole ).toString() ) );
1605void QgsLayoutMapWidget::mOverviewListWidget_itemChanged( QListWidgetItem *item )
1612 QgsLayoutItemMapOverview *overview = mMapItem->overviews()->overview( item->data( Qt::UserRole ).toString() );
1618 mMapItem->beginCommand( QStringLiteral(
"Rename Overview" ) );
1619 overview->
setName( item->text() );
1620 mMapItem->endCommand();
1621 if ( item->isSelected() )
1624 mOverviewCheckBox->setTitle( tr(
"Draw \"%1\" overview" ).arg( overview->
name() ) );
1628void QgsLayoutMapWidget::setOverviewItemsEnabled(
bool enabled )
1630 mOverviewFrameMapLabel->setEnabled( enabled );
1631 mOverviewFrameMapComboBox->setEnabled( enabled );
1632 mOverviewFrameStyleLabel->setEnabled( enabled );
1633 mOverviewFrameStyleButton->setEnabled( enabled );
1634 mOverviewBlendModeLabel->setEnabled( enabled );
1635 mOverviewBlendModeComboBox->setEnabled( enabled );
1636 mOverviewInvertCheckbox->setEnabled( enabled );
1637 mOverviewCenterCheckbox->setEnabled( enabled );
1638 mOverviewPositionComboBox->setEnabled( enabled );
1644void QgsLayoutMapWidget::blockOverviewItemsSignals(
const bool block )
1646 mOverviewFrameMapComboBox->blockSignals( block );
1647 mOverviewFrameStyleButton->blockSignals( block );
1648 mOverviewBlendModeComboBox->blockSignals( block );
1649 mOverviewInvertCheckbox->blockSignals( block );
1650 mOverviewCenterCheckbox->blockSignals( block );
1651 mOverviewPositionComboBox->blockSignals( block );
1652 mOverviewStackingLayerComboBox->blockSignals( block );
1662 blockOverviewItemsSignals(
true );
1664 mOverviewCheckBox->setTitle( tr(
"Draw \"%1\" overview" ).arg( overview->
name() ) );
1665 mOverviewCheckBox->setChecked( overview->
enabled() );
1668 mOverviewFrameMapComboBox->setItem( overview->
linkedMap() );
1671 mOverviewBlendModeComboBox->setBlendMode( overview->
blendMode() );
1673 mOverviewInvertCheckbox->setChecked( overview->
inverted() );
1675 mOverviewCenterCheckbox->setChecked( overview->
centered() );
1677 mOverviewPositionComboBox->setCurrentIndex( mOverviewPositionComboBox->findData( overview->
stackingPosition() ) );
1678 mOverviewStackingLayerComboBox->setLayer( overview->
stackingLayer() );
1683 blockOverviewItemsSignals(
false );
1686void QgsLayoutMapWidget::storeCurrentLayerSet()
1691 QList<QgsMapLayer *> layers = mMapCanvas->mapSettings().layers();
1693 mMapItem->setLayers( layers );
1695 if ( mMapItem->keepLayerStyles() )
1698 mMapItem->storeCurrentLayerStyles();
1702QList<QgsMapLayer *> QgsLayoutMapWidget::orderedPresetVisibleLayers(
const QString &name )
const
1707 QList<QgsMapLayer *> lst;
1709 for ( QgsMapLayer *layer : constLayerOrder )
1711 if ( visibleIds.contains( layer->
id() ) )
1719QListWidgetItem *QgsLayoutMapWidget::addOverviewListItem(
const QString &
id,
const QString &name )
1721 QListWidgetItem *item =
new QListWidgetItem( name,
nullptr );
1722 item->setData( Qt::UserRole,
id );
1723 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
1724 mOverviewListWidget->insertItem( 0, item );
1728void QgsLayoutMapWidget::loadOverviewEntries()
1731 QSet<QString> selectedIds;
1732 const QList<QListWidgetItem *> itemSelection = mOverviewListWidget->selectedItems();
1733 QList<QListWidgetItem *>::const_iterator sIt = itemSelection.constBegin();
1734 for ( ; sIt != itemSelection.constEnd(); ++sIt )
1736 selectedIds.insert( ( *sIt )->data( Qt::UserRole ).toString() );
1739 mOverviewListWidget->clear();
1745 mOverviewFrameMapComboBox->setExceptedItemList( QList<QgsLayoutItem *>() << mMapItem );
1748 const QList<QgsLayoutItemMapOverview *> overviews = mMapItem->overviews()->asList();
1749 QList<QgsLayoutItemMapOverview *>::const_iterator overviewIt = overviews.constBegin();
1750 for ( ; overviewIt != overviews.constEnd(); ++overviewIt )
1752 QListWidgetItem *item = addOverviewListItem( ( *overviewIt )->id(), ( *overviewIt )->name() );
1753 if ( selectedIds.contains( ( *overviewIt )->id() ) )
1755 item->setSelected(
true );
1756 mOverviewListWidget->setCurrentItem( item );
1760 if ( mOverviewListWidget->currentItem() )
1762 mOverviewListWidget_currentItemChanged( mOverviewListWidget->currentItem(),
nullptr );
1766 mOverviewListWidget_currentItemChanged(
nullptr,
nullptr );
1770void QgsLayoutMapWidget::mOverviewCheckBox_toggled(
bool state )
1772 QgsLayoutItemMapOverview *overview = currentOverview();
1778 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Overview Display Toggled" ) );
1780 mMapItem->invalidateCache();
1781 mMapItem->layout()->undoStack()->endCommand();
1784void QgsLayoutMapWidget::overviewMapChanged(
QgsLayoutItem *item )
1786 QgsLayoutItemMapOverview *overview = currentOverview();
1792 QgsLayoutItemMap *map =
dynamic_cast<QgsLayoutItemMap *
>( item );
1796 mMapItem->beginCommand( tr(
"Change Overview Map" ) );
1798 mMapItem->invalidateCache();
1799 mMapItem->endCommand();
1802void QgsLayoutMapWidget::mOverviewBlendModeComboBox_currentIndexChanged(
int index )
1805 QgsLayoutItemMapOverview *overview = currentOverview();
1811 mMapItem->beginCommand( tr(
"Change Overview Blend Mode" ) );
1812 overview->
setBlendMode( mOverviewBlendModeComboBox->blendMode() );
1813 mMapItem->invalidateCache();
1814 mMapItem->endCommand();
1817void QgsLayoutMapWidget::mOverviewInvertCheckbox_toggled(
bool state )
1819 QgsLayoutItemMapOverview *overview = currentOverview();
1825 mMapItem->beginCommand( tr(
"Toggle Overview Inverted" ) );
1827 mMapItem->invalidateCache();
1828 mMapItem->endCommand();
1831void QgsLayoutMapWidget::mOverviewCenterCheckbox_toggled(
bool state )
1833 QgsLayoutItemMapOverview *overview = currentOverview();
1839 mMapItem->beginCommand( tr(
"Toggle Overview Centered" ) );
1841 mMapItem->invalidateCache();
1842 mMapItem->endCommand();
1845void QgsLayoutMapWidget::overviewStackingChanged(
int )
1847 QgsLayoutItemMapOverview *overview = currentOverview();
1853 mMapItem->beginCommand( tr(
"Change Overview Position" ) );
1855 mMapItem->invalidateCache();
1856 mMapItem->endCommand();
1863 mOverviewStackingLayerComboBox->setEnabled(
false );
1868 mOverviewStackingLayerComboBox->setEnabled(
true );
1873void QgsLayoutMapWidget::overviewStackingLayerChanged(
QgsMapLayer *layer )
1875 QgsLayoutItemMapOverview *overview = currentOverview();
1881 mMapItem->beginCommand( tr(
"Change Overview Position" ) );
1883 mMapItem->invalidateCache();
1884 mMapItem->endCommand();
1898 mLabelBoundarySpinBox->setClearValue( 0 );
1899 mLabelBoundarySpinBox->setShowClearButton(
true );
1901 mLabelBoundaryUnitsCombo->linkToWidget( mLabelBoundarySpinBox );
1902 mLabelBoundaryUnitsCombo->setConverter( &mMapItem->layout()->renderContext().measurementConverter() );
1905 connect( mLabelBoundarySpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapLabelingWidget::labelMarginChanged );
1906 connect( mShowPartialLabelsCheckBox, &QCheckBox::toggled,
this, &QgsLayoutMapLabelingWidget::showPartialsToggled );
1907 connect( mShowUnplacedCheckBox, &QCheckBox::toggled,
this, &QgsLayoutMapLabelingWidget::showUnplacedToggled );
1924 mMapItem = qobject_cast<QgsLayoutItemMap *>( item );
1931 updateGuiElements();
1936void QgsLayoutMapLabelingWidget::updateGuiElements()
1938 whileBlocking( mLabelBoundarySpinBox )->setValue( mMapItem->labelMargin().length() );
1939 whileBlocking( mLabelBoundaryUnitsCombo )->setUnit( mMapItem->labelMargin().units() );
1943 if ( mBlockingItemsListView->model() )
1945 QAbstractItemModel *oldModel = mBlockingItemsListView->model();
1946 mBlockingItemsListView->setModel(
nullptr );
1947 oldModel->deleteLater();
1950 QgsLayoutMapItemBlocksLabelsModel *model =
new QgsLayoutMapItemBlocksLabelsModel( mMapItem, mMapItem->layout()->itemsModel(), mBlockingItemsListView );
1951 mBlockingItemsListView->setModel( model );
1956void QgsLayoutMapLabelingWidget::labelMarginChanged(
double val )
1962 mMapItem->setLabelMargin( QgsLayoutMeasurement( val, mLabelBoundaryUnitsCombo->unit() ) );
1963 mMapItem->layout()->undoStack()->endCommand();
1964 mMapItem->invalidateCache();
1967void QgsLayoutMapLabelingWidget::labelMarginUnitsChanged()
1973 mMapItem->setLabelMargin( QgsLayoutMeasurement( mLabelBoundarySpinBox->value(), mLabelBoundaryUnitsCombo->unit() ) );
1974 mMapItem->layout()->undoStack()->endCommand();
1975 mMapItem->invalidateCache();
1978void QgsLayoutMapLabelingWidget::showPartialsToggled(
bool checked )
1983 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Label Visibility" ) );
1988 flags &= ~QgsLayoutItemMap::ShowPartialLabels;
1989 mMapItem->setMapFlags( flags );
1990 mMapItem->layout()->undoStack()->endCommand();
1991 mMapItem->invalidateCache();
1994void QgsLayoutMapLabelingWidget::showUnplacedToggled(
bool checked )
1999 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Label Visibility" ) );
2004 flags &= ~QgsLayoutItemMap::ShowUnplacedLabels;
2005 mMapItem->setMapFlags( flags );
2006 mMapItem->layout()->undoStack()->endCommand();
2007 mMapItem->invalidateCache();
2011 : QSortFilterProxyModel( parent )
2012 , mLayoutModel( layoutModel )
2015 setSourceModel( layoutModel );
2028 if ( i.column() != 0 )
2033 QgsLayoutItem *item = mLayoutModel->itemFromIndex( mapToSource( i ) );
2041 case Qt::CheckStateRole:
2042 switch ( i.column() )
2045 return mMapItem ? ( mMapItem->isLabelBlockingItem( item ) ? Qt::Checked : Qt::Unchecked ) : Qt::Unchecked;
2051 return mLayoutModel->data( sourceIndex, role );
2059 if ( !index.isValid() )
2062 QgsLayoutItem *item = mLayoutModel->itemFromIndex( mapToSource( index ) );
2063 if ( !item || !mMapItem )
2070 if ( value.toBool() )
2072 mMapItem->addLabelBlockingItem( item );
2076 mMapItem->removeLabelBlockingItem( item );
2078 emit dataChanged( index, index, QVector<int>() << role );
2080 mMapItem->layout()->undoStack()->endCommand();
2081 mMapItem->invalidateCache();
2088 Qt::ItemFlags
flags = QSortFilterProxyModel::flags( index );
2090 if ( !index.isValid() )
2095 switch ( index.column() )
2098 return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
2100 return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
2106 QgsLayoutItem *item = mLayoutModel->itemFromIndex( mLayoutModel->index( source_row, 0, source_parent ) );
2107 if ( !item || item == mMapItem )
2128 mLayerModel->setItemsCheckable(
true );
2129 mLayersTreeView->setModel( mLayerModel );
2135 for (
int i = 0; i < mAtlasClippingTypeComboBox->count(); ++i )
2137 mItemClippingTypeComboBox->addItem( mAtlasClippingTypeComboBox->itemText( i ), mAtlasClippingTypeComboBox->itemData( i ) );
2140 mClipItemComboBox->setCurrentLayout( map->
layout() );
2143 connect( mRadioClipSelectedLayers, &QRadioButton::toggled,
this, &QgsLayoutMapClippingWidget::toggleLayersSelectionGui );
2144 mLayersTreeView->setEnabled(
false );
2145 mSelectAllButton->setEnabled(
false );
2146 mDeselectAllButton->setEnabled(
false );
2147 mInvertSelectionButton->setEnabled(
false );
2148 mRadioClipAllLayers->setChecked(
true );
2150 connect( mClipToAtlasCheckBox, &QGroupBox::toggled,
this, [
this](
bool active ) {
2151 if ( !mBlockUpdates )
2153 mMapItem->beginCommand( tr(
"Toggle Atlas Clipping" ) );
2154 mMapItem->atlasClippingSettings()->setEnabled( active );
2155 mMapItem->endCommand();
2158 connect( mForceLabelsInsideCheckBox, &QCheckBox::toggled,
this, [
this](
bool active ) {
2159 if ( !mBlockUpdates )
2161 mMapItem->beginCommand( tr(
"Change Atlas Clipping Label Behavior" ) );
2162 mMapItem->atlasClippingSettings()->setForceLabelsInsideFeature( active );
2163 mMapItem->endCommand();
2166 connect( mClipFrameCheckBox, &QCheckBox::toggled,
this, [
this](
bool active ) {
2167 if ( !mBlockUpdates )
2169 mMapItem->beginCommand( tr(
"Change Atlas Clipping Label Behavior" ) );
2170 mMapItem->atlasClippingSettings()->setClipItemShape( active );
2171 mMapItem->endCommand();
2174 connect( mAtlasClippingTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
2175 if ( !mBlockUpdates )
2177 mMapItem->beginCommand( tr(
"Change Atlas Clipping Behavior" ) );
2179 mMapItem->endCommand();
2183 connect( mRadioClipSelectedLayers, &QCheckBox::toggled,
this, [
this](
bool active ) {
2184 if ( active && !mBlockUpdates )
2186 mBlockUpdates =
true;
2187 mMapItem->beginCommand( tr(
"Change Atlas Clipping Layers" ) );
2188 mMapItem->atlasClippingSettings()->setRestrictToLayers(
true );
2189 mMapItem->endCommand();
2190 mBlockUpdates =
false;
2194 connect( mSelectAllButton, &QPushButton::clicked,
this, &QgsLayoutMapClippingWidget::selectAll );
2195 connect( mDeselectAllButton, &QPushButton::clicked,
this, &QgsLayoutMapClippingWidget::deselectAll );
2196 connect( mInvertSelectionButton, &QPushButton::clicked,
this, &QgsLayoutMapClippingWidget::invertSelection );
2198 connect( mRadioClipAllLayers, &QCheckBox::toggled,
this, [
this](
bool active ) {
2199 if ( active && !mBlockUpdates )
2201 mBlockUpdates =
true;
2202 mMapItem->beginCommand( tr(
"Change Atlas Clipping Layers" ) );
2203 mMapItem->atlasClippingSettings()->setRestrictToLayers(
false );
2204 mMapItem->endCommand();
2205 mBlockUpdates =
false;
2208 connect( mLayerModel, &QgsMapLayerModel::dataChanged,
this, [
this](
const QModelIndex &,
const QModelIndex &,
const QVector<int> &roles = QVector<int>() ) {
2209 if ( !roles.contains( Qt::CheckStateRole ) )
2212 if ( !mBlockUpdates )
2214 mBlockUpdates =
true;
2215 mMapItem->beginCommand( tr(
"Change Atlas Clipping Layers" ) );
2216 mMapItem->atlasClippingSettings()->setLayersToClip( mLayerModel->layersChecked() );
2217 mMapItem->endCommand();
2218 mBlockUpdates =
false;
2224 connect( mClipToItemCheckBox, &QGroupBox::toggled,
this, [
this](
bool active ) {
2225 if ( !mBlockUpdates )
2227 mMapItem->beginCommand( tr(
"Toggle Map Clipping" ) );
2228 mMapItem->itemClippingSettings()->setEnabled( active );
2229 mMapItem->endCommand();
2232 connect( mItemClippingTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
2233 if ( !mBlockUpdates )
2235 mMapItem->beginCommand( tr(
"Change Map Clipping Behavior" ) );
2237 mMapItem->endCommand();
2240 connect( mForceLabelsInsideItemCheckBox, &QCheckBox::toggled,
this, [
this](
bool active ) {
2241 if ( !mBlockUpdates )
2243 mMapItem->beginCommand( tr(
"Change Map Clipping Label Behavior" ) );
2244 mMapItem->itemClippingSettings()->setForceLabelsInsideClipPath( active );
2245 mMapItem->endCommand();
2249 if ( !mBlockUpdates )
2251 mMapItem->beginCommand( tr(
"Change Map Clipping Item" ) );
2252 mMapItem->itemClippingSettings()->setSourceItem( item );
2253 mMapItem->endCommand();
2263 atlasToggled( atlas->enabled() );
2269 mClipToAtlasCheckBox->setTitle( tr(
"Clip to %1 feature" ).arg(
string ) );
2270 mClipToAtlasLabel->setText( tr(
"<b>When enabled, map layers will be automatically clipped to the boundary of the current %1 feature.</b>" ).arg(
string ) );
2271 mForceLabelsInsideCheckBox->setText( tr(
"Force labels inside %1 feature" ).arg(
string ) );
2272 mClipFrameCheckBox->setText( tr(
"Clip item frame to match %1 feature" ).arg(
string ) );
2285 mMapItem = qobject_cast<QgsLayoutItemMap *>( item );
2292 updateGuiElements();
2297void QgsLayoutMapClippingWidget::updateGuiElements()
2299 if ( mBlockUpdates )
2302 mBlockUpdates =
true;
2303 mClipToAtlasCheckBox->setChecked( mMapItem->atlasClippingSettings()->enabled() );
2304 mAtlasClippingTypeComboBox->setCurrentIndex( mAtlasClippingTypeComboBox->findData(
static_cast<int>( mMapItem->atlasClippingSettings()->featureClippingType() ) ) );
2305 mForceLabelsInsideCheckBox->setChecked( mMapItem->atlasClippingSettings()->forceLabelsInsideFeature() );
2306 mClipFrameCheckBox->setChecked( mMapItem->atlasClippingSettings()->clipItemShape() );
2308 mRadioClipAllLayers->setChecked( !mMapItem->atlasClippingSettings()->restrictToLayers() );
2309 mRadioClipSelectedLayers->setChecked( mMapItem->atlasClippingSettings()->restrictToLayers() );
2310 mLayerModel->
setLayersChecked( mMapItem->atlasClippingSettings()->layersToClip() );
2312 mClipToItemCheckBox->setChecked( mMapItem->itemClippingSettings()->enabled() );
2313 mItemClippingTypeComboBox->setCurrentIndex( mItemClippingTypeComboBox->findData(
static_cast<int>( mMapItem->itemClippingSettings()->featureClippingType() ) ) );
2314 mForceLabelsInsideItemCheckBox->setChecked( mMapItem->itemClippingSettings()->forceLabelsInsideClipPath() );
2315 mClipItemComboBox->setItem( mMapItem->itemClippingSettings()->sourceItem() );
2317 mBlockUpdates =
false;
2320void QgsLayoutMapClippingWidget::atlasLayerChanged(
QgsVectorLayer *layer )
2325 mClipToAtlasCheckBox->setChecked(
false );
2326 mClipToAtlasCheckBox->setEnabled(
false );
2331 mClipToAtlasCheckBox->setEnabled(
true );
2335void QgsLayoutMapClippingWidget::atlasToggled(
bool atlasEnabled )
2337 if ( atlasEnabled && mMapItem && mMapItem->layout() && mMapItem->layout()->reportContext().layer()
2340 mClipToAtlasCheckBox->setEnabled(
true );
2344 mClipToAtlasCheckBox->setEnabled(
false );
2345 mClipToAtlasCheckBox->setChecked(
false );
2349void QgsLayoutMapClippingWidget::invertSelection()
2351 for (
int i = 0; i < mLayerModel->rowCount( QModelIndex() ); i++ )
2353 QModelIndex index = mLayerModel->index( i, 0 );
2354 Qt::CheckState currentState = Qt::CheckState( mLayerModel->data( index, Qt::CheckStateRole ).toInt() );
2355 Qt::CheckState newState = ( currentState == Qt::Checked ) ? Qt::Unchecked : Qt::Checked;
2356 mLayerModel->setData( index, newState, Qt::CheckStateRole );
2360void QgsLayoutMapClippingWidget::selectAll()
2362 for (
int i = 0; i < mLayerModel->rowCount( QModelIndex() ); i++ )
2364 QModelIndex index = mLayerModel->index( i, 0 );
2365 mLayerModel->setData( index, Qt::Checked, Qt::CheckStateRole );
2369void QgsLayoutMapClippingWidget::deselectAll()
2371 for (
int i = 0; i < mLayerModel->rowCount( QModelIndex() ); i++ )
2373 QModelIndex index = mLayerModel->index( i, 0 );
2374 mLayerModel->setData( index, Qt::Unchecked, Qt::CheckStateRole );
2378void QgsLayoutMapClippingWidget::toggleLayersSelectionGui(
bool toggled )
2380 mLayersTreeView->setEnabled( toggled );
2381 mSelectAllButton->setEnabled( toggled );
2382 mDeselectAllButton->setEnabled( toggled );
2383 mInvertSelectionButton->setEnabled( toggled );
@ 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.
Represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
@ MinimumValue
Reset value to minimum().
QgsFillSymbol * clone() const override
Returns a deep copy of this symbol.
QList< QgsMapLayer * > layerOrder() const
The order in which layers will be rendered on the canvas.
Used to render QgsLayout as an atlas, by iterating over the features from an associated vector layer.
void toggled(bool enabled)
Emitted when atlas is enabled or disabled.
A common interface for layout designer dialogs and widgets.
@ ToolMoveItemContent
Move item content tool.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
void setEnabled(bool enabled) override
Controls whether the item will be drawn.
void copyProperties(const QgsLayoutItemMapGrid *other)
Copies properties from specified map grid.
QString id() const
Returns the unique id for the map item.
StackingPosition
Item stacking position, specifies where the in the map's stack the item should be rendered.
@ StackBelowMapLabels
Render above all map layers, but below map labels.
@ StackAboveMapLabels
Render above all map layers and labels.
@ StackBelowMapLayer
Render below a specific map layer (see stackingLayer()).
@ StackAboveMapLayer
Render above a specific map layer (see stackingLayer()).
@ StackBelowMap
Render below all map layers.
void setStackingLayer(QgsMapLayer *layer)
Sets the item's stacking layer, which specifies where the in the map's stack the item should be rende...
virtual void setEnabled(bool enabled)
Controls whether the item will be drawn.
void setStackingPosition(StackingPosition position)
Sets the item's stacking position, which specifies where the in the map's stack the item should be re...
StackingPosition stackingPosition() const
Returns the item's stacking position, which specifies where the in the map's stack the item should be...
QString name() const
Returns the friendly display name for the item.
void setName(const QString &name)
Sets the friendly display name for the item.
bool enabled() const
Returns whether the item will be drawn.
QgsMapLayer * stackingLayer() const
Returns the item's stacking layer, which specifies where the in the map's stack the item should be re...
An individual overview which is drawn above the map content in a QgsLayoutItemMap,...
QgsFillSymbol * frameSymbol()
Returns the fill symbol used for drawing the overview extent.
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the overview.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the overview.
bool centered() const
Returns whether the extent of the map is forced to center on the overview.
void setLinkedMap(QgsLayoutItemMap *map)
Sets the map to show the overview extent of.
void setFrameSymbol(QgsFillSymbol *symbol)
Sets the fill symbol used for drawing the overview extent.
bool inverted() const
Returns whether the overview frame is inverted, ie, whether the shaded area is drawn outside the exte...
void setInverted(bool inverted)
Sets whether the overview frame is inverted, ie, whether the shaded area is drawn outside the extent ...
void setCentered(bool centered)
Sets whether the extent of the map is forced to center on the overview.
QgsLayoutItemMap * linkedMap()
Returns the source map to show the overview extent of.
Layout graphical items for displaying a map.
void extentChanged()
Emitted when the map's extent changes.
@ Predefined
A scale is chosen from the predefined scales.
@ Auto
The extent is adjusted so that each feature is fully visible.
@ Fixed
The current scale of the map is used for each feature of the atlas.
void mapRotationChanged(double newRotation)
Emitted when the map's rotation changes.
QFlags< MapItemFlag > MapItemFlags
@ ShowPartialLabels
Whether to draw labels which are partially outside of the map view.
@ ShowUnplacedLabels
Whether to render unplaced labels in the map view.
Base class for graphical items within a QgsLayout.
@ UndoOverviewStyle
Map overview style.
@ UndoMapRotation
Map rotation changed.
@ UndoAtlasMargin
Map atlas margin changed.
@ UndoMapLabelMargin
Margin for labels from edge of map.
int type() const override
Returns a unique graphics item type identifier.
@ FlagProvidesClipPath
Item can act as a clipping path provider (see clipPath()).
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
QgsLayoutMapItemBlocksLabelsModel(QgsLayoutItemMap *map, QgsLayoutModel *layoutModel, QObject *parent=nullptr)
constructor
Qt::ItemFlags flags(const QModelIndex &index) const override
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QVariant data(const QModelIndex &index, int role) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
A model for items attached to a layout.
const QgsLayout * layout() const
Returns the layout the object is attached to.
void changed()
Emitted when the object's properties change.
@ MapYMin
Map extent y minimum.
@ MapZRangeUpper
Map frame Z-range lower value.
@ StartDateTime
Temporal range's start DateTime.
@ MapLayers
Map layer set.
@ MapZRangeLower
Map frame Z-range lower value.
@ MapRotation
Map rotation.
@ MapXMax
Map extent x maximum.
@ MapStylePreset
Layer and style map theme.
@ MapYMax
Map extent y maximum.
@ MapAtlasMargin
Map atlas margin.
@ EndDateTime
Temporal range's end DateTime.
@ MapXMin
Map extent x minimum.
@ MapLabelMargin
Map label margin.
@ OriginalValue
Return the original, user set value.
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
void beginCommand(QgsLayoutUndoObjectInterface *object, const QString &commandText, int id=0)
Begins a new undo command for the specified object.
void unitChanged(Qgis::LayoutUnit unit)
Emitted when the unit is changed.
QgsLayoutReportContext & reportContext()
Returns a reference to the layout's report context, which stores information relating to the current ...
QgsLayoutUndoStack * undoStack()
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's ...
Map canvas is a class for displaying all GIS data types on a canvas.
FeatureClippingType
Feature clipping behavior, which controls how features from vector layers will be clipped.
@ NoClipping
Only render features which intersect the clipping region, but do not clip these features to the regio...
@ ClipPainterOnly
Applying clipping on the painter only (i.e. feature boundaries will be unchanged, but may be invisibl...
@ ClipToIntersection
Clip the geometry of these features to the region prior to rendering (i.e. feature boundaries will fo...
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
A model for display of map layers in widgets.
void setLayersChecked(const QList< QgsMapLayer * > &layers)
Sets which layers are checked in the model.
@ LayerId
Stores the map layer ID.
Base class for all map layer types.
void mapThemesChanged()
Emitted when map themes within the collection are changed.
QStringList mapThemeVisibleLayerIds(const QString &name) const
Returns the list of layer IDs that are visible for the specified map theme.
Interface for master layout type objects, such as print layouts and reports.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsMapThemeCollection * mapThemeCollection
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree.
QgsCoordinateReferenceSystem crs
void scale(double scaleFactor, const QgsPointXY *c=nullptr)
Scale the rectangle around its center point.
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.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
static const QgsSettingsEntryStringList * settingsMapScales
Represents a vector layer which manages a vector based dataset.
Q_INVOKABLE Qgis::WkbType wkbType() const final
Returns the WKBType or WKBUnknown in case of error.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
static Qgis::GeometryType geometryType(Qgis::WkbType type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.