CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
FWEveViewManager Class Reference

#include <Fireworks/Core/interface/FWEveViewManager.h>

Inheritance diagram for FWEveViewManager:
FWViewManagerBase

Classes

struct  BuilderInfo
 

Public Member Functions

void eventBegin () override
 
void eventEnd () override
 
 FWEveViewManager (FWGUIManager *)
 
void highlightAdded (TEveElement *)
 
void newItem (const FWEventItem *) override
 
virtual void removeItem (const FWEventItem *)
 
void selectionAdded (TEveElement *)
 
void selectionCleared ()
 
void selectionRemoved (TEveElement *)
 
void setContext (const fireworks::Context *) override
 
FWTypeToRepresentations supportedTypesAndRepresentations () const override
 
 ~FWEveViewManager () override
 
- Public Member Functions inherited from FWViewManagerBase
void colorsChangedSlot ()
 
const fireworks::Contextcontext () const
 
void modelChangesComingSlot ()
 
void modelChangesDoneSlot ()
 
void setChangeManager (FWModelChangeManager *iCM)
 
void setColorManager (FWColorManager *iCM)
 
virtual ~FWViewManagerBase ()
 

Static Public Member Functions

static void syncAllViews ()
 

Protected Member Functions

void colorsChanged () override
 
void modelChangesComing () override
 
void modelChangesDone () override
 
- Protected Member Functions inherited from FWViewManagerBase
FWModelChangeManagerchangeManager () const
 
FWColorManagercolorManager () const
 
void * createInstanceOf (const TClass *iBaseClass, const char *iNameOfClass)
 
 FWViewManagerBase ()
 

Private Types

typedef std::vector< std::shared_ptr< FWProxyBuilderBase > > BuilderVec
 
typedef BuilderVec::iterator BuilderVec_it
 
typedef std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
 
typedef std::map< std::string, std::vector< BuilderInfo > > TypeToBuilder
 

Private Member Functions

void beingDestroyed (const FWViewBase *)
 
FWViewBasebuildView (TEveWindowSlot *iParent, const std::string &type)
 
void eventCenterChanged ()
 
FWEveViewfinishViewCreate (std::shared_ptr< FWEveView >)
 
 FWEveViewManager (const FWEveViewManager &)=delete
 
void globalEnergyScaleChanged ()
 
bool haveViewForBit (int) const
 
void itemChanged (const FWEventItem *)
 
void modelChanges (const FWModelIds &iIds)
 
const FWEveViewManageroperator= (const FWEveViewManager &)=delete
 

Private Attributes

std::map< int, BuilderVecm_builders
 
std::map< const FWEventItem *, FWInteractionList * > m_interactionLists
 
TypeToBuilder m_typeToBuilder
 
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
 

Static Private Attributes

static bool s_syncAllViews = false
 

Detailed Description

Description: [one line class summary]

Usage: <usage>

Definition at line 44 of file FWEveViewManager.h.

Member Typedef Documentation

typedef std::vector<std::shared_ptr<FWProxyBuilderBase> > FWEveViewManager::BuilderVec
private

Definition at line 104 of file FWEveViewManager.h.

typedef BuilderVec::iterator FWEveViewManager::BuilderVec_it
private

Definition at line 105 of file FWEveViewManager.h.

typedef std::vector<std::shared_ptr<FWEveView > >::iterator FWEveViewManager::EveViewVec_it
private

Definition at line 106 of file FWEveViewManager.h.

typedef std::map<std::string, std::vector<BuilderInfo> > FWEveViewManager::TypeToBuilder
private

Definition at line 103 of file FWEveViewManager.h.

Constructor & Destructor Documentation

FWEveViewManager::FWEveViewManager ( FWGUIManager iGUIMgr)

Definition at line 85 of file FWEveViewManager.cc.

References PFRecoTauChargedHadronProducer_cfi::builders, buildView(), python.rootplot.argparse::category, edmplugin::PluginManager::categoryToInfos(), f, plotBeamSpotDB::first, reco::get(), edmplugin::PluginManager::get(), mps_fire::i, FWViewType::idToName(), FWViewType::kTable, FWViewType::kTableHLT, FWViewType::kTableL1, FWViewType::kTypeSize, m_typeToBuilder, m_views, edmplugin::PluginInfo::name_, trackingPlots::purpose, FWGUIManager::registerViewBuilder(), AlCaHLTBitMon_QueryRunRegistry::string, and create_public_lumi_plots::transform.

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo(), and syncAllViews().

85  :
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 }
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:82
TypeToBuilder m_typeToBuilder
uint16_t size_type
boost::function2< FWViewBase *, TEveWindowSlot *, const std::string & > ViewBuildFunctor
Definition: FWGUIManager.h:98
void registerViewBuilder(const std::string &iName, ViewBuildFunctor &iBuilder)
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
double f[11][100]
FWViewBase * buildView(TEveWindowSlot *iParent, const std::string &type)
static const std::string & idToName(int)
Definition: FWViewType.cc:89
std::string name_
Definition: PluginInfo.h:29
static PluginManager * get()
T get(const Candidate &c)
Definition: component.h:55
FWEveViewManager::~FWEveViewManager ( )
override

Definition at line 146 of file FWEveViewManager.cc.

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

147 {
148 }
FWEveViewManager::FWEveViewManager ( const FWEveViewManager )
privatedelete

Member Function Documentation

void FWEveViewManager::beingDestroyed ( const FWViewBase vb)
private

Definition at line 430 of file FWEveViewManager.cc.

References begin, haveViewForBit(), mps_fire::i, m_builders, m_views, FWViewBase::typeId(), and FWEveView::viewContext().

Referenced by finishViewCreate(), and syncAllViews().

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 }
bool haveViewForBit(int) const
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
std::map< int, BuilderVec > m_builders
std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
FWViewContext * viewContext()
Definition: FWEveView.h:86
BuilderVec::iterator BuilderVec_it
#define begin
Definition: vmac.h:32
std::vector< std::shared_ptr< FWProxyBuilderBase > > BuilderVec
FWViewType::EType typeId() const
Definition: FWViewBase.h:43
FWViewBase * FWEveViewManager::buildView ( TEveWindowSlot *  iParent,
const std::string &  type 
)
private

Definition at line 302 of file FWEveViewManager.cc.

References finishViewCreate(), mps_fire::i, FWViewType::idToName(), FWViewType::k3D, FWViewType::kGlimpse, FWViewType::kISpy, FWViewType::kLego, FWViewType::kLegoHF, FWViewType::kLegoPFECAL, FWViewType::kRhoPhi, FWViewType::kRhoPhiPF, FWViewType::kRhoZ, FWViewType::kTypeSize, and m_views.

Referenced by FWEveViewManager(), and syncAllViews().

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 }
type
Definition: HCALResponse.h:21
FWEveView * finishViewCreate(std::shared_ptr< FWEveView >)
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
static const std::string & idToName(int)
Definition: FWViewType.cc:89
void FWEveViewManager::colorsChanged ( )
overrideprotectedvirtual

Implements FWViewManagerBase.

Definition at line 637 of file FWEveViewManager.cc.

References begin, FWViewManagerBase::colorManager(), mps_fire::i, FWViewType::kTypeSize, m_views, and lumiQTWidget::t.

Referenced by syncAllViews().

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 }
FWColorManager & colorManager() const
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
#define begin
Definition: vmac.h:32
void FWEveViewManager::eventBegin ( )
overridevirtual

Reimplemented from FWViewManagerBase.

Definition at line 648 of file FWEveViewManager.cc.

References begin, FWViewManagerBase::context(), mps_fire::i, FWViewType::kTypeSize, m_views, fireworks::Context::resetMaxEtAndEnergy(), and lumiQTWidget::t.

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

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 }
const fireworks::Context & context() const
void resetMaxEtAndEnergy() const
Definition: Context.cc:190
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
#define begin
Definition: vmac.h:32
void FWEveViewManager::eventCenterChanged ( )
private

Definition at line 624 of file FWEveViewManager.cc.

References begin, mps_fire::i, FWViewType::kTypeSize, m_views, and lumiQTWidget::t.

Referenced by setContext(), and syncAllViews().

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 }
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
#define begin
Definition: vmac.h:32
void FWEveViewManager::eventEnd ( )
overridevirtual

Reimplemented from FWViewManagerBase.

Definition at line 665 of file FWEveViewManager.cc.

References begin, mps_fire::i, crabWrapper::key, FWViewType::kTypeSize, m_views, s_syncAllViews, lumiQTWidget::t, and relativeConstraints::value.

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

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 }
static bool s_syncAllViews
std::list< Particle > List_t
Definition: Particle.h:141
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
#define begin
Definition: vmac.h:32
FWEveView * FWEveViewManager::finishViewCreate ( std::shared_ptr< FWEveView view)
private

Definition at line 347 of file FWEveViewManager.cc.

References FWColorManager::background(), beingDestroyed(), fireworks::Context::colorManager(), FWViewManagerBase::context(), FWEveView::eventScene(), mps_fire::i, FWRPZView::importElements(), m_builders, m_views, FWEveView::ownedProducts(), FWColorManager::setColorSetViewer(), and FWEveView::setContext().

Referenced by buildView(), and syncAllViews().

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 }
Color_t background() const
const fireworks::Context & context() const
TEveScene * eventScene()
Definition: FWEveView.h:82
FWColorManager * colorManager() const
Definition: Context.h:65
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
void beingDestroyed(const FWViewBase *)
std::map< int, BuilderVec > m_builders
void importElements(TEveElement *iProjectableChild, float layer, TEveElement *iProjectedParent=nullptr)
Definition: FWRPZView.cc:316
BuilderVec::iterator BuilderVec_it
std::vector< std::shared_ptr< FWProxyBuilderBase > > BuilderVec
TEveElement * ownedProducts()
Definition: FWEveView.h:85
static Bool_t setColorSetViewer(TGLViewer *, Color_t)
void FWEveViewManager::globalEnergyScaleChanged ( )
private

Definition at line 608 of file FWEveViewManager.cc.

References begin, mps_fire::i, FWViewType::kTypeSize, m_views, and lumiQTWidget::t.

Referenced by setContext(), and syncAllViews().

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 }
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
#define begin
Definition: vmac.h:32
bool FWEveViewManager::haveViewForBit ( int  bit) const
private

Checks whether any of the views

Definition at line 835 of file FWEveViewManager.cc.

References relativeConstraints::empty, FWViewType::kTypeSize, m_views, and lumiQTWidget::t.

Referenced by beingDestroyed(), newItem(), and syncAllViews().

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 }
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
void FWEveViewManager::highlightAdded ( TEveElement *  iElement)

Definition at line 873 of file FWEveViewManager.cc.

References Abs(), FWViewManagerBase::context(), conversionPostprocessing_cfi::etaBin, fireworks::Context::getCaloData(), create_public_lumi_plots::hist, mps_fire::i, conversionPostprocessing_cfi::phiBin, and w.

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

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 fireworks::Context & context() const
const double w
Definition: UKUtility.cc:23
T Abs(T a)
Definition: MathUtil.h:49
TEveCaloDataHist * getCaloData() const
Definition: Context.h:80
void FWEveViewManager::itemChanged ( const FWEventItem item)
private

Callback of itemChanged_ signal. Iterate over all the builders for all the views and call itemChanged for any of the builders. If any of the builder also has at least one view, also update the interaction list.

Definition at line 532 of file FWEveViewManager.cc.

References FWProxyBuilderBase::getHaveWindow(), mps_fire::i, FWProxyBuilderBase::item(), FWProxyBuilderBase::itemChanged(), m_builders, and m_interactionLists.

Referenced by newItem(), and syncAllViews().

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 }
const FWEventItem * item() const
std::map< int, BuilderVec > m_builders
std::map< const FWEventItem *, FWInteractionList * > m_interactionLists
bool getHaveWindow() const
void itemChanged(const FWEventItem *)
void FWEveViewManager::modelChanges ( const FWModelIds iIds)
private

Callback of event item changed_ signal.

Definition at line 491 of file FWEveViewManager.cc.

References FWProxyBuilderBase::getHaveWindow(), mps_fire::i, FWProxyBuilderBase::item(), m_builders, m_interactionLists, and FWProxyBuilderBase::modelChanges().

Referenced by newItem(), and syncAllViews().

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 }
const FWEventItem * item() const
std::map< int, BuilderVec > m_builders
std::map< const FWEventItem *, FWInteractionList * > m_interactionLists
bool getHaveWindow() const
void modelChanges(const FWModelIds &)
void FWEveViewManager::modelChangesComing ( )
overrideprotectedvirtual

called when models have changed and so the display must be updated

Implements FWViewManagerBase.

Definition at line 478 of file FWEveViewManager.cc.

Referenced by syncAllViews().

479 {
480  gEve->DisableRedraw();
481 }
void FWEveViewManager::modelChangesDone ( )
overrideprotectedvirtual

Implements FWViewManagerBase.

Definition at line 484 of file FWEveViewManager.cc.

Referenced by syncAllViews().

485 {
486  gEve->EnableRedraw();
487 }
void FWEveViewManager::newItem ( const FWEventItem iItem)
overridevirtual

This is invoked when a new item is created by the FWEventItemsManager. The workflow is the following

  1. First we check if we have a builder info for the given purpose of the item. We return simply if we don't.
  2. We iterate over all the proxy builder registered for the given purpose and create a new one for this given item.
  3. Interaction lists are set up in case the proxy builder does not handle interaction by itself.
  4. We then iterate on the various supported views and add elements to them, making sure that we handle the case in which those elements are not unique among all the views.

Implements FWViewManagerBase.

Definition at line 192 of file FWEveViewManager.cc.

References addElements(), FWEventItem::changed_, FWEveViewManager::BuilderInfo::classType(), FWProxyBuilderBase::createProduct(), SoftLeptonByDistance_cfi::distance, MillePedeFileConverter_cfg::e, cppFunctionSkipper::exception, fwLog, reco::get(), FWEventItem::goingToBeDestroyed_, FWProxyBuilderBase::havePerViewProduct(), haveViewForBit(), mps_fire::i, info(), FWSimpleRepresentationChecker::inheritsFrom(), itemChanged(), FWEventItem::itemChanged_, FWViewType::kTypeSize, fwlog::kWarning, m_builders, m_interactionLists, FWEveViewManager::BuilderInfo::m_name, m_typeToBuilder, FWEveViewManager::BuilderInfo::m_viewBit, m_views, modelChanges(), FWEventItem::modelType(), FWEventItem::purpose(), removeItem(), FWProxyBuilderBase::setHaveWindow(), FWProxyBuilderBase::setInteractionList(), FWProxyBuilderBase::setItem(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, lumiQTWidget::t, FWEventItem::type(), FWEveView::viewContext(), and FWProxyBuilderBase::willHandleInteraction().

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

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 }
size
Write out results.
type
Definition: HCALResponse.h:21
static const TGPicture * info(bool iBackgroundIsBlack)
virtual bool willHandleInteraction() const
virtual bool havePerViewProduct(FWViewType::EType) const
void itemChanged(const FWEventItem *)
FWItemChangeSignal goingToBeDestroyed_
Definition: FWEventItem.h:218
TypeToBuilder m_typeToBuilder
static bool inheritsFrom(const edm::TypeWithDict &iChild, const std::string &iParentTypeName, unsigned int &distance)
virtual void setItem(const FWEventItem *iItem)
const TClass * type() const
Definition: FWEventItem.cc:508
FWItemChangeSignal itemChanged_
Definition: FWEventItem.h:202
bool haveViewForBit(int) const
void addElements(const FWEventItem *item, FWEveView *view, int viewType, TEveElementList *product)
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
void modelChanges(const FWModelIds &iIds)
std::map< int, BuilderVec > m_builders
void setHaveWindow(bool iFlag)
std::map< const FWEventItem *, FWInteractionList * > m_interactionLists
#define fwLog(_level_)
Definition: fwLog.h:50
FWViewContext * viewContext()
Definition: FWEveView.h:86
FWModelChangeSignal changed_
Definition: FWEventItem.h:199
const TClass * modelType() const
Definition: FWEventItem.cc:563
virtual void removeItem(const FWEventItem *)
TEveElementList * createProduct(FWViewType::EType, const FWViewContext *)
const std::string & purpose() const
Definition: FWEventItem.cc:514
T get(const Candidate &c)
Definition: component.h:55
virtual void setInteractionList(FWInteractionList *, const std::string &)
const FWEveViewManager& FWEveViewManager::operator= ( const FWEveViewManager )
privatedelete

Referenced by syncAllViews().

void FWEveViewManager::removeItem ( const FWEventItem item)
virtual

Remove an item from the given view.

Definition at line 568 of file FWEveViewManager.cc.

References mps_fire::i, m_builders, and m_interactionLists.

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo(), and newItem().

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 }
std::map< int, BuilderVec > m_builders
std::map< const FWEventItem *, FWInteractionList * > m_interactionLists
BuilderVec::iterator BuilderVec_it
void FWEveViewManager::selectionAdded ( TEveElement *  iElement)

Definition at line 764 of file FWEveViewManager.cc.

References FWFromEveSelectorBase::doSelect(), and getSelector().

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

765 {
766  FWFromEveSelectorBase* selector = getSelector(iElement);
767  if (selector)
768  selector->doSelect();
769 }
FWFromEveSelectorBase * getSelector(TEveElement *iElement)
virtual void doSelect()=0
void FWEveViewManager::selectionCleared ( )

Definition at line 780 of file FWEveViewManager.cc.

References FWSelectionManager::clearSelection(), FWViewManagerBase::context(), and fireworks::Context::selectionManager().

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

781 {
783 }
const fireworks::Context & context() const
FWSelectionManager * selectionManager() const
Definition: Context.h:57
void FWEveViewManager::selectionRemoved ( TEveElement *  iElement)

Definition at line 772 of file FWEveViewManager.cc.

References FWFromEveSelectorBase::doUnselect(), and getSelector().

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

773 {
774  FWFromEveSelectorBase* selector = getSelector(iElement);
775  if (selector)
776  selector->doUnselect();
777 }
virtual void doUnselect()=0
FWFromEveSelectorBase * getSelector(TEveElement *iElement)
void FWEveViewManager::setContext ( const fireworks::Context x)
overridevirtual

Reimplemented from FWViewManagerBase.

Definition at line 600 of file FWEveViewManager.cc.

References fireworks::Context::commonPrefs(), eventCenterChanged(), CmsShowCommon::eventCenterChanged_, CmsShowCommon::getEnergyScale(), globalEnergyScaleChanged(), FWViewEnergyScale::parameterChanged_, and FWViewManagerBase::setContext().

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

601 {
604  x->commonPrefs()->eventCenterChanged_.connect(boost::bind(&FWEveViewManager::eventCenterChanged,this));
605 }
sigc::signal< void, const CmsShowCommon * > eventCenterChanged_
Definition: CmsShowCommon.h:88
virtual void setContext(const fireworks::Context *x)
FWViewEnergyScale * getEnergyScale() const
Definition: CmsShowCommon.h:72
CmsShowCommon * commonPrefs() const
Definition: Context.cc:177
sigc::signal< void > parameterChanged_
FWTypeToRepresentations FWEveViewManager::supportedTypesAndRepresentations ( ) const
overridevirtual

Implements FWViewManagerBase.

Definition at line 791 of file FWEveViewManager.cc.

References FWTypeToRepresentations::add(), FWEveViewManager::BuilderInfo::classType(), FWViewManagerBase::context(), fireworks::Context::getHidePFBuilders(), info(), FWEveViewManager::BuilderInfo::m_name, m_typeToBuilder, FWEveViewManager::BuilderInfo::m_viewBit, dataset::name, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

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 }
static const TGPicture * info(bool iBackgroundIsBlack)
const fireworks::Context & context() const
TypeToBuilder m_typeToBuilder
void add(std::shared_ptr< FWRepresentationCheckerBase > iChecker)
bool getHidePFBuilders() const
Definition: Context.h:91
static void FWEveViewManager::syncAllViews ( )
inlinestatic

Member Data Documentation

std::map<int, BuilderVec> FWEveViewManager::m_builders
private
std::map<const FWEventItem*,FWInteractionList*> FWEveViewManager::m_interactionLists
private

Definition at line 116 of file FWEveViewManager.h.

Referenced by itemChanged(), modelChanges(), newItem(), and removeItem().

TypeToBuilder FWEveViewManager::m_typeToBuilder
private

Definition at line 108 of file FWEveViewManager.h.

Referenced by FWEveViewManager(), newItem(), and supportedTypesAndRepresentations().

std::vector< std::vector<std::shared_ptr<FWEveView> > > FWEveViewManager::m_views
private
bool FWEveViewManager::s_syncAllViews = false
staticprivate

Definition at line 110 of file FWEveViewManager.h.

Referenced by eventEnd(), and syncAllViews().