57 mGridFrameMarginSpinBox->setShowClearButton(
true );
58 mGridFrameMarginSpinBox->setClearValue( 0 );
60 mDistanceToMapFrameSpinBox->setShowClearButton(
true );
61 mDistanceToMapFrameSpinBox->setClearValue( 0 );
63 connect( mIntervalXSpinBox, &QgsDoubleSpinBox::editingFinished,
this, &QgsLayoutMapGridWidget::mIntervalXSpinBox_editingFinished );
64 connect( mIntervalYSpinBox, &QgsDoubleSpinBox::editingFinished,
this, &QgsLayoutMapGridWidget::mIntervalYSpinBox_editingFinished );
65 connect( mOffsetXSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mOffsetXSpinBox_valueChanged );
66 connect( mOffsetYSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mOffsetYSpinBox_valueChanged );
67 connect( mCrossWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mCrossWidthSpinBox_valueChanged );
68 connect( mFrameWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mFrameWidthSpinBox_valueChanged );
69 connect( mGridFrameMarginSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mGridFrameMarginSpinBox_valueChanged );
70 connect( mFrameStyleComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mFrameStyleComboBox_currentIndexChanged );
71 connect( mRotatedTicksGroupBox, &QGroupBox::toggled,
this, &QgsLayoutMapGridWidget::mRotatedTicksGroupBox_toggled );
72 connect( mRotatedTicksLengthModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mRotatedTicksLengthModeComboBox_currentIndexChanged );
73 connect( mRotatedTicksThresholdSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mRotatedTicksThresholdSpinBox_valueChanged );
74 connect( mRotatedTicksMarginToCornerSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mRotatedTicksMarginToCornerSpinBox_valueChanged );
75 connect( mRotatedAnnotationsGroupBox, &QGroupBox::toggled,
this, &QgsLayoutMapGridWidget::mRotatedAnnotationsGroupBox_toggled );
76 connect( mRotatedAnnotationsLengthModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mRotatedAnnotationsLengthModeComboBox_currentIndexChanged );
77 connect( mRotatedAnnotationsThresholdSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mRotatedAnnotationsThresholdSpinBox_valueChanged );
78 connect( mRotatedAnnotationsMarginToCornerSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mRotatedAnnotationsMarginToCornerSpinBox_valueChanged );
79 connect( mGridFramePenSizeSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mGridFramePenSizeSpinBox_valueChanged );
80 connect( mGridFramePenColorButton, &
QgsColorButton::colorChanged,
this, &QgsLayoutMapGridWidget::mGridFramePenColorButton_colorChanged );
81 connect( mGridFrameFill1ColorButton, &
QgsColorButton::colorChanged,
this, &QgsLayoutMapGridWidget::mGridFrameFill1ColorButton_colorChanged );
82 connect( mGridFrameFill2ColorButton, &
QgsColorButton::colorChanged,
this, &QgsLayoutMapGridWidget::mGridFrameFill2ColorButton_colorChanged );
83 connect( mGridTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mGridTypeComboBox_currentIndexChanged );
84 connect( mMapGridUnitComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::intervalUnitChanged );
85 connect( mGridBlendComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mGridBlendComboBox_currentIndexChanged );
86 connect( mCheckGridLeftSide, &QCheckBox::toggled,
this, &QgsLayoutMapGridWidget::mCheckGridLeftSide_toggled );
87 connect( mCheckGridRightSide, &QCheckBox::toggled,
this, &QgsLayoutMapGridWidget::mCheckGridRightSide_toggled );
88 connect( mCheckGridTopSide, &QCheckBox::toggled,
this, &QgsLayoutMapGridWidget::mCheckGridTopSide_toggled );
89 connect( mCheckGridBottomSide, &QCheckBox::toggled,
this, &QgsLayoutMapGridWidget::mCheckGridBottomSide_toggled );
90 connect( mFrameDivisionsLeftComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mFrameDivisionsLeftComboBox_currentIndexChanged );
91 connect( mFrameDivisionsRightComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mFrameDivisionsRightComboBox_currentIndexChanged );
92 connect( mFrameDivisionsTopComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mFrameDivisionsTopComboBox_currentIndexChanged );
93 connect( mFrameDivisionsBottomComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mFrameDivisionsBottomComboBox_currentIndexChanged );
94 connect( mDrawAnnotationGroupBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutMapGridWidget::mDrawAnnotationGroupBox_toggled );
95 connect( mAnnotationFormatButton, &QToolButton::clicked,
this, &QgsLayoutMapGridWidget::mAnnotationFormatButton_clicked );
96 connect( mAnnotationDisplayLeftComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDisplayLeftComboBox_currentIndexChanged );
97 connect( mAnnotationDisplayRightComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDisplayRightComboBox_currentIndexChanged );
98 connect( mAnnotationDisplayTopComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDisplayTopComboBox_currentIndexChanged );
99 connect( mAnnotationDisplayBottomComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDisplayBottomComboBox_currentIndexChanged );
100 connect( mAnnotationPositionLeftComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationPositionLeftComboBox_currentIndexChanged );
101 connect( mAnnotationPositionRightComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationPositionRightComboBox_currentIndexChanged );
102 connect( mAnnotationPositionTopComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationPositionTopComboBox_currentIndexChanged );
103 connect( mAnnotationPositionBottomComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationPositionBottomComboBox_currentIndexChanged );
104 connect( mAnnotationDirectionComboBoxLeft,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxLeft_currentIndexChanged );
105 connect( mAnnotationDirectionComboBoxRight,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxRight_currentIndexChanged );
106 connect( mAnnotationDirectionComboBoxTop,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxTop_currentIndexChanged );
107 connect( mAnnotationDirectionComboBoxBottom,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxBottom_currentIndexChanged );
108 connect( mAnnotationFormatComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationFormatComboBox_currentIndexChanged );
109 connect( mCoordinatePrecisionSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mCoordinatePrecisionSpinBox_valueChanged );
110 connect( mDistanceToMapFrameSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mDistanceToMapFrameSpinBox_valueChanged );
111 connect( mMinWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::minIntervalChanged );
112 connect( mMaxWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::maxIntervalChanged );
113 connect( mEnabledCheckBox, &QCheckBox::toggled,
this, &QgsLayoutMapGridWidget::gridEnabledToggled );
117 mMapGridCrsSelector->setNotSetText( tr(
"Use Map CRS" ) );
118 mMapGridCrsSelector->setDialogTitle( tr(
"Grid CRS" ) );
122 blockAllSignals(
true );
134 insertFrameDisplayEntries( mFrameDivisionsLeftComboBox );
135 insertFrameDisplayEntries( mFrameDivisionsRightComboBox );
136 insertFrameDisplayEntries( mFrameDivisionsTopComboBox );
137 insertFrameDisplayEntries( mFrameDivisionsBottomComboBox );
139 insertAnnotationDisplayEntries( mAnnotationDisplayLeftComboBox );
140 insertAnnotationDisplayEntries( mAnnotationDisplayRightComboBox );
141 insertAnnotationDisplayEntries( mAnnotationDisplayTopComboBox );
142 insertAnnotationDisplayEntries( mAnnotationDisplayBottomComboBox );
144 insertAnnotationPositionEntries( mAnnotationPositionLeftComboBox );
145 insertAnnotationPositionEntries( mAnnotationPositionRightComboBox );
146 insertAnnotationPositionEntries( mAnnotationPositionTopComboBox );
147 insertAnnotationPositionEntries( mAnnotationPositionBottomComboBox );
149 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxLeft );
150 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxRight );
151 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxTop );
152 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxBottom );
154 mGridFramePenColorButton->setColorDialogTitle( tr(
"Select Grid Frame Color" ) );
155 mGridFramePenColorButton->setAllowOpacity(
true );
156 mGridFramePenColorButton->setContext( QStringLiteral(
"composer" ) );
157 mGridFramePenColorButton->setNoColorString( tr(
"Transparent Frame" ) );
158 mGridFramePenColorButton->setShowNoColor(
true );
160 mGridFrameFill1ColorButton->setColorDialogTitle( tr(
"Select Grid Frame Fill Color" ) );
161 mGridFrameFill1ColorButton->setAllowOpacity(
true );
162 mGridFrameFill1ColorButton->setContext( QStringLiteral(
"composer" ) );
163 mGridFrameFill1ColorButton->setNoColorString( tr(
"Transparent Fill" ) );
164 mGridFrameFill1ColorButton->setShowNoColor(
true );
166 mGridFrameFill2ColorButton->setColorDialogTitle( tr(
"Select Grid Frame Fill Color" ) );
167 mGridFrameFill2ColorButton->setAllowOpacity(
true );
168 mGridFrameFill2ColorButton->setContext( QStringLiteral(
"composer" ) );
169 mGridFrameFill2ColorButton->setNoColorString( tr(
"Transparent Fill" ) );
170 mGridFrameFill2ColorButton->setShowNoColor(
true );
176 toggleFrameControls(
false,
false,
false,
false );
202 blockAllSignals(
false );
203 connect( mAnnotationFontButton, &
QgsFontButton::changed,
this, &QgsLayoutMapGridWidget::annotationTextFormatChanged );
207 mGridLineStyleButton->registerExpressionContextGenerator( mMapGrid );
209 mGridMarkerStyleButton->registerExpressionContextGenerator( mMapGrid );
211 if ( mMap->layout() )
218 mAnnotationFontButton->registerExpressionContextGenerator( mMapGrid );
245 void QgsLayoutMapGridWidget::setGuiElementValues()
252 if ( !mMapGrid || !mMap )
257 blockAllSignals(
true );
260 blockAllSignals(
false );
263 void QgsLayoutMapGridWidget::blockAllSignals(
bool block )
266 mEnabledCheckBox->blockSignals( block );
267 mGridTypeComboBox->blockSignals( block );
268 mIntervalXSpinBox->blockSignals( block );
269 mIntervalYSpinBox->blockSignals( block );
270 mOffsetXSpinBox->blockSignals( block );
271 mOffsetYSpinBox->blockSignals( block );
272 mCrossWidthSpinBox->blockSignals( block );
273 mFrameStyleComboBox->blockSignals( block );
274 mFrameWidthSpinBox->blockSignals( block );
275 mGridFrameMarginSpinBox->blockSignals( block );
276 mGridLineStyleButton->blockSignals( block );
277 mMapGridUnitComboBox->blockSignals( block );
278 mGridFramePenSizeSpinBox->blockSignals( block );
279 mGridFramePenColorButton->blockSignals( block );
280 mGridFrameFill1ColorButton->blockSignals( block );
281 mGridFrameFill2ColorButton->blockSignals( block );
282 mGridBlendComboBox->blockSignals( block );
283 mCheckGridLeftSide->blockSignals( block );
284 mCheckGridRightSide->blockSignals( block );
285 mCheckGridTopSide->blockSignals( block );
286 mCheckGridBottomSide->blockSignals( block );
287 mFrameDivisionsLeftComboBox->blockSignals( block );
288 mFrameDivisionsRightComboBox->blockSignals( block );
289 mFrameDivisionsTopComboBox->blockSignals( block );
290 mFrameDivisionsBottomComboBox->blockSignals( block );
291 mGridMarkerStyleButton->blockSignals( block );
294 mDrawAnnotationGroupBox->blockSignals( block );
295 mAnnotationFormatComboBox->blockSignals( block );
296 mAnnotationDisplayLeftComboBox->blockSignals( block );
297 mAnnotationPositionLeftComboBox->blockSignals( block );
298 mAnnotationDirectionComboBoxLeft->blockSignals( block );
299 mAnnotationDisplayRightComboBox->blockSignals( block );
300 mAnnotationPositionRightComboBox->blockSignals( block );
301 mAnnotationDirectionComboBoxRight->blockSignals( block );
302 mAnnotationDisplayTopComboBox->blockSignals( block );
303 mAnnotationPositionTopComboBox->blockSignals( block );
304 mAnnotationDirectionComboBoxTop->blockSignals( block );
305 mAnnotationDisplayBottomComboBox->blockSignals( block );
306 mAnnotationPositionBottomComboBox->blockSignals( block );
307 mAnnotationDirectionComboBoxBottom->blockSignals( block );
308 mDistanceToMapFrameSpinBox->blockSignals( block );
309 mCoordinatePrecisionSpinBox->blockSignals( block );
310 mAnnotationFontButton->blockSignals( block );
311 mMinWidthSpinBox->blockSignals( block );
312 mMaxWidthSpinBox->blockSignals( block );
317 if ( !mMapGrid || !mMap )
322 mMap->beginCommand( tr(
"Change Frame Divisions" ) );
323 mMapGrid->setFrameDivisions( mode, border );
325 mMap->updateBoundingRect();
330 if ( !mMapGrid || !mMap )
335 mMap->beginCommand( tr(
"Change Annotation Format" ) );
336 mMapGrid->setAnnotationDisplay( mode, border );
337 mMap->updateBoundingRect();
342 void QgsLayoutMapGridWidget::toggleFrameControls(
bool frameEnabled,
bool frameFillEnabled,
bool frameSizeEnabled,
bool rotationEnabled )
345 mFrameWidthSpinBox->setEnabled( frameSizeEnabled );
346 mGridFrameMarginSpinBox->setEnabled( frameEnabled );
347 mGridFramePenSizeSpinBox->setEnabled( frameEnabled );
348 mGridFramePenColorButton->setEnabled( frameEnabled );
349 mGridFrameFill1ColorButton->setEnabled( frameFillEnabled );
350 mGridFrameFill2ColorButton->setEnabled( frameFillEnabled );
351 mFrameWidthLabel->setEnabled( frameSizeEnabled );
352 mFrameMarginLabel->setEnabled( frameEnabled );
353 mFramePenLabel->setEnabled( frameEnabled );
354 mFrameFillLabel->setEnabled( frameFillEnabled );
355 mCheckGridLeftSide->setEnabled( frameEnabled );
356 mCheckGridRightSide->setEnabled( frameEnabled );
357 mCheckGridTopSide->setEnabled( frameEnabled );
358 mCheckGridBottomSide->setEnabled( frameEnabled );
359 mFrameDivisionsLeftComboBox->setEnabled( frameEnabled );
360 mFrameDivisionsRightComboBox->setEnabled( frameEnabled );
361 mFrameDivisionsTopComboBox->setEnabled( frameEnabled );
362 mFrameDivisionsBottomComboBox->setEnabled( frameEnabled );
363 mLeftDivisionsLabel->setEnabled( frameEnabled );
364 mRightDivisionsLabel->setEnabled( frameEnabled );
365 mTopDivisionsLabel->setEnabled( frameEnabled );
366 mBottomDivisionsLabel->setEnabled( frameEnabled );
367 mRotatedTicksGroupBox->setEnabled( rotationEnabled );
370 void QgsLayoutMapGridWidget::insertAnnotationPositionEntries( QComboBox *
c )
376 void QgsLayoutMapGridWidget::insertAnnotationDirectionEntries( QComboBox *
c )
394 c->setCurrentIndex(
c->findData( display ) );
399 if ( !mMapGrid || !mMap )
404 mMap->beginCommand( tr(
"Change Annotation Position" ) );
405 mMapGrid->setAnnotationPosition( position, border );
407 mMap->updateBoundingRect();
414 if ( !mMapGrid || !mMap )
419 mMap->beginCommand( tr(
"Change Annotation Direction" ) );
420 mMapGrid->setAnnotationDirection( direction, border );
421 mMap->updateBoundingRect();
426 void QgsLayoutMapGridWidget::insertFrameDisplayEntries( QComboBox *
c )
433 void QgsLayoutMapGridWidget::insertAnnotationDisplayEntries( QComboBox *
c )
450 c->setCurrentIndex(
c->findText( tr(
"Inside Frame" ) ) );
454 c->setCurrentIndex(
c->findText( tr(
"Outside Frame" ) ) );
464 c->setCurrentIndex(
c->findData( dir ) );
467 bool QgsLayoutMapGridWidget::hasPredefinedScales()
const
472 if ( !hasProjectScales || scales.isEmpty() )
477 QStringList myScalesList = scalesStr.split(
',' );
478 return !myScalesList.isEmpty() && !myScalesList[0].isEmpty();
483 void QgsLayoutMapGridWidget::setGridItems()
490 mGridMarkerStyleButton->registerExpressionContextGenerator( mMapGrid );
491 mGridLineStyleButton->registerExpressionContextGenerator( mMapGrid );
492 mAnnotationFontButton->registerExpressionContextGenerator( mMapGrid );
494 mEnabledCheckBox->setChecked( mMapGrid->enabled() );
495 mIntervalXSpinBox->setValue( mMapGrid->intervalX() );
496 mIntervalYSpinBox->setValue( mMapGrid->intervalY() );
497 mOffsetXSpinBox->setValue( mMapGrid->offsetX() );
498 mOffsetYSpinBox->setValue( mMapGrid->offsetY() );
499 mCrossWidthSpinBox->setValue( mMapGrid->crossLength() );
500 mFrameWidthSpinBox->setValue( mMapGrid->frameWidth() );
501 mGridFrameMarginSpinBox->setValue( mMapGrid->frameMargin() );
502 mGridFramePenSizeSpinBox->setValue( mMapGrid->framePenSize() );
503 mGridFramePenColorButton->setColor( mMapGrid->framePenColor() );
504 mGridFrameFill1ColorButton->setColor( mMapGrid->frameFillColor1() );
505 mGridFrameFill2ColorButton->setColor( mMapGrid->frameFillColor2() );
508 mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findData( gridStyle ) );
512 mCrossWidthSpinBox->setVisible(
true );
513 mCrossWidthDDBtn->setVisible(
true );
514 mCrossWidthLabel->setVisible(
true );
515 mGridLineStyleButton->setVisible(
true );
516 mLineStyleLabel->setVisible(
true );
517 mGridMarkerStyleButton->setVisible(
false );
518 mMarkerStyleLabel->setVisible(
false );
519 mGridBlendComboBox->setVisible(
true );
520 mGridBlendLabel->setVisible(
true );
523 mCrossWidthSpinBox->setVisible(
false );
524 mCrossWidthDDBtn->setVisible(
false );
525 mCrossWidthLabel->setVisible(
false );
526 mGridLineStyleButton->setVisible(
false );
527 mLineStyleLabel->setVisible(
false );
528 mGridMarkerStyleButton->setVisible(
true );
529 mMarkerStyleLabel->setVisible(
true );
530 mGridBlendComboBox->setVisible(
true );
531 mGridBlendLabel->setVisible(
true );
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 mMarkerStyleLabel->setVisible(
false );
541 mGridBlendComboBox->setVisible(
true );
542 mGridBlendLabel->setVisible(
true );
545 mCrossWidthSpinBox->setVisible(
false );
546 mCrossWidthDDBtn->setVisible(
false );
547 mCrossWidthLabel->setVisible(
false );
548 mGridLineStyleButton->setVisible(
false );
549 mLineStyleLabel->setVisible(
false );
550 mGridMarkerStyleButton->setVisible(
false );
551 mMarkerStyleLabel->setVisible(
false );
552 mGridBlendComboBox->setVisible(
false );
553 mGridBlendLabel->setVisible(
false );
558 mFrameWidthSpinBox->setValue( mMapGrid->frameWidth() );
559 mGridFrameMarginSpinBox->setValue( mMapGrid->frameMargin() );
561 mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findData( gridFrameStyle ) );
562 switch ( gridFrameStyle )
566 toggleFrameControls(
true,
true,
true,
false );
571 toggleFrameControls(
true,
false,
true,
true );
575 toggleFrameControls(
true,
false,
false,
false );
578 toggleFrameControls(
false,
false,
false,
false );
587 mRotatedTicksGroupBox->setChecked( mMapGrid->rotatedTicksEnabled() );
588 mRotatedTicksLengthModeComboBox->setCurrentIndex( mRotatedTicksLengthModeComboBox->findData( mMapGrid->rotatedTicksLengthMode() ) );
589 mRotatedTicksThresholdSpinBox->setValue( mMapGrid->rotatedTicksMinimumAngle() );
590 mRotatedTicksMarginToCornerSpinBox->setValue( mMapGrid->rotatedTicksMarginToCorner() );
592 mRotatedAnnotationsGroupBox->setChecked( mMapGrid->rotatedAnnotationsEnabled() );
593 mRotatedAnnotationsLengthModeComboBox->setCurrentIndex( mRotatedAnnotationsLengthModeComboBox->findData( mMapGrid->rotatedAnnotationsLengthMode() ) );
594 mRotatedAnnotationsThresholdSpinBox->setValue( mMapGrid->rotatedAnnotationsMinimumAngle() );
595 mRotatedAnnotationsMarginToCornerSpinBox->setValue( mMapGrid->rotatedAnnotationsMarginToCorner() );
603 mGridLineStyleButton->setSymbol( mMapGrid->lineSymbol()->clone() );
605 mGridMarkerStyleButton->setSymbol( mMapGrid->markerSymbol()->clone() );
607 mGridBlendComboBox->setBlendMode( mMapGrid->blendMode() );
609 mDrawAnnotationGroupBox->setChecked( mMapGrid->annotationEnabled() );
610 mAnnotationDisplayLeftComboBox->setCurrentIndex( mAnnotationDisplayLeftComboBox->findData( mMapGrid->annotationDisplay(
QgsLayoutItemMapGrid::Left ) ) );
611 mAnnotationDisplayRightComboBox->setCurrentIndex( mAnnotationDisplayRightComboBox->findData( mMapGrid->annotationDisplay(
QgsLayoutItemMapGrid::Right ) ) );
612 mAnnotationDisplayTopComboBox->setCurrentIndex( mAnnotationDisplayTopComboBox->findData( mMapGrid->annotationDisplay(
QgsLayoutItemMapGrid::Top ) ) );
613 mAnnotationDisplayBottomComboBox->setCurrentIndex( mAnnotationDisplayBottomComboBox->findData( mMapGrid->annotationDisplay(
QgsLayoutItemMapGrid::Bottom ) ) );
615 mAnnotationPositionLeftComboBox->setCurrentIndex( mAnnotationPositionLeftComboBox->findData( mMapGrid->annotationPosition(
QgsLayoutItemMapGrid::Left ) ) );
616 mAnnotationPositionRightComboBox->setCurrentIndex( mAnnotationPositionRightComboBox->findData( mMapGrid->annotationPosition(
QgsLayoutItemMapGrid::Right ) ) );
617 mAnnotationPositionTopComboBox->setCurrentIndex( mAnnotationPositionTopComboBox->findData( mMapGrid->annotationPosition(
QgsLayoutItemMapGrid::Top ) ) );
618 mAnnotationPositionBottomComboBox->setCurrentIndex( mAnnotationPositionBottomComboBox->findData( mMapGrid->annotationPosition(
QgsLayoutItemMapGrid::Bottom ) ) );
622 initAnnotationDirectionBox( mAnnotationDirectionComboBoxTop, mMapGrid->annotationDirection(
QgsLayoutItemMapGrid::Top ) );
625 mAnnotationFontButton->setDialogTitle( tr(
"Grid Annotation Font" ) );
627 mAnnotationFontButton->setTextFormat( mMapGrid->annotationTextFormat() );
629 mAnnotationFormatComboBox->setCurrentIndex( mAnnotationFormatComboBox->findData( mMapGrid->annotationFormat() ) );
631 mDistanceToMapFrameSpinBox->setValue( mMapGrid->annotationFrameDistance() );
632 mCoordinatePrecisionSpinBox->setValue( mMapGrid->annotationPrecision() );
635 mMapGridUnitComboBox->setCurrentIndex( mMapGridUnitComboBox->findData( mMapGrid->units() ) );
636 switch ( mMapGrid->units() )
641 mIntervalStackedWidget->setCurrentIndex( 0 );
645 mIntervalStackedWidget->setCurrentIndex( 1 );
648 mMinWidthSpinBox->setValue( mMapGrid->minimumIntervalWidth() );
649 mMaxWidthSpinBox->setValue( mMapGrid->maximumIntervalWidth() );
651 whileBlocking( mMapGridCrsSelector )->setCrs( mMapGrid->crs() );
654 void QgsLayoutMapGridWidget::mIntervalXSpinBox_editingFinished()
656 if ( !mMapGrid || !mMap )
661 mMap->beginCommand( tr(
"Change Grid Interval" ) );
662 mMapGrid->setIntervalX( mIntervalXSpinBox->value() );
663 mMap->updateBoundingRect();
668 void QgsLayoutMapGridWidget::mIntervalYSpinBox_editingFinished()
670 if ( !mMapGrid || !mMap )
675 mMap->beginCommand( tr(
"Change Grid Interval" ) );
676 mMapGrid->setIntervalY( mIntervalYSpinBox->value() );
677 mMap->updateBoundingRect();
682 void QgsLayoutMapGridWidget::mOffsetXSpinBox_valueChanged(
double value )
684 if ( !mMapGrid || !mMap )
689 mMap->beginCommand( tr(
"Change Grid Offset" ) );
690 mMapGrid->setOffsetX( value );
691 mMap->updateBoundingRect();
696 void QgsLayoutMapGridWidget::mOffsetYSpinBox_valueChanged(
double value )
698 if ( !mMapGrid || !mMap )
703 mMap->beginCommand( tr(
"Change Grid Offset" ) );
704 mMapGrid->setOffsetY( value );
705 mMap->updateBoundingRect();
710 void QgsLayoutMapGridWidget::mCrossWidthSpinBox_valueChanged(
double val )
712 if ( !mMapGrid || !mMap )
717 mMap->beginCommand( tr(
"Change Cross Width" ) );
718 mMapGrid->setCrossLength( val );
723 void QgsLayoutMapGridWidget::mFrameWidthSpinBox_valueChanged(
double val )
725 if ( !mMapGrid || !mMap )
730 mMap->beginCommand( tr(
"Change Frame Width" ) );
731 mMapGrid->setFrameWidth( val );
732 mMap->updateBoundingRect();
737 void QgsLayoutMapGridWidget::mGridFrameMarginSpinBox_valueChanged(
double val )
739 if ( !mMapGrid || !mMap )
744 mMap->beginCommand( tr(
"Change Grid Frame Margin" ) );
745 mMapGrid->setFrameMargin( val );
746 mMap->updateBoundingRect();
751 void QgsLayoutMapGridWidget::mCheckGridLeftSide_toggled(
bool checked )
753 if ( !mMapGrid || !mMap )
758 mMap->beginCommand( tr(
"Change Frame Left" ) );
760 mMap->updateBoundingRect();
765 void QgsLayoutMapGridWidget::mCheckGridRightSide_toggled(
bool checked )
767 if ( !mMapGrid || !mMap )
772 mMap->beginCommand( tr(
"Change Frame Right" ) );
774 mMap->updateBoundingRect();
779 void QgsLayoutMapGridWidget::mCheckGridTopSide_toggled(
bool checked )
781 if ( !mMapGrid || !mMap )
786 mMap->beginCommand( tr(
"Change Frame Top" ) );
788 mMap->updateBoundingRect();
793 void QgsLayoutMapGridWidget::mCheckGridBottomSide_toggled(
bool checked )
795 if ( !mMapGrid || !mMap )
800 mMap->beginCommand( tr(
"Change Frame Bottom" ) );
802 mMap->updateBoundingRect();
807 void QgsLayoutMapGridWidget::mFrameDivisionsLeftComboBox_currentIndexChanged(
int index )
812 void QgsLayoutMapGridWidget::mFrameDivisionsRightComboBox_currentIndexChanged(
int index )
817 void QgsLayoutMapGridWidget::mFrameDivisionsTopComboBox_currentIndexChanged(
int index )
822 void QgsLayoutMapGridWidget::mFrameDivisionsBottomComboBox_currentIndexChanged(
int index )
827 void QgsLayoutMapGridWidget::mGridFramePenSizeSpinBox_valueChanged(
double d )
829 if ( !mMapGrid || !mMap )
834 mMap->beginCommand( tr(
"Change Frame Thickness" ) );
835 mMapGrid->setFramePenSize( d );
836 mMap->updateBoundingRect();
841 void QgsLayoutMapGridWidget::mGridFramePenColorButton_colorChanged(
const QColor &newColor )
843 if ( !mMapGrid || !mMap )
849 mMapGrid->setFramePenColor( newColor );
854 void QgsLayoutMapGridWidget::mGridFrameFill1ColorButton_colorChanged(
const QColor &newColor )
856 if ( !mMapGrid || !mMap )
862 mMapGrid->setFrameFillColor1( newColor );
867 void QgsLayoutMapGridWidget::mGridFrameFill2ColorButton_colorChanged(
const QColor &newColor )
869 if ( !mMapGrid || !mMap )
875 mMapGrid->setFrameFillColor2( newColor );
880 void QgsLayoutMapGridWidget::mFrameStyleComboBox_currentIndexChanged(
int )
882 if ( !mMapGrid || !mMap )
888 mMap->beginCommand( tr(
"Change Frame Style" ) );
889 mMapGrid->setFrameStyle( style );
894 toggleFrameControls(
true,
true,
true,
false );
899 toggleFrameControls(
true,
false,
true,
true );
903 toggleFrameControls(
true,
false,
false,
false );
906 toggleFrameControls(
false,
false,
false,
false );
909 mMap->updateBoundingRect();
914 void QgsLayoutMapGridWidget::mRotatedTicksGroupBox_toggled(
bool state )
916 if ( !mMapGrid || !mMap )
921 mMap->beginCommand( tr(
"Change Tick Rotation Enabled" ) );
922 mMapGrid->setRotatedTicksEnabled( state );
927 void QgsLayoutMapGridWidget::mRotatedTicksLengthModeComboBox_currentIndexChanged(
int )
929 if ( !mMapGrid || !mMap )
935 mMap->beginCommand( tr(
"Change Tick Length Mode" ) );
936 mMapGrid->setRotatedTicksLengthMode( mode );
941 void QgsLayoutMapGridWidget::mRotatedTicksThresholdSpinBox_valueChanged(
double val )
943 if ( !mMapGrid || !mMap )
948 mMap->beginCommand( tr(
"Change Rotated Ticks Threshold" ) );
949 mMapGrid->setRotatedTicksMinimumAngle( val );
954 void QgsLayoutMapGridWidget::mRotatedTicksMarginToCornerSpinBox_valueChanged(
double val )
956 if ( !mMapGrid || !mMap )
961 mMap->beginCommand( tr(
"Change Rotated Ticks Margin to Corner" ) );
962 mMapGrid->setRotatedTicksMarginToCorner( val );
967 void QgsLayoutMapGridWidget::mRotatedAnnotationsGroupBox_toggled(
bool state )
969 if ( !mMapGrid || !mMap )
974 mMap->beginCommand( tr(
"Change Annotation Rotation Enabled" ) );
975 mMapGrid->setRotatedAnnotationsEnabled( state );
980 void QgsLayoutMapGridWidget::mRotatedAnnotationsLengthModeComboBox_currentIndexChanged(
int )
982 if ( !mMapGrid || !mMap )
988 mMap->beginCommand( tr(
"Change Annotation Length Mode" ) );
989 mMapGrid->setRotatedAnnotationsLengthMode( mode );
994 void QgsLayoutMapGridWidget::mRotatedAnnotationsThresholdSpinBox_valueChanged(
double val )
996 if ( !mMapGrid || !mMap )
1001 mMap->beginCommand( tr(
"Change Rotated Annotations Threshold" ) );
1002 mMapGrid->setRotatedAnnotationsMinimumAngle( val );
1007 void QgsLayoutMapGridWidget::mRotatedAnnotationsMarginToCornerSpinBox_valueChanged(
double val )
1009 if ( !mMapGrid || !mMap )
1014 mMap->beginCommand( tr(
"Change Rotated Annotations Margin to Corner" ) );
1015 mMapGrid->setRotatedAnnotationsMarginToCorner( val );
1020 void QgsLayoutMapGridWidget::intervalUnitChanged(
int )
1022 if ( !mMapGrid || !mMap )
1033 mIntervalStackedWidget->setCurrentIndex( 0 );
1037 mIntervalStackedWidget->setCurrentIndex( 1 );
1041 mMap->beginCommand( tr(
"Change Grid Unit" ) );
1042 mMapGrid->setUnits( unit );
1043 mMap->updateBoundingRect();
1048 void QgsLayoutMapGridWidget::minIntervalChanged(
double interval )
1051 mMapGrid->setMinimumIntervalWidth( interval );
1053 mMap->updateBoundingRect();
1057 void QgsLayoutMapGridWidget::maxIntervalChanged(
double interval )
1060 mMapGrid->setMaximumIntervalWidth( interval );
1062 mMap->updateBoundingRect();
1066 void QgsLayoutMapGridWidget::annotationTextFormatChanged()
1068 if ( !mMapGrid || !mMap )
1073 mMap->beginCommand( tr(
"Change Annotation Font" ) );
1074 mMapGrid->setAnnotationTextFormat( mAnnotationFontButton->textFormat() );
1076 mMap->updateBoundingRect();
1080 void QgsLayoutMapGridWidget::onCrsChanged()
1082 mBlockAnnotationFormatUpdates++;
1085 mAnnotationFormatComboBox->clear();
1115 const int prevIndex = mAnnotationFormatComboBox->findData( prevFormat );
1116 if ( prevIndex >= 0 )
1117 mAnnotationFormatComboBox->setCurrentIndex( prevIndex );
1119 mAnnotationFormatComboBox->setCurrentIndex( 0 );
1120 mBlockAnnotationFormatUpdates--;
1123 if ( newFormat != prevFormat )
1125 mAnnotationFormatComboBox_currentIndexChanged( mAnnotationFormatComboBox->currentIndex() );
1129 void QgsLayoutMapGridWidget::mGridBlendComboBox_currentIndexChanged(
int index )
1134 mMap->beginCommand( tr(
"Change Grid Blend Mode" ) );
1135 mMapGrid->setBlendMode( mGridBlendComboBox->blendMode() );
1142 void QgsLayoutMapGridWidget::mGridTypeComboBox_currentIndexChanged(
int )
1144 if ( !mMapGrid || !mMap )
1149 mMap->beginCommand( tr(
"Change Grid Type" ) );
1154 mCrossWidthSpinBox->setVisible(
true );
1155 mCrossWidthDDBtn->setVisible(
true );
1156 mCrossWidthLabel->setVisible(
true );
1157 mGridLineStyleButton->setVisible(
true );
1158 mLineStyleLabel->setVisible(
true );
1159 mGridMarkerStyleButton->setVisible(
false );
1160 mMarkerStyleLabel->setVisible(
false );
1161 mGridBlendComboBox->setVisible(
true );
1162 mGridBlendLabel->setVisible(
true );
1167 mCrossWidthSpinBox->setVisible(
false );
1168 mCrossWidthDDBtn->setVisible(
false );
1169 mCrossWidthLabel->setVisible(
false );
1170 mGridLineStyleButton->setVisible(
false );
1171 mLineStyleLabel->setVisible(
false );
1172 mGridMarkerStyleButton->setVisible(
true );
1173 mMarkerStyleLabel->setVisible(
true );
1174 mGridBlendComboBox->setVisible(
true );
1175 mGridBlendLabel->setVisible(
true );
1180 mCrossWidthSpinBox->setVisible(
false );
1181 mCrossWidthDDBtn->setVisible(
false );
1182 mCrossWidthLabel->setVisible(
false );
1183 mGridLineStyleButton->setVisible(
true );
1184 mLineStyleLabel->setVisible(
true );
1185 mGridMarkerStyleButton->setVisible(
false );
1186 mMarkerStyleLabel->setVisible(
false );
1187 mGridBlendComboBox->setVisible(
true );
1188 mGridBlendLabel->setVisible(
true );
1193 mCrossWidthSpinBox->setVisible(
false );
1194 mCrossWidthDDBtn->setVisible(
false );
1195 mCrossWidthLabel->setVisible(
false );
1196 mGridLineStyleButton->setVisible(
false );
1197 mLineStyleLabel->setVisible(
false );
1198 mGridMarkerStyleButton->setVisible(
false );
1199 mMarkerStyleLabel->setVisible(
false );
1200 mGridBlendComboBox->setVisible(
false );
1201 mGridBlendLabel->setVisible(
false );
1205 mMap->updateBoundingRect();
1212 if ( !mMapGrid || !mMap )
1217 if ( mMapGrid->crs() ==
crs )
1220 mMap->beginCommand( tr(
"Change Grid CRS" ) );
1221 mMapGrid->setCrs(
crs );
1222 mMap->updateBoundingRect();
1227 void QgsLayoutMapGridWidget::mDrawAnnotationGroupBox_toggled(
bool state )
1229 if ( !mMapGrid || !mMap )
1234 mMap->beginCommand( tr(
"Toggle Annotations" ) );
1235 mMapGrid->setAnnotationEnabled( state );
1236 mMap->updateBoundingRect();
1241 void QgsLayoutMapGridWidget::mAnnotationFormatButton_clicked()
1243 if ( !mMapGrid || !mMap )
1249 expressionContext.
setHighlightedFunctions( QStringList() << QStringLiteral(
"to_dms" ) << QStringLiteral(
"to_dm" ) );
1252 exprDlg.setWindowTitle( tr(
"Expression Based Annotation" ) );
1254 if ( exprDlg.exec() == QDialog::Accepted )
1256 const QString expression = exprDlg.expressionText();
1257 mMap->beginCommand( tr(
"Change Annotation Format" ) );
1258 mMapGrid->setAnnotationExpression( expression );
1259 mMap->updateBoundingRect();
1265 void QgsLayoutMapGridWidget::mAnnotationDisplayLeftComboBox_currentIndexChanged(
int )
1270 void QgsLayoutMapGridWidget::mAnnotationDisplayRightComboBox_currentIndexChanged(
int )
1275 void QgsLayoutMapGridWidget::mAnnotationDisplayTopComboBox_currentIndexChanged(
int )
1280 void QgsLayoutMapGridWidget::mAnnotationDisplayBottomComboBox_currentIndexChanged(
int )
1285 void QgsLayoutMapGridWidget::mAnnotationPositionLeftComboBox_currentIndexChanged(
int )
1290 void QgsLayoutMapGridWidget::mAnnotationPositionRightComboBox_currentIndexChanged(
int )
1295 void QgsLayoutMapGridWidget::mAnnotationPositionTopComboBox_currentIndexChanged(
int )
1300 void QgsLayoutMapGridWidget::mAnnotationPositionBottomComboBox_currentIndexChanged(
int )
1305 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxLeft_currentIndexChanged(
int index )
1310 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxRight_currentIndexChanged(
int index )
1315 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxTop_currentIndexChanged(
int index )
1320 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxBottom_currentIndexChanged(
int index )
1325 void QgsLayoutMapGridWidget::mDistanceToMapFrameSpinBox_valueChanged(
double d )
1327 if ( !mMapGrid || !mMap )
1333 mMapGrid->setAnnotationFrameDistance( d );
1334 mMap->updateBoundingRect();
1339 void QgsLayoutMapGridWidget::lineSymbolChanged()
1341 if ( !mMapGrid || !mMap )
1347 mMapGrid->setLineSymbol( mGridLineStyleButton->clonedSymbol<
QgsLineSymbol>() );
1352 void QgsLayoutMapGridWidget::markerSymbolChanged()
1354 if ( !mMapGrid || !mMap )
1360 mMapGrid->setMarkerSymbol( mGridMarkerStyleButton->clonedSymbol<
QgsMarkerSymbol>() );
1365 void QgsLayoutMapGridWidget::gridEnabledToggled(
bool active )
1367 if ( !mMapGrid || !mMap )
1372 mMap->beginCommand( tr(
"Toggle Grid Display" ) );
1373 mMapGrid->setEnabled( active );
1375 mMap->updateBoundingRect();
1379 void QgsLayoutMapGridWidget::mAnnotationFormatComboBox_currentIndexChanged(
int index )
1381 if ( !mMapGrid || !mMap )
1385 if ( mBlockAnnotationFormatUpdates )
1388 mMap->beginCommand( tr(
"Change Annotation Format" ) );
1393 mMap->updateBoundingRect();
1398 void QgsLayoutMapGridWidget::mCoordinatePrecisionSpinBox_valueChanged(
int value )
1400 if ( !mMapGrid || !mMap )
1404 mMap->beginCommand( tr(
"Change Annotation Precision" ) );
1405 mMapGrid->setAnnotationPrecision( value );
1406 mMap->updateBoundingRect();