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() && mMapItem->layout()->reportContext().layer()->wkbType() !=
Qgis::WkbType::NoGeometry )
306 mAtlasCheckBox->setEnabled(
true );
310 mAtlasCheckBox->setEnabled(
false );
311 mAtlasCheckBox->setChecked(
false );
315void QgsLayoutMapWidget::aboutToShowKeepLayersVisibilityPresetsMenu()
320 QMenu *menu = qobject_cast<QMenu *>( sender() );
326 for (
const QString &presetName : constMapThemes )
328 menu->addAction( presetName,
this, &QgsLayoutMapWidget::keepLayersVisibilityPresetSelected );
331 if ( menu->actions().isEmpty() )
332 menu->addAction( tr(
"No presets defined" ) )->setEnabled(
false );
335void QgsLayoutMapWidget::followVisibilityPresetSelected(
int currentIndex )
340 if ( mBlockThemeComboChanges != 0 )
343 if ( currentIndex == -1 )
347 if ( currentIndex != 0 )
349 presetName = mFollowVisibilityPresetCombo->currentText();
352 if ( presetName == mMapItem->followVisibilityPresetName() )
355 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
356 mFollowVisibilityPresetCheckBox->setChecked(
true );
357 mMapItem->setFollowVisibilityPresetName( presetName );
358 mMapItem->layout()->undoStack()->endCommand();
360 mMapItem->invalidateCache();
363void QgsLayoutMapWidget::keepLayersVisibilityPresetSelected()
365 QAction *action = qobject_cast<QAction *>( sender() );
369 const QString presetName = action->text();
370 const QList<QgsMapLayer *> lst = orderedPresetVisibleLayers( presetName );
373 mKeepLayerListCheckBox->setChecked(
true );
374 mMapItem->setLayers( lst );
376 mKeepLayerStylesCheckBox->setChecked(
true );
378 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
379 mMapItem->setLayerStyleOverrides(
QgsProject::instance()->mapThemeCollection()->mapThemeStyleOverrides( presetName ) );
380 mMapItem->layout()->undoStack()->endCommand();
382 mMapItem->invalidateCache();
386void QgsLayoutMapWidget::onMapThemesChanged()
388 if ( QStringListModel *model = qobject_cast<QStringListModel *>( mFollowVisibilityPresetCombo->model() ) )
390 mBlockThemeComboChanges++;
392 lst.append( tr(
"(none)" ) );
394 model->setStringList( lst );
397 const int presetModelIndex = mFollowVisibilityPresetCombo->findText( mMapItem->followVisibilityPresetName() );
398 mFollowVisibilityPresetCombo->blockSignals(
true );
399 mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 );
400 mFollowVisibilityPresetCombo->blockSignals(
false );
401 mBlockThemeComboChanges--;
412 if ( mMapItem->presetCrs() == crs )
416 const QgsCoordinateReferenceSystem oldCrs = mMapItem->crs();
418 bool updateExtent =
false;
419 QgsRectangle newExtent;
423 xForm.setBallparkTransformsAreAppropriate(
true );
424 const QgsRectangle prevExtent = mMapItem->extent();
425 newExtent = xForm.transformBoundingBox( prevExtent );
428 catch ( QgsCsException & )
433 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map CRS" ) );
434 mMapItem->setCrs( crs );
436 mMapItem->zoomToExtent( newExtent );
437 mMapItem->layout()->undoStack()->endCommand();
438 mMapItem->invalidateCache();
441void QgsLayoutMapWidget::overviewSymbolChanged()
443 QgsLayoutItemMapOverview *overview = currentOverview();
448 overview->
setFrameSymbol( mOverviewFrameStyleButton->clonedSymbol<QgsFillSymbol>() );
449 mMapItem->endCommand();
450 mMapItem->invalidateCache();
453void QgsLayoutMapWidget::showLabelSettings()
455 mLabelWidget =
new QgsLayoutMapLabelingWidget( mMapItem );
457 if ( !mReportTypeString.isEmpty() )
458 mLabelWidget->setReportTypeString( mReportTypeString );
463void QgsLayoutMapWidget::showClipSettings()
465 mClipWidget =
new QgsLayoutMapClippingWidget( mMapItem );
466 if ( !mReportTypeString.isEmpty() )
467 mClipWidget->setReportTypeString( mReportTypeString );
471void QgsLayoutMapWidget::switchToMoveContentTool()
477void QgsLayoutMapWidget::aboutToShowLayersMenu()
479 mLayersMenu->clear();
481 if ( !mMapLayerModel )
483 mMapLayerModel =
new QgsMapLayerProxyModel(
this );
487 if ( mMapLayerModel->rowCount() == 0 )
489 QAction *action =
new QAction( tr(
"No spatial layers available" ) );
490 action->setEnabled(
false );
491 mLayersMenu->addAction( action );
495 for (
int i = 0; i < mMapLayerModel->rowCount(); ++i )
497 const QModelIndex index = mMapLayerModel->index( i, 0 );
498 const QIcon icon = qvariant_cast<QIcon>( mMapLayerModel->data( index, Qt::DecorationRole ) );
499 const QString text = mMapLayerModel->data( index, Qt::DisplayRole ).toString();
500 const QString tooltip = mMapLayerModel->data( index, Qt::ToolTipRole ).toString();
503 QAction *action =
new QAction( icon, text, mLayersMenu );
504 action->setToolTip( tooltip );
505 connect( action, &QAction::triggered,
this, [
this, layerId] {
508 setToCustomExtent( QgsReferencedRectangle( layer->extent(), layer->crs() ) );
511 mLayersMenu->addAction( action );
515void QgsLayoutMapWidget::aboutToShowBookmarkMenu()
517 mBookmarkMenu->clear();
521 if ( !mBookmarkModel )
526 if ( mBookmarkModel->rowCount() == 0 )
528 QAction *action =
new QAction( tr(
"No bookmarks available" ) );
529 action->setEnabled(
false );
530 mBookmarkMenu->addAction( action );
534 QMap<QString, QMenu *> groupMenus;
535 for (
int i = 0; i < mBookmarkModel->rowCount(); ++i )
538 QMenu *destMenu = mBookmarkMenu;
539 if ( !group.isEmpty() )
541 destMenu = groupMenus.value( group );
544 destMenu =
new QMenu( group, mBookmarkMenu );
545 groupMenus[group] = destMenu;
550 connect( action, &QAction::triggered,
this, [
this, extent] { 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() != mMapItem->crs() )
840 QgsCoordinateTransform xForm( mMapCanvas->mapSettings().destinationCrs(), mMapItem->crs(),
QgsProject::instance() );
841 xForm.setBallparkTransformsAreAppropriate(
true );
842 newExtent = xForm.transformBoundingBox( newExtent );
844 catch ( QgsCsException & )
851 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Extent" ) );
852 mMapItem->zoomToExtent( newExtent );
853 mMapItem->layout()->undoStack()->endCommand();
856void QgsLayoutMapWidget::setToMapCanvasScale()
863 const double newScale = mMapCanvas->
scale();
865 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Scale" ) );
866 mMapItem->setScale( newScale );
867 mMapItem->layout()->undoStack()->endCommand();
870void QgsLayoutMapWidget::viewExtentInCanvas()
877 const QgsRectangle currentMapExtent = mMapItem->extent();
879 if ( !currentMapExtent.
isEmpty() )
883 mMapCanvas->setReferencedExtent( QgsReferencedRectangle( currentMapExtent, mMapItem->crs() ) );
885 catch ( QgsCsException & )
890 mMapCanvas->refresh();
894void QgsLayoutMapWidget::viewScaleInCanvas()
901 const double currentScale = mMapItem->scale();
902 mMapCanvas->zoomScale( currentScale,
true );
905void QgsLayoutMapWidget::mXMinLineEdit_editingFinished()
907 updateComposerExtentFromGui();
910void QgsLayoutMapWidget::mXMaxLineEdit_editingFinished()
912 updateComposerExtentFromGui();
915void QgsLayoutMapWidget::mYMinLineEdit_editingFinished()
917 updateComposerExtentFromGui();
920void QgsLayoutMapWidget::mYMaxLineEdit_editingFinished()
922 updateComposerExtentFromGui();
925void QgsLayoutMapWidget::updateGuiElements()
932 blockAllSignals(
true );
933 mLabel->setText( mMapItem->displayName() );
935 whileBlocking( mCrsSelector )->setCrs( mMapItem->presetCrs() );
938 const double scale = mMapItem->scale();
941 if ( scale >= 10000 )
944 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 0 ) );
946 else if ( scale >= 10 )
948 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 3 ) );
950 else if ( scale >= 1 )
953 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 4 ) );
958 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 10 ) );
962 const QgsRectangle composerMapExtent = mMapItem->extent();
963 mXMinLineEdit->setText( QLocale().toString( composerMapExtent.
xMinimum(),
'f', 3 ) );
964 mXMaxLineEdit->setText( QLocale().toString( composerMapExtent.
xMaximum(),
'f', 3 ) );
965 mYMinLineEdit->setText( QLocale().toString( composerMapExtent.
yMinimum(),
'f', 3 ) );
966 mYMaxLineEdit->setText( QLocale().toString( composerMapExtent.
yMaximum(),
'f', 3 ) );
971 mFollowVisibilityPresetCheckBox->setCheckState( mMapItem->followVisibilityPreset() ? Qt::Checked : Qt::Unchecked );
972 const int presetModelIndex = mFollowVisibilityPresetCombo->findText( mMapItem->followVisibilityPresetName() );
973 mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 );
976 if ( mMapItem->keepLayerSet() )
978 mKeepLayerListCheckBox->setCheckState( Qt::Checked );
982 mKeepLayerListCheckBox->setCheckState( Qt::Unchecked );
985 mKeepLayerStylesCheckBox->setEnabled( mMapItem->keepLayerSet() );
986 mKeepLayerStylesCheckBox->setCheckState( mMapItem->keepLayerStyles() ? Qt::Checked : Qt::Unchecked );
989 if ( mMapItem->drawAnnotations() )
991 mDrawCanvasItemsCheckBox->setCheckState( Qt::Checked );
995 mDrawCanvasItemsCheckBox->setCheckState( Qt::Unchecked );
999 mAtlasCheckBox->setChecked( mMapItem->atlasDriven() );
1002 mAtlasFixedScaleRadio->setEnabled( mMapItem->atlasDriven() );
1005 mAtlasMarginRadio->setEnabled( mMapItem->atlasDriven() );
1007 mAtlasPredefinedScaleRadio->setEnabled( mMapItem->atlasDriven() );
1010 if ( mMapItem->atlasDriven() )
1012 toggleAtlasScalingOptionsByLayerType();
1015 if ( !hasPredefinedScales() )
1017 mAtlasPredefinedScaleRadio->setEnabled(
false );
1020 mTemporalCheckBox->setChecked( mMapItem->isTemporal() );
1021 mTemporalCheckBox->setCollapsed( !mMapItem->isTemporal() );
1022 mStartDateTime->setEnabled( mMapItem->isTemporal() );
1023 mEndDateTime->setEnabled( mMapItem->isTemporal() );
1024 if ( mMapItem->isTemporal() )
1026 mStartDateTime->setDateTime( mMapItem->temporalRange().begin() );
1027 mEndDateTime->setDateTime( mMapItem->temporalRange().end() );
1030 whileBlocking( mElevationRangeCheckBox )->setChecked( mMapItem->zRangeEnabled() );
1031 mElevationRangeCheckBox->setCollapsed( !mMapItem->zRangeEnabled() );
1032 if ( mMapItem->zRange().lower() != std::numeric_limits<double>::lowest() )
1033 whileBlocking( mZLowerSpin )->setValue( mMapItem->zRange().lower() );
1036 if ( mMapItem->zRange().upper() != std::numeric_limits<double>::max() )
1037 whileBlocking( mZUpperSpin )->setValue( mMapItem->zRange().upper() );
1043 loadOverviewEntries();
1045 blockAllSignals(
false );
1048void QgsLayoutMapWidget::toggleAtlasScalingOptionsByLayerType()
1066 mAtlasFixedScaleRadio->setChecked(
true );
1067 mAtlasMarginRadio->setEnabled(
false );
1072 mAtlasMarginRadio->setEnabled(
true );
1076void QgsLayoutMapWidget::updateComposerExtentFromGui()
1083 double xmin, ymin, xmax, ymax;
1084 bool conversionSuccess;
1086 xmin = QLocale().toDouble( mXMinLineEdit->text(), &conversionSuccess );
1087 if ( !conversionSuccess )
1089 xmax = QLocale().toDouble( mXMaxLineEdit->text(), &conversionSuccess );
1090 if ( !conversionSuccess )
1092 ymin = QLocale().toDouble( mYMinLineEdit->text(), &conversionSuccess );
1093 if ( !conversionSuccess )
1095 ymax = QLocale().toDouble( mYMaxLineEdit->text(), &conversionSuccess );
1096 if ( !conversionSuccess )
1099 const QgsRectangle newExtent( xmin, ymin, xmax, ymax );
1101 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Extent" ) );
1102 mMapItem->setExtent( newExtent );
1103 mMapItem->layout()->undoStack()->endCommand();
1106void QgsLayoutMapWidget::blockAllSignals(
bool b )
1108 mScaleLineEdit->blockSignals( b );
1109 mXMinLineEdit->blockSignals( b );
1110 mXMaxLineEdit->blockSignals( b );
1111 mYMinLineEdit->blockSignals( b );
1112 mYMaxLineEdit->blockSignals( b );
1113 mDrawCanvasItemsCheckBox->blockSignals( b );
1114 mOverviewFrameMapComboBox->blockSignals( b );
1115 mOverviewFrameStyleButton->blockSignals( b );
1116 mOverviewBlendModeComboBox->blockSignals( b );
1117 mOverviewInvertCheckbox->blockSignals( b );
1118 mOverviewCenterCheckbox->blockSignals( b );
1119 mAtlasCheckBox->blockSignals( b );
1120 mAtlasMarginSpinBox->blockSignals( b );
1121 mAtlasFixedScaleRadio->blockSignals( b );
1122 mAtlasMarginRadio->blockSignals( b );
1123 mFollowVisibilityPresetCheckBox->blockSignals( b );
1124 mFollowVisibilityPresetCombo->blockSignals( b );
1125 mKeepLayerListCheckBox->blockSignals( b );
1126 mKeepLayerStylesCheckBox->blockSignals( b );
1127 mActionSetToCanvasExtent->blockSignals( b );
1128 mActionUpdatePreview->blockSignals( b );
1129 mTemporalCheckBox->blockSignals( b );
1130 mStartDateTime->blockSignals( b );
1131 mEndDateTime->blockSignals( b );
1133 blockOverviewItemsSignals( b );
1136void QgsLayoutMapWidget::updatePreview()
1142 mMapItem->refresh();
1145void QgsLayoutMapWidget::mFollowVisibilityPresetCheckBox_stateChanged(
int state )
1152 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
1153 if ( state == Qt::Checked )
1155 mMapItem->setFollowVisibilityPreset(
true );
1158 mKeepLayerListCheckBox->setCheckState( Qt::Unchecked );
1159 mKeepLayerStylesCheckBox->setCheckState( Qt::Unchecked );
1161 mMapItem->invalidateCache();
1165 mMapItem->setFollowVisibilityPreset(
false );
1167 mMapItem->layout()->undoStack()->endCommand();
1170void QgsLayoutMapWidget::mKeepLayerListCheckBox_stateChanged(
int state )
1178 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Map Preset Changed" ) );
1179 storeCurrentLayerSet();
1180 mMapItem->setKeepLayerSet( state == Qt::Checked );
1181 if ( state == Qt::Unchecked )
1183 mMapItem->setLayers( QList<QgsMapLayer *>() );
1185 mMapItem->layout()->undoStack()->endCommand();
1188 if ( state == Qt::Checked )
1191 mFollowVisibilityPresetCheckBox->setCheckState( Qt::Unchecked );
1195 mKeepLayerStylesCheckBox->setChecked( Qt::Unchecked );
1196 mMapItem->invalidateCache();
1199 mKeepLayerStylesCheckBox->setEnabled( state == Qt::Checked );
1202void QgsLayoutMapWidget::mKeepLayerStylesCheckBox_stateChanged(
int state )
1209 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
1210 if ( state == Qt::Checked )
1212 mMapItem->storeCurrentLayerStyles();
1213 mMapItem->setKeepLayerStyles(
true );
1217 mMapItem->setLayerStyleOverrides( QMap<QString, QString>() );
1218 mMapItem->setKeepLayerStyles(
false );
1220 mMapItem->layout()->undoStack()->endCommand();
1223void QgsLayoutMapWidget::mDrawCanvasItemsCheckBox_stateChanged(
int state )
1230 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Toggle Map Item" ) );
1231 mMapItem->setDrawAnnotations( state == Qt::Checked );
1232 mMapItem->invalidateCache();
1233 mMapItem->layout()->undoStack()->endCommand();
1236void QgsLayoutMapWidget::atlasLayerChanged(
QgsVectorLayer *layer )
1241 mAtlasCheckBox->setChecked(
false );
1242 mAtlasCheckBox->setEnabled(
false );
1247 mAtlasCheckBox->setEnabled(
true );
1251 if ( mAtlasCheckBox->isChecked() )
1252 toggleAtlasScalingOptionsByLayerType();
1255bool QgsLayoutMapWidget::hasPredefinedScales()
const
1260 if ( !hasProjectScales || scales.isEmpty() )
1263 const QgsSettings settings;
1265 return !scales.isEmpty() && !scales[0].isEmpty();
1270void QgsLayoutMapWidget::mAddGridPushButton_clicked()
1277 const QString itemName = tr(
"Grid %1" ).arg( mMapItem->grids()->size() + 1 );
1278 QgsLayoutItemMapGrid *grid =
new QgsLayoutItemMapGrid( itemName, mMapItem );
1279 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Add Map Grid" ) );
1280 mMapItem->grids()->addGrid( grid );
1281 mMapItem->layout()->undoStack()->endCommand();
1282 mMapItem->updateBoundingRect();
1285 addGridListItem( grid->
id(), grid->
name() );
1286 mGridListWidget->setCurrentRow( 0 );
1287 mGridListWidget_currentItemChanged( mGridListWidget->currentItem(),
nullptr );
1290void QgsLayoutMapWidget::mRemoveGridPushButton_clicked()
1292 QListWidgetItem *item = mGridListWidget->currentItem();
1298 mMapItem->beginCommand( tr(
"Remove Grid" ) );
1299 mMapItem->grids()->removeGrid( item->data( Qt::UserRole ).toString() );
1300 QListWidgetItem *delItem = mGridListWidget->takeItem( mGridListWidget->row( item ) );
1302 mMapItem->endCommand();
1303 mMapItem->updateBoundingRect();
1307void QgsLayoutMapWidget::mCopyGridPushButton_clicked()
1309 QListWidgetItem *item = mGridListWidget->currentItem();
1315 QgsLayoutItemMapGrid *sourceGrid = mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
1321 QString itemName = tr(
"%1 - Copy" ).arg( sourceGrid->
name() );
1322 QList<QgsLayoutItemMapGrid *> grids = mMapItem->grids()->asList();
1325 const auto it = std::find_if( grids.begin(), grids.end(), [&itemName](
const QgsLayoutItemMapGrid *grd ) { return grd->name() == itemName; } );
1326 if ( it != grids.end() )
1329 itemName = tr(
"%1 - Copy %2" ).arg( sourceGrid->
name() ).arg( i );
1334 QgsLayoutItemMapGrid *grid =
new QgsLayoutItemMapGrid( itemName, mMapItem );
1337 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Duplicate Map Grid" ) );
1338 mMapItem->grids()->addGrid( grid );
1339 mMapItem->layout()->undoStack()->endCommand();
1340 mMapItem->updateBoundingRect();
1343 addGridListItem( grid->
id(), grid->
name() );
1344 mGridListWidget->setCurrentRow( 0 );
1345 mGridListWidget_currentItemChanged( mGridListWidget->currentItem(),
nullptr );
1348void QgsLayoutMapWidget::mGridUpButton_clicked()
1350 QListWidgetItem *item = mGridListWidget->currentItem();
1356 const int row = mGridListWidget->row( item );
1361 mGridListWidget->takeItem( row );
1362 mGridListWidget->insertItem( row - 1, item );
1363 mGridListWidget->setCurrentItem( item );
1364 mMapItem->beginCommand( tr(
"Move Grid Up" ) );
1365 mMapItem->grids()->moveGridUp( item->data( Qt::UserRole ).toString() );
1366 mMapItem->endCommand();
1370void QgsLayoutMapWidget::mGridDownButton_clicked()
1372 QListWidgetItem *item = mGridListWidget->currentItem();
1378 const int row = mGridListWidget->row( item );
1379 if ( mGridListWidget->count() <= row )
1383 mGridListWidget->takeItem( row );
1384 mGridListWidget->insertItem( row + 1, item );
1385 mGridListWidget->setCurrentItem( item );
1386 mMapItem->beginCommand( tr(
"Move Grid Down" ) );
1387 mMapItem->grids()->moveGridDown( item->data( Qt::UserRole ).toString() );
1388 mMapItem->endCommand();
1399 QListWidgetItem *item = mGridListWidget->currentItem();
1404 return mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
1407void QgsLayoutMapWidget::mGridListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem * )
1409 mGridPropertiesButton->
setEnabled(
static_cast<bool>( current ) );
1412void QgsLayoutMapWidget::mGridListWidget_itemChanged( QListWidgetItem *item )
1419 QgsLayoutItemMapGrid *grid = mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
1425 mMapItem->beginCommand( tr(
"Rename Grid" ) );
1426 grid->
setName( item->text() );
1427 mMapItem->endCommand();
1430void QgsLayoutMapWidget::mGridPropertiesButton_clicked()
1436 QgsLayoutItemMapGrid *grid = currentGrid();
1442 QgsLayoutMapGridWidget *w =
new QgsLayoutMapGridWidget( grid, mMapItem );
1447QListWidgetItem *QgsLayoutMapWidget::addGridListItem(
const QString &
id,
const QString &name )
1449 QListWidgetItem *item =
new QListWidgetItem( name,
nullptr );
1450 item->setData( Qt::UserRole,
id );
1451 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
1452 mGridListWidget->insertItem( 0, item );
1456void QgsLayoutMapWidget::loadGridEntries()
1459 QSet<QString> selectedIds;
1460 const QList<QListWidgetItem *> itemSelection = mGridListWidget->selectedItems();
1461 QList<QListWidgetItem *>::const_iterator sIt = itemSelection.constBegin();
1462 for ( ; sIt != itemSelection.constEnd(); ++sIt )
1464 selectedIds.insert( ( *sIt )->data( Qt::UserRole ).toString() );
1467 mGridListWidget->clear();
1473 const QList<QgsLayoutItemMapGrid *> grids = mMapItem->grids()->asList();
1474 QList<QgsLayoutItemMapGrid *>::const_iterator gridIt = grids.constBegin();
1475 for ( ; gridIt != grids.constEnd(); ++gridIt )
1477 QListWidgetItem *item = addGridListItem( ( *gridIt )->id(), ( *gridIt )->name() );
1478 if ( selectedIds.contains( ( *gridIt )->id() ) )
1480 item->setSelected(
true );
1481 mGridListWidget->setCurrentItem( item );
1485 if ( mGridListWidget->currentItem() )
1487 mGridListWidget_currentItemChanged( mGridListWidget->currentItem(),
nullptr );
1491 mGridListWidget_currentItemChanged(
nullptr,
nullptr );
1495void QgsLayoutMapWidget::mAddOverviewPushButton_clicked()
1502 const QString itemName = tr(
"Overview %1" ).arg( mMapItem->overviews()->size() + 1 );
1503 QgsLayoutItemMapOverview *overview =
new QgsLayoutItemMapOverview( itemName, mMapItem );
1504 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Add Map Overview" ) );
1505 mMapItem->overviews()->addOverview( overview );
1506 mMapItem->layout()->undoStack()->endCommand();
1507 mMapItem->invalidateCache();
1509 addOverviewListItem( overview->
id(), overview->
name() );
1511 mOverviewListWidget->setCurrentRow( 0 );
1514void QgsLayoutMapWidget::mRemoveOverviewPushButton_clicked()
1516 QListWidgetItem *item = mOverviewListWidget->currentItem();
1521 mMapItem->beginCommand( tr(
"Remove Map Overview" ) );
1522 mMapItem->overviews()->removeOverview( item->data( Qt::UserRole ).toString() );
1523 mMapItem->endCommand();
1524 QListWidgetItem *delItem = mOverviewListWidget->takeItem( mOverviewListWidget->row( item ) );
1526 mMapItem->invalidateCache();
1529void QgsLayoutMapWidget::mOverviewUpButton_clicked()
1531 QListWidgetItem *item = mOverviewListWidget->currentItem();
1537 const int row = mOverviewListWidget->row( item );
1542 mOverviewListWidget->takeItem( row );
1543 mOverviewListWidget->insertItem( row - 1, item );
1544 mOverviewListWidget->setCurrentItem( item );
1545 mMapItem->beginCommand( tr(
"Move Overview Up" ) );
1546 mMapItem->overviews()->moveOverviewUp( item->data( Qt::UserRole ).toString() );
1547 mMapItem->endCommand();
1548 mMapItem->invalidateCache();
1551void QgsLayoutMapWidget::mOverviewDownButton_clicked()
1553 QListWidgetItem *item = mOverviewListWidget->currentItem();
1559 const int row = mOverviewListWidget->row( item );
1560 if ( mOverviewListWidget->count() <= row )
1564 mOverviewListWidget->takeItem( row );
1565 mOverviewListWidget->insertItem( row + 1, item );
1566 mOverviewListWidget->setCurrentItem( item );
1567 mMapItem->beginCommand( tr(
"Move Overview Down" ) );
1568 mMapItem->overviews()->moveOverviewDown( item->data( Qt::UserRole ).toString() );
1569 mMapItem->endCommand();
1570 mMapItem->invalidateCache();
1580 QListWidgetItem *item = mOverviewListWidget->currentItem();
1586 return mMapItem->overviews()->overview( item->data( Qt::UserRole ).toString() );
1589void QgsLayoutMapWidget::mOverviewListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous )
1591 Q_UNUSED( previous )
1594 mOverviewCheckBox->setEnabled(
false );
1599 setOverviewItems( mMapItem->overviews()->overview( current->data( Qt::UserRole ).toString() ) );
1602void QgsLayoutMapWidget::mOverviewListWidget_itemChanged( QListWidgetItem *item )
1609 QgsLayoutItemMapOverview *overview = mMapItem->overviews()->overview( item->data( Qt::UserRole ).toString() );
1615 mMapItem->beginCommand( u
"Rename Overview"_s );
1616 overview->
setName( item->text() );
1617 mMapItem->endCommand();
1618 if ( item->isSelected() )
1621 mOverviewCheckBox->setTitle( tr(
"Draw \"%1\" overview" ).arg( overview->
name() ) );
1625void QgsLayoutMapWidget::setOverviewItemsEnabled(
bool enabled )
1627 mOverviewFrameMapLabel->setEnabled( enabled );
1628 mOverviewFrameMapComboBox->setEnabled( enabled );
1629 mOverviewFrameStyleLabel->setEnabled( enabled );
1630 mOverviewFrameStyleButton->setEnabled( enabled );
1631 mOverviewBlendModeLabel->setEnabled( enabled );
1632 mOverviewBlendModeComboBox->setEnabled( enabled );
1633 mOverviewInvertCheckbox->setEnabled( enabled );
1634 mOverviewCenterCheckbox->setEnabled( enabled );
1635 mOverviewPositionComboBox->setEnabled( enabled );
1641void QgsLayoutMapWidget::blockOverviewItemsSignals(
const bool block )
1643 mOverviewFrameMapComboBox->blockSignals( block );
1644 mOverviewFrameStyleButton->blockSignals( block );
1645 mOverviewBlendModeComboBox->blockSignals( block );
1646 mOverviewInvertCheckbox->blockSignals( block );
1647 mOverviewCenterCheckbox->blockSignals( block );
1648 mOverviewPositionComboBox->blockSignals( block );
1649 mOverviewStackingLayerComboBox->blockSignals( block );
1659 blockOverviewItemsSignals(
true );
1661 mOverviewCheckBox->setTitle( tr(
"Draw \"%1\" overview" ).arg( overview->
name() ) );
1662 mOverviewCheckBox->setChecked( overview->
enabled() );
1665 mOverviewFrameMapComboBox->setItem( overview->
linkedMap() );
1668 mOverviewBlendModeComboBox->setBlendMode( overview->
blendMode() );
1670 mOverviewInvertCheckbox->setChecked( overview->
inverted() );
1672 mOverviewCenterCheckbox->setChecked( overview->
centered() );
1674 mOverviewPositionComboBox->setCurrentIndex( mOverviewPositionComboBox->findData( overview->
stackingPosition() ) );
1675 mOverviewStackingLayerComboBox->setLayer( overview->
stackingLayer() );
1676 mOverviewStackingLayerComboBox->setEnabled(
1682 blockOverviewItemsSignals(
false );
1685void QgsLayoutMapWidget::storeCurrentLayerSet()
1690 QList<QgsMapLayer *> layers = mMapCanvas->mapSettings().layers();
1692 mMapItem->setLayers( layers );
1694 if ( mMapItem->keepLayerStyles() )
1697 mMapItem->storeCurrentLayerStyles();
1701QList<QgsMapLayer *> QgsLayoutMapWidget::orderedPresetVisibleLayers(
const QString &name )
const
1706 QList<QgsMapLayer *> lst;
1708 for ( QgsMapLayer *layer : constLayerOrder )
1710 if ( visibleIds.contains( layer->
id() ) )
1718QListWidgetItem *QgsLayoutMapWidget::addOverviewListItem(
const QString &
id,
const QString &name )
1720 QListWidgetItem *item =
new QListWidgetItem( name,
nullptr );
1721 item->setData( Qt::UserRole,
id );
1722 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
1723 mOverviewListWidget->insertItem( 0, item );
1727void QgsLayoutMapWidget::loadOverviewEntries()
1730 QSet<QString> selectedIds;
1731 const QList<QListWidgetItem *> itemSelection = mOverviewListWidget->selectedItems();
1732 QList<QListWidgetItem *>::const_iterator sIt = itemSelection.constBegin();
1733 for ( ; sIt != itemSelection.constEnd(); ++sIt )
1735 selectedIds.insert( ( *sIt )->data( Qt::UserRole ).toString() );
1738 mOverviewListWidget->clear();
1744 mOverviewFrameMapComboBox->setExceptedItemList( QList<QgsLayoutItem *>() << mMapItem );
1747 const QList<QgsLayoutItemMapOverview *> overviews = mMapItem->overviews()->asList();
1748 QList<QgsLayoutItemMapOverview *>::const_iterator overviewIt = overviews.constBegin();
1749 for ( ; overviewIt != overviews.constEnd(); ++overviewIt )
1751 QListWidgetItem *item = addOverviewListItem( ( *overviewIt )->id(), ( *overviewIt )->name() );
1752 if ( selectedIds.contains( ( *overviewIt )->id() ) )
1754 item->setSelected(
true );
1755 mOverviewListWidget->setCurrentItem( item );
1759 if ( mOverviewListWidget->currentItem() )
1761 mOverviewListWidget_currentItemChanged( mOverviewListWidget->currentItem(),
nullptr );
1765 mOverviewListWidget_currentItemChanged(
nullptr,
nullptr );
1769void QgsLayoutMapWidget::mOverviewCheckBox_toggled(
bool state )
1771 QgsLayoutItemMapOverview *overview = currentOverview();
1777 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Overview Display Toggled" ) );
1779 mMapItem->invalidateCache();
1780 mMapItem->layout()->undoStack()->endCommand();
1783void QgsLayoutMapWidget::overviewMapChanged(
QgsLayoutItem *item )
1785 QgsLayoutItemMapOverview *overview = currentOverview();
1791 QgsLayoutItemMap *map =
dynamic_cast<QgsLayoutItemMap *
>( item );
1795 mMapItem->beginCommand( tr(
"Change Overview Map" ) );
1797 mMapItem->invalidateCache();
1798 mMapItem->endCommand();
1801void QgsLayoutMapWidget::mOverviewBlendModeComboBox_currentIndexChanged(
int index )
1804 QgsLayoutItemMapOverview *overview = currentOverview();
1810 mMapItem->beginCommand( tr(
"Change Overview Blend Mode" ) );
1811 overview->
setBlendMode( mOverviewBlendModeComboBox->blendMode() );
1812 mMapItem->invalidateCache();
1813 mMapItem->endCommand();
1816void QgsLayoutMapWidget::mOverviewInvertCheckbox_toggled(
bool state )
1818 QgsLayoutItemMapOverview *overview = currentOverview();
1824 mMapItem->beginCommand( tr(
"Toggle Overview Inverted" ) );
1826 mMapItem->invalidateCache();
1827 mMapItem->endCommand();
1830void QgsLayoutMapWidget::mOverviewCenterCheckbox_toggled(
bool state )
1832 QgsLayoutItemMapOverview *overview = currentOverview();
1838 mMapItem->beginCommand( tr(
"Toggle Overview Centered" ) );
1840 mMapItem->invalidateCache();
1841 mMapItem->endCommand();
1844void QgsLayoutMapWidget::overviewStackingChanged(
int )
1846 QgsLayoutItemMapOverview *overview = currentOverview();
1852 mMapItem->beginCommand( tr(
"Change Overview Position" ) );
1854 mMapItem->invalidateCache();
1855 mMapItem->endCommand();
1862 mOverviewStackingLayerComboBox->setEnabled(
false );
1867 mOverviewStackingLayerComboBox->setEnabled(
true );
1872void QgsLayoutMapWidget::overviewStackingLayerChanged(
QgsMapLayer *layer )
1874 QgsLayoutItemMapOverview *overview = currentOverview();
1880 mMapItem->beginCommand( tr(
"Change Overview Position" ) );
1882 mMapItem->invalidateCache();
1883 mMapItem->endCommand();
1897 mLabelBoundarySpinBox->setClearValue( 0 );
1898 mLabelBoundarySpinBox->setShowClearButton(
true );
1900 mLabelBoundaryUnitsCombo->linkToWidget( mLabelBoundarySpinBox );
1901 mLabelBoundaryUnitsCombo->setConverter( &mMapItem->layout()->renderContext().measurementConverter() );
1904 connect( mLabelBoundarySpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapLabelingWidget::labelMarginChanged );
1905 connect( mShowPartialLabelsCheckBox, &QCheckBox::toggled,
this, &QgsLayoutMapLabelingWidget::showPartialsToggled );
1906 connect( mShowUnplacedCheckBox, &QCheckBox::toggled,
this, &QgsLayoutMapLabelingWidget::showUnplacedToggled );
1923 mMapItem = qobject_cast<QgsLayoutItemMap *>( item );
1930 updateGuiElements();
1935void QgsLayoutMapLabelingWidget::updateGuiElements()
1937 whileBlocking( mLabelBoundarySpinBox )->setValue( mMapItem->labelMargin().length() );
1938 whileBlocking( mLabelBoundaryUnitsCombo )->setUnit( mMapItem->labelMargin().units() );
1942 if ( mBlockingItemsListView->model() )
1944 QAbstractItemModel *oldModel = mBlockingItemsListView->model();
1945 mBlockingItemsListView->setModel(
nullptr );
1946 oldModel->deleteLater();
1949 QgsLayoutMapItemBlocksLabelsModel *model =
new QgsLayoutMapItemBlocksLabelsModel( mMapItem, mMapItem->layout()->itemsModel(), mBlockingItemsListView );
1950 mBlockingItemsListView->setModel( model );
1955void QgsLayoutMapLabelingWidget::labelMarginChanged(
double val )
1961 mMapItem->setLabelMargin( QgsLayoutMeasurement( val, mLabelBoundaryUnitsCombo->unit() ) );
1962 mMapItem->layout()->undoStack()->endCommand();
1963 mMapItem->invalidateCache();
1966void QgsLayoutMapLabelingWidget::labelMarginUnitsChanged()
1972 mMapItem->setLabelMargin( QgsLayoutMeasurement( mLabelBoundarySpinBox->value(), mLabelBoundaryUnitsCombo->unit() ) );
1973 mMapItem->layout()->undoStack()->endCommand();
1974 mMapItem->invalidateCache();
1977void QgsLayoutMapLabelingWidget::showPartialsToggled(
bool checked )
1982 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Label Visibility" ) );
1987 flags &= ~QgsLayoutItemMap::ShowPartialLabels;
1988 mMapItem->setMapFlags( flags );
1989 mMapItem->layout()->undoStack()->endCommand();
1990 mMapItem->invalidateCache();
1993void QgsLayoutMapLabelingWidget::showUnplacedToggled(
bool checked )
1998 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Label Visibility" ) );
2003 flags &= ~QgsLayoutItemMap::ShowUnplacedLabels;
2004 mMapItem->setMapFlags( flags );
2005 mMapItem->layout()->undoStack()->endCommand();
2006 mMapItem->invalidateCache();
2010 : QSortFilterProxyModel( parent )
2011 , mLayoutModel( layoutModel )
2014 setSourceModel( layoutModel );
2027 if ( i.column() != 0 )
2032 QgsLayoutItem *item = mLayoutModel->itemFromIndex( mapToSource( i ) );
2040 case Qt::CheckStateRole:
2041 switch ( i.column() )
2044 return mMapItem ? ( mMapItem->isLabelBlockingItem( item ) ? Qt::Checked : Qt::Unchecked ) : Qt::Unchecked;
2050 return mLayoutModel->data( sourceIndex, role );
2058 if ( !index.isValid() )
2061 QgsLayoutItem *item = mLayoutModel->itemFromIndex( mapToSource( index ) );
2062 if ( !item || !mMapItem )
2069 if ( value.toBool() )
2071 mMapItem->addLabelBlockingItem( item );
2075 mMapItem->removeLabelBlockingItem( item );
2077 emit dataChanged( index, index, QVector<int>() << role );
2079 mMapItem->layout()->undoStack()->endCommand();
2080 mMapItem->invalidateCache();
2087 Qt::ItemFlags
flags = QSortFilterProxyModel::flags( index );
2089 if ( !index.isValid() )
2094 switch ( index.column() )
2097 return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
2099 return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
2105 QgsLayoutItem *item = mLayoutModel->itemFromIndex( mLayoutModel->index( source_row, 0, source_parent ) );
2106 if ( !item || item == mMapItem )
2127 mLayerModel->setItemsCheckable(
true );
2128 mLayersTreeView->setModel( mLayerModel );
2134 for (
int i = 0; i < mAtlasClippingTypeComboBox->count(); ++i )
2136 mItemClippingTypeComboBox->addItem( mAtlasClippingTypeComboBox->itemText( i ), mAtlasClippingTypeComboBox->itemData( i ) );
2139 mClipItemComboBox->setCurrentLayout( map->
layout() );
2142 connect( mRadioClipSelectedLayers, &QRadioButton::toggled,
this, &QgsLayoutMapClippingWidget::toggleLayersSelectionGui );
2143 mLayersTreeView->setEnabled(
false );
2144 mSelectAllButton->setEnabled(
false );
2145 mDeselectAllButton->setEnabled(
false );
2146 mInvertSelectionButton->setEnabled(
false );
2147 mRadioClipAllLayers->setChecked(
true );
2149 connect( mClipToAtlasCheckBox, &QGroupBox::toggled,
this, [
this](
bool active ) {
2150 if ( !mBlockUpdates )
2152 mMapItem->beginCommand( tr(
"Toggle Atlas Clipping" ) );
2153 mMapItem->atlasClippingSettings()->setEnabled( active );
2154 mMapItem->endCommand();
2157 connect( mForceLabelsInsideCheckBox, &QCheckBox::toggled,
this, [
this](
bool active ) {
2158 if ( !mBlockUpdates )
2160 mMapItem->beginCommand( tr(
"Change Atlas Clipping Label Behavior" ) );
2161 mMapItem->atlasClippingSettings()->setForceLabelsInsideFeature( active );
2162 mMapItem->endCommand();
2165 connect( mClipFrameCheckBox, &QCheckBox::toggled,
this, [
this](
bool active ) {
2166 if ( !mBlockUpdates )
2168 mMapItem->beginCommand( tr(
"Change Atlas Clipping Label Behavior" ) );
2169 mMapItem->atlasClippingSettings()->setClipItemShape( active );
2170 mMapItem->endCommand();
2173 connect( mAtlasClippingTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
2174 if ( !mBlockUpdates )
2176 mMapItem->beginCommand( tr(
"Change Atlas Clipping Behavior" ) );
2178 mMapItem->endCommand();
2182 connect( mRadioClipSelectedLayers, &QCheckBox::toggled,
this, [
this](
bool active ) {
2183 if ( active && !mBlockUpdates )
2185 mBlockUpdates =
true;
2186 mMapItem->beginCommand( tr(
"Change Atlas Clipping Layers" ) );
2187 mMapItem->atlasClippingSettings()->setRestrictToLayers(
true );
2188 mMapItem->endCommand();
2189 mBlockUpdates =
false;
2193 connect( mSelectAllButton, &QPushButton::clicked,
this, &QgsLayoutMapClippingWidget::selectAll );
2194 connect( mDeselectAllButton, &QPushButton::clicked,
this, &QgsLayoutMapClippingWidget::deselectAll );
2195 connect( mInvertSelectionButton, &QPushButton::clicked,
this, &QgsLayoutMapClippingWidget::invertSelection );
2197 connect( mRadioClipAllLayers, &QCheckBox::toggled,
this, [
this](
bool active ) {
2198 if ( active && !mBlockUpdates )
2200 mBlockUpdates =
true;
2201 mMapItem->beginCommand( tr(
"Change Atlas Clipping Layers" ) );
2202 mMapItem->atlasClippingSettings()->setRestrictToLayers(
false );
2203 mMapItem->endCommand();
2204 mBlockUpdates =
false;
2207 connect( mLayerModel, &QgsMapLayerModel::dataChanged,
this, [
this](
const QModelIndex &,
const QModelIndex &,
const QVector<int> &roles = QVector<int>() ) {
2208 if ( !roles.contains( Qt::CheckStateRole ) )
2211 if ( !mBlockUpdates )
2213 mBlockUpdates =
true;
2214 mMapItem->beginCommand( tr(
"Change Atlas Clipping Layers" ) );
2215 mMapItem->atlasClippingSettings()->setLayersToClip( mLayerModel->layersChecked() );
2216 mMapItem->endCommand();
2217 mBlockUpdates =
false;
2223 connect( mClipToItemCheckBox, &QGroupBox::toggled,
this, [
this](
bool active ) {
2224 if ( !mBlockUpdates )
2226 mMapItem->beginCommand( tr(
"Toggle Map Clipping" ) );
2227 mMapItem->itemClippingSettings()->setEnabled( active );
2228 mMapItem->endCommand();
2231 connect( mItemClippingTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
2232 if ( !mBlockUpdates )
2234 mMapItem->beginCommand( tr(
"Change Map Clipping Behavior" ) );
2236 mMapItem->endCommand();
2239 connect( mForceLabelsInsideItemCheckBox, &QCheckBox::toggled,
this, [
this](
bool active ) {
2240 if ( !mBlockUpdates )
2242 mMapItem->beginCommand( tr(
"Change Map Clipping Label Behavior" ) );
2243 mMapItem->itemClippingSettings()->setForceLabelsInsideClipPath( active );
2244 mMapItem->endCommand();
2248 if ( !mBlockUpdates )
2250 mMapItem->beginCommand( tr(
"Change Map Clipping Item" ) );
2251 mMapItem->itemClippingSettings()->setSourceItem( item );
2252 mMapItem->endCommand();
2262 atlasToggled( atlas->enabled() );
2268 mClipToAtlasCheckBox->setTitle( tr(
"Clip to %1 feature" ).arg(
string ) );
2269 mClipToAtlasLabel->setText( tr(
"<b>When enabled, map layers will be automatically clipped to the boundary of the current %1 feature.</b>" ).arg(
string ) );
2270 mForceLabelsInsideCheckBox->setText( tr(
"Force labels inside %1 feature" ).arg(
string ) );
2271 mClipFrameCheckBox->setText( tr(
"Clip item frame to match %1 feature" ).arg(
string ) );
2284 mMapItem = qobject_cast<QgsLayoutItemMap *>( item );
2291 updateGuiElements();
2296void QgsLayoutMapClippingWidget::updateGuiElements()
2298 if ( mBlockUpdates )
2301 mBlockUpdates =
true;
2302 mClipToAtlasCheckBox->setChecked( mMapItem->atlasClippingSettings()->enabled() );
2303 mAtlasClippingTypeComboBox->setCurrentIndex( mAtlasClippingTypeComboBox->findData(
static_cast<int>( mMapItem->atlasClippingSettings()->featureClippingType() ) ) );
2304 mForceLabelsInsideCheckBox->setChecked( mMapItem->atlasClippingSettings()->forceLabelsInsideFeature() );
2305 mClipFrameCheckBox->setChecked( mMapItem->atlasClippingSettings()->clipItemShape() );
2307 mRadioClipAllLayers->setChecked( !mMapItem->atlasClippingSettings()->restrictToLayers() );
2308 mRadioClipSelectedLayers->setChecked( mMapItem->atlasClippingSettings()->restrictToLayers() );
2309 mLayerModel->
setLayersChecked( mMapItem->atlasClippingSettings()->layersToClip() );
2311 mClipToItemCheckBox->setChecked( mMapItem->itemClippingSettings()->enabled() );
2312 mItemClippingTypeComboBox->setCurrentIndex( mItemClippingTypeComboBox->findData(
static_cast<int>( mMapItem->itemClippingSettings()->featureClippingType() ) ) );
2313 mForceLabelsInsideItemCheckBox->setChecked( mMapItem->itemClippingSettings()->forceLabelsInsideClipPath() );
2314 mClipItemComboBox->setItem( mMapItem->itemClippingSettings()->sourceItem() );
2316 mBlockUpdates =
false;
2319void QgsLayoutMapClippingWidget::atlasLayerChanged(
QgsVectorLayer *layer )
2324 mClipToAtlasCheckBox->setChecked(
false );
2325 mClipToAtlasCheckBox->setEnabled(
false );
2330 mClipToAtlasCheckBox->setEnabled(
true );
2334void QgsLayoutMapClippingWidget::atlasToggled(
bool atlasEnabled )
2336 if ( atlasEnabled && mMapItem && mMapItem->layout() && mMapItem->layout()->reportContext().layer() && mMapItem->layout()->reportContext().layer()->geometryType() ==
Qgis::GeometryType::Polygon )
2338 mClipToAtlasCheckBox->setEnabled(
true );
2342 mClipToAtlasCheckBox->setEnabled(
false );
2343 mClipToAtlasCheckBox->setChecked(
false );
2347void QgsLayoutMapClippingWidget::invertSelection()
2349 for (
int i = 0; i < mLayerModel->rowCount( QModelIndex() ); i++ )
2351 QModelIndex index = mLayerModel->index( i, 0 );
2352 Qt::CheckState currentState = Qt::CheckState( mLayerModel->data( index, Qt::CheckStateRole ).toInt() );
2353 Qt::CheckState newState = ( currentState == Qt::Checked ) ? Qt::Unchecked : Qt::Checked;
2354 mLayerModel->setData( index, newState, Qt::CheckStateRole );
2358void QgsLayoutMapClippingWidget::selectAll()
2360 for (
int i = 0; i < mLayerModel->rowCount( QModelIndex() ); i++ )
2362 QModelIndex index = mLayerModel->index( i, 0 );
2363 mLayerModel->setData( index, Qt::Checked, Qt::CheckStateRole );
2367void QgsLayoutMapClippingWidget::deselectAll()
2369 for (
int i = 0; i < mLayerModel->rowCount( QModelIndex() ); i++ )
2371 QModelIndex index = mLayerModel->index( i, 0 );
2372 mLayerModel->setData( index, Qt::Unchecked, Qt::CheckStateRole );
2376void QgsLayoutMapClippingWidget::toggleLayersSelectionGui(
bool toggled )
2378 mLayersTreeView->setEnabled( toggled );
2379 mSelectAllButton->setEnabled( toggled );
2380 mDeselectAllButton->setEnabled( toggled );
2381 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.