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 // $Id: FWGeometryTableViewManager.cc,v 1.11 2013/04/05 23:53:42 amraktad Exp $
12 //
13 
14 #include <boost/bind.hpp>
15 
16 #include "TFile.h"
17 #include "TSystem.h"
18 #include "TGeoManager.h"
19 #include "TGeoMatrix.h"
20 #include "TEveManager.h"
21 
29 
31 
33 
36  m_fileName(fileName)
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  boost::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(boost::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<boost::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<boost::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("cmsGeo;1");
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:25
type
Definition: HCALResponse.h:21
TGeoManager * FWGeometryTableViewManager_GetGeoManager()
FWColorManager & colorManager() const
FWGeometryTableViewManager(FWGUIManager *, std::string fileName)
boost::function2< FWViewBase *, TEveWindowSlot *, const std::string & > ViewBuildFunctor
Definition: FWGUIManager.h:100
void registerViewBuilder(const std::string &iName, ViewBuildFunctor &iBuilder)
static std::string sName[kTypeSize]
Definition: FWViewType.h:63
void beingDestroyed(const FWViewBase *iView)
double f[11][100]
#define fwLog(_level_)
Definition: fwLog.h:51
std::vector< boost::shared_ptr< FWGeometryTableViewBase > > m_views
static const std::string & idToName(int)
Definition: FWViewType.cc:90
static void setGeoManagerRuntime(TGeoManager *)
FWViewBase * buildView(TEveWindowSlot *iParent, const std::string &type)
Definition: DDAxes.h:10