Quantum GIS API Documentation
1.8
|
00001 /*************************************************************************** 00002 qgsvectorfieldsymbollayer.h 00003 ------------------------- 00004 begin : Octorer 25, 2011 00005 copyright : (C) 2011 by Marco Hugentobler 00006 email : marco dot hugentobler at sourcepole dot ch 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef QGSVECTORFIELDSYMBOLLAYER_H 00019 #define QGSVECTORFIELDSYMBOLLAYER_H 00020 00021 #include "qgssymbollayerv2.h" 00022 00024 class CORE_EXPORT QgsVectorFieldSymbolLayer: public QgsMarkerSymbolLayerV2 00025 { 00026 public: 00027 enum VectorFieldType 00028 { 00029 Cartesian = 0, 00030 Polar, 00031 Height 00032 }; 00033 00034 enum AngleOrientation 00035 { 00036 ClockwiseFromNorth = 0, 00037 CounterclockwiseFromEast 00038 }; 00039 00040 enum AngleUnits 00041 { 00042 Degrees = 0, 00043 Radians 00044 }; 00045 00046 QgsVectorFieldSymbolLayer(); 00047 ~QgsVectorFieldSymbolLayer(); 00048 00049 static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ); 00050 static QgsSymbolLayerV2* createFromSld( QDomElement &element ); 00051 00052 QString layerType() const { return "VectorField"; } 00053 00054 bool setSubSymbol( QgsSymbolV2* symbol ); 00055 QgsSymbolV2* subSymbol() { return mLineSymbol; } 00056 00057 void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context ); 00058 void startRender( QgsSymbolV2RenderContext& context ); 00059 void stopRender( QgsSymbolV2RenderContext& context ); 00060 00061 QgsSymbolLayerV2* clone() const; 00062 QgsStringMap properties() const; 00063 00064 void toSld( QDomDocument& doc, QDomElement &element, QgsStringMap props ) const; 00065 00066 void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size ); 00067 00068 QSet<QString> usedAttributes() const; 00069 00070 //setters and getters 00071 void setXAttribute( const QString& attribute ) { mXAttribute = attribute; } 00072 QString xAttribute() const { return mXAttribute; } 00073 void setYAttribute( const QString& attribute ) { mYAttribute = attribute; } 00074 QString yAttribute() const { return mYAttribute; } 00075 void setScale( double s ) { mScale = s; } 00076 double scale() const { return mScale; } 00077 void setVectorFieldType( VectorFieldType type ) { mVectorFieldType = type; } 00078 VectorFieldType vectorFieldType() const { return mVectorFieldType; } 00079 void setAngleOrientation( AngleOrientation orientation ) { mAngleOrientation = orientation; } 00080 AngleOrientation angleOrientation() const { return mAngleOrientation; } 00081 void setAngleUnits( AngleUnits units ) { mAngleUnits = units; } 00082 AngleUnits angleUnits() const { return mAngleUnits; } 00083 00084 private: 00085 QString mXAttribute; 00086 QString mYAttribute; 00087 double mScale; 00088 VectorFieldType mVectorFieldType; 00089 AngleOrientation mAngleOrientation; 00090 AngleUnits mAngleUnits; 00091 00092 QgsLineSymbolV2* mLineSymbol; 00093 00094 //Attribute indices are resolved in startRender method 00095 int mXIndex; 00096 int mYIndex; 00097 00098 //Converts length/angle to cartesian x/y 00099 void convertPolarToCartesian( double length, double angle, double& x, double& y ) const; 00100 }; 00101 00102 #endif // QGSVECTORFIELDSYMBOLLAYER_H