CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/Fireworks/Core/src/FWGeoTopNodeScene.cc

Go to the documentation of this file.
00001 #include "Fireworks/Core/src/FWGeoTopNodeScene.h"
00002 #include "Fireworks/Core/interface/FWGeoTopNode.h"
00003 #include "Fireworks/Core/interface/fwLog.h"
00004 #include "TGLSelectRecord.h"
00005 #include "TGLPhysicalShape.h"
00006 #include "TGLLogicalShape.h"
00007 #include "TGeoVolume.h"
00008 #include "TEveManager.h"
00009 #include "TEveSelection.h"
00010 #include "TBuffer3D.h"
00011 
00012 
00013 //______________________________________________________________________________
00014 FWGeoTopNodeGLScene::FWGeoTopNodeGLScene(TVirtualPad* pad) :
00015    TGLScenePad(pad),
00016    // fNextCompositeID(0),
00017    m_eveTopNode(0)
00018 {
00019    // Constructor.
00020    // fInternalPIDs = false;
00021    fTitle="GeoTopNodeScene";
00022 }
00023 
00024 //______________________________________________________________________________
00025 Bool_t FWGeoTopNodeGLScene::OpenCompositeWithPhyID(UInt_t phyID, const TBuffer3D& buffer)
00026 {
00027    // Open new composite container.
00028    // TVirtualViewer3D interface overload - see base/src/TVirtualViewer3D.cxx
00029    // for description of viewer architecture.
00030 
00031    if (fComposite) {
00032       Error("FWGeoTopNodeGLScene::OpenComposite", "composite already open");
00033       return kFALSE;
00034    }
00035 
00036    UInt_t extraSections = TGLScenePad::AddObject(phyID, buffer, 0);
00037    if (extraSections != TBuffer3D::kNone) {
00038       Error("FWGeoTopNodeGLScene::OpenComposite", "expected top level composite to not require extra buffer sections");
00039    }
00040 
00041    // If composite was created it is of interest - we want the rest of the
00042    // child components
00043    if (fComposite) {
00044       return kTRUE;
00045    } else {
00046       return kFALSE;
00047    }
00048 }
00049 
00050 //______________________________________________________________________________
00051 Int_t FWGeoTopNodeGLScene::AddObject(const TBuffer3D& buffer, Bool_t* addChildren)
00052 {
00053    if (fComposite)
00054    {
00055       // TGeoSubstraction, TGeoUnion, ... phyID ignored in this case
00056       int ns = TGLScenePad::AddObject(1, buffer, addChildren);
00057       return ns;
00058    }
00059    else
00060    {  
00061       fwLog(fwlog::kError)<< "FWGeoTopNodeGLScene::AddObject() should not be called if fNextCompositeID \n";
00062       return TGLScenePad::AddObject(buffer, addChildren);
00063    }
00064 }
00065 
00066 //______________________________________________________________________________
00067 Bool_t FWGeoTopNodeGLScene::ResolveSelectRecord(TGLSelectRecord& rec, Int_t curIdx)
00068 {
00069    // Process selection record rec.
00070    // 'curIdx' is the item position where the scene should start
00071    // its processing.
00072    // Return TRUE if an object has been identified or FALSE otherwise.
00073    // The scene-info member of the record is already set by the caller.  
00074 
00075    if (curIdx >= rec.GetN())
00076       return kFALSE;
00077 
00078    TGLPhysicalShape* pshp = FindPhysical(rec.GetItem(curIdx));
00079 
00080    /*
00081    printf("FWGeoTopNodeGLScene::ResolveSelectRecord pshp=%p, lshp=%p, obj=%p, shpcls=%s\n",
00082           (void*)pshp,(void*) pshp->GetLogical(),(void*) pshp->GetLogical()->GetExternal(),
00083           ((TGeoVolume*)pshp->GetLogical()->GetExternal())->GetShape()->ClassName());
00084    */
00085    if (pshp)
00086    {
00087       rec.SetTransparent(pshp->IsTransparent());
00088       rec.SetPhysShape(pshp);
00089 
00090 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,32,0)
00091       rec.SetLogShape(FindLogical(m_eveTopNode));
00092 #endif
00093       rec.SetObject(m_eveTopNode);
00094       rec.SetSpecific(0);
00095       return kTRUE;
00096    }
00097    return kFALSE;
00098 }
00099 
00100 //______________________________________________________________________________
00101 Int_t FWGeoTopNodeGLScene::DestroyPhysicals()
00102 {
00103    // Need to clear state on full redraw, else FWGeoTopNode ends
00104    // with invalid set of selected physical and logical ids.
00105 
00106    if (gEve->GetSelection()->HasChild( m_eveTopNode))
00107       gEve->GetSelection()->RemoveElement( m_eveTopNode);
00108 
00109    if (gEve->GetHighlight()->HasChild( m_eveTopNode))
00110       gEve->GetHighlight()->RemoveElement( m_eveTopNode);
00111 
00112 
00113    return TGLScene::DestroyPhysicals();
00114 }
00115 
00116 //______________________________________________________________________________
00117 Bool_t FWGeoTopNodeGLScene::DestroyPhysical(Int_t x)
00118 { 
00119    fwLog(fwlog::kInfo) << "FWGeoTopNodeGLScene::DestroyPhysical()\n"; 
00120    return TGLScene::DestroyPhysical(x);
00121 }
00122 
00123 //______________________________________________________________________________
00124 void FWGeoTopNodeGLScene::GeoPopupMenu(Int_t gx, Int_t gy, TGLViewer* v)
00125 {
00126    m_eveTopNode->popupMenu(gx, gy,v);
00127 }
00128 
00129 //==============================================================================
00130 //==============================================================================
00131 //==============================================================================
00132 #if ROOT_VERSION_CODE < ROOT_VERSION(5,32,0)
00133 
00134 #include "TEvePad.h"
00135 FWGeoTopNodeEveScene::FWGeoTopNodeEveScene(FWGeoTopNodeGLScene* gl_scene, const char* n, const char* t)
00136 {
00137    // Constructor.
00138 
00139    delete fGLScene;
00140 
00141    gl_scene->SetPad(fPad);
00142    fGLScene = gl_scene;
00143 
00144    fGLScene->SetName(n);
00145    fGLScene->SetAutoDestruct(kFALSE);
00146    fGLScene->SetSmartRefresh(kTRUE);
00147 }
00148 #endif