Skip to content

Commit aa3e40a

Browse files
committedDec 28, 2013
[FEATURE][composer] Add controls for changing zebra frame colors and line thickness, fix output of zebra style grids (fix #8767)
1 parent afbd2ac commit aa3e40a

File tree

8 files changed

+347
-57
lines changed

8 files changed

+347
-57
lines changed
 

‎python/core/composer/qgscomposermap.sip

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,32 @@ class QgsComposerMap : QgsComposerItem
247247
@note: this function was added in version 1.9*/
248248
void setGridFrameWidth( double w );
249249
double gridFrameWidth() const;
250+
251+
/**Set grid frame pen thickness
252+
@note: this function was added in version 2.1*/
253+
void setGridFramePenSize( double w );
254+
double gridFramePenSize() const;
255+
256+
/**Sets pen color for grid frame
257+
@note: this function was added in version 2.1*/
258+
void setGridFramePenColor( const QColor& c );
259+
/**Get pen color for grid frame
260+
@note: this function was added in version 2.1*/
261+
QColor gridFramePenColor() const;
262+
263+
/**Sets first fill color for grid zebra frame
264+
@note: this function was added in version 2.1*/
265+
void setGridFrameFillColor1( const QColor& c );
266+
/**Get first fill color for grid zebra frame
267+
@note: this function was added in version 2.1*/
268+
QColor gridFrameFillColor1() const;
269+
270+
/**Sets second fill color for grid zebra frame
271+
@note: this function was added in version 2.1*/
272+
void setGridFrameFillColor2( const QColor& c );
273+
/**Get second fill color for grid zebra frame
274+
@note: this function was added in version 2.1*/
275+
QColor gridFrameFillColor2() const;
250276

251277
/** Returns the grid's blending mode
252278
@note added in version 2.0*/

‎src/app/composer/qgscomposermapwidget.cpp

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap ): QWidg
6161
mAnnotationFormatComboBox->insertItem( 1, tr( "DegreeMinute" ) );
6262
mAnnotationFormatComboBox->insertItem( 2, tr( "DegreeMinuteSecond" ) );
6363

64+
mAnnotationFontColorButton->setColorDialogTitle( tr( "Select font color" ) );
65+
mAnnotationFontColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
66+
6467
insertAnnotationPositionEntries( mAnnotationPositionLeftComboBox );
6568
insertAnnotationPositionEntries( mAnnotationPositionRightComboBox );
6669
insertAnnotationPositionEntries( mAnnotationPositionTopComboBox );
@@ -74,9 +77,22 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap ): QWidg
7477
mFrameStyleComboBox->insertItem( 0, tr( "No frame" ) );
7578
mFrameStyleComboBox->insertItem( 1, tr( "Zebra" ) );
7679

80+
mGridFramePenColorButton->setColorDialogTitle( tr( "Select grid frame color" ) );
81+
mGridFramePenColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
82+
mGridFrameFill1ColorButton->setColorDialogTitle( tr( "Select grid frame fill color" ) );
83+
mGridFrameFill1ColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
84+
mGridFrameFill2ColorButton->setColorDialogTitle( tr( "Select grid frame fill color" ) );
85+
mGridFrameFill2ColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
86+
87+
//set initial state of frame style controls
88+
toggleFrameControls( false );
89+
7790
connect( mGridCheckBox, SIGNAL( toggled( bool ) ),
7891
mDrawAnnotationCheckableGroupBox, SLOT( setEnabled( bool ) ) );
7992

93+
connect( mFrameStyleComboBox, SIGNAL( currentIndexChanged( QString ) ),
94+
this, SLOT( frameStyleChanged( QString ) ) );
95+
8096
if ( composerMap )
8197
{
8298
connect( composerMap, SIGNAL( itemChanged() ), this, SLOT( setGuiElementValues() ) );
@@ -339,14 +355,20 @@ void QgsComposerMapWidget::updateGuiElements()
339355

340356
//grid frame
341357
mFrameWidthSpinBox->setValue( mComposerMap->gridFrameWidth() );
358+
mGridFramePenSizeSpinBox->setValue( mComposerMap->gridFramePenSize() );
359+
mGridFramePenColorButton->setColor( mComposerMap->gridFramePenColor() );
360+
mGridFrameFill1ColorButton->setColor( mComposerMap->gridFrameFillColor1() );
361+
mGridFrameFill2ColorButton->setColor( mComposerMap->gridFrameFillColor2() );
342362
QgsComposerMap::GridFrameStyle gridFrameStyle = mComposerMap->gridFrameStyle();
343363
if ( gridFrameStyle == QgsComposerMap::Zebra )
344364
{
345365
mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findText( tr( "Zebra" ) ) );
366+
toggleFrameControls( true );
346367
}
347368
else //NoGridFrame
348369
{
349370
mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findText( tr( "No frame" ) ) );
371+
toggleFrameControls( false );
350372
}
351373

352374
//grid blend mode
@@ -369,8 +391,6 @@ void QgsComposerMapWidget::updateGuiElements()
369391
initAnnotationDirectionBox( mAnnotationDirectionComboBoxBottom, mComposerMap->gridAnnotationDirection( QgsComposerMap::Bottom ) );
370392

371393
mAnnotationFontColorButton->setColor( mComposerMap->annotationFontColor() );
372-
mAnnotationFontColorButton->setColorDialogTitle( tr( "Select font color" ) );
373-
mAnnotationFontColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
374394

375395
mDistanceToMapFrameSpinBox->setValue( mComposerMap->annotationFrameDistance() );
376396

@@ -454,6 +474,10 @@ void QgsComposerMapWidget::blockAllSignals( bool b )
454474
mDrawCanvasItemsCheckBox->blockSignals( b );
455475
mFrameStyleComboBox->blockSignals( b );
456476
mFrameWidthSpinBox->blockSignals( b );
477+
mGridFramePenSizeSpinBox->blockSignals( b );
478+
mGridFramePenColorButton->blockSignals( b );
479+
mGridFrameFill1ColorButton->blockSignals( b );
480+
mGridFrameFill2ColorButton->blockSignals( b );
457481
mOverviewFrameMapComboBox->blockSignals( b );
458482
mOverviewFrameStyleButton->blockSignals( b );
459483
mOverviewBlendModeComboBox->blockSignals( b );
@@ -880,8 +904,23 @@ void QgsComposerMapWidget::on_mCoordinatePrecisionSpinBox_valueChanged( int valu
880904
mComposerMap->endCommand();
881905
}
882906

907+
void QgsComposerMapWidget::toggleFrameControls( bool frameEnabled )
908+
{
909+
//set status of frame controls
910+
mFrameWidthSpinBox->setEnabled( frameEnabled );
911+
mGridFramePenSizeSpinBox->setEnabled( frameEnabled );
912+
mGridFramePenColorButton->setEnabled( frameEnabled );
913+
mGridFrameFill1ColorButton->setEnabled( frameEnabled );
914+
mGridFrameFill2ColorButton->setEnabled( frameEnabled );
915+
mFrameWidthLabel->setEnabled( frameEnabled );
916+
mFramePenLabel->setEnabled( frameEnabled );
917+
mFrameFillLabel->setEnabled( frameEnabled );
918+
}
919+
883920
void QgsComposerMapWidget::on_mFrameStyleComboBox_currentIndexChanged( const QString& text )
884921
{
922+
toggleFrameControls( text != tr( "No frame" ) );
923+
885924
if ( !mComposerMap )
886925
{
887926
return;
@@ -913,6 +952,54 @@ void QgsComposerMapWidget::on_mFrameWidthSpinBox_valueChanged( double d )
913952
}
914953
}
915954

955+
void QgsComposerMapWidget::on_mGridFramePenSizeSpinBox_valueChanged( double d )
956+
{
957+
if ( mComposerMap )
958+
{
959+
mComposerMap->beginCommand( tr( "Changed grid frame line thickness" ) );
960+
mComposerMap->setGridFramePenSize( d );
961+
mComposerMap->updateBoundingRect();
962+
mComposerMap->update();
963+
mComposerMap->endCommand();
964+
}
965+
}
966+
967+
void QgsComposerMapWidget::on_mGridFramePenColorButton_colorChanged( const QColor& newColor )
968+
{
969+
if ( !mComposerMap )
970+
{
971+
return;
972+
}
973+
mComposerMap->beginCommand( tr( "Grid frame color changed" ) );
974+
mComposerMap->setGridFramePenColor( newColor );
975+
mComposerMap->update();
976+
mComposerMap->endCommand();
977+
}
978+
979+
void QgsComposerMapWidget::on_mGridFrameFill1ColorButton_colorChanged( const QColor& newColor )
980+
{
981+
if ( !mComposerMap )
982+
{
983+
return;
984+
}
985+
mComposerMap->beginCommand( tr( "Grid frame first fill color changed" ) );
986+
mComposerMap->setGridFrameFillColor1( newColor );
987+
mComposerMap->update();
988+
mComposerMap->endCommand();
989+
}
990+
991+
void QgsComposerMapWidget::on_mGridFrameFill2ColorButton_colorChanged( const QColor& newColor )
992+
{
993+
if ( !mComposerMap )
994+
{
995+
return;
996+
}
997+
mComposerMap->beginCommand( tr( "Grid frame second fill color changed" ) );
998+
mComposerMap->setGridFrameFillColor2( newColor );
999+
mComposerMap->update();
1000+
mComposerMap->endCommand();
1001+
}
1002+
9161003
void QgsComposerMapWidget::showEvent( QShowEvent * event )
9171004
{
9181005
refreshMapComboBox();

‎src/app/composer/qgscomposermapwidget.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ class QgsComposerMapWidget: public QWidget, private Ui::QgsComposerMapWidgetBase
8585

8686
void on_mFrameStyleComboBox_currentIndexChanged( const QString& text );
8787
void on_mFrameWidthSpinBox_valueChanged( double d );
88+
void on_mGridFramePenSizeSpinBox_valueChanged( double d );
89+
void on_mGridFramePenColorButton_colorChanged( const QColor& newColor );
90+
void on_mGridFrameFill1ColorButton_colorChanged( const QColor& newColor );
91+
void on_mGridFrameFill2ColorButton_colorChanged( const QColor& newColor );
8892

8993
protected:
9094
void showEvent( QShowEvent * event );
@@ -122,6 +126,9 @@ class QgsComposerMapWidget: public QWidget, private Ui::QgsComposerMapWidgetBase
122126

123127
/**Updates the map combo box with the current composer map ids*/
124128
void refreshMapComboBox();
129+
130+
/**Enables/disables grid frame related controls*/
131+
void toggleFrameControls( bool frameEnabled );
125132
};
126133

127134
#endif

‎src/core/composer/qgscomposermap.cpp

Lines changed: 87 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int w
4949
mTopGridAnnotationPosition( OutsideMapFrame ), mBottomGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ),
5050
mLeftGridAnnotationDirection( Horizontal ), mRightGridAnnotationDirection( Horizontal ), mTopGridAnnotationDirection( Horizontal ),
5151
mBottomGridAnnotationDirection( Horizontal ), mGridFrameStyle( NoGridFrame ), mGridFrameWidth( 2.0 ),
52+
mGridFramePenThickness( 0.5 ), mGridFramePenColor( QColor( 0, 0, 0 ) ), mGridFrameFillColor1( Qt::white ), mGridFrameFillColor2( Qt::black ),
5253
mCrossLength( 3 ), mMapCanvas( 0 ), mDrawCanvasItems( true )
5354
{
5455
mComposition = composition;
@@ -105,8 +106,9 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition )
105106
mLeftGridAnnotationPosition( OutsideMapFrame ), mRightGridAnnotationPosition( OutsideMapFrame ),
106107
mTopGridAnnotationPosition( OutsideMapFrame ), mBottomGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ),
107108
mLeftGridAnnotationDirection( Horizontal ), mRightGridAnnotationDirection( Horizontal ), mTopGridAnnotationDirection( Horizontal ),
108-
mBottomGridAnnotationDirection( Horizontal ), mGridFrameStyle( NoGridFrame ), mGridFrameWidth( 2.0 ), mCrossLength( 3 ),
109-
mMapCanvas( 0 ), mDrawCanvasItems( true )
109+
mBottomGridAnnotationDirection( Horizontal ), mGridFrameStyle( NoGridFrame ), mGridFrameWidth( 2.0 ), mGridFramePenThickness( 0.5 ),
110+
mGridFramePenColor( QColor( 0, 0, 0 ) ), mGridFrameFillColor1( Qt::white ), mGridFrameFillColor2( Qt::black ),
111+
mCrossLength( 3 ), mMapCanvas( 0 ), mDrawCanvasItems( true )
110112
{
111113
mOverviewFrameMapSymbol = 0;
112114
mGridLineSymbol = 0;
@@ -865,6 +867,28 @@ bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc ) const
865867
gridElem.setAttribute( "crossLength", qgsDoubleToString( mCrossLength ) );
866868
gridElem.setAttribute( "gridFrameStyle", mGridFrameStyle );
867869
gridElem.setAttribute( "gridFrameWidth", qgsDoubleToString( mGridFrameWidth ) );
870+
gridElem.setAttribute( "gridFramePenThickness", qgsDoubleToString( mGridFramePenThickness ) );
871+
//grid frame pen color
872+
QDomElement framePenColorElem = doc.createElement( "framePenColor" );
873+
framePenColorElem.setAttribute( "red", mGridFramePenColor.red() );
874+
framePenColorElem.setAttribute( "green", mGridFramePenColor.green() );
875+
framePenColorElem.setAttribute( "blue", mGridFramePenColor.blue() );
876+
framePenColorElem.setAttribute( "alpha", mGridFramePenColor.alpha() );
877+
gridElem.appendChild( framePenColorElem );
878+
//grid frame fill colors
879+
QDomElement frameFillColor1Elem = doc.createElement( "frameFillColor1" );
880+
frameFillColor1Elem.setAttribute( "red", mGridFrameFillColor1.red() );
881+
frameFillColor1Elem.setAttribute( "green", mGridFrameFillColor1.green() );
882+
frameFillColor1Elem.setAttribute( "blue", mGridFrameFillColor1.blue() );
883+
frameFillColor1Elem.setAttribute( "alpha", mGridFrameFillColor1.alpha() );
884+
gridElem.appendChild( frameFillColor1Elem );
885+
QDomElement frameFillColor2Elem = doc.createElement( "frameFillColor2" );
886+
frameFillColor2Elem.setAttribute( "red", mGridFrameFillColor2.red() );
887+
frameFillColor2Elem.setAttribute( "green", mGridFrameFillColor2.green() );
888+
frameFillColor2Elem.setAttribute( "blue", mGridFrameFillColor2.blue() );
889+
frameFillColor2Elem.setAttribute( "alpha", mGridFrameFillColor2.alpha() );
890+
gridElem.appendChild( frameFillColor2Elem );
891+
868892
gridElem.setAttribute( "gridBlendMode", QgsMapRenderer::getBlendModeEnum( mGridBlendMode ) );
869893
QDomElement gridLineStyleElem = QgsSymbolLayerV2Utils::saveSymbol( QString(), mGridLineSymbol, doc );
870894
gridElem.appendChild( gridLineStyleElem );
@@ -889,6 +913,7 @@ bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc ) const
889913
annotationFontColorElem.setAttribute( "red", mGridAnnotationFontColor.red() );
890914
annotationFontColorElem.setAttribute( "green", mGridAnnotationFontColor.green() );
891915
annotationFontColorElem.setAttribute( "blue", mGridAnnotationFontColor.blue() );
916+
annotationFontColorElem.setAttribute( "alpha", mGridAnnotationFontColor.alpha() );
892917
annotationElem.appendChild( annotationFontColorElem );
893918

894919
gridElem.appendChild( annotationElem );
@@ -1027,6 +1052,54 @@ bool QgsComposerMap::readXML( const QDomElement& itemElem, const QDomDocument& d
10271052
mCrossLength = gridElem.attribute( "crossLength", "3" ).toDouble();
10281053
mGridFrameStyle = ( QgsComposerMap::GridFrameStyle )gridElem.attribute( "gridFrameStyle", "0" ).toInt();
10291054
mGridFrameWidth = gridElem.attribute( "gridFrameWidth", "2.0" ).toDouble();
1055+
mGridFramePenThickness = gridElem.attribute( "gridFramePenThickness", "0.5" ).toDouble();
1056+
1057+
//grid frame pen color
1058+
QDomNodeList gridFramePenColorList = gridElem.elementsByTagName( "framePenColor" );
1059+
if ( gridFramePenColorList.size() > 0 )
1060+
{
1061+
QDomElement penColorElem = gridFramePenColorList.at( 0 ).toElement();
1062+
int red = penColorElem.attribute( "red", "0" ).toInt();
1063+
int green = penColorElem.attribute( "green", "0" ).toInt();
1064+
int blue = penColorElem.attribute( "blue", "0" ).toInt();
1065+
int alpha = penColorElem.attribute( "alpha", "255" ).toInt();
1066+
mGridFramePenColor = QColor( red, green, blue, alpha );
1067+
}
1068+
else
1069+
{
1070+
mGridFramePenColor = QColor( 0, 0, 0 );
1071+
}
1072+
//grid frame fill color 1
1073+
QDomNodeList gridFrameFillColor1List = gridElem.elementsByTagName( "frameFillColor1" );
1074+
if ( gridFrameFillColor1List.size() > 0 )
1075+
{
1076+
QDomElement fillColorElem = gridFrameFillColor1List.at( 0 ).toElement();
1077+
int red = fillColorElem.attribute( "red", "0" ).toInt();
1078+
int green = fillColorElem.attribute( "green", "0" ).toInt();
1079+
int blue = fillColorElem.attribute( "blue", "0" ).toInt();
1080+
int alpha = fillColorElem.attribute( "alpha", "255" ).toInt();
1081+
mGridFrameFillColor1 = QColor( red, green, blue, alpha );
1082+
}
1083+
else
1084+
{
1085+
mGridFrameFillColor1 = Qt::white;
1086+
}
1087+
//grid frame fill color 2
1088+
QDomNodeList gridFrameFillColor2List = gridElem.elementsByTagName( "frameFillColor2" );
1089+
if ( gridFrameFillColor2List.size() > 0 )
1090+
{
1091+
QDomElement fillColorElem = gridFrameFillColor2List.at( 0 ).toElement();
1092+
int red = fillColorElem.attribute( "red", "0" ).toInt();
1093+
int green = fillColorElem.attribute( "green", "0" ).toInt();
1094+
int blue = fillColorElem.attribute( "blue", "0" ).toInt();
1095+
int alpha = fillColorElem.attribute( "alpha", "255" ).toInt();
1096+
mGridFrameFillColor2 = QColor( red, green, blue, alpha );
1097+
}
1098+
else
1099+
{
1100+
mGridFrameFillColor2 = Qt::black;
1101+
}
1102+
10301103
setGridBlendMode( QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode ) gridElem.attribute( "gridBlendMode", "0" ).toUInt() ) );
10311104

10321105
QDomElement gridSymbolElem = gridElem.firstChildElement( "symbol" );
@@ -1070,7 +1143,8 @@ bool QgsComposerMap::readXML( const QDomElement& itemElem, const QDomDocument& d
10701143
int red = fontColorElem.attribute( "red", "0" ).toInt();
10711144
int green = fontColorElem.attribute( "green", "0" ).toInt();
10721145
int blue = fontColorElem.attribute( "blue", "0" ).toInt();
1073-
mGridAnnotationFontColor = QColor( red, green, blue );
1146+
int alpha = fontColorElem.attribute( "alpha", "255" ).toInt();
1147+
mGridAnnotationFontColor = QColor( red, green, blue, alpha );
10741148
}
10751149
else
10761150
{
@@ -1268,7 +1342,7 @@ void QgsComposerMap::drawGridLine( const QLineF& line, QPainter* p )
12681342
void QgsComposerMap::drawGridFrameBorder( QPainter* p, const QMap< double, double >& borderPos, Border border )
12691343
{
12701344
double currentCoord = - mGridFrameWidth;
1271-
bool white = true;
1345+
bool color1 = true;
12721346
double x = 0;
12731347
double y = 0;
12741348
double width = 0;
@@ -1287,10 +1361,15 @@ void QgsComposerMap::drawGridFrameBorder( QPainter* p, const QMap< double, doubl
12871361
pos.insert( rect().width() + mGridFrameWidth, rect().width() + mGridFrameWidth );
12881362
}
12891363

1364+
//set pen to current frame pen
1365+
QPen framePen = QPen( mGridFramePenColor );
1366+
framePen.setWidthF( mGridFramePenThickness );
1367+
p->setPen( framePen );
1368+
12901369
QMap< double, double >::const_iterator posIt = pos.constBegin();
12911370
for ( ; posIt != pos.constEnd(); ++posIt )
12921371
{
1293-
p->setBrush( QBrush( white ? Qt::white : Qt::black ) );
1372+
p->setBrush( QBrush( color1 ? mGridFrameFillColor1 : mGridFrameFillColor2 ) );
12941373
if ( border == Left || border == Right )
12951374
{
12961375
height = posIt.key() - currentCoord;
@@ -1307,7 +1386,7 @@ void QgsComposerMap::drawGridFrameBorder( QPainter* p, const QMap< double, doubl
13071386
}
13081387
p->drawRect( QRectF( x, y, width, height ) );
13091388
currentCoord = posIt.key();
1310-
white = !white;
1389+
color1 = !color1;
13111390
}
13121391
}
13131392

@@ -1347,7 +1426,7 @@ void QgsComposerMap::drawCoordinateAnnotation( QPainter* p, const QPointF& pos,
13471426
double ypos = pos.y();
13481427
int rotation = 0;
13491428

1350-
double gridFrameDistance = ( mGridFrameStyle == NoGridFrame ) ? 0 : mGridFrameWidth;
1429+
double gridFrameDistance = ( mGridFrameStyle == NoGridFrame ) ? 0 : mGridFrameWidth + ( mGridFramePenThickness / 2.0 );
13511430

13521431
if ( frameBorder == Left )
13531432
{
@@ -1801,7 +1880,7 @@ double QgsComposerMap::maxExtension() const
18011880
}
18021881

18031882
//grid frame
1804-
double gridFrameDist = ( mGridFrameStyle == NoGridFrame ) ? 0 : mGridFrameWidth;
1883+
double gridFrameDist = ( mGridFrameStyle == NoGridFrame ) ? 0 : mGridFrameWidth + ( mGridFramePenThickness / 2.0 );
18051884
return maxExtension + mAnnotationFrameDistance + gridFrameDist;
18061885
}
18071886

‎src/core/composer/qgscomposermap.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,32 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
287287
void setGridFrameWidth( double w ) { mGridFrameWidth = w; }
288288
double gridFrameWidth() const { return mGridFrameWidth; }
289289

290+
/**Set grid frame pen thickness
291+
@note: this function was added in version 2.1*/
292+
void setGridFramePenSize( double w ) { mGridFramePenThickness = w; }
293+
double gridFramePenSize() const { return mGridFramePenThickness; }
294+
295+
/**Sets pen color for grid frame
296+
@note: this function was added in version 2.1*/
297+
void setGridFramePenColor( const QColor& c ) { mGridFramePenColor = c;}
298+
/**Get pen color for grid frame
299+
@note: this function was added in version 2.1*/
300+
QColor gridFramePenColor() const {return mGridFramePenColor;}
301+
302+
/**Sets first fill color for grid zebra frame
303+
@note: this function was added in version 2.1*/
304+
void setGridFrameFillColor1( const QColor& c ) { mGridFrameFillColor1 = c;}
305+
/**Get first fill color for grid zebra frame
306+
@note: this function was added in version 2.1*/
307+
QColor gridFrameFillColor1() const {return mGridFrameFillColor1;}
308+
309+
/**Sets second fill color for grid zebra frame
310+
@note: this function was added in version 2.1*/
311+
void setGridFrameFillColor2( const QColor& c ) { mGridFrameFillColor2 = c;}
312+
/**Get second fill color for grid zebra frame
313+
@note: this function was added in version 2.1*/
314+
QColor gridFrameFillColor2() const {return mGridFrameFillColor2;}
315+
290316
/**In case of annotations, the bounding rectangle can be larger than the map item rectangle
291317
@note this function was added in version 1.4*/
292318
QRectF boundingRect() const;
@@ -470,6 +496,10 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
470496

471497
GridFrameStyle mGridFrameStyle;
472498
double mGridFrameWidth;
499+
double mGridFramePenThickness;
500+
QColor mGridFramePenColor;
501+
QColor mGridFrameFillColor1;
502+
QColor mGridFrameFillColor2;
473503

474504
/**Current bounding rectangle. This is used to check if notification to the graphics scene is necessary*/
475505
QRectF mCurrentRectangle;

‎src/ui/qgscomposermapwidgetbase.ui

Lines changed: 87 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@
5454
<property name="geometry">
5555
<rect>
5656
<x>0</x>
57-
<y>-376</y>
57+
<y>-420</y>
5858
<width>439</width>
59-
<height>1439</height>
59+
<height>1509</height>
6060
</rect>
6161
</property>
6262
<property name="sizePolicy">
@@ -393,32 +393,6 @@
393393
</widget>
394394
</item>
395395
<item row="4" column="0">
396-
<widget class="QLabel" name="mFrameStyleLabel">
397-
<property name="text">
398-
<string>Frame style</string>
399-
</property>
400-
<property name="wordWrap">
401-
<bool>false</bool>
402-
</property>
403-
</widget>
404-
</item>
405-
<item row="4" column="1">
406-
<widget class="QComboBox" name="mFrameStyleComboBox"/>
407-
</item>
408-
<item row="5" column="0">
409-
<widget class="QLabel" name="mFrameWidthLabel">
410-
<property name="text">
411-
<string>Frame width</string>
412-
</property>
413-
<property name="wordWrap">
414-
<bool>false</bool>
415-
</property>
416-
</widget>
417-
</item>
418-
<item row="5" column="1">
419-
<widget class="QDoubleSpinBox" name="mFrameWidthSpinBox"/>
420-
</item>
421-
<item row="6" column="0">
422396
<widget class="QLabel" name="mLineStyleLabel">
423397
<property name="text">
424398
<string>Line style</string>
@@ -428,17 +402,17 @@
428402
</property>
429403
</widget>
430404
</item>
431-
<item row="6" column="1">
405+
<item row="4" column="1">
432406
<widget class="QPushButton" name="mGridLineStyleButton">
433407
<property name="text">
434408
<string>change...</string>
435409
</property>
436410
</widget>
437411
</item>
438-
<item row="7" column="1">
412+
<item row="5" column="1">
439413
<widget class="QgsBlendModeComboBox" name="mGridBlendComboBox"/>
440414
</item>
441-
<item row="7" column="0">
415+
<item row="5" column="0">
442416
<widget class="QLabel" name="mGridBlendLabel">
443417
<property name="text">
444418
<string>Blend mode</string>
@@ -460,6 +434,88 @@
460434
</item>
461435
</layout>
462436
</item>
437+
<item>
438+
<widget class="QgsCollapsibleGroupBoxBasic" name="mGridFrameGroupBox">
439+
<property name="title">
440+
<string>Grid frame</string>
441+
</property>
442+
<property name="flat">
443+
<bool>false</bool>
444+
</property>
445+
<property name="checkable">
446+
<bool>false</bool>
447+
</property>
448+
<property name="collapsed" stdset="0">
449+
<bool>true</bool>
450+
</property>
451+
<layout class="QGridLayout" name="gridLayout_2">
452+
<item row="0" column="0">
453+
<widget class="QLabel" name="mFrameStyleLabel">
454+
<property name="text">
455+
<string>Frame style</string>
456+
</property>
457+
<property name="wordWrap">
458+
<bool>false</bool>
459+
</property>
460+
</widget>
461+
</item>
462+
<item row="0" column="1" colspan="2">
463+
<widget class="QComboBox" name="mFrameStyleComboBox"/>
464+
</item>
465+
<item row="1" column="0">
466+
<widget class="QLabel" name="mFrameWidthLabel">
467+
<property name="text">
468+
<string>Frame size</string>
469+
</property>
470+
<property name="wordWrap">
471+
<bool>false</bool>
472+
</property>
473+
</widget>
474+
</item>
475+
<item row="1" column="1" colspan="2">
476+
<widget class="QDoubleSpinBox" name="mFrameWidthSpinBox"/>
477+
</item>
478+
<item row="2" column="0">
479+
<widget class="QLabel" name="mFramePenLabel">
480+
<property name="text">
481+
<string>Frame line thickness</string>
482+
</property>
483+
</widget>
484+
</item>
485+
<item row="2" column="1">
486+
<widget class="QDoubleSpinBox" name="mGridFramePenSizeSpinBox"/>
487+
</item>
488+
<item row="2" column="2">
489+
<widget class="QgsColorButton" name="mGridFramePenColorButton">
490+
<property name="text">
491+
<string>Color...</string>
492+
</property>
493+
</widget>
494+
</item>
495+
<item row="3" column="0">
496+
<widget class="QLabel" name="mFrameFillLabel">
497+
<property name="text">
498+
<string>Frame fill colors</string>
499+
</property>
500+
</widget>
501+
</item>
502+
<item row="3" column="1">
503+
<widget class="QgsColorButton" name="mGridFrameFill1ColorButton">
504+
<property name="text">
505+
<string/>
506+
</property>
507+
</widget>
508+
</item>
509+
<item row="3" column="2">
510+
<widget class="QgsColorButton" name="mGridFrameFill2ColorButton">
511+
<property name="text">
512+
<string/>
513+
</property>
514+
</widget>
515+
</item>
516+
</layout>
517+
</widget>
518+
</item>
463519
<item>
464520
<widget class="QgsCollapsibleGroupBoxBasic" name="mDrawAnnotationCheckableGroupBox">
465521
<property name="enabled">

‎tests/src/core/testqgscomposermap.cpp

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void TestQgsComposerMap::initTestCase()
7575
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
7676
mComposerMap->setFrameEnabled( true );
7777
mComposition->addComposerMap( mComposerMap );
78-
78+
7979
mReport = "<h1>Composer Map Tests</h1>\n";
8080
}
8181

@@ -84,15 +84,15 @@ void TestQgsComposerMap::cleanupTestCase()
8484
delete mComposition;
8585
delete mMapRenderer;
8686
delete mRasterLayer;
87-
87+
8888
QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
8989
QFile myFile( myReportFile );
9090
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )
9191
{
9292
QTextStream myQTextStream( &myFile );
9393
myQTextStream << mReport;
9494
myFile.close();
95-
}
95+
}
9696
}
9797

9898
void TestQgsComposerMap::init()
@@ -108,7 +108,7 @@ void TestQgsComposerMap::render()
108108
{
109109
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
110110
QgsCompositionChecker checker( "composermap_render", mComposition );
111-
111+
112112
QVERIFY( checker.testComposition( mReport ) );
113113
}
114114

@@ -132,8 +132,8 @@ void TestQgsComposerMap::grid()
132132
mComposerMap->setGridBlendMode( QPainter::CompositionMode_Overlay );
133133
qWarning() << "grid annotation font: " << mComposerMap->gridAnnotationFont().toString() << " exactMatch:" << mComposerMap->gridAnnotationFont().exactMatch();
134134
QgsCompositionChecker checker( "composermap_grid", mComposition );
135-
136-
bool testResult = checker.testComposition( mReport);
135+
136+
bool testResult = checker.testComposition( mReport );
137137
mComposerMap->setGridEnabled( false );
138138
mComposerMap->setShowGridAnnotation( false );
139139
QVERIFY( testResult );
@@ -148,8 +148,8 @@ void TestQgsComposerMap::overviewMap()
148148
overviewMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
149149
overviewMap->setOverviewFrameMap( mComposerMap->id() );
150150
QgsCompositionChecker checker( "composermap_overview", mComposition );
151-
152-
bool testResult = checker.testComposition( mReport);
151+
152+
bool testResult = checker.testComposition( mReport );
153153
mComposition->removeComposerItem( overviewMap );
154154
QVERIFY( testResult );
155155
}
@@ -165,8 +165,8 @@ void TestQgsComposerMap::overviewMapBlending()
165165
overviewMapBlend->setOverviewBlendMode( QPainter::CompositionMode_Multiply );
166166

167167
QgsCompositionChecker checker( "composermap_overview_blending", mComposition );
168-
169-
bool testResult = checker.testComposition( mReport);
168+
169+
bool testResult = checker.testComposition( mReport );
170170
mComposition->removeComposerItem( overviewMapBlend );
171171
QVERIFY( testResult );
172172
}
@@ -182,8 +182,8 @@ void TestQgsComposerMap::overviewMapInvert()
182182
overviewMapInvert->setOverviewInverted( true );
183183

184184
QgsCompositionChecker checker( "composermap_overview_invert", mComposition );
185-
186-
bool testResult = checker.testComposition( mReport);
185+
186+
bool testResult = checker.testComposition( mReport );
187187
mComposition->removeComposerItem( overviewMapInvert );
188188
QVERIFY( testResult );
189189
}
@@ -222,11 +222,16 @@ void TestQgsComposerMap::zebraStyle()
222222
mComposerMap->setGridBlendMode( QPainter::CompositionMode_SourceOver );
223223

224224
mComposerMap->setGridFrameStyle( QgsComposerMap::Zebra );
225+
mComposerMap->setGridFrameWidth( 10 );
226+
mComposerMap->setGridFramePenSize( 1 );
227+
mComposerMap->setGridFramePenColor( QColor( 255, 100, 0, 200 ) );
228+
mComposerMap->setGridFrameFillColor1( QColor( 50, 90, 50, 100 ) );
229+
mComposerMap->setGridFrameFillColor2( QColor( 200, 220, 100, 60 ) );
225230
mComposerMap->setGridEnabled( true );
226231

227232
QgsCompositionChecker checker( "composermap_zebrastyle", mComposition );
228-
229-
bool testResult = checker.testComposition( mReport);
233+
234+
bool testResult = checker.testComposition( mReport );
230235
QVERIFY( testResult );
231236
}
232237

@@ -242,8 +247,8 @@ void TestQgsComposerMap::overviewMapCenter()
242247
overviewMapCenter->setOverviewCentered( true );
243248

244249
QgsCompositionChecker checker( "composermap_overview_center", mComposition );
245-
246-
bool testResult = checker.testComposition( mReport);
250+
251+
bool testResult = checker.testComposition( mReport );
247252
mComposition->removeComposerItem( overviewMapCenter );
248253
QVERIFY( testResult );
249254
}

0 commit comments

Comments
 (0)
Please sign in to comment.