QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
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 mOffsetXSpinBox->setShowClearButton( true );
59 mOffsetXSpinBox->setClearValue( 0 );
60 mOffsetYSpinBox->setShowClearButton( true );
61 mOffsetYSpinBox->setClearValue( 0 );
62
63 connect( mIntervalXSpinBox, &QgsDoubleSpinBox::editingFinished, this, &QgsLayoutMapGridWidget::mIntervalXSpinBox_editingFinished );
64 connect( mIntervalYSpinBox, &QgsDoubleSpinBox::editingFinished, this, &QgsLayoutMapGridWidget::mIntervalYSpinBox_editingFinished );
65 connect( mOffsetXSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mOffsetXSpinBox_valueChanged );
66 connect( mOffsetYSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mOffsetYSpinBox_valueChanged );
67 connect( mCrossWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mCrossWidthSpinBox_valueChanged );
68 connect( mFrameWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mFrameWidthSpinBox_valueChanged );
69 connect( mGridFrameMarginSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mGridFrameMarginSpinBox_valueChanged );
70 connect( mFrameStyleComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mFrameStyleComboBox_currentIndexChanged );
71 connect( mRotatedTicksGroupBox, &QGroupBox::toggled, this, &QgsLayoutMapGridWidget::mRotatedTicksGroupBox_toggled );
72 connect( mRotatedTicksLengthModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mRotatedTicksLengthModeComboBox_currentIndexChanged );
73 connect( mRotatedTicksThresholdSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mRotatedTicksThresholdSpinBox_valueChanged );
74 connect( mRotatedTicksMarginToCornerSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mRotatedTicksMarginToCornerSpinBox_valueChanged );
75 connect( mRotatedAnnotationsGroupBox, &QGroupBox::toggled, this, &QgsLayoutMapGridWidget::mRotatedAnnotationsGroupBox_toggled );
76 connect( mRotatedAnnotationsLengthModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mRotatedAnnotationsLengthModeComboBox_currentIndexChanged );
77 connect( mRotatedAnnotationsThresholdSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mRotatedAnnotationsThresholdSpinBox_valueChanged );
78 connect( mRotatedAnnotationsMarginToCornerSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mRotatedAnnotationsMarginToCornerSpinBox_valueChanged );
79 connect( mGridFramePenSizeSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mGridFramePenSizeSpinBox_valueChanged );
80 connect( mGridFramePenColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutMapGridWidget::mGridFramePenColorButton_colorChanged );
81 connect( mGridFrameFill1ColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutMapGridWidget::mGridFrameFill1ColorButton_colorChanged );
82 connect( mGridFrameFill2ColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutMapGridWidget::mGridFrameFill2ColorButton_colorChanged );
83 connect( mGridTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mGridTypeComboBox_currentIndexChanged );
84 connect( mMapGridUnitComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::intervalUnitChanged );
85 connect( mGridBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mGridBlendComboBox_currentIndexChanged );
86 connect( mCheckGridLeftSide, &QCheckBox::toggled, this, &QgsLayoutMapGridWidget::mCheckGridLeftSide_toggled );
87 connect( mCheckGridRightSide, &QCheckBox::toggled, this, &QgsLayoutMapGridWidget::mCheckGridRightSide_toggled );
88 connect( mCheckGridTopSide, &QCheckBox::toggled, this, &QgsLayoutMapGridWidget::mCheckGridTopSide_toggled );
89 connect( mCheckGridBottomSide, &QCheckBox::toggled, this, &QgsLayoutMapGridWidget::mCheckGridBottomSide_toggled );
90 connect( mFrameDivisionsLeftComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mFrameDivisionsLeftComboBox_currentIndexChanged );
91 connect( mFrameDivisionsRightComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mFrameDivisionsRightComboBox_currentIndexChanged );
92 connect( mFrameDivisionsTopComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mFrameDivisionsTopComboBox_currentIndexChanged );
93 connect( mFrameDivisionsBottomComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mFrameDivisionsBottomComboBox_currentIndexChanged );
94 connect( mDrawAnnotationGroupBox, &QgsCollapsibleGroupBoxBasic::toggled, this, &QgsLayoutMapGridWidget::mDrawAnnotationGroupBox_toggled );
95 connect( mAnnotationFormatButton, &QToolButton::clicked, this, &QgsLayoutMapGridWidget::mAnnotationFormatButton_clicked );
96 connect( mAnnotationDisplayLeftComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDisplayLeftComboBox_currentIndexChanged );
97 connect( mAnnotationDisplayRightComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDisplayRightComboBox_currentIndexChanged );
98 connect( mAnnotationDisplayTopComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDisplayTopComboBox_currentIndexChanged );
99 connect( mAnnotationDisplayBottomComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDisplayBottomComboBox_currentIndexChanged );
100 connect( mAnnotationPositionLeftComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationPositionLeftComboBox_currentIndexChanged );
101 connect( mAnnotationPositionRightComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationPositionRightComboBox_currentIndexChanged );
102 connect( mAnnotationPositionTopComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationPositionTopComboBox_currentIndexChanged );
103 connect( mAnnotationPositionBottomComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationPositionBottomComboBox_currentIndexChanged );
104 connect( mAnnotationDirectionComboBoxLeft, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxLeft_currentIndexChanged );
105 connect( mAnnotationDirectionComboBoxRight, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxRight_currentIndexChanged );
106 connect( mAnnotationDirectionComboBoxTop, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxTop_currentIndexChanged );
107 connect( mAnnotationDirectionComboBoxBottom, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxBottom_currentIndexChanged );
108 connect( mAnnotationFormatComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mAnnotationFormatComboBox_currentIndexChanged );
109 connect( mCoordinatePrecisionSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mCoordinatePrecisionSpinBox_valueChanged );
110 connect( mDistanceToMapFrameSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mDistanceToMapFrameSpinBox_valueChanged );
111 connect( mMinWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::minIntervalChanged );
112 connect( mMaxWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::maxIntervalChanged );
113 connect( mEnabledCheckBox, &QCheckBox::toggled, this, &QgsLayoutMapGridWidget::gridEnabledToggled );
114 setPanelTitle( tr( "Map Grid Properties" ) );
115
116 mMapGridCrsSelector->setOptionVisible( QgsProjectionSelectionWidget::CrsNotSet, true );
117 mMapGridCrsSelector->setNotSetText( tr( "Use Map CRS" ) );
118 mMapGridCrsSelector->setDialogTitle( tr( "Grid CRS" ) );
119
120 connect( mMapGridCrsSelector, &QgsProjectionSelectionWidget::crsChanged, this, &QgsLayoutMapGridWidget::mapGridCrsChanged );
121
122 blockAllSignals( true );
123
124 mMapGridUnitComboBox->addItem( tr( "Map Units" ), QgsLayoutItemMapGrid::MapUnit );
125 mMapGridUnitComboBox->addItem( tr( "Fit Segment Width" ), QgsLayoutItemMapGrid::DynamicPageSizeBased );
126 mMapGridUnitComboBox->addItem( tr( "Millimeters" ), QgsLayoutItemMapGrid::MM );
127 mMapGridUnitComboBox->addItem( tr( "Centimeters" ), QgsLayoutItemMapGrid::CM );
128
129 mGridTypeComboBox->insertItem( 0, tr( "Solid" ), QgsLayoutItemMapGrid::Solid );
130 mGridTypeComboBox->insertItem( 1, tr( "Cross" ), QgsLayoutItemMapGrid::Cross );
131 mGridTypeComboBox->insertItem( 2, tr( "Markers" ), QgsLayoutItemMapGrid::Markers );
132 mGridTypeComboBox->insertItem( 3, tr( "Frame and annotations only" ), QgsLayoutItemMapGrid::FrameAnnotationsOnly );
133
134 insertFrameDisplayEntries( mFrameDivisionsLeftComboBox );
135 insertFrameDisplayEntries( mFrameDivisionsRightComboBox );
136 insertFrameDisplayEntries( mFrameDivisionsTopComboBox );
137 insertFrameDisplayEntries( mFrameDivisionsBottomComboBox );
138
139 insertAnnotationDisplayEntries( mAnnotationDisplayLeftComboBox );
140 insertAnnotationDisplayEntries( mAnnotationDisplayRightComboBox );
141 insertAnnotationDisplayEntries( mAnnotationDisplayTopComboBox );
142 insertAnnotationDisplayEntries( mAnnotationDisplayBottomComboBox );
143
144 insertAnnotationPositionEntries( mAnnotationPositionLeftComboBox );
145 insertAnnotationPositionEntries( mAnnotationPositionRightComboBox );
146 insertAnnotationPositionEntries( mAnnotationPositionTopComboBox );
147 insertAnnotationPositionEntries( mAnnotationPositionBottomComboBox );
148
149 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxLeft );
150 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxRight );
151 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxTop );
152 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxBottom );
153
154 mGridFramePenColorButton->setColorDialogTitle( tr( "Select Grid Frame Color" ) );
155 mGridFramePenColorButton->setAllowOpacity( true );
156 mGridFramePenColorButton->setContext( QStringLiteral( "composer" ) );
157 mGridFramePenColorButton->setNoColorString( tr( "Transparent Frame" ) );
158 mGridFramePenColorButton->setShowNoColor( true );
159
160 mGridFrameFill1ColorButton->setColorDialogTitle( tr( "Select Grid Frame Fill Color" ) );
161 mGridFrameFill1ColorButton->setAllowOpacity( true );
162 mGridFrameFill1ColorButton->setContext( QStringLiteral( "composer" ) );
163 mGridFrameFill1ColorButton->setNoColorString( tr( "Transparent Fill" ) );
164 mGridFrameFill1ColorButton->setShowNoColor( true );
165
166 mGridFrameFill2ColorButton->setColorDialogTitle( tr( "Select Grid Frame Fill Color" ) );
167 mGridFrameFill2ColorButton->setAllowOpacity( true );
168 mGridFrameFill2ColorButton->setContext( QStringLiteral( "composer" ) );
169 mGridFrameFill2ColorButton->setNoColorString( tr( "Transparent Fill" ) );
170 mGridFrameFill2ColorButton->setShowNoColor( true );
171
172 mGridLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
173 mGridMarkerStyleButton->setSymbolType( Qgis::SymbolType::Marker );
174
175 //set initial state of frame style controls
176 toggleFrameControls( false, false, false, false );
177
196
197 // call to initially populate mAnnotationFormatComboBox
198 onCrsChanged();
199
201
202 blockAllSignals( false );
203 connect( mAnnotationFontButton, &QgsFontButton::changed, this, &QgsLayoutMapGridWidget::annotationTextFormatChanged );
204 connect( mGridLineStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutMapGridWidget::lineSymbolChanged );
205 connect( mGridMarkerStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutMapGridWidget::markerSymbolChanged );
206
207 mGridLineStyleButton->registerExpressionContextGenerator( mMapGrid );
208 mGridLineStyleButton->setLayer( coverageLayer() );
209 mGridMarkerStyleButton->registerExpressionContextGenerator( mMapGrid );
210 mGridMarkerStyleButton->setLayer( coverageLayer() );
211 if ( mMap->layout() )
212 {
213 connect( &mMap->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mGridLineStyleButton, &QgsSymbolButton::setLayer );
214 connect( &mMap->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mGridMarkerStyleButton, &QgsSymbolButton::setLayer );
215 connect( &mMap->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mAnnotationFontButton, &QgsFontButton::setLayer );
216 }
217 mAnnotationFontButton->setLayer( coverageLayer() );
218 mAnnotationFontButton->registerExpressionContextGenerator( mMapGrid );
219
220 connect( mMapGrid, &QgsLayoutItemMapGrid::crsChanged, this, &QgsLayoutMapGridWidget::onCrsChanged );
221}
222
224{
225 updateDataDefinedButton( mEnabledDDBtn );
226 updateDataDefinedButton( mIntervalXDDBtn );
227 updateDataDefinedButton( mIntervalYDDBtn );
228 updateDataDefinedButton( mOffsetXDDBtn );
229 updateDataDefinedButton( mOffsetYDDBtn );
230 updateDataDefinedButton( mFrameSizeDDBtn );
231 updateDataDefinedButton( mFrameMarginDDBtn );
232 updateDataDefinedButton( mLabelDistDDBtn );
233 updateDataDefinedButton( mCrossWidthDDBtn );
234 updateDataDefinedButton( mFrameLineThicknessDDBtn );
235 updateDataDefinedButton( mAnnotationDisplayLeftDDBtn );
236 updateDataDefinedButton( mAnnotationDisplayRightDDBtn );
237 updateDataDefinedButton( mAnnotationDisplayTopDDBtn );
238 updateDataDefinedButton( mAnnotationDisplayBottomDDBtn );
239 updateDataDefinedButton( mFrameDivisionsLeftDDBtn );
240 updateDataDefinedButton( mFrameDivisionsRightDDBtn );
241 updateDataDefinedButton( mFrameDivisionsTopDDBtn );
242 updateDataDefinedButton( mFrameDivisionsBottomDDBtn );
243}
244
245void QgsLayoutMapGridWidget::setGuiElementValues()
246{
248}
249
251{
252 if ( !mMapGrid || !mMap )
253 {
254 return;
255 }
256
257 blockAllSignals( true );
259 setGridItems();
260 blockAllSignals( false );
261}
262
263void QgsLayoutMapGridWidget::blockAllSignals( bool block )
264{
265 //grid
266 mEnabledCheckBox->blockSignals( block );
267 mGridTypeComboBox->blockSignals( block );
268 mIntervalXSpinBox->blockSignals( block );
269 mIntervalYSpinBox->blockSignals( block );
270 mOffsetXSpinBox->blockSignals( block );
271 mOffsetYSpinBox->blockSignals( block );
272 mCrossWidthSpinBox->blockSignals( block );
273 mFrameStyleComboBox->blockSignals( block );
274 mFrameWidthSpinBox->blockSignals( block );
275 mGridFrameMarginSpinBox->blockSignals( block );
276 mGridLineStyleButton->blockSignals( block );
277 mMapGridUnitComboBox->blockSignals( block );
278 mGridFramePenSizeSpinBox->blockSignals( block );
279 mGridFramePenColorButton->blockSignals( block );
280 mGridFrameFill1ColorButton->blockSignals( block );
281 mGridFrameFill2ColorButton->blockSignals( block );
282 mGridBlendComboBox->blockSignals( block );
283 mCheckGridLeftSide->blockSignals( block );
284 mCheckGridRightSide->blockSignals( block );
285 mCheckGridTopSide->blockSignals( block );
286 mCheckGridBottomSide->blockSignals( block );
287 mFrameDivisionsLeftComboBox->blockSignals( block );
288 mFrameDivisionsRightComboBox->blockSignals( block );
289 mFrameDivisionsTopComboBox->blockSignals( block );
290 mFrameDivisionsBottomComboBox->blockSignals( block );
291 mGridMarkerStyleButton->blockSignals( block );
292
293 //grid annotation
294 mDrawAnnotationGroupBox->blockSignals( block );
295 mAnnotationFormatComboBox->blockSignals( block );
296 mAnnotationDisplayLeftComboBox->blockSignals( block );
297 mAnnotationPositionLeftComboBox->blockSignals( block );
298 mAnnotationDirectionComboBoxLeft->blockSignals( block );
299 mAnnotationDisplayRightComboBox->blockSignals( block );
300 mAnnotationPositionRightComboBox->blockSignals( block );
301 mAnnotationDirectionComboBoxRight->blockSignals( block );
302 mAnnotationDisplayTopComboBox->blockSignals( block );
303 mAnnotationPositionTopComboBox->blockSignals( block );
304 mAnnotationDirectionComboBoxTop->blockSignals( block );
305 mAnnotationDisplayBottomComboBox->blockSignals( block );
306 mAnnotationPositionBottomComboBox->blockSignals( block );
307 mAnnotationDirectionComboBoxBottom->blockSignals( block );
308 mDistanceToMapFrameSpinBox->blockSignals( block );
309 mCoordinatePrecisionSpinBox->blockSignals( block );
310 mAnnotationFontButton->blockSignals( block );
311 mMinWidthSpinBox->blockSignals( block );
312 mMaxWidthSpinBox->blockSignals( block );
313}
314
315void QgsLayoutMapGridWidget::handleChangedFrameDisplay( QgsLayoutItemMapGrid::BorderSide border, const QgsLayoutItemMapGrid::DisplayMode mode )
316{
317 if ( !mMapGrid || !mMap )
318 {
319 return;
320 }
321
322 mMap->beginCommand( tr( "Change Frame Divisions" ) );
323 mMapGrid->setFrameDivisions( mode, border );
324 mMap->endCommand();
325 mMap->updateBoundingRect();
326}
327
328void QgsLayoutMapGridWidget::handleChangedAnnotationDisplay( QgsLayoutItemMapGrid::BorderSide border, const QgsLayoutItemMapGrid::DisplayMode mode )
329{
330 if ( !mMapGrid || !mMap )
331 {
332 return;
333 }
334
335 mMap->beginCommand( tr( "Change Annotation Format" ) );
336 mMapGrid->setAnnotationDisplay( mode, border );
337 mMap->updateBoundingRect();
338 mMap->update();
339 mMap->endCommand();
340}
341
342void QgsLayoutMapGridWidget::toggleFrameControls( bool frameEnabled, bool frameFillEnabled, bool frameSizeEnabled, bool rotationEnabled )
343{
344 //set status of frame controls
345 mFrameWidthSpinBox->setEnabled( frameSizeEnabled );
346 mGridFrameMarginSpinBox->setEnabled( frameEnabled );
347 mGridFramePenSizeSpinBox->setEnabled( frameEnabled );
348 mGridFramePenColorButton->setEnabled( frameEnabled );
349 mGridFrameFill1ColorButton->setEnabled( frameFillEnabled );
350 mGridFrameFill2ColorButton->setEnabled( frameFillEnabled );
351 mFrameWidthLabel->setEnabled( frameSizeEnabled );
352 mFrameMarginLabel->setEnabled( frameEnabled );
353 mFramePenLabel->setEnabled( frameEnabled );
354 mFrameFillLabel->setEnabled( frameFillEnabled );
355 mCheckGridLeftSide->setEnabled( frameEnabled );
356 mCheckGridRightSide->setEnabled( frameEnabled );
357 mCheckGridTopSide->setEnabled( frameEnabled );
358 mCheckGridBottomSide->setEnabled( frameEnabled );
359 mFrameDivisionsLeftComboBox->setEnabled( frameEnabled );
360 mFrameDivisionsRightComboBox->setEnabled( frameEnabled );
361 mFrameDivisionsTopComboBox->setEnabled( frameEnabled );
362 mFrameDivisionsBottomComboBox->setEnabled( frameEnabled );
363 mLeftDivisionsLabel->setEnabled( frameEnabled );
364 mRightDivisionsLabel->setEnabled( frameEnabled );
365 mTopDivisionsLabel->setEnabled( frameEnabled );
366 mBottomDivisionsLabel->setEnabled( frameEnabled );
367 mRotatedTicksGroupBox->setEnabled( rotationEnabled );
368}
369
370void QgsLayoutMapGridWidget::insertAnnotationPositionEntries( QComboBox *c )
371{
372 c->insertItem( 0, tr( "Inside Frame" ), QgsLayoutItemMapGrid::InsideMapFrame );
373 c->insertItem( 1, tr( "Outside Frame" ), QgsLayoutItemMapGrid::OutsideMapFrame );
374}
375
376void QgsLayoutMapGridWidget::insertAnnotationDirectionEntries( QComboBox *c )
377{
378 c->addItem( tr( "Horizontal" ), QgsLayoutItemMapGrid::Horizontal );
379 c->addItem( tr( "Vertical Ascending" ), QgsLayoutItemMapGrid::Vertical );
380 c->addItem( tr( "Vertical Descending" ), QgsLayoutItemMapGrid::VerticalDescending );
381 c->addItem( tr( "Boundary Direction" ), QgsLayoutItemMapGrid::BoundaryDirection );
382 // c->addItem( tr( "Parallel to Tick" ), QgsLayoutItemMapGrid::ParallelToTick );
383 c->addItem( tr( "Above Tick" ), QgsLayoutItemMapGrid::AboveTick );
384 c->addItem( tr( "On Tick" ), QgsLayoutItemMapGrid::OnTick );
385 c->addItem( tr( "Under Tick" ), QgsLayoutItemMapGrid::UnderTick );
386}
387
388void QgsLayoutMapGridWidget::initFrameDisplayBox( QComboBox *c, QgsLayoutItemMapGrid::DisplayMode display )
389{
390 if ( !c )
391 {
392 return;
393 }
394 c->setCurrentIndex( c->findData( display ) );
395}
396
397void QgsLayoutMapGridWidget::handleChangedAnnotationPosition( QgsLayoutItemMapGrid::BorderSide border, const QgsLayoutItemMapGrid::AnnotationPosition position )
398{
399 if ( !mMapGrid || !mMap )
400 {
401 return;
402 }
403
404 mMap->beginCommand( tr( "Change Annotation Position" ) );
405 mMapGrid->setAnnotationPosition( position, border );
406
407 mMap->updateBoundingRect();
408 mMap->update();
409 mMap->endCommand();
410}
411
412void QgsLayoutMapGridWidget::handleChangedAnnotationDirection( QgsLayoutItemMapGrid::BorderSide border, QgsLayoutItemMapGrid::AnnotationDirection direction )
413{
414 if ( !mMapGrid || !mMap )
415 {
416 return;
417 }
418
419 mMap->beginCommand( tr( "Change Annotation Direction" ) );
420 mMapGrid->setAnnotationDirection( direction, border );
421 mMap->updateBoundingRect();
422 mMap->update();
423 mMap->endCommand();
424}
425
426void QgsLayoutMapGridWidget::insertFrameDisplayEntries( QComboBox *c )
427{
428 c->addItem( tr( "All" ), QgsLayoutItemMapGrid::ShowAll );
429 c->addItem( tr( "Latitude/Y Only" ), QgsLayoutItemMapGrid::LatitudeOnly );
430 c->addItem( tr( "Longitude/X Only" ), QgsLayoutItemMapGrid::LongitudeOnly );
431}
432
433void QgsLayoutMapGridWidget::insertAnnotationDisplayEntries( QComboBox *c )
434{
435 c->insertItem( 0, tr( "Show All" ), QgsLayoutItemMapGrid::ShowAll );
436 c->insertItem( 1, tr( "Show Latitude/Y Only" ), QgsLayoutItemMapGrid::LatitudeOnly );
437 c->insertItem( 2, tr( "Show Longitude/X Only" ), QgsLayoutItemMapGrid::LongitudeOnly );
438 c->insertItem( 3, tr( "Disabled" ), QgsLayoutItemMapGrid::HideAll );
439}
440
441void QgsLayoutMapGridWidget::initAnnotationPositionBox( QComboBox *c, QgsLayoutItemMapGrid::AnnotationPosition pos )
442{
443 if ( !c )
444 {
445 return;
446 }
447
449 {
450 c->setCurrentIndex( c->findText( tr( "Inside Frame" ) ) );
451 }
452 else
453 {
454 c->setCurrentIndex( c->findText( tr( "Outside Frame" ) ) );
455 }
456}
457
458void QgsLayoutMapGridWidget::initAnnotationDirectionBox( QComboBox *c, QgsLayoutItemMapGrid::AnnotationDirection dir )
459{
460 if ( !c )
461 {
462 return;
463 }
464 c->setCurrentIndex( c->findData( dir ) );
465}
466
467bool QgsLayoutMapGridWidget::hasPredefinedScales() const
468{
469 // first look at project's scales
470 const QVector< double > scales = QgsProject::instance()->viewSettings()->mapScales();
471 const bool hasProjectScales( QgsProject::instance()->viewSettings()->useProjectScales() );
472 if ( !hasProjectScales || scales.isEmpty() )
473 {
474 // default to global map tool scales
475 const QStringList scales = QgsSettingsRegistryCore::settingsMapScales->value();
476 return !scales.isEmpty() && !scales[0].isEmpty();
477 }
478 return true;
479}
480
481void QgsLayoutMapGridWidget::setGridItems()
482{
483 if ( !mMapGrid )
484 {
485 return;
486 }
487
488 mGridMarkerStyleButton->registerExpressionContextGenerator( mMapGrid );
489 mGridLineStyleButton->registerExpressionContextGenerator( mMapGrid );
490 mAnnotationFontButton->registerExpressionContextGenerator( mMapGrid );
491
492 mEnabledCheckBox->setChecked( mMapGrid->enabled() );
493 mIntervalXSpinBox->setValue( mMapGrid->intervalX() );
494 mIntervalYSpinBox->setValue( mMapGrid->intervalY() );
495 mOffsetXSpinBox->setValue( mMapGrid->offsetX() );
496 mOffsetYSpinBox->setValue( mMapGrid->offsetY() );
497 mCrossWidthSpinBox->setValue( mMapGrid->crossLength() );
498 mFrameWidthSpinBox->setValue( mMapGrid->frameWidth() );
499 mGridFrameMarginSpinBox->setValue( mMapGrid->frameMargin() );
500 mGridFramePenSizeSpinBox->setValue( mMapGrid->framePenSize() );
501 mGridFramePenColorButton->setColor( mMapGrid->framePenColor() );
502 mGridFrameFill1ColorButton->setColor( mMapGrid->frameFillColor1() );
503 mGridFrameFill2ColorButton->setColor( mMapGrid->frameFillColor2() );
504
505 const QgsLayoutItemMapGrid::GridStyle gridStyle = mMapGrid->style();
506 mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findData( gridStyle ) );
507 switch ( gridStyle )
508 {
510 mCrossWidthSpinBox->setVisible( true );
511 mCrossWidthDDBtn->setVisible( true );
512 mCrossWidthLabel->setVisible( true );
513 mGridLineStyleButton->setVisible( true );
514 mLineStyleLabel->setVisible( true );
515 mGridMarkerStyleButton->setVisible( false );
516 mMarkerStyleLabel->setVisible( false );
517 mGridBlendComboBox->setVisible( true );
518 mGridBlendLabel->setVisible( true );
519 break;
521 mCrossWidthSpinBox->setVisible( false );
522 mCrossWidthDDBtn->setVisible( false );
523 mCrossWidthLabel->setVisible( false );
524 mGridLineStyleButton->setVisible( false );
525 mLineStyleLabel->setVisible( false );
526 mGridMarkerStyleButton->setVisible( true );
527 mMarkerStyleFrame->setVisible( true );
528 mMarkerStyleLabel->setVisible( true );
529 mGridBlendComboBox->setVisible( true );
530 mGridBlendLabel->setVisible( true );
531 break;
533 mCrossWidthSpinBox->setVisible( false );
534 mCrossWidthDDBtn->setVisible( false );
535 mCrossWidthLabel->setVisible( false );
536 mGridLineStyleButton->setVisible( true );
537 mLineStyleLabel->setVisible( true );
538 mGridMarkerStyleButton->setVisible( false );
539 mMarkerStyleFrame->setVisible( false );
540 mMarkerStyleLabel->setVisible( false );
541 mGridBlendComboBox->setVisible( true );
542 mGridBlendLabel->setVisible( true );
543 break;
545 mCrossWidthSpinBox->setVisible( false );
546 mCrossWidthDDBtn->setVisible( false );
547 mCrossWidthLabel->setVisible( false );
548 mGridLineStyleButton->setVisible( false );
549 mLineStyleLabel->setVisible( false );
550 mGridMarkerStyleButton->setVisible( false );
551 mMarkerStyleFrame->setVisible( false );
552 mMarkerStyleLabel->setVisible( false );
553 mGridBlendComboBox->setVisible( false );
554 mGridBlendLabel->setVisible( false );
555 break;
556 }
557
558 //grid frame
559 mFrameWidthSpinBox->setValue( mMapGrid->frameWidth() );
560 mGridFrameMarginSpinBox->setValue( mMapGrid->frameMargin() );
561 const QgsLayoutItemMapGrid::FrameStyle gridFrameStyle = mMapGrid->frameStyle();
562 mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findData( gridFrameStyle ) );
563 switch ( gridFrameStyle )
564 {
567 toggleFrameControls( true, true, true, false );
568 break;
572 toggleFrameControls( true, false, true, true );
573 break;
576 toggleFrameControls( true, false, false, false );
577 break;
579 toggleFrameControls( false, false, false, false );
580 break;
581 }
582
583 mCheckGridLeftSide->setChecked( mMapGrid->testFrameSideFlag( QgsLayoutItemMapGrid::FrameLeft ) );
584 mCheckGridRightSide->setChecked( mMapGrid->testFrameSideFlag( QgsLayoutItemMapGrid::FrameRight ) );
585 mCheckGridTopSide->setChecked( mMapGrid->testFrameSideFlag( QgsLayoutItemMapGrid::FrameTop ) );
586 mCheckGridBottomSide->setChecked( mMapGrid->testFrameSideFlag( QgsLayoutItemMapGrid::FrameBottom ) );
587
588 mRotatedTicksGroupBox->setChecked( mMapGrid->rotatedTicksEnabled() );
589 mRotatedTicksLengthModeComboBox->setCurrentIndex( mRotatedTicksLengthModeComboBox->findData( mMapGrid->rotatedTicksLengthMode() ) );
590 mRotatedTicksThresholdSpinBox->setValue( mMapGrid->rotatedTicksMinimumAngle() );
591 mRotatedTicksMarginToCornerSpinBox->setValue( mMapGrid->rotatedTicksMarginToCorner() );
592
593 mRotatedAnnotationsGroupBox->setChecked( mMapGrid->rotatedAnnotationsEnabled() );
594 mRotatedAnnotationsLengthModeComboBox->setCurrentIndex( mRotatedAnnotationsLengthModeComboBox->findData( mMapGrid->rotatedAnnotationsLengthMode() ) );
595 mRotatedAnnotationsThresholdSpinBox->setValue( mMapGrid->rotatedAnnotationsMinimumAngle() );
596 mRotatedAnnotationsMarginToCornerSpinBox->setValue( mMapGrid->rotatedAnnotationsMarginToCorner() );
597
598 initFrameDisplayBox( mFrameDivisionsLeftComboBox, mMapGrid->frameDivisions( QgsLayoutItemMapGrid::Left ) );
599 initFrameDisplayBox( mFrameDivisionsRightComboBox, mMapGrid->frameDivisions( QgsLayoutItemMapGrid::Right ) );
600 initFrameDisplayBox( mFrameDivisionsTopComboBox, mMapGrid->frameDivisions( QgsLayoutItemMapGrid::Top ) );
601 initFrameDisplayBox( mFrameDivisionsBottomComboBox, mMapGrid->frameDivisions( QgsLayoutItemMapGrid::Bottom ) );
602
603 //line style
604 mGridLineStyleButton->setSymbol( mMapGrid->lineSymbol()->clone() );
605 //marker style
606 mGridMarkerStyleButton->setSymbol( mMapGrid->markerSymbol()->clone() );
607
608 mGridBlendComboBox->setBlendMode( mMapGrid->blendMode() );
609
610 mDrawAnnotationGroupBox->setChecked( mMapGrid->annotationEnabled() );
611 mAnnotationDisplayLeftComboBox->setCurrentIndex( mAnnotationDisplayLeftComboBox->findData( mMapGrid->annotationDisplay( QgsLayoutItemMapGrid::Left ) ) );
612 mAnnotationDisplayRightComboBox->setCurrentIndex( mAnnotationDisplayRightComboBox->findData( mMapGrid->annotationDisplay( QgsLayoutItemMapGrid::Right ) ) );
613 mAnnotationDisplayTopComboBox->setCurrentIndex( mAnnotationDisplayTopComboBox->findData( mMapGrid->annotationDisplay( QgsLayoutItemMapGrid::Top ) ) );
614 mAnnotationDisplayBottomComboBox->setCurrentIndex( mAnnotationDisplayBottomComboBox->findData( mMapGrid->annotationDisplay( QgsLayoutItemMapGrid::Bottom ) ) );
615
616 mAnnotationPositionLeftComboBox->setCurrentIndex( mAnnotationPositionLeftComboBox->findData( mMapGrid->annotationPosition( QgsLayoutItemMapGrid::Left ) ) );
617 mAnnotationPositionRightComboBox->setCurrentIndex( mAnnotationPositionRightComboBox->findData( mMapGrid->annotationPosition( QgsLayoutItemMapGrid::Right ) ) );
618 mAnnotationPositionTopComboBox->setCurrentIndex( mAnnotationPositionTopComboBox->findData( mMapGrid->annotationPosition( QgsLayoutItemMapGrid::Top ) ) );
619 mAnnotationPositionBottomComboBox->setCurrentIndex( mAnnotationPositionBottomComboBox->findData( mMapGrid->annotationPosition( QgsLayoutItemMapGrid::Bottom ) ) );
620
621 initAnnotationDirectionBox( mAnnotationDirectionComboBoxLeft, mMapGrid->annotationDirection( QgsLayoutItemMapGrid::Left ) );
622 initAnnotationDirectionBox( mAnnotationDirectionComboBoxRight, mMapGrid->annotationDirection( QgsLayoutItemMapGrid::Right ) );
623 initAnnotationDirectionBox( mAnnotationDirectionComboBoxTop, mMapGrid->annotationDirection( QgsLayoutItemMapGrid::Top ) );
624 initAnnotationDirectionBox( mAnnotationDirectionComboBoxBottom, mMapGrid->annotationDirection( QgsLayoutItemMapGrid::Bottom ) );
625
626 mAnnotationFontButton->setDialogTitle( tr( "Grid Annotation Font" ) );
627 mAnnotationFontButton->setMode( QgsFontButton::ModeTextRenderer );
628 mAnnotationFontButton->setTextFormat( mMapGrid->annotationTextFormat() );
629
630 mAnnotationFormatComboBox->setCurrentIndex( mAnnotationFormatComboBox->findData( mMapGrid->annotationFormat() ) );
631 mAnnotationFormatButton->setEnabled( mMapGrid->annotationFormat() == QgsLayoutItemMapGrid::CustomFormat );
632 mDistanceToMapFrameSpinBox->setValue( mMapGrid->annotationFrameDistance() );
633 mCoordinatePrecisionSpinBox->setValue( mMapGrid->annotationPrecision() );
634
635 //Unit
636 mMapGridUnitComboBox->setCurrentIndex( mMapGridUnitComboBox->findData( mMapGrid->units() ) );
637 switch ( mMapGrid->units() )
638 {
642 mIntervalStackedWidget->setCurrentIndex( 0 );
643 break;
644
646 mIntervalStackedWidget->setCurrentIndex( 1 );
647 break;
648 }
649 mMinWidthSpinBox->setValue( mMapGrid->minimumIntervalWidth() );
650 mMaxWidthSpinBox->setValue( mMapGrid->maximumIntervalWidth() );
651
652 whileBlocking( mMapGridCrsSelector )->setCrs( mMapGrid->crs() );
653}
654
655void QgsLayoutMapGridWidget::mIntervalXSpinBox_editingFinished()
656{
657 if ( !mMapGrid || !mMap )
658 {
659 return;
660 }
661
662 mMap->beginCommand( tr( "Change Grid Interval" ) );
663 mMapGrid->setIntervalX( mIntervalXSpinBox->value() );
664 mMap->updateBoundingRect();
665 mMap->update();
666 mMap->endCommand();
667}
668
669void QgsLayoutMapGridWidget::mIntervalYSpinBox_editingFinished()
670{
671 if ( !mMapGrid || !mMap )
672 {
673 return;
674 }
675
676 mMap->beginCommand( tr( "Change Grid Interval" ) );
677 mMapGrid->setIntervalY( mIntervalYSpinBox->value() );
678 mMap->updateBoundingRect();
679 mMap->update();
680 mMap->endCommand();
681}
682
683void QgsLayoutMapGridWidget::mOffsetXSpinBox_valueChanged( double value )
684{
685 if ( !mMapGrid || !mMap )
686 {
687 return;
688 }
689
690 mMap->beginCommand( tr( "Change Grid Offset" ) );
691 mMapGrid->setOffsetX( value );
692 mMap->updateBoundingRect();
693 mMap->update();
694 mMap->endCommand();
695}
696
697void QgsLayoutMapGridWidget::mOffsetYSpinBox_valueChanged( double value )
698{
699 if ( !mMapGrid || !mMap )
700 {
701 return;
702 }
703
704 mMap->beginCommand( tr( "Change Grid Offset" ) );
705 mMapGrid->setOffsetY( value );
706 mMap->updateBoundingRect();
707 mMap->update();
708 mMap->endCommand();
709}
710
711void QgsLayoutMapGridWidget::mCrossWidthSpinBox_valueChanged( double val )
712{
713 if ( !mMapGrid || !mMap )
714 {
715 return;
716 }
717
718 mMap->beginCommand( tr( "Change Cross Width" ) );
719 mMapGrid->setCrossLength( val );
720 mMap->update();
721 mMap->endCommand();
722}
723
724void QgsLayoutMapGridWidget::mFrameWidthSpinBox_valueChanged( double val )
725{
726 if ( !mMapGrid || !mMap )
727 {
728 return;
729 }
730
731 mMap->beginCommand( tr( "Change Frame Width" ) );
732 mMapGrid->setFrameWidth( val );
733 mMap->updateBoundingRect();
734 mMap->update();
735 mMap->endCommand();
736}
737
738void QgsLayoutMapGridWidget::mGridFrameMarginSpinBox_valueChanged( double val )
739{
740 if ( !mMapGrid || !mMap )
741 {
742 return;
743 }
744
745 mMap->beginCommand( tr( "Change Grid Frame Margin" ) );
746 mMapGrid->setFrameMargin( val );
747 mMap->updateBoundingRect();
748 mMap->update();
749 mMap->endCommand();
750}
751
752void QgsLayoutMapGridWidget::mCheckGridLeftSide_toggled( bool checked )
753{
754 if ( !mMapGrid || !mMap )
755 {
756 return;
757 }
758
759 mMap->beginCommand( tr( "Change Frame Left" ) );
760 mMapGrid->setFrameSideFlag( QgsLayoutItemMapGrid::FrameLeft, checked );
761 mMap->updateBoundingRect();
762 mMap->update();
763 mMap->endCommand();
764}
765
766void QgsLayoutMapGridWidget::mCheckGridRightSide_toggled( bool checked )
767{
768 if ( !mMapGrid || !mMap )
769 {
770 return;
771 }
772
773 mMap->beginCommand( tr( "Change Frame Right" ) );
774 mMapGrid->setFrameSideFlag( QgsLayoutItemMapGrid::FrameRight, checked );
775 mMap->updateBoundingRect();
776 mMap->update();
777 mMap->endCommand();
778}
779
780void QgsLayoutMapGridWidget::mCheckGridTopSide_toggled( bool checked )
781{
782 if ( !mMapGrid || !mMap )
783 {
784 return;
785 }
786
787 mMap->beginCommand( tr( "Change Frame Top" ) );
788 mMapGrid->setFrameSideFlag( QgsLayoutItemMapGrid::FrameTop, checked );
789 mMap->updateBoundingRect();
790 mMap->update();
791 mMap->endCommand();
792}
793
794void QgsLayoutMapGridWidget::mCheckGridBottomSide_toggled( bool checked )
795{
796 if ( !mMapGrid || !mMap )
797 {
798 return;
799 }
800
801 mMap->beginCommand( tr( "Change Frame Bottom" ) );
802 mMapGrid->setFrameSideFlag( QgsLayoutItemMapGrid::FrameBottom, checked );
803 mMap->updateBoundingRect();
804 mMap->update();
805 mMap->endCommand();
806}
807
808void QgsLayoutMapGridWidget::mFrameDivisionsLeftComboBox_currentIndexChanged( int index )
809{
810 handleChangedFrameDisplay( QgsLayoutItemMapGrid::Left, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mFrameDivisionsLeftComboBox->itemData( index ).toInt() ) );
811}
812
813void QgsLayoutMapGridWidget::mFrameDivisionsRightComboBox_currentIndexChanged( int index )
814{
815 handleChangedFrameDisplay( QgsLayoutItemMapGrid::Right, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mFrameDivisionsRightComboBox->itemData( index ).toInt() ) );
816}
817
818void QgsLayoutMapGridWidget::mFrameDivisionsTopComboBox_currentIndexChanged( int index )
819{
820 handleChangedFrameDisplay( QgsLayoutItemMapGrid::Top, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mFrameDivisionsTopComboBox->itemData( index ).toInt() ) );
821}
822
823void QgsLayoutMapGridWidget::mFrameDivisionsBottomComboBox_currentIndexChanged( int index )
824{
825 handleChangedFrameDisplay( QgsLayoutItemMapGrid::Bottom, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mFrameDivisionsBottomComboBox->itemData( index ).toInt() ) );
826}
827
828void QgsLayoutMapGridWidget::mGridFramePenSizeSpinBox_valueChanged( double d )
829{
830 if ( !mMapGrid || !mMap )
831 {
832 return;
833 }
834
835 mMap->beginCommand( tr( "Change Frame Thickness" ) );
836 mMapGrid->setFramePenSize( d );
837 mMap->updateBoundingRect();
838 mMap->update();
839 mMap->endCommand();
840}
841
842void QgsLayoutMapGridWidget::mGridFramePenColorButton_colorChanged( const QColor &newColor )
843{
844 if ( !mMapGrid || !mMap )
845 {
846 return;
847 }
848
849 mMap->beginCommand( tr( "Change Frame Color" ), QgsLayoutItem::UndoGridFramePenColor );
850 mMapGrid->setFramePenColor( newColor );
851 mMap->update();
852 mMap->endCommand();
853}
854
855void QgsLayoutMapGridWidget::mGridFrameFill1ColorButton_colorChanged( const QColor &newColor )
856{
857 if ( !mMapGrid || !mMap )
858 {
859 return;
860 }
861
862 mMap->beginCommand( tr( "Change Frame Fill Color" ), QgsLayoutItem::UndoMapGridFrameFill1Color );
863 mMapGrid->setFrameFillColor1( newColor );
864 mMap->update();
865 mMap->endCommand();
866}
867
868void QgsLayoutMapGridWidget::mGridFrameFill2ColorButton_colorChanged( const QColor &newColor )
869{
870 if ( !mMapGrid || !mMap )
871 {
872 return;
873 }
874
875 mMap->beginCommand( tr( "Change Frame Fill Color" ), QgsLayoutItem::UndoMapGridFrameFill2Color );
876 mMapGrid->setFrameFillColor2( newColor );
877 mMap->update();
878 mMap->endCommand();
879}
880
881void QgsLayoutMapGridWidget::mFrameStyleComboBox_currentIndexChanged( int )
882{
883 if ( !mMapGrid || !mMap )
884 {
885 return;
886 }
887
888 const QgsLayoutItemMapGrid::FrameStyle style = static_cast< QgsLayoutItemMapGrid::FrameStyle >( mFrameStyleComboBox->currentData().toInt() );
889 mMap->beginCommand( tr( "Change Frame Style" ) );
890 mMapGrid->setFrameStyle( style );
891 switch ( style )
892 {
895 toggleFrameControls( true, true, true, false );
896 break;
900 toggleFrameControls( true, false, true, true );
901 break;
904 toggleFrameControls( true, false, false, false );
905 break;
907 toggleFrameControls( false, false, false, false );
908 break;
909 }
910 mMap->updateBoundingRect();
911 mMap->update();
912 mMap->endCommand();
913}
914
915void QgsLayoutMapGridWidget::mRotatedTicksGroupBox_toggled( bool state )
916{
917 if ( !mMapGrid || !mMap )
918 {
919 return;
920 }
921
922 mMap->beginCommand( tr( "Change Tick Rotation Enabled" ) );
923 mMapGrid->setRotatedTicksEnabled( state );
924 mMap->update();
925 mMap->endCommand();
926}
927
928void QgsLayoutMapGridWidget::mRotatedTicksLengthModeComboBox_currentIndexChanged( int )
929{
930 if ( !mMapGrid || !mMap )
931 {
932 return;
933 }
934
935 const QgsLayoutItemMapGrid::TickLengthMode mode = static_cast< QgsLayoutItemMapGrid::TickLengthMode >( mRotatedTicksLengthModeComboBox->currentData().toInt() );
936 mMap->beginCommand( tr( "Change Tick Length Mode" ) );
937 mMapGrid->setRotatedTicksLengthMode( mode );
938 mMap->update();
939 mMap->endCommand();
940}
941
942void QgsLayoutMapGridWidget::mRotatedTicksThresholdSpinBox_valueChanged( double val )
943{
944 if ( !mMapGrid || !mMap )
945 {
946 return;
947 }
948
949 mMap->beginCommand( tr( "Change Rotated Ticks Threshold" ) );
950 mMapGrid->setRotatedTicksMinimumAngle( val );
951 mMap->update();
952 mMap->endCommand();
953}
954
955void QgsLayoutMapGridWidget::mRotatedTicksMarginToCornerSpinBox_valueChanged( double val )
956{
957 if ( !mMapGrid || !mMap )
958 {
959 return;
960 }
961
962 mMap->beginCommand( tr( "Change Rotated Ticks Margin to Corner" ) );
963 mMapGrid->setRotatedTicksMarginToCorner( val );
964 mMap->update();
965 mMap->endCommand();
966}
967
968void QgsLayoutMapGridWidget::mRotatedAnnotationsGroupBox_toggled( bool state )
969{
970 if ( !mMapGrid || !mMap )
971 {
972 return;
973 }
974
975 mMap->beginCommand( tr( "Change Annotation Rotation Enabled" ) );
976 mMapGrid->setRotatedAnnotationsEnabled( state );
977 mMap->update();
978 mMap->endCommand();
979}
980
981void QgsLayoutMapGridWidget::mRotatedAnnotationsLengthModeComboBox_currentIndexChanged( int )
982{
983 if ( !mMapGrid || !mMap )
984 {
985 return;
986 }
987
988 const QgsLayoutItemMapGrid::TickLengthMode mode = static_cast< QgsLayoutItemMapGrid::TickLengthMode >( mRotatedAnnotationsLengthModeComboBox->currentData().toInt() );
989 mMap->beginCommand( tr( "Change Annotation Length Mode" ) );
990 mMapGrid->setRotatedAnnotationsLengthMode( mode );
991 mMap->update();
992 mMap->endCommand();
993}
994
995void QgsLayoutMapGridWidget::mRotatedAnnotationsThresholdSpinBox_valueChanged( double val )
996{
997 if ( !mMapGrid || !mMap )
998 {
999 return;
1000 }
1001
1002 mMap->beginCommand( tr( "Change Rotated Annotations Threshold" ) );
1003 mMapGrid->setRotatedAnnotationsMinimumAngle( val );
1004 mMap->update();
1005 mMap->endCommand();
1006}
1007
1008void QgsLayoutMapGridWidget::mRotatedAnnotationsMarginToCornerSpinBox_valueChanged( double val )
1009{
1010 if ( !mMapGrid || !mMap )
1011 {
1012 return;
1013 }
1014
1015 mMap->beginCommand( tr( "Change Rotated Annotations Margin to Corner" ) );
1016 mMapGrid->setRotatedAnnotationsMarginToCorner( val );
1017 mMap->update();
1018 mMap->endCommand();
1019}
1020
1021void QgsLayoutMapGridWidget::intervalUnitChanged( int )
1022{
1023 if ( !mMapGrid || !mMap )
1024 {
1025 return;
1026 }
1027
1028 const QgsLayoutItemMapGrid::GridUnit unit = static_cast< QgsLayoutItemMapGrid::GridUnit >( mMapGridUnitComboBox->currentData().toInt() );
1029 switch ( unit )
1030 {
1034 mIntervalStackedWidget->setCurrentIndex( 0 );
1035 break;
1036
1038 mIntervalStackedWidget->setCurrentIndex( 1 );
1039 break;
1040 }
1041
1042 mMap->beginCommand( tr( "Change Grid Unit" ) );
1043 mMapGrid->setUnits( unit );
1044 mMap->updateBoundingRect();
1045 mMap->update();
1046 mMap->endCommand();
1047}
1048
1049void QgsLayoutMapGridWidget::minIntervalChanged( double interval )
1050{
1051 mMap->beginCommand( tr( "Change Grid Interval Range" ), QgsLayoutItem::UndoMapGridIntervalRange );
1052 mMapGrid->setMinimumIntervalWidth( interval );
1053 mMap->endCommand();
1054 mMap->updateBoundingRect();
1055 mMap->update();
1056}
1057
1058void QgsLayoutMapGridWidget::maxIntervalChanged( double interval )
1059{
1060 mMap->beginCommand( tr( "Change Grid Interval Range" ), QgsLayoutItem::UndoMapGridIntervalRange );
1061 mMapGrid->setMaximumIntervalWidth( interval );
1062 mMap->endCommand();
1063 mMap->updateBoundingRect();
1064 mMap->update();
1065}
1066
1067void QgsLayoutMapGridWidget::annotationTextFormatChanged()
1068{
1069 if ( !mMapGrid || !mMap )
1070 {
1071 return;
1072 }
1073
1074 mMap->beginCommand( tr( "Change Annotation Font" ) );
1075 mMapGrid->setAnnotationTextFormat( mAnnotationFontButton->textFormat() );
1076 mMap->endCommand();
1077 mMap->updateBoundingRect();
1078 mMap->update();
1079}
1080
1081void QgsLayoutMapGridWidget::onCrsChanged()
1082{
1083 mBlockAnnotationFormatUpdates++;
1084 const QgsLayoutItemMapGrid::AnnotationFormat prevFormat = static_cast< QgsLayoutItemMapGrid::AnnotationFormat >( mAnnotationFormatComboBox->currentData().toInt() );
1085
1086 mAnnotationFormatComboBox->clear();
1087 mAnnotationFormatComboBox->addItem( tr( "Decimal" ), QgsLayoutItemMapGrid::Decimal );
1088 mAnnotationFormatComboBox->addItem( tr( "Decimal with Suffix" ), QgsLayoutItemMapGrid::DecimalWithSuffix );
1089
1090 // only show degree based options for geographic CRSes
1091 const QgsCoordinateReferenceSystem crs = mMapGrid->crs().isValid() ? mMapGrid->crs() : mMap->crs();
1092 switch ( crs.mapUnits() )
1093 {
1142 break;
1143
1146 mAnnotationFormatComboBox->addItem( tr( "Degree, Minute" ), QgsLayoutItemMapGrid::DegreeMinuteNoSuffix );
1147 mAnnotationFormatComboBox->addItem( tr( "Degree, Minute with Suffix" ), QgsLayoutItemMapGrid::DegreeMinute );
1148 mAnnotationFormatComboBox->addItem( tr( "Degree, Minute Aligned" ), QgsLayoutItemMapGrid::DegreeMinutePadded );
1149 mAnnotationFormatComboBox->addItem( tr( "Degree, Minute, Second" ), QgsLayoutItemMapGrid::DegreeMinuteSecondNoSuffix );
1150 mAnnotationFormatComboBox->addItem( tr( "Degree, Minute, Second with Suffix" ), QgsLayoutItemMapGrid::DegreeMinuteSecond );
1151 mAnnotationFormatComboBox->addItem( tr( "Degree, Minute, Second Aligned" ), QgsLayoutItemMapGrid::DegreeMinuteSecondPadded );
1152 break;
1153 }
1154 mAnnotationFormatComboBox->addItem( tr( "Custom" ), QgsLayoutItemMapGrid::CustomFormat );
1155
1156 const int prevIndex = mAnnotationFormatComboBox->findData( prevFormat );
1157 if ( prevIndex >= 0 )
1158 mAnnotationFormatComboBox->setCurrentIndex( prevIndex );
1159 else
1160 mAnnotationFormatComboBox->setCurrentIndex( 0 );
1161 mBlockAnnotationFormatUpdates--;
1162
1163 const QgsLayoutItemMapGrid::AnnotationFormat newFormat = static_cast< QgsLayoutItemMapGrid::AnnotationFormat >( mAnnotationFormatComboBox->currentData().toInt() );
1164 if ( newFormat != prevFormat )
1165 {
1166 mAnnotationFormatComboBox_currentIndexChanged( mAnnotationFormatComboBox->currentIndex() );
1167 }
1168}
1169
1170void QgsLayoutMapGridWidget::mGridBlendComboBox_currentIndexChanged( int index )
1171{
1172 Q_UNUSED( index )
1173 if ( mMapGrid )
1174 {
1175 mMap->beginCommand( tr( "Change Grid Blend Mode" ) );
1176 mMapGrid->setBlendMode( mGridBlendComboBox->blendMode() );
1177 mMap->update();
1178 mMap->endCommand();
1179 }
1180
1181}
1182
1183void QgsLayoutMapGridWidget::mGridTypeComboBox_currentIndexChanged( int )
1184{
1185 if ( !mMapGrid || !mMap )
1186 {
1187 return;
1188 }
1189
1190 mMap->beginCommand( tr( "Change Grid Type" ) );
1191 switch ( static_cast< QgsLayoutItemMapGrid::GridStyle >( mGridTypeComboBox->currentData().toInt() ) )
1192 {
1194 mMapGrid->setStyle( QgsLayoutItemMapGrid::Cross );
1195 mCrossWidthSpinBox->setVisible( true );
1196 mCrossWidthDDBtn->setVisible( true );
1197 mCrossWidthLabel->setVisible( true );
1198 mGridLineStyleButton->setVisible( true );
1199 mLineStyleLabel->setVisible( true );
1200 mGridMarkerStyleButton->setVisible( false );
1201 mMarkerStyleFrame->setVisible( false );
1202 mMarkerStyleFrame->setVisible( false );
1203 mMarkerStyleLabel->setVisible( false );
1204 mGridBlendComboBox->setVisible( true );
1205 mGridBlendLabel->setVisible( true );
1206 break;
1207
1209 mMapGrid->setStyle( QgsLayoutItemMapGrid::Markers );
1210 mCrossWidthSpinBox->setVisible( false );
1211 mCrossWidthDDBtn->setVisible( false );
1212 mCrossWidthLabel->setVisible( false );
1213 mGridLineStyleButton->setVisible( false );
1214 mLineStyleLabel->setVisible( false );
1215 mGridMarkerStyleButton->setVisible( true );
1216 mMarkerStyleFrame->setVisible( true );
1217 mMarkerStyleLabel->setVisible( true );
1218 mGridBlendComboBox->setVisible( true );
1219 mGridBlendLabel->setVisible( true );
1220 break;
1221
1223 mMapGrid->setStyle( QgsLayoutItemMapGrid::Solid );
1224 mCrossWidthSpinBox->setVisible( false );
1225 mCrossWidthDDBtn->setVisible( false );
1226 mCrossWidthLabel->setVisible( false );
1227 mGridLineStyleButton->setVisible( true );
1228 mLineStyleLabel->setVisible( true );
1229 mGridMarkerStyleButton->setVisible( false );
1230 mMarkerStyleFrame->setVisible( false );
1231 mMarkerStyleLabel->setVisible( false );
1232 mGridBlendComboBox->setVisible( true );
1233 mGridBlendLabel->setVisible( true );
1234 break;
1235
1237 mMapGrid->setStyle( QgsLayoutItemMapGrid::FrameAnnotationsOnly );
1238 mCrossWidthSpinBox->setVisible( false );
1239 mCrossWidthDDBtn->setVisible( false );
1240 mCrossWidthLabel->setVisible( false );
1241 mGridLineStyleButton->setVisible( false );
1242 mLineStyleLabel->setVisible( false );
1243 mGridMarkerStyleButton->setVisible( false );
1244 mMarkerStyleFrame->setVisible( false );
1245 mMarkerStyleLabel->setVisible( false );
1246 mGridBlendComboBox->setVisible( false );
1247 mGridBlendLabel->setVisible( false );
1248 break;
1249 }
1250
1251 mMap->updateBoundingRect();
1252 mMap->update();
1253 mMap->endCommand();
1254}
1255
1256void QgsLayoutMapGridWidget::mapGridCrsChanged( const QgsCoordinateReferenceSystem &crs )
1257{
1258 if ( !mMapGrid || !mMap )
1259 {
1260 return;
1261 }
1262
1263 if ( mMapGrid->crs() == crs )
1264 return;
1265
1266 mMap->beginCommand( tr( "Change Grid CRS" ) );
1267 mMapGrid->setCrs( crs );
1268 mMap->updateBoundingRect();
1269 mMap->update();
1270 mMap->endCommand();
1271}
1272
1273void QgsLayoutMapGridWidget::mDrawAnnotationGroupBox_toggled( bool state )
1274{
1275 if ( !mMapGrid || !mMap )
1276 {
1277 return;
1278 }
1279
1280 mMap->beginCommand( tr( "Toggle Annotations" ) );
1281 mMapGrid->setAnnotationEnabled( state );
1282 mMap->updateBoundingRect();
1283 mMap->update();
1284 mMap->endCommand();
1285}
1286
1287void QgsLayoutMapGridWidget::mAnnotationFormatButton_clicked()
1288{
1289 if ( !mMapGrid || !mMap )
1290 {
1291 return;
1292 }
1293
1294 QgsExpressionContext expressionContext = mMapGrid->createExpressionContext();
1295 expressionContext.setHighlightedFunctions( QStringList() << QStringLiteral( "to_dms" ) << QStringLiteral( "to_dm" ) );
1296
1297 QgsExpressionBuilderDialog exprDlg( coverageLayer(), mMapGrid->annotationExpression(), this, QStringLiteral( "generic" ), expressionContext );
1298 exprDlg.setWindowTitle( tr( "Expression Based Annotation" ) );
1299
1300 if ( exprDlg.exec() == QDialog::Accepted )
1301 {
1302 const QString expression = exprDlg.expressionText();
1303 mMap->beginCommand( tr( "Change Annotation Format" ) );
1304 mMapGrid->setAnnotationExpression( expression );
1305 mMap->updateBoundingRect();
1306 mMap->update();
1307 mMap->endCommand();
1308 }
1309}
1310
1311void QgsLayoutMapGridWidget::mAnnotationDisplayLeftComboBox_currentIndexChanged( int )
1312{
1313 handleChangedAnnotationDisplay( QgsLayoutItemMapGrid::Left, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mAnnotationDisplayLeftComboBox->currentData().toInt() ) );
1314}
1315
1316void QgsLayoutMapGridWidget::mAnnotationDisplayRightComboBox_currentIndexChanged( int )
1317{
1318 handleChangedAnnotationDisplay( QgsLayoutItemMapGrid::Right, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mAnnotationDisplayRightComboBox->currentData().toInt() ) );
1319}
1320
1321void QgsLayoutMapGridWidget::mAnnotationDisplayTopComboBox_currentIndexChanged( int )
1322{
1323 handleChangedAnnotationDisplay( QgsLayoutItemMapGrid::Top, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mAnnotationDisplayTopComboBox->currentData().toInt() ) );
1324}
1325
1326void QgsLayoutMapGridWidget::mAnnotationDisplayBottomComboBox_currentIndexChanged( int )
1327{
1328 handleChangedAnnotationDisplay( QgsLayoutItemMapGrid::Bottom, static_cast< QgsLayoutItemMapGrid::DisplayMode >( mAnnotationDisplayBottomComboBox->currentData().toInt() ) );
1329}
1330
1331void QgsLayoutMapGridWidget::mAnnotationPositionLeftComboBox_currentIndexChanged( int )
1332{
1333 handleChangedAnnotationPosition( QgsLayoutItemMapGrid::Left, static_cast< QgsLayoutItemMapGrid::AnnotationPosition >( mAnnotationPositionLeftComboBox->currentData().toInt() ) );
1334}
1335
1336void QgsLayoutMapGridWidget::mAnnotationPositionRightComboBox_currentIndexChanged( int )
1337{
1338 handleChangedAnnotationPosition( QgsLayoutItemMapGrid::Right, static_cast< QgsLayoutItemMapGrid::AnnotationPosition >( mAnnotationPositionRightComboBox->currentData().toInt() ) );
1339}
1340
1341void QgsLayoutMapGridWidget::mAnnotationPositionTopComboBox_currentIndexChanged( int )
1342{
1343 handleChangedAnnotationPosition( QgsLayoutItemMapGrid::Top, static_cast< QgsLayoutItemMapGrid::AnnotationPosition >( mAnnotationPositionTopComboBox->currentData().toInt() ) );
1344}
1345
1346void QgsLayoutMapGridWidget::mAnnotationPositionBottomComboBox_currentIndexChanged( int )
1347{
1348 handleChangedAnnotationPosition( QgsLayoutItemMapGrid::Bottom, static_cast< QgsLayoutItemMapGrid::AnnotationPosition >( mAnnotationPositionBottomComboBox->currentData().toInt() ) );
1349}
1350
1351void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxLeft_currentIndexChanged( int index )
1352{
1353 handleChangedAnnotationDirection( QgsLayoutItemMapGrid::Left, static_cast< QgsLayoutItemMapGrid::AnnotationDirection >( mAnnotationDirectionComboBoxLeft->itemData( index ).toInt() ) );
1354}
1355
1356void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxRight_currentIndexChanged( int index )
1357{
1358 handleChangedAnnotationDirection( QgsLayoutItemMapGrid::Right, static_cast< QgsLayoutItemMapGrid::AnnotationDirection >( mAnnotationDirectionComboBoxRight->itemData( index ).toInt() ) );
1359}
1360
1361void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxTop_currentIndexChanged( int index )
1362{
1363 handleChangedAnnotationDirection( QgsLayoutItemMapGrid::Top, static_cast< QgsLayoutItemMapGrid::AnnotationDirection >( mAnnotationDirectionComboBoxTop->itemData( index ).toInt() ) );
1364}
1365
1366void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxBottom_currentIndexChanged( int index )
1367{
1368 handleChangedAnnotationDirection( QgsLayoutItemMapGrid::Bottom, static_cast< QgsLayoutItemMapGrid::AnnotationDirection >( mAnnotationDirectionComboBoxBottom->itemData( index ).toInt() ) );
1369}
1370
1371void QgsLayoutMapGridWidget::mDistanceToMapFrameSpinBox_valueChanged( double d )
1372{
1373 if ( !mMapGrid || !mMap )
1374 {
1375 return;
1376 }
1377
1378 mMap->beginCommand( tr( "Change Annotation Distance" ), QgsLayoutItem::UndoMapAnnotationDistance );
1379 mMapGrid->setAnnotationFrameDistance( d );
1380 mMap->updateBoundingRect();
1381 mMap->update();
1382 mMap->endCommand();
1383}
1384
1385void QgsLayoutMapGridWidget::lineSymbolChanged()
1386{
1387 if ( !mMapGrid || !mMap )
1388 {
1389 return;
1390 }
1391
1392 mMap->beginCommand( tr( "Change Grid Line Style" ), QgsLayoutItem::UndoMapGridLineSymbol );
1393 mMapGrid->setLineSymbol( mGridLineStyleButton->clonedSymbol<QgsLineSymbol>() );
1394 mMap->endCommand();
1395 mMap->update();
1396}
1397
1398void QgsLayoutMapGridWidget::markerSymbolChanged()
1399{
1400 if ( !mMapGrid || !mMap )
1401 {
1402 return;
1403 }
1404
1405 mMap->beginCommand( tr( "Change Grid Marker Style" ), QgsLayoutItem::UndoMapGridMarkerSymbol );
1406 mMapGrid->setMarkerSymbol( mGridMarkerStyleButton->clonedSymbol<QgsMarkerSymbol>() );
1407 mMap->endCommand();
1408 mMap->update();
1409}
1410
1411void QgsLayoutMapGridWidget::gridEnabledToggled( bool active )
1412{
1413 if ( !mMapGrid || !mMap )
1414 {
1415 return;
1416 }
1417
1418 mMap->beginCommand( tr( "Toggle Grid Display" ) );
1419 mMapGrid->setEnabled( active );
1420 mMap->endCommand();
1421 mMap->updateBoundingRect();
1422 mMap->update();
1423}
1424
1425void QgsLayoutMapGridWidget::mAnnotationFormatComboBox_currentIndexChanged( int index )
1426{
1427 if ( !mMapGrid || !mMap )
1428 {
1429 return;
1430 }
1431 if ( mBlockAnnotationFormatUpdates )
1432 return;
1433
1434 mMap->beginCommand( tr( "Change Annotation Format" ) );
1435
1436 mMapGrid->setAnnotationFormat( static_cast< QgsLayoutItemMapGrid::AnnotationFormat >( mAnnotationFormatComboBox->itemData( index ).toInt() ) );
1437 mAnnotationFormatButton->setEnabled( mMapGrid->annotationFormat() == QgsLayoutItemMapGrid::CustomFormat );
1438
1439 mMap->updateBoundingRect();
1440 mMap->update();
1441 mMap->endCommand();
1442}
1443
1444void QgsLayoutMapGridWidget::mCoordinatePrecisionSpinBox_valueChanged( int value )
1445{
1446 if ( !mMapGrid || !mMap )
1447 {
1448 return;
1449 }
1450 mMap->beginCommand( tr( "Change Annotation Precision" ) );
1451 mMapGrid->setAnnotationPrecision( value );
1452 mMap->updateBoundingRect();
1453 mMap->update();
1454 mMap->endCommand();
1455}
@ YardsBritishSears1922Truncated
British yards (Sears 1922 truncated)
@ Feet
Imperial feet.
@ MilesUSSurvey
US Survey miles.
@ LinksBritishSears1922
British links (Sears 1922)
@ YardsBritishBenoit1895A
British yards (Benoit 1895 A)
@ LinksBritishBenoit1895A
British links (Benoit 1895 A)
@ Centimeters
Centimeters.
@ YardsIndian1975
Indian yards (1975)
@ FeetUSSurvey
US Survey feet.
@ Millimeters
Millimeters.
@ FeetBritishSears1922
British feet (Sears 1922)
@ YardsClarkes
Clarke's yards.
@ YardsIndian
Indian yards.
@ FeetBritishBenoit1895B
British feet (Benoit 1895 B)
@ Miles
Terrestrial miles.
@ LinksUSSurvey
US Survey links.
@ ChainsUSSurvey
US Survey chains.
@ FeetClarkes
Clarke's feet.
@ Unknown
Unknown distance unit.
@ Yards
Imperial yards.
@ FeetBritish1936
British feet (1936)
@ FeetIndian1962
Indian feet (1962)
@ YardsBritishSears1922
British yards (Sears 1922)
@ FeetIndian1937
Indian feet (1937)
@ YardsIndian1937
Indian yards (1937)
@ Degrees
Degrees, for planar geographic CRS distance measurements.
@ ChainsBritishBenoit1895B
British chains (Benoit 1895 B)
@ LinksBritishSears1922Truncated
British links (Sears 1922 truncated)
@ ChainsBritishBenoit1895A
British chains (Benoit 1895 A)
@ YardsBritishBenoit1895B
British yards (Benoit 1895 B)
@ FeetBritish1865
British feet (1865)
@ YardsIndian1962
Indian yards (1962)
@ FeetBritishSears1922Truncated
British feet (Sears 1922 truncated)
@ MetersGermanLegal
German legal meter.
@ LinksBritishBenoit1895B
British links (Benoit 1895 B)
@ ChainsInternational
International chains.
@ LinksInternational
International links.
@ ChainsBritishSears1922Truncated
British chains (Sears 1922 truncated)
@ FeetIndian
Indian (geodetic) feet.
@ NauticalMiles
Nautical miles.
@ ChainsClarkes
Clarke's chains.
@ LinksClarkes
Clarke's links.
@ ChainsBritishSears1922
British chains (Sears 1922)
@ Kilometers
Kilometers.
@ FeetIndian1975
Indian feet (1975)
@ FeetGoldCoast
Gold Coast feet.
@ FeetBritishBenoit1895A
British feet (Benoit 1895 A)
@ 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).
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.
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.
@ 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
@ MapGridFrameDivisionsBottom
Map frame division display bottom.
@ MapGridIntervalX
Map grid interval X.
@ MapGridFrameDivisionsTop
Map frame division display top.
@ MapGridAnnotationDisplayLeft
Map annotation display left.
@ MapGridFrameMargin
Map grid frame margin.
@ MapGridCrossSize
Map grid cross size.
@ MapGridAnnotationDisplayRight
Map annotation display right.
@ MapGridAnnotationDisplayTop
Map annotation display top.
@ MapGridAnnotationDisplayBottom
Map annotation display bottom.
@ MapGridFrameDivisionsRight
Map frame division display right.
@ MapGridLabelDistance
Map grid label distance.
@ MapGridIntervalY
Map grid interval Y.
@ MapGridFrameSize
Map grid frame size.
@ MapGridFrameLineThickness
Map grid frame line thickness.
@ MapGridFrameDivisionsLeft
Map frame division display left.
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
A line symbol type, for rendering LineString and MultiLineString geometries.
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.
const QgsProjectViewSettings * viewSettings() const
Returns the project's view settings, which contains settings and properties relating to how a QgsProj...
@ CrsNotSet
Not set (hidden by default)
void crsChanged(const QgsCoordinateReferenceSystem &crs)
Emitted when the selected CRS is changed.
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:5821
const QgsCoordinateReferenceSystem & crs