Skip to content
Permalink
Browse files

Handle different vector field types

  • Loading branch information
mhugent committed Nov 1, 2011
1 parent cc91d14 commit 59545f1c6525a289c2c57d6ce70653b69efd77f8
@@ -711,7 +711,7 @@ public:
//! delete layer at specified index and set a new one
bool changeSymbolLayer(int index, QgsSymbolLayerV2* layer /Transfer/);

void startRender( QgsRenderContext& context, const QgsVectorLayer* layer );
void startRender( QgsRenderContext& context, const QgsVectorLayer* layer = 0 );
void stopRender(QgsRenderContext& context);

void setColor(const QColor& color);
@@ -105,6 +105,13 @@ void QgsVectorFieldSymbolLayer::renderPoint( const QPointF& point, QgsSymbolV2Re
xComponent = context.outputLineWidth( xVal );
yComponent = context.outputLineWidth( yVal );
break;
case Polar:
convertPolarToCartesian( xVal, yVal, xComponent, yComponent );
xComponent = context.outputLineWidth( xComponent );
yComponent = context.outputLineWidth( yComponent );
case Height:
xComponent = 0;
yComponent = context.outputLineWidth( yVal );
default:
break;
}
@@ -189,3 +196,27 @@ QSet<QString> QgsVectorFieldSymbolLayer::usedAttributes() const
}
return attributes;
}

void QgsVectorFieldSymbolLayer::convertPolarToCartesian( double length, double angle, double& x, double& y ) const
{
//convert angle to degree and to north orientation
if ( mAngleOrientation == CounterclockwiseFromEast )
{
if ( angle <= 90 )
{
angle = 90 - angle;
}
else
{
angle = 360 - angle + 90;
}
}

if ( mAngleUnits == Degrees )
{
angle = angle * M_PI / 180.0;
}

x = length * sin( angle );
y = length * cos( angle );
}
@@ -91,6 +91,9 @@ class CORE_EXPORT QgsVectorFieldSymbolLayer: public QgsMarkerSymbolLayerV2
//Attribute indices are resolved in startRender method
int mXIndex;
int mYIndex;

//Converts length/angle to cartesian x/y
void convertPolarToCartesian( double length, double angle, double& x, double& y ) const;
};

#endif // QGSVECTORFIELDSYMBOLLAYER_H

0 comments on commit 59545f1

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