fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / GraphOp / OSGMakeTransparentGraphOp.h
blob27ce8215e2ab27c1e9beda33e1b63150018b2516
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 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 \*---------------------------------------------------------------------------*/
40 #ifndef _OSGMAKETRANSPARENTGRAPHOP_H_
41 #define _OSGMAKETRANSPARENTGRAPHOP_H_
42 #ifdef __sgi
43 #pragma once
44 #endif
46 #include <list>
47 #include <map>
49 #include "OSGGraphOp.h"
50 #include "OSGUtilDef.h"
51 #include "OSGAction.h"
52 #include "OSGMaterialDrawable.h"
53 #include "OSGMaterialGroup.h"
55 OSG_BEGIN_NAMESPACE
57 /*! \ingroup GrpUtilGraphOp
58 \ingroup GrpLibOSGUtil
61 class OSG_UTIL_DLLMAPPING MakeTransparentGraphOp : public GraphOp
64 public:
66 /*---------------------------------------------------------------------*/
67 /*! \name Types */
68 /*! \{ */
70 typedef GraphOp Inherited;
71 typedef MakeTransparentGraphOp Self;
73 OSG_GEN_INTERNAL_MEMOBJPTR(MakeTransparentGraphOp);
75 /*! \nohierarchy
77 class MaterialObject
79 public:
80 MaterialObject(MaterialDrawable *md)
81 : _md(md ),
82 _mg(NULL)
86 MaterialObject(MaterialGroup *mg)
87 : _md(NULL),
88 _mg(mg )
92 Material *getMaterial(void)
94 return (_md != NULL ? _md->getMaterial() : _mg->getMaterial());
97 void setMaterial(Material *mat)
99 if(_md != NULL)
101 _md->setMaterial(mat);
103 else
105 _mg->setMaterial(mat);
109 private:
110 MaterialDrawable *_md;
111 MaterialGroup *_mg;
114 /*! \} */
115 /*---------------------------------------------------------------------*/
116 /*! \name Classname */
117 /*! \{ */
119 static const char *getClassname(void) { return "MakeTransparentGraphOp"; };
121 /*! \} */
122 /*---------------------------------------------------------------------*/
123 /*! \name Constructors */
124 /*! \{ */
126 static ObjTransitPtr create(void);
128 virtual GraphOpTransitPtr clone (void);
130 /*! \} */
131 /*---------------------------------------------------------------------*/
132 /*! \name Main methods */
133 /*! \{ */
135 virtual bool traverse(Node *node);
137 /*! \} */
138 /*---------------------------------------------------------------------*/
139 /*! \name Parameters */
140 /*! \{ */
142 void setParams(const std::string params);
144 std::string usage(void);
146 /*! \} */
147 /*========================= PROTECTED ===============================*/
149 protected:
151 /*---------------------------------------------------------------------*/
152 /*! \name Constructors/Destructor */
153 /*! \{ */
155 MakeTransparentGraphOp(const char* name = "MakeTransparent");
156 virtual ~MakeTransparentGraphOp(void );
158 /*! \} */
159 /*========================== PRIVATE ================================*/
161 private:
163 Action::ResultE traverseEnter(Node * const node);
164 Action::ResultE traverseLeave(Node * const node, Action::ResultE res);
166 void addObject (MaterialObject m);
167 void applyTransparency(Material *m);
169 typedef std::list<MaterialObject > MaterialObjectList;
170 typedef std::map <MaterialUnrecPtr, MaterialObjectList> MaterialObjectMap;
172 MaterialObjectMap _materialMap;
173 Real32 _transparency;
176 OSG_GEN_MEMOBJPTR(MakeTransparentGraphOp);
178 OSG_END_NAMESPACE
180 #endif