CMS 3D CMS Logo

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 *)
 
 FWDetailViewManager (const FWDetailViewManager &)=delete
 
void newEventCallback ()
 
void openDetailViewFor (const FWModelId &, const std::string &)
 
const FWDetailViewManageroperator= (const FWDetailViewManager &)=delete
 
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
 

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

Member Typedef Documentation

◆ vViews_i

typedef vViews_t::iterator FWDetailViewManager::vViews_i
private

Definition at line 70 of file FWDetailViewManager.h.

◆ vViews_t

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

Definition at line 69 of file FWDetailViewManager.h.

Constructor & Destructor Documentation

◆ FWDetailViewManager() [1/2]

FWDetailViewManager::FWDetailViewManager ( fireworks::Context iCtx)

Definition at line 51 of file FWDetailViewManager.cc.

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

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

◆ ~FWDetailViewManager()

FWDetailViewManager::~FWDetailViewManager ( )
virtual

Definition at line 60 of file FWDetailViewManager.cc.

References newEventCallback().

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

◆ FWDetailViewManager() [2/2]

FWDetailViewManager::FWDetailViewManager ( const FWDetailViewManager )
delete

Member Function Documentation

◆ colorsChanged()

void FWDetailViewManager::colorsChanged ( )

Definition at line 194 of file FWDetailViewManager.cc.

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

Referenced by FWDetailViewManager().

194  {
195  for (vViews_i i = m_views.begin(); i != m_views.end(); ++i)
196  (*i).m_detailView->setBackgroundColor(m_context->colorManager()->background());
197 }
vViews_t::iterator vViews_i
Color_t background() const
fireworks::Context * m_context
FWColorManager * colorManager() const
Definition: Context.h:58

◆ detailViewsFor()

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, HcalDetIdTransform::transform(), dqmiodumpindices::typeName, and viewNameFrom().

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

112  {
113  std::string typeName = edm::TypeWithDict(*(iId.item()->modelType()->GetTypeInfo())).name();
114  std::vector<std::string> fullNames = findViewersFor(typeName);
115  std::vector<std::string> justViewNames;
116  justViewNames.reserve(fullNames.size());
117  std::transform(fullNames.begin(), fullNames.end(), std::back_inserter(justViewNames), &viewNameFrom);
118  return justViewNames;
119 }
static std::string viewNameFrom(const std::string &iFull)
std::vector< std::string > findViewersFor(const std::string &) const
const TClass * modelType() const
Definition: FWEventItem.cc:464
const FWEventItem * item() const
Definition: FWModelId.h:39
std::string name() const
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ eveWindowDestroyed()

void FWDetailViewManager::eveWindowDestroyed ( TEveWindow *  ew)

Definition at line 205 of file FWDetailViewManager.cc.

References mps_fire::i, and m_views.

205  {
206  for (vViews_i i = m_views.begin(); i != m_views.end(); ++i) {
207  if (ew == i->m_eveWindow) {
208  // printf("========================== delete %s \n", ew->GetElementName());
209  m_views.erase(i);
210  break;
211  }
212  }
213 }
vViews_t::iterator vViews_i

◆ findViewersFor()

std::vector< std::string > FWDetailViewManager::findViewersFor ( const std::string &  iType) const
private

Definition at line 130 of file FWDetailViewManager.cc.

References python.cmstools::all(), validateAlignments::category, edmplugin::PluginManager::categoryToInfos(), HLT_2024v11_cff::distance, dqmdumpme::first, newFWLiteAna::found, fwLog, edmplugin::PluginManager::get(), get, fireworks::Context::getHidePFBuilders(), FWJobMetadataManager::hasModuleLabel(), info(), FWSimpleRepresentationChecker::infoFor(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, fwlog::kDebug, m_context, m_typeToViewers, fireworks::Context::metadataManager(), edm_modernize_messagelogger::ml, edmplugin::PluginInfo::name_, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, HcalDetIdTransform::transform(), and tier0::unique().

Referenced by detailViewsFor(), and openDetailViewFor().

130  {
131  std::vector<std::string> returnValue;
132 
133  std::map<std::string, std::vector<std::string> >::const_iterator itFind = m_typeToViewers.find(iType);
134  if (itFind != m_typeToViewers.end()) {
135  return itFind->second;
136  }
137 
138  std::set<std::string> detailViews;
139 
140  std::vector<edmplugin::PluginInfo> all =
142  std::transform(all.begin(),
143  all.end(),
144  std::inserter(detailViews, detailViews.begin()),
145  std::bind(&edmplugin::PluginInfo::name_, std::placeholders::_1));
146  unsigned int closestMatch = 0xFFFFFFFF;
147 
148  for (std::set<std::string>::iterator it = detailViews.begin(), itEnd = detailViews.end(); it != itEnd; ++it) {
149  if (m_context->getHidePFBuilders()) {
150  std::size_t found = it->find("PF ");
151  if (found != std::string::npos)
152  continue;
153  }
154  std::string::size_type first = it->find_first_of('@');
155  std::string type = it->substr(0, first);
156 
157  //see if we match via inheritance
158  FWSimpleRepresentationChecker checker(type, "", 0, false);
159  FWRepresentationInfo info = checker.infoFor(iType);
160  bool pass = false;
161  if (closestMatch > info.proximity()) {
162  pass = true;
163  std::string::size_type firstD = it->find_first_of('&') + 1;
164  if (firstD != std::string::npos) {
165  std::stringstream ss(it->substr(firstD));
166  std::string ml;
167  while (std::getline(ss, ml, '&')) {
169  fwLog(fwlog::kDebug) << "DetailView " << *it << " requires module label " << ml << std::endl;
170  pass = false;
171  break;
172  }
173  }
174  }
175  if (pass) {
176  returnValue.push_back(*it);
177  } else {
178  std::string::size_type first = (*it).find_first_of('@');
179  std::string vn = *it;
180  vn.insert(++first, "!");
181  returnValue.push_back(vn);
182  }
183  }
184  }
185 
186  std::vector<std::string>::iterator it;
187  it = std::unique(returnValue.begin(), returnValue.end(), pluginComapreFunc);
188  returnValue.resize(std::distance(returnValue.begin(), it));
189 
190  m_typeToViewers[iType] = returnValue;
191  return returnValue;
192 }
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:82
static const TGPicture * info(bool iBackgroundIsBlack)
virtual bool hasModuleLabel(std::string &moduleLabel)=0
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
FWJobMetadataManager * metadataManager() const
Definition: Context.h:60
uint16_t size_type
bool getHidePFBuilders() const
Definition: Context.h:80
std::map< std::string, std::vector< std::string > > m_typeToViewers
def unique(seq, keepstr=True)
Definition: tier0.py:24
fireworks::Context * m_context
#define fwLog(_level_)
Definition: fwLog.h:45
std::string name_
Definition: PluginInfo.h:29
#define get
static PluginManager * get()
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ newEventCallback()

void FWDetailViewManager::newEventCallback ( )

Definition at line 199 of file FWDetailViewManager.cc.

References m_views.

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

199  {
200  while (!m_views.empty()) {
201  m_views.front().m_eveWindow->DestroyWindowAndSlot();
202  }
203 }

◆ openDetailViewFor()

void FWDetailViewManager::openDetailViewFor ( const FWModelId id,
const std::string &  iViewName 
)

Definition at line 71 of file FWDetailViewManager.cc.

References cms::cuda::assert(), FWColorManager::background(), fireworks::Context::colorManager(), findViewersFor(), fwLog, get, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, B2GTnPMonitor_cfi::item, fwlog::kError, m_context, m_views, match(), eostools::move(), Skims_PA_cff::name, edm::TypeWithDict::name(), FCDTask_cfi::slot, AlCaHLTBitMon_QueryRunRegistry::string, submitPVValidationJobs::t, dqmiodumpindices::typeName, viewNameFrom(), and ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::ws.

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

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 (viewerNames.empty()) {
79  fwLog(fwlog::kError) << "FWDetailViewManager: don't know what detailed view to "
80  "use for object "
81  << id.item()->name() << std::endl;
82  assert(!viewerNames.empty());
83  }
84 
85  //see if one of the names matches iViewName
87  for (std::vector<std::string>::iterator it = viewerNames.begin(), itEnd = viewerNames.end(); it != itEnd; ++it) {
89  //std::cout <<"'"<<iViewName<< "' '"<<t<<"'"<<std::endl;
90  if (t == iViewName) {
91  match = *it;
92  break;
93  }
94  }
95  assert(!match.empty());
96  std::unique_ptr<FWDetailViewBase> detailView{FWDetailViewFactory::get()->create(match)};
97  assert(nullptr != detailView);
98 
99  TEveWindowSlot* ws = (TEveWindowSlot*)(eveFrame->GetEveWindow());
100  detailView->init(ws);
101  detailView->build(id);
102  detailView->setBackgroundColor(m_context->colorManager()->background());
103 
104  TGMainFrame* mf = (TGMainFrame*)(eveFrame->GetParent());
105  mf->SetWindowName(Form("%s Detail View [%d]", id.item()->name().c_str(), id.index()));
106 
107  m_views.emplace_back(eveFrame, std::move(detailView), eveFrame->GetEveWindow());
108 
109  mf->MapRaised();
110 }
Color_t background() const
assert(be >=bs)
static std::string viewNameFrom(const std::string &iFull)
std::vector< std::string > findViewersFor(const std::string &) const
fireworks::Context * m_context
#define fwLog(_level_)
Definition: fwLog.h:45
std::string name() const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
#define get
def move(src, dest)
Definition: eostools.py:511
FWColorManager * colorManager() const
Definition: Context.h:58

◆ operator=()

const FWDetailViewManager& FWDetailViewManager::operator= ( const FWDetailViewManager )
delete

Member Data Documentation

◆ m_context

fireworks::Context* FWDetailViewManager::m_context
protected

◆ m_typeToViewers

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

Definition at line 73 of file FWDetailViewManager.h.

Referenced by findViewersFor().

◆ m_views

vViews_t FWDetailViewManager::m_views
private