[QGIS Commit] r14780 - in trunk/qgis/src: core/symbology-ng
gui/symbology-ng ui/symbollayer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sun Nov 28 15:48:26 EST 2010
Author: wonder
Date: 2010-11-28 12:48:26 -0800 (Sun, 28 Nov 2010)
New Revision: 14780
Modified:
trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.cpp
trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.h
trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp
trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.h
trunk/qgis/src/ui/symbollayer/widget_linedecoration.ui
Log:
Fixed scaling of line decoration symbol layer.
Modified: trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.cpp 2010-11-28 20:14:36 UTC (rev 14779)
+++ trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.cpp 2010-11-28 20:48:26 UTC (rev 14780)
@@ -455,9 +455,10 @@
/////////////
-QgsLineDecorationSymbolLayerV2::QgsLineDecorationSymbolLayerV2( QColor color )
+QgsLineDecorationSymbolLayerV2::QgsLineDecorationSymbolLayerV2( QColor color, double width )
{
mColor = color;
+ mWidth = width;
}
QgsLineDecorationSymbolLayerV2::~QgsLineDecorationSymbolLayerV2()
@@ -467,11 +468,14 @@
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 @@
{
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 @@
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 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 );
}
Modified: trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.h
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.h 2010-11-28 20:14:36 UTC (rev 14779)
+++ trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.h 2010-11-28 20:48:26 UTC (rev 14780)
@@ -146,11 +146,13 @@
/////////
#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();
Modified: trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp
===================================================================
--- trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp 2010-11-28 20:14:36 UTC (rev 14779)
+++ trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp 2010-11-28 20:48:26 UTC (rev 14780)
@@ -589,6 +589,7 @@
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 @@
// set values
btnChangeColor->setColor( mLayer->color() );
+ spinWidth->setValue( mLayer->width() );
}
QgsSymbolLayerV2* QgsLineDecorationSymbolLayerV2Widget::symbolLayer()
@@ -618,6 +620,12 @@
emit changed();
}
+void QgsLineDecorationSymbolLayerV2Widget::penWidthChanged()
+{
+ mLayer->setWidth( spinWidth->value() );
+ emit changed();
+}
+
/////////////
#include <QFileDialog>
Modified: trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.h
===================================================================
--- trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.h 2010-11-28 20:14:36 UTC (rev 14779)
+++ trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.h 2010-11-28 20:48:26 UTC (rev 14780)
@@ -209,6 +209,7 @@
public slots:
void colorChanged();
+ void penWidthChanged();
protected:
QgsLineDecorationSymbolLayerV2* mLayer;
Modified: trunk/qgis/src/ui/symbollayer/widget_linedecoration.ui
===================================================================
--- trunk/qgis/src/ui/symbollayer/widget_linedecoration.ui 2010-11-28 20:14:36 UTC (rev 14779)
+++ trunk/qgis/src/ui/symbollayer/widget_linedecoration.ui 2010-11-28 20:48:26 UTC (rev 14780)
@@ -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>
More information about the QGIS-commit
mailing list