CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 //
12 
13 // system include files
14 #include <functional>
15 
16 // user include files
25 
29 
30 #include "TEveScene.h"
31 #include "TEveSceneInfo.h"
32 #include "TEveWindow.h"
33 #include "TEveManager.h"
34 
35 #include "TGeoVolume.h"
36 #include "TGeoMatrix.h"
37 #include "TGeoShape.h"
38 #include "TGeoBBox.h"
39 #include "TGeoMatrix.h"
40 #include "TGeoManager.h"
41 
42 #include "TGLViewer.h"
43 #include "KeySymbols.h"
44 #include "TGLabel.h"
45 #include "TGNumberEntry.h"
46 #include "TGListBox.h"
47 #include "TGButton.h"
48 #include "TEveViewer.h"
49 #include "TGeoOverlap.h"
50 #include "TGClient.h"
51 
52 static const std::string sUpdateMsg = "Please press Apply button to update overlaps.\n";
53 
54 FWOverlapTableView::FWOverlapTableView(TEveWindowSlot* iParent, FWColorManager* colMng)
55  : FWGeometryTableViewBase(iParent, FWViewType::kOverlapTable, colMng),
56  m_applyButton(nullptr),
57  m_listOptionButton(nullptr),
58  m_tableManager(nullptr),
59  m_numEntry(nullptr),
60  m_runChecker(true),
61  m_path(this, "Path:", std::string("/cms:World_1/cms:CMSE_1")),
62  m_precision(this, "Precision", 0.05, 0.000001, 10),
63  m_listAllNodes(this, "ListAllNodes", true),
64  m_rnrOverlap(this, "Overlap", true),
65  m_rnrExtrusion(this, "Extrusion", true),
66  m_drawPoints(this, "DrawPoints", true),
67  m_pointSize(this, "PointSize", 4l, 0l, 10l),
68  m_extrusionMarkerColor(this, "ExtrusionMarkerColor", 0l, 0l, 20l),
69  m_overlapMarkerColor(this, "OverlapMarkerColor", 9l, 0l, 20l) {
70  // top row
71  TGHorizontalFrame* hp = new TGHorizontalFrame(m_frame);
72 
73  {
74  m_viewBox = new FWViewCombo(hp, this);
75  hp->AddFrame(m_viewBox, new TGLayoutHints(kLHintsExpandY, 2, 2, 0, 0));
76  }
77 
78  {
79  TGTextButton* rb = new TGTextButton(hp, "CdTop");
80  hp->AddFrame(rb, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
81  rb->Connect("Clicked()", "FWGeometryTableViewBase", this, "cdTop()");
82  }
83 
84  {
85  TGTextButton* rb = new TGTextButton(hp, "CdUp");
86  hp->AddFrame(rb, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
87  rb->Connect("Clicked()", "FWGeometryTableViewBase", this, "cdUp()");
88  }
89  {
90  hp->AddFrame(new TGLabel(hp, "Precision:"), new TGLayoutHints(kLHintsBottom, 10, 0, 0, 2));
91  m_numEntry = new TGNumberEntry(hp,
93  5,
94  -1,
95  TGNumberFormat::kNESReal,
96  TGNumberFormat::kNEAAnyNumber,
97  TGNumberFormat::kNELLimitMinMax,
98  m_precision.min(),
99  m_precision.max());
100  hp->AddFrame(m_numEntry, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
101  m_numEntry->Connect("ValueSet(Long_t)", "FWOverlapTableView", this, "precisionCallback(Long_t)");
102  }
103 
104  {
105  m_listOptionButton = new TGCheckButton(hp, m_listAllNodes.name().c_str());
106  m_listOptionButton->SetState(m_listAllNodes.value() ? kButtonDown : kButtonUp);
107  m_listOptionButton->Connect("Clicked()", "FWOverlapTableView", this, "setListAllNodes()");
108  hp->AddFrame(m_listOptionButton, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 0, 1, 1));
109  }
110  {
111  m_applyButton = new TGTextButton(hp, "Apply");
112  hp->AddFrame(m_applyButton, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
113  m_applyButton->Connect("Clicked()", "FWOverlapTableView", this, "recalculate()");
114  }
115 
116  m_frame->AddFrame(hp, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 4, 2, 2, 0));
118 
119  // std::cerr << " FWOverlapTableView::initGeometry \n";
120 
121  FWGeoTopNodeGLScene* gls = new FWGeoTopNodeGLScene(nullptr);
122 #if ROOT_VERSION_CODE < ROOT_VERSION(5, 32, 0)
123  m_eveScene = new FWGeoTopNodeEveScene(gls, "TopGeoNodeScene", "");
124 #else
125  m_eveScene = new TEveScene(gls, "TopGeoNodeScene", "");
126 #endif
127 
128  gEve->GetScenes()->AddElement(m_eveScene);
129 
130  m_eveTopNode = new FWEveOverlap(this);
131  m_eveTopNode->SetElementNameTitle("overlapNode", "opverlapNodetitle");
132  m_eveTopNode->IncDenyDestroy();
133  m_eveTopNode->SetPickable(true);
134  m_eveScene->AddElement(m_eveTopNode);
135 
136  gls->m_eveTopNode = m_eveTopNode;
137  m_eveTopNode->m_scene = gls;
138 
140  m_marker->SetMainColor(kRed);
141  m_marker->IncDenyDestroy();
142  m_marker->Reset(TEveQuadSet::kQT_FreeQuad, kFALSE, 32);
143  m_marker->SetOwnIds(kTRUE);
144  m_marker->SetAlwaysSecSelect(kTRUE);
145  m_marker->SetPickable(kTRUE);
146  m_marker->SetOwnIds(kTRUE);
147 
148  m_drawPoints.changed_.connect(std::bind(&FWOverlapTableView::drawPoints, this));
149  m_pointSize.changed_.connect(std::bind(&FWOverlapTableView::pointSize, this));
150  m_rnrOverlap.changed_.connect(std::bind(&FWOverlapTableView::refreshTable3D, this));
154 
155  postConst();
156 }
157 //______________________________________________________________________________
158 
160  if (m_marker)
161  m_marker->DecDenyDestroy();
162 }
163 
164 //______________________________________________________________________________
166 
167 //______________________________________________________________________________
169 
170 //______________________________________________________________________________
173  refreshTable3D();
174 }
175 //______________________________________________________________________________
176 
177 TEveElement* FWOverlapTableView::getEveGeoElement() const { return m_eveTopNode; }
178 
179 //______________________________________________________________________________
181  // std::cout << " ----------------------------- PRECISION \n" << m_numEntry->GetNumber();
182  setCheckerState(true);
183  m_precision.set(m_numEntry->GetNumber());
185 }
186 
188  //m_path.set(m_pathEntry->GetText());
189  // m_precision.set(m_numEntry->GetNumber());
190  // std::cout << " $$$$ " << m_path.value() << std::endl;
193  getTableManager()->setLevelOffset(getTableManager()->refEntries().at(getTopNodeIdx()).m_level);
194  refreshTable3D();
195 
196  setCheckerState(false);
197 }
198 
199 //______________________________________________________________________________
201  m_enableRedraw = false;
202 
203  for (const_iterator it = begin(), itEnd = end(); it != itEnd; ++it) {
204  (*it)->setFrom(iFrom);
205  }
206 
207  m_viewersConfig = iFrom.valueForKey("Viewers");
208  m_numEntry->SetNumber(m_precision.value());
209 
210  // refreshTable3D();
211  m_enableRedraw = true;
212  recalculate();
213 }
214 
215 //______________________________________________________________________________
217  gui.requestTab("Style")
218  .
219  // addParam(&m_enableHighlight).
220  // separator().
221  addParam(&m_rnrOverlap)
223  .separator()
227 
229 }
230 
231 //______________________________________________________________________________
233  m_marker->SetRnrSelf(m_drawPoints.value());
234  m_marker->ElementChanged();
235  gEve->Redraw3D();
236 }
237 
238 //______________________________________________________________________________
240  m_marker->SetMarkerSize(m_pointSize.value());
241  m_marker->ElementChanged();
242  gEve->Redraw3D();
243 }
244 
245 //______________________________________________________________________________
247  setCheckerState(true);
249 }
250 //______________________________________________________________________________
252  if (m_topNodeIdx.value() == -1)
253  return;
254 
255  setCheckerState(true);
257 }
258 //______________________________________________________________________________
260  m_runChecker = x;
261  m_applyButton->SetForegroundColor(x ? 0xff0000 : 0x000000);
262  gClient->NeedRedraw(m_applyButton);
263 }
264 //______________________________________________________________________________
265 
267  // printf(" FWOverlapTableView::chosenItem chosen item %s \n", ni->name());
268 
269  switch (menuIdx) {
271  std::cout << "=============================================================================" << std::endl
272  << std::endl;
274  break;
275  }
276  default:
278  }
279 }
280 
281 //______________________________________________________________________________
283  using namespace TMath;
284  if (!m_enableRedraw)
285  return;
287 
288  for (int i = 0; i < m_marker->GetPlex()->Size(); ++i) {
290  TEveQuadSet::QFreeQuad_t* q = (TEveQuadSet::QFreeQuad_t*)m_marker->GetDigit(i);
291  q->fValue = -1;
292 
293  // check if any of the overlaping nodes is visible -> is in the subtree
294  bool rnr = false;
295 
296  for (std::vector<int>::iterator j = id->m_nodes.begin(); j < id->m_nodes.end(); ++j) {
297  if ((id->m_ovl->IsExtrusion() && m_rnrExtrusion.value()) || (id->m_ovl->IsOverlap() && m_rnrOverlap.value())) {
299  rnr = true;
300  break;
301  }
302  }
303  }
304 
305  if (rnr) {
306  q->fValue = (id->m_ovl->IsOverlap()) ? m_overlapMarkerColor.value() : m_extrusionMarkerColor.value();
307  q->fValue += 1000;
308  }
309  }
310 
311  m_marker->ElementChanged();
312  gEve->FullRedraw3D(false, true);
313 }
void precisionCallback(Long_t)
TGTextButton * m_applyButton
bool isNodeRendered(int idx, int top_node_idx) const
FWStringParameter m_path
FWGeoTopNode * m_eveTopNode
const_iterator begin() const
FWBoolParameter m_rnrOverlap
FWOverlapTableView(TEveWindowSlot *iParent, FWColorManager *colMng)
void populateController(ViewerParameterGUI &) const override
FWEveDigitSetScalableMarker * m_marker
FWBoolParameter m_listAllNodes
ViewerParameterGUI & requestTab(const char *)
const FWConfiguration * m_viewersConfig
FWGeometryTableManagerBase * getTableManager() override
ViewerParameterGUI & separator()
void setFrom(const FWConfiguration &) override
std::vector< FWParameterBase * >::const_iterator const_iterator
int getFirstSelectedTableIndex()
void refreshTable3D() override
FWBoolParameter m_drawPoints
FWDoubleParameter m_precision
FWGeoTopNodeGLScene * m_scene
Definition: FWGeoTopNode.h:66
bool listAllNodes() const
void chosenItem(int x) override
FWBoolParameter m_rnrExtrusion
const_iterator end() const
TGNumberEntry * m_numEntry
TGCheckButton * m_listOptionButton
void populateController(ViewerParameterGUI &) const override
virtual TEveElement * getEveGeoElement() const
ViewerParameterGUI & addParam(const FWParameterBase *)
FWLongParameter m_extrusionMarkerColor
float x
tuple cout
Definition: gather_cfg.py:144
const FWConfiguration * valueForKey(const std::string &iKey) const
FWLongParameter m_pointSize
sigc::signal< void(T)> changed_
FWLongParameter m_overlapMarkerColor
FWOverlapTableManager * m_tableManager
static const std::string sUpdateMsg
const std::string & name() const
void importOverlaps(std::string path, double precision)