CMS 3D CMS Logo

FWEveViewManager.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWEveViewManager
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Chris Jones, Alja Mrak-Tadel
10 // Created: Thu Mar 18 14:11:32 CET 2010
11 //
12 
13 // system include files
14 
15 #include <boost/bind.hpp>
16 
17 
18 // user include files
19 #include "TEveManager.h"
20 #include "TEveSelection.h"
21 #include "TEveScene.h"
22 #include "TEveViewer.h"
23 #include "TEveCalo.h"
24 #include "TEveGedEditor.h"
25 #include "TGListTree.h"
26 #include "TGeoManager.h"
27 #include "TExMap.h"
28 #include "TEnv.h"
29 
39 
40 // PB
47 
48 // viewes
56 
59 
60 class FWViewContext;
61 
62 // sentry class block TEveSelection signals when call TEveSelection::Remove/AddElement and
63 // when process its callbacks
65 public:
67  {
68  m_blocked = gEve->GetSelection()->BlockSignals(true);
69  }
71  {
72  gEve->GetSelection()->BlockSignals(m_blocked);
73  }
74 private:
75  bool m_blocked;
76 };
77 
78 //
79 //
80 // constants, enums and typedefs
81 //
82 //
83 // constructors and destructor
84 //
87 {
88 
89  // builders
90  std::set<std::string> builders;
91 
92  std::vector<edmplugin::PluginInfo> available = FWProxyBuilderFactory::get()->available();
93  std::transform(available.begin(),
94  available.end(),
95  std::inserter(builders,builders.begin()),
96  boost::bind(&edmplugin::PluginInfo::name_,_1));
97 
100  std::transform(available.begin(),
101  available.end(),
102  std::inserter(builders,builders.begin()),
103  boost::bind(&edmplugin::PluginInfo::name_,_1));
104  }
105 
106 
107  for(std::set<std::string>::iterator it = builders.begin(), itEnd=builders.end();
108  it!=itEnd;
109  ++it) {
110  std::string::size_type first = it->find_first_of('@')+1;
111  std::string purpose = it->substr(first,it->find_last_of('@')-first);
112 
113  first = it->find_last_of('@')+1;
114  std::string view_str = it->substr(first,it->find_last_of('#')-first);
115  int viewTypes = atoi(view_str.c_str());
116  std::string fullName = *it;
117  m_typeToBuilder[purpose].push_back(BuilderInfo(*it, viewTypes));
118  }
119 
121 
122  // view construction called via GUI mng
123  FWGUIManager::ViewBuildFunctor f = boost::bind(&FWEveViewManager::buildView, this, _1, _2);
124  for (int i = 0; i < FWViewType::kTypeSize; i++)
125  {
127  continue;
129  }
130 
131  // signal
132  gEve->GetHighlight()->SetPickToSelect(TEveSelection::kPS_Master);
133  TEveSelection* eveSelection = gEve->GetSelection();
134  eveSelection->SetPickToSelect(TEveSelection::kPS_Master);
135  eveSelection->Connect("SelectionAdded(TEveElement*)","FWEveViewManager",this,"selectionAdded(TEveElement*)");
136  eveSelection->Connect("SelectionRepeated(TEveElement*)","FWEveViewManager",this,"selectionAdded(TEveElement*)");
137  eveSelection->Connect("SelectionRemoved(TEveElement*)","FWEveViewManager",this,"selectionRemoved(TEveElement*)");
138  eveSelection->Connect("SelectionCleared()","FWEveViewManager",this,"selectionCleared()");
139 
140  gEve->GetHighlight()->Connect("SelectionAdded(TEveElement*)","FWEveViewManager",this,"highlightAdded(TEveElement*)");
141  gEve->GetHighlight()->Connect("SelectionRepeated(TEveElement*)","FWEveViewManager",this,"highlightAdded(TEveElement*)");
142 
143  TGeoManager::SetVerboseLevel(0);
144 }
145 
147 {
148 }
149 
150 //
151 // member functions
152 //
153 
154 //______________________________________________________________________________
155 
161 void
162 addElements(const FWEventItem *item, FWEveView *view,
163  int viewType, TEveElementList* product)
164 {
165  if (FWViewType::isProjected(viewType))
166  {
167  FWRPZView* rpzView = dynamic_cast<FWRPZView*>(view);
168  assert(rpzView);
169  rpzView->importElements(product, item->layer(), rpzView->eventScene());
170  }
171  else
172  {
173  view->eventScene()->AddElement(product);
174  }
175 }
176 
191 void
193 {
194  TypeToBuilder::iterator itFind = m_typeToBuilder.find(iItem->purpose());
195 
196  if (itFind == m_typeToBuilder.end())
197  return;
198 
199  std::vector<BuilderInfo>& blist = itFind->second;
200 
201  std::string bType; bool bIsSimple;
202  for (size_t bii = 0, bie = blist.size(); bii != bie; ++bii)
203  {
204  // 1.
205  BuilderInfo &info = blist[bii];
206  info.classType(bType, bIsSimple);
207  if (bIsSimple)
208  {
209  unsigned int distance=1;
210  edm::TypeWithDict modelType( *(iItem->modelType()->GetTypeInfo()));
211  if (!FWSimpleRepresentationChecker::inheritsFrom(modelType, bType,distance))
212  {
213  // printf("PB does not matche itemType (%s) !!! EDproduct %s %s\n", info.m_name.c_str(), iItem->modelType()->GetTypeInfo()->name(), bType.c_str() );
214  continue;
215  }
216  }
217  else {
218  std::string itype = iItem->type()->GetTypeInfo()->name();
219  if (itype != bType) {
220  // printf("PB does not match modeType (%s)!!! EDproduct %s %s\n", info.m_name.c_str(), itype.c_str(), bType.c_str() );
221  continue;
222  }
223  }
224 
225  std::string builderName = info.m_name;
226  int builderViewBit = info.m_viewBit;
227 
228  FWProxyBuilderBase* builder = nullptr;
229  try
230  {
231  builder = FWProxyBuilderFactory::get()->create(builderName);
232 
233  }
234  catch (std::exception& exc)
235  {
236  fwLog(fwlog::kWarning) << "FWEveViewManager::newItem ignoring the following exception (probably edmplugincache mismatch):"
237  << std::endl << exc.what();
238  }
239  if (!builder)
240  continue;
241 
242  // 2.
243  // printf("FWEveViewManager::makeProxyBuilderFor NEW builder %s \n", builderName.c_str());
244 
245  std::shared_ptr<FWProxyBuilderBase> pB(builder);
246  builder->setItem(iItem);
247  iItem->changed_.connect(boost::bind(&FWEveViewManager::modelChanges,this,_1));
248  iItem->goingToBeDestroyed_.connect(boost::bind(&FWEveViewManager::removeItem,this,_1));
249  iItem->itemChanged_.connect(boost::bind(&FWEveViewManager::itemChanged,this,_1));
250 
251  // 3.
252  // This calud be opaque to the user. I would pass a reference to the m_interactionLists to
253  // FWProxyBuilderBase::setInteractionList and handle different case differently.
254  if (builder->willHandleInteraction() == false)
255  {
256  typedef std::map<const FWEventItem*, FWInteractionList*>::iterator Iterator;
257  std::pair<Iterator, bool> t = m_interactionLists.insert(std::make_pair(iItem,
258  (FWInteractionList*)nullptr));
259 
260  if (t.second == true)
261  t.first->second = new FWInteractionList(iItem);
262  // printf(">>> builder %s add list %p \n", iItem->name().c_str(), il); fflush(stdout);
263  builder->setInteractionList(t.first->second, iItem->purpose());
264  }
265 
266  builder->setHaveWindow(haveViewForBit(builderViewBit));
267 
268  // 4.
269  for (size_t viewType = 0; viewType < FWViewType::kTypeSize; ++viewType)
270  {
271  if (((1 << viewType) & builderViewBit) == 0)
272  continue;
273 
275 
276  // printf("%s builder %s supportsd view %s \n", iItem->name().c_str(), builderName.c_str(), FWViewType::idToName(viewType).c_str());
277  if (builder->havePerViewProduct((FWViewType::EType) viewType))
278  {
279  for (size_t i = 0, e = m_views[viewType].size(); i != e; ++i)
280  {
281  FWEveView *view = m_views[viewType][i].get();
282  TEveElementList* product = builder->createProduct(type,
283  view->viewContext());
284  addElements(iItem, view, viewType, product);
285  }
286  }
287  else
288  {
289  TEveElementList* product = builder->createProduct(type, nullptr);
290 
291  for (size_t i = 0, e = m_views[viewType].size(); i != e; ++i)
292  addElements(iItem, m_views[viewType][i].get(), viewType, product);
293  }
294  }
295 
296  m_builders[builderViewBit].push_back(pB);
297  } // loop views
298 }
299 
300 //______________________________________________________________________________
301 FWViewBase*
302 FWEveViewManager::buildView(TEveWindowSlot* iParent, const std::string& viewName)
303 {
305  for (int i = 0; i < FWViewType::kTypeSize; ++i)
306  {
307  if (viewName == FWViewType::idToName(i))
308  {
309  type = FWViewType::EType(i);
310  break;
311  }
312  }
313 
314  std::shared_ptr<FWEveView> view;
315  switch(type)
316  {
317  case FWViewType::k3D:
318  view.reset(new FW3DView(iParent, type));
319  break;
320  case FWViewType::kISpy:
321  view.reset(new FWISpyView(iParent, type));
322  break;
323  case FWViewType::kRhoPhi:
324  case FWViewType::kRhoZ:
326  view.reset(new FWRPZView(iParent, type));
327  break;
328  case FWViewType::kLego:
330  view.reset(new FWEveLegoView(iParent, type));
331  break;
332  case FWViewType::kLegoHF:
333  view.reset(new FWHFView(iParent, type));
334  break;
336  view.reset(new FWGlimpseView(iParent, type));
337  break;
338  default:
339  break;
340  }
341 
342  m_views[type].push_back(std::shared_ptr<FWEveView> (view));
343  return finishViewCreate(m_views[type].back());
344 }
345 
346 FWEveView*
347 FWEveViewManager::finishViewCreate(std::shared_ptr<FWEveView> view)
348 {
349  // printf("new view %s added \n", view->typeName().c_str());
350  gEve->DisableRedraw();
351 
352  // set geometry and calo data
353  view->setContext(context());
354 
356 
357  // set proxies have a window falg
358  int viewerBit = 1 << view->typeId();
359  if (m_views[view->typeId()].size() == 1)
360  {
361  for ( std::map<int, BuilderVec>::iterator i = m_builders.begin(); i!= m_builders.end(); ++i)
362  {
363  int builderViewBit = i->first;
364  BuilderVec& bv = i->second;
365  if (viewerBit == (builderViewBit & viewerBit))
366  {
367  for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
368  {
369  (*bIt)->setHaveWindow(true);
370  }
371  }
372  }
373  }
374 
375  FWRPZView* rpzView = dynamic_cast<FWRPZView*>(view.get());
376  for ( std::map<int, BuilderVec>::iterator i = m_builders.begin(); i!= m_builders.end(); ++i)
377  {
378  int builderViewBit = i->first;
379  BuilderVec& bv = i->second;
380  if (viewerBit == (builderViewBit & viewerBit))
381  {
382  for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
383  {
384  // it is ok to call create even for shared productsm since
385  // builder map key garanties that
386  TEveElementList* product = (*bIt)->createProduct(view->typeId(), view->viewContext());
387 
388  if ((*bIt)->havePerViewProduct((FWViewType::EType)view->typeId()))
389  {
390  // view owned
391  (*bIt)->build();
392  if (rpzView)
393  {
394  rpzView->importElements(product, (*bIt)->item()->layer(), rpzView->ownedProducts());
395  }
396  else
397  {
398  view->ownedProducts()->AddElement(product);
399  }
400  }
401  else
402  {
403  // shared
404  if (rpzView)
405  {
406  rpzView->importElements(product, (*bIt)->item()->layer(), rpzView->eventScene());
407  }
408  else
409  {
410  view->eventScene()->AddElement(product);
411  }
412 
413  }
414  }
415  }
416  }
417 
418  view->beingDestroyed_.connect(boost::bind(&FWEveViewManager::beingDestroyed,this,_1));
419 
420  view->setupEnergyScale(); // notify PB for energy scale
421 
422  gEve->EnableRedraw();
423  view->viewerGL()->UpdateScene();
424  gEve->Redraw3D();
425 
426  return view.get();
427 }
428 
429 void
431 {
432  FWEveView* view = (FWEveView*) vb;
433  int typeId = view->typeId();
434 
435  int viewerBit = 1 << typeId;
436  int nviews = m_views[typeId].size();
437  for ( std::map<int, BuilderVec>::iterator i = m_builders.begin(); i!= m_builders.end(); ++i)
438  {
439  int builderBit = i->first;
440  if (viewerBit == (builderBit & viewerBit)) // check only in case if connected
441  {
442  BuilderVec& bv = i->second;
443 
444  // remove view-owned product
445  if (viewerBit == (builderBit & viewerBit))
446  {
447  for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
448  (*bIt)->removePerViewProduct(view->typeId(), view->viewContext());
449  }
450 
451  // and setup proxy builders have-a-window flag
452  if (nviews == 1)
453  {
454  if (!haveViewForBit(builderBit))
455  {
456  if (viewerBit == (builderBit & viewerBit))
457  {
458  for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
459  (*bIt)->setHaveWindow(false);
460  }
461  }
462  }
463  }
464  }
465 
466 
467  for(EveViewVec_it i= m_views[typeId].begin(); i != m_views[typeId].end(); ++i) {
468  if(i->get() == vb) {
469  m_views[typeId].erase(i);
470  break;
471  }
472  }
473 }
474 
475 //______________________________________________________________________________
476 
477 void
479 {
480  gEve->DisableRedraw();
481 }
482 
483 void
485 {
486  gEve->EnableRedraw();
487 }
488 
490 void
492 {
493  FWModelId id = *(iIds.begin());
494  const FWEventItem* item = id.item();
495 
496  // in standard case new elements can be build in case of change of visibility
497  // and in non-standard case (e.g. calo towers) PB's modelChages handles all changes
498  bool itemHaveWindow = false;
499  for (std::map<int, BuilderVec>::iterator i = m_builders.begin();
500  i != m_builders.end(); ++i)
501  {
502  for (size_t bi = 0, be = i->second.size(); bi != be; ++bi)
503  {
504  FWProxyBuilderBase *builder = i->second[bi].get();
505  if (builder->getHaveWindow() && builder->item() == item)
506  {
507  builder->modelChanges(iIds);
508  itemHaveWindow = true;
509  }
510  }
511  }
512 
513  if (!itemHaveWindow)
514  return;
515 
517 
518  std::map<const FWEventItem*, FWInteractionList*>::iterator it = m_interactionLists.find(item);
519  if (it != m_interactionLists.end())
520  {
521  if (!it->second->empty())
522  it->second->modelChanges(iIds);
523  }
524 }
525 
531 void
533 {
534  if (!item)
535  return;
536 
537  bool itemHaveWindow = false;
538 
539  for (std::map<int, BuilderVec>::iterator i = m_builders.begin();
540  i != m_builders.end(); ++i)
541  {
542  for(size_t bi = 0, be = i->second.size(); bi != be; ++bi)
543  {
544  FWProxyBuilderBase *builder = i->second[bi].get();
545 
546  if (builder->item() != item)
547  continue;
548 
549  builder->itemChanged(item);
550  itemHaveWindow |= builder->getHaveWindow();
551  }
552  }
553 
554  if (!itemHaveWindow)
555  return;
556 
557  std::map<const FWEventItem*, FWInteractionList*>::iterator it = m_interactionLists.find(item);
558  if (it != m_interactionLists.end())
559  {
560  if (!it->second->empty())
561  it->second->itemChanged();
562  }
563 }
564 
567 void
569 {
571 
572  std::map<const FWEventItem*, FWInteractionList*>::iterator it = m_interactionLists.find(item);
573  if (it != m_interactionLists.end())
574  {
575  delete it->second;
576  m_interactionLists.erase(it);
577  }
578 
579  for (std::map<int, BuilderVec>::iterator i = m_builders.begin();
580  i != m_builders.end(); ++i)
581  {
582  BuilderVec_it bIt = i->second.begin();
583  while( bIt != i->second.end() )
584  {
585  if ((*bIt)->item() == item)
586  {
587  // TODO caching of proxy builders
588  (*bIt)->itemBeingDestroyed(item);
589  bIt = i->second.erase(bIt);
590  }
591  else
592  {
593  ++bIt;
594  }
595  }
596  }
597 }
598 
599 void
601 {
604  x->commonPrefs()->eventCenterChanged_.connect(boost::bind(&FWEveViewManager::eventCenterChanged,this));
605 }
606 
607 void
609 {
610  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
611  {
612  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
613  {
614  if ((*i)->isEnergyScaleGlobal())
615  {
616  (*i)->setupEnergyScale();
617  }
618  }
619 
620  }
621 }
622 
623 void
625 {
626  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
627  {
628  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
629  {
630  (*i)->setupEventCenter();
631  }
632  }
633 
634 }
635 
636 void
638 {
639  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
640  {
641  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
642  (*i)->setBackgroundColor(colorManager().background());
643  }
644 }
645 
646 //______________________________________________________________________________
647 void
649 {
650  // Prevent registration of redraw timer, full redraw is done in
651  // FWEveViewManager::eventEnd().
652  gEve->EnforceTimerActive(kTRUE);
653  gEve->DisableRedraw();
654 
656 
657  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
658  {
659  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
660  (*i)->eventBegin();
661  }
662 }
663 
664 void
666 {
667  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
668  {
669  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
670  (*i)->eventEnd();
671  }
672 
673  // What follows is a copy of TEveManager::DoRedraw3D() with the difference that
674  // we have full control over execution of GL view rendering. In particular:
675  // - optionally delay buffer swapping so they can all be swapped together;
676  // - we could render into FBO once and then use this to be put on screen
677  // and saved into an image file.
678 
679  {
680  TEveElement::List_t scenes;
681  Long64_t key, value;
682  TExMapIter stamped_elements(gEve->PtrToStampedElements());
683  while (stamped_elements.Next(key, value))
684  {
685  TEveElement *el = reinterpret_cast<TEveElement*>(key);
686  if (el->GetChangeBits() & TEveElement::kCBVisibility)
687  {
688  el->CollectSceneParents(scenes);
689  }
690  }
691  gEve->ScenesChanged(scenes);
692  }
693 
694  // Process changes in scenes.
695  gEve->GetScenes()->ProcessSceneChanges(kFALSE, gEve->PtrToStampedElements());
696 
697  // To synchronize buffer swapping set swap_on_render to false.
698  // Note that this costs 25-40% extra time with 4 views, depending on V-sync settings.
699  // Tested with NVIDIA 343.22.
700  const bool swap_on_render = !s_syncAllViews;
701 
702  // Loop over viewers, swap buffers if swap_on_render is true.
703  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
704  {
705  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
706  (*i)->fwViewerGL()->DrawHiLod(swap_on_render);
707  }
708 
709  // Swap buffers if they were not swapped before.
710  if ( ! swap_on_render)
711  {
712  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
713  {
714  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
715  (*i)->fwViewerGL()->JustSwap();
716  }
717  }
718 
719  gEve->GetViewers()->RepaintChangedViewers(kFALSE, kFALSE);
720 
721  {
722  Long64_t key, value;
723  TExMapIter stamped_elements(gEve->PtrToStampedElements());
724  while (stamped_elements.Next(key, value))
725  {
726  TEveElement *el = reinterpret_cast<TEveElement*>(key);
727  if (gEve->GetEditor()->GetModel() == el->GetEditorObject("FWEveViewManager::eventEnd"))
728  gEve->EditElement(el);
729  TEveGedEditor::ElementChanged(el);
730 
731  el->ClearStamps();
732  }
733  }
734  gEve->PtrToStampedElements()->Delete();
735 
736  gEve->GetListTree()->ClearViewPort(); // Fix this when several list-trees can be added.
737 
738  gEve->EnableRedraw();
739  gEve->EnforceTimerActive(kFALSE);
740 }
741 
742 //______________________________________________________________________________
743 
746 FWFromEveSelectorBase *getSelector(TEveElement *iElement)
747 {
748  if (!iElement)
749  return nullptr;
750 
751  //std::cout <<" non null"<<std::endl;
752  void* userData = iElement->GetUserData();
753  //std::cout <<" user data "<<userData<<std::endl;
754  if (!userData)
755  return nullptr;
756 
757  //std::cout <<" have userData"<<std::endl;
758  //std::cout <<" calo"<<std::endl;
760  return reinterpret_cast<FWFromEveSelectorBase*> (userData);
761 }
762 
763 void
764 FWEveViewManager::selectionAdded(TEveElement* iElement)
765 {
766  FWFromEveSelectorBase* selector = getSelector(iElement);
767  if (selector)
768  selector->doSelect();
769 }
770 
771 void
773 {
774  FWFromEveSelectorBase* selector = getSelector(iElement);
775  if (selector)
776  selector->doUnselect();
777 }
778 
779 void
781 {
783 }
784 
785 
786 //
787 // const member functions
788 //
789 
792 {
793  // needed for add collection GUI
794  FWTypeToRepresentations returnValue;
795  const static std::string kFullFrameWorkPBExtension = "FullFramework";
796  for(TypeToBuilder::const_iterator it = m_typeToBuilder.begin(), itEnd = m_typeToBuilder.end();
797  it != itEnd;
798  ++it)
799  {
800  std::vector<BuilderInfo> blist = it->second;
801  for (size_t bii = 0, bie = blist.size(); bii != bie; ++bii)
802  {
803  BuilderInfo &info = blist[bii];
804 
805  if (context().getHidePFBuilders()) {
806  const static std::string pfExt = "PF ";
807  if (std::string::npos != info.m_name.find(pfExt))
808  continue;
809  }
810 
811  unsigned int bitPackedViews = info.m_viewBit;
812  bool representsSubPart = (info.m_name.substr(info.m_name.find_first_of('@')-1, 1)=="!");
813  size_t extp = info.m_name.rfind(kFullFrameWorkPBExtension);
814  bool FFOnly = (extp != std::string::npos);
815 
817  bool isSimple;
818  info.classType(name, isSimple);
819  if(isSimple)
820  {
821  returnValue.add(std::make_shared<FWSimpleRepresentationChecker>(name, it->first,bitPackedViews,representsSubPart, FFOnly) );
822  }
823  else
824  {
825  returnValue.add(std::make_shared<FWEDProductRepresentationChecker>(name, it->first,bitPackedViews,representsSubPart, FFOnly) );
826  }
827  }
828  }
829  return returnValue;
830 }
831 
832 
834 bool
836 {
837  for (int t = 0; t < FWViewType::kTypeSize; ++t)
838  {
839  if ((bit & (1 << t)) && !m_views[t].empty())
840  return true;
841  }
842  // printf("have %d view for bit %d \n", haveView, bit);
843  return false;
844 }
845 
846 
847 void
849 {
850  const std::string kSimple("simple#");
851  simple = (m_name.substr(0,kSimple.size()) == kSimple);
852  if (simple)
853  {
854  typeName = m_name.substr(kSimple.size(), m_name.find_first_of('@')-kSimple.size()-1);
855  }
856  else
857  {
858  typeName = m_name.substr(0, m_name.find_first_of('@')-1);
859  }
860 }
861 
862 /*
863 AMT: temporary workaround for using TEveCaloDataHist instead of
864 TEveCaloDataVec.
865 
866  */
867 
868 #include "TH2F.h"
869 #include "TAxis.h"
870 #include "TEveCaloData.h"
871 
872 void
873 FWEveViewManager::highlightAdded(TEveElement* iElement)
874 {
875 
876  bool blocked = gEve->GetHighlight()->BlockSignals(true);
877 
878 
879  if (iElement == context().getCaloData())
880  {
881  TEveCaloData::vCellId_t& hlist = context().getCaloData()->GetCellsHighlighted();
882  std::set<TEveCaloData::CellId_t> hset;
883 
884  int etaBin, phiBin, w, newPhiBin, tower;
885  TH2F* hist = context().getCaloData()->GetHist(0);
886  TAxis* etaAxis = hist->GetXaxis();
887  int nBinsX = etaAxis->GetNbins() + 2;
888 
889  for (TEveCaloData::vCellId_i i = hlist.begin(); i != hlist.end(); ++i)
890  {
891  hist->GetBinXYZ((*i).fTower, etaBin, phiBin, w);
892  if (TMath::Abs(etaAxis->GetBinCenter(etaBin)) > 4.71475)
893  {
894  newPhiBin = ((phiBin + 1) / 4) * 4 - 1;
895  if (newPhiBin <= 0) newPhiBin = 71;
896 
897  tower = etaBin + newPhiBin*nBinsX;
898  hset.insert(TEveCaloData::CellId_t( tower, (*i).fSlice, (*i).fFraction));
899  tower += nBinsX;
900  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
901  tower += nBinsX;
902 
903  if (newPhiBin == 71)
904  tower = etaBin + 1*nBinsX;
905 
906  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
907  tower += nBinsX;
908  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
909  }
910  else if (TMath::Abs(etaAxis->GetBinCenter(etaBin)) > 1.747650)
911  {
912  newPhiBin = ((phiBin + 1)/2)*2 - 1;
913  tower = etaBin + newPhiBin*nBinsX;
914  hset.insert(TEveCaloData::CellId_t( tower, (*i).fSlice, (*i).fFraction));
915  tower += nBinsX;
916  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
917  }
918  else
919  {
920  hset.insert(*i);
921  }
922  }
923 
924  // edit calo data list
925  hlist.clear();
926  for(std::set<TEveCaloData::CellId_t>::iterator it = hset.begin(); it != hset.end(); ++it)
927  {
928  hlist.push_back(*it);
929  }
930  context().getCaloData()->CellSelectionChanged();
931 
932  }
933 
934  gEve->GetHighlight()->BlockSignals(blocked);
935 }
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:82
size
Write out results.
type
Definition: HCALResponse.h:21
static const TGPicture * info(bool iBackgroundIsBlack)
Color_t background() const
const fireworks::Context & context() const
TEveScene * eventScene()
Definition: FWEveView.h:82
sigc::signal< void, const CmsShowCommon * > eventCenterChanged_
Definition: CmsShowCommon.h:88
virtual void doUnselect()=0
const double w
Definition: UKUtility.cc:23
virtual bool willHandleInteraction() const
void eventBegin() override
virtual bool havePerViewProduct(FWViewType::EType) const
FWColorManager * colorManager() const
Definition: Context.h:65
void selectionAdded(TEveElement *)
void itemChanged(const FWEventItem *)
FWItemChangeSignal goingToBeDestroyed_
Definition: FWEventItem.h:218
void newItem(const FWEventItem *) override
TypeToBuilder m_typeToBuilder
FWColorManager & colorManager() const
uint16_t size_type
boost::function2< FWViewBase *, TEveWindowSlot *, const std::string & > ViewBuildFunctor
Definition: FWGUIManager.h:98
static bool s_syncAllViews
void add(std::shared_ptr< FWRepresentationCheckerBase > iChecker)
const FWEventItem * item() const
std::list< Particle > List_t
Definition: Particle.h:141
int layer() const
Definition: FWEventItem.cc:459
FWEveViewManager(FWGUIManager *)
void registerViewBuilder(const std::string &iName, ViewBuildFunctor &iBuilder)
FWFromEveSelectorBase * getSelector(TEveElement *iElement)
static bool isProjected(int)
Definition: FWViewType.cc:128
static bool inheritsFrom(const edm::TypeWithDict &iChild, const std::string &iParentTypeName, unsigned int &distance)
FWEveView * finishViewCreate(std::shared_ptr< FWEveView >)
~FWEveViewManager() override
virtual void setContext(const fireworks::Context *x)
std::set< FWModelId > FWModelIds
virtual void setItem(const FWEventItem *iItem)
void resetMaxEtAndEnergy() const
Definition: Context.cc:190
const TClass * type() const
Definition: FWEventItem.cc:508
FWItemChangeSignal itemChanged_
Definition: FWEventItem.h:202
T Abs(T a)
Definition: MathUtil.h:49
bool haveViewForBit(int) const
void addElements(const FWEventItem *item, FWEveView *view, int viewType, TEveElementList *product)
bool getHidePFBuilders() const
Definition: Context.h:91
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
double f[11][100]
void selectionRemoved(TEveElement *)
void highlightAdded(TEveElement *)
TEveCaloDataHist * getCaloData() const
Definition: Context.h:80
void modelChanges(const FWModelIds &iIds)
void beingDestroyed(const FWViewBase *)
std::map< int, BuilderVec > m_builders
FWSelectionManager * selectionManager() const
Definition: Context.h:57
std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
FWTypeToRepresentations supportedTypesAndRepresentations() const override
FWViewBase * buildView(TEveWindowSlot *iParent, const std::string &type)
void setContext(const fireworks::Context *) override
virtual void doSelect()=0
void setHaveWindow(bool iFlag)
std::map< const FWEventItem *, FWInteractionList * > m_interactionLists
#define fwLog(_level_)
Definition: fwLog.h:50
FWViewContext * viewContext()
Definition: FWEveView.h:86
void colorsChanged() override
FWViewEnergyScale * getEnergyScale() const
Definition: CmsShowCommon.h:72
void importElements(TEveElement *iProjectableChild, float layer, TEveElement *iProjectedParent=nullptr)
Definition: FWRPZView.cc:316
CmsShowCommon * commonPrefs() const
Definition: Context.cc:177
BuilderVec::iterator BuilderVec_it
FWModelChangeSignal changed_
Definition: FWEventItem.h:199
sigc::signal< void > parameterChanged_
#define begin
Definition: vmac.h:32
std::vector< std::shared_ptr< FWProxyBuilderBase > > BuilderVec
static const std::string & idToName(int)
Definition: FWViewType.cc:89
const TClass * modelType() const
Definition: FWEventItem.cc:563
std::string name_
Definition: PluginInfo.h:29
TEveElement * ownedProducts()
Definition: FWEveView.h:85
static Bool_t setColorSetViewer(TGLViewer *, Color_t)
virtual void removeItem(const FWEventItem *)
bool getHaveWindow() const
void eventEnd() override
TEveElementList * createProduct(FWViewType::EType, const FWViewContext *)
const std::string & purpose() const
Definition: FWEventItem.cc:514
void modelChangesDone() override
static PluginManager * get()
void classType(std::string &, bool &) const
void modelChangesComing() override
virtual void setContext(const fireworks::Context &x)
Definition: FWEveView.cc:271
T get(const Candidate &c)
Definition: component.h:55
void itemChanged(const FWEventItem *)
void modelChanges(const FWModelIds &)
virtual void setInteractionList(FWInteractionList *, const std::string &)
FWViewType::EType typeId() const
Definition: FWViewBase.h:43