Skip to content
Permalink
Browse files

[FEATURE] symbology-ng: possibility to offset for simple fill.

git-svn-id: http://svn.osgeo.org/qgis/trunk@13408 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Apr 29, 2010
1 parent 085d72f commit a1d5dcd133e1dda80d94ccc8993b75f981acba64
@@ -22,6 +22,7 @@ QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::create( const QgsStringMap& props
QColor borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR;
Qt::PenStyle borderStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE;
double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH;
QPointF offset;

if ( props.contains( "color" ) )
color = QgsSymbolLayerV2Utils::decodeColor( props["color"] );
@@ -33,8 +34,12 @@ QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::create( const QgsStringMap& props
borderStyle = QgsSymbolLayerV2Utils::decodePenStyle( props["style_border"] );
if ( props.contains( "width_border" ) )
borderWidth = props["width_border"].toDouble();
if ( props.contains( "offset" ) )
offset = QgsSymbolLayerV2Utils::decodePoint( props["offset"] );

return new QgsSimpleFillSymbolLayerV2( color, style, borderColor, borderStyle, borderWidth );
QgsSimpleFillSymbolLayerV2* sl = new QgsSimpleFillSymbolLayerV2( color, style, borderColor, borderStyle, borderWidth );
sl->setOffset( offset );
return sl;
}


@@ -72,7 +77,13 @@ void QgsSimpleFillSymbolLayerV2::renderPolygon( const QPolygonF& points, QList<Q
p->setBrush( context.selected() ? mSelBrush : mBrush );
p->setPen( mPen );

if ( !mOffset.isNull() )
p->translate( mOffset );

_renderPolygon( p, points, rings );

if ( !mOffset.isNull() )
p->translate( -mOffset );
}

QgsStringMap QgsSimpleFillSymbolLayerV2::properties() const
@@ -83,12 +94,15 @@ QgsStringMap QgsSimpleFillSymbolLayerV2::properties() const
map["color_border"] = QgsSymbolLayerV2Utils::encodeColor( mBorderColor );
map["style_border"] = QgsSymbolLayerV2Utils::encodePenStyle( mBorderStyle );
map["width_border"] = QString::number( mBorderWidth );
map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset );
return map;
}

QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::clone() const
{
return new QgsSimpleFillSymbolLayerV2( mColor, mBrushStyle, mBorderColor, mBorderStyle, mBorderWidth );
QgsSimpleFillSymbolLayerV2* sl = new QgsSimpleFillSymbolLayerV2( mColor, mBrushStyle, mBorderColor, mBorderStyle, mBorderWidth );
sl->setOffset( mOffset );
return sl;
}

//QgsSVGFillSymbolLayer
@@ -52,6 +52,9 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2
double borderWidth() const { return mBorderWidth; }
void setBorderWidth( double borderWidth ) { mBorderWidth = borderWidth; }

void setOffset( QPointF offset ) { mOffset = offset; }
QPointF offset() { return mOffset; }

protected:
QBrush mBrush;
QBrush mSelBrush;
@@ -60,6 +63,8 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2
Qt::PenStyle mBorderStyle;
double mBorderWidth;
QPen mPen;

QPointF mOffset;
};

/**A class for svg fill patterns. The class automatically scales the pattern to
@@ -271,6 +271,8 @@ QgsSimpleFillSymbolLayerV2Widget::QgsSimpleFillSymbolLayerV2Widget( QWidget* par
connect( btnChangeBorderColor, SIGNAL( clicked() ), this, SLOT( setBorderColor() ) );
connect( spinBorderWidth, SIGNAL( valueChanged( double ) ), this, SLOT( borderWidthChanged() ) );
connect( cboBorderStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
}

void QgsSimpleFillSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
@@ -287,6 +289,8 @@ void QgsSimpleFillSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
btnChangeBorderColor->setColor( mLayer->borderColor() );
cboBorderStyle->setPenStyle( mLayer->borderStyle() );
spinBorderWidth->setValue( mLayer->borderWidth() );
spinOffsetX->setValue( mLayer->offset().x() );
spinOffsetY->setValue( mLayer->offset().y() );
}

QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2Widget::symbolLayer()
@@ -332,6 +336,12 @@ void QgsSimpleFillSymbolLayerV2Widget::borderStyleChanged()
emit changed();
}

void QgsSimpleFillSymbolLayerV2Widget::offsetChanged()
{
mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
emit changed();
}

///////////

QgsMarkerLineSymbolLayerV2Widget::QgsMarkerLineSymbolLayerV2Widget( QWidget* parent )
@@ -113,6 +113,7 @@ class GUI_EXPORT QgsSimpleFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widge
void setBrushStyle();
void borderWidthChanged();
void borderStyleChanged();
void offsetChanged();

protected:
QgsSimpleFillSymbolLayerV2* mLayer;
@@ -13,9 +13,9 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
@@ -30,7 +30,7 @@
</property>
</widget>
</item>
<item row="0" column="2" rowspan="5">
<item row="0" column="2" rowspan="6">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -40,12 +40,22 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>91</width>
<height>51</height>
<width>28</width>
<height>158</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Fill style:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QgsBrushStyleComboBox" name="cboFillStyle"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
@@ -60,16 +70,6 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QgsBrushStyleComboBox" name="cboFillStyle"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Fill style:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
@@ -97,6 +97,37 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Offset X,Y:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QDoubleSpinBox" name="spinOffsetX">
<property name="minimum">
<double>-999.000000000000000</double>
</property>
<property name="maximum">
<double>999.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinOffsetY">
<property name="minimum">
<double>-999.000000000000000</double>
</property>
<property name="maximum">
<double>999.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>

0 comments on commit a1d5dcd

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