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