CMS 3D CMS Logo

Classes | Public Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes

FWDetailViewManager Class Reference

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

List of all members.

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.

                                                              :
   m_colorManager(colMng)
{  
   // force white background for all embedded canvases
   gROOT->SetStyle("Plain");

   m_colorManager->colorsHaveChanged_.connect(boost::bind(&FWDetailViewManager::colorsChanged,this));
   gEve->GetWindowManager()->Connect( "WindowDeleted(TEveWindow*)", "FWDetailViewManager", this, "eveWindowDestroyed(TEveWindow*)");   
}
FWDetailViewManager::~FWDetailViewManager ( ) [virtual]

Definition at line 59 of file FWDetailViewManager.cc.

References newEventCallback().

{ 
   newEventCallback();
   gEve->GetWindowManager()->Disconnect("WindowDeleted(TEveWindow*)", this, "eveWindowDestroyed(TEveWindow*)" );
}
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().

{
   for (vViews_i i = m_views.begin(); i !=  m_views.end(); ++i)
      (*i).m_detailView->setBackgroundColor(m_colorManager->background());
}
std::vector< std::string > FWDetailViewManager::detailViewsFor ( const FWModelId iId) const

Definition at line 108 of file FWDetailViewManager.cc.

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

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

{
   std::string typeName = ROOT::Reflex::Type::ByTypeInfo(*(iId.item()->modelType()->GetTypeInfo())).Name(ROOT::Reflex::SCOPED);
   std::vector<std::string> fullNames = findViewersFor(typeName);
   std::vector<std::string> justViewNames;
   justViewNames.reserve(fullNames.size());
   std::transform(fullNames.begin(),fullNames.end(),std::back_inserter(justViewNames),&viewNameFrom);
   return justViewNames;
}
void FWDetailViewManager::eveWindowDestroyed ( TEveWindow *  ew)

Definition at line 175 of file FWDetailViewManager.cc.

References i, and m_views.

{
   for (vViews_i i = m_views.begin(); i != m_views.end(); ++i)
   {
      if (ew == i->m_eveWindow)
      {
         // printf("========================== delete %s \n", ew->GetElementName());
         delete i->m_detailView;
         m_views.erase(i);
         break;
      }
   }
}
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(), and viewNameFrom().

Referenced by detailViewsFor(), and openDetailViewFor().

{
   std::vector<std::string> returnValue;

   std::map<std::string,std::vector<std::string> >::const_iterator itFind = m_typeToViewers.find(iType);
   if(itFind != m_typeToViewers.end()) {
      return itFind->second;
   }
   //create a list of the available ViewManager's
   std::set<std::string> detailViews;

   std::vector<edmplugin::PluginInfo> available = FWDetailViewFactory::get()->available();
   std::transform(available.begin(),
                  available.end(),
                  std::inserter(detailViews,detailViews.begin()),
                  boost::bind(&edmplugin::PluginInfo::name_,_1));
   unsigned int closestMatch= 0xFFFFFFFF;
   for(std::set<std::string>::iterator it = detailViews.begin(), itEnd=detailViews.end();
       it!=itEnd;
       ++it) {
      std::string::size_type first = it->find_first_of('@');
      std::string type = it->substr(0,first);

      if(type == iType) {
         returnValue.push_back(viewNameFrom(*it));
      }
      //see if we match via inheritance
      FWSimpleRepresentationChecker checker(type,"",0,false);
      FWRepresentationInfo info = checker.infoFor(iType);
      if(closestMatch > info.proximity()) {
         //closestMatch = info.proximity();
         returnValue.push_back(*it);
      }
   }
   m_typeToViewers[iType]=returnValue;
   return returnValue;
}
void FWDetailViewManager::newEventCallback ( )

Definition at line 166 of file FWDetailViewManager.cc.

References m_views.

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

{
   while (!m_views.empty())
   {  
      m_views.front().m_eveWindow->DestroyWindowAndSlot();
   }
}
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().

{
   TEveWindowSlot* slot = TEveWindow::CreateWindowMainFrame();
   TEveCompositeFrameInMainFrame* eveFrame = (TEveCompositeFrameInMainFrame*)slot->GetEveFrame();

   // find the right viewer for this item
   std::string typeName = ROOT::Reflex::Type::ByTypeInfo(*(id.item()->modelType()->GetTypeInfo())).Name(ROOT::Reflex::SCOPED);
   std::vector<std::string> viewerNames = findViewersFor(typeName);
   if(0==viewerNames.size()) {
      fwLog(fwlog::kError) << "FWDetailViewManager: don't know what detailed view to "
         "use for object " << id.item()->name() << std::endl;
      assert(0!=viewerNames.size());
   }

   //see if one of the names matches iViewName
   std::string match;
   for(std::vector<std::string>::iterator it = viewerNames.begin(), itEnd = viewerNames.end(); it != itEnd; ++it) {
      std::string t = viewNameFrom(*it);
      //std::cout <<"'"<<iViewName<< "' '"<<t<<"'"<<std::endl;
      if(t == iViewName) {
         match = *it;
         break;
      }
   }
   assert(match.size() != 0);
   FWDetailViewBase* detailView = FWDetailViewFactory::get()->create(match);
   assert(0!=detailView);

   TEveWindowSlot* ws  = (TEveWindowSlot*)(eveFrame->GetEveWindow());
   detailView->init(ws);
   detailView->build(id);
   detailView->setBackgroundColor(m_colorManager->background());

   TGMainFrame* mf = (TGMainFrame*)(eveFrame->GetParent());
   mf->SetWindowName(Form("%s Detail View [%d]", id.item()->name().c_str(), id.index())); 
  
   m_views.push_back(ViewFrame(eveFrame, detailView, eveFrame->GetEveWindow()));

   mf->MapRaised();
}
const FWDetailViewManager& FWDetailViewManager::operator= ( const FWDetailViewManager ) [private]

Member Data Documentation

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 [mutable, private]

Definition at line 67 of file FWDetailViewManager.h.

Referenced by findViewersFor().