55 mGridFrameMarginSpinBox->setShowClearButton(
true );
56 mGridFrameMarginSpinBox->setClearValue( 0 );
58 mDistanceToMapFrameSpinBox->setShowClearButton(
true );
59 mDistanceToMapFrameSpinBox->setClearValue( 0 );
61 connect( mIntervalXSpinBox, &QgsDoubleSpinBox::editingFinished,
this, &QgsLayoutMapGridWidget::mIntervalXSpinBox_editingFinished );
62 connect( mIntervalYSpinBox, &QgsDoubleSpinBox::editingFinished,
this, &QgsLayoutMapGridWidget::mIntervalYSpinBox_editingFinished );
63 connect( mOffsetXSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mOffsetXSpinBox_valueChanged );
64 connect( mOffsetYSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mOffsetYSpinBox_valueChanged );
65 connect( mCrossWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mCrossWidthSpinBox_valueChanged );
66 connect( mFrameWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mFrameWidthSpinBox_valueChanged );
67 connect( mGridFrameMarginSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mGridFrameMarginSpinBox_valueChanged );
68 connect( mFrameStyleComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mFrameStyleComboBox_currentIndexChanged );
69 connect( mRotatedTicksGroupBox, &QGroupBox::toggled,
this, &QgsLayoutMapGridWidget::mRotatedTicksGroupBox_toggled );
70 connect( mRotatedTicksLengthModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mRotatedTicksLengthModeComboBox_currentIndexChanged );
71 connect( mRotatedTicksThresholdSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mRotatedTicksThresholdSpinBox_valueChanged );
72 connect( mRotatedTicksMarginToCornerSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mRotatedTicksMarginToCornerSpinBox_valueChanged );
73 connect( mRotatedAnnotationsGroupBox, &QGroupBox::toggled,
this, &QgsLayoutMapGridWidget::mRotatedAnnotationsGroupBox_toggled );
74 connect( mRotatedAnnotationsLengthModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mRotatedAnnotationsLengthModeComboBox_currentIndexChanged );
75 connect( mRotatedAnnotationsThresholdSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mRotatedAnnotationsThresholdSpinBox_valueChanged );
76 connect( mRotatedAnnotationsMarginToCornerSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mRotatedAnnotationsMarginToCornerSpinBox_valueChanged );
77 connect( mGridFramePenSizeSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mGridFramePenSizeSpinBox_valueChanged );
78 connect( mGridFramePenColorButton, &
QgsColorButton::colorChanged,
this, &QgsLayoutMapGridWidget::mGridFramePenColorButton_colorChanged );
79 connect( mGridFrameFill1ColorButton, &
QgsColorButton::colorChanged,
this, &QgsLayoutMapGridWidget::mGridFrameFill1ColorButton_colorChanged );
80 connect( mGridFrameFill2ColorButton, &
QgsColorButton::colorChanged,
this, &QgsLayoutMapGridWidget::mGridFrameFill2ColorButton_colorChanged );
81 connect( mGridTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mGridTypeComboBox_currentIndexChanged );
82 connect( mMapGridUnitComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::intervalUnitChanged );
83 connect( mGridBlendComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mGridBlendComboBox_currentIndexChanged );
84 connect( mCheckGridLeftSide, &QCheckBox::toggled,
this, &QgsLayoutMapGridWidget::mCheckGridLeftSide_toggled );
85 connect( mCheckGridRightSide, &QCheckBox::toggled,
this, &QgsLayoutMapGridWidget::mCheckGridRightSide_toggled );
86 connect( mCheckGridTopSide, &QCheckBox::toggled,
this, &QgsLayoutMapGridWidget::mCheckGridTopSide_toggled );
87 connect( mCheckGridBottomSide, &QCheckBox::toggled,
this, &QgsLayoutMapGridWidget::mCheckGridBottomSide_toggled );
88 connect( mFrameDivisionsLeftComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mFrameDivisionsLeftComboBox_currentIndexChanged );
89 connect( mFrameDivisionsRightComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mFrameDivisionsRightComboBox_currentIndexChanged );
90 connect( mFrameDivisionsTopComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mFrameDivisionsTopComboBox_currentIndexChanged );
91 connect( mFrameDivisionsBottomComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mFrameDivisionsBottomComboBox_currentIndexChanged );
92 connect( mDrawAnnotationGroupBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutMapGridWidget::mDrawAnnotationGroupBox_toggled );
93 connect( mAnnotationFormatButton, &QToolButton::clicked,
this, &QgsLayoutMapGridWidget::mAnnotationFormatButton_clicked );
94 connect( mAnnotationDisplayLeftComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDisplayLeftComboBox_currentIndexChanged );
95 connect( mAnnotationDisplayRightComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDisplayRightComboBox_currentIndexChanged );
96 connect( mAnnotationDisplayTopComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDisplayTopComboBox_currentIndexChanged );
97 connect( mAnnotationDisplayBottomComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDisplayBottomComboBox_currentIndexChanged );
98 connect( mAnnotationPositionLeftComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationPositionLeftComboBox_currentIndexChanged );
99 connect( mAnnotationPositionRightComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationPositionRightComboBox_currentIndexChanged );
100 connect( mAnnotationPositionTopComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationPositionTopComboBox_currentIndexChanged );
101 connect( mAnnotationPositionBottomComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationPositionBottomComboBox_currentIndexChanged );
102 connect( mAnnotationDirectionComboBoxLeft,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxLeft_currentIndexChanged );
103 connect( mAnnotationDirectionComboBoxRight,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxRight_currentIndexChanged );
104 connect( mAnnotationDirectionComboBoxTop,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxTop_currentIndexChanged );
105 connect( mAnnotationDirectionComboBoxBottom,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxBottom_currentIndexChanged );
106 connect( mAnnotationFormatComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapGridWidget::mAnnotationFormatComboBox_currentIndexChanged );
107 connect( mCoordinatePrecisionSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mCoordinatePrecisionSpinBox_valueChanged );
108 connect( mDistanceToMapFrameSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::mDistanceToMapFrameSpinBox_valueChanged );
109 connect( mMinWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::minIntervalChanged );
110 connect( mMaxWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapGridWidget::maxIntervalChanged );
111 connect( mEnabledCheckBox, &QCheckBox::toggled,
this, &QgsLayoutMapGridWidget::gridEnabledToggled );
115 mMapGridCrsSelector->setNotSetText( tr(
"Use Map CRS" ) );
119 blockAllSignals(
true );
131 insertFrameDisplayEntries( mFrameDivisionsLeftComboBox );
132 insertFrameDisplayEntries( mFrameDivisionsRightComboBox );
133 insertFrameDisplayEntries( mFrameDivisionsTopComboBox );
134 insertFrameDisplayEntries( mFrameDivisionsBottomComboBox );
146 insertAnnotationDisplayEntries( mAnnotationDisplayLeftComboBox );
147 insertAnnotationDisplayEntries( mAnnotationDisplayRightComboBox );
148 insertAnnotationDisplayEntries( mAnnotationDisplayTopComboBox );
149 insertAnnotationDisplayEntries( mAnnotationDisplayBottomComboBox );
151 insertAnnotationPositionEntries( mAnnotationPositionLeftComboBox );
152 insertAnnotationPositionEntries( mAnnotationPositionRightComboBox );
153 insertAnnotationPositionEntries( mAnnotationPositionTopComboBox );
154 insertAnnotationPositionEntries( mAnnotationPositionBottomComboBox );
156 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxLeft );
157 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxRight );
158 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxTop );
159 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxBottom );
161 mGridFramePenColorButton->setColorDialogTitle( tr(
"Select Grid Frame Color" ) );
162 mGridFramePenColorButton->setAllowOpacity(
true );
163 mGridFramePenColorButton->setContext( QStringLiteral(
"composer" ) );
164 mGridFramePenColorButton->setNoColorString( tr(
"Transparent Frame" ) );
165 mGridFramePenColorButton->setShowNoColor(
true );
167 mGridFrameFill1ColorButton->setColorDialogTitle( tr(
"Select Grid Frame Fill Color" ) );
168 mGridFrameFill1ColorButton->setAllowOpacity(
true );
169 mGridFrameFill1ColorButton->setContext( QStringLiteral(
"composer" ) );
170 mGridFrameFill1ColorButton->setNoColorString( tr(
"Transparent Fill" ) );
171 mGridFrameFill1ColorButton->setShowNoColor(
true );
173 mGridFrameFill2ColorButton->setColorDialogTitle( tr(
"Select Grid Frame Fill Color" ) );
174 mGridFrameFill2ColorButton->setAllowOpacity(
true );
175 mGridFrameFill2ColorButton->setContext( QStringLiteral(
"composer" ) );
176 mGridFrameFill2ColorButton->setNoColorString( tr(
"Transparent Fill" ) );
177 mGridFrameFill2ColorButton->setShowNoColor(
true );
183 toggleFrameControls(
false,
false,
false,
false );
206 blockAllSignals(
false );
207 connect( mAnnotationFontButton, &
QgsFontButton::changed,
this, &QgsLayoutMapGridWidget::annotationTextFormatChanged );
211 mGridLineStyleButton->registerExpressionContextGenerator( mMapGrid );
213 mGridMarkerStyleButton->registerExpressionContextGenerator( mMapGrid );
215 if ( mMap->layout() )
222 mAnnotationFontButton->registerExpressionContextGenerator( mMapGrid );
247 void QgsLayoutMapGridWidget::setGuiElementValues()
254 if ( !mMapGrid || !mMap )
259 blockAllSignals(
true );
262 blockAllSignals(
false );
265 void QgsLayoutMapGridWidget::blockAllSignals(
bool block )
268 mEnabledCheckBox->blockSignals( block );
269 mGridTypeComboBox->blockSignals( block );
270 mIntervalXSpinBox->blockSignals( block );
271 mIntervalYSpinBox->blockSignals( block );
272 mOffsetXSpinBox->blockSignals( block );
273 mOffsetYSpinBox->blockSignals( block );
274 mCrossWidthSpinBox->blockSignals( block );
275 mFrameStyleComboBox->blockSignals( block );
276 mFrameWidthSpinBox->blockSignals( block );
277 mGridFrameMarginSpinBox->blockSignals( block );
278 mGridLineStyleButton->blockSignals( block );
279 mMapGridUnitComboBox->blockSignals( block );
280 mGridFramePenSizeSpinBox->blockSignals( block );
281 mGridFramePenColorButton->blockSignals( block );
282 mGridFrameFill1ColorButton->blockSignals( block );
283 mGridFrameFill2ColorButton->blockSignals( block );
284 mGridBlendComboBox->blockSignals( block );
285 mCheckGridLeftSide->blockSignals( block );
286 mCheckGridRightSide->blockSignals( block );
287 mCheckGridTopSide->blockSignals( block );
288 mCheckGridBottomSide->blockSignals( block );
289 mFrameDivisionsLeftComboBox->blockSignals( block );
290 mFrameDivisionsRightComboBox->blockSignals( block );
291 mFrameDivisionsTopComboBox->blockSignals( block );
292 mFrameDivisionsBottomComboBox->blockSignals( block );
293 mGridMarkerStyleButton->blockSignals( block );
296 mDrawAnnotationGroupBox->blockSignals( block );
297 mAnnotationFormatComboBox->blockSignals( block );
298 mAnnotationDisplayLeftComboBox->blockSignals( block );
299 mAnnotationPositionLeftComboBox->blockSignals( block );
300 mAnnotationDirectionComboBoxLeft->blockSignals( block );
301 mAnnotationDisplayRightComboBox->blockSignals( block );
302 mAnnotationPositionRightComboBox->blockSignals( block );
303 mAnnotationDirectionComboBoxRight->blockSignals( block );
304 mAnnotationDisplayTopComboBox->blockSignals( block );
305 mAnnotationPositionTopComboBox->blockSignals( block );
306 mAnnotationDirectionComboBoxTop->blockSignals( block );
307 mAnnotationDisplayBottomComboBox->blockSignals( block );
308 mAnnotationPositionBottomComboBox->blockSignals( block );
309 mAnnotationDirectionComboBoxBottom->blockSignals( block );
310 mDistanceToMapFrameSpinBox->blockSignals( block );
311 mCoordinatePrecisionSpinBox->blockSignals( block );
312 mAnnotationFontButton->blockSignals( block );
313 mMinWidthSpinBox->blockSignals( block );
314 mMaxWidthSpinBox->blockSignals( block );
319 if ( !mMapGrid || !mMap )
324 mMap->beginCommand( tr(
"Change Frame Divisions" ) );
325 mMapGrid->setFrameDivisions( mode, border );
327 mMap->updateBoundingRect();
332 if ( !mMapGrid || !mMap )
337 mMap->beginCommand( tr(
"Change Annotation Format" ) );
338 mMapGrid->setAnnotationDisplay( mode, border );
339 mMap->updateBoundingRect();
344 void QgsLayoutMapGridWidget::toggleFrameControls(
bool frameEnabled,
bool frameFillEnabled,
bool frameSizeEnabled,
bool rotationEnabled )
347 mFrameWidthSpinBox->setEnabled( frameSizeEnabled );
348 mGridFrameMarginSpinBox->setEnabled( frameEnabled );
349 mGridFramePenSizeSpinBox->setEnabled( frameEnabled );
350 mGridFramePenColorButton->setEnabled( frameEnabled );
351 mGridFrameFill1ColorButton->setEnabled( frameFillEnabled );
352 mGridFrameFill2ColorButton->setEnabled( frameFillEnabled );
353 mFrameWidthLabel->setEnabled( frameSizeEnabled );
354 mFrameMarginLabel->setEnabled( frameEnabled );
355 mFramePenLabel->setEnabled( frameEnabled );
356 mFrameFillLabel->setEnabled( frameFillEnabled );
357 mCheckGridLeftSide->setEnabled( frameEnabled );
358 mCheckGridRightSide->setEnabled( frameEnabled );
359 mCheckGridTopSide->setEnabled( frameEnabled );
360 mCheckGridBottomSide->setEnabled( frameEnabled );
361 mFrameDivisionsLeftComboBox->setEnabled( frameEnabled );
362 mFrameDivisionsRightComboBox->setEnabled( frameEnabled );
363 mFrameDivisionsTopComboBox->setEnabled( frameEnabled );
364 mFrameDivisionsBottomComboBox->setEnabled( frameEnabled );
365 mLeftDivisionsLabel->setEnabled( frameEnabled );
366 mRightDivisionsLabel->setEnabled( frameEnabled );
367 mTopDivisionsLabel->setEnabled( frameEnabled );
368 mBottomDivisionsLabel->setEnabled( frameEnabled );
369 mRotatedTicksGroupBox->setEnabled( rotationEnabled );
372 void QgsLayoutMapGridWidget::insertAnnotationPositionEntries( QComboBox *
c )
378 void QgsLayoutMapGridWidget::insertAnnotationDirectionEntries( QComboBox *
c )
396 c->setCurrentIndex(
c->findData( display ) );
401 if ( !mMapGrid || !mMap )
406 mMap->beginCommand( tr(
"Change Annotation Position" ) );
407 mMapGrid->setAnnotationPosition( position, border );
409 mMap->updateBoundingRect();
416 if ( !mMapGrid || !mMap )
421 mMap->beginCommand( tr(
"Change Annotation Direction" ) );
422 mMapGrid->setAnnotationDirection( direction, border );
423 mMap->updateBoundingRect();
428 void QgsLayoutMapGridWidget::insertFrameDisplayEntries( QComboBox *
c )
435 void QgsLayoutMapGridWidget::insertAnnotationDisplayEntries( QComboBox *
c )
452 c->setCurrentIndex(
c->findText( tr(
"Inside Frame" ) ) );
456 c->setCurrentIndex(
c->findText( tr(
"Outside Frame" ) ) );
466 c->setCurrentIndex(
c->findData( dir ) );
469 bool QgsLayoutMapGridWidget::hasPredefinedScales()
const
474 if ( !hasProjectScales || scales.isEmpty() )
479 QStringList myScalesList = scalesStr.split(
',' );
480 return !myScalesList.isEmpty() && !myScalesList[0].isEmpty();
485 void QgsLayoutMapGridWidget::setGridItems()
492 mGridMarkerStyleButton->registerExpressionContextGenerator( mMapGrid );
493 mGridLineStyleButton->registerExpressionContextGenerator( mMapGrid );
494 mAnnotationFontButton->registerExpressionContextGenerator( mMapGrid );
496 mEnabledCheckBox->setChecked( mMapGrid->enabled() );
497 mIntervalXSpinBox->setValue( mMapGrid->intervalX() );
498 mIntervalYSpinBox->setValue( mMapGrid->intervalY() );
499 mOffsetXSpinBox->setValue( mMapGrid->offsetX() );
500 mOffsetYSpinBox->setValue( mMapGrid->offsetY() );
501 mCrossWidthSpinBox->setValue( mMapGrid->crossLength() );
502 mFrameWidthSpinBox->setValue( mMapGrid->frameWidth() );
503 mGridFrameMarginSpinBox->setValue( mMapGrid->frameMargin() );
504 mGridFramePenSizeSpinBox->setValue( mMapGrid->framePenSize() );
505 mGridFramePenColorButton->setColor( mMapGrid->framePenColor() );
506 mGridFrameFill1ColorButton->setColor( mMapGrid->frameFillColor1() );
507 mGridFrameFill2ColorButton->setColor( mMapGrid->frameFillColor2() );
510 mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findData( gridStyle ) );
514 mCrossWidthSpinBox->setVisible(
true );
515 mCrossWidthDDBtn->setVisible(
true );
516 mCrossWidthLabel->setVisible(
true );
517 mGridLineStyleButton->setVisible(
true );
518 mLineStyleLabel->setVisible(
true );
519 mGridMarkerStyleButton->setVisible(
false );
520 mMarkerStyleLabel->setVisible(
false );
521 mGridBlendComboBox->setVisible(
true );
522 mGridBlendLabel->setVisible(
true );
525 mCrossWidthSpinBox->setVisible(
false );
526 mCrossWidthDDBtn->setVisible(
false );
527 mCrossWidthLabel->setVisible(
false );
528 mGridLineStyleButton->setVisible(
false );
529 mLineStyleLabel->setVisible(
false );
530 mGridMarkerStyleButton->setVisible(
true );
531 mMarkerStyleLabel->setVisible(
true );
532 mGridBlendComboBox->setVisible(
true );
533 mGridBlendLabel->setVisible(
true );
536 mCrossWidthSpinBox->setVisible(
false );
537 mCrossWidthDDBtn->setVisible(
false );
538 mCrossWidthLabel->setVisible(
false );
539 mGridLineStyleButton->setVisible(
true );
540 mLineStyleLabel->setVisible(
true );
541 mGridMarkerStyleButton->setVisible(
false );
542 mMarkerStyleLabel->setVisible(
false );
543 mGridBlendComboBox->setVisible(
true );
544 mGridBlendLabel->setVisible(
true );
547 mCrossWidthSpinBox->setVisible(
false );
548 mCrossWidthDDBtn->setVisible(
false );
549 mCrossWidthLabel->setVisible(
false );
550 mGridLineStyleButton->setVisible(
false );
551 mLineStyleLabel->setVisible(
false );
552 mGridMarkerStyleButton->setVisible(
false );
553 mMarkerStyleLabel->setVisible(
false );
554 mGridBlendComboBox->setVisible(
false );
555 mGridBlendLabel->setVisible(
false );
560 mFrameWidthSpinBox->setValue( mMapGrid->frameWidth() );
561 mGridFrameMarginSpinBox->setValue( mMapGrid->frameMargin() );
563 mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findData( gridFrameStyle ) );
564 switch ( gridFrameStyle )
568 toggleFrameControls(
true,
true,
true,
false );
573 toggleFrameControls(
true,
false,
true,
true );
577 toggleFrameControls(
true,
false,
false,
false );
580 toggleFrameControls(
false,
false,
false,
false );
589 mRotatedTicksGroupBox->setChecked( mMapGrid->rotatedTicksEnabled() );
590 mRotatedTicksLengthModeComboBox->setCurrentIndex( mRotatedTicksLengthModeComboBox->findData( mMapGrid->rotatedTicksLengthMode() ) );
591 mRotatedTicksThresholdSpinBox->setValue( mMapGrid->rotatedTicksMinimumAngle() );
592 mRotatedTicksMarginToCornerSpinBox->setValue( mMapGrid->rotatedTicksMarginToCorner() );
594 mRotatedAnnotationsGroupBox->setChecked( mMapGrid->rotatedAnnotationsEnabled() );
595 mRotatedAnnotationsLengthModeComboBox->setCurrentIndex( mRotatedAnnotationsLengthModeComboBox->findData( mMapGrid->rotatedAnnotationsLengthMode() ) );
596 mRotatedAnnotationsThresholdSpinBox->setValue( mMapGrid->rotatedAnnotationsMinimumAngle() );
597 mRotatedAnnotationsMarginToCornerSpinBox->setValue( mMapGrid->rotatedAnnotationsMarginToCorner() );
605 mGridLineStyleButton->setSymbol( mMapGrid->lineSymbol()->clone() );
607 mGridMarkerStyleButton->setSymbol( mMapGrid->markerSymbol()->clone() );
609 mGridBlendComboBox->setBlendMode( mMapGrid->blendMode() );
611 mDrawAnnotationGroupBox->setChecked( mMapGrid->annotationEnabled() );
612 mAnnotationDisplayLeftComboBox->setCurrentIndex( mAnnotationDisplayLeftComboBox->findData( mMapGrid->annotationDisplay(
QgsLayoutItemMapGrid::Left ) ) );
613 mAnnotationDisplayRightComboBox->setCurrentIndex( mAnnotationDisplayRightComboBox->findData( mMapGrid->annotationDisplay(
QgsLayoutItemMapGrid::Right ) ) );
614 mAnnotationDisplayTopComboBox->setCurrentIndex( mAnnotationDisplayTopComboBox->findData( mMapGrid->annotationDisplay(
QgsLayoutItemMapGrid::Top ) ) );
615 mAnnotationDisplayBottomComboBox->setCurrentIndex( mAnnotationDisplayBottomComboBox->findData( mMapGrid->annotationDisplay(
QgsLayoutItemMapGrid::Bottom ) ) );
617 mAnnotationPositionLeftComboBox->setCurrentIndex( mAnnotationPositionLeftComboBox->findData( mMapGrid->annotationPosition(
QgsLayoutItemMapGrid::Left ) ) );
618 mAnnotationPositionRightComboBox->setCurrentIndex( mAnnotationPositionRightComboBox->findData( mMapGrid->annotationPosition(
QgsLayoutItemMapGrid::Right ) ) );
619 mAnnotationPositionTopComboBox->setCurrentIndex( mAnnotationPositionTopComboBox->findData( mMapGrid->annotationPosition(
QgsLayoutItemMapGrid::Top ) ) );
620 mAnnotationPositionBottomComboBox->setCurrentIndex( mAnnotationPositionBottomComboBox->findData( mMapGrid->annotationPosition(
QgsLayoutItemMapGrid::Bottom ) ) );
624 initAnnotationDirectionBox( mAnnotationDirectionComboBoxTop, mMapGrid->annotationDirection(
QgsLayoutItemMapGrid::Top ) );
627 mAnnotationFontButton->setDialogTitle( tr(
"Grid Annotation Font" ) );
629 mAnnotationFontButton->setTextFormat( mMapGrid->annotationTextFormat() );
631 mAnnotationFormatComboBox->setCurrentIndex( mAnnotationFormatComboBox->findData( mMapGrid->annotationFormat() ) );
633 mDistanceToMapFrameSpinBox->setValue( mMapGrid->annotationFrameDistance() );
634 mCoordinatePrecisionSpinBox->setValue( mMapGrid->annotationPrecision() );
637 mMapGridUnitComboBox->setCurrentIndex( mMapGridUnitComboBox->findData( mMapGrid->units() ) );
638 switch ( mMapGrid->units() )
643 mIntervalStackedWidget->setCurrentIndex( 0 );
647 mIntervalStackedWidget->setCurrentIndex( 1 );
650 mMinWidthSpinBox->setValue( mMapGrid->minimumIntervalWidth() );
651 mMaxWidthSpinBox->setValue( mMapGrid->maximumIntervalWidth() );
653 whileBlocking( mMapGridCrsSelector )->setCrs( mMapGrid->crs() );
656 void QgsLayoutMapGridWidget::mIntervalXSpinBox_editingFinished()
658 if ( !mMapGrid || !mMap )
663 mMap->beginCommand( tr(
"Change Grid Interval" ) );
664 mMapGrid->setIntervalX( mIntervalXSpinBox->value() );
665 mMap->updateBoundingRect();
670 void QgsLayoutMapGridWidget::mIntervalYSpinBox_editingFinished()
672 if ( !mMapGrid || !mMap )
677 mMap->beginCommand( tr(
"Change Grid Interval" ) );
678 mMapGrid->setIntervalY( mIntervalYSpinBox->value() );
679 mMap->updateBoundingRect();
684 void QgsLayoutMapGridWidget::mOffsetXSpinBox_valueChanged(
double value )
686 if ( !mMapGrid || !mMap )
691 mMap->beginCommand( tr(
"Change Grid Offset" ) );
692 mMapGrid->setOffsetX( value );
693 mMap->updateBoundingRect();
698 void QgsLayoutMapGridWidget::mOffsetYSpinBox_valueChanged(
double value )
700 if ( !mMapGrid || !mMap )
705 mMap->beginCommand( tr(
"Change Grid Offset" ) );
706 mMapGrid->setOffsetY( value );
707 mMap->updateBoundingRect();
712 void QgsLayoutMapGridWidget::mCrossWidthSpinBox_valueChanged(
double val )
714 if ( !mMapGrid || !mMap )
719 mMap->beginCommand( tr(
"Change Cross Width" ) );
720 mMapGrid->setCrossLength( val );
725 void QgsLayoutMapGridWidget::mFrameWidthSpinBox_valueChanged(
double val )
727 if ( !mMapGrid || !mMap )
732 mMap->beginCommand( tr(
"Change Frame Width" ) );
733 mMapGrid->setFrameWidth( val );
734 mMap->updateBoundingRect();
739 void QgsLayoutMapGridWidget::mGridFrameMarginSpinBox_valueChanged(
double val )
741 if ( !mMapGrid || !mMap )
746 mMap->beginCommand( tr(
"Change Grid Frame Margin" ) );
747 mMapGrid->setFrameMargin( val );
748 mMap->updateBoundingRect();
753 void QgsLayoutMapGridWidget::mCheckGridLeftSide_toggled(
bool checked )
755 if ( !mMapGrid || !mMap )
760 mMap->beginCommand( tr(
"Change Frame Left" ) );
762 mMap->updateBoundingRect();
767 void QgsLayoutMapGridWidget::mCheckGridRightSide_toggled(
bool checked )
769 if ( !mMapGrid || !mMap )
774 mMap->beginCommand( tr(
"Change Frame Right" ) );
776 mMap->updateBoundingRect();
781 void QgsLayoutMapGridWidget::mCheckGridTopSide_toggled(
bool checked )
783 if ( !mMapGrid || !mMap )
788 mMap->beginCommand( tr(
"Change Frame Top" ) );
790 mMap->updateBoundingRect();
795 void QgsLayoutMapGridWidget::mCheckGridBottomSide_toggled(
bool checked )
797 if ( !mMapGrid || !mMap )
802 mMap->beginCommand( tr(
"Change Frame Bottom" ) );
804 mMap->updateBoundingRect();
809 void QgsLayoutMapGridWidget::mFrameDivisionsLeftComboBox_currentIndexChanged(
int index )
814 void QgsLayoutMapGridWidget::mFrameDivisionsRightComboBox_currentIndexChanged(
int index )
819 void QgsLayoutMapGridWidget::mFrameDivisionsTopComboBox_currentIndexChanged(
int index )
824 void QgsLayoutMapGridWidget::mFrameDivisionsBottomComboBox_currentIndexChanged(
int index )
829 void QgsLayoutMapGridWidget::mGridFramePenSizeSpinBox_valueChanged(
double d )
831 if ( !mMapGrid || !mMap )
836 mMap->beginCommand( tr(
"Change Frame Thickness" ) );
837 mMapGrid->setFramePenSize( d );
838 mMap->updateBoundingRect();
843 void QgsLayoutMapGridWidget::mGridFramePenColorButton_colorChanged(
const QColor &newColor )
845 if ( !mMapGrid || !mMap )
851 mMapGrid->setFramePenColor( newColor );
856 void QgsLayoutMapGridWidget::mGridFrameFill1ColorButton_colorChanged(
const QColor &newColor )
858 if ( !mMapGrid || !mMap )
864 mMapGrid->setFrameFillColor1( newColor );
869 void QgsLayoutMapGridWidget::mGridFrameFill2ColorButton_colorChanged(
const QColor &newColor )
871 if ( !mMapGrid || !mMap )
877 mMapGrid->setFrameFillColor2( newColor );
882 void QgsLayoutMapGridWidget::mFrameStyleComboBox_currentIndexChanged(
int )
884 if ( !mMapGrid || !mMap )
890 mMap->beginCommand( tr(
"Change Frame Style" ) );
891 mMapGrid->setFrameStyle( style );
896 toggleFrameControls(
true,
true,
true,
false );
901 toggleFrameControls(
true,
false,
true,
true );
905 toggleFrameControls(
true,
false,
false,
false );
908 toggleFrameControls(
false,
false,
false,
false );
911 mMap->updateBoundingRect();
916 void QgsLayoutMapGridWidget::mRotatedTicksGroupBox_toggled(
bool state )
918 if ( !mMapGrid || !mMap )
923 mMap->beginCommand( tr(
"Change Tick Rotation Enabled" ) );
924 mMapGrid->setRotatedTicksEnabled( state );
929 void QgsLayoutMapGridWidget::mRotatedTicksLengthModeComboBox_currentIndexChanged(
int )
931 if ( !mMapGrid || !mMap )
937 mMap->beginCommand( tr(
"Change Tick Length Mode" ) );
938 mMapGrid->setRotatedTicksLengthMode( mode );
943 void QgsLayoutMapGridWidget::mRotatedTicksThresholdSpinBox_valueChanged(
double val )
945 if ( !mMapGrid || !mMap )
950 mMap->beginCommand( tr(
"Change Rotated Ticks Threshold" ) );
951 mMapGrid->setRotatedTicksMinimumAngle( val );
956 void QgsLayoutMapGridWidget::mRotatedTicksMarginToCornerSpinBox_valueChanged(
double val )
958 if ( !mMapGrid || !mMap )
963 mMap->beginCommand( tr(
"Change Rotated Ticks Margin to Corner" ) );
964 mMapGrid->setRotatedTicksMarginToCorner( val );
969 void QgsLayoutMapGridWidget::mRotatedAnnotationsGroupBox_toggled(
bool state )
971 if ( !mMapGrid || !mMap )
976 mMap->beginCommand( tr(
"Change Annotation Rotation Enabled" ) );
977 mMapGrid->setRotatedAnnotationsEnabled( state );
982 void QgsLayoutMapGridWidget::mRotatedAnnotationsLengthModeComboBox_currentIndexChanged(
int )
984 if ( !mMapGrid || !mMap )
990 mMap->beginCommand( tr(
"Change Annotation Length Mode" ) );
991 mMapGrid->setRotatedAnnotationsLengthMode( mode );
996 void QgsLayoutMapGridWidget::mRotatedAnnotationsThresholdSpinBox_valueChanged(
double val )
998 if ( !mMapGrid || !mMap )
1003 mMap->beginCommand( tr(
"Change Rotated Annotations Threshold" ) );
1004 mMapGrid->setRotatedAnnotationsMinimumAngle( val );
1009 void QgsLayoutMapGridWidget::mRotatedAnnotationsMarginToCornerSpinBox_valueChanged(
double val )
1011 if ( !mMapGrid || !mMap )
1016 mMap->beginCommand( tr(
"Change Rotated Annotations Margin to Corner" ) );
1017 mMapGrid->setRotatedAnnotationsMarginToCorner( val );
1022 void QgsLayoutMapGridWidget::intervalUnitChanged(
int )
1024 if ( !mMapGrid || !mMap )
1035 mIntervalStackedWidget->setCurrentIndex( 0 );
1039 mIntervalStackedWidget->setCurrentIndex( 1 );
1043 mMap->beginCommand( tr(
"Change Grid Unit" ) );
1044 mMapGrid->setUnits( unit );
1045 mMap->updateBoundingRect();
1050 void QgsLayoutMapGridWidget::minIntervalChanged(
double interval )
1053 mMapGrid->setMinimumIntervalWidth( interval );
1055 mMap->updateBoundingRect();
1059 void QgsLayoutMapGridWidget::maxIntervalChanged(
double interval )
1062 mMapGrid->setMaximumIntervalWidth( interval );
1064 mMap->updateBoundingRect();
1068 void QgsLayoutMapGridWidget::annotationTextFormatChanged()
1070 if ( !mMapGrid || !mMap )
1075 mMap->beginCommand( tr(
"Change Annotation Font" ) );
1076 mMapGrid->setAnnotationTextFormat( mAnnotationFontButton->textFormat() );
1078 mMap->updateBoundingRect();
1082 void QgsLayoutMapGridWidget::mGridBlendComboBox_currentIndexChanged(
int index )
1087 mMap->beginCommand( tr(
"Change Grid Blend Mode" ) );
1088 mMapGrid->setBlendMode( mGridBlendComboBox->blendMode() );
1095 void QgsLayoutMapGridWidget::mGridTypeComboBox_currentIndexChanged(
int )
1097 if ( !mMapGrid || !mMap )
1102 mMap->beginCommand( tr(
"Change Grid Type" ) );
1107 mCrossWidthSpinBox->setVisible(
true );
1108 mCrossWidthDDBtn->setVisible(
true );
1109 mCrossWidthLabel->setVisible(
true );
1110 mGridLineStyleButton->setVisible(
true );
1111 mLineStyleLabel->setVisible(
true );
1112 mGridMarkerStyleButton->setVisible(
false );
1113 mMarkerStyleLabel->setVisible(
false );
1114 mGridBlendComboBox->setVisible(
true );
1115 mGridBlendLabel->setVisible(
true );
1120 mCrossWidthSpinBox->setVisible(
false );
1121 mCrossWidthDDBtn->setVisible(
false );
1122 mCrossWidthLabel->setVisible(
false );
1123 mGridLineStyleButton->setVisible(
false );
1124 mLineStyleLabel->setVisible(
false );
1125 mGridMarkerStyleButton->setVisible(
true );
1126 mMarkerStyleLabel->setVisible(
true );
1127 mGridBlendComboBox->setVisible(
true );
1128 mGridBlendLabel->setVisible(
true );
1133 mCrossWidthSpinBox->setVisible(
false );
1134 mCrossWidthDDBtn->setVisible(
false );
1135 mCrossWidthLabel->setVisible(
false );
1136 mGridLineStyleButton->setVisible(
true );
1137 mLineStyleLabel->setVisible(
true );
1138 mGridMarkerStyleButton->setVisible(
false );
1139 mMarkerStyleLabel->setVisible(
false );
1140 mGridBlendComboBox->setVisible(
true );
1141 mGridBlendLabel->setVisible(
true );
1146 mCrossWidthSpinBox->setVisible(
false );
1147 mCrossWidthDDBtn->setVisible(
false );
1148 mCrossWidthLabel->setVisible(
false );
1149 mGridLineStyleButton->setVisible(
false );
1150 mLineStyleLabel->setVisible(
false );
1151 mGridMarkerStyleButton->setVisible(
false );
1152 mMarkerStyleLabel->setVisible(
false );
1153 mGridBlendComboBox->setVisible(
false );
1154 mGridBlendLabel->setVisible(
false );
1158 mMap->updateBoundingRect();
1165 if ( !mMapGrid || !mMap )
1170 if ( mMapGrid->crs() ==
crs )
1173 mMap->beginCommand( tr(
"Change Grid CRS" ) );
1174 mMapGrid->setCrs(
crs );
1175 mMap->updateBoundingRect();
1180 void QgsLayoutMapGridWidget::mDrawAnnotationGroupBox_toggled(
bool state )
1182 if ( !mMapGrid || !mMap )
1187 mMap->beginCommand( tr(
"Toggle Annotations" ) );
1188 mMapGrid->setAnnotationEnabled( state );
1189 mMap->updateBoundingRect();
1194 void QgsLayoutMapGridWidget::mAnnotationFormatButton_clicked()
1196 if ( !mMapGrid || !mMap )
1202 expressionContext.
setHighlightedFunctions( QStringList() << QStringLiteral(
"to_dms" ) << QStringLiteral(
"to_dm" ) );
1204 QgsExpressionBuilderDialog exprDlg(
nullptr, mMapGrid->annotationExpression(),
this, QStringLiteral(
"generic" ), expressionContext );
1205 exprDlg.setWindowTitle( tr(
"Expression Based Annotation" ) );
1207 if ( exprDlg.exec() == QDialog::Accepted )
1209 QString expression = exprDlg.expressionText();
1210 mMap->beginCommand( tr(
"Change Annotation Format" ) );
1211 mMapGrid->setAnnotationExpression( expression );
1212 mMap->updateBoundingRect();
1218 void QgsLayoutMapGridWidget::mAnnotationDisplayLeftComboBox_currentIndexChanged(
int )
1223 void QgsLayoutMapGridWidget::mAnnotationDisplayRightComboBox_currentIndexChanged(
int )
1228 void QgsLayoutMapGridWidget::mAnnotationDisplayTopComboBox_currentIndexChanged(
int )
1233 void QgsLayoutMapGridWidget::mAnnotationDisplayBottomComboBox_currentIndexChanged(
int )
1238 void QgsLayoutMapGridWidget::mAnnotationPositionLeftComboBox_currentIndexChanged(
int )
1243 void QgsLayoutMapGridWidget::mAnnotationPositionRightComboBox_currentIndexChanged(
int )
1248 void QgsLayoutMapGridWidget::mAnnotationPositionTopComboBox_currentIndexChanged(
int )
1253 void QgsLayoutMapGridWidget::mAnnotationPositionBottomComboBox_currentIndexChanged(
int )
1258 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxLeft_currentIndexChanged(
int index )
1263 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxRight_currentIndexChanged(
int index )
1268 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxTop_currentIndexChanged(
int index )
1273 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxBottom_currentIndexChanged(
int index )
1278 void QgsLayoutMapGridWidget::mDistanceToMapFrameSpinBox_valueChanged(
double d )
1280 if ( !mMapGrid || !mMap )
1286 mMapGrid->setAnnotationFrameDistance( d );
1287 mMap->updateBoundingRect();
1292 void QgsLayoutMapGridWidget::lineSymbolChanged()
1294 if ( !mMapGrid || !mMap )
1300 mMapGrid->setLineSymbol( mGridLineStyleButton->clonedSymbol<
QgsLineSymbol>() );
1305 void QgsLayoutMapGridWidget::markerSymbolChanged()
1307 if ( !mMapGrid || !mMap )
1313 mMapGrid->setMarkerSymbol( mGridMarkerStyleButton->clonedSymbol<
QgsMarkerSymbol>() );
1318 void QgsLayoutMapGridWidget::gridEnabledToggled(
bool active )
1320 if ( !mMapGrid || !mMap )
1325 mMap->beginCommand( tr(
"Toggle Grid Display" ) );
1326 mMapGrid->setEnabled( active );
1328 mMap->updateBoundingRect();
1332 void QgsLayoutMapGridWidget::mAnnotationFormatComboBox_currentIndexChanged(
int index )
1334 if ( !mMapGrid || !mMap )
1339 mMap->beginCommand( tr(
"Change Annotation Format" ) );
1344 mMap->updateBoundingRect();
1349 void QgsLayoutMapGridWidget::mCoordinatePrecisionSpinBox_valueChanged(
int value )
1351 if ( !mMapGrid || !mMap )
1355 mMap->beginCommand( tr(
"Change Annotation Precision" ) );
1356 mMapGrid->setAnnotationPrecision( value );
1357 mMap->updateBoundingRect();