@@ -49,6 +49,7 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int w
49
49
mTopGridAnnotationPosition( OutsideMapFrame ), mBottomGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ),
50
50
mLeftGridAnnotationDirection( Horizontal ), mRightGridAnnotationDirection( Horizontal ), mTopGridAnnotationDirection( Horizontal ),
51
51
mBottomGridAnnotationDirection( Horizontal ), mGridFrameStyle( NoGridFrame ), mGridFrameWidth( 2.0 ),
52
+ mGridFramePenThickness( 0.5 ), mGridFramePenColor( QColor( 0 , 0 , 0 ) ), mGridFrameFillColor1( Qt::white ), mGridFrameFillColor2( Qt::black ),
52
53
mCrossLength( 3 ), mMapCanvas( 0 ), mDrawCanvasItems( true )
53
54
{
54
55
mComposition = composition;
@@ -105,8 +106,9 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition )
105
106
mLeftGridAnnotationPosition( OutsideMapFrame ), mRightGridAnnotationPosition( OutsideMapFrame ),
106
107
mTopGridAnnotationPosition( OutsideMapFrame ), mBottomGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ),
107
108
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 )
110
112
{
111
113
mOverviewFrameMapSymbol = 0 ;
112
114
mGridLineSymbol = 0 ;
@@ -865,6 +867,28 @@ bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc ) const
865
867
gridElem.setAttribute ( " crossLength" , qgsDoubleToString ( mCrossLength ) );
866
868
gridElem.setAttribute ( " gridFrameStyle" , mGridFrameStyle );
867
869
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
+
868
892
gridElem.setAttribute ( " gridBlendMode" , QgsMapRenderer::getBlendModeEnum ( mGridBlendMode ) );
869
893
QDomElement gridLineStyleElem = QgsSymbolLayerV2Utils::saveSymbol ( QString (), mGridLineSymbol , doc );
870
894
gridElem.appendChild ( gridLineStyleElem );
@@ -889,6 +913,7 @@ bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc ) const
889
913
annotationFontColorElem.setAttribute ( " red" , mGridAnnotationFontColor .red () );
890
914
annotationFontColorElem.setAttribute ( " green" , mGridAnnotationFontColor .green () );
891
915
annotationFontColorElem.setAttribute ( " blue" , mGridAnnotationFontColor .blue () );
916
+ annotationFontColorElem.setAttribute ( " alpha" , mGridAnnotationFontColor .alpha () );
892
917
annotationElem.appendChild ( annotationFontColorElem );
893
918
894
919
gridElem.appendChild ( annotationElem );
@@ -1027,6 +1052,54 @@ bool QgsComposerMap::readXML( const QDomElement& itemElem, const QDomDocument& d
1027
1052
mCrossLength = gridElem.attribute ( " crossLength" , " 3" ).toDouble ();
1028
1053
mGridFrameStyle = ( QgsComposerMap::GridFrameStyle )gridElem.attribute ( " gridFrameStyle" , " 0" ).toInt ();
1029
1054
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
+
1030
1103
setGridBlendMode ( QgsMapRenderer::getCompositionMode (( QgsMapRenderer::BlendMode ) gridElem.attribute ( " gridBlendMode" , " 0" ).toUInt () ) );
1031
1104
1032
1105
QDomElement gridSymbolElem = gridElem.firstChildElement ( " symbol" );
@@ -1070,7 +1143,8 @@ bool QgsComposerMap::readXML( const QDomElement& itemElem, const QDomDocument& d
1070
1143
int red = fontColorElem.attribute ( " red" , " 0" ).toInt ();
1071
1144
int green = fontColorElem.attribute ( " green" , " 0" ).toInt ();
1072
1145
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 );
1074
1148
}
1075
1149
else
1076
1150
{
@@ -1268,7 +1342,7 @@ void QgsComposerMap::drawGridLine( const QLineF& line, QPainter* p )
1268
1342
void QgsComposerMap::drawGridFrameBorder ( QPainter* p, const QMap< double , double >& borderPos, Border border )
1269
1343
{
1270
1344
double currentCoord = - mGridFrameWidth ;
1271
- bool white = true ;
1345
+ bool color1 = true ;
1272
1346
double x = 0 ;
1273
1347
double y = 0 ;
1274
1348
double width = 0 ;
@@ -1287,10 +1361,15 @@ void QgsComposerMap::drawGridFrameBorder( QPainter* p, const QMap< double, doubl
1287
1361
pos.insert ( rect ().width () + mGridFrameWidth , rect ().width () + mGridFrameWidth );
1288
1362
}
1289
1363
1364
+ // set pen to current frame pen
1365
+ QPen framePen = QPen ( mGridFramePenColor );
1366
+ framePen.setWidthF ( mGridFramePenThickness );
1367
+ p->setPen ( framePen );
1368
+
1290
1369
QMap< double , double >::const_iterator posIt = pos.constBegin ();
1291
1370
for ( ; posIt != pos.constEnd (); ++posIt )
1292
1371
{
1293
- p->setBrush ( QBrush ( white ? Qt::white : Qt::black ) );
1372
+ p->setBrush ( QBrush ( color1 ? mGridFrameFillColor1 : mGridFrameFillColor2 ) );
1294
1373
if ( border == Left || border == Right )
1295
1374
{
1296
1375
height = posIt.key () - currentCoord;
@@ -1307,7 +1386,7 @@ void QgsComposerMap::drawGridFrameBorder( QPainter* p, const QMap< double, doubl
1307
1386
}
1308
1387
p->drawRect ( QRectF ( x, y, width, height ) );
1309
1388
currentCoord = posIt.key ();
1310
- white = !white ;
1389
+ color1 = !color1 ;
1311
1390
}
1312
1391
}
1313
1392
@@ -1347,7 +1426,7 @@ void QgsComposerMap::drawCoordinateAnnotation( QPainter* p, const QPointF& pos,
1347
1426
double ypos = pos.y ();
1348
1427
int rotation = 0 ;
1349
1428
1350
- double gridFrameDistance = ( mGridFrameStyle == NoGridFrame ) ? 0 : mGridFrameWidth ;
1429
+ double gridFrameDistance = ( mGridFrameStyle == NoGridFrame ) ? 0 : mGridFrameWidth + ( mGridFramePenThickness / 2.0 ) ;
1351
1430
1352
1431
if ( frameBorder == Left )
1353
1432
{
@@ -1801,7 +1880,7 @@ double QgsComposerMap::maxExtension() const
1801
1880
}
1802
1881
1803
1882
// grid frame
1804
- double gridFrameDist = ( mGridFrameStyle == NoGridFrame ) ? 0 : mGridFrameWidth ;
1883
+ double gridFrameDist = ( mGridFrameStyle == NoGridFrame ) ? 0 : mGridFrameWidth + ( mGridFramePenThickness / 2.0 ) ;
1805
1884
return maxExtension + mAnnotationFrameDistance + gridFrameDist;
1806
1885
}
1807
1886
0 commit comments