diff --git a/python/core/composer/qgscomposermap.sip b/python/core/composer/qgscomposermap.sip index e1ea96a5129..c6172ac85a6 100644 --- a/python/core/composer/qgscomposermap.sip +++ b/python/core/composer/qgscomposermap.sip @@ -247,6 +247,32 @@ class QgsComposerMap : QgsComposerItem @note: this function was added in version 1.9*/ void setGridFrameWidth( double w ); double gridFrameWidth() const; + + /**Set grid frame pen thickness + @note: this function was added in version 2.1*/ + void setGridFramePenSize( double w ); + double gridFramePenSize() const; + + /**Sets pen color for grid frame + @note: this function was added in version 2.1*/ + void setGridFramePenColor( const QColor& c ); + /**Get pen color for grid frame + @note: this function was added in version 2.1*/ + QColor gridFramePenColor() const; + + /**Sets first fill color for grid zebra frame + @note: this function was added in version 2.1*/ + void setGridFrameFillColor1( const QColor& c ); + /**Get first fill color for grid zebra frame + @note: this function was added in version 2.1*/ + QColor gridFrameFillColor1() const; + + /**Sets second fill color for grid zebra frame + @note: this function was added in version 2.1*/ + void setGridFrameFillColor2( const QColor& c ); + /**Get second fill color for grid zebra frame + @note: this function was added in version 2.1*/ + QColor gridFrameFillColor2() const; /** Returns the grid's blending mode @note added in version 2.0*/ diff --git a/src/app/composer/qgscomposermapwidget.cpp b/src/app/composer/qgscomposermapwidget.cpp index 96dd0d55866..d5b38187841 100644 --- a/src/app/composer/qgscomposermapwidget.cpp +++ b/src/app/composer/qgscomposermapwidget.cpp @@ -61,6 +61,9 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap ): QWidg mAnnotationFormatComboBox->insertItem( 1, tr( "DegreeMinute" ) ); mAnnotationFormatComboBox->insertItem( 2, tr( "DegreeMinuteSecond" ) ); + mAnnotationFontColorButton->setColorDialogTitle( tr( "Select font color" ) ); + mAnnotationFontColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel ); + insertAnnotationPositionEntries( mAnnotationPositionLeftComboBox ); insertAnnotationPositionEntries( mAnnotationPositionRightComboBox ); insertAnnotationPositionEntries( mAnnotationPositionTopComboBox ); @@ -74,9 +77,22 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap ): QWidg mFrameStyleComboBox->insertItem( 0, tr( "No frame" ) ); mFrameStyleComboBox->insertItem( 1, tr( "Zebra" ) ); + mGridFramePenColorButton->setColorDialogTitle( tr( "Select grid frame color" ) ); + mGridFramePenColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel ); + mGridFrameFill1ColorButton->setColorDialogTitle( tr( "Select grid frame fill color" ) ); + mGridFrameFill1ColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel ); + mGridFrameFill2ColorButton->setColorDialogTitle( tr( "Select grid frame fill color" ) ); + mGridFrameFill2ColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel ); + + //set initial state of frame style controls + toggleFrameControls( false ); + connect( mGridCheckBox, SIGNAL( toggled( bool ) ), mDrawAnnotationCheckableGroupBox, SLOT( setEnabled( bool ) ) ); + connect( mFrameStyleComboBox, SIGNAL( currentIndexChanged( QString ) ), + this, SLOT( frameStyleChanged( QString ) ) ); + if ( composerMap ) { connect( composerMap, SIGNAL( itemChanged() ), this, SLOT( setGuiElementValues() ) ); @@ -339,14 +355,20 @@ void QgsComposerMapWidget::updateGuiElements() //grid frame mFrameWidthSpinBox->setValue( mComposerMap->gridFrameWidth() ); + mGridFramePenSizeSpinBox->setValue( mComposerMap->gridFramePenSize() ); + mGridFramePenColorButton->setColor( mComposerMap->gridFramePenColor() ); + mGridFrameFill1ColorButton->setColor( mComposerMap->gridFrameFillColor1() ); + mGridFrameFill2ColorButton->setColor( mComposerMap->gridFrameFillColor2() ); QgsComposerMap::GridFrameStyle gridFrameStyle = mComposerMap->gridFrameStyle(); if ( gridFrameStyle == QgsComposerMap::Zebra ) { mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findText( tr( "Zebra" ) ) ); + toggleFrameControls( true ); } else //NoGridFrame { mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findText( tr( "No frame" ) ) ); + toggleFrameControls( false ); } //grid blend mode @@ -369,8 +391,6 @@ void QgsComposerMapWidget::updateGuiElements() initAnnotationDirectionBox( mAnnotationDirectionComboBoxBottom, mComposerMap->gridAnnotationDirection( QgsComposerMap::Bottom ) ); mAnnotationFontColorButton->setColor( mComposerMap->annotationFontColor() ); - mAnnotationFontColorButton->setColorDialogTitle( tr( "Select font color" ) ); - mAnnotationFontColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel ); mDistanceToMapFrameSpinBox->setValue( mComposerMap->annotationFrameDistance() ); @@ -454,6 +474,10 @@ void QgsComposerMapWidget::blockAllSignals( bool b ) mDrawCanvasItemsCheckBox->blockSignals( b ); mFrameStyleComboBox->blockSignals( b ); mFrameWidthSpinBox->blockSignals( b ); + mGridFramePenSizeSpinBox->blockSignals( b ); + mGridFramePenColorButton->blockSignals( b ); + mGridFrameFill1ColorButton->blockSignals( b ); + mGridFrameFill2ColorButton->blockSignals( b ); mOverviewFrameMapComboBox->blockSignals( b ); mOverviewFrameStyleButton->blockSignals( b ); mOverviewBlendModeComboBox->blockSignals( b ); @@ -880,8 +904,23 @@ void QgsComposerMapWidget::on_mCoordinatePrecisionSpinBox_valueChanged( int valu mComposerMap->endCommand(); } +void QgsComposerMapWidget::toggleFrameControls( bool frameEnabled ) +{ + //set status of frame controls + mFrameWidthSpinBox->setEnabled( frameEnabled ); + mGridFramePenSizeSpinBox->setEnabled( frameEnabled ); + mGridFramePenColorButton->setEnabled( frameEnabled ); + mGridFrameFill1ColorButton->setEnabled( frameEnabled ); + mGridFrameFill2ColorButton->setEnabled( frameEnabled ); + mFrameWidthLabel->setEnabled( frameEnabled ); + mFramePenLabel->setEnabled( frameEnabled ); + mFrameFillLabel->setEnabled( frameEnabled ); +} + void QgsComposerMapWidget::on_mFrameStyleComboBox_currentIndexChanged( const QString& text ) { + toggleFrameControls( text != tr( "No frame" ) ); + if ( !mComposerMap ) { return; @@ -913,6 +952,54 @@ void QgsComposerMapWidget::on_mFrameWidthSpinBox_valueChanged( double d ) } } +void QgsComposerMapWidget::on_mGridFramePenSizeSpinBox_valueChanged( double d ) +{ + if ( mComposerMap ) + { + mComposerMap->beginCommand( tr( "Changed grid frame line thickness" ) ); + mComposerMap->setGridFramePenSize( d ); + mComposerMap->updateBoundingRect(); + mComposerMap->update(); + mComposerMap->endCommand(); + } +} + +void QgsComposerMapWidget::on_mGridFramePenColorButton_colorChanged( const QColor& newColor ) +{ + if ( !mComposerMap ) + { + return; + } + mComposerMap->beginCommand( tr( "Grid frame color changed" ) ); + mComposerMap->setGridFramePenColor( newColor ); + mComposerMap->update(); + mComposerMap->endCommand(); +} + +void QgsComposerMapWidget::on_mGridFrameFill1ColorButton_colorChanged( const QColor& newColor ) +{ + if ( !mComposerMap ) + { + return; + } + mComposerMap->beginCommand( tr( "Grid frame first fill color changed" ) ); + mComposerMap->setGridFrameFillColor1( newColor ); + mComposerMap->update(); + mComposerMap->endCommand(); +} + +void QgsComposerMapWidget::on_mGridFrameFill2ColorButton_colorChanged( const QColor& newColor ) +{ + if ( !mComposerMap ) + { + return; + } + mComposerMap->beginCommand( tr( "Grid frame second fill color changed" ) ); + mComposerMap->setGridFrameFillColor2( newColor ); + mComposerMap->update(); + mComposerMap->endCommand(); +} + void QgsComposerMapWidget::showEvent( QShowEvent * event ) { refreshMapComboBox(); diff --git a/src/app/composer/qgscomposermapwidget.h b/src/app/composer/qgscomposermapwidget.h index 7604615c0e2..a5f5ac1cc7d 100644 --- a/src/app/composer/qgscomposermapwidget.h +++ b/src/app/composer/qgscomposermapwidget.h @@ -85,6 +85,10 @@ class QgsComposerMapWidget: public QWidget, private Ui::QgsComposerMapWidgetBase void on_mFrameStyleComboBox_currentIndexChanged( const QString& text ); void on_mFrameWidthSpinBox_valueChanged( double d ); + void on_mGridFramePenSizeSpinBox_valueChanged( double d ); + void on_mGridFramePenColorButton_colorChanged( const QColor& newColor ); + void on_mGridFrameFill1ColorButton_colorChanged( const QColor& newColor ); + void on_mGridFrameFill2ColorButton_colorChanged( const QColor& newColor ); protected: void showEvent( QShowEvent * event ); @@ -122,6 +126,9 @@ class QgsComposerMapWidget: public QWidget, private Ui::QgsComposerMapWidgetBase /**Updates the map combo box with the current composer map ids*/ void refreshMapComboBox(); + + /**Enables/disables grid frame related controls*/ + void toggleFrameControls( bool frameEnabled ); }; #endif diff --git a/src/core/composer/qgscomposermap.cpp b/src/core/composer/qgscomposermap.cpp index 714213821a8..12d249bd320 100644 --- a/src/core/composer/qgscomposermap.cpp +++ b/src/core/composer/qgscomposermap.cpp @@ -49,6 +49,7 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int w mTopGridAnnotationPosition( OutsideMapFrame ), mBottomGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ), mLeftGridAnnotationDirection( Horizontal ), mRightGridAnnotationDirection( Horizontal ), mTopGridAnnotationDirection( Horizontal ), mBottomGridAnnotationDirection( Horizontal ), mGridFrameStyle( NoGridFrame ), mGridFrameWidth( 2.0 ), + mGridFramePenThickness( 0.5 ), mGridFramePenColor( QColor( 0, 0, 0 ) ), mGridFrameFillColor1( Qt::white ), mGridFrameFillColor2( Qt::black ), mCrossLength( 3 ), mMapCanvas( 0 ), mDrawCanvasItems( true ) { mComposition = composition; @@ -105,8 +106,9 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition ) mLeftGridAnnotationPosition( OutsideMapFrame ), mRightGridAnnotationPosition( OutsideMapFrame ), mTopGridAnnotationPosition( OutsideMapFrame ), mBottomGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ), mLeftGridAnnotationDirection( Horizontal ), mRightGridAnnotationDirection( Horizontal ), mTopGridAnnotationDirection( Horizontal ), - mBottomGridAnnotationDirection( Horizontal ), mGridFrameStyle( NoGridFrame ), mGridFrameWidth( 2.0 ), mCrossLength( 3 ), - mMapCanvas( 0 ), mDrawCanvasItems( true ) + mBottomGridAnnotationDirection( Horizontal ), mGridFrameStyle( NoGridFrame ), mGridFrameWidth( 2.0 ), mGridFramePenThickness( 0.5 ), + mGridFramePenColor( QColor( 0, 0, 0 ) ), mGridFrameFillColor1( Qt::white ), mGridFrameFillColor2( Qt::black ), + mCrossLength( 3 ), mMapCanvas( 0 ), mDrawCanvasItems( true ) { mOverviewFrameMapSymbol = 0; mGridLineSymbol = 0; @@ -865,6 +867,28 @@ bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc ) const gridElem.setAttribute( "crossLength", qgsDoubleToString( mCrossLength ) ); gridElem.setAttribute( "gridFrameStyle", mGridFrameStyle ); gridElem.setAttribute( "gridFrameWidth", qgsDoubleToString( mGridFrameWidth ) ); + gridElem.setAttribute( "gridFramePenThickness", qgsDoubleToString( mGridFramePenThickness ) ); + //grid frame pen color + QDomElement framePenColorElem = doc.createElement( "framePenColor" ); + framePenColorElem.setAttribute( "red", mGridFramePenColor.red() ); + framePenColorElem.setAttribute( "green", mGridFramePenColor.green() ); + framePenColorElem.setAttribute( "blue", mGridFramePenColor.blue() ); + framePenColorElem.setAttribute( "alpha", mGridFramePenColor.alpha() ); + gridElem.appendChild( framePenColorElem ); + //grid frame fill colors + QDomElement frameFillColor1Elem = doc.createElement( "frameFillColor1" ); + frameFillColor1Elem.setAttribute( "red", mGridFrameFillColor1.red() ); + frameFillColor1Elem.setAttribute( "green", mGridFrameFillColor1.green() ); + frameFillColor1Elem.setAttribute( "blue", mGridFrameFillColor1.blue() ); + frameFillColor1Elem.setAttribute( "alpha", mGridFrameFillColor1.alpha() ); + gridElem.appendChild( frameFillColor1Elem ); + QDomElement frameFillColor2Elem = doc.createElement( "frameFillColor2" ); + frameFillColor2Elem.setAttribute( "red", mGridFrameFillColor2.red() ); + frameFillColor2Elem.setAttribute( "green", mGridFrameFillColor2.green() ); + frameFillColor2Elem.setAttribute( "blue", mGridFrameFillColor2.blue() ); + frameFillColor2Elem.setAttribute( "alpha", mGridFrameFillColor2.alpha() ); + gridElem.appendChild( frameFillColor2Elem ); + gridElem.setAttribute( "gridBlendMode", QgsMapRenderer::getBlendModeEnum( mGridBlendMode ) ); QDomElement gridLineStyleElem = QgsSymbolLayerV2Utils::saveSymbol( QString(), mGridLineSymbol, doc ); gridElem.appendChild( gridLineStyleElem ); @@ -889,6 +913,7 @@ bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc ) const annotationFontColorElem.setAttribute( "red", mGridAnnotationFontColor.red() ); annotationFontColorElem.setAttribute( "green", mGridAnnotationFontColor.green() ); annotationFontColorElem.setAttribute( "blue", mGridAnnotationFontColor.blue() ); + annotationFontColorElem.setAttribute( "alpha", mGridAnnotationFontColor.alpha() ); annotationElem.appendChild( annotationFontColorElem ); gridElem.appendChild( annotationElem ); @@ -1027,6 +1052,54 @@ bool QgsComposerMap::readXML( const QDomElement& itemElem, const QDomDocument& d mCrossLength = gridElem.attribute( "crossLength", "3" ).toDouble(); mGridFrameStyle = ( QgsComposerMap::GridFrameStyle )gridElem.attribute( "gridFrameStyle", "0" ).toInt(); mGridFrameWidth = gridElem.attribute( "gridFrameWidth", "2.0" ).toDouble(); + mGridFramePenThickness = gridElem.attribute( "gridFramePenThickness", "0.5" ).toDouble(); + + //grid frame pen color + QDomNodeList gridFramePenColorList = gridElem.elementsByTagName( "framePenColor" ); + if ( gridFramePenColorList.size() > 0 ) + { + QDomElement penColorElem = gridFramePenColorList.at( 0 ).toElement(); + int red = penColorElem.attribute( "red", "0" ).toInt(); + int green = penColorElem.attribute( "green", "0" ).toInt(); + int blue = penColorElem.attribute( "blue", "0" ).toInt(); + int alpha = penColorElem.attribute( "alpha", "255" ).toInt(); + mGridFramePenColor = QColor( red, green, blue, alpha ); + } + else + { + mGridFramePenColor = QColor( 0, 0, 0 ); + } + //grid frame fill color 1 + QDomNodeList gridFrameFillColor1List = gridElem.elementsByTagName( "frameFillColor1" ); + if ( gridFrameFillColor1List.size() > 0 ) + { + QDomElement fillColorElem = gridFrameFillColor1List.at( 0 ).toElement(); + int red = fillColorElem.attribute( "red", "0" ).toInt(); + int green = fillColorElem.attribute( "green", "0" ).toInt(); + int blue = fillColorElem.attribute( "blue", "0" ).toInt(); + int alpha = fillColorElem.attribute( "alpha", "255" ).toInt(); + mGridFrameFillColor1 = QColor( red, green, blue, alpha ); + } + else + { + mGridFrameFillColor1 = Qt::white; + } + //grid frame fill color 2 + QDomNodeList gridFrameFillColor2List = gridElem.elementsByTagName( "frameFillColor2" ); + if ( gridFrameFillColor2List.size() > 0 ) + { + QDomElement fillColorElem = gridFrameFillColor2List.at( 0 ).toElement(); + int red = fillColorElem.attribute( "red", "0" ).toInt(); + int green = fillColorElem.attribute( "green", "0" ).toInt(); + int blue = fillColorElem.attribute( "blue", "0" ).toInt(); + int alpha = fillColorElem.attribute( "alpha", "255" ).toInt(); + mGridFrameFillColor2 = QColor( red, green, blue, alpha ); + } + else + { + mGridFrameFillColor2 = Qt::black; + } + setGridBlendMode( QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode ) gridElem.attribute( "gridBlendMode", "0" ).toUInt() ) ); QDomElement gridSymbolElem = gridElem.firstChildElement( "symbol" ); @@ -1070,7 +1143,8 @@ bool QgsComposerMap::readXML( const QDomElement& itemElem, const QDomDocument& d int red = fontColorElem.attribute( "red", "0" ).toInt(); int green = fontColorElem.attribute( "green", "0" ).toInt(); int blue = fontColorElem.attribute( "blue", "0" ).toInt(); - mGridAnnotationFontColor = QColor( red, green, blue ); + int alpha = fontColorElem.attribute( "alpha", "255" ).toInt(); + mGridAnnotationFontColor = QColor( red, green, blue, alpha ); } else { @@ -1268,7 +1342,7 @@ void QgsComposerMap::drawGridLine( const QLineF& line, QPainter* p ) void QgsComposerMap::drawGridFrameBorder( QPainter* p, const QMap< double, double >& borderPos, Border border ) { double currentCoord = - mGridFrameWidth; - bool white = true; + bool color1 = true; double x = 0; double y = 0; double width = 0; @@ -1287,10 +1361,15 @@ void QgsComposerMap::drawGridFrameBorder( QPainter* p, const QMap< double, doubl pos.insert( rect().width() + mGridFrameWidth, rect().width() + mGridFrameWidth ); } + //set pen to current frame pen + QPen framePen = QPen( mGridFramePenColor ); + framePen.setWidthF( mGridFramePenThickness ); + p->setPen( framePen ); + QMap< double, double >::const_iterator posIt = pos.constBegin(); for ( ; posIt != pos.constEnd(); ++posIt ) { - p->setBrush( QBrush( white ? Qt::white : Qt::black ) ); + p->setBrush( QBrush( color1 ? mGridFrameFillColor1 : mGridFrameFillColor2 ) ); if ( border == Left || border == Right ) { height = posIt.key() - currentCoord; @@ -1307,7 +1386,7 @@ void QgsComposerMap::drawGridFrameBorder( QPainter* p, const QMap< double, doubl } p->drawRect( QRectF( x, y, width, height ) ); currentCoord = posIt.key(); - white = !white; + color1 = !color1; } } @@ -1347,7 +1426,7 @@ void QgsComposerMap::drawCoordinateAnnotation( QPainter* p, const QPointF& pos, double ypos = pos.y(); int rotation = 0; - double gridFrameDistance = ( mGridFrameStyle == NoGridFrame ) ? 0 : mGridFrameWidth; + double gridFrameDistance = ( mGridFrameStyle == NoGridFrame ) ? 0 : mGridFrameWidth + ( mGridFramePenThickness / 2.0 ); if ( frameBorder == Left ) { @@ -1801,7 +1880,7 @@ double QgsComposerMap::maxExtension() const } //grid frame - double gridFrameDist = ( mGridFrameStyle == NoGridFrame ) ? 0 : mGridFrameWidth; + double gridFrameDist = ( mGridFrameStyle == NoGridFrame ) ? 0 : mGridFrameWidth + ( mGridFramePenThickness / 2.0 ); return maxExtension + mAnnotationFrameDistance + gridFrameDist; } diff --git a/src/core/composer/qgscomposermap.h b/src/core/composer/qgscomposermap.h index 8a8b4a436a2..0c2a63f51c7 100644 --- a/src/core/composer/qgscomposermap.h +++ b/src/core/composer/qgscomposermap.h @@ -287,6 +287,32 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem void setGridFrameWidth( double w ) { mGridFrameWidth = w; } double gridFrameWidth() const { return mGridFrameWidth; } + /**Set grid frame pen thickness + @note: this function was added in version 2.1*/ + void setGridFramePenSize( double w ) { mGridFramePenThickness = w; } + double gridFramePenSize() const { return mGridFramePenThickness; } + + /**Sets pen color for grid frame + @note: this function was added in version 2.1*/ + void setGridFramePenColor( const QColor& c ) { mGridFramePenColor = c;} + /**Get pen color for grid frame + @note: this function was added in version 2.1*/ + QColor gridFramePenColor() const {return mGridFramePenColor;} + + /**Sets first fill color for grid zebra frame + @note: this function was added in version 2.1*/ + void setGridFrameFillColor1( const QColor& c ) { mGridFrameFillColor1 = c;} + /**Get first fill color for grid zebra frame + @note: this function was added in version 2.1*/ + QColor gridFrameFillColor1() const {return mGridFrameFillColor1;} + + /**Sets second fill color for grid zebra frame + @note: this function was added in version 2.1*/ + void setGridFrameFillColor2( const QColor& c ) { mGridFrameFillColor2 = c;} + /**Get second fill color for grid zebra frame + @note: this function was added in version 2.1*/ + QColor gridFrameFillColor2() const {return mGridFrameFillColor2;} + /**In case of annotations, the bounding rectangle can be larger than the map item rectangle @note this function was added in version 1.4*/ QRectF boundingRect() const; @@ -470,6 +496,10 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem GridFrameStyle mGridFrameStyle; double mGridFrameWidth; + double mGridFramePenThickness; + QColor mGridFramePenColor; + QColor mGridFrameFillColor1; + QColor mGridFrameFillColor2; /**Current bounding rectangle. This is used to check if notification to the graphics scene is necessary*/ QRectF mCurrentRectangle; diff --git a/src/ui/qgscomposermapwidgetbase.ui b/src/ui/qgscomposermapwidgetbase.ui index 3f179ae3e1f..229f01849e4 100644 --- a/src/ui/qgscomposermapwidgetbase.ui +++ b/src/ui/qgscomposermapwidgetbase.ui @@ -54,9 +54,9 @@ 0 - -376 + -420 439 - 1439 + 1509 @@ -393,32 +393,6 @@ - - - Frame style - - - false - - - - - - - - - - Frame width - - - false - - - - - - - Line style @@ -428,17 +402,17 @@ - + change... - + - + Blend mode @@ -460,6 +434,88 @@ + + + + Grid frame + + + false + + + false + + + true + + + + + + Frame style + + + false + + + + + + + + + + Frame size + + + false + + + + + + + + + + Frame line thickness + + + + + + + + + + Color... + + + + + + + Frame fill colors + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/core/testqgscomposermap.cpp b/tests/src/core/testqgscomposermap.cpp index 1473cb4f0c5..f316c3e3ece 100644 --- a/tests/src/core/testqgscomposermap.cpp +++ b/tests/src/core/testqgscomposermap.cpp @@ -75,7 +75,7 @@ void TestQgsComposerMap::initTestCase() mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 ); mComposerMap->setFrameEnabled( true ); mComposition->addComposerMap( mComposerMap ); - + mReport = "

Composer Map Tests

\n"; } @@ -84,7 +84,7 @@ void TestQgsComposerMap::cleanupTestCase() delete mComposition; delete mMapRenderer; delete mRasterLayer; - + QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) @@ -92,7 +92,7 @@ void TestQgsComposerMap::cleanupTestCase() QTextStream myQTextStream( &myFile ); myQTextStream << mReport; myFile.close(); - } + } } void TestQgsComposerMap::init() @@ -108,7 +108,7 @@ void TestQgsComposerMap::render() { mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) ); QgsCompositionChecker checker( "composermap_render", mComposition ); - + QVERIFY( checker.testComposition( mReport ) ); } @@ -132,8 +132,8 @@ void TestQgsComposerMap::grid() mComposerMap->setGridBlendMode( QPainter::CompositionMode_Overlay ); qWarning() << "grid annotation font: " << mComposerMap->gridAnnotationFont().toString() << " exactMatch:" << mComposerMap->gridAnnotationFont().exactMatch(); QgsCompositionChecker checker( "composermap_grid", mComposition ); - - bool testResult = checker.testComposition( mReport); + + bool testResult = checker.testComposition( mReport ); mComposerMap->setGridEnabled( false ); mComposerMap->setShowGridAnnotation( false ); QVERIFY( testResult ); @@ -148,8 +148,8 @@ void TestQgsComposerMap::overviewMap() overviewMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) ); overviewMap->setOverviewFrameMap( mComposerMap->id() ); QgsCompositionChecker checker( "composermap_overview", mComposition ); - - bool testResult = checker.testComposition( mReport); + + bool testResult = checker.testComposition( mReport ); mComposition->removeComposerItem( overviewMap ); QVERIFY( testResult ); } @@ -165,8 +165,8 @@ void TestQgsComposerMap::overviewMapBlending() overviewMapBlend->setOverviewBlendMode( QPainter::CompositionMode_Multiply ); QgsCompositionChecker checker( "composermap_overview_blending", mComposition ); - - bool testResult = checker.testComposition( mReport); + + bool testResult = checker.testComposition( mReport ); mComposition->removeComposerItem( overviewMapBlend ); QVERIFY( testResult ); } @@ -182,8 +182,8 @@ void TestQgsComposerMap::overviewMapInvert() overviewMapInvert->setOverviewInverted( true ); QgsCompositionChecker checker( "composermap_overview_invert", mComposition ); - - bool testResult = checker.testComposition( mReport); + + bool testResult = checker.testComposition( mReport ); mComposition->removeComposerItem( overviewMapInvert ); QVERIFY( testResult ); } @@ -222,11 +222,16 @@ void TestQgsComposerMap::zebraStyle() mComposerMap->setGridBlendMode( QPainter::CompositionMode_SourceOver ); mComposerMap->setGridFrameStyle( QgsComposerMap::Zebra ); + mComposerMap->setGridFrameWidth( 10 ); + mComposerMap->setGridFramePenSize( 1 ); + mComposerMap->setGridFramePenColor( QColor( 255, 100, 0, 200 ) ); + mComposerMap->setGridFrameFillColor1( QColor( 50, 90, 50, 100 ) ); + mComposerMap->setGridFrameFillColor2( QColor( 200, 220, 100, 60 ) ); mComposerMap->setGridEnabled( true ); QgsCompositionChecker checker( "composermap_zebrastyle", mComposition ); - - bool testResult = checker.testComposition( mReport); + + bool testResult = checker.testComposition( mReport ); QVERIFY( testResult ); } @@ -242,8 +247,8 @@ void TestQgsComposerMap::overviewMapCenter() overviewMapCenter->setOverviewCentered( true ); QgsCompositionChecker checker( "composermap_overview_center", mComposition ); - - bool testResult = checker.testComposition( mReport); + + bool testResult = checker.testComposition( mReport ); mComposition->removeComposerItem( overviewMapCenter ); QVERIFY( testResult ); } diff --git a/tests/testdata/control_images/expected_composermap_zebrastyle/expected_composermap_zebrastyle.png b/tests/testdata/control_images/expected_composermap_zebrastyle/expected_composermap_zebrastyle.png index 088411ec3a3..8f3de94002d 100644 Binary files a/tests/testdata/control_images/expected_composermap_zebrastyle/expected_composermap_zebrastyle.png and b/tests/testdata/control_images/expected_composermap_zebrastyle/expected_composermap_zebrastyle.png differ