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