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.17 2013/04/19 04:21:29 amraktad Exp $
12 //
13 
14 // system include files
15 #include <boost/bind.hpp>
16 
17 // user include files
27 
31 
32 #include "TEveScene.h"
33 #include "TEveSceneInfo.h"
34 #include "TEveWindow.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", 4l, 0l, 10l),
72  m_extrusionMarkerColor(this, "ExtrusionMarkerColor", 0l, 0l, 20l),
73  m_overlapMarkerColor(this, "OverlapMarkerColor", 9l, 0l, 20l)
74 {
75  // top row
76  TGHorizontalFrame* hp = new TGHorizontalFrame(m_frame);
77 
78  {
79  m_viewBox = new FWViewCombo(hp, this);
80  hp->AddFrame( m_viewBox,new TGLayoutHints(kLHintsExpandY, 2, 2, 0, 0));
81  }
82 
83  {
84  TGTextButton* rb = new TGTextButton (hp, "CdTop");
85  hp->AddFrame(rb, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0) );
86  rb->Connect("Clicked()","FWGeometryTableViewBase",this,"cdTop()");
87  }
88 
89  {
90  TGTextButton* rb = new TGTextButton (hp, "CdUp");
91  hp->AddFrame(rb, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
92  rb->Connect("Clicked()","FWGeometryTableViewBase",this,"cdUp()");
93  }
94  {
95  hp->AddFrame(new TGLabel(hp, "Precision:"), new TGLayoutHints(kLHintsBottom, 10, 0, 0, 2));
96  m_numEntry = new TGNumberEntry(hp, m_precision.value(), 5, -1, TGNumberFormat::kNESReal, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, m_precision.min(), m_precision.max());
97  hp->AddFrame(m_numEntry, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
98  m_numEntry->Connect("ValueSet(Long_t)","FWOverlapTableView",this,"precisionCallback(Long_t)");
99  }
100 
101  {
102  m_listOptionButton = new TGCheckButton(hp,m_listAllNodes.name().c_str());
103  m_listOptionButton->SetState( m_listAllNodes.value() ? kButtonDown : kButtonUp );
104  m_listOptionButton->Connect("Clicked()", "FWOverlapTableView", this, "setListAllNodes()");
105  hp->AddFrame(m_listOptionButton, new TGLayoutHints(kLHintsLeft|kLHintsCenterY,2,0,1,1));
106 
107  }
108  {
109  m_applyButton = new TGTextButton (hp, "Apply");
110  hp->AddFrame( m_applyButton, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
111  m_applyButton->Connect("Clicked()","FWOverlapTableView",this,"recalculate()");
112  }
113 
114  m_frame->AddFrame(hp,new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 4, 2, 2, 0));
116 
117  // std::cerr << " FWOverlapTableView::initGeometry \n";
118 
120 #if ROOT_VERSION_CODE < ROOT_VERSION(5,32,0)
121  m_eveScene = new FWGeoTopNodeEveScene(gls, "TopGeoNodeScene", "");
122 #else
123  m_eveScene = new TEveScene(gls, "TopGeoNodeScene", "");
124 #endif
125 
126  gEve->GetScenes()->AddElement(m_eveScene);
127 
128  m_eveTopNode = new FWEveOverlap(this);
129  m_eveTopNode->SetElementNameTitle("overlapNode", "opverlapNodetitle");
130  m_eveTopNode->IncDenyDestroy();
131  m_eveTopNode->SetPickable(true);
132  m_eveScene->AddElement(m_eveTopNode);
133 
134  gls->m_eveTopNode = m_eveTopNode;
135  m_eveTopNode->m_scene = gls;
136 
138  m_marker->SetMainColor(kRed);
139  m_marker->IncDenyDestroy();
140  m_marker->Reset(TEveQuadSet::kQT_FreeQuad, kFALSE, 32);
141  m_marker->SetOwnIds(kTRUE);
142  m_marker->SetAlwaysSecSelect(kTRUE);
143  m_marker->SetPickable(kTRUE);
144  m_marker->SetOwnIds(kTRUE);
145 
146 
147  m_drawPoints.changed_.connect(boost::bind(&FWOverlapTableView::drawPoints,this));
148  m_pointSize.changed_.connect(boost::bind(&FWOverlapTableView::pointSize,this));
149  m_rnrOverlap.changed_.connect(boost::bind(&FWOverlapTableView::refreshTable3D,this));
153 
154  postConst();
155 }
156 //______________________________________________________________________________
157 
158 
160 {
161  if (m_marker) m_marker->DecDenyDestroy();
162 }
163 
164 //______________________________________________________________________________
166 {
167  return m_tableManager;
168 }
169 
170 //______________________________________________________________________________
172 {
173  return m_listAllNodes.value();
174 }
175 
176 //______________________________________________________________________________
178 {
180  refreshTable3D();
181 }
182 //______________________________________________________________________________
183 
185 {
186  return m_eveTopNode;
187 }
188 
189 //______________________________________________________________________________
191 {
192  // std::cout << " ----------------------------- PRECISION \n" << m_numEntry->GetNumber();
193  setCheckerState(true);
194  m_precision.set( m_numEntry->GetNumber());
196 }
197 
198 
200 {
201  //m_path.set(m_pathEntry->GetText());
202  // m_precision.set(m_numEntry->GetNumber());
203  // std::cout << " $$$$ " << m_path.value() << std::endl;
206  getTableManager()->setLevelOffset(getTableManager()->refEntries().at(getTopNodeIdx()).m_level);
207  refreshTable3D();
208 
209  setCheckerState(false);
210 }
211 
212 
213 //______________________________________________________________________________
215 {
216  m_enableRedraw = false;
217 
218  for (const_iterator it =begin(), itEnd = end(); it != itEnd; ++it)
219  {
220  (*it)->setFrom(iFrom);
221  }
222 
223  m_viewersConfig = iFrom.valueForKey("Viewers");
224  m_numEntry->SetNumber(m_precision.value());
225 
226  // refreshTable3D();
227  m_enableRedraw = true;
228  recalculate();
229 }
230 
231 //______________________________________________________________________________
233 {
234  gui.requestTab("Style").
235  // addParam(&m_enableHighlight).
236  // separator().
237  addParam(&m_rnrOverlap).
238  addParam(&m_rnrExtrusion).
239  separator().
240  addParam(&m_extrusionMarkerColor).
241  addParam(&m_overlapMarkerColor).
242  addParam(&m_pointSize);
243 
245 }
246 
247 //______________________________________________________________________________
249 {
250  m_marker->SetRnrSelf(m_drawPoints.value());
251  m_marker->ElementChanged();
252  gEve->Redraw3D();
253 }
254 
255 //______________________________________________________________________________
257 {
258  m_marker->SetMarkerSize(m_pointSize.value());
259  m_marker->ElementChanged();
260  gEve->Redraw3D();
261 }
262 
263 //______________________________________________________________________________
265 {
266  setCheckerState(true);
268 }
269 //______________________________________________________________________________
271 {
272  if (m_topNodeIdx.value() == -1) return;
273 
274  setCheckerState(true);
276 }
277 //______________________________________________________________________________
279 {
280  m_runChecker = x;
281  m_applyButton->SetForegroundColor(x ? 0xff0000 : 0x000000);
282  gClient->NeedRedraw(m_applyButton);
283 
284 }
285 //______________________________________________________________________________
286 
288 {
289  // printf(" FWOverlapTableView::chosenItem chosen item %s \n", ni->name());
290 
291  switch (menuIdx) {
293  {
294  std::cout << "=============================================================================" << std::endl << std::endl;
296  break;
297  }
298  default:
300  }
301 }
302 
303 //______________________________________________________________________________
305 {
306  using namespace TMath;
307  if (!m_enableRedraw) return;
309 
310  for (int i = 0; i < m_marker->GetPlex()->Size(); ++i)
311  {
313  TEveQuadSet::QFreeQuad_t* q = (TEveQuadSet::QFreeQuad_t*)m_marker->GetDigit(i);
314  q->fValue = -1;
315 
316  // check if any of the overlaping nodes is visible -> is in the subtree
317  bool rnr = false;
318 
319  for (std::vector<int>::iterator j = id->m_nodes.begin(); j < id->m_nodes.end(); ++j)
320  {
321  if ( (id->m_ovl->IsExtrusion() && m_rnrExtrusion.value()) || (id->m_ovl->IsOverlap() && m_rnrOverlap.value()))
322  {
324  rnr = true;
325  break;
326  }
327  }
328  }
329 
330  if (rnr) {
331  q->fValue = (id->m_ovl->IsOverlap()) ? m_overlapMarkerColor.value() : m_extrusionMarkerColor.value();
332  q->fValue += 1000;
333  }
334  }
335 
336  m_marker->ElementChanged();
337  gEve->FullRedraw3D(false, true);
338 }
void precisionCallback(Long_t)
virtual void populateController(ViewerParameterGUI &) const
TGTextButton * m_applyButton
int i
Definition: DBlmapReader.cc:9
bool isNodeRendered(int idx, int top_node_idx) const
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)
FWEveDigitSetScalableMarker * m_marker
FWBoolParameter m_listAllNodes
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:67
bool listAllNodes() const
virtual void refreshTable3D()
FWBoolParameter m_rnrExtrusion
virtual void chosenItem(int x)
const_iterator end() const
int j
Definition: DBlmapReader.cc:9
TGNumberEntry * m_numEntry
TGCheckButton * m_listOptionButton
virtual TEveElement * getEveGeoElement() const
FWLongParameter m_extrusionMarkerColor
tuple cout
Definition: gather_cfg.py:121
const FWConfiguration * valueForKey(const std::string &iKey) const
FWLongParameter m_pointSize
Definition: DDAxes.h:10
FWLongParameter m_overlapMarkerColor
FWOverlapTableManager * m_tableManager
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)