00001 #ifndef ABSTRACTCURVE_H 00002 #define ABSTRACTCURVE_H 00003 00004 #include "Types.h" 00005 #include "Rendernode.h" 00006 #include "UpdateInterface.h" 00007 00008 namespace RenderTools { 00009 00010 using namespace std; 00011 00013 class AbstractCurve : public Rendernode , public UpdateInterface { 00014 public: 00015 00016 enum InterpolationType { 00017 LINEAR, 00018 HERMITE 00019 }; 00020 00021 AbstractCurve( void ); 00022 virtual ~AbstractCurve( void ); 00023 00024 static PropertyPtr create( const XMLNodePtr & xml = XMLNodePtr() ); 00025 virtual void createProperties( void ); 00026 virtual const string getTypeName( bool ofComponent = false ) const; 00027 00028 virtual void onInitialize( void ); 00029 virtual void clear( void ) = 0; 00030 void setInterpolationType( InterpolationType t, bool send = true ); 00031 void setSubdivision( unsigned int s, bool send = true ); 00032 void setClosed( bool state, bool send = true ); 00033 InterpolationType getInterpolationType( void ) const { return( m_interpolationType ); } 00034 unsigned int getSubdivision( void ) const { return( m_subdiv ); } 00035 bool getClosed( void ) const { return( m_closed ); } 00036 protected: 00037 string m_type; 00038 InterpolationType m_interpolationType; 00039 unsigned int m_subdiv; 00040 bool m_closed; 00041 }; 00042 00043 inline EnumList getInterpolationTypeEnums( void ){ 00044 EnumList r; 00045 r.push_back("LINEAR"); 00046 r.push_back("HERMITE"); 00047 return( r ); 00048 } 00049 00050 struct InterpolationTypeStruct { 00051 InterpolationTypeStruct( AbstractCurve::InterpolationType * e = 0 ): 00052 m_value( e ){ 00053 } 00054 00055 bool operator == ( const InterpolationTypeStruct & v2 ){ 00056 return( m_value == v2.m_value ); 00057 } 00058 bool operator != ( const InterpolationTypeStruct & v2 ){ 00059 return( ! ( m_value == v2.m_value ) ); 00060 } 00061 AbstractCurve::InterpolationType operator [] ( const unsigned int i ){ 00062 return( * m_value ); 00063 } 00064 AbstractCurve::InterpolationType * m_value; 00065 }; 00066 00067 inline ostream & operator << ( ostream & s, const InterpolationTypeStruct & v ){ 00068 switch( * v.m_value ){ 00069 case AbstractCurve::LINEAR: 00070 s << string( "LINEAR" ); 00071 break; 00072 case AbstractCurve::HERMITE: 00073 s << string( "HERMITE" ); 00074 break; 00075 } 00076 return( s ); 00077 } 00078 00079 inline istream & operator >> ( istream & s, InterpolationTypeStruct & v ){ 00080 string value; 00081 s >> value; 00082 00083 if( value == "LINEAR" ){ 00084 * v.m_value = AbstractCurve::LINEAR; 00085 } 00086 else if( value == "HERMITE" ){ 00087 * v.m_value = AbstractCurve::HERMITE; 00088 } 00089 00090 return( s ); 00091 } 00092 00093 }; // namespace rendertools 00094 00095 #endif
1.5.8