mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
Handle different vector field types
This commit is contained in:
parent
cc91d142d6
commit
59545f1c65
@ -711,7 +711,7 @@ public:
|
|||||||
//! delete layer at specified index and set a new one
|
//! delete layer at specified index and set a new one
|
||||||
bool changeSymbolLayer(int index, QgsSymbolLayerV2* layer /Transfer/);
|
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 stopRender(QgsRenderContext& context);
|
||||||
|
|
||||||
void setColor(const QColor& color);
|
void setColor(const QColor& color);
|
||||||
|
@ -105,6 +105,13 @@ void QgsVectorFieldSymbolLayer::renderPoint( const QPointF& point, QgsSymbolV2Re
|
|||||||
xComponent = context.outputLineWidth( xVal );
|
xComponent = context.outputLineWidth( xVal );
|
||||||
yComponent = context.outputLineWidth( yVal );
|
yComponent = context.outputLineWidth( yVal );
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -189,3 +196,27 @@ QSet<QString> QgsVectorFieldSymbolLayer::usedAttributes() const
|
|||||||
}
|
}
|
||||||
return attributes;
|
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
|
//Attribute indices are resolved in startRender method
|
||||||
int mXIndex;
|
int mXIndex;
|
||||||
int mYIndex;
|
int mYIndex;
|
||||||
|
|
||||||
|
//Converts length/angle to cartesian x/y
|
||||||
|
void convertPolarToCartesian( double length, double angle, double& x, double& y ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QGSVECTORFIELDSYMBOLLAYER_H
|
#endif // QGSVECTORFIELDSYMBOLLAYER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user