|
42 | 42 | QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int width, int height )
|
43 | 43 | : QgsComposerItem( x, y, width, height, composition ), mKeepLayerSet( false ),
|
44 | 44 | mOverviewFrameMapId( -1 ), mOverviewBlendMode( QPainter::CompositionMode_SourceOver ), mOverviewInverted( false ), mGridEnabled( false ), mGridStyle( Solid ),
|
45 |
| - mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mGridAnnotationPrecision( 3 ), mShowGridAnnotation( false ), |
46 |
| - mGridBlendMode( QPainter::CompositionMode_SourceOver ), mLeftGridAnnotationPosition( OutsideMapFrame ), mRightGridAnnotationPosition( OutsideMapFrame ), |
| 45 | + mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mGridAnnotationFontColor( QColor( 0, 0, 0 ) ), |
| 46 | + mGridAnnotationPrecision( 3 ), mShowGridAnnotation( false ), mGridBlendMode( QPainter::CompositionMode_SourceOver ), |
| 47 | + mLeftGridAnnotationPosition( OutsideMapFrame ), mRightGridAnnotationPosition( OutsideMapFrame ), |
47 | 48 | mTopGridAnnotationPosition( OutsideMapFrame ), mBottomGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ),
|
48 | 49 | mLeftGridAnnotationDirection( Horizontal ), mRightGridAnnotationDirection( Horizontal ), mTopGridAnnotationDirection( Horizontal ),
|
49 | 50 | mBottomGridAnnotationDirection( Horizontal ), mGridFrameStyle( NoGridFrame ), mGridFrameWidth( 2.0 ),
|
@@ -86,8 +87,9 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int w
|
86 | 87 | QgsComposerMap::QgsComposerMap( QgsComposition *composition )
|
87 | 88 | : QgsComposerItem( 0, 0, 10, 10, composition ), mKeepLayerSet( false ), mOverviewFrameMapId( -1 ),
|
88 | 89 | mOverviewBlendMode( QPainter::CompositionMode_SourceOver ), mOverviewInverted( false ), mGridEnabled( false ), mGridStyle( Solid ),
|
89 |
| - mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mGridAnnotationPrecision( 3 ), mShowGridAnnotation( false ), |
90 |
| - mGridBlendMode( QPainter::CompositionMode_SourceOver ), mLeftGridAnnotationPosition( OutsideMapFrame ), mRightGridAnnotationPosition( OutsideMapFrame ), |
| 90 | + mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mGridAnnotationFontColor( QColor( 0, 0, 0 ) ), |
| 91 | + mGridAnnotationPrecision( 3 ), mShowGridAnnotation( false ), mGridBlendMode( QPainter::CompositionMode_SourceOver ), |
| 92 | + mLeftGridAnnotationPosition( OutsideMapFrame ), mRightGridAnnotationPosition( OutsideMapFrame ), |
91 | 93 | mTopGridAnnotationPosition( OutsideMapFrame ), mBottomGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ),
|
92 | 94 | mLeftGridAnnotationDirection( Horizontal ), mRightGridAnnotationDirection( Horizontal ), mTopGridAnnotationDirection( Horizontal ),
|
93 | 95 | mBottomGridAnnotationDirection( Horizontal ), mGridFrameStyle( NoGridFrame ), mGridFrameWidth( 2.0 ), mCrossLength( 3 ),
|
@@ -813,6 +815,12 @@ bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc ) const
|
813 | 815 | annotationElem.setAttribute( "frameDistance", QString::number( mAnnotationFrameDistance ) );
|
814 | 816 | annotationElem.setAttribute( "font", mGridAnnotationFont.toString() );
|
815 | 817 | annotationElem.setAttribute( "precision", mGridAnnotationPrecision );
|
| 818 | + //annotation font color |
| 819 | + QDomElement annotationFontColorElem = doc.createElement( "fontColor" ); |
| 820 | + annotationFontColorElem.setAttribute( "red", mGridAnnotationFontColor.red() ); |
| 821 | + annotationFontColorElem.setAttribute( "green", mGridAnnotationFontColor.green() ); |
| 822 | + annotationFontColorElem.setAttribute( "blue", mGridAnnotationFontColor.blue() ); |
| 823 | + annotationElem.appendChild( annotationFontColorElem ); |
816 | 824 |
|
817 | 825 | gridElem.appendChild( annotationElem );
|
818 | 826 | composerMapElem.appendChild( gridElem );
|
@@ -975,6 +983,22 @@ bool QgsComposerMap::readXML( const QDomElement& itemElem, const QDomDocument& d
|
975 | 983 | mBottomGridAnnotationDirection = QgsComposerMap::GridAnnotationDirection( annotationElem.attribute( "bottomDirection", "0" ).toInt() );
|
976 | 984 | mAnnotationFrameDistance = annotationElem.attribute( "frameDistance", "0" ).toDouble();
|
977 | 985 | mGridAnnotationFont.fromString( annotationElem.attribute( "font", "" ) );
|
| 986 | + |
| 987 | + //annotation font color |
| 988 | + QDomNodeList annotationFontColorList = annotationElem.elementsByTagName( "fontColor" ); |
| 989 | + if ( annotationFontColorList.size() > 0 ) |
| 990 | + { |
| 991 | + QDomElement fontColorElem = annotationFontColorList.at( 0 ).toElement(); |
| 992 | + int red = fontColorElem.attribute( "red", "0" ).toInt(); |
| 993 | + int green = fontColorElem.attribute( "green", "0" ).toInt(); |
| 994 | + int blue = fontColorElem.attribute( "blue", "0" ).toInt(); |
| 995 | + mGridAnnotationFontColor = QColor( red, green, blue ); |
| 996 | + } |
| 997 | + else |
| 998 | + { |
| 999 | + mGridAnnotationFontColor = QColor( 0, 0, 0 ); |
| 1000 | + } |
| 1001 | + |
978 | 1002 | mGridAnnotationPrecision = annotationElem.attribute( "precision", "3" ).toInt();
|
979 | 1003 | }
|
980 | 1004 | }
|
@@ -1398,7 +1422,7 @@ void QgsComposerMap::drawAnnotation( QPainter* p, const QPointF& pos, int rotati
|
1398 | 1422 | p->save();
|
1399 | 1423 | p->translate( pos );
|
1400 | 1424 | p->rotate( rotation );
|
1401 |
| - p->setPen( QColor( 0, 0, 0 ) ); |
| 1425 | + p->setPen( QPen( QColor( mGridAnnotationFontColor ) ) ); |
1402 | 1426 | drawText( p, 0, 0, annotationText, mGridAnnotationFont );
|
1403 | 1427 | p->restore();
|
1404 | 1428 | }
|
|
0 commit comments