CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
30 
32 
35  m_fileName(fileName)
36 {
38  f=boost::bind(&FWGeometryTableViewManager::buildView, this, _1, _2);
41 }
42 
44 {
45 }
46 
47 
49 FWGeometryTableViewManager::buildView(TEveWindowSlot* iParent, const std::string& type)
50 {
52  boost::shared_ptr<FWGeometryTableViewBase> view;
53 
55  if (typeId == FWViewType::kGeometryTable)
56  view.reset( new FWGeometryTableView(iParent, &colorManager()));
57  else
58  view.reset( new FWOverlapTableView(iParent, &colorManager()));
59 
60  view->setBackgroundColor();
61  m_views.push_back(boost::shared_ptr<FWGeometryTableViewBase> (view));
62  view->beingDestroyed_.connect(boost::bind(&FWGeometryTableViewManager::beingDestroyed, this,_1));
63 
64  return view.get();
65 }
66 
67 
68 void
70 {
71  for(std::vector<boost::shared_ptr<FWGeometryTableViewBase> >::iterator it=m_views.begin(); it != m_views.end(); ++it) {
72  if(it->get() == iView) {
73  m_views.erase(it);
74  return;
75  }
76  }
77 }
78 
79 void
81 {
82  for(std::vector<boost::shared_ptr<FWGeometryTableViewBase> >::iterator it=m_views.begin(); it != m_views.end(); ++it)
83  (*it)->setBackgroundColor();
84 }
85 
86 //______________________________________________________________________________
87 TGeoManager*
89 {
90  // Function used in geomtery table views.
91 
93  return s_geoManager;
94 }
95 
96 //______________________________________________________________________________
97 void
99 {
100  // Function called from FWFFLooper to set geometry created in runtime.
101 
102  s_geoManager = x;
103 }
104 
105 //______________________________________________________________________________
106 void
108 {
109  TFile* file = FWGeometry::findFile( m_fileName.c_str() );
110  fwLog(fwlog::kInfo) << "Geometry table file: " << m_fileName.c_str() << std::endl;
111  try
112  {
113  if ( ! file )
114  throw std::runtime_error("No root file.");
115 
116  file->ls();
117 
118  s_geoManager = (TGeoManager*) file->Get("cmsGeo;1");
119  if ( ! s_geoManager)
120  throw std::runtime_error("Can't find TGeoManager object in selected file.");
121 
122  }
123  catch (std::runtime_error &e)
124  {
125  fwLog(fwlog::kError) << "Failed to find simulation geomtery file. Please set the file path with --sim-geom-file option.\n";
126  exit(0);
127  }
128 }
static TFile * findFile(const char *fileName)
Definition: FWGeometry.cc:26
type
Definition: HCALResponse.h:21
TGeoManager * FWGeometryTableViewManager_GetGeoManager()
assert(m_qm.get())
FWColorManager & colorManager() const
FWGeometryTableViewManager(FWGUIManager *, std::string fileName)
boost::function2< FWViewBase *, TEveWindowSlot *, const std::string & > ViewBuildFunctor
Definition: FWGUIManager.h:99
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
std::vector< boost::shared_ptr< FWGeometryTableViewBase > > m_views
static const std::string & idToName(int)
Definition: FWViewType.cc:89
static void setGeoManagerRuntime(TGeoManager *)
FWViewBase * buildView(TEveWindowSlot *iParent, const std::string &type)
Definition: DDAxes.h:10