1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGGEOVECTORPROPERTY_H_
40 #define _OSGGEOVECTORPROPERTY_H_
45 #include "OSGVector.h"
46 #include "OSGGeoVectorPropertyBase.h"
47 #include "OSGGeoVectorPropertyConversion.h"
53 /*! \brief GeoVectorProperty class. See \ref
54 PageDrawableGeoVectorProperty for a description.
55 \ingroup GrpDrawablesGeometryProperties
56 \ingroup GrpLibOSGDrawables
60 class OSG_SYSTEM_DLLMAPPING GeoVectorProperty
:
61 public GeoVectorPropertyBase
65 /*========================== PUBLIC =================================*/
69 typedef GeoVectorPropertyBase Inherited
;
71 /*---------------------------------------------------------------------*/
72 /*! \name Arbitrary Type Interface Methods */
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
85 getGenericValue(ival
, index
);
87 TypeTraits
<typename
ExternalType::ValueType
>::MathProp
==
90 GeoConvertNormalize::convertOut(eval
, ival
,
91 TypeTraits
<typename
ExternalType::ValueType
>::getMax(), 0);
95 GeoConvert::convertOut(eval
, ival
);
100 template <class ExternalType
>
101 void getValue(ExternalType
&eval
, const SizeT index
) const
104 getGenericValue(ival
, index
);
106 TypeTraits
<typename
ExternalType::ValueType
>::MathProp
==
109 GeoConvertNormalize::convertOut(eval
, ival
,
110 TypeTraits
<typename
ExternalType::ValueType
>::getMax(), 0);
114 GeoConvert::convertOut(eval
, ival
);
118 template <class ExternalType
>
119 void setValue(const ExternalType
&val
, const SizeT index
)
123 TypeTraits
<typename
ExternalType::ValueType
>::MathProp
==
126 GeoConvertNormalize::convertIn(ival
, val
,
127 TypeTraits
<typename
ExternalType::ValueType
>::getMax(), 0);
131 GeoConvert::convertIn(ival
, val
);
133 setGenericValue(ival
, index
);
136 template <class ExternalType
>
137 void addValue(const ExternalType
&val
)
142 template <class ExternalType
>
143 void push_back(const ExternalType
&val
)
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;
156 /*---------------------------------------------------------------------*/
160 virtual void changed(ConstFieldMaskArg whichField
,
165 /*---------------------------------------------------------------------*/
169 virtual void dump( UInt32 uiIndent
= 0,
170 const BitVector bvFlags
= 0) const;
173 /*---------------------------------------------------------------------*/
174 /*! \name Chunk Class Access */
177 virtual const StateChunkClass
* getClass (void) const;
180 /*---------------------------------------------------------------------*/
181 /*! \name Static Chunk Class Access */
184 inline static UInt32
getStaticClassId (void);
185 inline static const StateChunkClass
* getStaticClass (void);
188 /*---------------------------------------------------------------------*/
189 /*! \name State Commands */
192 virtual void activate (DrawEnv
*pEnv
,
195 virtual void changeFrom (DrawEnv
*pEnv
,
199 virtual void deactivate (DrawEnv
*pEnv
,
203 /*---------------------------------------------------------------------*/
204 /*! \name State Commands */
207 virtual void *mapBuffer (GLenum eAccess
, DrawEnv
*pEnv
);
208 virtual bool unmapBuffer( DrawEnv
*pEnv
);
211 /*========================= PROTECTED ===============================*/
215 // Variables should all be in GeoVectorPropertyBase.
217 /*---------------------------------------------------------------------*/
218 /*! \name Constructors */
221 GeoVectorProperty(void);
222 GeoVectorProperty(const GeoVectorProperty
&source
);
225 /*---------------------------------------------------------------------*/
226 /*! \name Destructors */
229 virtual ~GeoVectorProperty(void);
232 /*---------------------------------------------------------------------*/
233 /*! \name Generic Access */
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;
244 virtual GLenum
getBufferType(void); // buffer type for VBOs
246 static void initMethod(InitPhase ePhase
);
248 /*========================== 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;
265 #include "OSGGeoVectorPropertyBase.inl"
266 #include "OSGGeoVectorProperty.inl"
268 #endif /* _OSGGEOVECTORPROPERTY_H_ */