42#include <QStringListModel>
44#include "moc_qgslayoutmapwidget.cpp"
46using namespace Qt::StringLiterals;
51 , mMapCanvas( mapCanvas )
56 connect( mScaleLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mScaleLineEdit_editingFinished );
57 connect( mActionSetToCanvasExtent, &QAction::triggered,
this, &QgsLayoutMapWidget::setToMapCanvasExtent );
58 connect( mActionViewExtentInCanvas, &QAction::triggered,
this, &QgsLayoutMapWidget::viewExtentInCanvas );
59 connect( mActionSetToCanvasScale, &QAction::triggered,
this, &QgsLayoutMapWidget::setToMapCanvasScale );
60 connect( mActionViewScaleInCanvas, &QAction::triggered,
this, &QgsLayoutMapWidget::viewScaleInCanvas );
61 connect( mActionUpdatePreview, &QAction::triggered,
this, &QgsLayoutMapWidget::updatePreview );
62 connect( mFollowVisibilityPresetCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMapWidget::mFollowVisibilityPresetCheckBox_stateChanged );
63 connect( mKeepLayerListCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMapWidget::mKeepLayerListCheckBox_stateChanged );
64 connect( mKeepLayerStylesCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMapWidget::mKeepLayerStylesCheckBox_stateChanged );
65 connect( mDrawCanvasItemsCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMapWidget::mDrawCanvasItemsCheckBox_stateChanged );
66 connect( mOverviewBlendModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapWidget::mOverviewBlendModeComboBox_currentIndexChanged );
67 connect( mOverviewInvertCheckbox, &QCheckBox::toggled,
this, &QgsLayoutMapWidget::mOverviewInvertCheckbox_toggled );
68 connect( mOverviewCenterCheckbox, &QCheckBox::toggled,
this, &QgsLayoutMapWidget::mOverviewCenterCheckbox_toggled );
69 connect( mOverviewPositionComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapWidget::overviewStackingChanged );
71 connect( mXMinLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mXMinLineEdit_editingFinished );
72 connect( mXMaxLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mXMaxLineEdit_editingFinished );
73 connect( mYMinLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mYMinLineEdit_editingFinished );
74 connect( mYMaxLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mYMaxLineEdit_editingFinished );
75 connect( mAtlasMarginRadio, &QRadioButton::toggled,
this, &QgsLayoutMapWidget::mAtlasMarginRadio_toggled );
76 connect( mAtlasCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutMapWidget::mAtlasCheckBox_toggled );
77 connect( mAtlasMarginSpinBox,
static_cast<void ( QSpinBox::* )(
int )
>( &QSpinBox::valueChanged ),
this, &QgsLayoutMapWidget::mAtlasMarginSpinBox_valueChanged );
78 connect( mAtlasFixedScaleRadio, &QRadioButton::toggled,
this, &QgsLayoutMapWidget::mAtlasFixedScaleRadio_toggled );
79 connect( mAtlasPredefinedScaleRadio, &QRadioButton::toggled,
this, &QgsLayoutMapWidget::mAtlasPredefinedScaleRadio_toggled );
80 connect( mAddGridPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mAddGridPushButton_clicked );
81 connect( mRemoveGridPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mRemoveGridPushButton_clicked );
82 connect( mCopyGridPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mCopyGridPushButton_clicked );
83 connect( mGridUpButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mGridUpButton_clicked );
84 connect( mGridDownButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mGridDownButton_clicked );
85 connect( mGridListWidget, &QListWidget::currentItemChanged,
this, &QgsLayoutMapWidget::mGridListWidget_currentItemChanged );
86 connect( mGridListWidget, &QListWidget::itemChanged,
this, &QgsLayoutMapWidget::mGridListWidget_itemChanged );
87 connect( mGridPropertiesButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mGridPropertiesButton_clicked );
88 connect( mAddOverviewPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mAddOverviewPushButton_clicked );
89 connect( mRemoveOverviewPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mRemoveOverviewPushButton_clicked );
90 connect( mOverviewUpButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mOverviewUpButton_clicked );
91 connect( mOverviewDownButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mOverviewDownButton_clicked );
92 connect( mOverviewCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutMapWidget::mOverviewCheckBox_toggled );
93 connect( mOverviewListWidget, &QListWidget::currentItemChanged,
this, &QgsLayoutMapWidget::mOverviewListWidget_currentItemChanged );
94 connect( mOverviewListWidget, &QListWidget::itemChanged,
this, &QgsLayoutMapWidget::mOverviewListWidget_itemChanged );
95 connect( mActionLabelSettings, &QAction::triggered,
this, &QgsLayoutMapWidget::showLabelSettings );
96 connect( mActionClipSettings, &QAction::triggered,
this, &QgsLayoutMapWidget::showClipSettings );
98 connect( mTemporalCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutMapWidget::mTemporalCheckBox_toggled );
99 connect( mStartDateTime, &QDateTimeEdit::dateTimeChanged,
this, &QgsLayoutMapWidget::updateTemporalExtent );
100 connect( mEndDateTime, &QDateTimeEdit::dateTimeChanged,
this, &QgsLayoutMapWidget::updateTemporalExtent );
104 connect( mElevationRangeCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutMapWidget::mElevationRangeCheckBox_toggled );
105 connect( mZLowerSpin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapWidget::updateZRange );
106 connect( mZUpperSpin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapWidget::updateZRange );
108 mStartDateTime->setDateTimeRange( QDateTime( QDate( 1, 1, 1 ), QTime( 0, 0, 0 ) ), mStartDateTime->maximumDateTime() );
109 mEndDateTime->setDateTimeRange( QDateTime( QDate( 1, 1, 1 ), QTime( 0, 0, 0 ) ), mStartDateTime->maximumDateTime() );
110 mStartDateTime->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
111 mEndDateTime->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
113 connect( mActionMoveContent, &QAction::triggered,
this, &QgsLayoutMapWidget::switchToMoveContentTool );
115 mMapRotationSpinBox->setClearValue( 0 );
119 mLayersMenu =
new QMenu(
this );
120 QToolButton *btnLayers =
new QToolButton(
this );
121 btnLayers->setAutoRaise(
true );
122 btnLayers->setToolTip( tr(
"Set Map Extent to Layer Extent" ) );
124 btnLayers->setPopupMode( QToolButton::InstantPopup );
125 btnLayers->setMenu( mLayersMenu );
127 mDockToolbar->insertWidget( mActionMoveContent, btnLayers );
128 connect( mLayersMenu, &QMenu::aboutToShow,
this, &QgsLayoutMapWidget::aboutToShowLayersMenu );
130 mBookmarkMenu =
new QMenu(
this );
131 QToolButton *btnBookmarks =
new QToolButton(
this );
132 btnBookmarks->setAutoRaise(
true );
133 btnBookmarks->setToolTip( tr(
"Set Map Extent to Bookmark Extent" ) );
135 btnBookmarks->setPopupMode( QToolButton::InstantPopup );
136 btnBookmarks->setMenu( mBookmarkMenu );
138 mDockToolbar->insertWidget( mActionMoveContent, btnBookmarks );
139 connect( mBookmarkMenu, &QMenu::aboutToShow,
this, &QgsLayoutMapWidget::aboutToShowBookmarkMenu );
143 mainLayout->addWidget( mItemPropertiesWidget );
145 mScaleLineEdit->setValidator(
new QDoubleValidator( mScaleLineEdit ) );
147 mXMinLineEdit->setValidator(
new QDoubleValidator( mXMinLineEdit ) );
148 mXMaxLineEdit->setValidator(
new QDoubleValidator( mXMaxLineEdit ) );
149 mYMinLineEdit->setValidator(
new QDoubleValidator( mYMinLineEdit ) );
150 mYMaxLineEdit->setValidator(
new QDoubleValidator( mYMaxLineEdit ) );
158 blockAllSignals(
true );
161 mCrsSelector->setNotSetText( tr(
"Use Project CRS" ) );
162 mCrsSelector->setDialogTitle( tr(
"Map Item CRS" ) );
167 mFollowVisibilityPresetCombo->setModel(
new QStringListModel( mFollowVisibilityPresetCombo ) );
168 connect( mFollowVisibilityPresetCombo,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapWidget::followVisibilityPresetSelected );
170 onMapThemesChanged();
173 QMenu *menuKeepLayers =
new QMenu(
this );
174 mLayerListFromPresetButton->setMenu( menuKeepLayers );
176 mLayerListFromPresetButton->setToolTip( tr(
"Set layer list from a map theme" ) );
177 connect( menuKeepLayers, &QMenu::aboutToShow,
this, &QgsLayoutMapWidget::aboutToShowKeepLayersVisibilityPresetsMenu );
185 compositionAtlasToggled( atlas->enabled() );
188 mOverviewFrameMapComboBox->setCurrentLayout( item->
layout() );
190 mOverviewFrameStyleButton->registerExpressionContextGenerator( item );
196 mOverviewFrameStyleButton->registerExpressionContextGenerator( item );
221 loadOverviewEntries();
223 connect( mMapRotationSpinBox,
static_cast<void (
QgsDoubleSpinBox::* )(
double )
>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapWidget::rotationChanged );
227 blockAllSignals(
false );
232 if ( mItemPropertiesWidget )
233 mItemPropertiesWidget->setMasterLayout( masterLayout );
238 mReportTypeString = string;
239 mAtlasCheckBox->setTitle( tr(
"Controlled by %1" ).arg(
string == tr(
"atlas" ) ? tr(
"Atlas" ) : tr(
"Report" ) ) );
240 mAtlasPredefinedScaleRadio->setToolTip( tr(
"Use one of the predefined scales of the project where the %1 feature best fits." ).arg(
string ) );
243 mClipWidget->setReportTypeString(
string );
245 mLabelWidget->setReportTypeString(
string );
266 mMapItem = qobject_cast<QgsLayoutItemMap *>( item );
267 mItemPropertiesWidget->setItem( mMapItem );
269 mLabelWidget->setItem( mMapItem );
271 mClipWidget->setItem( mMapItem );
278 mOverviewFrameStyleButton->registerExpressionContextGenerator( mMapItem );
302void QgsLayoutMapWidget::compositionAtlasToggled(
bool atlasEnabled )
304 if ( atlasEnabled && mMapItem && mMapItem->layout() && mMapItem->layout()->reportContext().layer()
307 mAtlasCheckBox->setEnabled(
true );
311 mAtlasCheckBox->setEnabled(
false );
312 mAtlasCheckBox->setChecked(
false );
316void QgsLayoutMapWidget::aboutToShowKeepLayersVisibilityPresetsMenu()
321 QMenu *menu = qobject_cast<QMenu *>( sender() );
327 for (
const QString &presetName : constMapThemes )
329 menu->addAction( presetName,
this, &QgsLayoutMapWidget::keepLayersVisibilityPresetSelected );
332 if ( menu->actions().isEmpty() )
333 menu->addAction( tr(
"No presets defined" ) )->setEnabled(
false );
336void QgsLayoutMapWidget::followVisibilityPresetSelected(
int currentIndex )
341 if ( mBlockThemeComboChanges != 0 )
344 if ( currentIndex == -1 )
348 if ( currentIndex != 0 )
350 presetName = mFollowVisibilityPresetCombo->currentText();
353 if ( presetName == mMapItem->followVisibilityPresetName() )
356 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
357 mFollowVisibilityPresetCheckBox->setChecked(
true );
358 mMapItem->setFollowVisibilityPresetName( presetName );
359 mMapItem->layout()->undoStack()->endCommand();
361 mMapItem->invalidateCache();
364void QgsLayoutMapWidget::keepLayersVisibilityPresetSelected()
366 QAction *action = qobject_cast<QAction *>( sender() );
370 const QString presetName = action->text();
371 const QList<QgsMapLayer *> lst = orderedPresetVisibleLayers( presetName );
374 mKeepLayerListCheckBox->setChecked(
true );
375 mMapItem->setLayers( lst );
377 mKeepLayerStylesCheckBox->setChecked(
true );
379 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
380 mMapItem->setLayerStyleOverrides(
QgsProject::instance()->mapThemeCollection()->mapThemeStyleOverrides( presetName ) );
381 mMapItem->layout()->undoStack()->endCommand();
383 mMapItem->invalidateCache();
387void QgsLayoutMapWidget::onMapThemesChanged()
389 if ( QStringListModel *model = qobject_cast<QStringListModel *>( mFollowVisibilityPresetCombo->model() ) )
391 mBlockThemeComboChanges++;
393 lst.append( tr(
"(none)" ) );
395 model->setStringList( lst );
398 const int presetModelIndex = mFollowVisibilityPresetCombo->findText( mMapItem->followVisibilityPresetName() );
399 mFollowVisibilityPresetCombo->blockSignals(
true );
400 mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 );
401 mFollowVisibilityPresetCombo->blockSignals(
false );
402 mBlockThemeComboChanges--;
413 if ( mMapItem->presetCrs() == crs )
417 const QgsCoordinateReferenceSystem oldCrs = mMapItem->crs();
419 bool updateExtent =
false;
420 QgsRectangle newExtent;
424 xForm.setBallparkTransformsAreAppropriate(
true );
425 const QgsRectangle prevExtent = mMapItem->extent();
426 newExtent = xForm.transformBoundingBox( prevExtent );
429 catch ( QgsCsException & )
434 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map CRS" ) );
435 mMapItem->setCrs( crs );
437 mMapItem->zoomToExtent( newExtent );
438 mMapItem->layout()->undoStack()->endCommand();
439 mMapItem->invalidateCache();
442void QgsLayoutMapWidget::overviewSymbolChanged()
444 QgsLayoutItemMapOverview *overview = currentOverview();
449 overview->
setFrameSymbol( mOverviewFrameStyleButton->clonedSymbol<QgsFillSymbol>() );
450 mMapItem->endCommand();
451 mMapItem->invalidateCache();
454void QgsLayoutMapWidget::showLabelSettings()
456 mLabelWidget =
new QgsLayoutMapLabelingWidget( mMapItem );
458 if ( !mReportTypeString.isEmpty() )
459 mLabelWidget->setReportTypeString( mReportTypeString );
464void QgsLayoutMapWidget::showClipSettings()
466 mClipWidget =
new QgsLayoutMapClippingWidget( mMapItem );
467 if ( !mReportTypeString.isEmpty() )
468 mClipWidget->setReportTypeString( mReportTypeString );
472void QgsLayoutMapWidget::switchToMoveContentTool()
478void QgsLayoutMapWidget::aboutToShowLayersMenu()
480 mLayersMenu->clear();
482 if ( !mMapLayerModel )
484 mMapLayerModel =
new QgsMapLayerProxyModel(
this );
488 if ( mMapLayerModel->rowCount() == 0 )
490 QAction *action =
new QAction( tr(
"No spatial layers available" ) );
491 action->setEnabled(
false );
492 mLayersMenu->addAction( action );
496 for (
int i = 0; i < mMapLayerModel->rowCount(); ++i )
498 const QModelIndex index = mMapLayerModel->index( i, 0 );
499 const QIcon icon = qvariant_cast<QIcon>( mMapLayerModel->data( index, Qt::DecorationRole ) );
500 const QString text = mMapLayerModel->data( index, Qt::DisplayRole ).toString();
501 const QString tooltip = mMapLayerModel->data( index, Qt::ToolTipRole ).toString();
504 QAction *action =
new QAction( icon, text, mLayersMenu );
505 action->setToolTip( tooltip );
506 connect( action, &QAction::triggered,
this, [
this, layerId] {
509 setToCustomExtent( QgsReferencedRectangle( layer->extent(), layer->crs() ) );
512 mLayersMenu->addAction( action );
516void QgsLayoutMapWidget::aboutToShowBookmarkMenu()
518 mBookmarkMenu->clear();
522 if ( !mBookmarkModel )
527 if ( mBookmarkModel->rowCount() == 0 )
529 QAction *action =
new QAction( tr(
"No bookmarks available" ) );
530 action->setEnabled(
false );
531 mBookmarkMenu->addAction( action );
535 QMap<QString, QMenu *> groupMenus;
536 for (
int i = 0; i < mBookmarkModel->rowCount(); ++i )
539 QMenu *destMenu = mBookmarkMenu;
540 if ( !group.isEmpty() )
542 destMenu = groupMenus.value( group );
545 destMenu =
new QMenu( group, mBookmarkMenu );
546 groupMenus[group] = destMenu;
551 connect( action, &QAction::triggered,
this, [
this, extent] {
552 setToCustomExtent( extent );
554 destMenu->addAction( action );
557 QStringList groupKeys = groupMenus.keys();
558 groupKeys.sort( Qt::CaseInsensitive );
559 for (
int i = 0; i < groupKeys.count(); ++i )
561 if ( mBookmarkMenu->actions().value( i ) )
562 mBookmarkMenu->insertMenu( mBookmarkMenu->actions().at( i ), groupMenus.value( groupKeys.at( i ) ) );
564 mBookmarkMenu->addMenu( groupMenus.value( groupKeys.at( i ) ) );
570 if ( !mMapItem || referencedExtent.
isEmpty() )
575 QgsRectangle extent = referencedExtent;
576 if ( referencedExtent.
crs() != mMapItem->crs() )
581 coordinateTransform.setBallparkTransformsAreAppropriate(
true );
582 extent = coordinateTransform.transformBoundingBox( extent );
584 catch ( QgsCsException & )
591 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Extent" ) );
592 mMapItem->zoomToExtent( extent );
593 mMapItem->layout()->undoStack()->endCommand();
596void QgsLayoutMapWidget::mTemporalCheckBox_toggled(
bool checked )
603 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Toggle Temporal Range" ) );
604 mMapItem->setIsTemporal( checked );
605 mMapItem->layout()->undoStack()->endCommand();
609 whileBlocking( mStartDateTime )->setDateTime( mMapItem->temporalRange().begin() );
610 whileBlocking( mEndDateTime )->setDateTime( mMapItem->temporalRange().end() );
616void QgsLayoutMapWidget::updateTemporalExtent()
623 const QDateTime begin = mStartDateTime->dateTime();
624 const QDateTime end = mEndDateTime->dateTime();
627 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Set Temporal Range" ) );
628 mMapItem->setTemporalRange( range );
629 mMapItem->layout()->undoStack()->endCommand();
634void QgsLayoutMapWidget::mElevationRangeCheckBox_toggled(
bool checked )
641 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Toggle Z Range" ) );
642 mMapItem->setZRangeEnabled( checked );
643 mMapItem->layout()->undoStack()->endCommand();
648void QgsLayoutMapWidget::updateZRange()
655 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Set Z Range" ) );
656 double zLower = mZLowerSpin->value();
657 if ( zLower == mZLowerSpin->clearValue() )
658 zLower = std::numeric_limits<double>::lowest();
659 double zUpper = mZUpperSpin->value();
660 if ( zUpper == mZUpperSpin->clearValue() )
661 zUpper = std::numeric_limits<double>::max();
663 mMapItem->setZRange( QgsDoubleRange( zLower, zUpper ) );
664 mMapItem->layout()->undoStack()->endCommand();
669void QgsLayoutMapWidget::mAtlasCheckBox_toggled(
bool checked )
676 mAtlasFixedScaleRadio->setEnabled( checked );
677 mAtlasMarginRadio->setEnabled( checked );
679 if ( mAtlasMarginRadio->isEnabled() && mAtlasMarginRadio->isChecked() )
681 mAtlasMarginSpinBox->setEnabled(
true );
685 mAtlasMarginSpinBox->setEnabled(
false );
688 mAtlasPredefinedScaleRadio->setEnabled( checked );
693 if ( mMapItem->layout() )
695 toggleAtlasScalingOptionsByLayerType();
700 if ( !hasPredefinedScales() )
702 mAtlasPredefinedScaleRadio->setEnabled(
false );
705 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Set Atlas Driven" ) );
706 mMapItem->setAtlasDriven( checked );
707 mMapItem->layout()->undoStack()->endCommand();
711void QgsLayoutMapWidget::updateMapForAtlas()
714 if ( mMapItem->atlasDriven() )
721 mMapItem->invalidateCache();
725void QgsLayoutMapWidget::mAtlasMarginRadio_toggled(
bool checked )
727 mAtlasMarginSpinBox->setEnabled( checked );
729 if ( checked && mMapItem )
731 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Atlas Mode" ) );
733 mMapItem->layout()->undoStack()->endCommand();
738void QgsLayoutMapWidget::mAtlasMarginSpinBox_valueChanged(
int value )
746 mMapItem->setAtlasMargin( value / 100. );
747 mMapItem->layout()->undoStack()->endCommand();
751void QgsLayoutMapWidget::mAtlasFixedScaleRadio_toggled(
bool checked )
760 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Atlas Mode" ) );
762 mMapItem->layout()->undoStack()->endCommand();
767void QgsLayoutMapWidget::mAtlasPredefinedScaleRadio_toggled(
bool checked )
774 if ( hasPredefinedScales() )
778 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Atlas Scales" ) );
780 mMapItem->layout()->undoStack()->endCommand();
788 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Atlas Mode" ) );
790 mMapItem->layout()->undoStack()->endCommand();
794void QgsLayoutMapWidget::mScaleLineEdit_editingFinished()
801 bool conversionSuccess =
false;
802 const double scaleDenominator = QLocale().toDouble( mScaleLineEdit->text(), &conversionSuccess );
803 if ( !conversionSuccess )
811 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Scale" ) );
812 mMapItem->setScale( scaleDenominator );
813 mMapItem->layout()->undoStack()->endCommand();
816void QgsLayoutMapWidget::rotationChanged(
double value )
824 mMapItem->setMapRotation( value );
825 mMapItem->layout()->undoStack()->endCommand();
826 mMapItem->invalidateCache();
829void QgsLayoutMapWidget::setToMapCanvasExtent()
836 QgsRectangle newExtent = mMapCanvas->mapSettings().visibleExtent();
839 if ( mMapCanvas->mapSettings().destinationCrs()
844 QgsCoordinateTransform xForm( mMapCanvas->mapSettings().destinationCrs(), mMapItem->crs(),
QgsProject::instance() );
845 xForm.setBallparkTransformsAreAppropriate(
true );
846 newExtent = xForm.transformBoundingBox( newExtent );
848 catch ( QgsCsException & )
855 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Extent" ) );
856 mMapItem->zoomToExtent( newExtent );
857 mMapItem->layout()->undoStack()->endCommand();
860void QgsLayoutMapWidget::setToMapCanvasScale()
867 const double newScale = mMapCanvas->
scale();
869 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Scale" ) );
870 mMapItem->setScale( newScale );
871 mMapItem->layout()->undoStack()->endCommand();
874void QgsLayoutMapWidget::viewExtentInCanvas()
881 const QgsRectangle currentMapExtent = mMapItem->extent();
883 if ( !currentMapExtent.
isEmpty() )
887 mMapCanvas->setReferencedExtent( QgsReferencedRectangle( currentMapExtent, mMapItem->crs() ) );
889 catch ( QgsCsException & )
894 mMapCanvas->refresh();
898void QgsLayoutMapWidget::viewScaleInCanvas()
905 const double currentScale = mMapItem->scale();
906 mMapCanvas->zoomScale( currentScale,
true );
909void QgsLayoutMapWidget::mXMinLineEdit_editingFinished()
911 updateComposerExtentFromGui();
914void QgsLayoutMapWidget::mXMaxLineEdit_editingFinished()
916 updateComposerExtentFromGui();
919void QgsLayoutMapWidget::mYMinLineEdit_editingFinished()
921 updateComposerExtentFromGui();
924void QgsLayoutMapWidget::mYMaxLineEdit_editingFinished()
926 updateComposerExtentFromGui();
929void QgsLayoutMapWidget::updateGuiElements()
936 blockAllSignals(
true );
937 mLabel->setText( mMapItem->displayName() );
939 whileBlocking( mCrsSelector )->setCrs( mMapItem->presetCrs() );
942 const double scale = mMapItem->scale();
945 if ( scale >= 10000 )
948 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 0 ) );
950 else if ( scale >= 10 )
952 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 3 ) );
954 else if ( scale >= 1 )
957 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 4 ) );
962 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 10 ) );
966 const QgsRectangle composerMapExtent = mMapItem->extent();
967 mXMinLineEdit->setText( QLocale().toString( composerMapExtent.
xMinimum(),
'f', 3 ) );
968 mXMaxLineEdit->setText( QLocale().toString( composerMapExtent.
xMaximum(),
'f', 3 ) );
969 mYMinLineEdit->setText( QLocale().toString( composerMapExtent.
yMinimum(),
'f', 3 ) );
970 mYMaxLineEdit->setText( QLocale().toString( composerMapExtent.
yMaximum(),
'f', 3 ) );
975 mFollowVisibilityPresetCheckBox->setCheckState(
976 mMapItem->followVisibilityPreset() ? Qt::Checked : Qt::Unchecked
978 const int presetModelIndex = mFollowVisibilityPresetCombo->findText( mMapItem->followVisibilityPresetName() );
979 mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 );
982 if ( mMapItem->keepLayerSet() )
984 mKeepLayerListCheckBox->setCheckState( Qt::Checked );
988 mKeepLayerListCheckBox->setCheckState( Qt::Unchecked );
991 mKeepLayerStylesCheckBox->setEnabled( mMapItem->keepLayerSet() );
992 mKeepLayerStylesCheckBox->setCheckState( mMapItem->keepLayerStyles() ? Qt::Checked : Qt::Unchecked );
995 if ( mMapItem->drawAnnotations() )
997 mDrawCanvasItemsCheckBox->setCheckState( Qt::Checked );
1001 mDrawCanvasItemsCheckBox->setCheckState( Qt::Unchecked );
1005 mAtlasCheckBox->setChecked( mMapItem->atlasDriven() );
1008 mAtlasFixedScaleRadio->setEnabled( mMapItem->atlasDriven() );
1011 mAtlasMarginRadio->setEnabled( mMapItem->atlasDriven() );
1013 mAtlasPredefinedScaleRadio->setEnabled( mMapItem->atlasDriven() );
1016 if ( mMapItem->atlasDriven() )
1018 toggleAtlasScalingOptionsByLayerType();
1021 if ( !hasPredefinedScales() )
1023 mAtlasPredefinedScaleRadio->setEnabled(
false );
1026 mTemporalCheckBox->setChecked( mMapItem->isTemporal() );
1027 mTemporalCheckBox->setCollapsed( !mMapItem->isTemporal() );
1028 mStartDateTime->setEnabled( mMapItem->isTemporal() );
1029 mEndDateTime->setEnabled( mMapItem->isTemporal() );
1030 if ( mMapItem->isTemporal() )
1032 mStartDateTime->setDateTime( mMapItem->temporalRange().begin() );
1033 mEndDateTime->setDateTime( mMapItem->temporalRange().end() );
1036 whileBlocking( mElevationRangeCheckBox )->setChecked( mMapItem->zRangeEnabled() );
1037 mElevationRangeCheckBox->setCollapsed( !mMapItem->zRangeEnabled() );
1038 if ( mMapItem->zRange().lower() != std::numeric_limits<double>::lowest() )
1039 whileBlocking( mZLowerSpin )->setValue( mMapItem->zRange().lower() );
1042 if ( mMapItem->zRange().upper() != std::numeric_limits<double>::max() )
1043 whileBlocking( mZUpperSpin )->setValue( mMapItem->zRange().upper() );
1049 loadOverviewEntries();
1051 blockAllSignals(
false );
1054void QgsLayoutMapWidget::toggleAtlasScalingOptionsByLayerType()
1072 mAtlasFixedScaleRadio->setChecked(
true );
1073 mAtlasMarginRadio->setEnabled(
false );
1078 mAtlasMarginRadio->setEnabled(
true );
1082void QgsLayoutMapWidget::updateComposerExtentFromGui()
1089 double xmin, ymin, xmax, ymax;
1090 bool conversionSuccess;
1092 xmin = QLocale().toDouble( mXMinLineEdit->text(), &conversionSuccess );
1093 if ( !conversionSuccess )
1095 xmax = QLocale().toDouble( mXMaxLineEdit->text(), &conversionSuccess );
1096 if ( !conversionSuccess )
1098 ymin = QLocale().toDouble( mYMinLineEdit->text(), &conversionSuccess );
1099 if ( !conversionSuccess )
1101 ymax = QLocale().toDouble( mYMaxLineEdit->text(), &conversionSuccess );
1102 if ( !conversionSuccess )
1105 const QgsRectangle newExtent( xmin, ymin, xmax, ymax );
1107 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Extent" ) );
1108 mMapItem->setExtent( newExtent );
1109 mMapItem->layout()->undoStack()->endCommand();
1112void QgsLayoutMapWidget::blockAllSignals(
bool b )
1114 mScaleLineEdit->blockSignals( b );
1115 mXMinLineEdit->blockSignals( b );
1116 mXMaxLineEdit->blockSignals( b );
1117 mYMinLineEdit->blockSignals( b );
1118 mYMaxLineEdit->blockSignals( b );
1119 mDrawCanvasItemsCheckBox->blockSignals( b );
1120 mOverviewFrameMapComboBox->blockSignals( b );
1121 mOverviewFrameStyleButton->blockSignals( b );
1122 mOverviewBlendModeComboBox->blockSignals( b );
1123 mOverviewInvertCheckbox->blockSignals( b );
1124 mOverviewCenterCheckbox->blockSignals( b );
1125 mAtlasCheckBox->blockSignals( b );
1126 mAtlasMarginSpinBox->blockSignals( b );
1127 mAtlasFixedScaleRadio->blockSignals( b );
1128 mAtlasMarginRadio->blockSignals( b );
1129 mFollowVisibilityPresetCheckBox->blockSignals( b );
1130 mFollowVisibilityPresetCombo->blockSignals( b );
1131 mKeepLayerListCheckBox->blockSignals( b );
1132 mKeepLayerStylesCheckBox->blockSignals( b );
1133 mActionSetToCanvasExtent->blockSignals( b );
1134 mActionUpdatePreview->blockSignals( b );
1135 mTemporalCheckBox->blockSignals( b );
1136 mStartDateTime->blockSignals( b );
1137 mEndDateTime->blockSignals( b );
1139 blockOverviewItemsSignals( b );
1142void QgsLayoutMapWidget::updatePreview()
1148 mMapItem->refresh();
1151void QgsLayoutMapWidget::mFollowVisibilityPresetCheckBox_stateChanged(
int state )
1158 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
1159 if ( state == Qt::Checked )
1161 mMapItem->setFollowVisibilityPreset(
true );
1164 mKeepLayerListCheckBox->setCheckState( Qt::Unchecked );
1165 mKeepLayerStylesCheckBox->setCheckState( Qt::Unchecked );
1167 mMapItem->invalidateCache();
1171 mMapItem->setFollowVisibilityPreset(
false );
1173 mMapItem->layout()->undoStack()->endCommand();
1176void QgsLayoutMapWidget::mKeepLayerListCheckBox_stateChanged(
int state )
1184 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Map Preset Changed" ) );
1185 storeCurrentLayerSet();
1186 mMapItem->setKeepLayerSet( state == Qt::Checked );
1187 if ( state == Qt::Unchecked )
1189 mMapItem->setLayers( QList<QgsMapLayer *>() );
1191 mMapItem->layout()->undoStack()->endCommand();
1194 if ( state == Qt::Checked )
1197 mFollowVisibilityPresetCheckBox->setCheckState( Qt::Unchecked );
1201 mKeepLayerStylesCheckBox->setChecked( Qt::Unchecked );
1202 mMapItem->invalidateCache();
1205 mKeepLayerStylesCheckBox->setEnabled( state == Qt::Checked );
1208void QgsLayoutMapWidget::mKeepLayerStylesCheckBox_stateChanged(
int state )
1215 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
1216 if ( state == Qt::Checked )
1218 mMapItem->storeCurrentLayerStyles();
1219 mMapItem->setKeepLayerStyles(
true );
1223 mMapItem->setLayerStyleOverrides( QMap<QString, QString>() );
1224 mMapItem->setKeepLayerStyles(
false );
1226 mMapItem->layout()->undoStack()->endCommand();
1229void QgsLayoutMapWidget::mDrawCanvasItemsCheckBox_stateChanged(
int state )
1236 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Toggle Map Item" ) );
1237 mMapItem->setDrawAnnotations( state == Qt::Checked );
1238 mMapItem->invalidateCache();
1239 mMapItem->layout()->undoStack()->endCommand();
1242void QgsLayoutMapWidget::atlasLayerChanged(
QgsVectorLayer *layer )
1247 mAtlasCheckBox->setChecked(
false );
1248 mAtlasCheckBox->setEnabled(
false );
1253 mAtlasCheckBox->setEnabled(
true );
1257 if ( mAtlasCheckBox->isChecked() )
1258 toggleAtlasScalingOptionsByLayerType();
1261bool QgsLayoutMapWidget::hasPredefinedScales()
const
1266 if ( !hasProjectScales || scales.isEmpty() )
1269 const QgsSettings settings;
1271 return !scales.isEmpty() && !scales[0].isEmpty();
1276void QgsLayoutMapWidget::mAddGridPushButton_clicked()
1283 const QString itemName = tr(
"Grid %1" ).arg( mMapItem->grids()->size() + 1 );
1284 QgsLayoutItemMapGrid *grid =
new QgsLayoutItemMapGrid( itemName, mMapItem );
1285 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Add Map Grid" ) );
1286 mMapItem->grids()->addGrid( grid );
1287 mMapItem->layout()->undoStack()->endCommand();
1288 mMapItem->updateBoundingRect();
1291 addGridListItem( grid->
id(), grid->
name() );
1292 mGridListWidget->setCurrentRow( 0 );
1293 mGridListWidget_currentItemChanged( mGridListWidget->currentItem(),
nullptr );
1296void QgsLayoutMapWidget::mRemoveGridPushButton_clicked()
1298 QListWidgetItem *item = mGridListWidget->currentItem();
1304 mMapItem->beginCommand( tr(
"Remove Grid" ) );
1305 mMapItem->grids()->removeGrid( item->data( Qt::UserRole ).toString() );
1306 QListWidgetItem *delItem = mGridListWidget->takeItem( mGridListWidget->row( item ) );
1308 mMapItem->endCommand();
1309 mMapItem->updateBoundingRect();
1313void QgsLayoutMapWidget::mCopyGridPushButton_clicked()
1315 QListWidgetItem *item = mGridListWidget->currentItem();
1321 QgsLayoutItemMapGrid *sourceGrid = mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
1327 QString itemName = tr(
"%1 - Copy" ).arg( sourceGrid->
name() );
1328 QList<QgsLayoutItemMapGrid *> grids = mMapItem->grids()->asList();
1331 const auto it = std::find_if( grids.begin(), grids.end(), [&itemName](
const QgsLayoutItemMapGrid *grd ) { return grd->name() == itemName; } );
1332 if ( it != grids.end() )
1335 itemName = tr(
"%1 - Copy %2" ).arg( sourceGrid->
name() ).arg( i );
1340 QgsLayoutItemMapGrid *grid =
new QgsLayoutItemMapGrid( itemName, mMapItem );
1343 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Duplicate Map Grid" ) );
1344 mMapItem->grids()->addGrid( grid );
1345 mMapItem->layout()->undoStack()->endCommand();
1346 mMapItem->updateBoundingRect();
1349 addGridListItem( grid->
id(), grid->
name() );
1350 mGridListWidget->setCurrentRow( 0 );
1351 mGridListWidget_currentItemChanged( mGridListWidget->currentItem(),
nullptr );
1354void QgsLayoutMapWidget::mGridUpButton_clicked()
1356 QListWidgetItem *item = mGridListWidget->currentItem();
1362 const int row = mGridListWidget->row( item );
1367 mGridListWidget->takeItem( row );
1368 mGridListWidget->insertItem( row - 1, item );
1369 mGridListWidget->setCurrentItem( item );
1370 mMapItem->beginCommand( tr(
"Move Grid Up" ) );
1371 mMapItem->grids()->moveGridUp( item->data( Qt::UserRole ).toString() );
1372 mMapItem->endCommand();
1376void QgsLayoutMapWidget::mGridDownButton_clicked()
1378 QListWidgetItem *item = mGridListWidget->currentItem();
1384 const int row = mGridListWidget->row( item );
1385 if ( mGridListWidget->count() <= row )
1389 mGridListWidget->takeItem( row );
1390 mGridListWidget->insertItem( row + 1, item );
1391 mGridListWidget->setCurrentItem( item );
1392 mMapItem->beginCommand( tr(
"Move Grid Down" ) );
1393 mMapItem->grids()->moveGridDown( item->data( Qt::UserRole ).toString() );
1394 mMapItem->endCommand();
1405 QListWidgetItem *item = mGridListWidget->currentItem();
1410 return mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
1413void QgsLayoutMapWidget::mGridListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem * )
1415 mGridPropertiesButton->
setEnabled(
static_cast<bool>( current ) );
1418void QgsLayoutMapWidget::mGridListWidget_itemChanged( QListWidgetItem *item )
1425 QgsLayoutItemMapGrid *grid = mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
1431 mMapItem->beginCommand( tr(
"Rename Grid" ) );
1432 grid->
setName( item->text() );
1433 mMapItem->endCommand();
1436void QgsLayoutMapWidget::mGridPropertiesButton_clicked()
1442 QgsLayoutItemMapGrid *grid = currentGrid();
1448 QgsLayoutMapGridWidget *w =
new QgsLayoutMapGridWidget( grid, mMapItem );
1453QListWidgetItem *QgsLayoutMapWidget::addGridListItem(
const QString &
id,
const QString &name )
1455 QListWidgetItem *item =
new QListWidgetItem( name,
nullptr );
1456 item->setData( Qt::UserRole,
id );
1457 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
1458 mGridListWidget->insertItem( 0, item );
1462void QgsLayoutMapWidget::loadGridEntries()
1465 QSet<QString> selectedIds;
1466 const QList<QListWidgetItem *> itemSelection = mGridListWidget->selectedItems();
1467 QList<QListWidgetItem *>::const_iterator sIt = itemSelection.constBegin();
1468 for ( ; sIt != itemSelection.constEnd(); ++sIt )
1470 selectedIds.insert( ( *sIt )->data( Qt::UserRole ).toString() );
1473 mGridListWidget->clear();
1479 const QList<QgsLayoutItemMapGrid *> grids = mMapItem->grids()->asList();
1480 QList<QgsLayoutItemMapGrid *>::const_iterator gridIt = grids.constBegin();
1481 for ( ; gridIt != grids.constEnd(); ++gridIt )
1483 QListWidgetItem *item = addGridListItem( ( *gridIt )->id(), ( *gridIt )->name() );
1484 if ( selectedIds.contains( ( *gridIt )->id() ) )
1486 item->setSelected(
true );
1487 mGridListWidget->setCurrentItem( item );
1491 if ( mGridListWidget->currentItem() )
1493 mGridListWidget_currentItemChanged( mGridListWidget->currentItem(),
nullptr );
1497 mGridListWidget_currentItemChanged(
nullptr,
nullptr );
1501void QgsLayoutMapWidget::mAddOverviewPushButton_clicked()
1508 const QString itemName = tr(
"Overview %1" ).arg( mMapItem->overviews()->size() + 1 );
1509 QgsLayoutItemMapOverview *overview =
new QgsLayoutItemMapOverview( itemName, mMapItem );
1510 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Add Map Overview" ) );
1511 mMapItem->overviews()->addOverview( overview );
1512 mMapItem->layout()->undoStack()->endCommand();
1513 mMapItem->invalidateCache();
1515 addOverviewListItem( overview->
id(), overview->
name() );
1517 mOverviewListWidget->setCurrentRow( 0 );
1520void QgsLayoutMapWidget::mRemoveOverviewPushButton_clicked()
1522 QListWidgetItem *item = mOverviewListWidget->currentItem();
1527 mMapItem->beginCommand( tr(
"Remove Map Overview" ) );
1528 mMapItem->overviews()->removeOverview( item->data( Qt::UserRole ).toString() );
1529 mMapItem->endCommand();
1530 QListWidgetItem *delItem = mOverviewListWidget->takeItem( mOverviewListWidget->row( item ) );
1532 mMapItem->invalidateCache();
1535void QgsLayoutMapWidget::mOverviewUpButton_clicked()
1537 QListWidgetItem *item = mOverviewListWidget->currentItem();
1543 const int row = mOverviewListWidget->row( item );
1548 mOverviewListWidget->takeItem( row );
1549 mOverviewListWidget->insertItem( row - 1, item );
1550 mOverviewListWidget->setCurrentItem( item );
1551 mMapItem->beginCommand( tr(
"Move Overview Up" ) );
1552 mMapItem->overviews()->moveOverviewUp( item->data( Qt::UserRole ).toString() );
1553 mMapItem->endCommand();
1554 mMapItem->invalidateCache();
1557void QgsLayoutMapWidget::mOverviewDownButton_clicked()
1559 QListWidgetItem *item = mOverviewListWidget->currentItem();
1565 const int row = mOverviewListWidget->row( item );
1566 if ( mOverviewListWidget->count() <= row )
1570 mOverviewListWidget->takeItem( row );
1571 mOverviewListWidget->insertItem( row + 1, item );
1572 mOverviewListWidget->setCurrentItem( item );
1573 mMapItem->beginCommand( tr(
"Move Overview Down" ) );
1574 mMapItem->overviews()->moveOverviewDown( item->data( Qt::UserRole ).toString() );
1575 mMapItem->endCommand();
1576 mMapItem->invalidateCache();
1586 QListWidgetItem *item = mOverviewListWidget->currentItem();
1592 return mMapItem->overviews()->overview( item->data( Qt::UserRole ).toString() );
1595void QgsLayoutMapWidget::mOverviewListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous )
1597 Q_UNUSED( previous )
1600 mOverviewCheckBox->setEnabled(
false );
1605 setOverviewItems( mMapItem->overviews()->overview( current->data( Qt::UserRole ).toString() ) );
1608void QgsLayoutMapWidget::mOverviewListWidget_itemChanged( QListWidgetItem *item )
1615 QgsLayoutItemMapOverview *overview = mMapItem->overviews()->overview( item->data( Qt::UserRole ).toString() );
1621 mMapItem->beginCommand( u
"Rename Overview"_s );
1622 overview->
setName( item->text() );
1623 mMapItem->endCommand();
1624 if ( item->isSelected() )
1627 mOverviewCheckBox->setTitle( tr(
"Draw \"%1\" overview" ).arg( overview->
name() ) );
1631void QgsLayoutMapWidget::setOverviewItemsEnabled(
bool enabled )
1633 mOverviewFrameMapLabel->setEnabled( enabled );
1634 mOverviewFrameMapComboBox->setEnabled( enabled );
1635 mOverviewFrameStyleLabel->setEnabled( enabled );
1636 mOverviewFrameStyleButton->setEnabled( enabled );
1637 mOverviewBlendModeLabel->setEnabled( enabled );
1638 mOverviewBlendModeComboBox->setEnabled( enabled );
1639 mOverviewInvertCheckbox->setEnabled( enabled );
1640 mOverviewCenterCheckbox->setEnabled( enabled );
1641 mOverviewPositionComboBox->setEnabled( enabled );
1647void QgsLayoutMapWidget::blockOverviewItemsSignals(
const bool block )
1649 mOverviewFrameMapComboBox->blockSignals( block );
1650 mOverviewFrameStyleButton->blockSignals( block );
1651 mOverviewBlendModeComboBox->blockSignals( block );
1652 mOverviewInvertCheckbox->blockSignals( block );
1653 mOverviewCenterCheckbox->blockSignals( block );
1654 mOverviewPositionComboBox->blockSignals( block );
1655 mOverviewStackingLayerComboBox->blockSignals( block );
1665 blockOverviewItemsSignals(
true );
1667 mOverviewCheckBox->setTitle( tr(
"Draw \"%1\" overview" ).arg( overview->
name() ) );
1668 mOverviewCheckBox->setChecked( overview->
enabled() );
1671 mOverviewFrameMapComboBox->setItem( overview->
linkedMap() );
1674 mOverviewBlendModeComboBox->setBlendMode( overview->
blendMode() );
1676 mOverviewInvertCheckbox->setChecked( overview->
inverted() );
1678 mOverviewCenterCheckbox->setChecked( overview->
centered() );
1680 mOverviewPositionComboBox->setCurrentIndex( mOverviewPositionComboBox->findData( overview->
stackingPosition() ) );
1681 mOverviewStackingLayerComboBox->setLayer( overview->
stackingLayer() );
1686 blockOverviewItemsSignals(
false );
1689void QgsLayoutMapWidget::storeCurrentLayerSet()
1694 QList<QgsMapLayer *> layers = mMapCanvas->mapSettings().layers();
1696 mMapItem->setLayers( layers );
1698 if ( mMapItem->keepLayerStyles() )
1701 mMapItem->storeCurrentLayerStyles();
1705QList<QgsMapLayer *> QgsLayoutMapWidget::orderedPresetVisibleLayers(
const QString &name )
const
1710 QList<QgsMapLayer *> lst;
1712 for ( QgsMapLayer *layer : constLayerOrder )
1714 if ( visibleIds.contains( layer->
id() ) )
1722QListWidgetItem *QgsLayoutMapWidget::addOverviewListItem(
const QString &
id,
const QString &name )
1724 QListWidgetItem *item =
new QListWidgetItem( name,
nullptr );
1725 item->setData( Qt::UserRole,
id );
1726 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
1727 mOverviewListWidget->insertItem( 0, item );
1731void QgsLayoutMapWidget::loadOverviewEntries()
1734 QSet<QString> selectedIds;
1735 const QList<QListWidgetItem *> itemSelection = mOverviewListWidget->selectedItems();
1736 QList<QListWidgetItem *>::const_iterator sIt = itemSelection.constBegin();
1737 for ( ; sIt != itemSelection.constEnd(); ++sIt )
1739 selectedIds.insert( ( *sIt )->data( Qt::UserRole ).toString() );
1742 mOverviewListWidget->clear();
1748 mOverviewFrameMapComboBox->setExceptedItemList( QList<QgsLayoutItem *>() << mMapItem );
1751 const QList<QgsLayoutItemMapOverview *> overviews = mMapItem->overviews()->asList();
1752 QList<QgsLayoutItemMapOverview *>::const_iterator overviewIt = overviews.constBegin();
1753 for ( ; overviewIt != overviews.constEnd(); ++overviewIt )
1755 QListWidgetItem *item = addOverviewListItem( ( *overviewIt )->id(), ( *overviewIt )->name() );
1756 if ( selectedIds.contains( ( *overviewIt )->id() ) )
1758 item->setSelected(
true );
1759 mOverviewListWidget->setCurrentItem( item );
1763 if ( mOverviewListWidget->currentItem() )
1765 mOverviewListWidget_currentItemChanged( mOverviewListWidget->currentItem(),
nullptr );
1769 mOverviewListWidget_currentItemChanged(
nullptr,
nullptr );
1773void QgsLayoutMapWidget::mOverviewCheckBox_toggled(
bool state )
1775 QgsLayoutItemMapOverview *overview = currentOverview();
1781 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Overview Display Toggled" ) );
1783 mMapItem->invalidateCache();
1784 mMapItem->layout()->undoStack()->endCommand();
1787void QgsLayoutMapWidget::overviewMapChanged(
QgsLayoutItem *item )
1789 QgsLayoutItemMapOverview *overview = currentOverview();
1795 QgsLayoutItemMap *map =
dynamic_cast<QgsLayoutItemMap *
>( item );
1799 mMapItem->beginCommand( tr(
"Change Overview Map" ) );
1801 mMapItem->invalidateCache();
1802 mMapItem->endCommand();
1805void QgsLayoutMapWidget::mOverviewBlendModeComboBox_currentIndexChanged(
int index )
1808 QgsLayoutItemMapOverview *overview = currentOverview();
1814 mMapItem->beginCommand( tr(
"Change Overview Blend Mode" ) );
1815 overview->
setBlendMode( mOverviewBlendModeComboBox->blendMode() );
1816 mMapItem->invalidateCache();
1817 mMapItem->endCommand();
1820void QgsLayoutMapWidget::mOverviewInvertCheckbox_toggled(
bool state )
1822 QgsLayoutItemMapOverview *overview = currentOverview();
1828 mMapItem->beginCommand( tr(
"Toggle Overview Inverted" ) );
1830 mMapItem->invalidateCache();
1831 mMapItem->endCommand();
1834void QgsLayoutMapWidget::mOverviewCenterCheckbox_toggled(
bool state )
1836 QgsLayoutItemMapOverview *overview = currentOverview();
1842 mMapItem->beginCommand( tr(
"Toggle Overview Centered" ) );
1844 mMapItem->invalidateCache();
1845 mMapItem->endCommand();
1848void QgsLayoutMapWidget::overviewStackingChanged(
int )
1850 QgsLayoutItemMapOverview *overview = currentOverview();
1856 mMapItem->beginCommand( tr(
"Change Overview Position" ) );
1858 mMapItem->invalidateCache();
1859 mMapItem->endCommand();
1866 mOverviewStackingLayerComboBox->setEnabled(
false );
1871 mOverviewStackingLayerComboBox->setEnabled(
true );
1876void QgsLayoutMapWidget::overviewStackingLayerChanged(
QgsMapLayer *layer )
1878 QgsLayoutItemMapOverview *overview = currentOverview();
1884 mMapItem->beginCommand( tr(
"Change Overview Position" ) );
1886 mMapItem->invalidateCache();
1887 mMapItem->endCommand();
1901 mLabelBoundarySpinBox->setClearValue( 0 );
1902 mLabelBoundarySpinBox->setShowClearButton(
true );
1904 mLabelBoundaryUnitsCombo->linkToWidget( mLabelBoundarySpinBox );
1905 mLabelBoundaryUnitsCombo->setConverter( &mMapItem->layout()->renderContext().measurementConverter() );
1908 connect( mLabelBoundarySpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapLabelingWidget::labelMarginChanged );
1909 connect( mShowPartialLabelsCheckBox, &QCheckBox::toggled,
this, &QgsLayoutMapLabelingWidget::showPartialsToggled );
1910 connect( mShowUnplacedCheckBox, &QCheckBox::toggled,
this, &QgsLayoutMapLabelingWidget::showUnplacedToggled );
1927 mMapItem = qobject_cast<QgsLayoutItemMap *>( item );
1934 updateGuiElements();
1939void QgsLayoutMapLabelingWidget::updateGuiElements()
1941 whileBlocking( mLabelBoundarySpinBox )->setValue( mMapItem->labelMargin().length() );
1942 whileBlocking( mLabelBoundaryUnitsCombo )->setUnit( mMapItem->labelMargin().units() );
1946 if ( mBlockingItemsListView->model() )
1948 QAbstractItemModel *oldModel = mBlockingItemsListView->model();
1949 mBlockingItemsListView->setModel(
nullptr );
1950 oldModel->deleteLater();
1953 QgsLayoutMapItemBlocksLabelsModel *model =
new QgsLayoutMapItemBlocksLabelsModel( mMapItem, mMapItem->layout()->itemsModel(), mBlockingItemsListView );
1954 mBlockingItemsListView->setModel( model );
1959void QgsLayoutMapLabelingWidget::labelMarginChanged(
double val )
1965 mMapItem->setLabelMargin( QgsLayoutMeasurement( val, mLabelBoundaryUnitsCombo->unit() ) );
1966 mMapItem->layout()->undoStack()->endCommand();
1967 mMapItem->invalidateCache();
1970void QgsLayoutMapLabelingWidget::labelMarginUnitsChanged()
1976 mMapItem->setLabelMargin( QgsLayoutMeasurement( mLabelBoundarySpinBox->value(), mLabelBoundaryUnitsCombo->unit() ) );
1977 mMapItem->layout()->undoStack()->endCommand();
1978 mMapItem->invalidateCache();
1981void QgsLayoutMapLabelingWidget::showPartialsToggled(
bool checked )
1986 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Label Visibility" ) );
1991 flags &= ~QgsLayoutItemMap::ShowPartialLabels;
1992 mMapItem->setMapFlags( flags );
1993 mMapItem->layout()->undoStack()->endCommand();
1994 mMapItem->invalidateCache();
1997void QgsLayoutMapLabelingWidget::showUnplacedToggled(
bool checked )
2002 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Label Visibility" ) );
2007 flags &= ~QgsLayoutItemMap::ShowUnplacedLabels;
2008 mMapItem->setMapFlags( flags );
2009 mMapItem->layout()->undoStack()->endCommand();
2010 mMapItem->invalidateCache();
2014 : QSortFilterProxyModel( parent )
2015 , mLayoutModel( layoutModel )
2018 setSourceModel( layoutModel );
2031 if ( i.column() != 0 )
2036 QgsLayoutItem *item = mLayoutModel->itemFromIndex( mapToSource( i ) );
2044 case Qt::CheckStateRole:
2045 switch ( i.column() )
2048 return mMapItem ? ( mMapItem->isLabelBlockingItem( item ) ? Qt::Checked : Qt::Unchecked ) : Qt::Unchecked;
2054 return mLayoutModel->data( sourceIndex, role );
2062 if ( !index.isValid() )
2065 QgsLayoutItem *item = mLayoutModel->itemFromIndex( mapToSource( index ) );
2066 if ( !item || !mMapItem )
2073 if ( value.toBool() )
2075 mMapItem->addLabelBlockingItem( item );
2079 mMapItem->removeLabelBlockingItem( item );
2081 emit dataChanged( index, index, QVector<int>() << role );
2083 mMapItem->layout()->undoStack()->endCommand();
2084 mMapItem->invalidateCache();
2091 Qt::ItemFlags
flags = QSortFilterProxyModel::flags( index );
2093 if ( !index.isValid() )
2098 switch ( index.column() )
2101 return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
2103 return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
2109 QgsLayoutItem *item = mLayoutModel->itemFromIndex( mLayoutModel->index( source_row, 0, source_parent ) );
2110 if ( !item || item == mMapItem )
2131 mLayerModel->setItemsCheckable(
true );
2132 mLayersTreeView->setModel( mLayerModel );
2138 for (
int i = 0; i < mAtlasClippingTypeComboBox->count(); ++i )
2140 mItemClippingTypeComboBox->addItem( mAtlasClippingTypeComboBox->itemText( i ), mAtlasClippingTypeComboBox->itemData( i ) );
2143 mClipItemComboBox->setCurrentLayout( map->
layout() );
2146 connect( mRadioClipSelectedLayers, &QRadioButton::toggled,
this, &QgsLayoutMapClippingWidget::toggleLayersSelectionGui );
2147 mLayersTreeView->setEnabled(
false );
2148 mSelectAllButton->setEnabled(
false );
2149 mDeselectAllButton->setEnabled(
false );
2150 mInvertSelectionButton->setEnabled(
false );
2151 mRadioClipAllLayers->setChecked(
true );
2153 connect( mClipToAtlasCheckBox, &QGroupBox::toggled,
this, [
this](
bool active ) {
2154 if ( !mBlockUpdates )
2156 mMapItem->beginCommand( tr(
"Toggle Atlas Clipping" ) );
2157 mMapItem->atlasClippingSettings()->setEnabled( active );
2158 mMapItem->endCommand();
2161 connect( mForceLabelsInsideCheckBox, &QCheckBox::toggled,
this, [
this](
bool active ) {
2162 if ( !mBlockUpdates )
2164 mMapItem->beginCommand( tr(
"Change Atlas Clipping Label Behavior" ) );
2165 mMapItem->atlasClippingSettings()->setForceLabelsInsideFeature( active );
2166 mMapItem->endCommand();
2169 connect( mClipFrameCheckBox, &QCheckBox::toggled,
this, [
this](
bool active ) {
2170 if ( !mBlockUpdates )
2172 mMapItem->beginCommand( tr(
"Change Atlas Clipping Label Behavior" ) );
2173 mMapItem->atlasClippingSettings()->setClipItemShape( active );
2174 mMapItem->endCommand();
2177 connect( mAtlasClippingTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
2178 if ( !mBlockUpdates )
2180 mMapItem->beginCommand( tr(
"Change Atlas Clipping Behavior" ) );
2182 mMapItem->endCommand();
2186 connect( mRadioClipSelectedLayers, &QCheckBox::toggled,
this, [
this](
bool active ) {
2187 if ( active && !mBlockUpdates )
2189 mBlockUpdates =
true;
2190 mMapItem->beginCommand( tr(
"Change Atlas Clipping Layers" ) );
2191 mMapItem->atlasClippingSettings()->setRestrictToLayers(
true );
2192 mMapItem->endCommand();
2193 mBlockUpdates =
false;
2197 connect( mSelectAllButton, &QPushButton::clicked,
this, &QgsLayoutMapClippingWidget::selectAll );
2198 connect( mDeselectAllButton, &QPushButton::clicked,
this, &QgsLayoutMapClippingWidget::deselectAll );
2199 connect( mInvertSelectionButton, &QPushButton::clicked,
this, &QgsLayoutMapClippingWidget::invertSelection );
2201 connect( mRadioClipAllLayers, &QCheckBox::toggled,
this, [
this](
bool active ) {
2202 if ( active && !mBlockUpdates )
2204 mBlockUpdates =
true;
2205 mMapItem->beginCommand( tr(
"Change Atlas Clipping Layers" ) );
2206 mMapItem->atlasClippingSettings()->setRestrictToLayers(
false );
2207 mMapItem->endCommand();
2208 mBlockUpdates =
false;
2211 connect( mLayerModel, &QgsMapLayerModel::dataChanged,
this, [
this](
const QModelIndex &,
const QModelIndex &,
const QVector<int> &roles = QVector<int>() ) {
2212 if ( !roles.contains( Qt::CheckStateRole ) )
2215 if ( !mBlockUpdates )
2217 mBlockUpdates =
true;
2218 mMapItem->beginCommand( tr(
"Change Atlas Clipping Layers" ) );
2219 mMapItem->atlasClippingSettings()->setLayersToClip( mLayerModel->layersChecked() );
2220 mMapItem->endCommand();
2221 mBlockUpdates =
false;
2227 connect( mClipToItemCheckBox, &QGroupBox::toggled,
this, [
this](
bool active ) {
2228 if ( !mBlockUpdates )
2230 mMapItem->beginCommand( tr(
"Toggle Map Clipping" ) );
2231 mMapItem->itemClippingSettings()->setEnabled( active );
2232 mMapItem->endCommand();
2235 connect( mItemClippingTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
2236 if ( !mBlockUpdates )
2238 mMapItem->beginCommand( tr(
"Change Map Clipping Behavior" ) );
2240 mMapItem->endCommand();
2243 connect( mForceLabelsInsideItemCheckBox, &QCheckBox::toggled,
this, [
this](
bool active ) {
2244 if ( !mBlockUpdates )
2246 mMapItem->beginCommand( tr(
"Change Map Clipping Label Behavior" ) );
2247 mMapItem->itemClippingSettings()->setForceLabelsInsideClipPath( active );
2248 mMapItem->endCommand();
2252 if ( !mBlockUpdates )
2254 mMapItem->beginCommand( tr(
"Change Map Clipping Item" ) );
2255 mMapItem->itemClippingSettings()->setSourceItem( item );
2256 mMapItem->endCommand();
2266 atlasToggled( atlas->enabled() );
2272 mClipToAtlasCheckBox->setTitle( tr(
"Clip to %1 feature" ).arg(
string ) );
2273 mClipToAtlasLabel->setText( tr(
"<b>When enabled, map layers will be automatically clipped to the boundary of the current %1 feature.</b>" ).arg(
string ) );
2274 mForceLabelsInsideCheckBox->setText( tr(
"Force labels inside %1 feature" ).arg(
string ) );
2275 mClipFrameCheckBox->setText( tr(
"Clip item frame to match %1 feature" ).arg(
string ) );
2288 mMapItem = qobject_cast<QgsLayoutItemMap *>( item );
2295 updateGuiElements();
2300void QgsLayoutMapClippingWidget::updateGuiElements()
2302 if ( mBlockUpdates )
2305 mBlockUpdates =
true;
2306 mClipToAtlasCheckBox->setChecked( mMapItem->atlasClippingSettings()->enabled() );
2307 mAtlasClippingTypeComboBox->setCurrentIndex( mAtlasClippingTypeComboBox->findData(
static_cast<int>( mMapItem->atlasClippingSettings()->featureClippingType() ) ) );
2308 mForceLabelsInsideCheckBox->setChecked( mMapItem->atlasClippingSettings()->forceLabelsInsideFeature() );
2309 mClipFrameCheckBox->setChecked( mMapItem->atlasClippingSettings()->clipItemShape() );
2311 mRadioClipAllLayers->setChecked( !mMapItem->atlasClippingSettings()->restrictToLayers() );
2312 mRadioClipSelectedLayers->setChecked( mMapItem->atlasClippingSettings()->restrictToLayers() );
2313 mLayerModel->
setLayersChecked( mMapItem->atlasClippingSettings()->layersToClip() );
2315 mClipToItemCheckBox->setChecked( mMapItem->itemClippingSettings()->enabled() );
2316 mItemClippingTypeComboBox->setCurrentIndex( mItemClippingTypeComboBox->findData(
static_cast<int>( mMapItem->itemClippingSettings()->featureClippingType() ) ) );
2317 mForceLabelsInsideItemCheckBox->setChecked( mMapItem->itemClippingSettings()->forceLabelsInsideClipPath() );
2318 mClipItemComboBox->setItem( mMapItem->itemClippingSettings()->sourceItem() );
2320 mBlockUpdates =
false;
2323void QgsLayoutMapClippingWidget::atlasLayerChanged(
QgsVectorLayer *layer )
2328 mClipToAtlasCheckBox->setChecked(
false );
2329 mClipToAtlasCheckBox->setEnabled(
false );
2334 mClipToAtlasCheckBox->setEnabled(
true );
2338void QgsLayoutMapClippingWidget::atlasToggled(
bool atlasEnabled )
2340 if ( atlasEnabled && mMapItem && mMapItem->layout() && mMapItem->layout()->reportContext().layer()
2343 mClipToAtlasCheckBox->setEnabled(
true );
2347 mClipToAtlasCheckBox->setEnabled(
false );
2348 mClipToAtlasCheckBox->setChecked(
false );
2352void QgsLayoutMapClippingWidget::invertSelection()
2354 for (
int i = 0; i < mLayerModel->rowCount( QModelIndex() ); i++ )
2356 QModelIndex index = mLayerModel->index( i, 0 );
2357 Qt::CheckState currentState = Qt::CheckState( mLayerModel->data( index, Qt::CheckStateRole ).toInt() );
2358 Qt::CheckState newState = ( currentState == Qt::Checked ) ? Qt::Unchecked : Qt::Checked;
2359 mLayerModel->setData( index, newState, Qt::CheckStateRole );
2363void QgsLayoutMapClippingWidget::selectAll()
2365 for (
int i = 0; i < mLayerModel->rowCount( QModelIndex() ); i++ )
2367 QModelIndex index = mLayerModel->index( i, 0 );
2368 mLayerModel->setData( index, Qt::Checked, Qt::CheckStateRole );
2372void QgsLayoutMapClippingWidget::deselectAll()
2374 for (
int i = 0; i < mLayerModel->rowCount( QModelIndex() ); i++ )
2376 QModelIndex index = mLayerModel->index( i, 0 );
2377 mLayerModel->setData( index, Qt::Unchecked, Qt::CheckStateRole );
2381void QgsLayoutMapClippingWidget::toggleLayersSelectionGui(
bool toggled )
2383 mLayersTreeView->setEnabled( toggled );
2384 mSelectAllButton->setEnabled( toggled );
2385 mDeselectAllButton->setEnabled( toggled );
2386 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.