CMS 3D CMS Logo

FWGeometryTableViewManager.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWGeometryTableViewManager
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Alja Mrak-Tadel
10 // Created: Fri Jul 8 00:40:37 CEST 2011
11 //
12 
13 #include <boost/bind.hpp>
14 
15 #include "TFile.h"
16 #include "TSystem.h"
17 #include "TGeoManager.h"
18 #include "TGeoMatrix.h"
19 #include "TEveManager.h"
20 
28 
29 TGeoManager* FWGeometryTableViewManager::s_geoManager = nullptr;
30 
32 
35  m_fileName(fileName),
36  m_TGeoName(geoName)
37 {
39  f=boost::bind(&FWGeometryTableViewManager::buildView, this, _1, _2);
42 }
43 
45 {
46 }
47 
48 
50 FWGeometryTableViewManager::buildView(TEveWindowSlot* iParent, const std::string& type)
51 {
53  std::shared_ptr<FWGeometryTableViewBase> view;
54 
56  if (typeId == FWViewType::kGeometryTable)
57  view.reset( new FWGeometryTableView(iParent, &colorManager()));
58  else
59  view.reset( new FWOverlapTableView(iParent, &colorManager()));
60 
61  view->setBackgroundColor();
62  m_views.push_back(std::shared_ptr<FWGeometryTableViewBase> (view));
63  view->beingDestroyed_.connect(boost::bind(&FWGeometryTableViewManager::beingDestroyed, this,_1));
64 
65  return view.get();
66 }
67 
68 
69 void
71 {
72  for(std::vector<std::shared_ptr<FWGeometryTableViewBase> >::iterator it=m_views.begin(); it != m_views.end(); ++it) {
73  if(it->get() == iView) {
74  m_views.erase(it);
75  return;
76  }
77  }
78 }
79 
80 void
82 {
83  for(std::vector<std::shared_ptr<FWGeometryTableViewBase> >::iterator it=m_views.begin(); it != m_views.end(); ++it)
84  (*it)->setBackgroundColor();
85 }
86 
87 //______________________________________________________________________________
88 TGeoManager*
90 {
91  // Function used in geomtery table views.
92 
93  assert( s_geoManager);
94  return s_geoManager;
95 }
96 
97 //______________________________________________________________________________
98 void
100 {
101  // Function called from FWFFLooper to set geometry created in runtime.
102 
103  s_geoManager = x;
104 }
105 
106 //______________________________________________________________________________
107 void
109 {
110  TFile* file = FWGeometry::findFile( m_fileName.c_str() );
111  fwLog(fwlog::kInfo) << "Geometry table file: " << m_fileName.c_str() << std::endl;
112  try
113  {
114  if ( ! file )
115  throw std::runtime_error("No root file.");
116 
117  file->ls();
118 
119  s_geoManager = (TGeoManager*) file->Get( m_TGeoName.c_str());
120  if ( ! s_geoManager)
121  throw std::runtime_error("Can't find TGeoManager object in selected file.");
122 
123  }
124  catch (std::runtime_error &e)
125  {
126  fwLog(fwlog::kError) << "Failed to find simulation geomtery file. Please set the file path with --sim-geom-file option.\n";
127  exit(0);
128  }
129 }
static TFile * findFile(const char *fileName)
Definition: FWGeometry.cc:30
type
Definition: HCALResponse.h:21
TGeoManager * FWGeometryTableViewManager_GetGeoManager()
std::vector< std::shared_ptr< FWGeometryTableViewBase > > m_views
FWColorManager & colorManager() const
boost::function2< FWViewBase *, TEveWindowSlot *, const std::string & > ViewBuildFunctor
Definition: FWGUIManager.h:98
void registerViewBuilder(const std::string &iName, ViewBuildFunctor &iBuilder)
static std::string sName[kTypeSize]
Definition: FWViewType.h:62
void beingDestroyed(const FWViewBase *iView)
double f[11][100]
#define fwLog(_level_)
Definition: fwLog.h:50
FWGeometryTableViewManager(FWGUIManager *, std::string fileName, std::string geoName)
static const std::string & idToName(int)
Definition: FWViewType.cc:89
static void setGeoManagerRuntime(TGeoManager *)
FWViewBase * buildView(TEveWindowSlot *iParent, const std::string &type)