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