Skip to content
Permalink
Browse files

Make outline only simple markers work with categorised/graduated

etc renderers (fix #15132)
  • Loading branch information
nyalldawson committed Jun 26, 2016
1 parent 972fc9f commit 9f0ae9b4084eaec65635ee5d9d1574b55ee0100d
@@ -220,6 +220,8 @@ class QgsSimpleMarkerSymbolLayerV2 : QgsSimpleMarkerSymbolLayerBase
void setOutlineColor( const QColor& color );
QColor fillColor() const;
void setFillColor( const QColor& color );
void setColor( const QColor& color );
virtual QColor color() const;

// new methods

@@ -1516,6 +1516,32 @@ QRectF QgsSimpleMarkerSymbolLayerV2::bounds( QPointF point, QgsSymbolV2RenderCon
return symbolBounds;
}

void QgsSimpleMarkerSymbolLayerV2::setColor( const QColor& color )
{
if ( shapeIsFilled( mShape ) )
{
setFillColor( color );
}
else
{
setOutlineColor( color );
}
}

QColor QgsSimpleMarkerSymbolLayerV2::color() const
{
if ( shapeIsFilled( mShape ) )
{
return fillColor();
}
else
{
return outlineColor();
}
}




//
// QgsFilledMarkerSymbolLayer
@@ -257,8 +257,10 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsSimpleMarkerSymbolLay
QRectF bounds( QPointF point, QgsSymbolV2RenderContext& context ) override;
QColor outlineColor() const override { return borderColor(); }
void setOutlineColor( const QColor& color ) override { setBorderColor( color ); }
QColor fillColor() const override { return color(); }
void setFillColor( const QColor& color ) override { setColor( color ); }
QColor fillColor() const override { return mColor; }
void setFillColor( const QColor& color ) override { mColor = color; }
void setColor( const QColor& color ) override;
virtual QColor color() const override;

// new methods

@@ -493,7 +493,7 @@ void QgsSimpleMarkerSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer
btnChangeColorBorder->setColor( mLayer->borderColor() );
btnChangeColorBorder->blockSignals( false );
btnChangeColorFill->blockSignals( true );
btnChangeColorFill->setColor( mLayer->color() );
btnChangeColorFill->setColor( mLayer->fillColor() );
btnChangeColorFill->blockSignals( false );
spinSize->blockSignals( true );
spinSize->setValue( mLayer->size() );
@@ -66,6 +66,7 @@ class TestQgsSimpleMarkerSymbol : public QObject
void boundsWithOffset();
void boundsWithRotation();
void boundsWithRotationAndOffset();
void colors();

private:
bool mTestHasError;
@@ -251,6 +252,27 @@ void TestQgsSimpleMarkerSymbol::boundsWithRotationAndOffset()
QVERIFY( result );
}

void TestQgsSimpleMarkerSymbol::colors()
{
//test logic for setting/retrieving symbol color

QgsSimpleMarkerSymbolLayerV2 marker;
marker.setOutlineColor( QColor( 200, 200, 200 ) );
marker.setFillColor( QColor( 100, 100, 100 ) );

//start with a filled shape - color should be fill color
marker.setShape( QgsSimpleMarkerSymbolLayerBase::Circle );
QCOMPARE( marker.color(), QColor( 100, 100, 100 ) );
marker.setColor( QColor( 150, 150, 150 ) );
QCOMPARE( marker.fillColor(), QColor( 150, 150, 150 ) );

//now try with a non-filled (outline only) shape - color should be outline color
marker.setShape( QgsSimpleMarkerSymbolLayerBase::Cross );
QCOMPARE( marker.color(), QColor( 200, 200, 200 ) );
marker.setColor( QColor( 250, 250, 250 ) );
QCOMPARE( marker.outlineColor(), QColor( 250, 250, 250 ) );
}

//
// Private helper functions not called directly by CTest
//

0 comments on commit 9f0ae9b

Please sign in to comment.
You can’t perform that action at this time.