CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWGeoTopNodeScene.cc
Go to the documentation of this file.
4 #include "TGLSelectRecord.h"
5 #include "TGLPhysicalShape.h"
6 #include "TGLLogicalShape.h"
7 #include "TGeoVolume.h"
8 #include "TEveManager.h"
9 #include "TEveSelection.h"
10 #include "TBuffer3D.h"
11 
12 
13 //______________________________________________________________________________
15  TGLScenePad(pad),
16  // fNextCompositeID(0),
17  m_eveTopNode(0)
18 {
19  // Constructor.
20  // fInternalPIDs = false;
21  fTitle="GeoTopNodeScene";
22 }
23 
24 //______________________________________________________________________________
25 Bool_t FWGeoTopNodeGLScene::OpenCompositeWithPhyID(UInt_t phyID, const TBuffer3D& buffer)
26 {
27  // Open new composite container.
28  // TVirtualViewer3D interface overload - see base/src/TVirtualViewer3D.cxx
29  // for description of viewer architecture.
30 
31  if (fComposite) {
32  Error("FWGeoTopNodeGLScene::OpenComposite", "composite already open");
33  return kFALSE;
34  }
35 
36  UInt_t extraSections = TGLScenePad::AddObject(phyID, buffer, 0);
37  if (extraSections != TBuffer3D::kNone) {
38  Error("FWGeoTopNodeGLScene::OpenComposite", "expected top level composite to not require extra buffer sections");
39  }
40 
41  // If composite was created it is of interest - we want the rest of the
42  // child components
43  if (fComposite) {
44  return kTRUE;
45  } else {
46  return kFALSE;
47  }
48 }
49 
50 //______________________________________________________________________________
51 Int_t FWGeoTopNodeGLScene::AddObject(const TBuffer3D& buffer, Bool_t* addChildren)
52 {
53  if (fComposite)
54  {
55  // TGeoSubstraction, TGeoUnion, ... phyID ignored in this case
56  int ns = TGLScenePad::AddObject(1, buffer, addChildren);
57  return ns;
58  }
59  else
60  {
61  fwLog(fwlog::kError)<< "FWGeoTopNodeGLScene::AddObject() should not be called if fNextCompositeID \n";
62  return TGLScenePad::AddObject(buffer, addChildren);
63  }
64 }
65 
66 //______________________________________________________________________________
67 Bool_t FWGeoTopNodeGLScene::ResolveSelectRecord(TGLSelectRecord& rec, Int_t curIdx)
68 {
69  // Process selection record rec.
70  // 'curIdx' is the item position where the scene should start
71  // its processing.
72  // Return TRUE if an object has been identified or FALSE otherwise.
73  // The scene-info member of the record is already set by the caller.
74 
75  if (curIdx >= rec.GetN())
76  return kFALSE;
77 
78  TGLPhysicalShape* pshp = FindPhysical(rec.GetItem(curIdx));
79 
80  /*
81  printf("FWGeoTopNodeGLScene::ResolveSelectRecord pshp=%p, lshp=%p, obj=%p, shpcls=%s\n",
82  (void*)pshp,(void*) pshp->GetLogical(),(void*) pshp->GetLogical()->GetExternal(),
83  ((TGeoVolume*)pshp->GetLogical()->GetExternal())->GetShape()->ClassName());
84  */
85  if (pshp)
86  {
87  rec.SetTransparent(pshp->IsTransparent());
88  rec.SetPhysShape(pshp);
89 
90 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,32,0)
91  rec.SetLogShape(FindLogical(m_eveTopNode));
92 #endif
93  rec.SetObject(m_eveTopNode);
94  rec.SetSpecific(0);
95  return kTRUE;
96  }
97  return kFALSE;
98 }
99 
100 //______________________________________________________________________________
102 {
103  // Need to clear state on full redraw, else FWGeoTopNode ends
104  // with invalid set of selected physical and logical ids.
105 
106  if (gEve->GetSelection()->HasChild( m_eveTopNode))
107  gEve->GetSelection()->RemoveElement( m_eveTopNode);
108 
109  if (gEve->GetHighlight()->HasChild( m_eveTopNode))
110  gEve->GetHighlight()->RemoveElement( m_eveTopNode);
111 
112 
113  return TGLScene::DestroyPhysicals();
114 }
115 
116 //______________________________________________________________________________
118 {
119  fwLog(fwlog::kInfo) << "FWGeoTopNodeGLScene::DestroyPhysical()\n";
120  return TGLScene::DestroyPhysical(x);
121 }
122 
123 //______________________________________________________________________________
124 void FWGeoTopNodeGLScene::GeoPopupMenu(Int_t gx, Int_t gy, TGLViewer* v)
125 {
126  m_eveTopNode->popupMenu(gx, gy,v);
127 }
128 
129 //==============================================================================
130 //==============================================================================
131 //==============================================================================
132 #if ROOT_VERSION_CODE < ROOT_VERSION(5,32,0)
133 
134 #include "TEvePad.h"
135 FWGeoTopNodeEveScene::FWGeoTopNodeEveScene(FWGeoTopNodeGLScene* gl_scene, const char* n, const char* t)
136 {
137  // Constructor.
138 
139  delete fGLScene;
140 
141  gl_scene->SetPad(fPad);
142  fGLScene = gl_scene;
143 
144  fGLScene->SetName(n);
145  fGLScene->SetAutoDestruct(kFALSE);
146  fGLScene->SetSmartRefresh(kTRUE);
147 }
148 #endif
void GeoPopupMenu(Int_t gx, Int_t gy, TGLViewer *)
FWGeoTopNode * m_eveTopNode
virtual Bool_t DestroyPhysical(Int_t)
bool OpenCompositeWithPhyID(UInt_t phyID, const TBuffer3D &buffer)
virtual Int_t AddObject(const TBuffer3D &buffer, Bool_t *addChildren=0)
virtual Bool_t ResolveSelectRecord(TGLSelectRecord &rec, Int_t curIdx)
virtual void popupMenu(int x, int y, TGLViewer *)
Definition: FWGeoTopNode.h:80
unsigned int UInt_t
Definition: FUTypes.h:12
#define fwLog(_level_)
Definition: fwLog.h:51
void SetPad(TVirtualPad *p)
virtual Int_t DestroyPhysicals()
Definition: DDAxes.h:10
mathSSE::Vec4< T > v
FWGeoTopNodeGLScene(const FWGeoTopNodeGLScene &)