![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 ** Copyright (c) 2010 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 /****************************************************************************** 00006 ** $RCSfile: DtOsgChannelCompassInstance.h,v $ $Revision: 1.17 $ $State: Exp $ 00007 ******************************************************************************/ 00008 00012 00013 #pragma once 00014 00015 #include <vrvOsg/vrvOsg.h> 00016 #include <vrvCore/DtChannelCompassInstance.h> 00017 #include <vrvUtil/DtSignalConnectionManager.h> 00018 #include <osg/Vec2> 00019 #include <osg/ref_ptr> 00020 00021 namespace osg 00022 { 00023 class Texture; 00024 } 00025 00026 namespace makVrv 00027 { 00028 class DtDe; 00029 class DtChannel; 00030 class DtChannelConfiguration; 00031 class DtChannelManager; 00032 class DtOsgChannel; 00033 class DtOverlayRenderer; 00034 class DtQuad; 00035 class DtWindowConfiguration; 00036 class DtLineSegment; 00037 00041 class DT_DLL_VRVOSG DtOsgChannelCompassInstance : public DtChannelCompassInstance 00042 { 00043 public: 00045 DtOsgChannelCompassInstance(DtDe& de); 00046 00048 virtual ~DtOsgChannelCompassInstance(); 00049 00051 virtual void setVisible(bool isVisible); 00052 00054 virtual bool visible(); 00055 00057 virtual void setChannelName( const std::string& deName, 00058 const std::string& winName, const std::string& channelName ); 00059 00062 virtual void setModelDefinition( const std::string& modelDefinition ); 00063 00066 virtual void updateCompass( bool force); 00067 00068 void updateLetter( bool &dirtyFlag, const std::string& filename, 00069 int tickIndex, DtQuad* letterQuad, 00070 osg::ref_ptr<osg::Texture>& letterTexture, bool& force ); 00071 00073 virtual void setNorthLetterFilename( const std::string& filename ); 00074 00076 virtual void setSouthLetterFilename( const std::string& filename ); 00077 00079 virtual void setEastLetterFilename( const std::string& filename ); 00080 00082 virtual void setWestLetterFilename( const std::string& filename ); 00083 00085 virtual void setDarkTickColor( float r, float g, float b, float a ); 00086 00088 virtual void setLightTickColor( float r, float g, float b, float a ); 00089 00090 protected: 00091 00092 virtual void slot_channelCreated(DtChannelManager*, DtChannel*); 00093 00094 virtual void slot_channelToBeDestroyed(DtChannelManager*, DtChannel*); 00095 00096 virtual void slot_channelConfigurationModified( const std::string& deName, 00097 const std::string& winName, const std::string& oldChannelName, 00098 const DtChannelConfiguration& config); 00099 00100 virtual void slot_windowConfigurationModified( const std::string& deName, 00101 const std::string& winName, const DtWindowConfiguration& config ); 00102 00103 // Create the compass frame 00104 void createCompass(); 00105 00106 // delete / clear the DtQuad and DtFilledPolygons, if they exist 00107 void destroyCompass(); 00108 00109 // Calculates a frame position based on Location enum, margins, current window size 00110 // and channel parameters 00111 osg::Vec2 calcCenterPosition(); 00112 00113 void slot_update(); 00114 00115 DtLineSegment* createDarkSide( DtOverlayRenderer& overlay ); 00116 DtLineSegment* createLightSide( DtOverlayRenderer& overlay ); 00117 00118 // This type can be used to provide a list of vertices to the polygon objects 00119 typedef std::vector<float> VertexList; 00120 00122 static void rotate(const DtOsgChannelCompassInstance::VertexList& in, 00123 double rad, DtOsgChannelCompassInstance::VertexList& out ); 00124 00126 static void translate( const DtOsgChannelCompassInstance::VertexList& in, 00127 const osg::Vec2& translation, DtOsgChannelCompassInstance::VertexList& out ); 00128 00129 static void scale( const DtOsgChannelCompassInstance::VertexList& in, 00130 double s, DtOsgChannelCompassInstance::VertexList& out ); 00131 00132 protected: 00133 00134 struct TickMark 00135 { 00136 DtLineSegment* lightSide; 00137 DtLineSegment* darkSide; 00138 }; 00139 00140 DtDe& myDe; 00141 DtSignalConnectionManager myConnections; 00142 00143 DtOsgChannel* myChannel; 00144 00145 osg::ref_ptr<osg::Texture> myNorthTexture; 00146 osg::ref_ptr<osg::Texture> mySouthTexture; 00147 osg::ref_ptr<osg::Texture> myEastTexture; 00148 osg::ref_ptr<osg::Texture> myWestTexture; 00149 00150 DtQuad* myNorthLetter; 00151 DtQuad* mySouthLetter; 00152 DtQuad* myEastLetter; 00153 DtQuad* myWestLetter; 00154 osg::Vec2 myCenterPosition; 00155 00156 // Set to true at beginning and whenever the letter filename changes 00157 bool myNorthLetterDirty; 00158 bool mySouthLetterDirty; 00159 bool myEastLetterDirty; 00160 bool myWestLetterDirty; 00161 00162 // NW, NE, SW, SE +, if missing, E, S, and W 00163 TickMark myLargeTickMarks[7]; 00164 00165 // Every 15 degrees, skipping the 4 letters and 4 large tick marks 00166 TickMark mySmallTickMarks[16]; 00167 }; 00168 } 00169