Home Hierarchy Members Alphabetical Related Pages

sfcolor.h

Go to the documentation of this file.
00001 #ifndef XDKWRL_SFCOLOR_H
00002 #define XDKWRL_SFCOLOR_H
00003 
00004 #include <xdkwrl/fieldtypes.h>
00005 #include <iostream>
00006 
00007 namespace wrl
00008 {
00009   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00010   // Interface of  SFColor
00011   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00012   /*! \ingroup fieldtypes
00013    *
00014    * Represents a RGB color value. Below is included the documentation for
00015    * this field type from the ISO standard.
00016    * \htmlinclude sfcolor.html
00017    */
00018   class SFColor 
00019   {
00020   public:
00021     inline SFColor();
00022     inline SFColor(const float* c);
00023     inline SFColor(const float r,const float g,const float b);
00024     inline SFColor& operator=(const SFColor& c);
00025     inline operator const float*() const;
00026     inline float red() const;
00027     inline float green() const;
00028     inline float blue() const;
00029     inline void setRGB(const float r,const float g,const float b);
00030     inline void setRed(const float);
00031     inline void setGreen(const float);
00032     inline void setBlue(const float);
00033     static inline const char* typeName();
00034     static inline FieldTypeId typeId();
00035     inline bool operator==(const SFColor& c) const;
00036     friend std::ostream& operator<<(std::ostream& s,const SFColor& f);
00037   protected:
00038   private:
00039     float red_;
00040     float green_;
00041     float blue_;
00042   };
00043   //************************************************************
00044   // Implementation of SFColor
00045   //************************************************************
00046   inline
00047   SFColor::SFColor()
00048     : red_(0.0f),green_(0.0f),blue_(0.0f)
00049   {
00050   }
00051   inline
00052   SFColor::SFColor(const float* c)
00053     : red_(c[0]),green_(c[1]),blue_(c[2])    
00054   {    
00055   }
00056   inline
00057   SFColor::SFColor(const float r,const float g,const float b)
00058     : red_(r),green_(g),blue_(b)    
00059   {    
00060   }    
00061   inline SFColor&
00062   SFColor::operator=(const SFColor& c)
00063   {
00064     red_ = c.red_;
00065     green_ = c.green_;
00066     blue_ = c.blue_;
00067     return *this;
00068   }
00069   inline
00070   SFColor::operator const float*() const
00071   {
00072     return &red_;
00073   }
00074   inline float
00075   SFColor::red() const
00076   {
00077     return red_;
00078   }
00079   inline float
00080   SFColor::green() const
00081   {
00082     return green_;
00083   }
00084   inline float
00085   SFColor::blue() const
00086   {
00087     return blue_;
00088   }
00089   inline void
00090   SFColor::setRed(const float f)
00091   {
00092     red_ = f;
00093   }
00094   inline void
00095   SFColor::setGreen(const float f)
00096   {
00097     green_ = f;
00098   }
00099   inline void
00100   SFColor::setBlue(const float f)
00101   {
00102     blue_ = f;
00103   }  
00104   inline void
00105   SFColor::setRGB(const float r,const float g,const float b)
00106   {
00107     red_ = r;
00108     green_ = g;
00109     blue_ = b;
00110   }  
00111   inline bool
00112   SFColor::operator==(const SFColor& c) const
00113   {
00114     return red_ == c.red_ && green_ == c.green_ && blue_ == c.blue_;
00115   }
00116   inline const char*
00117   SFColor::typeName()
00118   {
00119     return "SFColor";
00120   }
00121   inline FieldTypeId
00122   SFColor::typeId()
00123   {
00124     return sfColor;
00125   }  
00126   inline std::ostream& operator<<(std::ostream& s,const SFColor& f)
00127   {
00128     return s<<f.red_<<' '<<f.green_<<' '<<f.blue_;
00129   }
00130 };
00131 
00132 #endif // XDKWRL_SFCOLOR_H

Generated on 24 Feb 2005 with doxygen version 1.3.9.1. Valid HTML 4.0! Valid CSS!