CMS 3D CMS Logo

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 <boost/bind.hpp>
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 
36 #include "TGeoVolume.h"
37 #include "TGeoMatrix.h"
38 #include "TGeoShape.h"
39 #include "TGeoBBox.h"
40 #include "TGeoMatrix.h"
41 #include "TGeoManager.h"
42 
43 #include "TGLViewer.h"
44 #include "KeySymbols.h"
45 #include "TGLabel.h"
46 #include "TGNumberEntry.h"
47 #include "TGListBox.h"
48 #include "TGButton.h"
49 #include "TEveViewer.h"
50 #include "TGeoOverlap.h"
51 #include "TGClient.h"
52 
53 static const std::string sUpdateMsg = "Please press Apply button to update overlaps.\n";
54 
55 
56 FWOverlapTableView::FWOverlapTableView(TEveWindowSlot* iParent, FWColorManager* colMng) :
57  FWGeometryTableViewBase(iParent, FWViewType::kOverlapTable, colMng),
58  m_applyButton(nullptr),
59  m_listOptionButton(nullptr),
60  m_tableManager(nullptr),
61  m_numEntry(nullptr),
62  m_runChecker(true),
63  m_path(this,"Path:", std::string("/cms:World_1/cms:CMSE_1")),
64  m_precision(this, "Precision", 0.05, 0.000001, 10),
65  m_listAllNodes(this, "ListAllNodes", true),
66  m_rnrOverlap(this, "Overlap", true),
67  m_rnrExtrusion(this, "Extrusion", true),
68  m_drawPoints(this, "DrawPoints", true),
69  m_pointSize(this, "PointSize", 4l, 0l, 10l),
70  m_extrusionMarkerColor(this, "ExtrusionMarkerColor", 0l, 0l, 20l),
71  m_overlapMarkerColor(this, "OverlapMarkerColor", 9l, 0l, 20l)
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 
117  FWGeoTopNodeGLScene *gls = new FWGeoTopNodeGLScene(nullptr);
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 
136  m_marker->SetMainColor(kRed);
137  m_marker->IncDenyDestroy();
138  m_marker->Reset(TEveQuadSet::kQT_FreeQuad, kFALSE, 32);
139  m_marker->SetOwnIds(kTRUE);
140  m_marker->SetAlwaysSecSelect(kTRUE);
141  m_marker->SetPickable(kTRUE);
142  m_marker->SetOwnIds(kTRUE);
143 
144 
145  m_drawPoints.changed_.connect(boost::bind(&FWOverlapTableView::drawPoints,this));
146  m_pointSize.changed_.connect(boost::bind(&FWOverlapTableView::pointSize,this));
147  m_rnrOverlap.changed_.connect(boost::bind(&FWOverlapTableView::refreshTable3D,this));
151 
152  postConst();
153 }
154 //______________________________________________________________________________
155 
156 
158 {
159  if (m_marker) m_marker->DecDenyDestroy();
160 }
161 
162 //______________________________________________________________________________
164 {
165  return m_tableManager;
166 }
167 
168 //______________________________________________________________________________
170 {
171  return m_listAllNodes.value();
172 }
173 
174 //______________________________________________________________________________
176 {
178  refreshTable3D();
179 }
180 //______________________________________________________________________________
181 
183 {
184  return m_eveTopNode;
185 }
186 
187 //______________________________________________________________________________
189 {
190  // std::cout << " ----------------------------- PRECISION \n" << m_numEntry->GetNumber();
191  setCheckerState(true);
192  m_precision.set( m_numEntry->GetNumber());
194 }
195 
196 
198 {
199  //m_path.set(m_pathEntry->GetText());
200  // m_precision.set(m_numEntry->GetNumber());
201  // std::cout << " $$$$ " << m_path.value() << std::endl;
204  getTableManager()->setLevelOffset(getTableManager()->refEntries().at(getTopNodeIdx()).m_level);
205  refreshTable3D();
206 
207  setCheckerState(false);
208 }
209 
210 
211 //______________________________________________________________________________
213 {
214  m_enableRedraw = false;
215 
216  for (const_iterator it =begin(), itEnd = end(); it != itEnd; ++it)
217  {
218  (*it)->setFrom(iFrom);
219  }
220 
221  m_viewersConfig = iFrom.valueForKey("Viewers");
222  m_numEntry->SetNumber(m_precision.value());
223 
224  // refreshTable3D();
225  m_enableRedraw = true;
226  recalculate();
227 }
228 
229 //______________________________________________________________________________
231 {
232  gui.requestTab("Style").
233  // addParam(&m_enableHighlight).
234  // separator().
235  addParam(&m_rnrOverlap).
236  addParam(&m_rnrExtrusion).
237  separator().
238  addParam(&m_extrusionMarkerColor).
239  addParam(&m_overlapMarkerColor).
240  addParam(&m_pointSize);
241 
243 }
244 
245 //______________________________________________________________________________
247 {
248  m_marker->SetRnrSelf(m_drawPoints.value());
249  m_marker->ElementChanged();
250  gEve->Redraw3D();
251 }
252 
253 //______________________________________________________________________________
255 {
256  m_marker->SetMarkerSize(m_pointSize.value());
257  m_marker->ElementChanged();
258  gEve->Redraw3D();
259 }
260 
261 //______________________________________________________________________________
263 {
264  setCheckerState(true);
266 }
267 //______________________________________________________________________________
269 {
270  if (m_topNodeIdx.value() == -1) return;
271 
272  setCheckerState(true);
274 }
275 //______________________________________________________________________________
277 {
278  m_runChecker = x;
279  m_applyButton->SetForegroundColor(x ? 0xff0000 : 0x000000);
280  gClient->NeedRedraw(m_applyButton);
281 
282 }
283 //______________________________________________________________________________
284 
286 {
287  // printf(" FWOverlapTableView::chosenItem chosen item %s \n", ni->name());
288 
289  switch (menuIdx) {
291  {
292  std::cout << "=============================================================================" << std::endl << std::endl;
294  break;
295  }
296  default:
298  }
299 }
300 
301 //______________________________________________________________________________
303 {
304  using namespace TMath;
305  if (!m_enableRedraw) return;
307 
308  for (int i = 0; i < m_marker->GetPlex()->Size(); ++i)
309  {
311  TEveQuadSet::QFreeQuad_t* q = (TEveQuadSet::QFreeQuad_t*)m_marker->GetDigit(i);
312  q->fValue = -1;
313 
314  // check if any of the overlaping nodes is visible -> is in the subtree
315  bool rnr = false;
316 
317  for (std::vector<int>::iterator j = id->m_nodes.begin(); j < id->m_nodes.end(); ++j)
318  {
319  if ( (id->m_ovl->IsExtrusion() && m_rnrExtrusion.value()) || (id->m_ovl->IsOverlap() && m_rnrOverlap.value()))
320  {
321  if (*j == getTopNodeIdx() || m_tableManager->isNodeRendered(*j, getTopNodeIdx() )) {
322  rnr = true;
323  break;
324  }
325  }
326  }
327 
328  if (rnr) {
329  q->fValue = (id->m_ovl->IsOverlap()) ? m_overlapMarkerColor.value() : m_extrusionMarkerColor.value();
330  q->fValue += 1000;
331  }
332  }
333 
334  m_marker->ElementChanged();
335  gEve->FullRedraw3D(false, true);
336 }
void precisionCallback(Long_t)
TGTextButton * m_applyButton
bool isNodeRendered(int idx, int top_node_idx) const
FWStringParameter m_path
string separator
Definition: mps_merge.py:79
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
void populateController(ViewerParameterGUI &) const override
FWBoolParameter m_listAllNodes
ViewerParameterGUI & requestTab(const char *)
#define nullptr
const FWConfiguration * m_viewersConfig
FWGeometryTableManagerBase * getTableManager() override
void setFrom(const FWConfiguration &) override
sigc::signal< void, T > changed_
int getFirstSelectedTableIndex()
void refreshTable3D() override
FWBoolParameter m_drawPoints
FWDoubleParameter m_precision
FWGeoTopNodeGLScene * m_scene
Definition: FWGeoTopNode.h:68
bool listAllNodes() const
void chosenItem(int x) override
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
FWBoolParameter m_rnrExtrusion
const_iterator end() const
TGNumberEntry * m_numEntry
TGCheckButton * m_listOptionButton
virtual TEveElement * getEveGeoElement() const
FWLongParameter m_extrusionMarkerColor
const FWConfiguration * valueForKey(const std::string &iKey) const
FWLongParameter m_pointSize
FWLongParameter m_overlapMarkerColor
FWOverlapTableManager * m_tableManager
static const std::string sUpdateMsg
void populateController(ViewerParameterGUI &) const override
const std::string & name() const
void importOverlaps(std::string path, double precision)