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 <functional>
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 
34  : FWViewManagerBase(), m_fileName(fileName), m_TGeoName(geoName) {
36  f = std::bind(&FWGeometryTableViewManager::buildView, this, std::placeholders::_1, std::placeholders::_2);
39 }
40 
42 
44  if (!s_geoManager)
46  std::shared_ptr<FWGeometryTableViewBase> view;
47 
48  FWViewType::EType typeId =
50  if (typeId == FWViewType::kGeometryTable)
51  view.reset(new FWGeometryTableView(iParent, &colorManager()));
52  else
53  view.reset(new FWOverlapTableView(iParent, &colorManager()));
54 
55  view->setBackgroundColor();
56  m_views.push_back(std::shared_ptr<FWGeometryTableViewBase>(view));
57  view->beingDestroyed_.connect(std::bind(&FWGeometryTableViewManager::beingDestroyed, this, std::placeholders::_1));
58 
59  return view.get();
60 }
61 
63  for (std::vector<std::shared_ptr<FWGeometryTableViewBase> >::iterator it = m_views.begin(); it != m_views.end();
64  ++it) {
65  if (it->get() == iView) {
66  m_views.erase(it);
67  return;
68  }
69  }
70 }
71 
73  for (std::vector<std::shared_ptr<FWGeometryTableViewBase> >::iterator it = m_views.begin(); it != m_views.end(); ++it)
74  (*it)->setBackgroundColor();
75 }
76 
77 //______________________________________________________________________________
79  // Function used in geometry table views.
80 
82  return s_geoManager;
83 }
84 
85 //______________________________________________________________________________
87  // Function called from FWFFLooper to set geometry created in runtime.
88 
89  s_geoManager = x;
90 }
91 
92 //______________________________________________________________________________
94  TFile* file = FWGeometry::findFile(m_fileName.c_str());
95  fwLog(fwlog::kInfo) << "Geometry table file: " << m_fileName.c_str() << std::endl;
96  try {
97  if (!file) {
98  // Try it as a GDML file
99  s_geoManager = TGeoManager::Import(m_fileName.c_str(), m_TGeoName.c_str());
100  } else {
101  file->ls();
102  s_geoManager = (TGeoManager*)file->Get(m_TGeoName.c_str());
103  }
104  if (!s_geoManager)
105  throw std::runtime_error("Can't find TGeoManager object in selected file.");
106 
107  } catch (std::runtime_error& e) {
108  fwLog(fwlog::kError) << e.what();
109  exit(0);
110  }
111 }
fwLog
#define fwLog(_level_)
Definition: fwLog.h:45
FWGUIManager
Definition: FWGUIManager.h:95
FWViewType::idToName
static const std::string & idToName(int)
Definition: FWViewType.cc:72
FWViewManagerBase
Definition: FWViewManagerBase.h:45
FWGeometryTableViewManager::getGeoMangeur
static TGeoManager * getGeoMangeur()
Definition: FWGeometryTableViewManager.cc:78
FWViewType::EType
EType
Definition: FWViewType.h:31
FWViewType::kGeometryTable
Definition: FWViewType.h:44
FWGUIManager::registerViewBuilder
void registerViewBuilder(const std::string &iName, ViewBuildFunctor &iBuilder)
Definition: FWGUIManager.cc:273
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
FWViewManagerBase::colorManager
FWColorManager & colorManager() const
Definition: FWViewManagerBase.cc:123
cms::cuda::assert
assert(be >=bs)
FWGeometryTableViewManager::buildView
FWViewBase * buildView(TEveWindowSlot *iParent, const std::string &type)
Definition: FWGeometryTableViewManager.cc:43
DDAxes::x
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
FWGeometryTableViewManager::m_views
std::vector< std::shared_ptr< FWGeometryTableViewBase > > m_views
Definition: FWGeometryTableViewManager.h:52
FWViewType::kOverlapTable
Definition: FWViewType.h:45
FWGeometryTableViewManager::FWGeometryTableViewManager
FWGeometryTableViewManager(FWGUIManager *, std::string fileName, std::string geoName)
Definition: FWGeometryTableViewManager.cc:33
FWGeometryTableViewManager::setGeoManagerFromFile
void setGeoManagerFromFile()
Definition: FWGeometryTableViewManager.cc:93
FWViewType::sName
static std::string sName[kTypeSize]
Definition: FWViewType.h:71
FWGeometryTableView
Definition: FWGeometryTableView.h:28
FWColorManager.h
FWGeometryTableViewManager::m_TGeoName
std::string m_TGeoName
Definition: FWGeometryTableViewManager.h:61
FWGeometryTableViewManager.h
geometryDiff.file
file
Definition: geometryDiff.py:13
FWGeometry.h
FWGUIManager::ViewBuildFunctor
std::function< FWViewBase *(TEveWindowSlot *, const std::string &)> ViewBuildFunctor
Definition: FWGUIManager.h:98
FWGeometryTableViewManager::colorsChanged
void colorsChanged() override
Definition: FWGeometryTableViewManager.cc:72
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
FWGeometryTableViewManager::m_fileName
std::string m_fileName
Definition: FWGeometryTableViewManager.h:60
fwLog.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
fwlog::kInfo
Definition: fwLog.h:35
FWGeometry::findFile
static TFile * findFile(const char *fileName)
Definition: FWGeometry.cc:38
FWGeometryTableViewManager::s_geoManager
static TGeoManager * s_geoManager
Definition: FWGeometryTableViewManager.h:59
genVertex_cff.x
x
Definition: genVertex_cff.py:13
FWGeometryTableViewManager::setGeoManagerRuntime
static void setGeoManagerRuntime(TGeoManager *)
Definition: FWGeometryTableViewManager.cc:86
fwlog::kError
Definition: fwLog.h:35
FWOverlapTableView.h
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:52
FWGeometryTableViewManager_GetGeoManager
TGeoManager * FWGeometryTableViewManager_GetGeoManager()
Definition: FWGeometryTableViewManager.cc:31
FWViewBase
Definition: FWViewBase.h:36
FWGeometryTableView.h
FWGeometryTableViewManager::beingDestroyed
void beingDestroyed(const FWViewBase *iView)
Definition: FWGeometryTableViewManager.cc:62
FWOverlapTableView
Definition: FWOverlapTableView.h:32
FWGeometryTableViewManager::~FWGeometryTableViewManager
~FWGeometryTableViewManager() override
Definition: FWGeometryTableViewManager.cc:41
FWGUIManager.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37