File indexing completed on 2024-04-06 12:11:39
0001 #include "Fireworks/Core/src/FWGeoTopNodeScene.h"
0002 #include "Fireworks/Core/interface/FWGeoTopNode.h"
0003 #include "Fireworks/Core/interface/fwLog.h"
0004 #include "TGLSelectRecord.h"
0005 #include "TGLPhysicalShape.h"
0006 #include "TGLLogicalShape.h"
0007 #include "TGeoVolume.h"
0008 #include "TEveManager.h"
0009 #include "TEveSelection.h"
0010 #include "TBuffer3D.h"
0011
0012
0013 FWGeoTopNodeGLScene::FWGeoTopNodeGLScene(TVirtualPad* pad)
0014 : TGLScenePad(pad),
0015
0016 m_eveTopNode(nullptr) {
0017
0018
0019 fTitle = "GeoTopNodeScene";
0020 }
0021
0022
0023 Bool_t FWGeoTopNodeGLScene::OpenCompositeWithPhyID(UInt_t phyID, const TBuffer3D& buffer) {
0024
0025
0026
0027
0028 if (fComposite) {
0029 Error("FWGeoTopNodeGLScene::OpenComposite", "composite already open");
0030 return kFALSE;
0031 }
0032
0033 UInt_t extraSections = TGLScenePad::AddObject(phyID, buffer, nullptr);
0034 if (extraSections != TBuffer3D::kNone) {
0035 Error("FWGeoTopNodeGLScene::OpenComposite", "expected top level composite to not require extra buffer sections");
0036 }
0037
0038
0039
0040 if (fComposite) {
0041 return kTRUE;
0042 } else {
0043 return kFALSE;
0044 }
0045 }
0046
0047
0048 Int_t FWGeoTopNodeGLScene::AddObject(const TBuffer3D& buffer, Bool_t* addChildren) {
0049 if (fComposite) {
0050
0051 int ns = TGLScenePad::AddObject(1, buffer, addChildren);
0052 return ns;
0053 } else {
0054 fwLog(fwlog::kError) << "FWGeoTopNodeGLScene::AddObject() should not be called if fNextCompositeID \n";
0055 return TGLScenePad::AddObject(buffer, addChildren);
0056 }
0057 }
0058
0059
0060 Bool_t FWGeoTopNodeGLScene::ResolveSelectRecord(TGLSelectRecord& rec, Int_t curIdx) {
0061
0062
0063
0064
0065
0066
0067 if (curIdx >= rec.GetN())
0068 return kFALSE;
0069
0070 TGLPhysicalShape* pshp = FindPhysical(rec.GetItem(curIdx));
0071
0072
0073
0074
0075
0076
0077 if (pshp) {
0078 rec.SetTransparent(pshp->IsTransparent());
0079 rec.SetPhysShape(pshp);
0080
0081 #if ROOT_VERSION_CODE >= ROOT_VERSION(5, 32, 0)
0082 rec.SetLogShape(FindLogical(m_eveTopNode));
0083 #endif
0084 rec.SetObject(m_eveTopNode);
0085 rec.SetSpecific(nullptr);
0086 return kTRUE;
0087 }
0088 return kFALSE;
0089 }
0090
0091
0092 Int_t FWGeoTopNodeGLScene::DestroyPhysicals() {
0093
0094
0095
0096 if (gEve->GetSelection()->HasChild(m_eveTopNode))
0097 gEve->GetSelection()->RemoveElement(m_eveTopNode);
0098
0099 if (gEve->GetHighlight()->HasChild(m_eveTopNode))
0100 gEve->GetHighlight()->RemoveElement(m_eveTopNode);
0101
0102 return TGLScene::DestroyPhysicals();
0103 }
0104
0105
0106 Bool_t FWGeoTopNodeGLScene::DestroyPhysical(Int_t x) {
0107 fwLog(fwlog::kInfo) << "FWGeoTopNodeGLScene::DestroyPhysical()\n";
0108 return TGLScene::DestroyPhysical(x);
0109 }
0110
0111
0112 void FWGeoTopNodeGLScene::GeoPopupMenu(Int_t gx, Int_t gy, TGLViewer* v) { m_eveTopNode->popupMenu(gx, gy, v); }
0113
0114
0115
0116
0117 #if ROOT_VERSION_CODE < ROOT_VERSION(5, 32, 0)
0118
0119 #include "TEvePad.h"
0120 FWGeoTopNodeEveScene::FWGeoTopNodeEveScene(FWGeoTopNodeGLScene* gl_scene, const char* n, const char* t) {
0121
0122
0123 delete fGLScene;
0124
0125 gl_scene->SetPad(fPad);
0126 fGLScene = gl_scene;
0127
0128 fGLScene->SetName(n);
0129 fGLScene->SetAutoDestruct(kFALSE);
0130 fGLScene->SetSmartRefresh(kTRUE);
0131 }
0132 #endif