CMS 3D CMS Logo

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

List of all members.

Public Types

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

Public Member Functions

const FWEventItemadd (const FWPhysicsObjectDesc &iItem)
void addTo (FWConfiguration &) const
const_iterator begin () const
 NOTE: iterator is allowed to return a null object for items that have been removed.
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 &)
virtual ~FWEventItemsManager ()

Public Attributes

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

Private Member Functions

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

Private Attributes

boost::shared_ptr
< FWItemAccessorFactory
m_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 40 of file FWEventItemsManager.cc.

FWEventItemsManager::~FWEventItemsManager ( ) [virtual]

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 59 of file FWEventItemsManager.cc.

References i, and m_items.

{
   for (size_t i = 0, e = m_items.size(); i != e; ++i)
      delete m_items[i];

   m_items.clear();
}
FWEventItemsManager::FWEventItemsManager ( const FWEventItemsManager ) [private]

Member Function Documentation

const FWEventItem * FWEventItemsManager::add ( const FWPhysicsObjectDesc iItem)

Definition at line 83 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(), cond::rpcobtemp::temp, and FWPhysicsObjectDesc::type().

Referenced by FWGUIEventDataAdder::addNewItem(), and setFrom().

{
   FWPhysicsObjectDesc temp(iItem);
   
   if(! m_context->colorManager()->colorHasIndex(temp.displayProperties().color())) {
      FWDisplayProperties prop(temp.displayProperties());
      fwLog(fwlog::kWarning) << Form("FWEventItemsManager::add(const FWPhysicsObjectDesc& iItem), color index  not valid. Set Color idex to %d\n", FWColorManager::getDefaultStartColorIndex());
      prop.setColor(FWColorManager::getDefaultStartColorIndex());
      temp.setDisplayProperties(prop);
   }
   
   m_items.push_back(new FWEventItem(m_context,m_items.size(),m_accessorFactory->accessorFor(temp.type()),
                                     temp) );
   newItem_(m_items.back());
   m_items.back()->goingToBeDestroyed_.connect(boost::bind(&FWEventItemsManager::removeItem,this,_1));
   if(m_event) {
      FWChangeSentry sentry(*m_changeManager);
      m_items.back()->setEvent(m_event);
   }
   return m_items.back();
}
void FWEventItemsManager::addTo ( FWConfiguration iTo) const [virtual]

Implements FWConfigurable.

Definition at line 156 of file FWEventItemsManager.cc.

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

{
   FWColorManager* cm = m_context->colorManager();
   assert(0!=cm);
   for(std::vector<FWEventItem*>::const_iterator it = m_items.begin();
       it != m_items.end();
       ++it)
   {
      if(!*it) continue;
      FWConfiguration conf(5);
      ROOT::Reflex::Type dataType( ROOT::Reflex::Type::ByTypeInfo(*((*it)->type()->GetTypeInfo())));
      assert(dataType != ROOT::Reflex::Type() );

      conf.addKeyValue(kType,FWConfiguration(dataType.Name(ROOT::Reflex::SCOPED)));
      conf.addKeyValue(kModuleLabel,FWConfiguration((*it)->moduleLabel()));
      conf.addKeyValue(kProductInstanceLabel, FWConfiguration((*it)->productInstanceLabel()));
      conf.addKeyValue(kProcessName, FWConfiguration((*it)->processName()));
      conf.addKeyValue(kFilterExpression, FWConfiguration((*it)->filterExpression()));
      {
         std::ostringstream os;
         os << (*it)->defaultDisplayProperties().color();
         conf.addKeyValue(kColor, FWConfiguration(os.str()));
      }
      conf.addKeyValue(kIsVisible, FWConfiguration((*it)->defaultDisplayProperties().isVisible() ? kTrue : kFalse));
      {
         std::ostringstream os;
         os << (*it)->layer();
         conf.addKeyValue(kLayer,FWConfiguration(os.str()));
      }
      conf.addKeyValue(kPurpose,(*it)->purpose());
      {
         std::ostringstream os;
         os << static_cast<int>((*it)->defaultDisplayProperties().transparency());
         conf.addKeyValue(kTransparency, FWConfiguration(os.str()));
      }
      iTo.addKeyValue((*it)->name(), conf, true);
   }
}
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 299 of file FWEventItemsManager.cc.

References m_items.

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

{
   return m_items.begin();
}
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 127 of file FWEventItemsManager.cc.

References FWEventItem::destroy(), goingToClearItems_, i, and m_items.

Referenced by setFrom().

{
   for (size_t i = 0, e = m_items.size(); i != e; ++i)
   {
      FWEventItem *item = m_items[i];
      if (item) {
         item->destroy();
      }
      m_items[i]=0;
   }
   goingToClearItems_();

   m_items.clear();
}
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 312 of file FWEventItemsManager.cc.

References i, m_items, and FWEventItem::name().

Referenced by FWGUIEventDataAdder::addNewItem().

{
   for (size_t i = 0, e = m_items.size(); i != e; ++i)
   {
      const FWEventItem *item = m_items[i];
      if (item && item->name() == iName)
         return item;
   }
   return 0;
}
void FWEventItemsManager::newEvent ( const edm::EventBase iEvent)

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

Definition at line 109 of file FWEventItemsManager.cc.

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

{
   FWChangeSentry sentry(*m_changeManager);
   m_event = iEvent;
   for(size_t i = 0, e = m_items.size(); i != e; ++i)
   {
      FWEventItem *item = m_items[i];
      if(item)
         item->setEvent(iEvent);
   }
}
const FWEventItemsManager& FWEventItemsManager::operator= ( const FWEventItemsManager ) [private]
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 283 of file FWEventItemsManager.cc.

References FWEventItem::id(), and m_items.

Referenced by add().

{
   assert(iItem->id() < m_items.size());
   m_items[iItem->id()] = 0;
}
void FWEventItemsManager::setContext ( fireworks::Context iContext)

Definition at line 290 of file FWEventItemsManager.cc.

References m_context.

Referenced by CmsShowMain::CmsShowMain(), FWFFLooper::FWFFLooper(), and FWFFService::FWFFService().

{
   m_context = iContext;
}
void FWEventItemsManager::setFrom ( const FWConfiguration iFrom) [virtual]

This is responsible for resetting the status of items from configuration

Implements FWConfigurable.

Definition at line 198 of file FWEventItemsManager.cc.

References add(), clearItems(), fireworks::Context::colorManager(), dbtoconf::conf, FWConfiguration::keyValues(), kTrue(), m_context, moduleLabel(), mergeVDriftHistosByStation::name, FWColorManager::oldColorToIndex(), edm::second(), and FWConfiguration::version().

{
 
   FWColorManager* cm = m_context->colorManager();
   assert(0!=cm);

   clearItems();
   const FWConfiguration::KeyValues* keyValues =  iFrom.keyValues();

   if (keyValues == 0) return;

   for (FWConfiguration::KeyValues::const_iterator it = keyValues->begin();
        it != keyValues->end();
        ++it)
   {
      const std::string& name = it->first;
      const FWConfiguration& conf = it->second;
      const FWConfiguration::KeyValues* keyValues =  conf.keyValues();
      assert(0!=keyValues);
      const std::string& type = (*keyValues)[0].second.value();
      const std::string& moduleLabel = (*keyValues)[1].second.value();
      const std::string& productInstanceLabel = (*keyValues)[2].second.value();
      const std::string& processName = (*keyValues)[3].second.value();
      const std::string& filterExpression = (*keyValues)[4].second.value();
      const std::string& sColor = (*keyValues)[5].second.value();
      const bool isVisible = (*keyValues)[6].second.value() == kTrue;

      unsigned int colorIndex;
      if(conf.version() < 5)
      {
         std::istringstream is(sColor);
         Color_t color;
         is >> color;
         colorIndex = cm->oldColorToIndex(color, conf.version());
      }
      else
      {
         // In version 4 we assume:
         //   fireworks colors start at ROOT index 1000
         //   geometry  colors start at ROOT index 1100
         // We save them as such -- no conversions needed.
         std::istringstream is(sColor);
         is >> colorIndex;
      }
      
      int transparency = 0;

      // Read transparency from file. We don't care about checking errors
      // because strtol returns 0 in that case.
      if (conf.version() > 3)
         transparency = strtol((*keyValues)[9].second.value().c_str(), 0, 10);

      FWDisplayProperties dp(colorIndex, isVisible, transparency);

      unsigned int layer = strtol((*keyValues)[7].second.value().c_str(), 0, 10);

      //For older configs assume name is the same as purpose
      std::string purpose(name);
      if (conf.version() > 1)
         purpose = (*keyValues)[8].second.value();
      
      FWPhysicsObjectDesc desc(name,
                               TClass::GetClass(type.c_str()),
                               purpose,
                               dp,
                               moduleLabel,
                               productInstanceLabel,
                               processName,
                               filterExpression,
                               layer);
      add(desc);
   }
}

Member Data Documentation

Definition at line 89 of file FWEventItemsManager.h.

Referenced by add().

Definition at line 85 of file FWEventItemsManager.h.

Referenced by add(), and newEvent().

Definition at line 86 of file FWEventItemsManager.h.

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

Definition at line 88 of file FWEventItemsManager.h.

Referenced by add(), and newEvent().

std::vector<FWEventItem*> FWEventItemsManager::m_items [private]