Skip to content

Commit b16f611

Browse files
author
Marco Hugentobler
committedJun 10, 2011
Improve data defined rotation
1 parent 7072290 commit b16f611

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed
 

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
#include <QPainter>
55
#include <QSet>
66

7-
QgsEllipseSymbolLayerV2::QgsEllipseSymbolLayerV2(): mSymbolName("circle"), mSymbolWidth(4), mSymbolHeight(3), mRotation(0), mFillColor( Qt::black ), mOutlineColor( Qt::white )
7+
QgsEllipseSymbolLayerV2::QgsEllipseSymbolLayerV2(): mSymbolName("circle"), mSymbolWidth(4), mSymbolHeight(3),
8+
mFillColor( Qt::black ), mOutlineColor( Qt::white ), mOutlineWidth( 0 )
89
{
910
mPen.setColor( mOutlineColor );
1011
mPen.setWidth( 1.0 );
1112
mPen.setJoinStyle( Qt::MiterJoin );
1213
mBrush.setColor( mFillColor );
1314
mBrush.setStyle( Qt::SolidPattern );
1415

16+
mAngle = 0;
1517
mWidthField.first = -1;
1618
mHeightField.first = -1;
1719
mRotationField.first = -1;
@@ -39,9 +41,9 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& propertie
3941
{
4042
layer->setSymbolHeight( properties["symbol_height"].toDouble() );
4143
}
42-
if( properties.contains("rotation") )
44+
if( properties.contains("angle") )
4345
{
44-
layer->setRotation( properties["rotation"].toDouble() );
46+
layer->setAngle( properties["angle"].toDouble() );
4547
}
4648
if( properties.contains( "outline_width" ) )
4749
{
@@ -117,22 +119,15 @@ void QgsEllipseSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2Rend
117119
return;
118120
}
119121

120-
//priority for rotation: 1. data defined, 2. symbol layer rotation (mRotation), 3. symbol rotation (mAngle)
122+
//priority for rotation: 1. data defined, 2. symbol layer rotation (mAngle)
121123
double rotation = 0.0;
122-
if( mRotationField.first != -1 )
124+
if( f && mRotationField.first != -1 )
123125
{
124126
rotation = f->attributeMap()[mRotationField.first].toDouble();
125127
}
126-
else
128+
else if( !doubleNear( mAngle, 0.0 ) )
127129
{
128-
if( !doubleNear( mRotation, 0.0 ) )
129-
{
130-
rotation = mRotation;
131-
}
132-
else if( !doubleNear( mAngle, 0.0 ) )
133-
{
134-
rotation = mAngle;
135-
}
130+
rotation = mAngle;
136131
}
137132

138133
QMatrix transform;
@@ -182,7 +177,7 @@ QgsStringMap QgsEllipseSymbolLayerV2::properties() const
182177
map["symbol_height"] = QString::number( mSymbolHeight );
183178
map["height_index"] = QString::number( mHeightField.first );
184179
map["height_field"] = mHeightField.second;
185-
map["rotation"] = QString::number( mRotation );
180+
map["angle"] = QString::number( mAngle );
186181
map["rotation_index"] = QString::number( mRotationField.first );
187182
map["rotation_field"] = mRotationField.second;
188183
map["outline_width"] = QString::number( mOutlineWidth );
@@ -262,6 +257,10 @@ QSet<QString> QgsEllipseSymbolLayerV2::usedAttributes() const
262257
{
263258
dataDefinedAttributes.insert( mHeightField.second );
264259
}
260+
if( mRotationField.first != -1 )
261+
{
262+
dataDefinedAttributes.insert( mRotationField.second );
263+
}
265264
if( mOutlineWidthField.first != -1 )
266265
{
267266
dataDefinedAttributes.insert( mOutlineWidthField.second );

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ class QgsEllipseSymbolLayerV2: public QgsMarkerSymbolLayerV2
3535
void setHeightField( int index, const QString& field );
3636
const QPair<int, QString>& heightField() const { return mHeightField; }
3737

38-
void setRotation( double r ){ mRotation = r; }
39-
double rotation() const { return mRotation; }
40-
4138
void setRotationField( int index, const QString& field );
4239
const QPair<int, QString>& rotationField() const { return mRotationField; }
4340

@@ -65,7 +62,6 @@ class QgsEllipseSymbolLayerV2: public QgsMarkerSymbolLayerV2
6562
QString mSymbolName;
6663
double mSymbolWidth;
6764
double mSymbolHeight;
68-
double mRotation;
6965
QColor mFillColor;
7066
QColor mOutlineColor;
7167
double mOutlineWidth;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void QgsEllipseSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
4141
mLayer = static_cast<QgsEllipseSymbolLayerV2*>( layer );
4242
mWidthSpinBox->setValue( mLayer->symbolWidth() );
4343
mHeightSpinBox->setValue( mLayer->symbolHeight() );
44-
mRotationSpinBox->setValue( mLayer->rotation() );
44+
mRotationSpinBox->setValue( mLayer->angle() );
4545
mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() );
4646

4747
QList<QListWidgetItem *> symbolItemList = mShapeListWidget->findItems( mLayer->symbolName(), Qt::MatchExactly );
@@ -122,7 +122,7 @@ void QgsEllipseSymbolLayerV2Widget::on_mRotationSpinBox_valueChanged( double d )
122122
{
123123
if( mLayer )
124124
{
125-
mLayer->setRotation( d );
125+
mLayer->setAngle( d );
126126
emit changed();
127127
}
128128
}

0 commit comments

Comments
 (0)
Please sign in to comment.