CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/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 
00005 #include "TGLSelectRecord.h"
00006 #include "TGLPhysicalShape.h"
00007 #include "TGLLogicalShape.h"
00008 #include "TGeoVolume.h"
00009 #include "TBuffer3D.h"
00010 
00011 
00012 //______________________________________________________________________________
00013 FWGeoTopNodeGLScene::FWGeoTopNodeGLScene(TVirtualPad* pad) :
00014    TGLScenePad(pad),
00015    // fNextCompositeID(0),
00016    fTopNodeJebo(0)
00017 {
00018    // Constructor.
00019    // fInternalPIDs = false;
00020    fTitle="JeboScene";
00021 }
00022 
00023 //______________________________________________________________________________
00024 Bool_t FWGeoTopNodeGLScene::OpenCompositeWithPhyID(UInt_t phyID, const TBuffer3D& buffer)
00025 {
00026    // Open new composite container.
00027    // TVirtualViewer3D interface overload - see base/src/TVirtualViewer3D.cxx
00028    // for description of viewer architecture.
00029 
00030    if (fComposite) {
00031       Error("FWGeoTopNodeGLScene::OpenComposite", "composite already open");
00032       return kFALSE;
00033    }
00034 
00035    UInt_t extraSections = TGLScenePad::AddObject(phyID, buffer, 0);
00036    if (extraSections != TBuffer3D::kNone) {
00037       Error("FWGeoTopNodeGLScene::OpenComposite", "expected top level composite to not require extra buffer sections");
00038    }
00039 
00040    // If composite was created it is of interest - we want the rest of the
00041    // child components
00042    if (fComposite) {
00043       return kTRUE;
00044    } else {
00045       return kFALSE;
00046    }
00047 }
00048 
00049 //______________________________________________________________________________
00050 Int_t FWGeoTopNodeGLScene::AddObject(const TBuffer3D& buffer, Bool_t* addChildren)
00051 {
00052    if (fComposite)
00053    {
00054       // TGeoSubstraction, TGeoUnion, ... phyID ignored in this case
00055       int ns = TGLScenePad::AddObject(1, buffer, addChildren);
00056       return ns;
00057    }
00058    else
00059    {  
00060       fwLog(fwlog::kError)<< "FWGeoTopNodeGLScene::AddObject() should not be called if fNextCompositeID \n";
00061       return TGLScenePad::AddObject(buffer, addChildren);
00062    }
00063 }
00064 
00065 //______________________________________________________________________________
00066 Bool_t FWGeoTopNodeGLScene::ResolveSelectRecord(TGLSelectRecord& rec, Int_t curIdx)
00067 {
00068    // Process selection record rec.
00069    // 'curIdx' is the item position where the scene should start
00070    // its processing.
00071    // Return TRUE if an object has been identified or FALSE otherwise.
00072    // The scene-info member of the record is already set by the caller.  
00073 
00074    if (curIdx >= rec.GetN())
00075       return kFALSE;
00076 
00077    TGLPhysicalShape* pshp = FindPhysical(rec.GetItem(curIdx));
00078 
00079    /*
00080    printf("FWGeoTopNodeGLScene::ResolveSelectRecord pshp=%p, lshp=%p, obj=%p, shpcls=%s\n",
00081           (void*)pshp,(void*) pshp->GetLogical(),(void*) pshp->GetLogical()->GetExternal(),
00082           ((TGeoVolume*)pshp->GetLogical()->GetExternal())->GetShape()->ClassName());
00083    */
00084    if (pshp)
00085    {
00086       rec.SetTransparent(pshp->IsTransparent());
00087       rec.SetPhysShape(pshp);
00088       rec.SetLogShape(FindLogical(fTopNodeJebo));
00089       rec.SetObject(fTopNodeJebo);
00090       rec.SetSpecific(0);
00091       return kTRUE;
00092    }
00093    return kFALSE;
00094 }
00095 
00096 //______________________________________________________________________________
00097 void FWGeoTopNodeGLScene::GeoPopupMenu(Int_t gx, Int_t gy)
00098 {fTopNodeJebo->popupMenu(gx, gy);
00099 }