CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
FWEventItemsManager Class Reference

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

Inheritance diagram for FWEventItemsManager:
FWConfigurable

Public Types

typedef std::vector< FWEventItem * >::const_iterator const_iterator
 

Public Member Functions

FWEventItemadd (const FWPhysicsObjectDesc &iItem, const FWConfiguration *pbConf=nullptr, bool doSetEvent=true)
 
void addTo (FWConfiguration &) const override
 
const_iterator begin () const
 NOTE: iterator is allowed to return a null object for items that have been removed. More...
 
void clearItems ()
 
const_iterator end () const
 
const FWEventItemfind (const std::string &iName) const
 
 FWEventItemsManager (FWModelChangeManager *)
 
void newEvent (const edm::EventBase *iEvent)
 
void setContext (fireworks::Context *)
 
void setFrom (const FWConfiguration &) override
 
 ~FWEventItemsManager () override
 
- Public Member Functions inherited from FWConfigurable
 FWConfigurable ()
 
virtual ~FWConfigurable ()
 

Public Attributes

sigc::signal< void > goingToClearItems_
 
sigc::signal< void, FWEventItem * > newItem_
 
sigc::signal< void, const FWEventItem * > removingItem_
 

Private Member Functions

 FWEventItemsManager (const FWEventItemsManager &)=delete
 
const FWEventItemsManageroperator= (const FWEventItemsManager &)=delete
 
void removeItem (const FWEventItem *)
 

Private Attributes

std::shared_ptr< FWItemAccessorFactorym_accessorFactory
 
FWModelChangeManagerm_changeManager
 
fireworks::Contextm_context
 
const edm::EventBasem_event
 
std::vector< FWEventItem * > m_items
 

Detailed Description

Description: Manages multiple FWEventItems

Usage: <usage>

Definition at line 44 of file FWEventItemsManager.h.

Member Typedef Documentation

Definition at line 51 of file FWEventItemsManager.h.

Constructor & Destructor Documentation

FWEventItemsManager::FWEventItemsManager ( FWModelChangeManager iManager)

Definition at line 41 of file FWEventItemsManager.cc.

41  :
42  m_changeManager(iManager),
43  m_context(nullptr),
44  m_event(nullptr),
46 {
47 }
FWModelChangeManager * m_changeManager
const edm::EventBase * m_event
std::shared_ptr< FWItemAccessorFactory > m_accessorFactory
fireworks::Context * m_context
FWEventItemsManager::~FWEventItemsManager ( )
override

FWEventItemsManager has ownership of the items it contains.

Note that because of the way we keep track of removed items, m_items[i] could actually be 0 for indices corresponding to removed items.

Definition at line 60 of file FWEventItemsManager.cc.

References MillePedeFileConverter_cfg::e, mps_fire::i, and m_items.

61 {
62  for (size_t i = 0, e = m_items.size(); i != e; ++i)
63  delete m_items[i];
64 
65  m_items.clear();
66 }
std::vector< FWEventItem * > m_items
FWEventItemsManager::FWEventItemsManager ( const FWEventItemsManager )
privatedelete

Member Function Documentation

FWEventItem * FWEventItemsManager::add ( const FWPhysicsObjectDesc iItem,
const FWConfiguration pbConf = nullptr,
bool  doSetEvent = true 
)

Definition at line 84 of file FWEventItemsManager.cc.

References FWDisplayProperties::color(), FWColorManager::colorHasIndex(), fireworks::Context::colorManager(), FWPhysicsObjectDesc::displayProperties(), fwLog, FWColorManager::getDefaultStartColorIndex(), fwlog::kWarning, m_accessorFactory, m_changeManager, m_context, m_event, m_items, newItem_, removeItem(), FWPhysicsObjectDesc::setDisplayProperties(), groupFilesInBlocks::temp, and FWPhysicsObjectDesc::type().

Referenced by FWGUIEventDataAdder::addNewItem(), counter.Counter::register(), SequenceTypes.Task::remove(), SequenceTypes.Task::replace(), and setFrom().

87 {
89 
90  if(! m_context->colorManager()->colorHasIndex(temp.displayProperties().color())) {
91  FWDisplayProperties prop(temp.displayProperties());
92  fwLog(fwlog::kWarning) << Form("FWEventItemsManager::add(const FWPhysicsObjectDesc& iItem), color index not valid. Set Color idex to %d\n", FWColorManager::getDefaultStartColorIndex());
94  temp.setDisplayProperties(prop);
95  }
96 
97  m_items.push_back(new FWEventItem(m_context,m_items.size(),m_accessorFactory->accessorFor(temp.type()),
98  temp, pbc));
99  newItem_(m_items.back());
100  m_items.back()->goingToBeDestroyed_.connect(boost::bind(&FWEventItemsManager::removeItem,this,_1));
101  if (doSetEvent && m_event)
102  {
104  m_items.back()->setEvent(m_event);
105  }
106  return m_items.back();
107 }
FWModelChangeManager * m_changeManager
void removeItem(const FWEventItem *)
FWColorManager * colorManager() const
Definition: Context.h:65
static Color_t getDefaultStartColorIndex()
bool colorHasIndex(Color_t) const
sigc::signal< void, FWEventItem * > newItem_
const edm::EventBase * m_event
std::shared_ptr< FWItemAccessorFactory > m_accessorFactory
#define fwLog(_level_)
Definition: fwLog.h:50
fireworks::Context * m_context
std::vector< FWEventItem * > m_items
void FWEventItemsManager::addTo ( FWConfiguration iTo) const
overridevirtual

Implements FWConfigurable.

Definition at line 160 of file FWEventItemsManager.cc.

References FWConfiguration::addKeyValue(), fireworks::Context::colorManager(), MergeFilesAndCalculateEfficiencies_cfg::dataType, kColor(), kFalse(), kFilterExpression(), kIsVisible(), kLayer(), kModuleLabel(), kProcessName(), kProductInstanceLabel(), kPurpose(), kTransparency(), kTrue(), kType(), m_context, and m_items.

161 {
163  assert(nullptr!=cm);
164  for(std::vector<FWEventItem*>::const_iterator it = m_items.begin();
165  it != m_items.end();
166  ++it)
167  {
168  if(!*it) continue;
169  FWConfiguration conf(6);
170  edm::TypeWithDict dataType((*((*it)->type()->GetTypeInfo())));
171  assert(dataType != edm::TypeWithDict() );
172 
173  conf.addKeyValue(kType,FWConfiguration(dataType.name()));
174  conf.addKeyValue(kModuleLabel,FWConfiguration((*it)->moduleLabel()));
175  conf.addKeyValue(kProductInstanceLabel, FWConfiguration((*it)->productInstanceLabel()));
176  conf.addKeyValue(kProcessName, FWConfiguration((*it)->processName()));
177  conf.addKeyValue(kFilterExpression, FWConfiguration((*it)->filterExpression()));
178  {
179  std::ostringstream os;
180  os << (*it)->defaultDisplayProperties().color();
181  conf.addKeyValue(kColor, FWConfiguration(os.str()));
182  }
183  conf.addKeyValue(kIsVisible, FWConfiguration((*it)->defaultDisplayProperties().isVisible() ? kTrue : kFalse));
184  {
185  std::ostringstream os;
186  os << (*it)->layer();
187  conf.addKeyValue(kLayer,FWConfiguration(os.str()));
188  }
189  conf.addKeyValue(kPurpose,(*it)->purpose());
190  {
191  std::ostringstream os;
192  os << static_cast<int>((*it)->defaultDisplayProperties().transparency());
193  conf.addKeyValue(kTransparency, FWConfiguration(os.str()));
194  }
195 
196  FWConfiguration pbTmp;
197  (*it)->getConfig()->addTo(pbTmp);
198  conf.addKeyValue("PBConfig",pbTmp, true);
199 
200  iTo.addKeyValue((*it)->name(), conf, true);
201  }
202 }
static const std::string kModuleLabel("moduleLabel")
FWColorManager * colorManager() const
Definition: Context.h:65
static const std::string kTrue("t")
static const std::string kType("type")
static const std::string kColor("color")
static const std::string kProductInstanceLabel("productInstanceLabel")
static const std::string kFilterExpression("filterExpression")
static const std::string kProcessName("processName")
static const std::string kFalse("f")
static const std::string kLayer("layer")
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
static const std::string kTransparency("transparency")
static const std::string kIsVisible("isVisible")
static const std::string kPurpose("purpose")
fireworks::Context * m_context
std::vector< FWEventItem * > m_items
FWEventItemsManager::const_iterator FWEventItemsManager::begin ( void  ) const

NOTE: iterator is allowed to return a null object for items that have been removed.

Definition at line 334 of file FWEventItemsManager.cc.

References m_items.

Referenced by FWGUIEventDataAdder::addNewItem(), FWEventItem::isInBack(), FWEventItem::isInFront(), FWEventItem::moveToBack(), FWEventItem::moveToFront(), CmsShowCommon::permuteColors(), CmsShowCommon::randomizeColors(), FWFileEntry::runFilter(), CmsShowCommon::setPalette(), and CmsShowMain::setupDataHandling().

335 {
336  return m_items.begin();
337 }
std::vector< FWEventItem * > m_items
void FWEventItemsManager::clearItems ( void  )

Clear all the items in the model.

Notice that a previous implementation was setting all the items to 0, I guess to track accessing delete items.

Definition at line 131 of file FWEventItemsManager.cc.

References FWEventItem::destroy(), MillePedeFileConverter_cfg::e, goingToClearItems_, mps_fire::i, kColor(), kFalse(), kFilterExpression(), kIsVisible(), kLayer(), kModuleLabel(), kProcessName(), kProductInstanceLabel(), kPurpose(), kTransparency(), kTrue(), kType(), m_items, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FWPartialConfigLoadGUI::Load(), and setFrom().

132 {
133  for (size_t i = 0, e = m_items.size(); i != e; ++i)
134  {
135  FWEventItem *item = m_items[i];
136  if (item) {
137  item->destroy();
138  }
139  m_items[i]=nullptr;
140  }
142 
143  m_items.clear();
144 }
void destroy() const
Definition: FWEventItem.cc:610
std::vector< FWEventItem * > m_items
sigc::signal< void > goingToClearItems_
FWEventItemsManager::const_iterator FWEventItemsManager::end ( void  ) const
const FWEventItem * FWEventItemsManager::find ( const std::string &  iName) const

Look up an item by name.

Definition at line 347 of file FWEventItemsManager.cc.

References MillePedeFileConverter_cfg::e, mps_fire::i, m_items, and FWEventItem::name().

Referenced by FWGUIEventDataAdder::addNewItem().

348 {
349  for (size_t i = 0, e = m_items.size(); i != e; ++i)
350  {
351  const FWEventItem *item = m_items[i];
352  if (item && item->name() == iName)
353  return item;
354  }
355  return nullptr;
356 }
const std::string & name() const
Definition: FWEventItem.cc:502
std::vector< FWEventItem * > m_items
void FWEventItemsManager::newEvent ( const edm::EventBase iEvent)

Prepare to handle a new event by associating all the items to watch it.

Definition at line 113 of file FWEventItemsManager.cc.

References MillePedeFileConverter_cfg::e, mps_fire::i, iEvent, m_changeManager, m_event, m_items, and FWEventItem::setEvent().

114 {
116  m_event = iEvent;
117  for(size_t i = 0, e = m_items.size(); i != e; ++i)
118  {
119  FWEventItem *item = m_items[i];
120  if(item)
121  item->setEvent(iEvent);
122  }
123 }
FWModelChangeManager * m_changeManager
void setEvent(const edm::EventBase *iEvent)
Definition: FWEventItem.cc:122
int iEvent
Definition: GenABIO.cc:230
const edm::EventBase * m_event
std::vector< FWEventItem * > m_items
const FWEventItemsManager& FWEventItemsManager::operator= ( const FWEventItemsManager )
privatedelete
void FWEventItemsManager::removeItem ( const FWEventItem iItem)
private

Remove one item.

Notice that rather than erasing the item from the list, it is preferred to set it to zero, I guess to catch accesses to remove items and to avoid having to recalculate the current selection.

GE: I think this is a broken way of handling removal of objects. The object should be properly deleted and the current selection should be updated accordingly.

Definition at line 317 of file FWEventItemsManager.cc.

References FWEventItem::id(), m_items, and removingItem_.

Referenced by add().

318 {
319  assert(iItem->id() < m_items.size());
320  removingItem_(iItem);
321  m_items[iItem->id()] = nullptr;
322 }
sigc::signal< void, const FWEventItem * > removingItem_
unsigned int id() const
Definition: FWEventItem.cc:496
std::vector< FWEventItem * > m_items
void FWEventItemsManager::setContext ( fireworks::Context iContext)

Definition at line 325 of file FWEventItemsManager.cc.

References m_context.

Referenced by CmsShowMain::CmsShowMain().

326 {
327  m_context = iContext;
328 }
fireworks::Context * m_context
void FWEventItemsManager::setFrom ( const FWConfiguration iFrom)
overridevirtual

This is responsible for resetting the status of items from configuration

Implements FWConfigurable.

Definition at line 207 of file FWEventItemsManager.cc.

References add(), FWConfiguration::addKeyValue(), clearItems(), create_public_lumi_plots::color, fireworks::Context::colorManager(), FWConfiguration::keyValues(), kTrue(), m_changeManager, m_context, m_event, dataset::name, FWColorManager::oldColorToIndex(), modifiedElectrons_cfi::processName, trackingPlots::purpose, edm::second(), AlCaHLTBitMon_QueryRunRegistry::string, FWConfiguration::valueForKey(), and FWConfiguration::version().

208 {
210  assert(nullptr!=cm);
211 
212  clearItems();
213  const FWConfiguration::KeyValues* keyValues = iFrom.keyValues();
214 
215  if (keyValues == nullptr) return;
216 
217  std::vector<FWEventItem*> newItems;
218  newItems.reserve(keyValues->size());
219 
220  for (FWConfiguration::KeyValues::const_iterator it = keyValues->begin();
221  it != keyValues->end();
222  ++it)
223  {
224  const std::string& name = it->first;
225  const FWConfiguration& conf = it->second;
226  const FWConfiguration::KeyValues* keyValues = conf.keyValues();
227  assert(nullptr!=keyValues);
228  const std::string& type = (*keyValues)[0].second.value();
229  const std::string& moduleLabel = (*keyValues)[1].second.value();
230  const std::string& productInstanceLabel = (*keyValues)[2].second.value();
231  const std::string& processName = (*keyValues)[3].second.value();
232  const std::string& filterExpression = (*keyValues)[4].second.value();
233  const std::string& sColor = (*keyValues)[5].second.value();
234  const bool isVisible = (*keyValues)[6].second.value() == kTrue;
235 
236  unsigned int colorIndex;
237  if(conf.version() < 5)
238  {
239  std::istringstream is(sColor);
240  Color_t color;
241  is >> color;
242  colorIndex = cm->oldColorToIndex(color, conf.version());
243  }
244  else
245  {
246  // In version 4 we assume:
247  // fireworks colors start at ROOT index 1000
248  // geometry colors start at ROOT index 1100
249  // We save them as such -- no conversions needed.
250  std::istringstream is(sColor);
251  is >> colorIndex;
252  }
253 
254  int transparency = 0;
255 
256  // Read transparency from file. We don't care about checking errors
257  // because strtol returns 0 in that case.
258  if (conf.version() > 3)
259  transparency = strtol((*keyValues)[9].second.value().c_str(), nullptr, 10);
260 
261  FWDisplayProperties dp(colorIndex, isVisible, transparency);
262 
263  unsigned int layer = strtol((*keyValues)[7].second.value().c_str(), nullptr, 10);
264 
265  //For older configs assume name is the same as purpose
266  std::string purpose(name);
267  if (conf.version() > 1)
268  purpose = (*keyValues)[8].second.value();
269 
270  FWConfiguration* proxyConfig = (FWConfiguration*) conf.valueForKey("PBConfig") ? new FWConfiguration(*conf.valueForKey("PBConfig")) : nullptr;
271 
272  // beckward compatibilty for obsolete proxy builders
273  if (conf.version() < 6)
274  {
275  assert(proxyConfig == nullptr);
276  if (purpose == "VerticesWithTracks")
277  {
278  purpose = "Vertices";
279  proxyConfig = new FWConfiguration();
280  FWConfiguration vTmp; vTmp.addKeyValue("Draw Tracks", FWConfiguration("1"));
281  proxyConfig->addKeyValue("Var", vTmp,true);
282  }
283  }
284 
285  FWPhysicsObjectDesc desc(name,
286  TClass::GetClass(type.c_str()),
287  purpose,
288  dp,
289  moduleLabel,
290  productInstanceLabel,
291  processName,
292  filterExpression,
293  layer);
294 
295  newItems.push_back( add(desc, proxyConfig, false) );
296  }
297 
298  if (m_event)
299  {
301  for (auto ip : newItems)
302  ip->setEvent(m_event);
303  }
304 }
FWModelChangeManager * m_changeManager
type
Definition: HCALResponse.h:21
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
const KeyValues * keyValues() const
FWColorManager * colorManager() const
Definition: Context.h:65
static const std::string kTrue("t")
unsigned int version() const
Color_t oldColorToIndex(Color_t, int version) const
U second(std::pair< T, U > const &p)
FWEventItem * add(const FWPhysicsObjectDesc &iItem, const FWConfiguration *pbConf=nullptr, bool doSetEvent=true)
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
const edm::EventBase * m_event
fireworks::Context * m_context
const FWConfiguration * valueForKey(const std::string &iKey) const

Member Data Documentation

sigc::signal<void> FWEventItemsManager::goingToClearItems_
std::shared_ptr<FWItemAccessorFactory> FWEventItemsManager::m_accessorFactory
private

Definition at line 92 of file FWEventItemsManager.h.

Referenced by add().

FWModelChangeManager* FWEventItemsManager::m_changeManager
private

Definition at line 88 of file FWEventItemsManager.h.

Referenced by add(), newEvent(), and setFrom().

fireworks::Context* FWEventItemsManager::m_context
private

Definition at line 89 of file FWEventItemsManager.h.

Referenced by add(), addTo(), setContext(), and setFrom().

const edm::EventBase* FWEventItemsManager::m_event
private

Definition at line 91 of file FWEventItemsManager.h.

Referenced by add(), newEvent(), and setFrom().

std::vector<FWEventItem*> FWEventItemsManager::m_items
private
sigc::signal<void, FWEventItem*> FWEventItemsManager::newItem_
sigc::signal<void, const FWEventItem*> FWEventItemsManager::removingItem_

Definition at line 76 of file FWEventItemsManager.h.

Referenced by removeItem().