Skip to content

Commit d794bdb

Browse files
konstnyalldawson
authored andcommittedDec 6, 2018
[FEATURE] [needs-docs] Add the grid frame MARGIN In the "Print Layout" map grid
1 parent e6ec1ec commit d794bdb

File tree

6 files changed

+148
-37
lines changed

6 files changed

+148
-37
lines changed
 

‎python/core/auto_generated/layout/qgslayoutitemmapgrid.sip.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,22 @@ The size of the line outlines drawn in the frame can be retrieved via the
748748
framePenSize method.
749749

750750
.. seealso:: :py:func:`setFrameWidth`
751+
%End
752+
753+
void setGridFrameMargin( const double margin );
754+
%Docstring
755+
Sets the grid frame margin (in layout units).
756+
This property controls distance between the map frame and the grid frame.
757+
758+
.. seealso:: GridFrameMargin
759+
%End
760+
761+
double GridFrameMargin() const;
762+
%Docstring
763+
Sets the grid frame Margin (in layout units).
764+
This property controls distance between the map frame and the grid frame.
765+
766+
.. seealso:: :py:func:`setGridFrameMargin`
751767
%End
752768

753769
void setFramePenSize( const double width );

‎src/app/layout/qgslayoutmapgridwidget.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ QgsLayoutMapGridWidget::QgsLayoutMapGridWidget( QgsLayoutItemMapGrid *mapGrid, Q
4040
connect( mOffsetYSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mOffsetYSpinBox_valueChanged );
4141
connect( mCrossWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mCrossWidthSpinBox_valueChanged );
4242
connect( mFrameWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mFrameWidthSpinBox_valueChanged );
43+
connect( mGridFrameMarginSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mGridFrameMarginSpinBox_valueChanged );
4344
connect( mFrameStyleComboBox, static_cast<void ( QComboBox::* )( const QString & )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapGridWidget::mFrameStyleComboBox_currentIndexChanged );
4445
connect( mGridFramePenSizeSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutMapGridWidget::mGridFramePenSizeSpinBox_valueChanged );
4546
connect( mGridFramePenColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutMapGridWidget::mGridFramePenColorButton_colorChanged );
@@ -197,6 +198,7 @@ void QgsLayoutMapGridWidget::blockAllSignals( bool block )
197198
mCrossWidthSpinBox->blockSignals( block );
198199
mFrameStyleComboBox->blockSignals( block );
199200
mFrameWidthSpinBox->blockSignals( block );
201+
mGridFrameMarginSpinBox->blockSignals( block );
200202
mGridLineStyleButton->blockSignals( block );
201203
mMapGridUnitComboBox->blockSignals( block );
202204
mGridFramePenSizeSpinBox->blockSignals( block );
@@ -282,11 +284,13 @@ void QgsLayoutMapGridWidget::toggleFrameControls( bool frameEnabled, bool frameF
282284
{
283285
//set status of frame controls
284286
mFrameWidthSpinBox->setEnabled( frameSizeEnabled );
287+
mGridFrameMarginSpinBox->setEnabled( frameEnabled );
285288
mGridFramePenSizeSpinBox->setEnabled( frameEnabled );
286289
mGridFramePenColorButton->setEnabled( frameEnabled );
287290
mGridFrameFill1ColorButton->setEnabled( frameFillEnabled );
288291
mGridFrameFill2ColorButton->setEnabled( frameFillEnabled );
289292
mFrameWidthLabel->setEnabled( frameSizeEnabled );
293+
mFrameMarginLabel->setEnabled( frameEnabled );
290294
mFramePenLabel->setEnabled( frameEnabled );
291295
mFrameFillLabel->setEnabled( frameFillEnabled );
292296
mCheckGridLeftSide->setEnabled( frameEnabled );
@@ -459,6 +463,7 @@ void QgsLayoutMapGridWidget::setGridItems()
459463
mOffsetYSpinBox->setValue( mMapGrid->offsetY() );
460464
mCrossWidthSpinBox->setValue( mMapGrid->crossLength() );
461465
mFrameWidthSpinBox->setValue( mMapGrid->frameWidth() );
466+
mGridFrameMarginSpinBox->setValue( mMapGrid->GridFrameMargin() );
462467
mGridFramePenSizeSpinBox->setValue( mMapGrid->framePenSize() );
463468
mGridFramePenColorButton->setColor( mMapGrid->framePenColor() );
464469
mGridFrameFill1ColorButton->setColor( mMapGrid->frameFillColor1() );
@@ -515,6 +520,7 @@ void QgsLayoutMapGridWidget::setGridItems()
515520

516521
//grid frame
517522
mFrameWidthSpinBox->setValue( mMapGrid->frameWidth() );
523+
mGridFrameMarginSpinBox->setValue( mMapGrid->GridFrameMargin() );
518524
QgsLayoutItemMapGrid::FrameStyle gridFrameStyle = mMapGrid->frameStyle();
519525
switch ( gridFrameStyle )
520526
{
@@ -689,6 +695,20 @@ void QgsLayoutMapGridWidget::mFrameWidthSpinBox_valueChanged( double val )
689695
mMap->endCommand();
690696
}
691697

698+
void QgsLayoutMapGridWidget::mGridFrameMarginSpinBox_valueChanged( double val )
699+
{
700+
if ( !mMapGrid || !mMap )
701+
{
702+
return;
703+
}
704+
705+
mMap->beginCommand( tr( "Change Grid Frame Margin" ) );
706+
mMapGrid->setGridFrameMargin( val );
707+
mMap->updateBoundingRect();
708+
mMap->update();
709+
mMap->endCommand();
710+
}
711+
692712
void QgsLayoutMapGridWidget::mCheckGridLeftSide_toggled( bool checked )
693713
{
694714
if ( !mMapGrid || !mMap )

‎src/app/layout/qgslayoutmapgridwidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class QgsLayoutMapGridWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLay
4242
void mOffsetYSpinBox_valueChanged( double value );
4343
void mCrossWidthSpinBox_valueChanged( double val );
4444
void mFrameWidthSpinBox_valueChanged( double val );
45+
void mGridFrameMarginSpinBox_valueChanged( double val );
4546
void mFrameStyleComboBox_currentIndexChanged( const QString &text );
4647
void mGridFramePenSizeSpinBox_valueChanged( double d );
4748
void mGridFramePenColorButton_colorChanged( const QColor &newColor );

‎src/core/layout/qgslayoutitemmapgrid.cpp

Lines changed: 63 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ bool QgsLayoutItemMapGrid::writeXml( QDomElement &elem, QDomDocument &doc, const
234234
mapGridElem.setAttribute( QStringLiteral( "gridFrameStyle" ), mGridFrameStyle );
235235
mapGridElem.setAttribute( QStringLiteral( "gridFrameSideFlags" ), mGridFrameSides );
236236
mapGridElem.setAttribute( QStringLiteral( "gridFrameWidth" ), qgsDoubleToString( mGridFrameWidth ) );
237+
mapGridElem.setAttribute( QStringLiteral( "gridFrameMargin" ), qgsDoubleToString( mGridFrameMargin ) );
237238
mapGridElem.setAttribute( QStringLiteral( "gridFramePenThickness" ), qgsDoubleToString( mGridFramePenThickness ) );
238239
mapGridElem.setAttribute( QStringLiteral( "gridFramePenColor" ), QgsSymbolLayerUtils::encodeColor( mGridFramePenColor ) );
239240
mapGridElem.setAttribute( QStringLiteral( "frameFillColor1" ), QgsSymbolLayerUtils::encodeColor( mGridFrameFillColor1 ) );
@@ -294,6 +295,7 @@ bool QgsLayoutItemMapGrid::readXml( const QDomElement &itemElem, const QDomDocum
294295
mGridFrameStyle = static_cast< QgsLayoutItemMapGrid::FrameStyle >( itemElem.attribute( QStringLiteral( "gridFrameStyle" ), QStringLiteral( "0" ) ).toInt() );
295296
mGridFrameSides = static_cast< QgsLayoutItemMapGrid::FrameSideFlags >( itemElem.attribute( QStringLiteral( "gridFrameSideFlags" ), QStringLiteral( "15" ) ).toInt() );
296297
mGridFrameWidth = itemElem.attribute( QStringLiteral( "gridFrameWidth" ), QStringLiteral( "2.0" ) ).toDouble();
298+
mGridFrameMargin = itemElem.attribute( QStringLiteral( "gridFrameMargin" ), QStringLiteral( "0.0" ) ).toDouble();
297299
mGridFramePenThickness = itemElem.attribute( QStringLiteral( "gridFramePenThickness" ), QStringLiteral( "0.3" ) ).toDouble();
298300
mGridFramePenColor = QgsSymbolLayerUtils::decodeColor( itemElem.attribute( QStringLiteral( "gridFramePenColor" ), QStringLiteral( "0,0,0" ) ) );
299301
mGridFrameFillColor1 = QgsSymbolLayerUtils::decodeColor( itemElem.attribute( QStringLiteral( "frameFillColor1" ), QStringLiteral( "255,255,255,255" ) ) );
@@ -800,21 +802,23 @@ void QgsLayoutItemMapGrid::drawGridFrameZebraBorder( QPainter *p, const QMap< do
800802

801803
if ( extension )
802804
{
803-
*extension = mGridFrameWidth + mGridFramePenThickness / 2.0;
805+
*extension = mGridFrameMargin + mGridFrameWidth + mGridFramePenThickness / 2.0;
804806
return;
805807
}
806808

807809
QMap< double, double > pos = borderPos;
808810

809-
double currentCoord = 0;
811+
double currentCoord = 0.0;
810812
if ( ( border == QgsLayoutItemMapGrid::Left || border == QgsLayoutItemMapGrid::Right ) && testFrameSideFlag( QgsLayoutItemMapGrid::FrameTop ) )
811813
{
812-
currentCoord = - mGridFrameWidth;
814+
// currentCoord = - (mGridFrameWidth + mGridFrameMargin);
815+
currentCoord = -mGridFramePenThickness / 2.0;
813816
pos.insert( 0, 0 );
814817
}
815818
else if ( ( border == QgsLayoutItemMapGrid::Top || border == QgsLayoutItemMapGrid::Bottom ) && testFrameSideFlag( QgsLayoutItemMapGrid::FrameLeft ) )
816819
{
817-
currentCoord = - mGridFrameWidth;
820+
// currentCoord = - (mGridFrameWidth + mGridFrameMargin);
821+
currentCoord = -mGridFramePenThickness / 2.0;
818822
pos.insert( 0, 0 );
819823
}
820824
bool color1 = true;
@@ -828,15 +832,17 @@ void QgsLayoutItemMapGrid::drawGridFrameZebraBorder( QPainter *p, const QMap< do
828832
pos.insert( mMap->rect().height(), mMap->rect().height() );
829833
if ( testFrameSideFlag( QgsLayoutItemMapGrid::FrameBottom ) )
830834
{
831-
pos.insert( mMap->rect().height() + mGridFrameWidth, mMap->rect().height() + mGridFrameWidth );
835+
// pos.insert( mMap->rect().height() + mGridFrameWidth, mMap->rect().height() + mGridFrameWidth );
836+
pos.insert( mMap->rect().height(), mMap->rect().height() );
832837
}
833838
}
834839
else if ( border == QgsLayoutItemMapGrid::Top || border == QgsLayoutItemMapGrid::Bottom )
835840
{
836841
pos.insert( mMap->rect().width(), mMap->rect().width() );
837842
if ( testFrameSideFlag( QgsLayoutItemMapGrid::FrameRight ) )
838843
{
839-
pos.insert( mMap->rect().width() + mGridFrameWidth, mMap->rect().width() + mGridFrameWidth );
844+
// pos.insert( mMap->rect().width() + mGridFrameWidth, mMap->rect().width() + mGridFrameWidth );
845+
pos.insert( mMap->rect().width(), mMap->rect().width() );
840846
}
841847
}
842848

@@ -854,20 +860,27 @@ void QgsLayoutItemMapGrid::drawGridFrameZebraBorder( QPainter *p, const QMap< do
854860
{
855861
height = posIt.key() - currentCoord;
856862
width = mGridFrameWidth;
857-
x = ( border == QgsLayoutItemMapGrid::Left ) ? -mGridFrameWidth : mMap->rect().width();
863+
x = ( border == QgsLayoutItemMapGrid::Left ) ? -( mGridFrameWidth + mGridFrameMargin ) : mMap->rect().width() + mGridFrameMargin;
858864
y = currentCoord;
859865
}
860866
else //top or bottom
861867
{
862868
height = mGridFrameWidth;
863869
width = posIt.key() - currentCoord;
864870
x = currentCoord;
865-
y = ( border == QgsLayoutItemMapGrid::Top ) ? -mGridFrameWidth : mMap->rect().height();
871+
y = ( border == QgsLayoutItemMapGrid::Top ) ? -( mGridFrameWidth + mGridFrameMargin ) : mMap->rect().height() + mGridFrameMargin;
866872
}
867873
p->drawRect( QRectF( x, y, width, height ) );
868874
currentCoord = posIt.key();
869875
color1 = !color1;
870876
}
877+
//draw corners
878+
width = height = ( mGridFrameWidth + mGridFrameMargin ) ;
879+
p->setBrush( QBrush( mGridFrameFillColor1 ) );
880+
p->drawRect( QRectF( -( mGridFrameWidth + mGridFrameMargin ), -( mGridFrameWidth + mGridFrameMargin ), width, height ) );
881+
p->drawRect( QRectF( mMap->rect().width(), -( mGridFrameWidth + mGridFrameMargin ), width, height ) );
882+
p->drawRect( QRectF( -( mGridFrameWidth + mGridFrameMargin ), mMap->rect().height(), width, height ) );
883+
p->drawRect( QRectF( mMap->rect().width(), mMap->rect().height(), width, height ) );
871884
}
872885

873886
void QgsLayoutItemMapGrid::drawGridFrameTicks( QPainter *p, const QMap< double, double > &borderPos, QgsLayoutItemMapGrid::BorderSide border, double *extension ) const
@@ -880,7 +893,7 @@ void QgsLayoutItemMapGrid::drawGridFrameTicks( QPainter *p, const QMap< double,
880893
if ( extension )
881894
{
882895
if ( mGridFrameStyle != QgsLayoutItemMapGrid::InteriorTicks )
883-
*extension = mGridFrameWidth;
896+
*extension = mGridFrameMargin + mGridFrameWidth;
884897
return;
885898
}
886899

@@ -906,17 +919,17 @@ void QgsLayoutItemMapGrid::drawGridFrameTicks( QPainter *p, const QMap< double,
906919
if ( mGridFrameStyle == QgsLayoutItemMapGrid::InteriorTicks )
907920
{
908921
width = mGridFrameWidth;
909-
x = ( border == QgsLayoutItemMapGrid::Left ) ? 0 : mMap->rect().width() - mGridFrameWidth;
922+
x = ( border == QgsLayoutItemMapGrid::Left ) ? 0 - mGridFrameMargin : mMap->rect().width() - mGridFrameWidth + mGridFrameMargin;
910923
}
911924
else if ( mGridFrameStyle == QgsLayoutItemMapGrid::ExteriorTicks )
912925
{
913926
width = mGridFrameWidth;
914-
x = ( border == QgsLayoutItemMapGrid::Left ) ? - mGridFrameWidth : mMap->rect().width();
927+
x = ( border == QgsLayoutItemMapGrid::Left ) ? - mGridFrameWidth - mGridFrameMargin : mMap->rect().width() + mGridFrameMargin;
915928
}
916929
else if ( mGridFrameStyle == QgsLayoutItemMapGrid::InteriorExteriorTicks )
917930
{
918931
width = mGridFrameWidth * 2;
919-
x = ( border == QgsLayoutItemMapGrid::Left ) ? - mGridFrameWidth : mMap->rect().width() - mGridFrameWidth;
932+
x = ( border == QgsLayoutItemMapGrid::Left ) ? - mGridFrameWidth - mGridFrameMargin : mMap->rect().width() - mGridFrameWidth + mGridFrameMargin;
920933
}
921934
}
922935
else //top or bottom
@@ -926,17 +939,17 @@ void QgsLayoutItemMapGrid::drawGridFrameTicks( QPainter *p, const QMap< double,
926939
if ( mGridFrameStyle == QgsLayoutItemMapGrid::InteriorTicks )
927940
{
928941
height = mGridFrameWidth;
929-
y = ( border == QgsLayoutItemMapGrid::Top ) ? 0 : mMap->rect().height() - mGridFrameWidth;
942+
y = ( border == QgsLayoutItemMapGrid::Top ) ? 0 - mGridFrameMargin : mMap->rect().height() - mGridFrameWidth + mGridFrameMargin;
930943
}
931944
else if ( mGridFrameStyle == QgsLayoutItemMapGrid::ExteriorTicks )
932945
{
933946
height = mGridFrameWidth;
934-
y = ( border == QgsLayoutItemMapGrid::Top ) ? -mGridFrameWidth : mMap->rect().height();
947+
y = ( border == QgsLayoutItemMapGrid::Top ) ? -mGridFrameWidth - mGridFrameMargin : mMap->rect().height() + mGridFrameMargin;
935948
}
936949
else if ( mGridFrameStyle == QgsLayoutItemMapGrid::InteriorExteriorTicks )
937950
{
938951
height = mGridFrameWidth * 2;
939-
y = ( border == QgsLayoutItemMapGrid::Top ) ? -mGridFrameWidth : mMap->rect().height() - mGridFrameWidth;
952+
y = ( border == QgsLayoutItemMapGrid::Top ) ? -mGridFrameWidth - mGridFrameMargin : mMap->rect().height() - mGridFrameWidth + mGridFrameMargin;
940953
}
941954
}
942955
p->drawLine( QLineF( x, y, x + width, y + height ) );
@@ -952,7 +965,7 @@ void QgsLayoutItemMapGrid::drawGridFrameLineBorder( QPainter *p, QgsLayoutItemMa
952965

953966
if ( extension )
954967
{
955-
*extension = mGridFramePenThickness / 2.0;
968+
*extension = mGridFrameMargin + mGridFramePenThickness / 2.0;
956969
return;
957970
}
958971

@@ -966,16 +979,44 @@ void QgsLayoutItemMapGrid::drawGridFrameLineBorder( QPainter *p, QgsLayoutItemMa
966979
switch ( border )
967980
{
968981
case QgsLayoutItemMapGrid::Left:
969-
p->drawLine( QLineF( 0, 0, 0, mMap->rect().height() ) );
982+
p->drawLine( QLineF( 0 - mGridFrameMargin, 0 - mGridFrameMargin, 0 - mGridFrameMargin, mMap->rect().height() + mGridFrameMargin ) );
983+
//corner left-top
984+
if ( mGridFrameMargin != 0 )
985+
{
986+
const double X1 = 0 - mGridFrameMargin + mGridFramePenThickness / 2.0;
987+
const double Y1 = 0 - mGridFrameMargin + mGridFramePenThickness / 2.0;
988+
p->drawLine( QLineF( 0, 0, X1, Y1 ) );
989+
}
970990
break;
971991
case QgsLayoutItemMapGrid::Right:
972-
p->drawLine( QLineF( mMap->rect().width(), 0, mMap->rect().width(), mMap->rect().height() ) );
992+
p->drawLine( QLineF( mMap->rect().width() + mGridFrameMargin, 0 - mGridFrameMargin, mMap->rect().width() + mGridFrameMargin, mMap->rect().height() + mGridFrameMargin ) );
993+
//corner right-bottom
994+
if ( mGridFrameMargin != 0 )
995+
{
996+
const double X1 = mMap->rect().width() + mGridFrameMargin - mGridFramePenThickness / 2.0 ;
997+
const double Y1 = mMap->rect().height() + mGridFrameMargin - mGridFramePenThickness / 2.0 ;
998+
p->drawLine( QLineF( mMap->rect().width(), mMap->rect().height(), X1, Y1 ) );
999+
}
9731000
break;
9741001
case QgsLayoutItemMapGrid::Top:
975-
p->drawLine( QLineF( 0, 0, mMap->rect().width(), 0 ) );
1002+
p->drawLine( QLineF( 0 - mGridFrameMargin, 0 - mGridFrameMargin, mMap->rect().width() + mGridFrameMargin, 0 - mGridFrameMargin ) );
1003+
//corner right-top
1004+
if ( mGridFrameMargin != 0 )
1005+
{
1006+
const double X1 = mMap->rect().width() + mGridFrameMargin - mGridFramePenThickness / 2.0 ;
1007+
const double Y1 = 0 - mGridFrameMargin + mGridFramePenThickness / 2.0 ;
1008+
p->drawLine( QLineF( mMap->rect().width(), 0, X1, Y1 ) );
1009+
}
9761010
break;
9771011
case QgsLayoutItemMapGrid::Bottom:
978-
p->drawLine( QLineF( 0, mMap->rect().height(), mMap->rect().width(), mMap->rect().height() ) );
1012+
p->drawLine( QLineF( 0 - mGridFrameMargin, mMap->rect().height() + mGridFrameMargin, mMap->rect().width() + mGridFrameMargin, mMap->rect().height() + mGridFrameMargin ) );
1013+
//corner left-bottom
1014+
if ( mGridFrameMargin != 0 )
1015+
{
1016+
const double X1 = 0 - mGridFrameMargin + mGridFramePenThickness / 2.0 ;
1017+
const double Y1 = mMap->rect().height() + mGridFrameMargin - mGridFramePenThickness / 2.0 ;
1018+
p->drawLine( QLineF( 0, mMap->rect().height(), X1, Y1 ) );
1019+
}
9791020
break;
9801021
}
9811022
}
@@ -1684,7 +1725,7 @@ int QgsLayoutItemMapGrid::xGridLinesCrsTransform( const QgsRectangle &bbox, cons
16841725
catch ( QgsCsException &cse )
16851726
{
16861727
Q_UNUSED( cse );
1687-
QgsDebugMsg( QStringLiteral( "Caught CRS exception %1" ).arg( cse.what() ) );
1728+
QgsDebugMsg( QString( "Caught CRS exception %1" ).arg( cse.what() ) );
16881729
}
16891730

16901731
currentX += step;
@@ -1760,7 +1801,7 @@ int QgsLayoutItemMapGrid::yGridLinesCrsTransform( const QgsRectangle &bbox, cons
17601801
catch ( QgsCsException &cse )
17611802
{
17621803
Q_UNUSED( cse );
1763-
QgsDebugMsg( QStringLiteral( "Caught CRS exception %1" ).arg( cse.what() ) );
1804+
QgsDebugMsg( QString( "Caught CRS exception %1" ).arg( cse.what() ) );
17641805
}
17651806

17661807
currentY += step;

‎src/core/layout/qgslayoutitemmapgrid.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,20 @@ class CORE_EXPORT QgsLayoutItemMapGrid : public QgsLayoutItemMapItem
724724
*/
725725
double frameWidth() const { return mGridFrameWidth; }
726726

727+
/**
728+
* Sets the grid frame margin (in layout units).
729+
* This property controls distance between the map frame and the grid frame.
730+
* \see GridFrameMargin()
731+
*/
732+
void setGridFrameMargin( const double margin ) { mGridFrameMargin = margin; }
733+
734+
/**
735+
* Sets the grid frame Margin (in layout units).
736+
* This property controls distance between the map frame and the grid frame.
737+
* \see setGridFrameMargin()
738+
*/
739+
double GridFrameMargin() const { return mGridFrameMargin; }
740+
727741
/**
728742
* Sets the \a width of the stroke drawn in the grid frame.
729743
* \see framePenSize()
@@ -867,6 +881,7 @@ class CORE_EXPORT QgsLayoutItemMapGrid : public QgsLayoutItemMapItem
867881
QColor mGridFrameFillColor1 = Qt::white;
868882
QColor mGridFrameFillColor2 = Qt::black;
869883
double mCrossLength = 3.0;
884+
double mGridFrameMargin = 0.0;
870885

871886
//! Divisions for frame on left map side
872887
DisplayMode mLeftFrameDivisions = QgsLayoutItemMapGrid::ShowAll;

‎src/ui/layout/qgslayoutmapgridwidgetbase.ui

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,14 @@
330330
</property>
331331
</widget>
332332
</item>
333-
<item row="2" column="0">
333+
<item row="3" column="0">
334334
<widget class="QLabel" name="mFramePenLabel">
335335
<property name="text">
336336
<string>Frame line thickness</string>
337337
</property>
338338
</widget>
339339
</item>
340-
<item row="2" column="1">
340+
<item row="3" column="1">
341341
<widget class="QgsDoubleSpinBox" name="mGridFramePenSizeSpinBox">
342342
<property name="suffix">
343343
<string> mm</string>
@@ -347,7 +347,7 @@
347347
</property>
348348
</widget>
349349
</item>
350-
<item row="2" column="2">
350+
<item row="3" column="2">
351351
<widget class="QgsColorButton" name="mGridFramePenColorButton">
352352
<property name="minimumSize">
353353
<size>
@@ -366,14 +366,14 @@
366366
</property>
367367
</widget>
368368
</item>
369-
<item row="3" column="0">
369+
<item row="4" column="0">
370370
<widget class="QLabel" name="mFrameFillLabel">
371371
<property name="text">
372372
<string>Frame fill colors</string>
373373
</property>
374374
</widget>
375375
</item>
376-
<item row="3" column="1">
376+
<item row="4" column="1">
377377
<widget class="QgsColorButton" name="mGridFrameFill1ColorButton">
378378
<property name="minimumSize">
379379
<size>
@@ -392,7 +392,7 @@
392392
</property>
393393
</widget>
394394
</item>
395-
<item row="3" column="2">
395+
<item row="4" column="2">
396396
<widget class="QgsColorButton" name="mGridFrameFill2ColorButton">
397397
<property name="minimumSize">
398398
<size>
@@ -411,7 +411,7 @@
411411
</property>
412412
</widget>
413413
</item>
414-
<item row="8" column="0" colspan="3">
414+
<item row="9" column="0" colspan="3">
415415
<layout class="QGridLayout" name="gridLayout_4">
416416
<item row="0" column="0">
417417
<widget class="QCheckBox" name="mCheckGridLeftSide">
@@ -487,46 +487,63 @@
487487
</property>
488488
</widget>
489489
</item>
490-
<item row="5" column="0">
490+
<item row="6" column="0">
491491
<widget class="QLabel" name="mRightDivisionsLabel">
492492
<property name="text">
493493
<string>Right divisions</string>
494494
</property>
495495
</widget>
496496
</item>
497-
<item row="4" column="0">
497+
<item row="5" column="0">
498498
<widget class="QLabel" name="mLeftDivisionsLabel">
499499
<property name="text">
500500
<string>Left divisions</string>
501501
</property>
502502
</widget>
503503
</item>
504-
<item row="6" column="0">
504+
<item row="7" column="0">
505505
<widget class="QLabel" name="mTopDivisionsLabel">
506506
<property name="text">
507507
<string>Top divisions</string>
508508
</property>
509509
</widget>
510510
</item>
511-
<item row="7" column="0">
511+
<item row="8" column="0">
512512
<widget class="QLabel" name="mBottomDivisionsLabel">
513513
<property name="text">
514514
<string>Bottom divisions</string>
515515
</property>
516516
</widget>
517517
</item>
518-
<item row="4" column="1" colspan="2">
518+
<item row="5" column="1" colspan="2">
519519
<widget class="QComboBox" name="mFrameDivisionsLeftComboBox"/>
520520
</item>
521-
<item row="5" column="1" colspan="2">
521+
<item row="6" column="1" colspan="2">
522522
<widget class="QComboBox" name="mFrameDivisionsRightComboBox"/>
523523
</item>
524-
<item row="6" column="1" colspan="2">
524+
<item row="7" column="1" colspan="2">
525525
<widget class="QComboBox" name="mFrameDivisionsTopComboBox"/>
526526
</item>
527-
<item row="7" column="1" colspan="2">
527+
<item row="8" column="1" colspan="2">
528528
<widget class="QComboBox" name="mFrameDivisionsBottomComboBox"/>
529529
</item>
530+
<item row="2" column="0">
531+
<widget class="QLabel" name="mFrameMarginLabel">
532+
<property name="text">
533+
<string>Frame margin</string>
534+
</property>
535+
</widget>
536+
</item>
537+
<item row="2" column="1" colspan="2">
538+
<widget class="QgsDoubleSpinBox" name="mGridFrameMarginSpinBox">
539+
<property name="suffix">
540+
<string> mm</string>
541+
</property>
542+
<property name="showClearButton" stdset="0">
543+
<bool>false</bool>
544+
</property>
545+
</widget>
546+
</item>
530547
</layout>
531548
</widget>
532549
</item>
@@ -814,6 +831,7 @@
814831
<tabstop>mGridFrameGroupBox</tabstop>
815832
<tabstop>mFrameStyleComboBox</tabstop>
816833
<tabstop>mFrameWidthSpinBox</tabstop>
834+
<tabstop>mGridFrameMarginSpinBox</tabstop>
817835
<tabstop>mGridFramePenSizeSpinBox</tabstop>
818836
<tabstop>mGridFramePenColorButton</tabstop>
819837
<tabstop>mGridFrameFill1ColorButton</tabstop>

0 commit comments

Comments
 (0)
Please sign in to comment.