Index: src/core/symbology-ng/qgsmarkersymbollayerv2.cpp =================================================================== --- src/core/symbology-ng/qgsmarkersymbollayerv2.cpp (revision 15861) +++ src/core/symbology-ng/qgsmarkersymbollayerv2.cpp (working copy) @@ -31,13 +31,14 @@ ////// -QgsSimpleMarkerSymbolLayerV2::QgsSimpleMarkerSymbolLayerV2( QString name, QColor color, QColor borderColor, double size, double angle ) +QgsSimpleMarkerSymbolLayerV2::QgsSimpleMarkerSymbolLayerV2( QString name, QColor color, Qt::BrushStyle style, QColor borderColor, double size, double angle ) { mName = name; mColor = color; mBorderColor = borderColor; mSize = size; mAngle = angle; + mBrushStyle = style; mOffset = QPointF( 0, 0 ); } @@ -45,6 +46,7 @@ { QString name = DEFAULT_SIMPLEMARKER_NAME; QColor color = DEFAULT_SIMPLEMARKER_COLOR; + Qt::BrushStyle style = DEFAULT_SIMPLEMARKER_STYLE; QColor borderColor = DEFAULT_SIMPLEMARKER_BORDERCOLOR; double size = DEFAULT_SIMPLEMARKER_SIZE; double angle = DEFAULT_SIMPLEMARKER_ANGLE; @@ -53,6 +55,8 @@ name = props["name"]; if ( props.contains( "color" ) ) color = QgsSymbolLayerV2Utils::decodeColor( props["color"] ); + if ( props.contains( "style" ) ) + style = QgsSymbolLayerV2Utils::decodeBrushStyle( props["style"] ); if ( props.contains( "color_border" ) ) borderColor = QgsSymbolLayerV2Utils::decodeColor( props["color_border"] ); if ( props.contains( "size" ) ) @@ -60,7 +64,7 @@ if ( props.contains( "angle" ) ) angle = props["angle"].toDouble(); - QgsSimpleMarkerSymbolLayerV2* m = new QgsSimpleMarkerSymbolLayerV2( name, color, borderColor, size, angle ); + QgsSimpleMarkerSymbolLayerV2* m = new QgsSimpleMarkerSymbolLayerV2( name, color, style, borderColor, size, angle ); if ( props.contains( "offset" ) ) m->setOffset( QgsSymbolLayerV2Utils::decodePoint( props["offset"] ) ); return m; @@ -76,26 +80,49 @@ { QColor brushColor = mColor; QColor penColor = mBorderColor; +// Alister - I don't know that the following line is needed anymore. What does it do? + QColor selColor = context.selectionColor(); + QColor selBrushColor = context.selectionColor(); +// Alister - I don't understand the reasoning for the following line +// QColor selPenColor = selBrushColor == mColor ? selBrushColor : mBorderColor; +// I think it is a mistake and should be this + QColor selPenColor = mBorderColor == mColor ? selBrushColor : mBorderColor ; +// N.B. this isn't consistent with polygon symbology, which I think should be changed +// to match this. (But perhaps it is desirable for the borders of selected polygons +// to be visible even if they are invisible when unselected, so that you can +// distinguish between adjacent polygons if you select more than one). +// Or maybe the following would be desirable? (No, I don't think so) +// QColor selPenColor = selBrushColor == mBorderColor ? mColor : mBorderColor ; + if ( context.alpha() < 1 ) { + brushColor.setAlphaF( context.alpha() ); penColor.setAlphaF( context.alpha() ); - brushColor.setAlphaF( context.alpha() ); - } - mBrush = QBrush( brushColor ); - mPen = QPen( penColor ); - mPen.setWidthF( context.outputLineWidth( mPen.widthF() ) ); - - QColor selBrushColor = context.selectionColor(); - QColor selPenColor = selBrushColor == mColor ? selBrushColor : mBorderColor; - if ( context.alpha() < 1 ) - { +// Alister - I don't know that the following line is needed anymore. What does it do? + selColor.setAlphaF( context.alpha() ); +// Alister - This isn't consistent with polygon symbology. If we apply transparency +// to selected point symbols we should also apply it to selected polygons. selBrushColor.setAlphaF( context.alpha() ); selPenColor.setAlphaF( context.alpha() ); } - mSelBrush = QBrush( selBrushColor ); + + mBrush = QBrush( brushColor, mBrushStyle ); + mPen = QPen( penColor ); +// mSelBrush = QBrush( selBrushColor ); +// Alister - the following method mostly works, but applying the fill style to selected +// objects isn't consistent with polygon symbology. If we do this we should probably +// make polygon symbology work in the same way. +// The only bug is that "no fill" doesn't work if brushColor = penColor +// e.g. if the symbol is a circle, the whole bounding box (is that what it's called?) +// of the circle is filled. + mSelBrush = QBrush( selBrushColor, mBrushStyle ); mSelPen = QPen( selPenColor ); + mPen.setWidthF( context.outputLineWidth( mPen.widthF() ) ); mSelPen.setWidthF( context.outputLineWidth( mPen.widthF() ) ); +// Alister - this method doesn't seem to work; +// if ( selectFillStyle ) mSelBrush.setStyle( mBrushStyle ); + bool hasDataDefinedRotation = context.renderHints() & QgsSymbolV2::DataDefinedRotation; bool hasDataDefinedSize = context.renderHints() & QgsSymbolV2::DataDefinedSizeScale; @@ -410,6 +437,7 @@ QgsStringMap map; map["name"] = mName; map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor ); + map["style"] = QgsSymbolLayerV2Utils::encodeBrushStyle( mBrushStyle ); map["color_border"] = QgsSymbolLayerV2Utils::encodeColor( mBorderColor ); map["size"] = QString::number( mSize ); map["angle"] = QString::number( mAngle ); @@ -419,7 +447,7 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::clone() const { - QgsSimpleMarkerSymbolLayerV2* m = new QgsSimpleMarkerSymbolLayerV2( mName, mColor, mBorderColor, mSize, mAngle ); + QgsSimpleMarkerSymbolLayerV2* m = new QgsSimpleMarkerSymbolLayerV2( mName, mColor, mBrushStyle, mBorderColor, mSize, mAngle ); m->setOffset( mOffset ); return m; } Index: src/core/symbology-ng/qgsmarkersymbollayerv2.h =================================================================== --- src/core/symbology-ng/qgsmarkersymbollayerv2.h (revision 15861) +++ src/core/symbology-ng/qgsmarkersymbollayerv2.h (working copy) @@ -6,6 +6,7 @@ #define DEFAULT_SIMPLEMARKER_NAME "circle" #define DEFAULT_SIMPLEMARKER_COLOR QColor(255,0,0) +#define DEFAULT_SIMPLEMARKER_STYLE Qt::SolidPattern #define DEFAULT_SIMPLEMARKER_BORDERCOLOR QColor(0,0,0) #define DEFAULT_SIMPLEMARKER_SIZE DEFAULT_POINT_SIZE #define DEFAULT_SIMPLEMARKER_ANGLE 0 @@ -21,6 +22,7 @@ public: QgsSimpleMarkerSymbolLayerV2( QString name = DEFAULT_SIMPLEMARKER_NAME, QColor color = DEFAULT_SIMPLEMARKER_COLOR, + Qt::BrushStyle style = DEFAULT_SIMPLEMARKER_STYLE, QColor borderColor = DEFAULT_SIMPLEMARKER_BORDERCOLOR, double size = DEFAULT_SIMPLEMARKER_SIZE, double angle = DEFAULT_SIMPLEMARKER_ANGLE ); @@ -42,6 +44,9 @@ QgsStringMap properties() const; QgsSymbolLayerV2* clone() const; + + Qt::BrushStyle brushStyle() const { return mBrushStyle; } + void setBrushStyle( Qt::BrushStyle style ) { mBrushStyle = style; } QString name() const { return mName; } void setName( QString name ) { mName = name; } @@ -64,6 +69,7 @@ QPolygonF mPolygon; QPainterPath mPath; QString mName; + Qt::BrushStyle mBrushStyle; QImage mCache; QPen mSelPen; QBrush mSelBrush; Index: src/core/symbology-ng/qgssymbologyv2conversion.cpp =================================================================== --- src/core/symbology-ng/qgssymbologyv2conversion.cpp (revision 15861) +++ src/core/symbology-ng/qgssymbologyv2conversion.cpp (working copy) @@ -32,7 +32,8 @@ QColor color = s->fillColor(); QColor borderColor = s->color(); QString name = symbolName.mid( 5 ); - sl = new QgsSimpleMarkerSymbolLayerV2( name, color, borderColor, size, angle ); + Qt::BrushStyle brushStyle = s->brush().style(); + sl = new QgsSimpleMarkerSymbolLayerV2( name, color, brushStyle, borderColor, size, angle ); } else { Index: src/gui/symbology-ng/qgssymbollayerv2widget.cpp =================================================================== --- src/gui/symbology-ng/qgssymbollayerv2widget.cpp (revision 15861) +++ src/gui/symbology-ng/qgssymbollayerv2widget.cpp (working copy) @@ -168,9 +168,10 @@ names << "circle" << "rectangle" << "diamond" << "pentagon" << "cross" << "cross2" << "triangle" << "equilateral_triangle" << "star" << "regular_star" << "arrow" << "line" << "arrowhead" << "filled_arrowhead"; double markerSize = DEFAULT_POINT_SIZE * 2; + Qt::BrushStyle brushStyle = DEFAULT_SIMPLEFILL_STYLE ; for ( int i = 0; i < names.count(); ++i ) { - QgsSimpleMarkerSymbolLayerV2* lyr = new QgsSimpleMarkerSymbolLayerV2( names[i], QColor( 200, 200, 200 ), QColor( 0, 0, 0 ), markerSize ); + QgsSimpleMarkerSymbolLayerV2* lyr = new QgsSimpleMarkerSymbolLayerV2( names[i], QColor( 200, 200, 200 ),brushStyle, QColor( 0, 0, 0 ), markerSize ); QIcon icon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( lyr, QgsSymbolV2::MM, size ); QListWidgetItem* item = new QListWidgetItem( icon, QString(), lstNames ); item->setData( Qt::UserRole, names[i] ); @@ -180,8 +181,9 @@ connect( lstNames, SIGNAL( currentRowChanged( int ) ), this, SLOT( setName() ) ); connect( btnChangeColorBorder, SIGNAL( clicked() ), this, SLOT( setColorBorder() ) ); connect( btnChangeColorFill, SIGNAL( clicked() ), this, SLOT( setColorFill() ) ); + connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) ); connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) ); - connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) ); + connect( cboFillStyleMarker,SIGNAL( currentIndexChanged( int ) ), this, SLOT( setBrushStyle() )) ; connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) ); connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) ); } @@ -208,6 +210,7 @@ btnChangeColorFill->setColor( mLayer->color() ); spinSize->setValue( mLayer->size() ); spinAngle->setValue( mLayer->angle() ); + cboFillStyleMarker->setBrushStyle( mLayer->brushStyle() ); // without blocking signals the value gets changed because of slot setOffset() spinOffsetX->blockSignals( true ); @@ -259,6 +262,12 @@ emit changed(); } +void QgsSimpleMarkerSymbolLayerV2Widget::setBrushStyle() +{ + mLayer->setBrushStyle( cboFillStyleMarker->brushStyle() ); + emit changed(); +} + void QgsSimpleMarkerSymbolLayerV2Widget::setSize() { mLayer->setSize( spinSize->value() ); Index: src/gui/symbology-ng/qgssymbollayerv2widget.h =================================================================== --- src/gui/symbology-ng/qgssymbollayerv2widget.h (revision 15861) +++ src/gui/symbology-ng/qgssymbollayerv2widget.h (working copy) @@ -4,6 +4,7 @@ #include +#define DEFAULT_SIMPLEFILL_STYLE Qt::SolidPattern class QgsSymbolLayerV2; @@ -80,6 +81,7 @@ void setName(); void setColorBorder(); void setColorFill(); + void setBrushStyle(); void setSize(); void setAngle(); void setOffset(); Index: src/ui/symbollayer/widget_simplemarker.ui =================================================================== --- src/ui/symbollayer/widget_simplemarker.ui (revision 15861) +++ src/ui/symbollayer/widget_simplemarker.ui (working copy) @@ -7,7 +7,7 @@ 0 0 394 - 275 + 305 @@ -60,21 +60,21 @@ - + Size - + Angle - + 1 @@ -87,14 +87,14 @@ - + Offset X,Y - + @@ -118,7 +118,7 @@ - + 2 @@ -131,6 +131,16 @@ + + + + Fill Style + + + + + + @@ -156,9 +166,6 @@ QListView::LeftToRight - - QListView::Adjust - 4 @@ -196,6 +203,11 @@ + Q3ComboBox + QWidget +
Qt3Support/Q3ComboBox
+
+ QgsColorButtonV2 QPushButton
qgscolorbutton.h