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  std::shared_ptr<FWProxyBuilderBase> builder;
229  try
230  {
231  builder = std::shared_ptr<FWProxyBuilderBase>{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  builder->setItem(iItem);
246  iItem->changed_.connect(boost::bind(&FWEveViewManager::modelChanges,this,_1));
247  iItem->goingToBeDestroyed_.connect(boost::bind(&FWEveViewManager::removeItem,this,_1));
248  iItem->itemChanged_.connect(boost::bind(&FWEveViewManager::itemChanged,this,_1));
249 
250  // 3.
251  // This calud be opaque to the user. I would pass a reference to the m_interactionLists to
252  // FWProxyBuilderBase::setInteractionList and handle different case differently.
253  if (builder->willHandleInteraction() == false)
254  {
255  typedef std::map<const FWEventItem*, FWInteractionList*>::iterator Iterator;
256  std::pair<Iterator, bool> t = m_interactionLists.insert(std::make_pair(iItem,
257  (FWInteractionList*)nullptr));
258 
259  if (t.second == true)
260  t.first->second = new FWInteractionList(iItem);
261  // printf(">>> builder %s add list %p \n", iItem->name().c_str(), il); fflush(stdout);
262  builder->setInteractionList(t.first->second, iItem->purpose());
263  }
264 
265  builder->setHaveWindow(haveViewForBit(builderViewBit));
266 
267  // 4.
268  for (size_t viewType = 0; viewType < FWViewType::kTypeSize; ++viewType)
269  {
270  if (((1 << viewType) & builderViewBit) == 0)
271  continue;
272 
274 
275  // printf("%s builder %s supportsd view %s \n", iItem->name().c_str(), builderName.c_str(), FWViewType::idToName(viewType).c_str());
276  if (builder->havePerViewProduct((FWViewType::EType) viewType))
277  {
278  for (size_t i = 0, e = m_views[viewType].size(); i != e; ++i)
279  {
280  FWEveView *view = m_views[viewType][i].get();
281  TEveElementList* product = builder->createProduct(type,
282  view->viewContext());
283  addElements(iItem, view, viewType, product);
284  }
285  }
286  else
287  {
288  TEveElementList* product = builder->createProduct(type, nullptr);
289 
290  for (size_t i = 0, e = m_views[viewType].size(); i != e; ++i)
291  addElements(iItem, m_views[viewType][i].get(), viewType, product);
292  }
293  }
294 
295  m_builders[builderViewBit].emplace_back(std::move(builder));
296  } // loop views
297 }
298 
299 //______________________________________________________________________________
300 FWViewBase*
301 FWEveViewManager::buildView(TEveWindowSlot* iParent, const std::string& viewName)
302 {
304  for (int i = 0; i < FWViewType::kTypeSize; ++i)
305  {
306  if (viewName == FWViewType::idToName(i))
307  {
308  type = FWViewType::EType(i);
309  break;
310  }
311  }
312 
313  std::shared_ptr<FWEveView> view;
314  switch(type)
315  {
316  case FWViewType::k3D:
317  view.reset(new FW3DView(iParent, type));
318  break;
319  case FWViewType::kISpy:
320  view.reset(new FWISpyView(iParent, type));
321  break;
322  case FWViewType::kRhoPhi:
323  case FWViewType::kRhoZ:
325  view.reset(new FWRPZView(iParent, type));
326  break;
327  case FWViewType::kLego:
329  view.reset(new FWEveLegoView(iParent, type));
330  break;
331  case FWViewType::kLegoHF:
332  view.reset(new FWHFView(iParent, type));
333  break;
335  view.reset(new FWGlimpseView(iParent, type));
336  break;
337  default:
338  break;
339  }
340 
341  m_views[type].push_back(std::shared_ptr<FWEveView> (view));
342  return finishViewCreate(m_views[type].back());
343 }
344 
345 FWEveView*
346 FWEveViewManager::finishViewCreate(std::shared_ptr<FWEveView> view)
347 {
348  // printf("new view %s added \n", view->typeName().c_str());
349  gEve->DisableRedraw();
350 
351  // set geometry and calo data
352  view->setContext(context());
353 
355 
356  // set proxies have a window falg
357  int viewerBit = 1 << view->typeId();
358  if (m_views[view->typeId()].size() == 1)
359  {
360  for ( std::map<int, BuilderVec>::iterator i = m_builders.begin(); i!= m_builders.end(); ++i)
361  {
362  int builderViewBit = i->first;
363  BuilderVec& bv = i->second;
364  if (viewerBit == (builderViewBit & viewerBit))
365  {
366  for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
367  {
368  (*bIt)->setHaveWindow(true);
369  }
370  }
371  }
372  }
373 
374  FWRPZView* rpzView = dynamic_cast<FWRPZView*>(view.get());
375  for ( std::map<int, BuilderVec>::iterator i = m_builders.begin(); i!= m_builders.end(); ++i)
376  {
377  int builderViewBit = i->first;
378  BuilderVec& bv = i->second;
379  if (viewerBit == (builderViewBit & viewerBit))
380  {
381  for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
382  {
383  // it is ok to call create even for shared productsm since
384  // builder map key garanties that
385  TEveElementList* product = (*bIt)->createProduct(view->typeId(), view->viewContext());
386 
387  if ((*bIt)->havePerViewProduct((FWViewType::EType)view->typeId()))
388  {
389  // view owned
390  (*bIt)->build();
391  if (rpzView)
392  {
393  rpzView->importElements(product, (*bIt)->item()->layer(), rpzView->ownedProducts());
394  }
395  else
396  {
397  view->ownedProducts()->AddElement(product);
398  }
399  }
400  else
401  {
402  // shared
403  if (rpzView)
404  {
405  rpzView->importElements(product, (*bIt)->item()->layer(), rpzView->eventScene());
406  }
407  else
408  {
409  view->eventScene()->AddElement(product);
410  }
411 
412  }
413  }
414  }
415  }
416 
417  view->beingDestroyed_.connect(boost::bind(&FWEveViewManager::beingDestroyed,this,_1));
418 
419  view->setupEnergyScale(); // notify PB for energy scale
420 
421  gEve->EnableRedraw();
422  view->viewerGL()->UpdateScene();
423  gEve->Redraw3D();
424 
425  return view.get();
426 }
427 
428 void
430 {
431  FWEveView* view = (FWEveView*) vb;
432  int typeId = view->typeId();
433 
434  int viewerBit = 1 << typeId;
435  int nviews = m_views[typeId].size();
436  for ( std::map<int, BuilderVec>::iterator i = m_builders.begin(); i!= m_builders.end(); ++i)
437  {
438  int builderBit = i->first;
439  if (viewerBit == (builderBit & viewerBit)) // check only in case if connected
440  {
441  BuilderVec& bv = i->second;
442 
443  // remove view-owned product
444  if (viewerBit == (builderBit & viewerBit))
445  {
446  for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
447  (*bIt)->removePerViewProduct(view->typeId(), view->viewContext());
448  }
449 
450  // and setup proxy builders have-a-window flag
451  if (nviews == 1)
452  {
453  if (!haveViewForBit(builderBit))
454  {
455  if (viewerBit == (builderBit & viewerBit))
456  {
457  for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
458  (*bIt)->setHaveWindow(false);
459  }
460  }
461  }
462  }
463  }
464 
465 
466  for(EveViewVec_it i= m_views[typeId].begin(); i != m_views[typeId].end(); ++i) {
467  if(i->get() == vb) {
468  m_views[typeId].erase(i);
469  break;
470  }
471  }
472 }
473 
474 //______________________________________________________________________________
475 
476 void
478 {
479  gEve->DisableRedraw();
480 }
481 
482 void
484 {
485  gEve->EnableRedraw();
486 }
487 
489 void
491 {
492  FWModelId id = *(iIds.begin());
493  const FWEventItem* item = id.item();
494 
495  // in standard case new elements can be build in case of change of visibility
496  // and in non-standard case (e.g. calo towers) PB's modelChages handles all changes
497  bool itemHaveWindow = false;
498  for (std::map<int, BuilderVec>::iterator i = m_builders.begin();
499  i != m_builders.end(); ++i)
500  {
501  for (size_t bi = 0, be = i->second.size(); bi != be; ++bi)
502  {
503  FWProxyBuilderBase *builder = i->second[bi].get();
504  if (builder->getHaveWindow() && builder->item() == item)
505  {
506  builder->modelChanges(iIds);
507  itemHaveWindow = true;
508  }
509  }
510  }
511 
512  if (!itemHaveWindow)
513  return;
514 
516 
517  std::map<const FWEventItem*, FWInteractionList*>::iterator it = m_interactionLists.find(item);
518  if (it != m_interactionLists.end())
519  {
520  if (!it->second->empty())
521  it->second->modelChanges(iIds);
522  }
523 }
524 
530 void
532 {
533  if (!item)
534  return;
535 
536  bool itemHaveWindow = false;
537 
538  for (std::map<int, BuilderVec>::iterator i = m_builders.begin();
539  i != m_builders.end(); ++i)
540  {
541  for(size_t bi = 0, be = i->second.size(); bi != be; ++bi)
542  {
543  FWProxyBuilderBase *builder = i->second[bi].get();
544 
545  if (builder->item() != item)
546  continue;
547 
548  builder->itemChanged(item);
549  itemHaveWindow |= builder->getHaveWindow();
550  }
551  }
552 
553  if (!itemHaveWindow)
554  return;
555 
556  std::map<const FWEventItem*, FWInteractionList*>::iterator it = m_interactionLists.find(item);
557  if (it != m_interactionLists.end())
558  {
559  if (!it->second->empty())
560  it->second->itemChanged();
561  }
562 }
563 
566 void
568 {
570 
571  std::map<const FWEventItem*, FWInteractionList*>::iterator it = m_interactionLists.find(item);
572  if (it != m_interactionLists.end())
573  {
574  delete it->second;
575  m_interactionLists.erase(it);
576  }
577 
578  for (std::map<int, BuilderVec>::iterator i = m_builders.begin();
579  i != m_builders.end(); ++i)
580  {
581  BuilderVec_it bIt = i->second.begin();
582  while( bIt != i->second.end() )
583  {
584  if ((*bIt)->item() == item)
585  {
586  // TODO caching of proxy builders
587  (*bIt)->itemBeingDestroyed(item);
588  bIt = i->second.erase(bIt);
589  }
590  else
591  {
592  ++bIt;
593  }
594  }
595  }
596 }
597 
598 void
600 {
603  x->commonPrefs()->eventCenterChanged_.connect(boost::bind(&FWEveViewManager::eventCenterChanged,this));
604 }
605 
606 void
608 {
609  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
610  {
611  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
612  {
613  if ((*i)->isEnergyScaleGlobal())
614  {
615  (*i)->setupEnergyScale();
616  }
617  }
618 
619  }
620 }
621 
622 void
624 {
625  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
626  {
627  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
628  {
629  (*i)->setupEventCenter();
630  }
631  }
632 
633 }
634 
635 void
637 {
638  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
639  {
640  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
641  (*i)->setBackgroundColor(colorManager().background());
642  }
643 }
644 
645 //______________________________________________________________________________
646 void
648 {
649  // Prevent registration of redraw timer, full redraw is done in
650  // FWEveViewManager::eventEnd().
651  gEve->EnforceTimerActive(kTRUE);
652  gEve->DisableRedraw();
653 
655 
656  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
657  {
658  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
659  (*i)->eventBegin();
660  }
661 }
662 
663 void
665 {
666  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
667  {
668  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
669  (*i)->eventEnd();
670  }
671 
672  // What follows is a copy of TEveManager::DoRedraw3D() with the difference that
673  // we have full control over execution of GL view rendering. In particular:
674  // - optionally delay buffer swapping so they can all be swapped together;
675  // - we could render into FBO once and then use this to be put on screen
676  // and saved into an image file.
677 
678  {
679  TEveElement::List_t scenes;
680  Long64_t key, value;
681  TExMapIter stamped_elements(gEve->PtrToStampedElements());
682  while (stamped_elements.Next(key, value))
683  {
684  TEveElement *el = reinterpret_cast<TEveElement*>(key);
685  if (el->GetChangeBits() & TEveElement::kCBVisibility)
686  {
687  el->CollectSceneParents(scenes);
688  }
689  }
690  gEve->ScenesChanged(scenes);
691  }
692 
693  // Process changes in scenes.
694  gEve->GetScenes()->ProcessSceneChanges(kFALSE, gEve->PtrToStampedElements());
695 
696  // To synchronize buffer swapping set swap_on_render to false.
697  // Note that this costs 25-40% extra time with 4 views, depending on V-sync settings.
698  // Tested with NVIDIA 343.22.
699  const bool swap_on_render = !s_syncAllViews;
700 
701  // Loop over viewers, swap buffers if swap_on_render is true.
702  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
703  {
704  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
705  (*i)->fwViewerGL()->DrawHiLod(swap_on_render);
706  }
707 
708  // Swap buffers if they were not swapped before.
709  if ( ! swap_on_render)
710  {
711  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
712  {
713  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
714  (*i)->fwViewerGL()->JustSwap();
715  }
716  }
717 
718  gEve->GetViewers()->RepaintChangedViewers(kFALSE, kFALSE);
719 
720  {
721  Long64_t key, value;
722  TExMapIter stamped_elements(gEve->PtrToStampedElements());
723  while (stamped_elements.Next(key, value))
724  {
725  TEveElement *el = reinterpret_cast<TEveElement*>(key);
726  if (gEve->GetEditor()->GetModel() == el->GetEditorObject("FWEveViewManager::eventEnd"))
727  gEve->EditElement(el);
728  TEveGedEditor::ElementChanged(el);
729 
730  el->ClearStamps();
731  }
732  }
733  gEve->PtrToStampedElements()->Delete();
734 
735  gEve->GetListTree()->ClearViewPort(); // Fix this when several list-trees can be added.
736 
737  gEve->EnableRedraw();
738  gEve->EnforceTimerActive(kFALSE);
739 }
740 
741 //______________________________________________________________________________
742 
745 FWFromEveSelectorBase *getSelector(TEveElement *iElement)
746 {
747  if (!iElement)
748  return nullptr;
749 
750  //std::cout <<" non null"<<std::endl;
751  void* userData = iElement->GetUserData();
752  //std::cout <<" user data "<<userData<<std::endl;
753  if (!userData)
754  return nullptr;
755 
756  //std::cout <<" have userData"<<std::endl;
757  //std::cout <<" calo"<<std::endl;
759  return reinterpret_cast<FWFromEveSelectorBase*> (userData);
760 }
761 
762 void
763 FWEveViewManager::selectionAdded(TEveElement* iElement)
764 {
765  FWFromEveSelectorBase* selector = getSelector(iElement);
766  if (selector)
767  selector->doSelect();
768 }
769 
770 void
772 {
773  FWFromEveSelectorBase* selector = getSelector(iElement);
774  if (selector)
775  selector->doUnselect();
776 }
777 
778 void
780 {
782 }
783 
784 
785 //
786 // const member functions
787 //
788 
791 {
792  // needed for add collection GUI
793  FWTypeToRepresentations returnValue;
794  const static std::string kFullFrameWorkPBExtension = "FullFramework";
795  for(TypeToBuilder::const_iterator it = m_typeToBuilder.begin(), itEnd = m_typeToBuilder.end();
796  it != itEnd;
797  ++it)
798  {
799  std::vector<BuilderInfo> blist = it->second;
800  for (size_t bii = 0, bie = blist.size(); bii != bie; ++bii)
801  {
802  BuilderInfo &info = blist[bii];
803 
804  if (context().getHidePFBuilders()) {
805  const static std::string pfExt = "PF ";
806  if (std::string::npos != info.m_name.find(pfExt))
807  continue;
808  }
809 
810  unsigned int bitPackedViews = info.m_viewBit;
811  bool representsSubPart = (info.m_name.substr(info.m_name.find_first_of('@')-1, 1)=="!");
812  size_t extp = info.m_name.rfind(kFullFrameWorkPBExtension);
813  bool FFOnly = (extp != std::string::npos);
814 
816  bool isSimple;
817  info.classType(name, isSimple);
818  if(isSimple)
819  {
820  returnValue.add(std::make_shared<FWSimpleRepresentationChecker>(name, it->first,bitPackedViews,representsSubPart, FFOnly) );
821  }
822  else
823  {
824  returnValue.add(std::make_shared<FWEDProductRepresentationChecker>(name, it->first,bitPackedViews,representsSubPart, FFOnly) );
825  }
826  }
827  }
828  return returnValue;
829 }
830 
831 
833 bool
835 {
836  for (int t = 0; t < FWViewType::kTypeSize; ++t)
837  {
838  if ((bit & (1 << t)) && !m_views[t].empty())
839  return true;
840  }
841  // printf("have %d view for bit %d \n", haveView, bit);
842  return false;
843 }
844 
845 
846 void
848 {
849  const std::string kSimple("simple#");
850  simple = (m_name.substr(0,kSimple.size()) == kSimple);
851  if (simple)
852  {
853  typeName = m_name.substr(kSimple.size(), m_name.find_first_of('@')-kSimple.size()-1);
854  }
855  else
856  {
857  typeName = m_name.substr(0, m_name.find_first_of('@')-1);
858  }
859 }
860 
861 /*
862 AMT: temporary workaround for using TEveCaloDataHist instead of
863 TEveCaloDataVec.
864 
865  */
866 
867 #include "TH2F.h"
868 #include "TAxis.h"
869 #include "TEveCaloData.h"
870 
871 void
872 FWEveViewManager::highlightAdded(TEveElement* iElement)
873 {
874 
875  bool blocked = gEve->GetHighlight()->BlockSignals(true);
876 
877 
878  if (iElement == context().getCaloData())
879  {
880  TEveCaloData::vCellId_t& hlist = context().getCaloData()->GetCellsHighlighted();
881  std::set<TEveCaloData::CellId_t> hset;
882 
883  int etaBin, phiBin, w, newPhiBin, tower;
884  TH2F* hist = context().getCaloData()->GetHist(0);
885  TAxis* etaAxis = hist->GetXaxis();
886  int nBinsX = etaAxis->GetNbins() + 2;
887 
888  for (TEveCaloData::vCellId_i i = hlist.begin(); i != hlist.end(); ++i)
889  {
890  hist->GetBinXYZ((*i).fTower, etaBin, phiBin, w);
891  if (TMath::Abs(etaAxis->GetBinCenter(etaBin)) > 4.71475)
892  {
893  newPhiBin = ((phiBin + 1) / 4) * 4 - 1;
894  if (newPhiBin <= 0) newPhiBin = 71;
895 
896  tower = etaBin + newPhiBin*nBinsX;
897  hset.insert(TEveCaloData::CellId_t( tower, (*i).fSlice, (*i).fFraction));
898  tower += nBinsX;
899  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
900  tower += nBinsX;
901 
902  if (newPhiBin == 71)
903  tower = etaBin + 1*nBinsX;
904 
905  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
906  tower += nBinsX;
907  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
908  }
909  else if (TMath::Abs(etaAxis->GetBinCenter(etaBin)) > 1.747650)
910  {
911  newPhiBin = ((phiBin + 1)/2)*2 - 1;
912  tower = etaBin + newPhiBin*nBinsX;
913  hset.insert(TEveCaloData::CellId_t( tower, (*i).fSlice, (*i).fFraction));
914  tower += nBinsX;
915  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
916  }
917  else
918  {
919  hset.insert(*i);
920  }
921  }
922 
923  // edit calo data list
924  hlist.clear();
925  for(std::set<TEveCaloData::CellId_t>::iterator it = hset.begin(); it != hset.end(); ++it)
926  {
927  hlist.push_back(*it);
928  }
929  context().getCaloData()->CellSelectionChanged();
930 
931  }
932 
933  gEve->GetHighlight()->BlockSignals(blocked);
934 }
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:83
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
void eventBegin() override
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
TGeoIterator Iterator
std::list< Particle > List_t
Definition: Particle.h:141
int layer() const
Definition: FWEventItem.cc:462
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
void resetMaxEtAndEnergy() const
Definition: Context.cc:190
const TClass * type() const
Definition: FWEventItem.cc:511
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
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:566
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
const std::string & purpose() const
Definition: FWEventItem.cc:517
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
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55
void itemChanged(const FWEventItem *)
void modelChanges(const FWModelIds &)
FWViewType::EType typeId() const
Definition: FWViewBase.h:43