00001 // @(#)root/gl:$Id: TGLPShapeRef.cxx 26394 2008-11-23 14:35:25Z matevz $ 00002 // Author: Matevz Tadel, Feb 2007 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 #include "TGLPShapeRef.h" 00013 #include "TGLPhysicalShape.h" 00014 00015 //______________________________________________________________________ 00016 // 00017 // Base class for references to TGLPysicalShape that need to be notified 00018 // when the shape is destroyed. 00019 // Could also deliver 'change' notifications. 00020 00021 ClassImp(TGLPShapeRef); 00022 00023 //______________________________________________________________________ 00024 TGLPShapeRef::TGLPShapeRef() : 00025 fNextPSRef (0), 00026 fPShape (0) 00027 { 00028 // Default contructor. 00029 } 00030 00031 //______________________________________________________________________ 00032 TGLPShapeRef::TGLPShapeRef(TGLPhysicalShape * shape) : 00033 fNextPSRef (0), 00034 fPShape (0) 00035 { 00036 // Constructor with known shape - reference it. 00037 00038 SetPShape(shape); 00039 } 00040 //______________________________________________________________________ 00041 TGLPShapeRef::~TGLPShapeRef() 00042 { 00043 // Destructor - unreference the shape if set. 00044 00045 SetPShape(0); 00046 } 00047 00048 //______________________________________________________________________ 00049 void TGLPShapeRef::SetPShape(TGLPhysicalShape * shape) 00050 { 00051 // Set the shape. Unreference the old and reference the new. 00052 // This is virtual so that sub-classes can perform other tasks 00053 // on change. This function should be called first from there. 00054 // 00055 // This is also called from destructor of the refereced physical 00056 // shape with 0 argument. 00057 00058 if (fPShape) 00059 fPShape->RemoveReference(this); 00060 fPShape = shape; 00061 if (fPShape) 00062 fPShape->AddReference(this); 00063 } 00064 00065 //______________________________________________________________________ 00066 void TGLPShapeRef::PShapeModified() 00067 { 00068 // This is called from physical shape when it is modified. 00069 // Sub-classes can override and take appropriate action. 00070 }