Logo ROOT   6.14/05
Reference Guide
TGLPShapeRef.cxx
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Matevz Tadel, Feb 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TGLPShapeRef.h"
13 #include "TGLPhysicalShape.h"
14 
15 /** \class TGLPShapeRef
16 \ingroup opengl
17 Base class for references to TGLPysicalShape that need to be notified
18 when the shape is destroyed.
19 Could also deliver 'change' notifications.
20 */
21 
23 
24 ////////////////////////////////////////////////////////////////////////////////
25 /// Default constructor.
26 
28  fNextPSRef (0),
29  fPShape (0)
30 {
31 }
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 /// Constructor with known shape - reference it.
35 
37  fNextPSRef (0),
38  fPShape (0)
39 {
40  SetPShape(shape);
41 }
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Destructor - unreference the shape if set.
44 
46 {
47  SetPShape(0);
48 }
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// Set the shape. Unreference the old and reference the new.
52 /// This is virtual so that sub-classes can perform other tasks
53 /// on change. This function should be called first from there.
54 ///
55 /// This is also called from destructor of the referenced physical
56 /// shape with 0 argument.
57 
59 {
60  if (fPShape)
61  fPShape->RemoveReference(this);
62  fPShape = shape;
63  if (fPShape)
64  fPShape->AddReference(this);
65 }
66 
67 ////////////////////////////////////////////////////////////////////////////////
68 /// This is called from physical shape when it is modified.
69 /// Sub-classes can override and take appropriate action.
70 
72 {
73 }
Concrete physical shape - a GL drawable.
virtual void PShapeModified()
This is called from physical shape when it is modified.
Base class for references to TGLPysicalShape that need to be notified when the shape is destroyed...
Definition: TGLPShapeRef.h:19
virtual ~TGLPShapeRef()
Destructor - unreference the shape if set.
virtual void SetPShape(TGLPhysicalShape *shape)
Set the shape.
#define ClassImp(name)
Definition: Rtypes.h:359
void AddReference(TGLPShapeRef *ref)
Add reference ref.
TGLPhysicalShape * fPShape
Definition: TGLPShapeRef.h:29
void RemoveReference(TGLPShapeRef *ref)
Remove reference ref.
TGLPShapeRef * fNextPSRef
Definition: TGLPShapeRef.h:26
TGLPShapeRef()
Default constructor.