CMS 3D CMS Logo

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