Skip to content
Permalink
Browse files

#9254: QgsSimpleMarkerSymbolLayerV2 use OutlineStyle

  • Loading branch information
ahuarte47 committed Jan 2, 2014
1 parent 0625c79 commit 8a1d769d288ba1c43f42bcf3e61527734ce6d820
@@ -35,7 +35,7 @@
//////

QgsSimpleMarkerSymbolLayerV2::QgsSimpleMarkerSymbolLayerV2( QString name, QColor color, QColor borderColor, double size, double angle, QgsSymbolV2::ScaleMethod scaleMethod )
: mOutlineWidth( 0 ), mOutlineWidthUnit( QgsSymbolV2::MM )
: mOutlineStyle( Qt::SolidLine ), mOutlineWidth( 0 ), mOutlineWidthUnit( QgsSymbolV2::MM )
{
mName = name;
mColor = color;
@@ -80,6 +80,10 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::create( const QgsStringMap& prop
if ( props.contains( "size_unit" ) )
m->setSizeUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["size_unit"] ) );

if ( props.contains( "outline_style" ) )
{
m->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( props["outline_style"] ) );
}
if ( props.contains( "outline_width" ) )
{
m->setOutlineWidth( props["outline_width"].toDouble() );
@@ -154,6 +158,7 @@ void QgsSimpleMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& contex

mBrush = QBrush( brushColor );
mPen = QPen( penColor );
mPen.setStyle( mOutlineStyle );
mPen.setWidthF( mOutlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOutlineWidthUnit ) );

QColor selBrushColor = context.renderContext().selectionColor();
@@ -165,6 +170,7 @@ void QgsSimpleMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& contex
}
mSelBrush = QBrush( selBrushColor );
mSelPen = QPen( selPenColor );
mSelPen.setStyle( mOutlineStyle );
mSelPen.setWidthF( mOutlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOutlineWidthUnit ) );

bool hasDataDefinedRotation = context.renderHints() & QgsSymbolV2::DataDefinedRotation || dataDefinedProperty( "angle" );
@@ -567,6 +573,7 @@ QgsStringMap QgsSimpleMarkerSymbolLayerV2::properties() const
map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset );
map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit );
map["scale_method"] = QgsSymbolLayerV2Utils::encodeScaleMethod( mScaleMethod );
map["outline_style"] = QgsSymbolLayerV2Utils::encodePenStyle( mOutlineStyle );
map["outline_width"] = QString::number( mOutlineWidth );
map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit );
map["horizontal_anchor_point"] = QString::number( mHorizontalAnchorPoint );
@@ -583,6 +590,7 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::clone() const
m->setOffset( mOffset );
m->setSizeUnit( mSizeUnit );
m->setOffsetUnit( mOffsetUnit );
m->setOutlineStyle( mOutlineStyle );
m->setOutlineWidth( mOutlineWidth );
m->setOutlineWidthUnit( mOutlineWidthUnit );
m->setHorizontalAnchorPoint( mHorizontalAnchorPoint );
@@ -70,6 +70,9 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
QColor borderColor() const { return mBorderColor; }
void setBorderColor( QColor color ) { mBorderColor = color; }

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

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

@@ -90,6 +93,7 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
bool prepareCache( QgsSymbolV2RenderContext& context );

QColor mBorderColor;
Qt::PenStyle mOutlineStyle;
double mOutlineWidth;
QgsSymbolV2::OutputUnit mOutlineWidthUnit;
QPen mPen;
@@ -301,6 +301,7 @@ void QgsSimpleMarkerSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer
btnChangeColorFill->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
spinSize->setValue( mLayer->size() );
spinAngle->setValue( mLayer->angle() );
mOutlineStyleComboBox->setPenStyle( mLayer->outlineStyle() );
mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() );

// without blocking signals the value gets changed because of slot setOffset()
@@ -371,6 +372,15 @@ void QgsSimpleMarkerSymbolLayerV2Widget::setOffset()
emit changed();
}

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

void QgsSimpleMarkerSymbolLayerV2Widget::on_mOutlineWidthSpinBox_valueChanged( double d )
{
if ( mLayer )
@@ -109,6 +109,7 @@ class GUI_EXPORT QgsSimpleMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Wid
void on_mOffsetUnitComboBox_currentIndexChanged( int index );
void on_mOutlineWidthUnitComboBox_currentIndexChanged( int index );
void on_mDataDefinedPropertiesButton_clicked();
void on_mOutlineStyleComboBox_currentIndexChanged( int index );
void on_mOutlineWidthSpinBox_valueChanged( double d );
void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
void on_mVerticalAnchorComboBox_currentIndexChanged( int index );
@@ -141,13 +141,23 @@
</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="0">
<widget class="QLabel" name="mOutlineWidthLabel">
<property name="text">
<string>Outline width</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QDoubleSpinBox" name="mOutlineWidthSpinBox">
@@ -175,14 +185,14 @@
</item>
</layout>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Angle</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="spinAngle">
<property name="suffix">
<string> °</string>
@@ -198,14 +208,14 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Offset X,Y</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QDoubleSpinBox" name="spinOffsetX">
@@ -255,14 +265,14 @@
</item>
</layout>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="mAnchorPointLabel">
<property name="text">
<string>Anchor point</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QComboBox" name="mHorizontalAnchorComboBox">
@@ -304,7 +314,7 @@
</item>
</layout>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="QPushButton" name="mDataDefinedPropertiesButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@@ -317,7 +327,7 @@
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="8" column="0" colspan="2">
<widget class="QListWidget" name="lstNames">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">

0 comments on commit 8a1d769

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