48 mGridFrameMarginSpinBox->setShowClearButton(
true );
49 mGridFrameMarginSpinBox->setClearValue( 0 );
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 );
100 blockAllSignals(
true );
112 insertFrameDisplayEntries( mFrameDivisionsLeftComboBox );
113 insertFrameDisplayEntries( mFrameDivisionsRightComboBox );
114 insertFrameDisplayEntries( mFrameDivisionsTopComboBox );
115 insertFrameDisplayEntries( mFrameDivisionsBottomComboBox );
127 mAnnotationFontColorButton->setColorDialogTitle( tr(
"Select Font Color" ) );
128 mAnnotationFontColorButton->setAllowOpacity(
true );
129 mAnnotationFontColorButton->setContext( QStringLiteral(
"composer" ) );
131 insertAnnotationDisplayEntries( mAnnotationDisplayLeftComboBox );
132 insertAnnotationDisplayEntries( mAnnotationDisplayRightComboBox );
133 insertAnnotationDisplayEntries( mAnnotationDisplayTopComboBox );
134 insertAnnotationDisplayEntries( mAnnotationDisplayBottomComboBox );
136 insertAnnotationPositionEntries( mAnnotationPositionLeftComboBox );
137 insertAnnotationPositionEntries( mAnnotationPositionRightComboBox );
138 insertAnnotationPositionEntries( mAnnotationPositionTopComboBox );
139 insertAnnotationPositionEntries( mAnnotationPositionBottomComboBox );
141 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxLeft );
142 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxRight );
143 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxTop );
144 insertAnnotationDirectionEntries( mAnnotationDirectionComboBoxBottom );
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 );
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 );
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 );
168 toggleFrameControls(
false,
false,
false );
183 blockAllSignals(
false );
184 connect( mAnnotationFontButton, &
QgsFontButton::changed,
this, &QgsLayoutMapGridWidget::annotationFontChanged );
188 mGridLineStyleButton->registerExpressionContextGenerator( mMapGrid );
190 mGridMarkerStyleButton->registerExpressionContextGenerator( mMapGrid );
192 if ( mMap->layout() )
214 void QgsLayoutMapGridWidget::setGuiElementValues()
221 if ( !mMapGrid || !mMap )
226 blockAllSignals(
true );
229 blockAllSignals(
false );
232 void QgsLayoutMapGridWidget::blockAllSignals(
bool block )
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 );
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 );
287 if ( !mMapGrid || !mMap )
292 mMap->beginCommand( tr(
"Change Frame Divisions" ) );
293 mMapGrid->setFrameDivisions( mode, border );
295 mMap->updateBoundingRect();
300 if ( !mMapGrid || !mMap )
305 mMap->beginCommand( tr(
"Change Annotation Format" ) );
306 mMapGrid->setAnnotationDisplay( mode, border );
307 mMap->updateBoundingRect();
312 void QgsLayoutMapGridWidget::toggleFrameControls(
bool frameEnabled,
bool frameFillEnabled,
bool frameSizeEnabled )
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 );
339 void QgsLayoutMapGridWidget::insertAnnotationPositionEntries( QComboBox *
c )
345 void QgsLayoutMapGridWidget::insertAnnotationDirectionEntries( QComboBox *
c )
358 c->setCurrentIndex(
c->findData( display ) );
363 if ( !mMapGrid || !mMap )
368 mMap->beginCommand( tr(
"Change Annotation Position" ) );
369 mMapGrid->setAnnotationPosition( position, border );
371 mMap->updateBoundingRect();
378 if ( !mMapGrid || !mMap )
383 mMap->beginCommand( tr(
"Change Annotation Direction" ) );
384 mMapGrid->setAnnotationDirection( direction, border );
385 mMap->updateBoundingRect();
390 void QgsLayoutMapGridWidget::insertFrameDisplayEntries( QComboBox *
c )
397 void QgsLayoutMapGridWidget::insertAnnotationDisplayEntries( QComboBox *
c )
414 c->setCurrentIndex(
c->findText( tr(
"Inside Frame" ) ) );
418 c->setCurrentIndex(
c->findText( tr(
"Outside Frame" ) ) );
428 c->setCurrentIndex(
c->findData( dir ) );
431 bool QgsLayoutMapGridWidget::hasPredefinedScales()
const
436 if ( !hasProjectScales || scales.isEmpty() )
441 QStringList myScalesList = scalesStr.split(
',' );
442 return !myScalesList.isEmpty() && !myScalesList[0].isEmpty();
447 void QgsLayoutMapGridWidget::setGridItems()
454 mGridMarkerStyleButton->registerExpressionContextGenerator( mMapGrid );
455 mGridLineStyleButton->registerExpressionContextGenerator( mMapGrid );
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() );
471 mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findData( gridStyle ) );
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 );
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 );
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 );
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 );
521 mFrameWidthSpinBox->setValue( mMapGrid->frameWidth() );
522 mGridFrameMarginSpinBox->setValue( mMapGrid->frameMargin() );
524 mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findData( gridFrameStyle ) );
525 switch ( gridFrameStyle )
529 toggleFrameControls(
true,
true,
true );
534 toggleFrameControls(
true,
false,
true );
538 toggleFrameControls(
true,
false,
false );
541 toggleFrameControls(
false,
false,
false );
556 mGridLineStyleButton->setSymbol( mMapGrid->lineSymbol()->clone() );
558 mGridMarkerStyleButton->setSymbol( mMapGrid->markerSymbol()->clone() );
560 mGridBlendComboBox->setBlendMode( mMapGrid->blendMode() );
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 ) ) );
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 ) ) );
575 initAnnotationDirectionBox( mAnnotationDirectionComboBoxTop, mMapGrid->annotationDirection(
QgsLayoutItemMapGrid::Top ) );
578 mAnnotationFontColorButton->setColor( mMapGrid->annotationFontColor() );
579 mAnnotationFontButton->setCurrentFont( mMapGrid->annotationFont() );
581 mAnnotationFormatComboBox->setCurrentIndex( mAnnotationFormatComboBox->findData( mMapGrid->annotationFormat() ) );
583 mDistanceToMapFrameSpinBox->setValue( mMapGrid->annotationFrameDistance() );
584 mCoordinatePrecisionSpinBox->setValue( mMapGrid->annotationPrecision() );
587 mMapGridUnitComboBox->setCurrentIndex( mMapGridUnitComboBox->findData( mMapGrid->units() ) );
588 switch ( mMapGrid->units() )
593 mIntervalStackedWidget->setCurrentIndex( 0 );
597 mIntervalStackedWidget->setCurrentIndex( 1 );
600 mMinWidthSpinBox->setValue( mMapGrid->minimumIntervalWidth() );
601 mMaxWidthSpinBox->setValue( mMapGrid->maximumIntervalWidth() );
605 QString crsButtonText = gridCrs.
isValid() ? gridCrs.
authid() : tr(
"Change…" );
606 mMapGridCRSButton->setText( crsButtonText );
609 void QgsLayoutMapGridWidget::mIntervalXSpinBox_editingFinished()
611 if ( !mMapGrid || !mMap )
616 mMap->beginCommand( tr(
"Change Grid Interval" ) );
617 mMapGrid->setIntervalX( mIntervalXSpinBox->value() );
618 mMap->updateBoundingRect();
623 void QgsLayoutMapGridWidget::mIntervalYSpinBox_editingFinished()
625 if ( !mMapGrid || !mMap )
630 mMap->beginCommand( tr(
"Change Grid Interval" ) );
631 mMapGrid->setIntervalY( mIntervalYSpinBox->value() );
632 mMap->updateBoundingRect();
637 void QgsLayoutMapGridWidget::mOffsetXSpinBox_valueChanged(
double value )
639 if ( !mMapGrid || !mMap )
644 mMap->beginCommand( tr(
"Change Grid Offset" ) );
645 mMapGrid->setOffsetX( value );
646 mMap->updateBoundingRect();
651 void QgsLayoutMapGridWidget::mOffsetYSpinBox_valueChanged(
double value )
653 if ( !mMapGrid || !mMap )
658 mMap->beginCommand( tr(
"Change Grid Offset" ) );
659 mMapGrid->setOffsetY( value );
660 mMap->updateBoundingRect();
665 void QgsLayoutMapGridWidget::mCrossWidthSpinBox_valueChanged(
double val )
667 if ( !mMapGrid || !mMap )
672 mMap->beginCommand( tr(
"Change Cross Width" ) );
673 mMapGrid->setCrossLength( val );
678 void QgsLayoutMapGridWidget::mFrameWidthSpinBox_valueChanged(
double val )
680 if ( !mMapGrid || !mMap )
685 mMap->beginCommand( tr(
"Change Frame Width" ) );
686 mMapGrid->setFrameWidth( val );
687 mMap->updateBoundingRect();
692 void QgsLayoutMapGridWidget::mGridFrameMarginSpinBox_valueChanged(
double val )
694 if ( !mMapGrid || !mMap )
699 mMap->beginCommand( tr(
"Change Grid Frame Margin" ) );
700 mMapGrid->setFrameMargin( val );
701 mMap->updateBoundingRect();
706 void QgsLayoutMapGridWidget::mCheckGridLeftSide_toggled(
bool checked )
708 if ( !mMapGrid || !mMap )
713 mMap->beginCommand( tr(
"Change Frame Left" ) );
715 mMap->updateBoundingRect();
720 void QgsLayoutMapGridWidget::mCheckGridRightSide_toggled(
bool checked )
722 if ( !mMapGrid || !mMap )
727 mMap->beginCommand( tr(
"Change Frame Right" ) );
729 mMap->updateBoundingRect();
734 void QgsLayoutMapGridWidget::mCheckGridTopSide_toggled(
bool checked )
736 if ( !mMapGrid || !mMap )
741 mMap->beginCommand( tr(
"Change Frame Top" ) );
743 mMap->updateBoundingRect();
748 void QgsLayoutMapGridWidget::mCheckGridBottomSide_toggled(
bool checked )
750 if ( !mMapGrid || !mMap )
755 mMap->beginCommand( tr(
"Change Frame Bottom" ) );
757 mMap->updateBoundingRect();
762 void QgsLayoutMapGridWidget::mFrameDivisionsLeftComboBox_currentIndexChanged(
int index )
767 void QgsLayoutMapGridWidget::mFrameDivisionsRightComboBox_currentIndexChanged(
int index )
772 void QgsLayoutMapGridWidget::mFrameDivisionsTopComboBox_currentIndexChanged(
int index )
777 void QgsLayoutMapGridWidget::mFrameDivisionsBottomComboBox_currentIndexChanged(
int index )
782 void QgsLayoutMapGridWidget::mGridFramePenSizeSpinBox_valueChanged(
double d )
784 if ( !mMapGrid || !mMap )
789 mMap->beginCommand( tr(
"Change Frame Thickness" ) );
790 mMapGrid->setFramePenSize( d );
791 mMap->updateBoundingRect();
796 void QgsLayoutMapGridWidget::mGridFramePenColorButton_colorChanged(
const QColor &newColor )
798 if ( !mMapGrid || !mMap )
804 mMapGrid->setFramePenColor( newColor );
809 void QgsLayoutMapGridWidget::mGridFrameFill1ColorButton_colorChanged(
const QColor &newColor )
811 if ( !mMapGrid || !mMap )
817 mMapGrid->setFrameFillColor1( newColor );
822 void QgsLayoutMapGridWidget::mGridFrameFill2ColorButton_colorChanged(
const QColor &newColor )
824 if ( !mMapGrid || !mMap )
830 mMapGrid->setFrameFillColor2( newColor );
835 void QgsLayoutMapGridWidget::mFrameStyleComboBox_currentIndexChanged(
int )
837 if ( !mMapGrid || !mMap )
843 mMap->beginCommand( tr(
"Change Frame Style" ) );
844 mMapGrid->setFrameStyle( style );
849 toggleFrameControls(
true,
true,
true );
854 toggleFrameControls(
true,
false,
true );
858 toggleFrameControls(
true,
false,
false );
861 toggleFrameControls(
false,
false,
false );
864 mMap->updateBoundingRect();
869 void QgsLayoutMapGridWidget::intervalUnitChanged(
int )
871 if ( !mMapGrid || !mMap )
882 mIntervalStackedWidget->setCurrentIndex( 0 );
886 mIntervalStackedWidget->setCurrentIndex( 1 );
890 mMap->beginCommand( tr(
"Change Grid Unit" ) );
891 mMapGrid->setUnits( unit );
892 mMap->updateBoundingRect();
897 void QgsLayoutMapGridWidget::minIntervalChanged(
double interval )
900 mMapGrid->setMinimumIntervalWidth( interval );
902 mMap->updateBoundingRect();
906 void QgsLayoutMapGridWidget::maxIntervalChanged(
double interval )
909 mMapGrid->setMaximumIntervalWidth( interval );
911 mMap->updateBoundingRect();
915 void QgsLayoutMapGridWidget::mGridBlendComboBox_currentIndexChanged(
int index )
920 mMap->beginCommand( tr(
"Change Grid Blend Mode" ) );
921 mMapGrid->setBlendMode( mGridBlendComboBox->blendMode() );
928 void QgsLayoutMapGridWidget::mGridTypeComboBox_currentIndexChanged(
int )
930 if ( !mMapGrid || !mMap )
935 mMap->beginCommand( tr(
"Change Grid Type" ) );
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 );
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 );
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 );
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 );
991 mMap->updateBoundingRect();
996 void QgsLayoutMapGridWidget::mMapGridCRSButton_clicked()
998 if ( !mMapGrid || !mMap )
1007 if ( crsDialog.exec() == QDialog::Accepted )
1009 mMap->beginCommand( tr(
"Change Grid CRS" ) );
1010 mMapGrid->setCrs( crsDialog.crs() );
1011 mMap->updateBoundingRect();
1012 mMapGridCRSButton->setText( crsDialog.crs().authid() );
1017 void QgsLayoutMapGridWidget::mDrawAnnotationGroupBox_toggled(
bool state )
1019 if ( !mMapGrid || !mMap )
1024 mMap->beginCommand( tr(
"Toggle Annotations" ) );
1025 mMapGrid->setAnnotationEnabled( state );
1026 mMap->updateBoundingRect();
1031 void QgsLayoutMapGridWidget::mAnnotationFormatButton_clicked()
1033 if ( !mMapGrid || !mMap )
1039 expressionContext.
setHighlightedFunctions( QStringList() << QStringLiteral(
"to_dms" ) << QStringLiteral(
"to_dm" ) );
1041 QgsExpressionBuilderDialog exprDlg(
nullptr, mMapGrid->annotationExpression(),
this, QStringLiteral(
"generic" ), expressionContext );
1042 exprDlg.setWindowTitle( tr(
"Expression Based Annotation" ) );
1044 if ( exprDlg.exec() == QDialog::Accepted )
1046 QString expression = exprDlg.expressionText();
1047 mMap->beginCommand( tr(
"Change Annotation Format" ) );
1048 mMapGrid->setAnnotationExpression( expression );
1049 mMap->updateBoundingRect();
1055 void QgsLayoutMapGridWidget::mAnnotationDisplayLeftComboBox_currentIndexChanged(
int )
1060 void QgsLayoutMapGridWidget::mAnnotationDisplayRightComboBox_currentIndexChanged(
int )
1065 void QgsLayoutMapGridWidget::mAnnotationDisplayTopComboBox_currentIndexChanged(
int )
1070 void QgsLayoutMapGridWidget::mAnnotationDisplayBottomComboBox_currentIndexChanged(
int )
1075 void QgsLayoutMapGridWidget::mAnnotationPositionLeftComboBox_currentIndexChanged(
int )
1080 void QgsLayoutMapGridWidget::mAnnotationPositionRightComboBox_currentIndexChanged(
int )
1085 void QgsLayoutMapGridWidget::mAnnotationPositionTopComboBox_currentIndexChanged(
int )
1090 void QgsLayoutMapGridWidget::mAnnotationPositionBottomComboBox_currentIndexChanged(
int )
1095 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxLeft_currentIndexChanged(
int index )
1100 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxRight_currentIndexChanged(
int index )
1105 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxTop_currentIndexChanged(
int index )
1110 void QgsLayoutMapGridWidget::mAnnotationDirectionComboBoxBottom_currentIndexChanged(
int index )
1115 void QgsLayoutMapGridWidget::mDistanceToMapFrameSpinBox_valueChanged(
double d )
1117 if ( !mMapGrid || !mMap )
1123 mMapGrid->setAnnotationFrameDistance( d );
1124 mMap->updateBoundingRect();
1129 void QgsLayoutMapGridWidget::annotationFontChanged()
1131 if ( !mMapGrid || !mMap )
1136 mMap->beginCommand( tr(
"Change Annotation Font" ) );
1137 mMapGrid->setAnnotationFont( mAnnotationFontButton->currentFont() );
1138 mMap->updateBoundingRect();
1143 void QgsLayoutMapGridWidget::lineSymbolChanged()
1145 if ( !mMapGrid || !mMap )
1151 mMapGrid->setLineSymbol( mGridLineStyleButton->clonedSymbol<
QgsLineSymbol>() );
1156 void QgsLayoutMapGridWidget::markerSymbolChanged()
1158 if ( !mMapGrid || !mMap )
1164 mMapGrid->setMarkerSymbol( mGridMarkerStyleButton->clonedSymbol<
QgsMarkerSymbol>() );
1169 void QgsLayoutMapGridWidget::gridEnabledToggled(
bool active )
1171 if ( !mMapGrid || !mMap )
1176 mMap->beginCommand( tr(
"Toggle Grid Display" ) );
1177 mMapGrid->setEnabled( active );
1179 mMap->updateBoundingRect();
1183 void QgsLayoutMapGridWidget::mAnnotationFontColorButton_colorChanged(
const QColor &color )
1185 if ( !mMapGrid || !mMap )
1191 mMapGrid->setAnnotationFontColor( color );
1196 void QgsLayoutMapGridWidget::mAnnotationFormatComboBox_currentIndexChanged(
int index )
1198 if ( !mMapGrid || !mMap )
1203 mMap->beginCommand( tr(
"Change Annotation Format" ) );
1208 mMap->updateBoundingRect();
1213 void QgsLayoutMapGridWidget::mCoordinatePrecisionSpinBox_valueChanged(
int value )
1215 if ( !mMapGrid || !mMap )
1219 mMap->beginCommand( tr(
"Change Annotation Precision" ) );
1220 mMapGrid->setAnnotationPrecision( value );
1221 mMap->updateBoundingRect();