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 (fireworks::Context *)
 
void newEventCallback ()
 
void openDetailViewFor (const FWModelId &, const std::string &)
 
virtual ~FWDetailViewManager ()
 

Protected Attributes

fireworks::Contextm_context
 

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 34 of file FWDetailViewManager.h.

Member Typedef Documentation

typedef vViews_t::iterator FWDetailViewManager::vViews_i
private

Definition at line 68 of file FWDetailViewManager.h.

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

Definition at line 67 of file FWDetailViewManager.h.

Constructor & Destructor Documentation

FWDetailViewManager::FWDetailViewManager ( fireworks::Context iCtx)

Definition at line 52 of file FWDetailViewManager.cc.

References fireworks::Context::colorManager(), colorsChanged(), FWColorManager::colorsHaveChanged_, and m_context.

52  :
53  m_context(iCtx)
54 {
55  // force white background for all embedded canvases
56  gROOT->SetStyle("Plain");
57 
59  gEve->GetWindowManager()->Connect( "WindowDeleted(TEveWindow*)", "FWDetailViewManager", this, "eveWindowDestroyed(TEveWindow*)");
60 }
FWColorManager * colorManager() const
Definition: Context.h:65
fireworks::Context * m_context
sigc::signal< void > colorsHaveChanged_
FWDetailViewManager::~FWDetailViewManager ( )
virtual

Definition at line 62 of file FWDetailViewManager.cc.

References newEventCallback().

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

Member Function Documentation

void FWDetailViewManager::colorsChanged ( )

Definition at line 189 of file FWDetailViewManager.cc.

References FWColorManager::background(), fireworks::Context::colorManager(), i, m_context, and m_views.

Referenced by FWDetailViewManager().

190 {
191  for (vViews_i i = m_views.begin(); i != m_views.end(); ++i)
192  (*i).m_detailView->setBackgroundColor(m_context->colorManager()->background());
193 }
int i
Definition: DBlmapReader.cc:9
Color_t background() const
FWColorManager * colorManager() const
Definition: Context.h:65
vViews_t::iterator vViews_i
fireworks::Context * m_context
std::vector< std::string > FWDetailViewManager::detailViewsFor ( const FWModelId iId) const

Definition at line 112 of file FWDetailViewManager.cc.

References findViewersFor(), FWModelId::item(), FWEventItem::modelType(), edm::TypeWithDict::name(), AlCaHLTBitMon_QueryRunRegistry::string, create_public_lumi_plots::transform, and viewNameFrom().

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

113 {
114  std::string typeName = edm::TypeWithDict(*(iId.item()->modelType()->GetTypeInfo())).name();
115  std::vector<std::string> fullNames = findViewersFor(typeName);
116  std::vector<std::string> justViewNames;
117  justViewNames.reserve(fullNames.size());
118  std::transform(fullNames.begin(),fullNames.end(),std::back_inserter(justViewNames),&viewNameFrom);
119  return justViewNames;
120 }
static std::string viewNameFrom(const std::string &iFull)
std::vector< std::string > findViewersFor(const std::string &) const
std::string name() const
const TClass * modelType() const
Definition: FWEventItem.cc:561
const FWEventItem * item() const
Definition: FWModelId.h:44
void FWDetailViewManager::eveWindowDestroyed ( TEveWindow *  ew)

Definition at line 206 of file FWDetailViewManager.cc.

References i, and m_views.

207 {
208  for (vViews_i i = m_views.begin(); i != m_views.end(); ++i)
209  {
210  if (ew == i->m_eveWindow)
211  {
212  // printf("========================== delete %s \n", ew->GetElementName());
213  delete i->m_detailView;
214  m_views.erase(i);
215  break;
216  }
217  }
218 }
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 123 of file FWDetailViewManager.cc.

References plotBeamSpotDB::first, newFWLiteAna::found, fwLog, reco::get(), fireworks::Context::getHidePFBuilders(), FWJobMetadataManager::hasModuleLabel(), info(), FWSimpleRepresentationChecker::infoFor(), fwlog::kDebug, m_context, m_typeToViewers, fireworks::Context::metadataManager(), edmplugin::PluginInfo::name_, FWRepresentationInfo::proximity(), contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, and create_public_lumi_plots::transform.

Referenced by detailViewsFor(), and openDetailViewFor().

124 {
125 
126  std::vector<std::string> returnValue;
127 
128  std::map<std::string,std::vector<std::string> >::const_iterator itFind = m_typeToViewers.find(iType);
129  if(itFind != m_typeToViewers.end()) {
130  return itFind->second;
131  }
132  //create a list of the available ViewManager's
133  std::set<std::string> detailViews;
134 
135  std::vector<edmplugin::PluginInfo> available = FWDetailViewFactory::get()->available();
136  std::transform(available.begin(),
137  available.end(),
138  std::inserter(detailViews,detailViews.begin()),
139  boost::bind(&edmplugin::PluginInfo::name_,_1));
140  unsigned int closestMatch= 0xFFFFFFFF;
141 
142 
143  for(std::set<std::string>::iterator it = detailViews.begin(), itEnd=detailViews.end();
144  it!=itEnd;
145  ++it) {
146 
147  if (m_context->getHidePFBuilders()) {
148  std::size_t found = it->find("PF ");
149  if (found != std::string::npos)
150  break;
151  }
152  std::string::size_type first = it->find_first_of('@');
153  std::string type = it->substr(0,first);
154 
155  //see if we match via inheritance
156  FWSimpleRepresentationChecker checker(type,"",0,false);
157  FWRepresentationInfo info = checker.infoFor(iType);
158  bool pass = false;
159  if(closestMatch > info.proximity()) {
160  pass = true;
161  std::string::size_type firstD = it->find_first_of('&')+1;
162  if(firstD != std::string::npos) {
163  std::stringstream ss(it->substr(firstD));
164  std::string ml;
165  while(std::getline(ss, ml, '&')) {
167  fwLog(fwlog::kDebug) << "DetailView "<< *it << " requires module label " << ml << std::endl;
168  pass = false;
169  break;
170  }
171  }
172  }
173  if (pass) {
174  returnValue.push_back(*it);
175  }
176  else {
177  std::string::size_type first = (*it).find_first_of('@');
178  std::string vn = *it;
179  vn.insert(++first, "!");
180  returnValue.push_back(vn);
181  }
182  }
183  }
184  m_typeToViewers[iType]=returnValue;
185  return returnValue;
186 }
type
Definition: HCALResponse.h:21
static const TGPicture * info(bool iBackgroundIsBlack)
virtual bool hasModuleLabel(std::string &moduleLabel)=0
uint16_t size_type
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 getHidePFBuilders() const
Definition: Context.h:91
fireworks::Context * m_context
#define fwLog(_level_)
Definition: fwLog.h:50
FWJobMetadataManager * metadataManager() const
Definition: Context.h:69
std::string name_
Definition: PluginInfo.h:29
T get(const Candidate &c)
Definition: component.h:55
void FWDetailViewManager::newEventCallback ( )

Definition at line 197 of file FWDetailViewManager.cc.

References m_views.

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

198 {
199  while (!m_views.empty())
200  {
201  m_views.front().m_eveWindow->DestroyWindowAndSlot();
202  }
203 }
void FWDetailViewManager::openDetailViewFor ( const FWModelId id,
const std::string &  iViewName 
)

Definition at line 69 of file FWDetailViewManager.cc.

References assert(), FWColorManager::background(), fireworks::Context::colorManager(), findViewersFor(), fwLog, reco::get(), cmsHarvester::index, fwlog::kError, m_context, m_views, match(), mergeVDriftHistosByStation::name, edm::TypeWithDict::name(), AlCaHLTBitMon_QueryRunRegistry::string, edmStreamStallGrapher::t, and viewNameFrom().

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

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

Member Data Documentation

fireworks::Context* FWDetailViewManager::m_context
protected
std::map<std::string, std::vector<std::string> > FWDetailViewManager::m_typeToViewers
mutableprivate

Definition at line 71 of file FWDetailViewManager.h.

Referenced by findViewersFor().

vViews_t FWDetailViewManager::m_views
private