Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:30

0001 #include "TCanvas.h"
0002 #include "RVersion.h"
0003 #include "TRootEmbeddedCanvas.h"
0004 #include "TGLViewer.h"
0005 
0006 #include "TEveWindow.h"
0007 #include "TEveViewer.h"
0008 #include "TEveScene.h"
0009 #include "TEveManager.h"
0010 #include "TSystem.h"
0011 
0012 #include "Fireworks/Core/interface/FWColorManager.h"
0013 #include "Fireworks/Core/interface/FWGLEventHandler.h"
0014 
0015 template <typename T>
0016 FWDetailViewGL<T>::FWDetailViewGL()
0017     : m_infoCanvas(nullptr), m_guiFrame(nullptr), m_eveViewer(nullptr), m_eveScene(nullptr) {}
0018 
0019 template <typename T>
0020 FWDetailViewGL<T>::~FWDetailViewGL() {
0021   m_eveScene->Destroy();
0022 }
0023 
0024 template <typename T>
0025 void FWDetailViewGL<T>::init(TEveWindowSlot* slot) {
0026   TEveWindowPack* pack = slot->MakePack();
0027   pack->SetHorizontal();
0028   pack->SetShowTitleBar(kFALSE);
0029   pack->SetElementNameTitle("DetalView pack", "DetailViewPack");
0030 
0031   // canvas & widgets
0032   TEveWindowFrame* frame = pack->NewSlotWithWeight(1)->MakeFrame();
0033   frame->SetShowTitleBar(kFALSE);
0034   TGCompositeFrame* cf = frame->GetGUICompositeFrame();
0035 
0036   TGCompositeFrame* hf = new TGVerticalFrame(cf);
0037   hf->SetCleanup(kLocalCleanup);
0038   cf->AddFrame(hf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
0039   {
0040     m_guiFrame = new TGVerticalFrame(hf);
0041     hf->AddFrame(m_guiFrame, new TGLayoutHints(kLHintsExpandX));
0042     m_guiFrame->SetCleanup(kDeepCleanup);
0043 
0044     // legend
0045     TRootEmbeddedCanvas* ec = new TRootEmbeddedCanvas("Embeddedcanvas", hf, 100, 100, 0);
0046     hf->AddFrame(ec, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
0047     m_infoCanvas = ec->GetCanvas();
0048     m_infoCanvas->SetHighLightColor(-1);
0049   }
0050 
0051   cf->MapSubwindows();
0052   cf->Layout();
0053   cf->MapWindow();
0054 
0055   // viewer GL
0056   m_eveViewer = new TEveViewer("DetailView");
0057 #if ROOT_VERSION_CODE >= ROOT_VERSION(5, 25, 4)
0058   m_eveViewer->SpawnGLEmbeddedViewer(nullptr);
0059 #else
0060   m_eveViewer->SpawnGLEmbeddedViewer();
0061 #endif
0062   pack->NewSlotWithWeight(3)->ReplaceWindow(m_eveViewer);
0063   m_eveViewer->SetShowTitleBar(kFALSE);
0064   gEve->GetViewers()->AddElement(m_eveViewer);
0065 
0066   m_eveScene = gEve->SpawnNewScene("Detailed view");
0067   m_eveViewer->AddScene(m_eveScene);
0068 
0069   // override event handling
0070   TGLViewer* glv = m_eveViewer->GetGLViewer();
0071   FWGLEventHandler* eh = new FWGLEventHandler((TGWindow*)glv->GetGLWidget(), (TObject*)glv);
0072   glv->SetEventHandler(eh);
0073 }
0074 
0075 template <typename T>
0076 void FWDetailViewGL<T>::setBackgroundColor(Color_t col) {
0077   FWColorManager::setColorSetViewer(viewerGL(), col);
0078 }