QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgslayoutmapgridwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutmapgridwidget.cpp
3  ----------------------------
4  begin : October 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgslayoutmapgridwidget.h"
20 #include "qgssymbol.h"
21 #include "qgslayoutitemmap.h"
22 #include "qgsproject.h"
23 #include "qgssymbollayerutils.h"
24 #include "qgsstyle.h"
26 #include "qgslayout.h"
27 #include "qgsmapsettings.h"
29 #include "qgsvectorlayer.h"
30 #include "qgsprojectviewsettings.h"
31 #include "qgstextformatwidget.h"
32 #include "qgsguiutils.h"
33 
35  : QgsLayoutItemBaseWidget( nullptr, mapGrid )
36  , mMap( map )
37  , mMapGrid( mapGrid )
38 {
39  setupUi( this );
40 
41  mFrameStyleComboBox->addItem( tr( "No Frame" ), QgsLayoutItemMapGrid::NoFrame );
42  mFrameStyleComboBox->addItem( tr( "Zebra" ), QgsLayoutItemMapGrid::Zebra );
43  mFrameStyleComboBox->addItem( tr( "Zebra (Nautical)" ), QgsLayoutItemMapGrid::ZebraNautical );
44  mFrameStyleComboBox->addItem( tr( "Interior Ticks" ), QgsLayoutItemMapGrid::InteriorTicks );
45  mFrameStyleComboBox->addItem( tr( "Exterior Ticks" ), QgsLayoutItemMapGrid::ExteriorTicks );
46  mFrameStyleComboBox->addItem( tr( "Interior and Exterior Ticks" ), QgsLayoutItemMapGrid::InteriorExteriorTicks );
47  mFrameStyleComboBox->addItem( tr( "Line Border" ), QgsLayoutItemMapGrid::LineBorder );
48  mFrameStyleComboBox->addItem( tr( "Line Border (Nautical)" ), QgsLayoutItemMapGrid::LineBorderNautical );
49 
50  mRotatedTicksLengthModeComboBox->addItem( tr( "Orthogonal" ), QgsLayoutItemMapGrid::OrthogonalTicks );
51  mRotatedTicksLengthModeComboBox->addItem( tr( "Fixed length" ), QgsLayoutItemMapGrid::NormalizedTicks );
52  mRotatedAnnotationsLengthModeComboBox->addItem( tr( "Orthogonal" ), QgsLayoutItemMapGrid::OrthogonalTicks );
53  mRotatedAnnotationsLengthModeComboBox->addItem( tr( "Fixed length" ), QgsLayoutItemMapGrid::NormalizedTicks );
54 
55  mGridFrameMarginSpinBox->setShowClearButton( true );
56  mGridFrameMarginSpinBox->setClearValue( 0 );
57 
58  mDistanceToMapFrameSpinBox->setShowClearButton( true );
59  mDistanceToMapFrameSpinBox->setClearValue( 0 );
60 
61  connect( mIntervalXSpinBox, &QgsDoubleSpinBox::editingFinished, this, &QgsLayoutMapGridWidget::mIntervalXSpinBox_editingFinished );
62  connect( mIntervalYSpinBox, &QgsDoubleSpinBox::editingFinished, this, &QgsLayoutMapGridWidget::mIntervalYSpinBox_editingFinished );
63  connect( mOffsetXSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mOffsetXSpinBox_valueChanged );
64  connect( mOffsetYSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mOffsetYSpinBox_valueChanged );
65  connect( mCrossWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mCrossWidthSpinBox_valueChanged );
66  connect( mFrameWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mFrameWidthSpinBox_valueChanged );
67  connect( mGridFrameMarginSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mGridFrameMarginSpinBox_valueChanged );
68  connect( mFrameStyleComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mFrameStyleComboBox_currentIndexChanged );
69  connect( mRotatedTicksGroupBox, &QGroupBox::toggled, this, &QgsLayoutMapGridWidget::mRotatedTicksGroupBox_toggled );
70  connect( mRotatedTicksLengthModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mRotatedTicksLengthModeComboBox_currentIndexChanged );
71  connect( mRotatedTicksThresholdSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mRotatedTicksThresholdSpinBox_valueChanged );
72  connect( mRotatedTicksMarginToCornerSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mRotatedTicksMarginToCornerSpinBox_valueChanged );
73  connect( mRotatedAnnotationsGroupBox, &QGroupBox::toggled, this, &QgsLayoutMapGridWidget::mRotatedAnnotationsGroupBox_toggled );
74  connect( mRotatedAnnotationsLengthModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mRotatedAnnotationsLengthModeComboBox_currentIndexChanged );
75  connect( mRotatedAnnotationsThresholdSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mRotatedAnnotationsThresholdSpinBox_valueChanged );
76  connect( mRotatedAnnotationsMarginToCornerSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mRotatedAnnotationsMarginToCornerSpinBox_valueChanged );
77  connect( mGridFramePenSizeSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mGridFramePenSizeSpinBox_valueChanged );
78  connect( mGridFramePenColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutMapGridWidget::mGridFramePenColorButton_colorChanged );
79  connect( mGridFrameFill1ColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutMapGridWidget::mGridFrameFill1ColorButton_colorChanged );
80  connect( mGridFrameFill2ColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutMapGridWidget::mGridFrameFill2ColorButton_colorChanged );
81  connect( mGridTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mGridTypeComboBox_currentIndexChanged );
82  connect( mMapGridUnitComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::intervalUnitChanged );
83  connect( mGridBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mGridBlendComboBox_currentIndexChanged );
84  connect( mCheckGridLeftSide, &QCheckBox::toggled, this, &QgsLayoutMapGridWidget::mCheckGridLeftSide_toggled );
85  connect( mCheckGridRightSide, &QCheckBox::toggled, this, &QgsLayoutMapGridWidget::mCheckGridRightSide_toggled );
86  connect( mCheckGridTopSide, &QCheckBox::toggled, this, &QgsLayoutMapGridWidget::mCheckGridTopSide_toggled );
87  connect( mCheckGridBottomSide, &QCheckBox::toggled, this, &QgsLayoutMapGridWidget::mCheckGridBottomSide_toggled );
88  connect( mFrameDivisionsLeftComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mFrameDivisionsLeftComboBox_currentIndexChanged );
89  connect( mFrameDivisionsRightComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mFrameDivisionsRightComboBox_currentIndexChanged );
90  connect( mFrameDivisionsTopComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mFrameDivisionsTopComboBox_currentIndexChanged );
91  connect( mFrameDivisionsBottomComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mFrameDivisionsBottomComboBox_currentIndexChanged );
92  connect( mDrawAnnotationGroupBox, &QgsCollapsibleGroupBoxBasic::toggled, this, &QgsLayoutMapGridWidget::mDrawAnnotationGroupBox_toggled );
93  connect( mAnnotationFormatButton, &QToolButton::clicked, this, &QgsLayoutMapGridWidget::mAnnotationFormatButton_clicked );
94  connect( mAnnotationDisplayLeftComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDisplayLeftComboBox_currentIndexChanged );
95  connect( mAnnotationDisplayRightComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDisplayRightComboBox_currentIndexChanged );
96  connect( mAnnotationDisplayTopComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDisplayTopComboBox_currentIndexChanged );
97  connect( mAnnotationDisplayBottomComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDisplayBottomComboBox_currentIndexChanged );
98  connect( mAnnotationPositionLeftComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationPositionLeftComboBox_currentIndexChanged );
99  connect( mAnnotationPositionRightComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationPositionRightComboBox_currentIndexChanged );
100  connect( mAnnotationPositionTopComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationPositionTopComboBox_currentIndexChanged );
101  connect( mAnnotationPositionBottomComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationPositionBottomComboBox_currentIndexChanged );
102  connect( mAnnotationDirectionComboBoxLeft, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxLeft_currentIndexChanged );
103  connect( mAnnotationDirectionComboBoxRight, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxRight_currentIndexChanged );
104  connect( mAnnotationDirectionComboBoxTop, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxTop_currentIndexChanged );
105  connect( mAnnotationDirectionComboBoxBottom, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxBottom_currentIndexChanged );
106  connect( mAnnotationFormatComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationFormatComboBox_currentIndexChanged );
107  connect( mCoordinatePrecisionSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mCoordinatePrecisionSpinBox_valueChanged );
108  connect( mDistanceToMapFrameSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mDistanceToMapFrameSpinBox_valueChanged );
109  connect( mMinWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::minIntervalChanged );
110  connect( mMaxWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::maxIntervalChanged );
111  connect( mEnabledCheckBox, &QCheckBox::toggled, this, &QgsLayoutMapGridWidget::gridEnabledToggled );
112  setPanelTitle( tr( "Map Grid Properties" ) );
113 
114  mMapGridCrsSelector->setOptionVisible( QgsProjectionSelectionWidget::CrsNotSet, true );
115  mMapGridCrsSelector->setNotSetText( tr( "Use Map CRS" ) );
116 
117  connect( mMapGridCrsSelector, &QgsProjectionSelectionWidget::crsChanged, this, &QgsLayoutMapGridWidget::mapGridCrsChanged );
118 
119  blockAllSignals( true );
120 
121  mMapGridUnitComboBox->addItem( tr( "Map Units" ), QgsLayoutItemMapGrid::MapUnit );
122  mMapGridUnitComboBox->addItem( tr( "Fit Segment Width" ), QgsLayoutItemMapGrid::DynamicPageSizeBased );
123  mMapGridUnitComboBox->addItem( tr( "Millimeters" ), QgsLayoutItemMapGrid::MM );
124  mMapGridUnitComboBox->addItem( tr( "Centimeters" ), QgsLayoutItemMapGrid::CM );
125 
126  mGridTypeComboBox->insertItem( 0, tr( "Solid" ), QgsLayoutItemMapGrid::Solid );
127  mGridTypeComboBox->insertItem( 1, tr( "Cross" ), QgsLayoutItemMapGrid::Cross );
128  mGridTypeComboBox->insertItem( 2, tr( "Markers" ), QgsLayoutItemMapGrid::Markers );
129  mGridTypeComboBox->insertItem( 3, tr( "Frame and annotations only" ), QgsLayoutItemMapGrid::FrameAnnotationsOnly );
130 
131  insertFrameDisplayEntries( mFrameDivisionsLeftComboBox );
132  insertFrameDisplayEntries( mFrameDivisionsRightComboBox );
133  insertFrameDisplayEntries( mFrameDivisionsTopComboBox );
134  insertFrameDisplayEntries( mFrameDivisionsBottomComboBox );
135 
136  mAnnotationFormatComboBox->addItem( tr( "Decimal" ), QgsLayoutItemMapGrid::Decimal );
137  mAnnotationFormatComboBox->addItem( tr( "Decimal with Suffix" ), QgsLayoutItemMapGrid::DecimalWithSuffix );
138  mAnnotationFormatComboBox->addItem( tr( "Degree, Minute" ), QgsLayoutItemMapGrid::DegreeMinuteNoSuffix );
139  mAnnotationFormatComboBox->addItem( tr( "Degree, Minute with Suffix" ), QgsLayoutItemMapGrid::DegreeMinute );
140  mAnnotationFormatComboBox->addItem( tr( "Degree, Minute Aligned" ), QgsLayoutItemMapGrid::DegreeMinutePadded );
141  mAnnotationFormatComboBox->addItem( tr( "Degree, Minute, Second" ), QgsLayoutItemMapGrid::DegreeMinuteSecondNoSuffix );
142  mAnnotationFormatComboBox->addItem( tr( "Degree, Minute, Second with Suffix" ), QgsLayoutItemMapGrid::DegreeMinuteSecond );
143  mAnnotationFormatComboBox->addItem( tr( "Degree, Minute, Second Aligned" ), QgsLayoutItemMapGrid::DegreeMinuteSecondPadded );
144  mAnnotationFormatComboBox->addItem( tr( "Custom" ), QgsLayoutItemMapGrid::CustomFormat );
145 
146  insertAnnotationDisplayEntries( mAnnotationDisplayLeftComboBox );
147  insertAnnotationDisplayEntries( mAnnotationDisplayRightComboBox );
148  insertAnnotationDisplayEntries( mAnnotationDisplayTopComboBox );
149  insertAnnotationDisplayEntries( mAnnotationDisplayBottomComboBox );
150 
151  insertAnnotationPositionEntries( mAnnotationPositionLeftComboBox );
152  insertAnnotationPositionEntries( mAnnotationPositionRightComboBox );
153  insertAnnotationPositionEntries( mAnnotationPositionTopComboBox );
154  insertAnnotationPositionEntries( mAnnotationPositionBottomComboBox );
155 
156  insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxLeft );
157  insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxRight );
158  insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxTop );
159  insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxBottom );
160 
161  mGridFramePenColorButton->setColorDialogTitle( tr( "Select Grid Frame Color" ) );
162  mGridFramePenColorButton->setAllowOpacity( true );
163  mGridFramePenColorButton->setContext( QStringLiteral( "composer" ) );
164  mGridFramePenColorButton->setNoColorString( tr( "Transparent Frame" ) );
165  mGridFramePenColorButton->setShowNoColor( true );
166 
167  mGridFrameFill1ColorButton->setColorDialogTitle( tr( "Select Grid Frame Fill Color" ) );
168  mGridFrameFill1ColorButton->setAllowOpacity( true );
169  mGridFrameFill1ColorButton->setContext( QStringLiteral( "composer" ) );
170  mGridFrameFill1ColorButton->setNoColorString( tr( "Transparent Fill" ) );
171  mGridFrameFill1ColorButton->setShowNoColor( true );
172 
173  mGridFrameFill2ColorButton->setColorDialogTitle( tr( "Select Grid Frame Fill Color" ) );
174  mGridFrameFill2ColorButton->setAllowOpacity( true );
175  mGridFrameFill2ColorButton->setContext( QStringLiteral( "composer" ) );
176  mGridFrameFill2ColorButton->setNoColorString( tr( "Transparent Fill" ) );
177  mGridFrameFill2ColorButton->setShowNoColor( true );
178 
179  mGridLineStyleButton->setSymbolType( QgsSymbol::Line );
180  mGridMarkerStyleButton->setSymbolType( QgsSymbol::Marker );
181 
182  //set initial state of frame style controls
183  toggleFrameControls( false, false, false, false );
184 
203 
205 
206  blockAllSignals( false );
207  connect( mAnnotationFontButton, &QgsFontButton::changed, this, &QgsLayoutMapGridWidget::annotationTextFormatChanged );
208  connect( mGridLineStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutMapGridWidget::lineSymbolChanged );
209  connect( mGridMarkerStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutMapGridWidget::markerSymbolChanged );
210 
211  mGridLineStyleButton->registerExpressionContextGenerator( mMapGrid );
212  mGridLineStyleButton->setLayer( coverageLayer() );
213  mGridMarkerStyleButton->registerExpressionContextGenerator( mMapGrid );
214  mGridMarkerStyleButton->setLayer( coverageLayer() );
215  if ( mMap->layout() )
216  {
217  connect( &mMap->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mGridLineStyleButton, &QgsSymbolButton::setLayer );
218  connect( &mMap->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mGridMarkerStyleButton, &QgsSymbolButton::setLayer );
219  connect( &mMap->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mAnnotationFontButton, &QgsFontButton::setLayer );
220  }
221  mAnnotationFontButton->setLayer( coverageLayer() );
222  mAnnotationFontButton->registerExpressionContextGenerator( mMapGrid );
223 }
224 
226 {
227  updateDataDefinedButton( mEnabledDDBtn );
228  updateDataDefinedButton( mIntervalXDDBtn );
229  updateDataDefinedButton( mIntervalYDDBtn );
230  updateDataDefinedButton( mOffsetXDDBtn );
231  updateDataDefinedButton( mOffsetYDDBtn );
232  updateDataDefinedButton( mFrameSizeDDBtn );
233  updateDataDefinedButton( mFrameMarginDDBtn );
234  updateDataDefinedButton( mLabelDistDDBtn );
235  updateDataDefinedButton( mCrossWidthDDBtn );
236  updateDataDefinedButton( mFrameLineThicknessDDBtn );
237  updateDataDefinedButton( mAnnotationDisplayLeftDDBtn );
238  updateDataDefinedButton( mAnnotationDisplayRightDDBtn );
239  updateDataDefinedButton( mAnnotationDisplayTopDDBtn );
240  updateDataDefinedButton( mAnnotationDisplayBottomDDBtn );
241  updateDataDefinedButton( mFrameDivisionsLeftDDBtn );
242  updateDataDefinedButton( mFrameDivisionsRightDDBtn );
243  updateDataDefinedButton( mFrameDivisionsTopDDBtn );
244  updateDataDefinedButton( mFrameDivisionsBottomDDBtn );
245 }
246 
247 void QgsLayoutMapGridWidget::setGuiElementValues()
248 {
250 }
251 
253 {
254  if ( !mMapGrid || !mMap )
255  {
256  return;
257  }
258 
259  blockAllSignals( true );
261  setGridItems();
262  blockAllSignals( false );
263 }
264 
265 void QgsLayoutMapGridWidget::blockAllSignals( bool block )
266 {
267  //grid
268  mEnabledCheckBox->blockSignals( block );
269  mGridTypeComboBox->blockSignals( block );
270  mIntervalXSpinBox->blockSignals( block );
271  mIntervalYSpinBox->blockSignals( block );
272  mOffsetXSpinBox->blockSignals( block );
273  mOffsetYSpinBox->blockSignals( block );
274  mCrossWidthSpinBox->blockSignals( block );
275  mFrameStyleComboBox->blockSignals( block );
276  mFrameWidthSpinBox->blockSignals( block );
277  mGridFrameMarginSpinBox->blockSignals( block );
278  mGridLineStyleButton->blockSignals( block );
279  mMapGridUnitComboBox->blockSignals( block );
280  mGridFramePenSizeSpinBox->blockSignals( block );
281  mGridFramePenColorButton->blockSignals( block );
282  mGridFrameFill1ColorButton->blockSignals( block );
283  mGridFrameFill2ColorButton->blockSignals( block );
284  mGridBlendComboBox->blockSignals( block );
285  mCheckGridLeftSide->blockSignals( block );
286  mCheckGridRightSide->blockSignals( block );
287  mCheckGridTopSide->blockSignals( block );
288  mCheckGridBottomSide->blockSignals( block );
289  mFrameDivisionsLeftComboBox->blockSignals( block );
290  mFrameDivisionsRightComboBox->blockSignals( block );
291  mFrameDivisionsTopComboBox->blockSignals( block );
292  mFrameDivisionsBottomComboBox->blockSignals( block );
293  mGridMarkerStyleButton->blockSignals( block );
294 
295  //grid annotation
296  mDrawAnnotationGroupBox->blockSignals( block );
297  mAnnotationFormatComboBox->blockSignals( block );
298  mAnnotationDisplayLeftComboBox->blockSignals( block );
299  mAnnotationPositionLeftComboBox->blockSignals( block );
300  mAnnotationDirectionComboBoxLeft->blockSignals( block );
301  mAnnotationDisplayRightComboBox->blockSignals( block );
302  mAnnotationPositionRightComboBox->blockSignals( block );
303  mAnnotationDirectionComboBoxRight->blockSignals( block );
304  mAnnotationDisplayTopComboBox->blockSignals( block );
305  mAnnotationPositionTopComboBox->blockSignals( block );
306  mAnnotationDirectionComboBoxTop->blockSignals( block );
307  mAnnotationDisplayBottomComboBox->blockSignals( block );
308  mAnnotationPositionBottomComboBox->blockSignals( block );
309  mAnnotationDirectionComboBoxBottom->blockSignals( block );
310  mDistanceToMapFrameSpinBox->blockSignals( block );
311  mCoordinatePrecisionSpinBox->blockSignals( block );
312  mAnnotationFontButton->blockSignals( block );
313  mMinWidthSpinBox->blockSignals( block );
314  mMaxWidthSpinBox->blockSignals( block );
315 }
316 
317 void QgsLayoutMapGridWidget::handleChangedFrameDisplay( QgsLayoutItemMapGrid::BorderSide border, const QgsLayoutItemMapGrid::DisplayMode mode )
318 {
319  if ( !mMapGrid || !mMap )
320  {
321  return;
322  }
323 
324  mMap->beginCommand( tr( "Change Frame Divisions" ) );
325  mMapGrid->setFrameDivisions( mode, border );
326  mMap->endCommand();
327  mMap->updateBoundingRect();
328 }
329 
330 void QgsLayoutMapGridWidget::handleChangedAnnotationDisplay( QgsLayoutItemMapGrid::BorderSide border, const QgsLayoutItemMapGrid::DisplayMode mode )
331 {
332  if ( !mMapGrid || !mMap )
333  {
334  return;
335  }
336 
337  mMap->beginCommand( tr( "Change Annotation Format" ) );
338  mMapGrid->setAnnotationDisplay( mode, border );
339  mMap->updateBoundingRect();
340  mMap->update();
341  mMap->endCommand();
342 }
343 
344 void QgsLayoutMapGridWidget::toggleFrameControls( bool frameEnabled, bool frameFillEnabled, bool frameSizeEnabled, bool rotationEnabled )
345 {
346  //set status of frame controls
347  mFrameWidthSpinBox->setEnabled( frameSizeEnabled );
348  mGridFrameMarginSpinBox->setEnabled( frameEnabled );
349  mGridFramePenSizeSpinBox->setEnabled( frameEnabled );
350  mGridFramePenColorButton->setEnabled( frameEnabled );
351  mGridFrameFill1ColorButton->setEnabled( frameFillEnabled );
352  mGridFrameFill2ColorButton->setEnabled( frameFillEnabled );
353  mFrameWidthLabel->setEnabled( frameSizeEnabled );
354  mFrameMarginLabel->setEnabled( frameEnabled );
355  mFramePenLabel->setEnabled( frameEnabled );
356  mFrameFillLabel->setEnabled( frameFillEnabled );
357  mCheckGridLeftSide->setEnabled( frameEnabled );
358  mCheckGridRightSide->setEnabled( frameEnabled );
359  mCheckGridTopSide->setEnabled( frameEnabled );
360  mCheckGridBottomSide->setEnabled( frameEnabled );
361  mFrameDivisionsLeftComboBox->setEnabled( frameEnabled );
362  mFrameDivisionsRightComboBox->setEnabled( frameEnabled );
363  mFrameDivisionsTopComboBox->setEnabled( frameEnabled );
364  mFrameDivisionsBottomComboBox->setEnabled( frameEnabled );
365  mLeftDivisionsLabel->setEnabled( frameEnabled );
366  mRightDivisionsLabel->setEnabled( frameEnabled );
367  mTopDivisionsLabel->setEnabled( frameEnabled );
368  mBottomDivisionsLabel->setEnabled( frameEnabled );
369  mRotatedTicksGroupBox->setEnabled( rotationEnabled );
370 }
371 
372 void QgsLayoutMapGridWidget::insertAnnotationPositionEntries( QComboBox *c )
373 {
374  c->insertItem( 0, tr( "Inside Frame" ), QgsLayoutItemMapGrid::InsideMapFrame );
375  c->insertItem( 1, tr( "Outside Frame" ), QgsLayoutItemMapGrid::OutsideMapFrame );
376 }
377 
378 void QgsLayoutMapGridWidget::insertAnnotationDirectionEntries( QComboBox *c )
379 {
380  c->addItem( tr( "Horizontal" ), QgsLayoutItemMapGrid::Horizontal );
381  c->addItem( tr( "Vertical Ascending" ), QgsLayoutItemMapGrid::Vertical );
382  c->addItem( tr( "Vertical Descending" ), QgsLayoutItemMapGrid::VerticalDescending );
383  c->addItem( tr( "Boundary Direction" ), QgsLayoutItemMapGrid::BoundaryDirection );
384  // c->addItem( tr( "Parallel to Tick" ), QgsLayoutItemMapGrid::ParallelToTick );
385  c->addItem( tr( "Above Tick" ), QgsLayoutItemMapGrid::AboveTick );
386  c->addItem( tr( "On Tick" ), QgsLayoutItemMapGrid::OnTick );
387  c->addItem( tr( "Under Tick" ), QgsLayoutItemMapGrid::UnderTick );
388 }
389 
390 void QgsLayoutMapGridWidget::initFrameDisplayBox( QComboBox *c, QgsLayoutItemMapGrid::DisplayMode display )
391 {
392  if ( !c )
393  {
394  return;
395  }
396  c->setCurrentIndex( c->findData( display ) );
397 }
398 
399 void QgsLayoutMapGridWidget::handleChangedAnnotationPosition( QgsLayoutItemMapGrid::BorderSide border, const QgsLayoutItemMapGrid::AnnotationPosition position )
400 {
401  if ( !mMapGrid || !mMap )
402  {
403  return;
404  }
405 
406  mMap->beginCommand( tr( "Change Annotation Position" ) );
407  mMapGrid->setAnnotationPosition( position, border );
408 
409  mMap->updateBoundingRect();
410  mMap->update();
411  mMap->endCommand();
412 }
413 
414 void QgsLayoutMapGridWidget::handleChangedAnnotationDirection( QgsLayoutItemMapGrid::BorderSide border, QgsLayoutItemMapGrid::AnnotationDirection direction )
415 {
416  if ( !mMapGrid || !mMap )
417  {
418  return;
419  }
420 
421  mMap->beginCommand( tr( "Change Annotation Direction" ) );
422  mMapGrid->setAnnotationDirection( direction, border );
423  mMap->updateBoundingRect();
424  mMap->update();
425  mMap->endCommand();
426 }
427 
428 void QgsLayoutMapGridWidget::insertFrameDisplayEntries( QComboBox *c )
429 {
430  c->addItem( tr( "All" ), QgsLayoutItemMapGrid::ShowAll );
431  c->addItem( tr( "Latitude/Y Only" ), QgsLayoutItemMapGrid::LatitudeOnly );
432  c->addItem( tr( "Longitude/X Only" ), QgsLayoutItemMapGrid::LongitudeOnly );
433 }
434 
435 void QgsLayoutMapGridWidget::insertAnnotationDisplayEntries( QComboBox *c )
436 {
437  c->insertItem( 0, tr( "Show All" ), QgsLayoutItemMapGrid::ShowAll );
438  c->insertItem( 1, tr( "Show Latitude/Y Only" ), QgsLayoutItemMapGrid::LatitudeOnly );
439  c->insertItem( 2, tr( "Show Longitude/X Only" ), QgsLayoutItemMapGrid::LongitudeOnly );
440  c->insertItem( 3, tr( "Disabled" ), QgsLayoutItemMapGrid::HideAll );
441 }
442 
443 void QgsLayoutMapGridWidget::initAnnotationPositionBox( QComboBox *c, QgsLayoutItemMapGrid::AnnotationPosition pos )
444 {
445  if ( !c )
446  {
447  return;
448  }
449 
451  {
452  c->setCurrentIndex( c->findText( tr( "Inside Frame" ) ) );
453  }
454  else
455  {
456  c->setCurrentIndex( c->findText( tr( "Outside Frame" ) ) );
457  }
458 }
459 
460 void QgsLayoutMapGridWidget::initAnnotationDirectionBox( QComboBox *c, QgsLayoutItemMapGrid::AnnotationDirection dir )
461 {
462  if ( !c )
463  {
464  return;
465  }
466  c->setCurrentIndex( c->findData( dir ) );
467 }
468 
469 bool QgsLayoutMapGridWidget::hasPredefinedScales() const
470 {
471  // first look at project's scales
472  const QVector< double > scales = QgsProject::instance()->viewSettings()->mapScales();
473  bool hasProjectScales( QgsProject::instance()->viewSettings()->useProjectScales() );
474  if ( !hasProjectScales || scales.isEmpty() )
475  {
476  // default to global map tool scales
477  QgsSettings settings;
478  QString scalesStr( settings.value( QStringLiteral( "Map/scales" ), Qgis::defaultProjectScales() ).toString() );
479  QStringList myScalesList = scalesStr.split( ',' );
480  return !myScalesList.isEmpty() && !myScalesList[0].isEmpty();
481  }
482  return true;
483 }
484 
485 void QgsLayoutMapGridWidget::setGridItems()
486 {
487  if ( !mMapGrid )
488  {
489  return;
490  }
491 
492  mGridMarkerStyleButton->registerExpressionContextGenerator( mMapGrid );
493  mGridLineStyleButton->registerExpressionContextGenerator( mMapGrid );
494  mAnnotationFontButton->registerExpressionContextGenerator( mMapGrid );
495 
496  mEnabledCheckBox->setChecked( mMapGrid->enabled() );
497  mIntervalXSpinBox->setValue( mMapGrid->intervalX() );
498  mIntervalYSpinBox->setValue( mMapGrid->intervalY() );
499  mOffsetXSpinBox->setValue( mMapGrid->offsetX() );
500  mOffsetYSpinBox->setValue( mMapGrid->offsetY() );
501  mCrossWidthSpinBox->setValue( mMapGrid->crossLength() );
502  mFrameWidthSpinBox->setValue( mMapGrid->frameWidth() );
503  mGridFrameMarginSpinBox->setValue( mMapGrid->frameMargin() );
504  mGridFramePenSizeSpinBox->setValue( mMapGrid->framePenSize() );
505  mGridFramePenColorButton->setColor( mMapGrid->framePenColor() );
506  mGridFrameFill1ColorButton->setColor( mMapGrid->frameFillColor1() );
507  mGridFrameFill2ColorButton->setColor( mMapGrid->frameFillColor2() );
508 
509  const QgsLayoutItemMapGrid::GridStyle gridStyle = mMapGrid->style();
510  mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findData( gridStyle ) );
511  switch ( gridStyle )
512  {
514  mCrossWidthSpinBox->setVisible( true );
515  mCrossWidthDDBtn->setVisible( true );
516  mCrossWidthLabel->setVisible( true );
517  mGridLineStyleButton->setVisible( true );
518  mLineStyleLabel->setVisible( true );
519  mGridMarkerStyleButton->setVisible( false );
520  mMarkerStyleLabel->setVisible( false );
521  mGridBlendComboBox->setVisible( true );
522  mGridBlendLabel->setVisible( true );
523  break;
525  mCrossWidthSpinBox->setVisible( false );
526  mCrossWidthDDBtn->setVisible( false );
527  mCrossWidthLabel->setVisible( false );
528  mGridLineStyleButton->setVisible( false );
529  mLineStyleLabel->setVisible( false );
530  mGridMarkerStyleButton->setVisible( true );
531  mMarkerStyleLabel->setVisible( true );
532  mGridBlendComboBox->setVisible( true );
533  mGridBlendLabel->setVisible( true );
534  break;
536  mCrossWidthSpinBox->setVisible( false );
537  mCrossWidthDDBtn->setVisible( false );
538  mCrossWidthLabel->setVisible( false );
539  mGridLineStyleButton->setVisible( true );
540  mLineStyleLabel->setVisible( true );
541  mGridMarkerStyleButton->setVisible( false );
542  mMarkerStyleLabel->setVisible( false );
543  mGridBlendComboBox->setVisible( true );
544  mGridBlendLabel->setVisible( true );
545  break;
547  mCrossWidthSpinBox->setVisible( false );
548  mCrossWidthDDBtn->setVisible( false );
549  mCrossWidthLabel->setVisible( false );
550  mGridLineStyleButton->setVisible( false );
551  mLineStyleLabel->setVisible( false );
552  mGridMarkerStyleButton->setVisible( false );
553  mMarkerStyleLabel->setVisible( false );
554  mGridBlendComboBox->setVisible( false );
555  mGridBlendLabel->setVisible( false );
556  break;
557  }
558 
559  //grid frame
560  mFrameWidthSpinBox->setValue( mMapGrid->frameWidth() );
561  mGridFrameMarginSpinBox->setValue( mMapGrid->frameMargin() );
562  QgsLayoutItemMapGrid::FrameStyle gridFrameStyle = mMapGrid->frameStyle();
563  mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findData( gridFrameStyle ) );
564  switch ( gridFrameStyle )
565  {
568  toggleFrameControls( true, true, true, false );
569  break;
573  toggleFrameControls( true, false, true, true );
574  break;
577  toggleFrameControls( true, false, false, false );
578  break;
580  toggleFrameControls( false, false, false, false );
581  break;
582  }
583 
584  mCheckGridLeftSide->setChecked( mMapGrid->testFrameSideFlag( QgsLayoutItemMapGrid::FrameLeft ) );
585  mCheckGridRightSide->setChecked( mMapGrid->testFrameSideFlag( QgsLayoutItemMapGrid::FrameRight ) );
586  mCheckGridTopSide->setChecked( mMapGrid->testFrameSideFlag( QgsLayoutItemMapGrid::FrameTop ) );
587  mCheckGridBottomSide->setChecked( mMapGrid->testFrameSideFlag( QgsLayoutItemMapGrid::FrameBottom ) );
588 
589  mRotatedTicksGroupBox->setChecked( mMapGrid->rotatedTicksEnabled() );
590  mRotatedTicksLengthModeComboBox->setCurrentIndex( mRotatedTicksLengthModeComboBox->findData( mMapGrid->rotatedTicksLengthMode() ) );
591  mRotatedTicksThresholdSpinBox->setValue( mMapGrid->rotatedTicksMinimumAngle() );
592  mRotatedTicksMarginToCornerSpinBox->setValue( mMapGrid->rotatedTicksMarginToCorner() );
593 
594  mRotatedAnnotationsGroupBox->setChecked( mMapGrid->rotatedAnnotationsEnabled() );
595  mRotatedAnnotationsLengthModeComboBox->setCurrentIndex( mRotatedAnnotationsLengthModeComboBox->findData( mMapGrid->rotatedAnnotationsLengthMode() ) );
596  mRotatedAnnotationsThresholdSpinBox->setValue( mMapGrid->rotatedAnnotationsMinimumAngle() );
597  mRotatedAnnotationsMarginToCornerSpinBox->setValue( mMapGrid->rotatedAnnotationsMarginToCorner() );
598 
599  initFrameDisplayBox( mFrameDivisionsLeftComboBox, mMapGrid->frameDivisions( QgsLayoutItemMapGrid::Left ) );
600  initFrameDisplayBox( mFrameDivisionsRightComboBox, mMapGrid->frameDivisions( QgsLayoutItemMapGrid::Right ) );
601  initFrameDisplayBox( mFrameDivisionsTopComboBox, mMapGrid->frameDivisions( QgsLayoutItemMapGrid::Top ) );
602  initFrameDisplayBox( mFrameDivisionsBottomComboBox, mMapGrid->frameDivisions( QgsLayoutItemMapGrid::Bottom ) );
603 
604  //line style
605  mGridLineStyleButton->setSymbol( mMapGrid->lineSymbol()->clone() );
606  //marker style
607  mGridMarkerStyleButton->setSymbol( mMapGrid->markerSymbol()->clone() );
608 
609  mGridBlendComboBox->setBlendMode( mMapGrid->blendMode() );
610 
611  mDrawAnnotationGroupBox->setChecked( mMapGrid->annotationEnabled() );
612  mAnnotationDisplayLeftComboBox->setCurrentIndex( mAnnotationDisplayLeftComboBox->findData( mMapGrid->annotationDisplay( QgsLayoutItemMapGrid::Left ) ) );
613  mAnnotationDisplayRightComboBox->setCurrentIndex( mAnnotationDisplayRightComboBox->findData( mMapGrid->annotationDisplay( QgsLayoutItemMapGrid::Right ) ) );
614  mAnnotationDisplayTopComboBox->setCurrentIndex( mAnnotationDisplayTopComboBox->findData( mMapGrid->annotationDisplay( QgsLayoutItemMapGrid::Top ) ) );
615  mAnnotationDisplayBottomComboBox->setCurrentIndex( mAnnotationDisplayBottomComboBox->findData( mMapGrid->annotationDisplay( QgsLayoutItemMapGrid::Bottom ) ) );
616 
617  mAnnotationPositionLeftComboBox->setCurrentIndex( mAnnotationPositionLeftComboBox->findData( mMapGrid->annotationPosition( QgsLayoutItemMapGrid::Left ) ) );
618  mAnnotationPositionRightComboBox->setCurrentIndex( mAnnotationPositionRightComboBox->findData( mMapGrid->annotationPosition( QgsLayoutItemMapGrid::Right ) ) );
619  mAnnotationPositionTopComboBox->setCurrentIndex( mAnnotationPositionTopComboBox->findData( mMapGrid->annotationPosition( QgsLayoutItemMapGrid::Top ) ) );
620  mAnnotationPositionBottomComboBox->setCurrentIndex( mAnnotationPositionBottomComboBox->findData( mMapGrid->annotationPosition( QgsLayoutItemMapGrid::Bottom ) ) );
621 
622  initAnnotationDirectionBox( mAnnotationDirectionComboBoxLeft, mMapGrid->annotationDirection( QgsLayoutItemMapGrid::Left ) );
623  initAnnotationDirectionBox( mAnnotationDirectionComboBoxRight, mMapGrid->annotationDirection( QgsLayoutItemMapGrid::Right ) );
624  initAnnotationDirectionBox( mAnnotationDirectionComboBoxTop, mMapGrid->annotationDirection( QgsLayoutItemMapGrid::Top ) );
625  initAnnotationDirectionBox( mAnnotationDirectionComboBoxBottom, mMapGrid->annotationDirection( QgsLayoutItemMapGrid::Bottom ) );
626 
627  mAnnotationFontButton->setDialogTitle( tr( "Grid Annotation Font" ) );
628  mAnnotationFontButton->setMode( QgsFontButton::ModeTextRenderer );
629  mAnnotationFontButton->setTextFormat( mMapGrid->annotationTextFormat() );
630 
631  mAnnotationFormatComboBox->setCurrentIndex( mAnnotationFormatComboBox->findData( mMapGrid->annotationFormat() ) );
632  mAnnotationFormatButton->setEnabled( mMapGrid->annotationFormat() == QgsLayoutItemMapGrid::CustomFormat );
633  mDistanceToMapFrameSpinBox->setValue( mMapGrid->annotationFrameDistance() );
634  mCoordinatePrecisionSpinBox->setValue( mMapGrid->annotationPrecision() );
635 
636  //Unit
637  mMapGridUnitComboBox->setCurrentIndex( mMapGridUnitComboBox->findData( mMapGrid->units() ) );
638  switch ( mMapGrid->units() )
639  {
643  mIntervalStackedWidget->setCurrentIndex( 0 );
644  break;
645 
647  mIntervalStackedWidget->setCurrentIndex( 1 );
648  break;
649  }
650  mMinWidthSpinBox->setValue( mMapGrid->minimumIntervalWidth() );
651  mMaxWidthSpinBox->setValue( mMapGrid->maximumIntervalWidth() );
652 
653  whileBlocking( mMapGridCrsSelector )->setCrs( mMapGrid->crs() );
654 }
655 
656 void QgsLayoutMapGridWidget::mIntervalXSpinBox_editingFinished()
657 {
658  if ( !mMapGrid || !mMap )
659  {
660  return;
661  }
662 
663  mMap->beginCommand( tr( "Change Grid Interval" ) );
664  mMapGrid->setIntervalX( mIntervalXSpinBox->value() );
665  mMap->updateBoundingRect();
666  mMap->update();
667  mMap->endCommand();
668 }
669 
670 void QgsLayoutMapGridWidget::mIntervalYSpinBox_editingFinished()
671 {
672  if ( !mMapGrid || !mMap )
673  {
674  return;
675  }
676 
677  mMap->beginCommand( tr( "Change Grid Interval" ) );
678  mMapGrid->setIntervalY( mIntervalYSpinBox->value() );
679  mMap->updateBoundingRect();
680  mMap->update();
681  mMap->endCommand();
682 }
683 
684 void QgsLayoutMapGridWidget::mOffsetXSpinBox_valueChanged( double value )
685 {
686  if ( !mMapGrid || !mMap )
687  {
688  return;
689  }
690 
691  mMap->beginCommand( tr( "Change Grid Offset" ) );
692  mMapGrid->setOffsetX( value );
693  mMap->updateBoundingRect();
694  mMap->update();
695  mMap->endCommand();
696 }
697 
698 void QgsLayoutMapGridWidget::mOffsetYSpinBox_valueChanged( double value )
699 {
700  if ( !mMapGrid || !mMap )
701  {
702  return;
703  }
704 
705  mMap->beginCommand( tr( "Change Grid Offset" ) );
706  mMapGrid->setOffsetY( value );
707  mMap->updateBoundingRect();
708  mMap->update();
709  mMap->endCommand();
710 }
711 
712 void QgsLayoutMapGridWidget::mCrossWidthSpinBox_valueChanged( double val )
713 {
714  if ( !mMapGrid || !mMap )
715  {
716  return;
717  }
718 
719  mMap->beginCommand( tr( "Change Cross Width" ) );
720  mMapGrid->setCrossLength( val );
721  mMap->update();
722  mMap->endCommand();
723 }
724 
725 void QgsLayoutMapGridWidget::mFrameWidthSpinBox_valueChanged( double val )
726 {
727  if ( !mMapGrid || !mMap )
728  {
729  return;
730  }
731 
732  mMap->beginCommand( tr( "Change Frame Width" ) );
733  mMapGrid->setFrameWidth( val );
734  mMap->updateBoundingRect();
735  mMap->update();
736  mMap->endCommand();
737 }
738 
739 void QgsLayoutMapGridWidget::mGridFrameMarginSpinBox_valueChanged( double val )
740 {
741  if ( !mMapGrid || !mMap )
742  {
743  return;
744  }
745 
746  mMap->beginCommand( tr( "Change Grid Frame Margin" ) );
747  mMapGrid->setFrameMargin( val );
748  mMap->updateBoundingRect();
749  mMap->update();
750  mMap->endCommand();
751 }
752 
753 void QgsLayoutMapGridWidget::mCheckGridLeftSide_toggled( bool checked )
754 {
755  if ( !mMapGrid || !mMap )
756  {
757  return;
758  }
759 
760  mMap->beginCommand( tr( "Change Frame Left" ) );
761  mMapGrid->setFrameSideFlag( QgsLayoutItemMapGrid::FrameLeft, checked );
762  mMap->updateBoundingRect();
763  mMap->update();
764  mMap->endCommand();
765 }
766 
767 void QgsLayoutMapGridWidget::mCheckGridRightSide_toggled( bool checked )
768 {
769  if ( !mMapGrid || !mMap )
770  {
771  return;
772  }
773 
774  mMap->beginCommand( tr( "Change Frame Right" ) );
775  mMapGrid->setFrameSideFlag( QgsLayoutItemMapGrid::FrameRight, checked );
776  mMap->updateBoundingRect();
777  mMap->update();
778  mMap->endCommand();
779 }
780 
781 void QgsLayoutMapGridWidget::mCheckGridTopSide_toggled( bool checked )
782 {
783  if ( !mMapGrid || !mMap )
784  {
785  return;
786  }
787 
788  mMap->beginCommand( tr( "Change Frame Top" ) );
789  mMapGrid->setFrameSideFlag( QgsLayoutItemMapGrid::FrameTop, checked );
790  mMap->updateBoundingRect();
791  mMap->update();
792  mMap->endCommand();
793 }
794 
795 void QgsLayoutMapGridWidget::mCheckGridBottomSide_toggled( bool checked )
796 {
797  if ( !mMapGrid || !mMap )
798  {
799  return;
800  }
801 
802  mMap->beginCommand( tr( "Change Frame Bottom" ) );
803  mMapGrid->setFrameSideFlag( QgsLayoutItemMapGrid::FrameBottom, checked );
804  mMap->updateBoundingRect();
805  mMap->update();
806  mMap->endCommand();
807 }
808 
809 void QgsLayoutMapGridWidget::mFrameDivisionsLeftComboBox_currentIndexChanged( int index )
810 {
811  handleChangedFrameDisplay( QgsLayoutItemMapGrid::Left, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mFrameDivisionsLeftComboBox->itemData( index ).toInt() ) );
812 }
813 
814 void QgsLayoutMapGridWidget::mFrameDivisionsRightComboBox_currentIndexChanged( int index )
815 {
816  handleChangedFrameDisplay( QgsLayoutItemMapGrid::Right, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mFrameDivisionsRightComboBox->itemData( index ).toInt() ) );
817 }
818 
819 void QgsLayoutMapGridWidget::mFrameDivisionsTopComboBox_currentIndexChanged( int index )
820 {
821  handleChangedFrameDisplay( QgsLayoutItemMapGrid::Top, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mFrameDivisionsTopComboBox->itemData( index ).toInt() ) );
822 }
823 
824 void QgsLayoutMapGridWidget::mFrameDivisionsBottomComboBox_currentIndexChanged( int index )
825 {
826  handleChangedFrameDisplay( QgsLayoutItemMapGrid::Bottom, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mFrameDivisionsBottomComboBox->itemData( index ).toInt() ) );
827 }
828 
829 void QgsLayoutMapGridWidget::mGridFramePenSizeSpinBox_valueChanged( double d )
830 {
831  if ( !mMapGrid || !mMap )
832  {
833  return;
834  }
835 
836  mMap->beginCommand( tr( "Change Frame Thickness" ) );
837  mMapGrid->setFramePenSize( d );
838  mMap->updateBoundingRect();
839  mMap->update();
840  mMap->endCommand();
841 }
842 
843 void QgsLayoutMapGridWidget::mGridFramePenColorButton_colorChanged( const QColor &newColor )
844 {
845  if ( !mMapGrid || !mMap )
846  {
847  return;
848  }
849 
850  mMap->beginCommand( tr( "Change Frame Color" ), QgsLayoutItem::UndoGridFramePenColor );
851  mMapGrid->setFramePenColor( newColor );
852  mMap->update();
853  mMap->endCommand();
854 }
855 
856 void QgsLayoutMapGridWidget::mGridFrameFill1ColorButton_colorChanged( const QColor &newColor )
857 {
858  if ( !mMapGrid || !mMap )
859  {
860  return;
861  }
862 
863  mMap->beginCommand( tr( "Change Frame Fill Color" ), QgsLayoutItem::UndoMapGridFrameFill1Color );
864  mMapGrid->setFrameFillColor1( newColor );
865  mMap->update();
866  mMap->endCommand();
867 }
868 
869 void QgsLayoutMapGridWidget::mGridFrameFill2ColorButton_colorChanged( const QColor &newColor )
870 {
871  if ( !mMapGrid || !mMap )
872  {
873  return;
874  }
875 
876  mMap->beginCommand( tr( "Change Frame Fill Color" ), QgsLayoutItem::UndoMapGridFrameFill2Color );
877  mMapGrid->setFrameFillColor2( newColor );
878  mMap->update();
879  mMap->endCommand();
880 }
881 
882 void QgsLayoutMapGridWidget::mFrameStyleComboBox_currentIndexChanged( int )
883 {
884  if ( !mMapGrid || !mMap )
885  {
886  return;
887  }
888 
889  QgsLayoutItemMapGrid::FrameStyle style = static_cast< QgsLayoutItemMapGrid::FrameStyle >( mFrameStyleComboBox->currentData().toInt() );
890  mMap->beginCommand( tr( "Change Frame Style" ) );
891  mMapGrid->setFrameStyle( style );
892  switch ( style )
893  {
896  toggleFrameControls( true, true, true, false );
897  break;
901  toggleFrameControls( true, false, true, true );
902  break;
905  toggleFrameControls( true, false, false, false );
906  break;
908  toggleFrameControls( false, false, false, false );
909  break;
910  }
911  mMap->updateBoundingRect();
912  mMap->update();
913  mMap->endCommand();
914 }
915 
916 void QgsLayoutMapGridWidget::mRotatedTicksGroupBox_toggled( bool state )
917 {
918  if ( !mMapGrid || !mMap )
919  {
920  return;
921  }
922 
923  mMap->beginCommand( tr( "Change Tick Rotation Enabled" ) );
924  mMapGrid->setRotatedTicksEnabled( state );
925  mMap->update();
926  mMap->endCommand();
927 }
928 
929 void QgsLayoutMapGridWidget::mRotatedTicksLengthModeComboBox_currentIndexChanged( int )
930 {
931  if ( !mMapGrid || !mMap )
932  {
933  return;
934  }
935 
936  QgsLayoutItemMapGrid::TickLengthMode mode = static_cast< QgsLayoutItemMapGrid::TickLengthMode >( mRotatedTicksLengthModeComboBox->currentData().toInt() );
937  mMap->beginCommand( tr( "Change Tick Length Mode" ) );
938  mMapGrid->setRotatedTicksLengthMode( mode );
939  mMap->update();
940  mMap->endCommand();
941 }
942 
943 void QgsLayoutMapGridWidget::mRotatedTicksThresholdSpinBox_valueChanged( double val )
944 {
945  if ( !mMapGrid || !mMap )
946  {
947  return;
948  }
949 
950  mMap->beginCommand( tr( "Change Rotated Ticks Threshold" ) );
951  mMapGrid->setRotatedTicksMinimumAngle( val );
952  mMap->update();
953  mMap->endCommand();
954 }
955 
956 void QgsLayoutMapGridWidget::mRotatedTicksMarginToCornerSpinBox_valueChanged( double val )
957 {
958  if ( !mMapGrid || !mMap )
959  {
960  return;
961  }
962 
963  mMap->beginCommand( tr( "Change Rotated Ticks Margin to Corner" ) );
964  mMapGrid->setRotatedTicksMarginToCorner( val );
965  mMap->update();
966  mMap->endCommand();
967 }
968 
969 void QgsLayoutMapGridWidget::mRotatedAnnotationsGroupBox_toggled( bool state )
970 {
971  if ( !mMapGrid || !mMap )
972  {
973  return;
974  }
975 
976  mMap->beginCommand( tr( "Change Annotation Rotation Enabled" ) );
977  mMapGrid->setRotatedAnnotationsEnabled( state );
978  mMap->update();
979  mMap->endCommand();
980 }
981 
982 void QgsLayoutMapGridWidget::mRotatedAnnotationsLengthModeComboBox_currentIndexChanged( int )
983 {
984  if ( !mMapGrid || !mMap )
985  {
986  return;
987  }
988 
989  QgsLayoutItemMapGrid::TickLengthMode mode = static_cast< QgsLayoutItemMapGrid::TickLengthMode >( mRotatedAnnotationsLengthModeComboBox->currentData().toInt() );
990  mMap->beginCommand( tr( "Change Annotation Length Mode" ) );
991  mMapGrid->setRotatedAnnotationsLengthMode( mode );
992  mMap->update();
993  mMap->endCommand();
994 }
995 
996 void QgsLayoutMapGridWidget::mRotatedAnnotationsThresholdSpinBox_valueChanged( double val )
997 {
998  if ( !mMapGrid || !mMap )
999  {
1000  return;
1001  }
1002 
1003  mMap->beginCommand( tr( "Change Rotated Annotations Threshold" ) );
1004  mMapGrid->setRotatedAnnotationsMinimumAngle( val );
1005  mMap->update();
1006  mMap->endCommand();
1007 }
1008 
1009 void QgsLayoutMapGridWidget::mRotatedAnnotationsMarginToCornerSpinBox_valueChanged( double val )
1010 {
1011  if ( !mMapGrid || !mMap )
1012  {
1013  return;
1014  }
1015 
1016  mMap->beginCommand( tr( "Change Rotated Annotations Margin to Corner" ) );
1017  mMapGrid->setRotatedAnnotationsMarginToCorner( val );
1018  mMap->update();
1019  mMap->endCommand();
1020 }
1021 
1022 void QgsLayoutMapGridWidget::intervalUnitChanged( int )
1023 {
1024  if ( !mMapGrid || !mMap )
1025  {
1026  return;
1027  }
1028 
1029  const QgsLayoutItemMapGrid::GridUnit unit = static_cast< QgsLayoutItemMapGrid::GridUnit >( mMapGridUnitComboBox->currentData().toInt() );
1030  switch ( unit )
1031  {
1035  mIntervalStackedWidget->setCurrentIndex( 0 );
1036  break;
1037 
1039  mIntervalStackedWidget->setCurrentIndex( 1 );
1040  break;
1041  }
1042 
1043  mMap->beginCommand( tr( "Change Grid Unit" ) );
1044  mMapGrid->setUnits( unit );
1045  mMap->updateBoundingRect();
1046  mMap->update();
1047  mMap->endCommand();
1048 }
1049 
1050 void QgsLayoutMapGridWidget::minIntervalChanged( double interval )
1051 {
1052  mMap->beginCommand( tr( "Change Grid Interval Range" ), QgsLayoutItem::UndoMapGridIntervalRange );
1053  mMapGrid->setMinimumIntervalWidth( interval );
1054  mMap->endCommand();
1055  mMap->updateBoundingRect();
1056  mMap->update();
1057 }
1058 
1059 void QgsLayoutMapGridWidget::maxIntervalChanged( double interval )
1060 {
1061  mMap->beginCommand( tr( "Change Grid Interval Range" ), QgsLayoutItem::UndoMapGridIntervalRange );
1062  mMapGrid->setMaximumIntervalWidth( interval );
1063  mMap->endCommand();
1064  mMap->updateBoundingRect();
1065  mMap->update();
1066 }
1067 
1068 void QgsLayoutMapGridWidget::annotationTextFormatChanged()
1069 {
1070  if ( !mMapGrid || !mMap )
1071  {
1072  return;
1073  }
1074 
1075  mMap->beginCommand( tr( "Change Annotation Font" ) );
1076  mMapGrid->setAnnotationTextFormat( mAnnotationFontButton->textFormat() );
1077  mMap->endCommand();
1078  mMap->updateBoundingRect();
1079  mMap->update();
1080 }
1081 
1082 void QgsLayoutMapGridWidget::mGridBlendComboBox_currentIndexChanged( int index )
1083 {
1084  Q_UNUSED( index )
1085  if ( mMapGrid )
1086  {
1087  mMap->beginCommand( tr( "Change Grid Blend Mode" ) );
1088  mMapGrid->setBlendMode( mGridBlendComboBox->blendMode() );
1089  mMap->update();
1090  mMap->endCommand();
1091  }
1092 
1093 }
1094 
1095 void QgsLayoutMapGridWidget::mGridTypeComboBox_currentIndexChanged( int )
1096 {
1097  if ( !mMapGrid || !mMap )
1098  {
1099  return;
1100  }
1101 
1102  mMap->beginCommand( tr( "Change Grid Type" ) );
1103  switch ( static_cast< QgsLayoutItemMapGrid::GridStyle >( mGridTypeComboBox->currentData().toInt() ) )
1104  {
1106  mMapGrid->setStyle( QgsLayoutItemMapGrid::Cross );
1107  mCrossWidthSpinBox->setVisible( true );
1108  mCrossWidthDDBtn->setVisible( true );
1109  mCrossWidthLabel->setVisible( true );
1110  mGridLineStyleButton->setVisible( true );
1111  mLineStyleLabel->setVisible( true );
1112  mGridMarkerStyleButton->setVisible( false );
1113  mMarkerStyleLabel->setVisible( false );
1114  mGridBlendComboBox->setVisible( true );
1115  mGridBlendLabel->setVisible( true );
1116  break;
1117 
1119  mMapGrid->setStyle( QgsLayoutItemMapGrid::Markers );
1120  mCrossWidthSpinBox->setVisible( false );
1121  mCrossWidthDDBtn->setVisible( false );
1122  mCrossWidthLabel->setVisible( false );
1123  mGridLineStyleButton->setVisible( false );
1124  mLineStyleLabel->setVisible( false );
1125  mGridMarkerStyleButton->setVisible( true );
1126  mMarkerStyleLabel->setVisible( true );
1127  mGridBlendComboBox->setVisible( true );
1128  mGridBlendLabel->setVisible( true );
1129  break;
1130 
1132  mMapGrid->setStyle( QgsLayoutItemMapGrid::Solid );
1133  mCrossWidthSpinBox->setVisible( false );
1134  mCrossWidthDDBtn->setVisible( false );
1135  mCrossWidthLabel->setVisible( false );
1136  mGridLineStyleButton->setVisible( true );
1137  mLineStyleLabel->setVisible( true );
1138  mGridMarkerStyleButton->setVisible( false );
1139  mMarkerStyleLabel->setVisible( false );
1140  mGridBlendComboBox->setVisible( true );
1141  mGridBlendLabel->setVisible( true );
1142  break;
1143 
1145  mMapGrid->setStyle( QgsLayoutItemMapGrid::FrameAnnotationsOnly );
1146  mCrossWidthSpinBox->setVisible( false );
1147  mCrossWidthDDBtn->setVisible( false );
1148  mCrossWidthLabel->setVisible( false );
1149  mGridLineStyleButton->setVisible( false );
1150  mLineStyleLabel->setVisible( false );
1151  mGridMarkerStyleButton->setVisible( false );
1152  mMarkerStyleLabel->setVisible( false );
1153  mGridBlendComboBox->setVisible( false );
1154  mGridBlendLabel->setVisible( false );
1155  break;
1156  }
1157 
1158  mMap->updateBoundingRect();
1159  mMap->update();
1160  mMap->endCommand();
1161 }
1162 
1163 void QgsLayoutMapGridWidget::mapGridCrsChanged( const QgsCoordinateReferenceSystem &crs )
1164 {
1165  if ( !mMapGrid || !mMap )
1166  {
1167  return;
1168  }
1169 
1170  if ( mMapGrid->crs() == crs )
1171  return;
1172 
1173  mMap->beginCommand( tr( "Change Grid CRS" ) );
1174  mMapGrid->setCrs( crs );
1175  mMap->updateBoundingRect();
1176  mMap->update();
1177  mMap->endCommand();
1178 }
1179 
1180 void QgsLayoutMapGridWidget::mDrawAnnotationGroupBox_toggled( bool state )
1181 {
1182  if ( !mMapGrid || !mMap )
1183  {
1184  return;
1185  }
1186 
1187  mMap->beginCommand( tr( "Toggle Annotations" ) );
1188  mMapGrid->setAnnotationEnabled( state );
1189  mMap->updateBoundingRect();
1190  mMap->update();
1191  mMap->endCommand();
1192 }
1193 
1194 void QgsLayoutMapGridWidget::mAnnotationFormatButton_clicked()
1195 {
1196  if ( !mMapGrid || !mMap )
1197  {
1198  return;
1199  }
1200 
1201  QgsExpressionContext expressionContext = mMapGrid->createExpressionContext();
1202  expressionContext.setHighlightedFunctions( QStringList() << QStringLiteral( "to_dms" ) << QStringLiteral( "to_dm" ) );
1203 
1204  QgsExpressionBuilderDialog exprDlg( nullptr, mMapGrid->annotationExpression(), this, QStringLiteral( "generic" ), expressionContext );
1205  exprDlg.setWindowTitle( tr( "Expression Based Annotation" ) );
1206 
1207  if ( exprDlg.exec() == QDialog::Accepted )
1208  {
1209  QString expression = exprDlg.expressionText();
1210  mMap->beginCommand( tr( "Change Annotation Format" ) );
1211  mMapGrid->setAnnotationExpression( expression );
1212  mMap->updateBoundingRect();
1213  mMap->update();
1214  mMap->endCommand();
1215  }
1216 }
1217 
1218 void QgsLayoutMapGridWidget::mAnnotationDisplayLeftComboBox_currentIndexChanged( int )
1219 {
1220  handleChangedAnnotationDisplay( QgsLayoutItemMapGrid::Left, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mAnnotationDisplayLeftComboBox->currentData().toInt() ) );
1221 }
1222 
1223 void QgsLayoutMapGridWidget::mAnnotationDisplayRightComboBox_currentIndexChanged( int )
1224 {
1225  handleChangedAnnotationDisplay( QgsLayoutItemMapGrid::Right, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mAnnotationDisplayRightComboBox->currentData().toInt() ) );
1226 }
1227 
1228 void QgsLayoutMapGridWidget::mAnnotationDisplayTopComboBox_currentIndexChanged( int )
1229 {
1230  handleChangedAnnotationDisplay( QgsLayoutItemMapGrid::Top, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mAnnotationDisplayTopComboBox->currentData().toInt() ) );
1231 }
1232 
1233 void QgsLayoutMapGridWidget::mAnnotationDisplayBottomComboBox_currentIndexChanged( int )
1234 {
1235  handleChangedAnnotationDisplay( QgsLayoutItemMapGrid::Bottom, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mAnnotationDisplayBottomComboBox->currentData().toInt() ) );
1236 }
1237 
1238 void QgsLayoutMapGridWidget::mAnnotationPositionLeftComboBox_currentIndexChanged( int )
1239 {
1240  handleChangedAnnotationPosition( QgsLayoutItemMapGrid::Left, static_cast< QgsLayoutItemMapGrid::AnnotationPosition >( mAnnotationPositionLeftComboBox->currentData().toInt() ) );
1241 }
1242 
1243 void QgsLayoutMapGridWidget::mAnnotationPositionRightComboBox_currentIndexChanged( int )
1244 {
1245  handleChangedAnnotationPosition( QgsLayoutItemMapGrid::Right, static_cast< QgsLayoutItemMapGrid::AnnotationPosition >( mAnnotationPositionRightComboBox->currentData().toInt() ) );
1246 }
1247 
1248 void QgsLayoutMapGridWidget::mAnnotationPositionTopComboBox_currentIndexChanged( int )
1249 {
1250  handleChangedAnnotationPosition( QgsLayoutItemMapGrid::Top, static_cast< QgsLayoutItemMapGrid::AnnotationPosition >( mAnnotationPositionTopComboBox->currentData().toInt() ) );
1251 }
1252 
1253 void QgsLayoutMapGridWidget::mAnnotationPositionBottomComboBox_currentIndexChanged( int )
1254 {
1255  handleChangedAnnotationPosition( QgsLayoutItemMapGrid::Bottom, static_cast< QgsLayoutItemMapGrid::AnnotationPosition >( mAnnotationPositionBottomComboBox->currentData().toInt() ) );
1256 }
1257 
1258 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxLeft_currentIndexChanged( int index )
1259 {
1260  handleChangedAnnotationDirection( QgsLayoutItemMapGrid::Left, static_cast< QgsLayoutItemMapGrid::AnnotationDirection >( mAnnotationDirectionComboBoxLeft->itemData( index ).toInt() ) );
1261 }
1262 
1263 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxRight_currentIndexChanged( int index )
1264 {
1265  handleChangedAnnotationDirection( QgsLayoutItemMapGrid::Right, static_cast< QgsLayoutItemMapGrid::AnnotationDirection >( mAnnotationDirectionComboBoxRight->itemData( index ).toInt() ) );
1266 }
1267 
1268 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxTop_currentIndexChanged( int index )
1269 {
1270  handleChangedAnnotationDirection( QgsLayoutItemMapGrid::Top, static_cast< QgsLayoutItemMapGrid::AnnotationDirection >( mAnnotationDirectionComboBoxTop->itemData( index ).toInt() ) );
1271 }
1272 
1273 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxBottom_currentIndexChanged( int index )
1274 {
1275  handleChangedAnnotationDirection( QgsLayoutItemMapGrid::Bottom, static_cast< QgsLayoutItemMapGrid::AnnotationDirection >( mAnnotationDirectionComboBoxBottom->itemData( index ).toInt() ) );
1276 }
1277 
1278 void QgsLayoutMapGridWidget::mDistanceToMapFrameSpinBox_valueChanged( double d )
1279 {
1280  if ( !mMapGrid || !mMap )
1281  {
1282  return;
1283  }
1284 
1285  mMap->beginCommand( tr( "Change Annotation Distance" ), QgsLayoutItem::UndoMapAnnotationDistance );
1286  mMapGrid->setAnnotationFrameDistance( d );
1287  mMap->updateBoundingRect();
1288  mMap->update();
1289  mMap->endCommand();
1290 }
1291 
1292 void QgsLayoutMapGridWidget::lineSymbolChanged()
1293 {
1294  if ( !mMapGrid || !mMap )
1295  {
1296  return;
1297  }
1298 
1299  mMap->beginCommand( tr( "Change Grid Line Style" ), QgsLayoutItem::UndoMapGridLineSymbol );
1300  mMapGrid->setLineSymbol( mGridLineStyleButton->clonedSymbol<QgsLineSymbol>() );
1301  mMap->endCommand();
1302  mMap->update();
1303 }
1304 
1305 void QgsLayoutMapGridWidget::markerSymbolChanged()
1306 {
1307  if ( !mMapGrid || !mMap )
1308  {
1309  return;
1310  }
1311 
1312  mMap->beginCommand( tr( "Change Grid Marker Style" ), QgsLayoutItem::UndoMapGridMarkerSymbol );
1313  mMapGrid->setMarkerSymbol( mGridMarkerStyleButton->clonedSymbol<QgsMarkerSymbol>() );
1314  mMap->endCommand();
1315  mMap->update();
1316 }
1317 
1318 void QgsLayoutMapGridWidget::gridEnabledToggled( bool active )
1319 {
1320  if ( !mMapGrid || !mMap )
1321  {
1322  return;
1323  }
1324 
1325  mMap->beginCommand( tr( "Toggle Grid Display" ) );
1326  mMapGrid->setEnabled( active );
1327  mMap->endCommand();
1328  mMap->updateBoundingRect();
1329  mMap->update();
1330 }
1331 
1332 void QgsLayoutMapGridWidget::mAnnotationFormatComboBox_currentIndexChanged( int index )
1333 {
1334  if ( !mMapGrid || !mMap )
1335  {
1336  return;
1337  }
1338 
1339  mMap->beginCommand( tr( "Change Annotation Format" ) );
1340 
1341  mMapGrid->setAnnotationFormat( static_cast< QgsLayoutItemMapGrid::AnnotationFormat >( mAnnotationFormatComboBox->itemData( index ).toInt() ) );
1342  mAnnotationFormatButton->setEnabled( mMapGrid->annotationFormat() == QgsLayoutItemMapGrid::CustomFormat );
1343 
1344  mMap->updateBoundingRect();
1345  mMap->update();
1346  mMap->endCommand();
1347 }
1348 
1349 void QgsLayoutMapGridWidget::mCoordinatePrecisionSpinBox_valueChanged( int value )
1350 {
1351  if ( !mMapGrid || !mMap )
1352  {
1353  return;
1354  }
1355  mMap->beginCommand( tr( "Change Annotation Precision" ) );
1356  mMapGrid->setAnnotationPrecision( value );
1357  mMap->updateBoundingRect();
1358  mMap->update();
1359  mMap->endCommand();
1360 }
QgsLayoutItemMapGrid::TickLengthMode
TickLengthMode
Tick length mode (useful for rotated grids)
Definition: qgslayoutitemmapgrid.h:249
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:370
QgsLayoutItemBaseWidget::updateDataDefinedButton
void updateDataDefinedButton(QgsPropertyOverrideButton *button)
Updates a previously registered data defined button to reflect the item's current properties.
Definition: qgslayoutitemwidget.cpp:212
QgsLayoutObject::MapGridAnnotationDisplayTop
@ MapGridAnnotationDisplayTop
Map annotation display top.
Definition: qgslayoutobject.h:179
QgsLayoutItemMapGrid::FrameRight
@ FrameRight
Right side of map.
Definition: qgslayoutitemmapgrid.h:260
QgsLayoutItemMapGrid::Zebra
@ Zebra
Black/white pattern.
Definition: qgslayoutitemmapgrid.h:236
QgsLayoutItemMapGrid
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
Definition: qgslayoutitemmapgrid.h:141
QgsLayoutItemMapGrid::InteriorTicks
@ InteriorTicks
Tick markers drawn inside map frame.
Definition: qgslayoutitemmapgrid.h:237
QgsLayoutObject::MapGridFrameLineThickness
@ MapGridFrameLineThickness
Map grid frame line thickness.
Definition: qgslayoutobject.h:176
QgsLayoutItemMapGrid::VerticalDescending
@ VerticalDescending
Draw annotations vertically, descending.
Definition: qgslayoutitemmapgrid.h:196
QgsLayoutItemMapGrid::LongitudeOnly
@ LongitudeOnly
Show longitude/x annotations/divisions only.
Definition: qgslayoutitemmapgrid.h:176
QgsSymbolButton::changed
void changed()
Emitted when the symbol's settings are changed.
QgsSettings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Definition: qgssettings.cpp:174
QgsLayoutItemMapGrid::DynamicPageSizeBased
@ DynamicPageSizeBased
Dynamically sized, based on a on-page size range.
Definition: qgslayoutitemmapgrid.h:155
qgslayoutmapgridwidget.h
QgsLayoutItemMapGrid::OutsideMapFrame
@ OutsideMapFrame
Draw annotations outside the map frame.
Definition: qgslayoutitemmapgrid.h:186
QgsLayoutItemMapGrid::FrameLeft
@ FrameLeft
Left side of map.
Definition: qgslayoutitemmapgrid.h:259
Qgis::defaultProjectScales
static QString defaultProjectScales()
A string with default project scales.
Definition: qgis.cpp:270
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:51
QgsLayoutItemMapGrid::ExteriorTicks
@ ExteriorTicks
Tick markers drawn outside map frame.
Definition: qgslayoutitemmapgrid.h:238
QgsLayoutItemMapGrid::ShowAll
@ ShowAll
Show both latitude and longitude annotations/divisions.
Definition: qgslayoutitemmapgrid.h:174
qgssymbollayerutils.h
QgsProjectionSelectionWidget::crsChanged
void crsChanged(const QgsCoordinateReferenceSystem &)
Emitted when the selected CRS is changed.
QgsLayoutObject::MapGridAnnotationDisplayLeft
@ MapGridAnnotationDisplayLeft
Map annotation display left.
Definition: qgslayoutobject.h:177
QgsLayoutItemBaseWidget::registerDataDefinedButton
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsLayoutObject::DataDefinedProperty property)
Registers a data defined button, setting up its initial value, connections and description.
Definition: qgslayoutitemwidget.cpp:207
QgsLayoutItemMapGrid::CustomFormat
@ CustomFormat
Custom expression-based format.
Definition: qgslayoutitemmapgrid.h:216
QgsLayoutItemMapGrid::GridStyle
GridStyle
Grid drawing style.
Definition: qgslayoutitemmapgrid.h:162
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:468
QgsSettings
This class is a composition of two QSettings instances:
Definition: qgssettings.h:62
QgsLayoutItemMapGrid::ZebraNautical
@ ZebraNautical
Black/white pattern, with nautical style diagonals on corners.
Definition: qgslayoutitemmapgrid.h:242
QgsLayoutItemMapGrid::DegreeMinutePadded
@ DegreeMinutePadded
Degree/minutes, with minutes using leading zeros where required.
Definition: qgslayoutitemmapgrid.h:213
QgsLayoutItemMapGrid::CM
@ CM
Grid units in centimeters.
Definition: qgslayoutitemmapgrid.h:154
qgsmapsettings.h
QgsLayoutItemMapGrid::DisplayMode
DisplayMode
Display settings for grid annotations and frames.
Definition: qgslayoutitemmapgrid.h:173
QgsLayoutItemMapGrid::BoundaryDirection
@ BoundaryDirection
Annotations follow the boundary direction.
Definition: qgslayoutitemmapgrid.h:197
QgsLayoutObject::MapGridOffsetY
@ MapGridOffsetY
Map grid offset Y.
Definition: qgslayoutobject.h:171
QgsLayoutItemMapGrid::InteriorExteriorTicks
@ InteriorExteriorTicks
Tick markers drawn both inside and outside the map frame.
Definition: qgslayoutitemmapgrid.h:239
QgsLayoutItemBaseWidget::coverageLayer
QgsVectorLayer * coverageLayer() const
Returns the current layout context coverage layer (if set).
Definition: qgslayoutitemwidget.cpp:217
QgsColorButton::colorChanged
void colorChanged(const QColor &color)
Emitted whenever a new color is set for the button.
QgsLayoutItemMapGrid::LatitudeOnly
@ LatitudeOnly
Show latitude/y annotations/divisions only.
Definition: qgslayoutitemmapgrid.h:175
QgsLayoutItemMapGrid::FrameBottom
@ FrameBottom
Bottom side of map.
Definition: qgslayoutitemmapgrid.h:262
QgsLayoutObject::MapGridFrameDivisionsTop
@ MapGridFrameDivisionsTop
Map frame division display top.
Definition: qgslayoutobject.h:183
QgsLayoutItem::UndoMapGridIntervalRange
@ UndoMapGridIntervalRange
Grid interval range.
Definition: qgslayoutitem.h:240
QgsLayoutItemMapGrid::NormalizedTicks
@ NormalizedTicks
Constant tick lengths.
Definition: qgslayoutitemmapgrid.h:251
qgsprojectionselectiondialog.h
QgsLayoutItem::UndoMapAnnotationDistance
@ UndoMapAnnotationDistance
Map frame annotation distance.
Definition: qgslayoutitem.h:236
QgsLayoutItemMapGrid::FrameTop
@ FrameTop
Top side of map.
Definition: qgslayoutitemmapgrid.h:261
QgsLayoutItem::UndoGridFramePenColor
@ UndoGridFramePenColor
Map grid frame pen color.
Definition: qgslayoutitem.h:233
QgsLayoutObject::MapGridFrameMargin
@ MapGridFrameMargin
Map grid frame margin.
Definition: qgslayoutobject.h:173
qgstextformatwidget.h
QgsExpressionContext::setHighlightedFunctions
void setHighlightedFunctions(const QStringList &names)
Sets the list of function names intended to be highlighted to the user.
Definition: qgsexpressioncontext.cpp:334
QgsLayoutObject::MapGridAnnotationDisplayBottom
@ MapGridAnnotationDisplayBottom
Map annotation display bottom.
Definition: qgslayoutobject.h:180
whileBlocking
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:262
QgsLayoutItemMapGrid::GridUnit
GridUnit
Unit for grid values.
Definition: qgslayoutitemmapgrid.h:151
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:931
QgsLayoutItemMapGrid::AnnotationDirection
AnnotationDirection
Direction of grid annotations.
Definition: qgslayoutitemmapgrid.h:193
QgsLayoutObject::MapGridIntervalX
@ MapGridIntervalX
Map grid interval X.
Definition: qgslayoutobject.h:168
QgsLayoutMapGridWidget::QgsLayoutMapGridWidget
QgsLayoutMapGridWidget(QgsLayoutItemMapGrid *mapGrid, QgsLayoutItemMap *map)
constructor
Definition: qgslayoutmapgridwidget.cpp:34
QgsExpressionBuilderDialog
A generic dialog for building expression strings.
Definition: qgsexpressionbuilderdialog.h:31
QgsLayoutItemMapGrid::MapUnit
@ MapUnit
Grid units follow map units.
Definition: qgslayoutitemmapgrid.h:152
QgsLayoutObject::MapGridCrossSize
@ MapGridCrossSize
Map grid cross size.
Definition: qgslayoutobject.h:175
QgsLayoutItemMapGrid::LineBorderNautical
@ LineBorderNautical
Simple solid line frame, with nautical style diagonals on corners.
Definition: qgslayoutitemmapgrid.h:241
QgsLayoutItemMapGrid::DegreeMinuteSecondPadded
@ DegreeMinuteSecondPadded
Degree/minutes/seconds, with minutes using leading zeros where required.
Definition: qgslayoutitemmapgrid.h:215
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgssymbol.h:1131
QgsLayoutItemMapGrid::Right
@ Right
Right border.
Definition: qgslayoutitemmapgrid.h:225
QgsLayoutObject::MapGridOffsetX
@ MapGridOffsetX
Map grid offset X.
Definition: qgslayoutobject.h:170
QgsLayoutItemMapGrid::AnnotationPosition
AnnotationPosition
Position for grid annotations.
Definition: qgslayoutitemmapgrid.h:184
QgsLayoutItem::UndoMapGridMarkerSymbol
@ UndoMapGridMarkerSymbol
Grid marker symbol.
Definition: qgslayoutitem.h:239
QgsLayoutItemMapGrid::BorderSide
BorderSide
Border sides for annotations.
Definition: qgslayoutitemmapgrid.h:223
QgsPanelWidget::setPanelTitle
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
Definition: qgspanelwidget.h:44
qgslayout.h
QgsProjectionSelectionWidget::CrsNotSet
@ CrsNotSet
Not set (hidden by default)
Definition: qgsprojectionselectionwidget.h:53
QgsLayoutItemMapGrid::FrameAnnotationsOnly
@ FrameAnnotationsOnly
No grid lines over the map, only draw frame and annotations.
Definition: qgslayoutitemmapgrid.h:166
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsLayoutItem::UndoMapGridLineSymbol
@ UndoMapGridLineSymbol
Grid line symbol.
Definition: qgslayoutitem.h:238
QgsLayoutItemMapGrid::Solid
@ Solid
Definition: qgslayoutitemmapgrid.h:163
QgsLayoutItemMapGrid::Bottom
@ Bottom
Bottom border.
Definition: qgslayoutitemmapgrid.h:226
qgssymbolselectordialog.h
qgsstyle.h
QgsLayoutItemBaseWidget
A base class for property widgets for layout items.
Definition: qgslayoutitemwidget.h:123
QgsLayoutObject::MapGridEnabled
@ MapGridEnabled
Map grid enabled.
Definition: qgslayoutobject.h:167
qgsvectorlayer.h
QgsLayoutItemMapGrid::Cross
@ Cross
Draw line crosses at intersections of grid lines.
Definition: qgslayoutitemmapgrid.h:164
QgsLayoutItemMap
Layout graphical items for displaying a map.
Definition: qgslayoutitemmap.h:318
QgsLayoutItemMapGrid::Horizontal
@ Horizontal
Draw annotations horizontally.
Definition: qgslayoutitemmapgrid.h:194
qgsprojectviewsettings.h
QgsLayoutMapGridWidget::updateGuiElements
virtual void updateGuiElements()
Sets the current composer map values to the GUI elements.
Definition: qgslayoutmapgridwidget.cpp:252
QgsFontButton::ModeTextRenderer
@ ModeTextRenderer
Configure font settings for use with QgsTextRenderer.
Definition: qgsfontbutton.h:60
QgsLayoutItemMapGrid::Vertical
@ Vertical
Draw annotations vertically, ascending.
Definition: qgslayoutitemmapgrid.h:195
QgsLayoutItemMapGrid::InsideMapFrame
@ InsideMapFrame
Draw annotations inside the map frame.
Definition: qgslayoutitemmapgrid.h:185
QgsSymbolButton::setLayer
void setLayer(QgsVectorLayer *layer)
Sets a layer to associate with the widget.
Definition: qgssymbolbutton.cpp:180
c
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Definition: porting_processing.dox:1
QgsProjectViewSettings::mapScales
QVector< double > mapScales() const
Returns the list of custom project map scales.
Definition: qgsprojectviewsettings.cpp:61
QgsLayoutItemMapGrid::DegreeMinute
@ DegreeMinute
Degree/minutes, use NSEW suffix.
Definition: qgslayoutitemmapgrid.h:209
QgsLayoutItemMapGrid::DecimalWithSuffix
@ DecimalWithSuffix
Decimal degrees, use NSEW suffix.
Definition: qgslayoutitemmapgrid.h:211
QgsLayoutItemMapGrid::DegreeMinuteNoSuffix
@ DegreeMinuteNoSuffix
Degree/minutes, use - for S/W coordinates.
Definition: qgslayoutitemmapgrid.h:212
QgsLayoutObject::MapGridLabelDistance
@ MapGridLabelDistance
Map grid label distance.
Definition: qgslayoutobject.h:174
QgsLayoutItemMapGrid::DegreeMinuteSecond
@ DegreeMinuteSecond
Degree/minutes/seconds, use NSEW suffix.
Definition: qgslayoutitemmapgrid.h:210
QgsLayoutItemMapGrid::NoFrame
@ NoFrame
Disable grid frame.
Definition: qgslayoutitemmapgrid.h:235
QgsSymbol::Line
@ Line
Line symbol.
Definition: qgssymbol.h:88
QgsLayoutItemMapGrid::Top
@ Top
Top border.
Definition: qgslayoutitemmapgrid.h:227
QgsLayoutItemMapGrid::AnnotationFormat
AnnotationFormat
Format for displaying grid annotations.
Definition: qgslayoutitemmapgrid.h:207
QgsSymbol::Marker
@ Marker
Marker symbol.
Definition: qgssymbol.h:87
QgsLayoutObject::MapGridFrameDivisionsRight
@ MapGridFrameDivisionsRight
Map frame division display right.
Definition: qgslayoutobject.h:182
QgsLayoutItemMapGrid::DegreeMinuteSecondNoSuffix
@ DegreeMinuteSecondNoSuffix
Degree/minutes/seconds, use - for S/W coordinates.
Definition: qgslayoutitemmapgrid.h:214
QgsLayoutItemMapGrid::AboveTick
@ AboveTick
Draw annotations parallel to tick (above the line)
Definition: qgslayoutitemmapgrid.h:198
QgsLayoutObject::MapGridAnnotationDisplayRight
@ MapGridAnnotationDisplayRight
Map annotation display right.
Definition: qgslayoutobject.h:178
QgsLayoutObject::MapGridIntervalY
@ MapGridIntervalY
Map grid interval Y.
Definition: qgslayoutobject.h:169
QgsLayoutItemMapGrid::Decimal
@ Decimal
Decimal degrees, use - for S/W coordinates.
Definition: qgslayoutitemmapgrid.h:208
QgsFontButton::setLayer
void setLayer(QgsVectorLayer *layer)
Sets a layer to associate with the widget.
Definition: qgsfontbutton.cpp:761
QgsLayoutMapGridWidget::populateDataDefinedButtons
void populateDataDefinedButtons()
Initializes data defined buttons to current atlas coverage layer.
Definition: qgslayoutmapgridwidget.cpp:225
QgsLayoutItem::UndoMapGridFrameFill1Color
@ UndoMapGridFrameFill1Color
Map grid frame fill color 1.
Definition: qgslayoutitem.h:234
QgsLayoutObject::MapGridFrameSize
@ MapGridFrameSize
Map grid frame size.
Definition: qgslayoutobject.h:172
qgsguiutils.h
QgsLayoutItemMapGrid::OrthogonalTicks
@ OrthogonalTicks
Align ticks orthogonaly.
Definition: qgslayoutitemmapgrid.h:250
QgsLayoutReportContext::layerChanged
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
QgsLayoutObject::MapGridFrameDivisionsBottom
@ MapGridFrameDivisionsBottom
Map frame division display bottom.
Definition: qgslayoutobject.h:184
QgsLayoutItemMapGrid::Markers
@ Markers
Draw markers at intersections of grid lines.
Definition: qgslayoutitemmapgrid.h:165
QgsLayoutObject::MapGridFrameDivisionsLeft
@ MapGridFrameDivisionsLeft
Map frame division display left.
Definition: qgslayoutobject.h:181
QgsProject::viewSettings
const QgsProjectViewSettings * viewSettings() const
Returns the project's view settings, which contains settings and properties relating to how a QgsProj...
Definition: qgsproject.cpp:3070
QgsLayoutItem::UndoMapGridFrameFill2Color
@ UndoMapGridFrameFill2Color
Map grid frame fill color 2.
Definition: qgslayoutitem.h:235
QgsLayoutItemMapGrid::LineBorder
@ LineBorder
Simple solid line frame.
Definition: qgslayoutitemmapgrid.h:240
qgssymbol.h
QgsLayoutItemMapGrid::UnderTick
@ UnderTick
Draw annotations parallel to tick (under the line)
Definition: qgslayoutitemmapgrid.h:200
QgsLayoutItemMapGrid::HideAll
@ HideAll
No annotations.
Definition: qgslayoutitemmapgrid.h:177
qgsproject.h
QgsLayoutItemMapGrid::FrameStyle
FrameStyle
Style for grid frame.
Definition: qgslayoutitemmapgrid.h:234
QgsLayoutItemMapGrid::OnTick
@ OnTick
Draw annotations parallel to tick (on the line)
Definition: qgslayoutitemmapgrid.h:199
qgslayoutitemmap.h
QgsLayoutItemMapGrid::Left
@ Left
Left border.
Definition: qgslayoutitemmapgrid.h:224
QgsLayoutItemMapGrid::MM
@ MM
Grid units in millimeters.
Definition: qgslayoutitemmapgrid.h:153
qgsexpressionbuilderdialog.h
QgsFontButton::changed
void changed()
Emitted when the widget's text format settings are changed.