CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWGeometryBrowser.cc
Go to the documentation of this file.
4 
8 
9 
10 #include "TFile.h"
11 #include "TGFileDialog.h"
12 #include "TGeoNode.h"
13 #include "TGStatusBar.h"
14 #include "TGButton.h"
15 #include "TGLabel.h"
16 
17 bool geodebug = 0;
18 
19 #include <iostream>
21  : TGMainFrame(gClient->GetRoot(), 600, 500),
22  m_mode(this, "Mode:", 1l, 0l, 1l),
23  m_filter(this,"Materials:",std::string()),
24  m_autoExpand(this,"AutoExpand:", 5l, 0l, 1000l),
25  m_maxDaughters(this,"MaxChildren:", 999l, 0l, 1000l), // debug
26  m_guiManager(guiManager),
27  m_tableManager(0),
28  m_geometryFile(0),
29  m_fileOpen(0),
30  m_settersFrame(0)
31 {
32  m_mode.addEntry(0, "Node");
33  m_mode.addEntry(1, "Volume");
34 
36 
37  TGTextButton* m_fileOpen = new TGTextButton (this, "Open Geometry File");
38  this->AddFrame(m_fileOpen, new TGLayoutHints( kLHintsExpandX , 4, 2, 2, 2));
39  m_fileOpen->Connect("Clicked()","FWGeometryBrowser",this,"browse()");
40 
41 
42  m_settersFrame = new TGHorizontalFrame(this);
43  this->AddFrame( m_settersFrame,new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
44  m_settersFrame->SetCleanup(kDeepCleanup);
45 
47  AddFrame(m_tableWidget,new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,2,2,2,2));
51  m_tableWidget->Connect("cellClicked(Int_t,Int_t,Int_t,Int_t,Int_t,Int_t)",
52  "FWGeometryBrowser",this,
53  "cellClicked(Int_t,Int_t,Int_t,Int_t,Int_t,Int_t)");
55  resetSetters();
56 
57  m_statBar = new TGStatusBar(this, this->GetWidth(), 12);
58  m_statBar->SetText("No simulation geomtery loaded.");
59  AddFrame(m_statBar, new TGLayoutHints(kLHintsExpandX));
60 
61  SetWindowName("Geometry Browser");
62  this->Connect("CloseWindow()","FWGeometryBrowser",this,"windowIsClosing()");
63  Layout();
64  MapSubwindows();
65 
66  gVirtualX->SelectInput(GetId(), kKeyPressMask | kKeyReleaseMask | kExposureMask |
67  kPointerMotionMask | kStructureNotifyMask | kFocusChangeMask |
68  kEnterWindowMask | kLeaveWindowMask);
69 }
70 
72 {}
73 
74 void
76 {
77  if (!m_settersFrame->GetList()->IsEmpty())
78  {
79  m_setters.clear();
80  TGFrameElement *el = (TGFrameElement*) m_settersFrame->GetList()->First();
81  m_settersFrame->RemoveFrame(el->fFrame);
82  }
83 
84  TGHorizontalFrame* frame = new TGHorizontalFrame(m_settersFrame);
85  m_settersFrame->AddFrame(frame);
86  makeSetter(frame, &m_mode);
87  makeSetter(frame, &m_filter);
88  makeSetter(frame, &m_autoExpand);
89  if (geodebug) makeSetter(frame, &m_maxDaughters);
90  m_settersFrame->MapSubwindows();
91  Layout();
92 }
93 
94 void
95 FWGeometryBrowser::makeSetter(TGCompositeFrame* frame, FWParameterBase* param)
96 {
97  boost::shared_ptr<FWParameterSetterBase> ptr( FWParameterSetterBase::makeSetterFor(param) );
98  ptr->attach(param, this);
99 
100  TGFrame* pframe = ptr->build(frame, false);
101  frame->AddFrame(pframe, new TGLayoutHints(kLHintsExpandX));
102 
103  m_setters.push_back(ptr);
104 }
105 //==============================================================================
106 
107 
108 void
110 {
112 }
113 
114 void
116 {
117  for(const_iterator it =begin(), itEnd = end();
118  it != itEnd;
119  ++it) {
120 
121  if (!geodebug && (&m_maxDaughters == (*it)))
122  continue;
123 
124  (*it)->setFrom(iFrom);
125 
126  }
127  resetSetters();
128 }
129 
130 //==============================================================================
131 void
132 FWGeometryBrowser::cellClicked(Int_t iRow, Int_t iColumn, Int_t iButton, Int_t iKeyMod, Int_t, Int_t)
133 {
134  if (iButton != kButton1)
135  {
136  // m_tableManager->setSelection(iRow, iColumn, iKeyMod);
137  return;
138  }
139 
140  if (iButton == kButton1 && iColumn == 0)
141  {
143  }
144 }
145 
147 {
148  if (!fBindList) return kFALSE;
149 
150  TIter next(fBindList);
151  TGMapKey *m;
152  TGFrame *w = 0;
153 
154  while ((m = (TGMapKey *) next())) {
155  if (m->fKeyCode == event->fCode) {
156  w = (TGFrame *) m->fWindow;
157  if (w->HandleKey(event)) return kTRUE;
158  }
159  }
160  return kFALSE;
161 }
162 
163 void
165 {
166  UnmapWindow();
167 }
168 
169 void
170 FWGeometryBrowser::newIndexSelected(int iSelectedRow, int iSelectedColumn)
171 {
172  if (iSelectedRow == -1)
173  return;
174 
176 }
177 
178 void
180 {
181  try {
182 
183  if ( ! m_geometryFile )
184  throw std::runtime_error("No root file.");
185 
186  m_geometryFile->ls();
187 
188  if ( !m_geometryFile->Get("cmsGeo;1"))
189  throw std::runtime_error("Can't find TGeoManager object in selected file.");
190 
191  TGeoManager* m_geoManager = (TGeoManager*) m_geometryFile->Get("cmsGeo;1");
192  m_tableManager->loadGeometry(m_geoManager);
193  MapRaised();
194 
195  }
196  catch (std::runtime_error &e)
197  {
198  fwLog(fwlog::kError) << "Failed to load simulation geomtery.\n";
199  updateStatusBar("Failed to load simulation geomtery from file");
200  }
201 }
202 
203 void
205 {
206  std::cout<<"FWGeometryBrowser::openFile()"<<std::endl;
207 
208  if (!geodebug)
209  {
210  const char* kRootType[] = {"ROOT files","*.root", 0, 0};
211  TGFileInfo fi;
212  fi.fFileTypes = kRootType;
213 
214  m_guiManager->updateStatus("opening geometry file...");
215 
216  new TGFileDialog(gClient->GetDefaultRoot(),
217  (TGWindow*) m_guiManager->getMainFrame(), kFDOpen, &fi);
218 
219  m_guiManager->updateStatus("loading geometry file...");
220  m_geometryFile = new TFile(fi.fFilename, "READ");
221  }
222  else
223  {
224  // AMT developing environment
225  m_geometryFile = new TFile("cmsSimGeom-14.root", "READ");
226  }
228 
229  readFile();
230 }
231 
232 
234  m_statBar->SetText(status, 0);
235 }
void SetBackgroundColor(Pixel_t)
void updateStatusBar(const char *status)
std::vector< FWParameterBase * >::const_iterator const_iterator
FWStringParameter m_filter
const_iterator begin() const
TGTextButton * m_fileOpen
void cellClicked(Int_t iRow, Int_t iColumn, Int_t iButton, Int_t iKeyMod, Int_t iGlobalX, Int_t iGlobalY)
void newIndexSelected(int, int)
void SetHeaderBackgroundColor(Pixel_t)
TGCompositeFrame * m_settersFrame
virtual ~FWGeometryBrowser()
static boost::shared_ptr< FWParameterSetterBase > makeSetterFor(FWParameterBase *)
void dataChanged()
Classes which inherit from FWTableManagerBase must call this when their underlying data changes...
void updateStatus(const char *status)
void SetLineSeparatorColor(Pixel_t)
TGStatusBar * m_statBar
void disableGrowInWidth()
FWGeometryBrowser(FWGUIManager *)
void makeSetter(TGCompositeFrame *frame, FWParameterBase *param)
const_iterator end() const
bool addEntry(Long_t id, const std::string &txt)
FWLongParameter m_maxDaughters
Bool_t HandleKey(Event_t *event)
FWGUIManager * m_guiManager
bool geodebug
CmsShowMainFrame * getMainFrame() const
Definition: FWGUIManager.h:202
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void loadGeometry(TGeoManager *geoManager)
virtual void addTo(FWConfiguration &) const
void clearStatus()
FWEnumParameter m_mode
#define fwLog(_level_)
Definition: fwLog.h:51
friend class FWGeometryTableManager
std::vector< boost::shared_ptr< FWParameterSetterBase > > m_setters
FWGeometryTableManager * m_tableManager
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
FWLongParameter m_autoExpand
tuple cout
Definition: gather_cfg.py:41
tuple status
Definition: ntuplemaker.py:245
virtual void setFrom(const FWConfiguration &)
FWTableWidget * m_tableWidget
virtual void addTo(FWConfiguration &) const