Skip to content
Permalink
Browse files

Fixed scaling of line decoration symbol layer.

git-svn-id: http://svn.osgeo.org/qgis/trunk@14780 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Nov 28, 2010
1 parent 89e0a94 commit 5a28acc9552d5e1bedf96e9c39dffb25df153656
@@ -455,9 +455,10 @@ double QgsMarkerLineSymbolLayerV2::width() const

/////////////

QgsLineDecorationSymbolLayerV2::QgsLineDecorationSymbolLayerV2( QColor color )
QgsLineDecorationSymbolLayerV2::QgsLineDecorationSymbolLayerV2( QColor color, double width )
{
mColor = color;
mWidth = width;
}

QgsLineDecorationSymbolLayerV2::~QgsLineDecorationSymbolLayerV2()
@@ -467,11 +468,14 @@ QgsLineDecorationSymbolLayerV2::~QgsLineDecorationSymbolLayerV2()
QgsSymbolLayerV2* QgsLineDecorationSymbolLayerV2::create( const QgsStringMap& props )
{
QColor color = DEFAULT_LINEDECORATION_COLOR;
double width = DEFAULT_LINEDECORATION_WIDTH;

if ( props.contains( "color" ) )
color = QgsSymbolLayerV2Utils::decodeColor( props["color"] );
if ( props.contains( "width" ) )
width = props["width"].toDouble();

return new QgsLineDecorationSymbolLayerV2( color );
return new QgsLineDecorationSymbolLayerV2( color, width );
}

QString QgsLineDecorationSymbolLayerV2::layerType() const
@@ -483,9 +487,11 @@ void QgsLineDecorationSymbolLayerV2::startRender( QgsSymbolV2RenderContext& cont
{
QColor penColor = mColor;
penColor.setAlphaF( context.alpha() );
mPen.setWidth( context.outputLineWidth( mWidth ) );
mPen.setColor( penColor );
QColor selColor = context.selectionColor();
if ( ! selectionIsOpaque ) selColor.setAlphaF( context.alpha() );
mSelPen.setWidth( context.outputLineWidth( mWidth ) );
mSelPen.setColor( selColor );
}

@@ -521,7 +527,7 @@ void QgsLineDecorationSymbolLayerV2::renderPolyline( const QPolygonF& points, Qg
QPointF p2 = points.at( cnt - 1 );
double angle = _calculateAngle( p1.x(), p1.y(), p2.x(), p2.y() );

double size = context.outputLineWidth( 2 );
double size = context.outputLineWidth( mWidth * 8 );
double angle1 = angle + M_PI / 6;
double angle2 = angle - M_PI / 6;

@@ -537,10 +543,11 @@ QgsStringMap QgsLineDecorationSymbolLayerV2::properties() const
{
QgsStringMap map;
map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
map["width"] = QString::number( mWidth );
return map;
}

QgsSymbolLayerV2* QgsLineDecorationSymbolLayerV2::clone() const
{
return new QgsLineDecorationSymbolLayerV2( mColor );
return new QgsLineDecorationSymbolLayerV2( mColor, mWidth );
}
@@ -146,11 +146,13 @@ class CORE_EXPORT QgsMarkerLineSymbolLayerV2 : public QgsLineSymbolLayerV2
/////////

#define DEFAULT_LINEDECORATION_COLOR QColor(0,0,0)
#define DEFAULT_LINEDECORATION_WIDTH DEFAULT_LINE_WIDTH

class CORE_EXPORT QgsLineDecorationSymbolLayerV2 : public QgsLineSymbolLayerV2
{
public:
QgsLineDecorationSymbolLayerV2( QColor color = DEFAULT_LINEDECORATION_COLOR );
QgsLineDecorationSymbolLayerV2( QColor color = DEFAULT_LINEDECORATION_COLOR,
double width = DEFAULT_LINEDECORATION_WIDTH );

~QgsLineDecorationSymbolLayerV2();

@@ -589,6 +589,7 @@ QgsLineDecorationSymbolLayerV2Widget::QgsLineDecorationSymbolLayerV2Widget( QWid
setupUi( this );

connect( btnChangeColor, SIGNAL( clicked() ), this, SLOT( colorChanged() ) );
connect( spinWidth, SIGNAL( valueChanged( double ) ), this, SLOT( penWidthChanged() ) );
}

void QgsLineDecorationSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
@@ -601,6 +602,7 @@ void QgsLineDecorationSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* lay

// set values
btnChangeColor->setColor( mLayer->color() );
spinWidth->setValue( mLayer->width() );
}

QgsSymbolLayerV2* QgsLineDecorationSymbolLayerV2Widget::symbolLayer()
@@ -618,6 +620,12 @@ void QgsLineDecorationSymbolLayerV2Widget::colorChanged()
emit changed();
}

void QgsLineDecorationSymbolLayerV2Widget::penWidthChanged()
{
mLayer->setWidth( spinWidth->value() );
emit changed();
}

/////////////

#include <QFileDialog>
@@ -209,6 +209,7 @@ class GUI_EXPORT QgsLineDecorationSymbolLayerV2Widget : public QgsSymbolLayerV2W

public slots:
void colorChanged();
void penWidthChanged();

protected:
QgsLineDecorationSymbolLayerV2* mLayer;
@@ -6,24 +6,24 @@
<rect>
<x>0</x>
<y>0</y>
<width>368</width>
<height>244</height>
<width>366</width>
<height>242</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QgsColorButtonV2" name="btnChangeColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@@ -36,7 +36,7 @@
</property>
</widget>
</item>
<item>
<item row="0" column="2" rowspan="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -47,11 +47,31 @@
<property name="sizeHint" stdset="0">
<size>
<width>112</width>
<height>21</height>
<height>48</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Pen width</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="spinWidth">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="maximum">
<double>100000.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
@@ -76,6 +96,10 @@
<header>qgscolorbutton.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>btnChangeColor</tabstop>
<tabstop>spinWidth</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

0 comments on commit 5a28acc

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