CMS 3D CMS Logo

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