CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes
FWDetailViewManager Class Reference

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

Classes

struct  ViewFrame
 

Public Member Functions

void colorsChanged ()
 
std::vector< std::string > detailViewsFor (const FWModelId &) const
 
void eveWindowDestroyed (TEveWindow *)
 
 FWDetailViewManager (FWColorManager *)
 
void newEventCallback ()
 
void openDetailViewFor (const FWModelId &, const std::string &)
 
virtual ~FWDetailViewManager ()
 

Protected Attributes

FWColorManagerm_colorManager
 

Private Types

typedef vViews_t::iterator vViews_i
 
typedef std::vector< ViewFramevViews_t
 

Private Member Functions

std::vector< std::string > findViewersFor (const std::string &) const
 
 FWDetailViewManager (const FWDetailViewManager &)
 
const FWDetailViewManageroperator= (const FWDetailViewManager &)
 

Private Attributes

std::map< std::string,
std::vector< std::string > > 
m_typeToViewers
 
vViews_t m_views
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 30 of file FWDetailViewManager.h.

Member Typedef Documentation

typedef vViews_t::iterator FWDetailViewManager::vViews_i
private

Definition at line 64 of file FWDetailViewManager.h.

typedef std::vector<ViewFrame> FWDetailViewManager::vViews_t
private

Definition at line 63 of file FWDetailViewManager.h.

Constructor & Destructor Documentation

FWDetailViewManager::FWDetailViewManager ( FWColorManager colMng)

Definition at line 49 of file FWDetailViewManager.cc.

References colorsChanged(), FWColorManager::colorsHaveChanged_, and m_colorManager.

49  :
50  m_colorManager(colMng)
51 {
52  // force white background for all embedded canvases
53  gROOT->SetStyle("Plain");
54 
56  gEve->GetWindowManager()->Connect( "WindowDeleted(TEveWindow*)", "FWDetailViewManager", this, "eveWindowDestroyed(TEveWindow*)");
57 }
FWColorManager * m_colorManager
sigc::signal< void > colorsHaveChanged_
FWDetailViewManager::~FWDetailViewManager ( )
virtual

Definition at line 59 of file FWDetailViewManager.cc.

References newEventCallback().

60 {
62  gEve->GetWindowManager()->Disconnect("WindowDeleted(TEveWindow*)", this, "eveWindowDestroyed(TEveWindow*)" );
63 }
FWDetailViewManager::FWDetailViewManager ( const FWDetailViewManager )
private

Member Function Documentation

void FWDetailViewManager::colorsChanged ( )

Definition at line 158 of file FWDetailViewManager.cc.

References FWColorManager::background(), i, m_colorManager, and m_views.

Referenced by FWDetailViewManager().

159 {
160  for (vViews_i i = m_views.begin(); i != m_views.end(); ++i)
161  (*i).m_detailView->setBackgroundColor(m_colorManager->background());
162 }
int i
Definition: DBlmapReader.cc:9
Color_t background() const
vViews_t::iterator vViews_i
FWColorManager * m_colorManager
std::vector< std::string > FWDetailViewManager::detailViewsFor ( const FWModelId iId) const

Definition at line 108 of file FWDetailViewManager.cc.

References findViewersFor(), FWModelId::item(), FWEventItem::modelType(), create_public_pileup_plots::transform, and viewNameFrom().

Referenced by FWModelContextMenuHandler::chosenItem(), CmsShowModelPopup::clicked(), CmsShowModelPopup::fillModelPopup(), CmsShowModelPopup::openDetailedView(), and FWModelContextMenuHandler::showSelectedModelContext().

109 {
110  std::string typeName = Reflex::Type::ByTypeInfo(*(iId.item()->modelType()->GetTypeInfo())).Name(Reflex::SCOPED);
111  std::vector<std::string> fullNames = findViewersFor(typeName);
112  std::vector<std::string> justViewNames;
113  justViewNames.reserve(fullNames.size());
114  std::transform(fullNames.begin(),fullNames.end(),std::back_inserter(justViewNames),&viewNameFrom);
115  return justViewNames;
116 }
static std::string viewNameFrom(const std::string &iFull)
std::vector< std::string > findViewersFor(const std::string &) const
const TClass * modelType() const
Definition: FWEventItem.cc:561
const FWEventItem * item() const
Definition: FWModelId.h:45
void FWDetailViewManager::eveWindowDestroyed ( TEveWindow *  ew)

Definition at line 175 of file FWDetailViewManager.cc.

References i, and m_views.

176 {
177  for (vViews_i i = m_views.begin(); i != m_views.end(); ++i)
178  {
179  if (ew == i->m_eveWindow)
180  {
181  // printf("========================== delete %s \n", ew->GetElementName());
182  delete i->m_detailView;
183  m_views.erase(i);
184  break;
185  }
186  }
187 }
int i
Definition: DBlmapReader.cc:9
vViews_t::iterator vViews_i
std::vector< std::string > FWDetailViewManager::findViewersFor ( const std::string &  iType) const
private

Definition at line 119 of file FWDetailViewManager.cc.

References first, reco::get(), info, FWSimpleRepresentationChecker::infoFor(), m_typeToViewers, edmplugin::PluginInfo::name_, FWRepresentationInfo::proximity(), create_public_pileup_plots::transform, and viewNameFrom().

Referenced by detailViewsFor(), and openDetailViewFor().

120 {
121  std::vector<std::string> returnValue;
122 
123  std::map<std::string,std::vector<std::string> >::const_iterator itFind = m_typeToViewers.find(iType);
124  if(itFind != m_typeToViewers.end()) {
125  return itFind->second;
126  }
127  //create a list of the available ViewManager's
128  std::set<std::string> detailViews;
129 
130  std::vector<edmplugin::PluginInfo> available = FWDetailViewFactory::get()->available();
131  std::transform(available.begin(),
132  available.end(),
133  std::inserter(detailViews,detailViews.begin()),
134  boost::bind(&edmplugin::PluginInfo::name_,_1));
135  unsigned int closestMatch= 0xFFFFFFFF;
136  for(std::set<std::string>::iterator it = detailViews.begin(), itEnd=detailViews.end();
137  it!=itEnd;
138  ++it) {
139  std::string::size_type first = it->find_first_of('@');
140  std::string type = it->substr(0,first);
141 
142  if(type == iType) {
143  returnValue.push_back(viewNameFrom(*it));
144  }
145  //see if we match via inheritance
146  FWSimpleRepresentationChecker checker(type,"",0,false);
147  FWRepresentationInfo info = checker.infoFor(iType);
148  if(closestMatch > info.proximity()) {
149  //closestMatch = info.proximity();
150  returnValue.push_back(*it);
151  }
152  }
153  m_typeToViewers[iType]=returnValue;
154  return returnValue;
155 }
type
Definition: HCALResponse.h:22
uint16_t size_type
static std::string viewNameFrom(const std::string &iFull)
unsigned int proximity() const
measures how &#39;close&#39; this representation is to the type in question, the large the number the farther...
std::map< std::string, std::vector< std::string > > m_typeToViewers
bool first
Definition: L1TdeRCT.cc:94
std::string name_
Definition: PluginInfo.h:30
T get(const Candidate &c)
Definition: component.h:56
void FWDetailViewManager::newEventCallback ( )

Definition at line 166 of file FWDetailViewManager.cc.

References m_views.

Referenced by FWGUIManager::eventChangedCallback(), and ~FWDetailViewManager().

167 {
168  while (!m_views.empty())
169  {
170  m_views.front().m_eveWindow->DestroyWindowAndSlot();
171  }
172 }
void FWDetailViewManager::openDetailViewFor ( const FWModelId id,
const std::string &  iViewName 
)

Definition at line 66 of file FWDetailViewManager.cc.

References FWColorManager::background(), findViewersFor(), fwLog, reco::get(), getHLTprescales::index, fwlog::kError, m_colorManager, m_views, match(), mergeVDriftHistosByStation::name, lumiQTWidget::t, and viewNameFrom().

Referenced by FWModelContextMenuHandler::chosenItem(), CmsShowModelPopup::clicked(), and CmsShowModelPopup::openDetailedView().

67 {
68  TEveWindowSlot* slot = TEveWindow::CreateWindowMainFrame();
69  TEveCompositeFrameInMainFrame* eveFrame = (TEveCompositeFrameInMainFrame*)slot->GetEveFrame();
70 
71  // find the right viewer for this item
72  std::string typeName = Reflex::Type::ByTypeInfo(*(id.item()->modelType()->GetTypeInfo())).Name(Reflex::SCOPED);
73  std::vector<std::string> viewerNames = findViewersFor(typeName);
74  if(0==viewerNames.size()) {
75  fwLog(fwlog::kError) << "FWDetailViewManager: don't know what detailed view to "
76  "use for object " << id.item()->name() << std::endl;
77  assert(0!=viewerNames.size());
78  }
79 
80  //see if one of the names matches iViewName
81  std::string match;
82  for(std::vector<std::string>::iterator it = viewerNames.begin(), itEnd = viewerNames.end(); it != itEnd; ++it) {
83  std::string t = viewNameFrom(*it);
84  //std::cout <<"'"<<iViewName<< "' '"<<t<<"'"<<std::endl;
85  if(t == iViewName) {
86  match = *it;
87  break;
88  }
89  }
90  assert(match.size() != 0);
91  FWDetailViewBase* detailView = FWDetailViewFactory::get()->create(match);
92  assert(0!=detailView);
93 
94  TEveWindowSlot* ws = (TEveWindowSlot*)(eveFrame->GetEveWindow());
95  detailView->init(ws);
96  detailView->build(id);
97  detailView->setBackgroundColor(m_colorManager->background());
98 
99  TGMainFrame* mf = (TGMainFrame*)(eveFrame->GetParent());
100  mf->SetWindowName(Form("%s Detail View [%d]", id.item()->name().c_str(), id.index()));
101 
102  m_views.push_back(ViewFrame(eveFrame, detailView, eveFrame->GetEveWindow()));
103 
104  mf->MapRaised();
105 }
Color_t background() const
static std::string viewNameFrom(const std::string &iFull)
std::vector< std::string > findViewersFor(const std::string &) const
FWColorManager * m_colorManager
#define fwLog(_level_)
Definition: fwLog.h:51
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
T get(const Candidate &c)
Definition: component.h:56
const FWDetailViewManager& FWDetailViewManager::operator= ( const FWDetailViewManager )
private

Member Data Documentation

FWColorManager* FWDetailViewManager::m_colorManager
protected

Definition at line 44 of file FWDetailViewManager.h.

Referenced by colorsChanged(), FWDetailViewManager(), and openDetailViewFor().

std::map<std::string, std::vector<std::string> > FWDetailViewManager::m_typeToViewers
mutableprivate

Definition at line 67 of file FWDetailViewManager.h.

Referenced by findViewersFor().

vViews_t FWDetailViewManager::m_views
private