Skip to content

Commit 5a28acc

Browse files
author
wonder
committedNov 28, 2010
Fixed scaling of line decoration symbol layer.
git-svn-id: http://svn.osgeo.org/qgis/trunk@14780 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 89e0a94 commit 5a28acc

File tree

5 files changed

+55
-13
lines changed

5 files changed

+55
-13
lines changed
 

‎src/core/symbology-ng/qgslinesymbollayerv2.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,10 @@ double QgsMarkerLineSymbolLayerV2::width() const
455455

456456
/////////////
457457

458-
QgsLineDecorationSymbolLayerV2::QgsLineDecorationSymbolLayerV2( QColor color )
458+
QgsLineDecorationSymbolLayerV2::QgsLineDecorationSymbolLayerV2( QColor color, double width )
459459
{
460460
mColor = color;
461+
mWidth = width;
461462
}
462463

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

471473
if ( props.contains( "color" ) )
472474
color = QgsSymbolLayerV2Utils::decodeColor( props["color"] );
475+
if ( props.contains( "width" ) )
476+
width = props["width"].toDouble();
473477

474-
return new QgsLineDecorationSymbolLayerV2( color );
478+
return new QgsLineDecorationSymbolLayerV2( color, width );
475479
}
476480

477481
QString QgsLineDecorationSymbolLayerV2::layerType() const
@@ -483,9 +487,11 @@ void QgsLineDecorationSymbolLayerV2::startRender( QgsSymbolV2RenderContext& cont
483487
{
484488
QColor penColor = mColor;
485489
penColor.setAlphaF( context.alpha() );
490+
mPen.setWidth( context.outputLineWidth( mWidth ) );
486491
mPen.setColor( penColor );
487492
QColor selColor = context.selectionColor();
488493
if ( ! selectionIsOpaque ) selColor.setAlphaF( context.alpha() );
494+
mSelPen.setWidth( context.outputLineWidth( mWidth ) );
489495
mSelPen.setColor( selColor );
490496
}
491497

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

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

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

543550
QgsSymbolLayerV2* QgsLineDecorationSymbolLayerV2::clone() const
544551
{
545-
return new QgsLineDecorationSymbolLayerV2( mColor );
552+
return new QgsLineDecorationSymbolLayerV2( mColor, mWidth );
546553
}

‎src/core/symbology-ng/qgslinesymbollayerv2.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,13 @@ class CORE_EXPORT QgsMarkerLineSymbolLayerV2 : public QgsLineSymbolLayerV2
146146
/////////
147147

148148
#define DEFAULT_LINEDECORATION_COLOR QColor(0,0,0)
149+
#define DEFAULT_LINEDECORATION_WIDTH DEFAULT_LINE_WIDTH
149150

150151
class CORE_EXPORT QgsLineDecorationSymbolLayerV2 : public QgsLineSymbolLayerV2
151152
{
152153
public:
153-
QgsLineDecorationSymbolLayerV2( QColor color = DEFAULT_LINEDECORATION_COLOR );
154+
QgsLineDecorationSymbolLayerV2( QColor color = DEFAULT_LINEDECORATION_COLOR,
155+
double width = DEFAULT_LINEDECORATION_WIDTH );
154156

155157
~QgsLineDecorationSymbolLayerV2();
156158

‎src/gui/symbology-ng/qgssymbollayerv2widget.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ QgsLineDecorationSymbolLayerV2Widget::QgsLineDecorationSymbolLayerV2Widget( QWid
589589
setupUi( this );
590590

591591
connect( btnChangeColor, SIGNAL( clicked() ), this, SLOT( colorChanged() ) );
592+
connect( spinWidth, SIGNAL( valueChanged( double ) ), this, SLOT( penWidthChanged() ) );
592593
}
593594

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

602603
// set values
603604
btnChangeColor->setColor( mLayer->color() );
605+
spinWidth->setValue( mLayer->width() );
604606
}
605607

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

623+
void QgsLineDecorationSymbolLayerV2Widget::penWidthChanged()
624+
{
625+
mLayer->setWidth( spinWidth->value() );
626+
emit changed();
627+
}
628+
621629
/////////////
622630

623631
#include <QFileDialog>

‎src/gui/symbology-ng/qgssymbollayerv2widget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ class GUI_EXPORT QgsLineDecorationSymbolLayerV2Widget : public QgsSymbolLayerV2W
209209

210210
public slots:
211211
void colorChanged();
212+
void penWidthChanged();
212213

213214
protected:
214215
QgsLineDecorationSymbolLayerV2* mLayer;

‎src/ui/symbollayer/widget_linedecoration.ui

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>368</width>
10-
<height>244</height>
9+
<width>366</width>
10+
<height>242</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
1414
<string>Form</string>
1515
</property>
16-
<layout class="QVBoxLayout">
16+
<layout class="QVBoxLayout" name="verticalLayout">
1717
<item>
18-
<layout class="QHBoxLayout">
19-
<item>
18+
<layout class="QGridLayout" name="gridLayout">
19+
<item row="0" column="0">
2020
<widget class="QLabel" name="label">
2121
<property name="text">
2222
<string>Color</string>
2323
</property>
2424
</widget>
2525
</item>
26-
<item>
26+
<item row="0" column="1">
2727
<widget class="QgsColorButtonV2" name="btnChangeColor">
2828
<property name="sizePolicy">
2929
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@@ -36,7 +36,7 @@
3636
</property>
3737
</widget>
3838
</item>
39-
<item>
39+
<item row="0" column="2" rowspan="2">
4040
<spacer>
4141
<property name="orientation">
4242
<enum>Qt::Horizontal</enum>
@@ -47,11 +47,31 @@
4747
<property name="sizeHint" stdset="0">
4848
<size>
4949
<width>112</width>
50-
<height>21</height>
50+
<height>48</height>
5151
</size>
5252
</property>
5353
</spacer>
5454
</item>
55+
<item row="1" column="0">
56+
<widget class="QLabel" name="label_2">
57+
<property name="text">
58+
<string>Pen width</string>
59+
</property>
60+
</widget>
61+
</item>
62+
<item row="1" column="1">
63+
<widget class="QDoubleSpinBox" name="spinWidth">
64+
<property name="alignment">
65+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
66+
</property>
67+
<property name="maximum">
68+
<double>100000.000000000000000</double>
69+
</property>
70+
<property name="value">
71+
<double>1.000000000000000</double>
72+
</property>
73+
</widget>
74+
</item>
5575
</layout>
5676
</item>
5777
<item>
@@ -76,6 +96,10 @@
7696
<header>qgscolorbutton.h</header>
7797
</customwidget>
7898
</customwidgets>
99+
<tabstops>
100+
<tabstop>btnChangeColor</tabstop>
101+
<tabstop>spinWidth</tabstop>
102+
</tabstops>
79103
<resources/>
80104
<connections/>
81105
</ui>

0 commit comments

Comments
 (0)
Please sign in to comment.