Skip to content

Commit

Permalink
#9254: QgsEllipseSymbolLayerV2 use OutlineStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuarte47 committed Jan 2, 2014
1 parent 9ef3f86 commit 0625c79
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 13 deletions.
9 changes: 8 additions & 1 deletion src/core/symbology-ng/qgsellipsesymbollayerv2.cpp
Expand Up @@ -26,9 +26,10 @@
#include <QDomElement>

QgsEllipseSymbolLayerV2::QgsEllipseSymbolLayerV2(): mSymbolName( "circle" ), mSymbolWidth( 4 ), mSymbolWidthUnit( QgsSymbolV2::MM ), mSymbolHeight( 3 ),
mSymbolHeightUnit( QgsSymbolV2::MM ), mFillColor( Qt::white ), mOutlineColor( Qt::black ), mOutlineWidth( 0 ), mOutlineWidthUnit( QgsSymbolV2::MM )
mSymbolHeightUnit( QgsSymbolV2::MM ), mFillColor( Qt::white ), mOutlineColor( Qt::black ), mOutlineStyle( Qt::SolidLine ), mOutlineWidth( 0 ), mOutlineWidthUnit( QgsSymbolV2::MM )
{
mPen.setColor( mOutlineColor );
mPen.setStyle( mOutlineStyle );
mPen.setWidth( 1.0 );
mPen.setJoinStyle( Qt::MiterJoin );
mBrush.setColor( mFillColor );
Expand Down Expand Up @@ -69,6 +70,10 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& propertie
{
layer->setAngle( properties["angle"].toDouble() );
}
if ( properties.contains( "outline_style" ) )
{
layer->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( properties["outline_style"] ) );
}
if ( properties.contains( "outline_width" ) )
{
layer->setOutlineWidth( properties["outline_width"].toDouble() );
Expand Down Expand Up @@ -262,6 +267,7 @@ void QgsEllipseSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
preparePath( mSymbolName, context );
}
mPen.setColor( mOutlineColor );
mPen.setStyle( mOutlineStyle );
mPen.setWidthF( mOutlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOutlineWidthUnit ) );
mBrush.setColor( mFillColor );
prepareExpressions( context.layer(), context.renderContext().rendererScale() );
Expand Down Expand Up @@ -396,6 +402,7 @@ QgsStringMap QgsEllipseSymbolLayerV2::properties() const
map["symbol_height"] = QString::number( mSymbolHeight );
map["symbol_height_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSymbolHeightUnit );
map["angle"] = QString::number( mAngle );
map["outline_style"] = QgsSymbolLayerV2Utils::encodePenStyle( mOutlineStyle );
map["outline_width"] = QString::number( mOutlineWidth );
map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit );
map["fill_color"] = QgsSymbolLayerV2Utils::encodeColor( mFillColor );
Expand Down
4 changes: 4 additions & 0 deletions src/core/symbology-ng/qgsellipsesymbollayerv2.h
Expand Up @@ -51,6 +51,9 @@ class CORE_EXPORT QgsEllipseSymbolLayerV2: public QgsMarkerSymbolLayerV2
void setSymbolHeight( double h ) { mSymbolHeight = h; }
double symbolHeight() const { return mSymbolHeight; }

Qt::PenStyle outlineStyle() const { return mOutlineStyle; }
void setOutlineStyle( Qt::PenStyle outlineStyle ) { mOutlineStyle = outlineStyle; }

void setOutlineWidth( double w ) { mOutlineWidth = w; }
double outlineWidth() const { return mOutlineWidth; }

Expand Down Expand Up @@ -80,6 +83,7 @@ class CORE_EXPORT QgsEllipseSymbolLayerV2: public QgsMarkerSymbolLayerV2
QgsSymbolV2::OutputUnit mSymbolHeightUnit;
QColor mFillColor;
QColor mOutlineColor;
Qt::PenStyle mOutlineStyle;
double mOutlineWidth;
QgsSymbolV2::OutputUnit mOutlineWidthUnit;

Expand Down
12 changes: 10 additions & 2 deletions src/gui/symbology-ng/qgsellipsesymbollayerv2widget.cpp
Expand Up @@ -57,6 +57,7 @@ void QgsEllipseSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
mWidthSpinBox->setValue( mLayer->symbolWidth() );
mHeightSpinBox->setValue( mLayer->symbolHeight() );
mRotationSpinBox->setValue( mLayer->angle() );
mOutlineStyleComboBox->setPenStyle( mLayer->outlineStyle() );
mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() );

btnChangeColorBorder->setColor( mLayer->outlineColor() );
Expand Down Expand Up @@ -132,6 +133,15 @@ void QgsEllipseSymbolLayerV2Widget::on_mRotationSpinBox_valueChanged( double d )
}
}

void QgsEllipseSymbolLayerV2Widget::on_mOutlineStyleComboBox_currentIndexChanged( int index )
{
if ( mLayer )
{
mLayer->setOutlineStyle( mOutlineStyleComboBox->penStyle() );
emit changed();
}
}

void QgsEllipseSymbolLayerV2Widget::on_mOutlineWidthSpinBox_valueChanged( double d )
{
if ( mLayer )
Expand Down Expand Up @@ -278,5 +288,3 @@ void QgsEllipseSymbolLayerV2Widget::setOffset()
mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
emit changed();
}


1 change: 1 addition & 0 deletions src/gui/symbology-ng/qgsellipsesymbollayerv2widget.h
Expand Up @@ -44,6 +44,7 @@ class GUI_EXPORT QgsEllipseSymbolLayerV2Widget: public QgsSymbolLayerV2Widget, p
void on_mWidthSpinBox_valueChanged( double d );
void on_mHeightSpinBox_valueChanged( double d );
void on_mRotationSpinBox_valueChanged( double d );
void on_mOutlineStyleComboBox_currentIndexChanged( int index );
void on_mOutlineWidthSpinBox_valueChanged( double d );
void on_btnChangeColorBorder_colorChanged( const QColor& newColor );
void on_btnChangeColorFill_colorChanged( const QColor& newColor );
Expand Down
30 changes: 20 additions & 10 deletions src/ui/symbollayer/widget_ellipse.ui
Expand Up @@ -23,7 +23,7 @@
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="mRotationSpinBox">
<property name="minimum">
<double>-360.000000000000000</double>
Expand All @@ -33,14 +33,14 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="mSymbolHeightLabel">
<property name="text">
<string>Symbol height</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="mRotationLabel">
<property name="text">
<string>Rotation</string>
Expand Down Expand Up @@ -128,7 +128,7 @@
</item>
</layout>
</item>
<item row="4" column="1">
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QDoubleSpinBox" name="mHeightSpinBox">
Expand Down Expand Up @@ -209,7 +209,7 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QComboBox" name="mHorizontalAnchorComboBox">
Expand Down Expand Up @@ -251,7 +251,17 @@
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mOutlineStyleLabel">
<property name="text">
<string>Outline style</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QgsPenStyleComboBox" name="mOutlineStyleComboBox"/>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QDoubleSpinBox" name="mOutlineWidthSpinBox">
Expand Down Expand Up @@ -285,28 +295,28 @@
</item>
</layout>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="mOutlineWidthLabel">
<property name="text">
<string>Outline width</string>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="mAnchorPointLabel">
<property name="text">
<string>Anchor point</string>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Offset X,Y</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QDoubleSpinBox" name="spinOffsetX">
Expand Down Expand Up @@ -356,7 +366,7 @@
</item>
</layout>
</item>
<item row="7" column="0" colspan="2">
<item row="8" column="0" colspan="2">
<widget class="QPushButton" name="mDataDefinedPropertiesButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
Expand Down

0 comments on commit 0625c79

Please sign in to comment.