Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGGeoPropColors.inl

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #include <stdlib.h>
00040 #include <stdio.h>
00041 
00042 #include "OSGConfig.h"
00043 
00044 OSG_BEGIN_NAMESPACE
00045 
00046 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00047 
00048 // Color4f
00049 
00050 template<> inline 
00051 Color3f GeoProperty<GeoColors4fPropertyDesc>::getValue(const UInt32 index)
00052 {
00053     return Color3f(_field[index].red  (), 
00054                    _field[index].green(),
00055                    _field[index].blue ());
00056 }
00057 
00058 template<> inline 
00059 Color3f GeoProperty<GeoColors4fPropertyDesc>::getValue( 
00060     const UInt32 index) const
00061 {
00062     return Color3f(_field[index].red  (), 
00063                    _field[index].green(), 
00064                    _field[index].blue ());
00065 }
00066 
00067 template<> inline
00068 void GeoProperty<GeoColors4fPropertyDesc>::getValue(
00069           Color3f &res,
00070     const UInt32   index)
00071 {
00072     res.setValuesRGB(_field[index].red  (), 
00073                      _field[index].green(), 
00074                      _field[index].blue ());
00075 }
00076 
00077 
00078 template<> inline 
00079 void GeoProperty<GeoColors4fPropertyDesc>::getValue(
00080           Color3f &res,
00081     const UInt32   index) const
00082 {
00083     res.setValuesRGB(_field[index].red  (), 
00084                      _field[index].green(), 
00085                      _field[index].blue ());
00086 }
00087 
00088 
00089 template<> inline 
00090 void GeoProperty<GeoColors4fPropertyDesc>::setValue(const Color3f &val,
00091                                                     const UInt32   index)
00092 {
00093     _field[index].setValuesRGBA(val.red(), val.green(), val.blue (), 1.f);
00094 }
00095 
00096 
00097 template<> inline 
00098 void GeoProperty<GeoColors4fPropertyDesc>::addValue(const Color3f &val)
00099 {
00100     _field.push_back(Color4f(val.red(), val.green(), val.blue (), 1.f));
00101 }
00102 
00103 template <> inline
00104 bool GeoProperty<GeoColors4fPropertyDesc>::insertValue(const Color3f &val,
00105                                                        const UInt32 index)
00106 {
00107     if(_field.size() < index)
00108     {
00109         return false;
00110     }
00111     else if(_field.size() == index)
00112     {
00113         addValue(val);
00114         return true;
00115     }
00116     else
00117     {
00118         _field.insert(_field.begin() + index,
00119                       Color4f(val.red(), val.green(), val.blue (), 1.f));
00120         return true;
00121     }
00122 }
00123 
00124 
00125 // Color3ub
00126 
00127 template<> inline
00128 Color3f GeoProperty<GeoColors3ubPropertyDesc>::getValue(const UInt32 index)
00129 {
00130     return Color3f(_field[index].red  () / 255.f,
00131                    _field[index].green() / 255.f,
00132                    _field[index].blue () / 255.f);
00133 }
00134 
00135 template<> inline
00136 Color3f GeoProperty<GeoColors3ubPropertyDesc>::getValue(
00137     const UInt32 index) const
00138 {
00139     return Color3f(_field[index].red  () / 255.f,
00140                    _field[index].green() / 255.f,
00141                    _field[index].blue () / 255.f);
00142 }
00143 
00144 template<> inline
00145 void GeoProperty<GeoColors3ubPropertyDesc>::getValue(
00146           Color3f &res,
00147     const UInt32   index)
00148 {
00149     res.setValuesRGB(_field[index].red  () / 255.f,
00150                      _field[index].green() / 255.f,
00151                      _field[index].blue () / 255.f);
00152 }
00153 
00154 template<> inline
00155 void GeoProperty<GeoColors3ubPropertyDesc>::getValue(
00156           Color3f &res,
00157     const UInt32   index) const
00158 {
00159     res.setValuesRGB(_field[index].red  () / 255.f,
00160                      _field[index].green() / 255.f,
00161                      _field[index].blue () / 255.f);
00162 }
00163 
00164 template<> inline
00165 void GeoProperty<GeoColors3ubPropertyDesc>::setValue(const Color3f &val,
00166                                                      const UInt32   index)
00167 {
00168     _field[index].setValuesRGB(UInt8(val.red  () * 255.f),
00169                                UInt8(val.green() * 255.f),
00170                                UInt8(val.blue () * 255.f));
00171 }
00172 
00173 template<> inline
00174 void GeoProperty<GeoColors3ubPropertyDesc>::addValue(const Color3f &val)
00175 {
00176     _field.push_back(Color3ub(UInt8(val.red  () * 255.f),
00177                               UInt8(val.green() * 255.f),
00178                               UInt8(val.blue () * 255.f)));
00179 }
00180 
00181 template <> inline
00182 bool GeoProperty<GeoColors3ubPropertyDesc>::insertValue(const Color3f &val,
00183                                                         const UInt32 index)
00184 {
00185     if(_field.size() < index)
00186     {
00187         return false;
00188     }
00189     else if(_field.size() == index)
00190     {
00191         addValue(val);
00192         return true;
00193     }
00194     else
00195     {
00196         _field.insert(_field.begin() + index,
00197                       Color3ub(UInt8(val.red  () * 255.f),
00198                                UInt8(val.green() * 255.f),
00199                                UInt8(val.blue () * 255.f)));
00200         return true;
00201     }
00202 }
00203 
00204 
00205 // Color4ub
00206 
00207 template<> inline
00208 Color3f GeoProperty<GeoColors4ubPropertyDesc>::getValue(const UInt32 index)
00209 {
00210     return Color3f(_field[index].red  () / 255.f,
00211                    _field[index].green() / 255.f,
00212                    _field[index].blue () / 255.f);
00213 }
00214 
00215 template<> inline
00216 Color3f GeoProperty<GeoColors4ubPropertyDesc>::getValue(
00217     const UInt32 index) const
00218 {
00219     return Color3f(_field[index].red  () / 255.f, 
00220                    _field[index].green() / 255.f,
00221                    _field[index].blue () / 255.f);
00222 }
00223 
00224 template<> inline 
00225 void GeoProperty<GeoColors4ubPropertyDesc>::getValue(
00226           Color3f &res,
00227     const UInt32   index)
00228 {
00229     res.setValuesRGB(_field[index].red  () / 255.f, 
00230                      _field[index].green() / 255.f, 
00231                      _field[index].blue () / 255.f);
00232 }
00233 
00234 template<> inline 
00235 void GeoProperty<GeoColors4ubPropertyDesc>::getValue(
00236           Color3f &res,
00237     const UInt32   index) const
00238 {
00239     res.setValuesRGB(_field[index].red  () / 255.f, 
00240                      _field[index].green() / 255.f, 
00241                      _field[index].blue () / 255.f);
00242 }
00243 
00244 template<> inline 
00245 void GeoProperty<GeoColors4ubPropertyDesc>::setValue(const Color3f &val,
00246                                                      const UInt32   index)
00247 {
00248     _field[index].setValuesRGBA(UInt8(val.red  () * 255.f),
00249                                 UInt8(val.green() * 255.f),
00250                                 UInt8(val.blue () * 255.f),
00251                                                     255  );
00252 }
00253 
00254 template<> inline 
00255 void GeoProperty<GeoColors4ubPropertyDesc>::addValue(const Color3f &val)
00256 {
00257     _field.push_back(Color4ub(UInt8(val.red  () * 255.f),
00258                               UInt8(val.green() * 255.f),
00259                               UInt8(val.blue () * 255.f),
00260                                                   255  ));
00261 }
00262 
00263 template <> inline
00264 bool GeoProperty<GeoColors4ubPropertyDesc>::insertValue(const Color3f &val,
00265                                                         const UInt32 index)
00266 {
00267     if(_field.size() < index)
00268     {
00269         return false;
00270     }
00271     else if(_field.size() == index)
00272     {
00273         addValue(val);
00274         return true;
00275     }
00276     else
00277     {
00278         _field.insert(_field.begin() + index, Color4ub(UInt8(val.red  () * 255.f),
00279                                                        UInt8(val.green() * 255.f),
00280                                                        UInt8(val.blue () * 255.f),
00281                                                                            255  ));
00282         return true;
00283     }
00284 }
00285 
00286 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00287 
00288 OSG_END_NAMESPACE

Generated on Thu Aug 25 04:05:23 2005 for OpenSG by  doxygen 1.4.3