![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 ** Copyright (c) 2012 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 00009 00010 #pragma once 00011 00012 #include <vrvOsg/vrvOsg.h> 00013 00014 #include <vrvCore/DtWindowLineInstance.h> 00015 #include <vrvOsg/DtRgbColorInterpolator.h> 00016 00017 #include <osg/Vec2> 00018 #include <osg/Vec4> 00019 00020 namespace makVrv 00021 { 00022 class DtDe; 00023 class DtSegmentedLine; 00024 00028 class DT_DLL_VRVOSG DtOsgWindowLineInstance : public DtWindowLineInstance 00029 { 00030 public: 00032 DtOsgWindowLineInstance(DtDe& de); 00033 00035 virtual ~DtOsgWindowLineInstance(); 00036 00038 virtual void setVertex(unsigned int vertex, double x, double y ); 00039 00041 virtual void removeVertex(unsigned int vertex ); 00042 00044 virtual void setColor(float r, float g, float b, float a); 00045 00047 virtual void setStipplePattern(unsigned int stipplePattern); 00048 00050 virtual void setWidth(unsigned int width); 00051 00054 virtual void setStyleSegments( const std::vector<double>& segmentPercentages ); 00055 00057 virtual void setSegmentColor(unsigned int index, float r, float g, float b, float a); 00058 00061 virtual void setSegmentStartColor(unsigned int index, float r, float g, 00062 float b, float a); 00063 00066 virtual void setSegmentEndColor(unsigned int index, float r, float g, 00067 float b, float a); 00068 00070 virtual void setSegmentLightningStyle(unsigned int index, bool enableLightningStyle); 00071 00073 virtual void setSegmentStartArrow(unsigned int index, bool enableStartArrow); 00074 00076 virtual void setSegmentEndArrow(unsigned int index, bool enableEndArrow); 00077 00079 virtual void setSegmentStipplePattern(unsigned int index, unsigned int stipplePattern); 00080 00082 virtual void setSegmentWidth(unsigned int index, unsigned int width); 00083 00085 virtual void setVisible(bool isVisible); 00086 00088 virtual void update(); 00089 00090 protected: 00091 00093 virtual void resizeSegmentAttributes( int size ); 00094 00096 virtual void createLineIfNecessary(); 00097 00099 virtual void updateSegments(); 00100 00102 virtual void updateGeometry(); 00103 00105 virtual void generateSegment( int segmentIndex, const osg::Vec2& startPoint, 00106 const osg::Vec2& endPoint, const osg::Vec2& segmentAxis, 00107 const osg::Vec2& segmentPerpendicular ); 00108 00110 struct SegmentAttributes 00111 { 00112 unsigned int width; 00113 bool startArrow; 00114 bool endArrow; 00115 bool lightning; 00116 unsigned int stipplePattern; 00117 osg::Vec4 color[2]; 00118 int segmentStartVertex; 00119 int segmentEndVertex; 00120 int startColorRange[2]; 00121 int blendColorRange[2]; 00122 int endColorRange[2]; 00123 DtRgbColorInterpolator interpolator; 00124 bool colorRangesSetup; 00125 }; 00126 00128 virtual void setupColorRanges( SegmentAttributes* segmentAttributes ); 00129 00132 virtual void setLineSegmentColors( unsigned int vtx, 00133 SegmentAttributes* segmentAttributes ); 00134 00135 protected: 00136 00137 DtDe& myDe; 00138 00139 typedef std::vector<SegmentAttributes> SegmentAttributesVector; 00140 typedef std::vector<osg::Vec2> Points; 00141 00142 // These are the points as set by the model 00143 Points myPoints; 00144 00145 // These are the actual vertices, which may be different if style segments are used 00146 Points myVertices; 00147 00148 SegmentAttributesVector mySegmentAttributes; 00149 00150 DtSegmentedLine* myLine; 00151 bool myVisible; 00152 00153 osg::Vec4 myColor; 00154 float myWidth; 00155 unsigned int myStipplePattern; 00156 std::vector<double> mySegmentPercentages; 00157 00158 bool myGeometryDirty; 00159 bool mySegmentsDirty; 00160 }; 00161 } 00162