fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / NodeCores / Drawables / Geometry / PropertiesBase / OSGGeoVectorProperty.h
blob03daab03d3272dae22d4db6c7e044df8bcd47a3c
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGGEOVECTORPROPERTY_H_
40 #define _OSGGEOVECTORPROPERTY_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGVector.h"
46 #include "OSGGeoVectorPropertyBase.h"
47 #include "OSGGeoVectorPropertyConversion.h"
49 OSG_BEGIN_NAMESPACE
51 class DrawEnv;
53 /*! \brief GeoVectorProperty class. See \ref
54 PageDrawableGeoVectorProperty for a description.
55 \ingroup GrpDrawablesGeometryProperties
56 \ingroup GrpLibOSGDrawables
57 \includebasedoc
60 class OSG_SYSTEM_DLLMAPPING GeoVectorProperty :
61 public GeoVectorPropertyBase
63 private:
65 /*========================== PUBLIC =================================*/
67 public:
69 typedef GeoVectorPropertyBase Inherited;
71 /*---------------------------------------------------------------------*/
72 /*! \name Arbitrary Type Interface Methods */
73 /*! \{ */
75 typedef Vec4d MaxTypeT;
77 // MSVC 7.0 is a little weird about template member methods, that's why
78 // the code has to be here...
80 template <class ExternalType>
81 ExternalType getValue(const SizeT index) const
83 ExternalType eval;
84 MaxTypeT ival;
85 getGenericValue(ival, index);
86 if(getNormalize() &&
87 TypeTraits<typename ExternalType::ValueType>::MathProp ==
88 IntValue)
90 GeoConvertNormalize::convertOut(eval, ival,
91 TypeTraits<typename ExternalType::ValueType>::getMax(), 0);
93 else
95 GeoConvert::convertOut(eval, ival);
97 return eval;
100 template <class ExternalType>
101 void getValue(ExternalType &eval, const SizeT index) const
103 MaxTypeT ival;
104 getGenericValue(ival, index);
105 if(getNormalize() &&
106 TypeTraits<typename ExternalType::ValueType>::MathProp ==
107 IntValue)
109 GeoConvertNormalize::convertOut(eval, ival,
110 TypeTraits<typename ExternalType::ValueType>::getMax(), 0);
112 else
114 GeoConvert::convertOut(eval, ival);
118 template <class ExternalType>
119 void setValue(const ExternalType &val, const SizeT index)
121 MaxTypeT ival;
122 if(getNormalize() &&
123 TypeTraits<typename ExternalType::ValueType>::MathProp ==
124 IntValue)
126 GeoConvertNormalize::convertIn(ival, val,
127 TypeTraits<typename ExternalType::ValueType>::getMax(), 0);
129 else
131 GeoConvert::convertIn(ival, val);
133 setGenericValue(ival, index);
136 template <class ExternalType>
137 void addValue(const ExternalType &val)
139 push_back(val);
142 template <class ExternalType>
143 void push_back(const ExternalType &val)
145 resize(size() + 1);
146 setValue(val, size() - 1);
149 virtual bool getNormalize(void ) const = 0;
150 virtual void clear (void ) = 0;
151 virtual void resize (SizeT newsize) = 0;
152 virtual SizeT size (void ) const = 0;
153 virtual UInt32 size32 (void ) const = 0;
155 /*! \} */
156 /*---------------------------------------------------------------------*/
157 /*! \name Sync */
158 /*! \{ */
160 virtual void changed(ConstFieldMaskArg whichField,
161 UInt32 origin,
162 BitVector detail);
164 /*! \} */
165 /*---------------------------------------------------------------------*/
166 /*! \name Output */
167 /*! \{ */
169 virtual void dump( UInt32 uiIndent = 0,
170 const BitVector bvFlags = 0) const;
172 /*! \} */
173 /*---------------------------------------------------------------------*/
174 /*! \name Chunk Class Access */
175 /*! \{ */
177 virtual const StateChunkClass * getClass (void) const;
179 /*! \} */
180 /*---------------------------------------------------------------------*/
181 /*! \name Static Chunk Class Access */
182 /*! \{ */
184 inline static UInt32 getStaticClassId (void);
185 inline static const StateChunkClass * getStaticClass (void);
187 /*! \} */
188 /*---------------------------------------------------------------------*/
189 /*! \name State Commands */
190 /*! \{ */
192 virtual void activate (DrawEnv *pEnv,
193 UInt32 index = 0);
195 virtual void changeFrom (DrawEnv *pEnv,
196 StateChunk *old,
197 UInt32 index = 0);
199 virtual void deactivate (DrawEnv *pEnv,
200 UInt32 index = 0);
202 /*! \} */
203 /*---------------------------------------------------------------------*/
204 /*! \name State Commands */
205 /*! \{ */
207 virtual void *mapBuffer (GLenum eAccess, DrawEnv *pEnv);
208 virtual bool unmapBuffer( DrawEnv *pEnv);
210 /*! \} */
211 /*========================= PROTECTED ===============================*/
213 protected:
215 // Variables should all be in GeoVectorPropertyBase.
217 /*---------------------------------------------------------------------*/
218 /*! \name Constructors */
219 /*! \{ */
221 GeoVectorProperty(void);
222 GeoVectorProperty(const GeoVectorProperty &source);
224 /*! \} */
225 /*---------------------------------------------------------------------*/
226 /*! \name Destructors */
227 /*! \{ */
229 virtual ~GeoVectorProperty(void);
231 /*! \} */
232 /*---------------------------------------------------------------------*/
233 /*! \name Generic Access */
234 /*! \{ */
236 // This is the fallback, it has to be implemented by the concrete Props!
237 virtual void getGenericValue( MaxTypeT &val,
238 const SizeT index ) const = 0;
239 virtual void setGenericValue(const MaxTypeT &val,
240 const SizeT index ) = 0;
242 /*! \} */
244 virtual GLenum getBufferType(void); // buffer type for VBOs
246 static void initMethod(InitPhase ePhase);
248 /*========================== PRIVATE ================================*/
249 private:
251 friend class FieldContainer;
252 friend class GeoVectorPropertyBase;
254 // prohibit default functions (move to 'public' if you need one)
255 void operator =(const GeoVectorProperty &source);
258 typedef GeoVectorProperty *GeoVectorPropertyP;
260 //typedef GeoVectorProperty::ObjPtr GeoVectorPropertyPtr;
261 //typedef GeoVectorProperty::ConstObjPtr ConstGeoVectorPropertyPtr;
263 OSG_END_NAMESPACE
265 #include "OSGGeoVectorPropertyBase.inl"
266 #include "OSGGeoVectorProperty.inl"
268 #endif /* _OSGGEOVECTORPROPERTY_H_ */