CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWOverlapTableView.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWOverlapTableView
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author:
10 // Created: Wed Jan 4 00:06:35 CET 2012
11 // $Id: FWOverlapTableView.cc,v 1.12 2012/05/10 21:02:31 amraktad Exp $
12 //
13 
14 // system include files
15 #include <boost/bind.hpp>
16 
17 // user include files
26 
29 
30 #include "TEveScene.h"
31 #include "TEveSceneInfo.h"
32 #include "TEveWindow.h"
33 
34 #include "TEvePointSet.h"
35 #include "TEveManager.h"
36 
37 
38 #include "TGeoVolume.h"
39 #include "TGeoMatrix.h"
40 #include "TGeoShape.h"
41 #include "TGeoBBox.h"
42 #include "TGeoMatrix.h"
43 #include "TGeoManager.h"
44 
45 #include "TGLViewer.h"
46 #include "KeySymbols.h"
47 #include "TGLabel.h"
48 #include "TGNumberEntry.h"
49 #include "TGListBox.h"
50 #include "TGButton.h"
51 #include "TEveViewer.h"
52 #include "TGeoOverlap.h"
53 #include "TGClient.h"
54 
55 static const std::string sUpdateMsg = "Please press Apply button to update overlaps.\n";
56 
57 
58 FWOverlapTableView::FWOverlapTableView(TEveWindowSlot* iParent, FWColorManager* colMng) :
59  FWGeometryTableViewBase(iParent, FWViewType::kOverlapTable, colMng),
60  m_applyButton(0),
61  m_listOptionButton(0),
62  m_tableManager(0),
63  m_numEntry(0),
64  m_runChecker(true),
65  m_path(this,"Path:", std::string("/cms:World_1/cms:CMSE_1")),
66  m_precision(this, "Precision", 0.05, 0.000001, 10),
67  m_listAllNodes(this, "ListAllNodes", true),
68  m_rnrOverlap(this, "Overlap", true),
69  m_rnrExtrusion(this, "Extrusion", true),
70  m_drawPoints(this, "DrawPoints", true),
71  m_pointSize(this, "PointSize:", 1l, 0l, 10l)
72 {
73  // top row
74  TGHorizontalFrame* hp = new TGHorizontalFrame(m_frame);
75 
76  {
77  m_viewBox = new FWViewCombo(hp, this);
78  hp->AddFrame( m_viewBox,new TGLayoutHints(kLHintsExpandY, 2, 2, 0, 0));
79  }
80 
81  {
82  TGTextButton* rb = new TGTextButton (hp, "CdTop");
83  hp->AddFrame(rb, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0) );
84  rb->Connect("Clicked()","FWGeometryTableViewBase",this,"cdTop()");
85  }
86 
87  {
88  TGTextButton* rb = new TGTextButton (hp, "CdUp");
89  hp->AddFrame(rb, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
90  rb->Connect("Clicked()","FWGeometryTableViewBase",this,"cdUp()");
91  }
92  {
93  hp->AddFrame(new TGLabel(hp, "Precision:"), new TGLayoutHints(kLHintsBottom, 10, 0, 0, 2));
94  m_numEntry = new TGNumberEntry(hp, m_precision.value(), 5, -1, TGNumberFormat::kNESReal, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, m_precision.min(), m_precision.max());
95  hp->AddFrame(m_numEntry, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
96  m_numEntry->Connect("ValueSet(Long_t)","FWOverlapTableView",this,"precisionCallback(Long_t)");
97  }
98 
99  {
100  m_listOptionButton = new TGCheckButton(hp,m_listAllNodes.name().c_str());
101  m_listOptionButton->SetState( m_listAllNodes.value() ? kButtonDown : kButtonUp );
102  m_listOptionButton->Connect("Clicked()", "FWOverlapTableView", this, "setListAllNodes()");
103  hp->AddFrame(m_listOptionButton, new TGLayoutHints(kLHintsLeft|kLHintsCenterY,2,0,1,1));
104 
105  }
106  {
107  m_applyButton = new TGTextButton (hp, "Apply");
108  hp->AddFrame( m_applyButton, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
109  m_applyButton->Connect("Clicked()","FWOverlapTableView",this,"recalculate()");
110  }
111 
112  m_frame->AddFrame(hp,new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 4, 2, 2, 0));
114 
115  // std::cerr << " FWOverlapTableView::initGeometry \n";
116 
118 #if ROOT_VERSION_CODE < ROOT_VERSION(5,32,0)
119  m_eveScene = new FWGeoTopNodeEveScene(gls, "TopGeoNodeScene", "");
120 #else
121  m_eveScene = new TEveScene(gls, "TopGeoNodeScene", "");
122 #endif
123 
124  gEve->GetScenes()->AddElement(m_eveScene);
125 
126  m_eveTopNode = new FWEveOverlap(this);
127  m_eveTopNode->SetElementNameTitle("overlapNode", "opverlapNodetitle");
128  m_eveTopNode->IncDenyDestroy();
129  m_eveTopNode->SetPickable(true);
130  m_eveScene->AddElement(m_eveTopNode);
131 
132  gls->m_eveTopNode = m_eveTopNode;
133  m_eveTopNode->m_scene = gls;
134 
135  m_marker = new TEvePointSet();
136  m_marker->SetMarkerSize(5);
137  m_marker->SetMainColor(kRed);
138  m_marker->IncDenyDestroy();
139 
140 
141  m_drawPoints.changed_.connect(boost::bind(&FWOverlapTableView::drawPoints,this));
142  m_pointSize.changed_.connect(boost::bind(&FWOverlapTableView::pointSize,this));
143  m_rnrOverlap.changed_.connect(boost::bind(&FWOverlapTableView::refreshTable3D,this));
145 
146  postConst();
147 }
148 //______________________________________________________________________________
149 
150 
152 {
153  if (m_marker) m_marker->DecDenyDestroy();
154 }
155 
156 //______________________________________________________________________________
158 {
159  return m_tableManager;
160 }
161 
162 //______________________________________________________________________________
164 {
165  return m_listAllNodes.value();
166 }
167 
168 //______________________________________________________________________________
170 {
172  refreshTable3D();
173 }
174 //______________________________________________________________________________
175 
177 {
178  return m_eveTopNode;
179 }
180 
181 //______________________________________________________________________________
183 {
184  // std::cout << " ----------------------------- PRECISION \n" << m_numEntry->GetNumber();
185  setCheckerState(true);
186  m_precision.set( m_numEntry->GetNumber());
188 }
189 
190 
192 {
193  //m_path.set(m_pathEntry->GetText());
194  // m_precision.set(m_numEntry->GetNumber());
195  // std::cout << " $$$$ " << m_path.value() << std::endl;
198  getTableManager()->setLevelOffset(getTableManager()->refEntries().at(getTopNodeIdx()).m_level);
199  refreshTable3D();
200 
201  setCheckerState(false);
202 }
203 
204 
205 //______________________________________________________________________________
207 {
208  m_enableRedraw = false;
209 
210  for (const_iterator it =begin(), itEnd = end(); it != itEnd; ++it)
211  {
212  if ((*it)->name() == m_topNodeIdx.name() )
214  else
215  (*it)->setFrom(iFrom);
216  }
217 
218  m_viewersConfig = iFrom.valueForKey("Viewers");
219  m_numEntry->SetNumber(m_precision.value());
220 
221  // refreshTable3D();
222  m_enableRedraw = true;
223  recalculate();
224 }
225 
226 //______________________________________________________________________________
228 {
229  gui.requestTab("Style").
230  // addParam(&m_enableHighlight).
231  // separator().
232  addParam(&m_rnrOverlap).
233  addParam(&m_rnrExtrusion).
234  separator().
235  addParam(&m_drawPoints).
236  addParam(&m_pointSize);
237 
239 }
240 
241 //______________________________________________________________________________
243 {
244  m_marker->SetRnrSelf(m_drawPoints.value());
245  m_marker->ElementChanged();
246  gEve->Redraw3D();
247 }
248 
249 //______________________________________________________________________________
251 {
252  m_marker->SetMarkerSize(m_pointSize.value());
253  m_marker->ElementChanged();
254  gEve->Redraw3D();
255 }
256 
257 //______________________________________________________________________________
259 {
260  setCheckerState(true);
262 }
263 //______________________________________________________________________________
265 {
266  if (m_topNodeIdx.value() == -1) return;
267 
268  setCheckerState(true);
270 }
271 //______________________________________________________________________________
273 {
274  m_runChecker = x;
275  m_applyButton->SetForegroundColor(x ? 0xff0000 : 0x000000);
276  gClient->NeedRedraw(m_applyButton);
277 
278 }
279 //______________________________________________________________________________
280 
282 {
283  // printf(" FWOverlapTableView::chosenItem chosen item %s \n", ni->name());
284 
285  switch (menuIdx) {
287  {
288  std::cout << "=============================================================================" << std::endl << std::endl;
290  break;
291  }
292  default:
294  }
295 }
296 
297 //______________________________________________________________________________
299 {
300  using namespace TMath;
301  if (!m_enableRedraw) return;
303 
304  std::vector<float> pnts;
305  int cnt = 0;
306 
307  // std::cout << "WOverlapTableView::refreshTable3D() "<< std::endl;
308  int n0 = getTopNodeIdx();
309  int nd = 0;
311  int n1 = n0+nd;
312  // printf("marker rnf %d %d \n", n0, n1);
313  if (m_drawPoints.value()) {
314  for (std::vector<int>::iterator i = m_markerIndices.begin(); i!=m_markerIndices.end(); i++, cnt+=3)
315  {
316  if (Abs(*i) >= n0 && Abs(*i) <= n1)
317  {
320  ( (( *i > 0 ) && m_rnrOverlap.value()) || ((*i < 0) && m_rnrExtrusion.value()) ))
321  {
322  pnts.push_back(m_markerVertices[cnt]);
323  pnts.push_back(m_markerVertices[cnt+1]);
324  pnts.push_back(m_markerVertices[cnt+2]);
325  }
326  }
327  }
328  }
329 
330  m_marker->SetPolyMarker(int(pnts.size()/3), &pnts[0], 4);
331  m_marker->ElementChanged();
332  gEve->FullRedraw3D(false, true);
333 }
void precisionCallback(Long_t)
virtual void populateController(ViewerParameterGUI &) const
TGTextButton * m_applyButton
int i
Definition: DBlmapReader.cc:9
FWStringParameter m_path
std::vector< FWParameterBase * >::const_iterator const_iterator
FWGeoTopNode * m_eveTopNode
const_iterator begin() const
FWBoolParameter m_rnrOverlap
FWOverlapTableView(TEveWindowSlot *iParent, FWColorManager *colMng)
std::vector< float > m_markerVertices
std::vector< int > m_markerIndices
FWBoolParameter m_listAllNodes
void setTopNodePathFromConfig(const FWConfiguration &iFrom)
ViewerParameterGUI & requestTab(const char *)
const FWConfiguration * m_viewersConfig
virtual FWGeometryTableManagerBase * getTableManager()
sigc::signal< void, T > changed_
int getFirstSelectedTableIndex()
virtual void setFrom(const FWConfiguration &)
FWBoolParameter m_drawPoints
FWDoubleParameter m_precision
FWGeoTopNodeGLScene * m_scene
Definition: FWGeoTopNode.h:69
bool listAllNodes() const
virtual void refreshTable3D()
int n0
Definition: AMPTWrapper.h:34
FWBoolParameter m_rnrExtrusion
virtual void chosenItem(int x)
const_iterator end() const
TGNumberEntry * m_numEntry
TGCheckButton * m_listOptionButton
static void getNNodesTotal(TGeoNode *geoNode, int &off)
virtual TEveElement * getEveGeoElement() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
tuple cout
Definition: gather_cfg.py:121
const FWConfiguration * valueForKey(const std::string &iKey) const
FWLongParameter m_pointSize
FWOverlapTableManager * m_tableManager
x
Definition: VDTMath.h:216
static const std::string sUpdateMsg
virtual void populateController(ViewerParameterGUI &) const
const std::string & name() const
list at
Definition: asciidump.py:428
void importOverlaps(std::string path, double precision)