ROOT logo
// @(#)root/geom:$Id: TGeoPhysicalNode.h 25123 2008-08-12 09:59:46Z brun $
// Author: Andrei Gheata   17/02/04

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGeoPhysicalNode
#define ROOT_TGeoPhysicalNode

#ifndef ROOT_TNamed
#include "TNamed.h"
#endif

#ifndef ROOT_TObjArray
#include "TObjArray.h"
#endif

#ifndef ROOT_TAttLine
#include "TAttLine.h"
#endif

// forward declarations
class TGeoHMatrix;
class TGeoMatrix;
class TGeoVolume;
class TGeoNode;
class TGeoShape;

//////////////////////////////////////////////////////////////////////////////
//                                                                          //
// TGeoPhysicalNode - class representing an unique object associated with a //
//   path.                                                                  //
//                                                                          //
//////////////////////////////////////////////////////////////////////////////

class TGeoPhysicalNode : public TNamed,
                         public TAttLine
{
protected:
   Int_t             fLevel;          // depth in the geometry tree
   TObjArray        *fMatrices;       // global transformation matrices
   TObjArray        *fNodes;          // branch of nodes
   TGeoHMatrix      *fMatrixOrig;     // original local matrix of the last node in the path

   TGeoPhysicalNode(const TGeoPhysicalNode&); 
   TGeoPhysicalNode& operator=(const TGeoPhysicalNode&);

   void              SetAligned(Bool_t flag=kTRUE) {TObject::SetBit(kGeoPNodeAligned,flag);}
   Bool_t            SetPath(const char *path);
   void              SetBranchAsState();

public:
   enum {
      kGeoPNodeFull    = BIT(10),     // full branch is visible (default only last node)
      kGeoPNodeVisible = BIT(11),     // this node is visible (default)
      kGeoPNodeVolAtt  = BIT(12),     // preserve volume attributes (default)
      kGeoPNodeAligned = BIT(13)      // alignment bit
   };

   // constructors
   TGeoPhysicalNode();
   TGeoPhysicalNode(const char *path);
   // destructor
   virtual ~TGeoPhysicalNode();

   void              Align(TGeoMatrix *newmat=0, TGeoShape *newshape=0, Bool_t check=kFALSE, Double_t ovlp=0.001);
   void              cd() const;
   void              Draw(Option_t *option="");
   Int_t             GetLevel() const {return fLevel;}
   TGeoHMatrix      *GetMatrix(Int_t level=-1) const;
   TGeoHMatrix      *GetOriginalMatrix() const {return fMatrixOrig;}
   TGeoNode         *GetMother(Int_t levup=1) const;
   TGeoNode         *GetNode(Int_t level=-1) const;
   TGeoShape        *GetShape(Int_t level=-1) const;
   TGeoVolume       *GetVolume(Int_t level=-1) const;
   
 
   Bool_t            IsAligned() const {return TObject::TestBit(kGeoPNodeAligned);}
   Bool_t            IsVolAttributes() const {return TObject::TestBit(kGeoPNodeVolAtt);}
   Bool_t            IsVisible() const {return TObject::TestBit(kGeoPNodeVisible);}
   Bool_t            IsVisibleFull() const {return TObject::TestBit(kGeoPNodeFull);}

   virtual void      Print(Option_t *option="") const;
   void              Refresh();

   void              SetMatrixOrig(const TGeoMatrix *local);
   void              SetIsVolAtt(Bool_t flag=kTRUE) {TObject::SetBit(kGeoPNodeVolAtt,flag);}
   void              SetVisibility(Bool_t flag=kTRUE)  {TObject::SetBit(kGeoPNodeVisible,flag);}
   void              SetVisibleFull(Bool_t flag=kTRUE) {TObject::SetBit(kGeoPNodeFull,flag);}
   virtual void      Paint(Option_t *option = "");


   ClassDef(TGeoPhysicalNode, 1)               // base class for physical nodes
};

///////////////////////////////////////////////////////////////////////////////
//                                                                           //
// TGeoPNEntry - class representing phisical node entry having a unique name //
//   associated to a path.                                                   //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////

class TGeoPNEntry : public TNamed
{
private:
   enum EPNEntryFlags {
      kPNEntryOwnMatrix = BIT(14)
   };   
   TGeoPhysicalNode   *fNode;        // Physical node to which this applies
   const TGeoHMatrix  *fMatrix;      // Additional matrix
   TGeoHMatrix        *fGlobalOrig;  // Original global matrix for the linked physical node

protected:
   TGeoPNEntry(const TGeoPNEntry& pne) 
     : TNamed(pne), fNode(pne.fNode), fMatrix(NULL), fGlobalOrig(NULL) { }
   TGeoPNEntry& operator=(const TGeoPNEntry& pne)
     {if(this!=&pne) {TNamed::operator=(pne); fNode=pne.fNode; fMatrix=pne.fMatrix;}
     return *this;}

public:
   TGeoPNEntry();
   TGeoPNEntry(const char *unique_name, const char *path);
   virtual ~TGeoPNEntry();
   
   inline const char   *GetPath() const {return GetTitle();}
   const TGeoHMatrix   *GetMatrix() const {return fMatrix;}
   TGeoHMatrix      *GetMatrixOrig() const {if (fNode) return fNode->GetOriginalMatrix(); else return NULL;};
   TGeoHMatrix      *GetGlobalOrig() const {return fGlobalOrig;}
   TGeoPhysicalNode *GetPhysicalNode() const {return fNode;}
   void              SetMatrix(const TGeoHMatrix *matrix);
   void              SetPhysicalNode(TGeoPhysicalNode *node);
   
   ClassDef(TGeoPNEntry, 4)                  // a physical node entry with unique name
};

#endif

 TGeoPhysicalNode.h:1
 TGeoPhysicalNode.h:2
 TGeoPhysicalNode.h:3
 TGeoPhysicalNode.h:4
 TGeoPhysicalNode.h:5
 TGeoPhysicalNode.h:6
 TGeoPhysicalNode.h:7
 TGeoPhysicalNode.h:8
 TGeoPhysicalNode.h:9
 TGeoPhysicalNode.h:10
 TGeoPhysicalNode.h:11
 TGeoPhysicalNode.h:12
 TGeoPhysicalNode.h:13
 TGeoPhysicalNode.h:14
 TGeoPhysicalNode.h:15
 TGeoPhysicalNode.h:16
 TGeoPhysicalNode.h:17
 TGeoPhysicalNode.h:18
 TGeoPhysicalNode.h:19
 TGeoPhysicalNode.h:20
 TGeoPhysicalNode.h:21
 TGeoPhysicalNode.h:22
 TGeoPhysicalNode.h:23
 TGeoPhysicalNode.h:24
 TGeoPhysicalNode.h:25
 TGeoPhysicalNode.h:26
 TGeoPhysicalNode.h:27
 TGeoPhysicalNode.h:28
 TGeoPhysicalNode.h:29
 TGeoPhysicalNode.h:30
 TGeoPhysicalNode.h:31
 TGeoPhysicalNode.h:32
 TGeoPhysicalNode.h:33
 TGeoPhysicalNode.h:34
 TGeoPhysicalNode.h:35
 TGeoPhysicalNode.h:36
 TGeoPhysicalNode.h:37
 TGeoPhysicalNode.h:38
 TGeoPhysicalNode.h:39
 TGeoPhysicalNode.h:40
 TGeoPhysicalNode.h:41
 TGeoPhysicalNode.h:42
 TGeoPhysicalNode.h:43
 TGeoPhysicalNode.h:44
 TGeoPhysicalNode.h:45
 TGeoPhysicalNode.h:46
 TGeoPhysicalNode.h:47
 TGeoPhysicalNode.h:48
 TGeoPhysicalNode.h:49
 TGeoPhysicalNode.h:50
 TGeoPhysicalNode.h:51
 TGeoPhysicalNode.h:52
 TGeoPhysicalNode.h:53
 TGeoPhysicalNode.h:54
 TGeoPhysicalNode.h:55
 TGeoPhysicalNode.h:56
 TGeoPhysicalNode.h:57
 TGeoPhysicalNode.h:58
 TGeoPhysicalNode.h:59
 TGeoPhysicalNode.h:60
 TGeoPhysicalNode.h:61
 TGeoPhysicalNode.h:62
 TGeoPhysicalNode.h:63
 TGeoPhysicalNode.h:64
 TGeoPhysicalNode.h:65
 TGeoPhysicalNode.h:66
 TGeoPhysicalNode.h:67
 TGeoPhysicalNode.h:68
 TGeoPhysicalNode.h:69
 TGeoPhysicalNode.h:70
 TGeoPhysicalNode.h:71
 TGeoPhysicalNode.h:72
 TGeoPhysicalNode.h:73
 TGeoPhysicalNode.h:74
 TGeoPhysicalNode.h:75
 TGeoPhysicalNode.h:76
 TGeoPhysicalNode.h:77
 TGeoPhysicalNode.h:78
 TGeoPhysicalNode.h:79
 TGeoPhysicalNode.h:80
 TGeoPhysicalNode.h:81
 TGeoPhysicalNode.h:82
 TGeoPhysicalNode.h:83
 TGeoPhysicalNode.h:84
 TGeoPhysicalNode.h:85
 TGeoPhysicalNode.h:86
 TGeoPhysicalNode.h:87
 TGeoPhysicalNode.h:88
 TGeoPhysicalNode.h:89
 TGeoPhysicalNode.h:90
 TGeoPhysicalNode.h:91
 TGeoPhysicalNode.h:92
 TGeoPhysicalNode.h:93
 TGeoPhysicalNode.h:94
 TGeoPhysicalNode.h:95
 TGeoPhysicalNode.h:96
 TGeoPhysicalNode.h:97
 TGeoPhysicalNode.h:98
 TGeoPhysicalNode.h:99
 TGeoPhysicalNode.h:100
 TGeoPhysicalNode.h:101
 TGeoPhysicalNode.h:102
 TGeoPhysicalNode.h:103
 TGeoPhysicalNode.h:104
 TGeoPhysicalNode.h:105
 TGeoPhysicalNode.h:106
 TGeoPhysicalNode.h:107
 TGeoPhysicalNode.h:108
 TGeoPhysicalNode.h:109
 TGeoPhysicalNode.h:110
 TGeoPhysicalNode.h:111
 TGeoPhysicalNode.h:112
 TGeoPhysicalNode.h:113
 TGeoPhysicalNode.h:114
 TGeoPhysicalNode.h:115
 TGeoPhysicalNode.h:116
 TGeoPhysicalNode.h:117
 TGeoPhysicalNode.h:118
 TGeoPhysicalNode.h:119
 TGeoPhysicalNode.h:120
 TGeoPhysicalNode.h:121
 TGeoPhysicalNode.h:122
 TGeoPhysicalNode.h:123
 TGeoPhysicalNode.h:124
 TGeoPhysicalNode.h:125
 TGeoPhysicalNode.h:126
 TGeoPhysicalNode.h:127
 TGeoPhysicalNode.h:128
 TGeoPhysicalNode.h:129
 TGeoPhysicalNode.h:130
 TGeoPhysicalNode.h:131
 TGeoPhysicalNode.h:132
 TGeoPhysicalNode.h:133
 TGeoPhysicalNode.h:134
 TGeoPhysicalNode.h:135
 TGeoPhysicalNode.h:136
 TGeoPhysicalNode.h:137
 TGeoPhysicalNode.h:138
 TGeoPhysicalNode.h:139
 TGeoPhysicalNode.h:140
 TGeoPhysicalNode.h:141
 TGeoPhysicalNode.h:142