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