Back to home page

Project CMSSW displayed by LXR

 
 

    


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       // fNextCompositeID(0),
0016       m_eveTopNode(nullptr) {
0017   // Constructor.
0018   // fInternalPIDs = false;
0019   fTitle = "GeoTopNodeScene";
0020 }
0021 
0022 //______________________________________________________________________________
0023 Bool_t FWGeoTopNodeGLScene::OpenCompositeWithPhyID(UInt_t phyID, const TBuffer3D& buffer) {
0024   // Open new composite container.
0025   // TVirtualViewer3D interface overload - see base/src/TVirtualViewer3D.cxx
0026   // for description of viewer architecture.
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   // If composite was created it is of interest - we want the rest of the
0039   // child components
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     // TGeoSubstraction, TGeoUnion, ... phyID ignored in this case
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   // Process selection record rec.
0062   // 'curIdx' is the item position where the scene should start
0063   // its processing.
0064   // Return TRUE if an object has been identified or FALSE otherwise.
0065   // The scene-info member of the record is already set by the caller.
0066 
0067   if (curIdx >= rec.GetN())
0068     return kFALSE;
0069 
0070   TGLPhysicalShape* pshp = FindPhysical(rec.GetItem(curIdx));
0071 
0072   /*
0073    printf("FWGeoTopNodeGLScene::ResolveSelectRecord pshp=%p, lshp=%p, obj=%p, shpcls=%s\n",
0074           (void*)pshp,(void*) pshp->GetLogical(),(void*) pshp->GetLogical()->GetExternal(),
0075           ((TGeoVolume*)pshp->GetLogical()->GetExternal())->GetShape()->ClassName());
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   // Need to clear state on full redraw, else FWGeoTopNode ends
0094   // with invalid set of selected physical and logical ids.
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   // Constructor.
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