CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Fireworks/Core/src/FWViewManagerManager.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWViewManagerManager
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Tue Jan 15 10:27:12 EST 2008
00011 // $Id: FWViewManagerManager.cc,v 1.18 2010/06/18 10:17:16 yana Exp $
00012 //
00013 
00014 // system include files
00015 #include <iostream>
00016 #include <boost/bind.hpp>
00017 
00018 #include "TEveManager.h"
00019 
00020 // user include files
00021 #include "Fireworks/Core/interface/FWViewManagerManager.h"
00022 #include "Fireworks/Core/interface/FWViewManagerBase.h"
00023 #include "Fireworks/Core/interface/FWEventItem.h"
00024 #include "Fireworks/Core/interface/fwLog.h"
00025 #include "Fireworks/Core/interface/FWTypeToRepresentations.h"
00026 
00027 //
00028 // constants, enums and typedefs
00029 //
00030 
00031 //
00032 // static data member definitions
00033 //
00034 
00035 //
00036 // constructors and destructor
00037 //
00038 FWViewManagerManager::FWViewManagerManager(FWModelChangeManager* iCM,
00039                                            FWColorManager* iColorM) :
00040    m_changeManager(iCM),
00041    m_colorManager(iColorM)
00042 {
00043 }
00044 
00045 // FWViewManagerManager::FWViewManagerManager(const FWViewManagerManager& rhs)
00046 // {
00047 //    // do actual copying here;
00048 // }
00049 
00050 FWViewManagerManager::~FWViewManagerManager()
00051 {
00052 }
00053 
00054 //
00055 // assignment operators
00056 //
00057 // const FWViewManagerManager& FWViewManagerManager::operator=(const FWViewManagerManager& rhs)
00058 // {
00059 //   //An exception safe implementation is
00060 //   FWViewManagerManager temp(rhs);
00061 //   swap(rhs);
00062 //
00063 //   return *this;
00064 // }
00065 
00066 //
00067 // member functions
00068 //
00069 void
00070 FWViewManagerManager::add( boost::shared_ptr<FWViewManagerBase> iManager)
00071 {
00072    m_viewManagers.push_back(iManager);
00073    iManager->setChangeManager(m_changeManager);
00074    iManager->setColorManager(m_colorManager);
00075 
00076    for(std::map<std::string,const FWEventItem*>::iterator it=m_typeToItems.begin(), itEnd=m_typeToItems.end();
00077        it != itEnd;
00078        ++it) {
00079       iManager->newItem(it->second);
00080    }
00081 }
00082 
00083 void
00084 FWViewManagerManager::registerEventItem(const FWEventItem*iItem)
00085 {
00086    if ( m_typeToItems.find(iItem->name()) != m_typeToItems.end() ) {
00087       fwLog(fwlog::kWarning) << "WARNING: item "<< iItem->name() <<" was already registered. Request ignored.\n";
00088       return;
00089    }
00090    m_typeToItems[iItem->name()]=iItem;
00091    iItem->goingToBeDestroyed_.connect(boost::bind(&FWViewManagerManager::removeEventItem,this,_1));
00092 
00093    //std::map<std::string, std::vector<std::string> >::iterator itFind = m_typeToBuilders.find(iItem->name());
00094    for(std::vector<boost::shared_ptr<FWViewManagerBase> >::iterator itVM = m_viewManagers.begin();
00095        itVM != m_viewManagers.end();
00096        ++itVM) {
00097       (*itVM)->newItem(iItem);
00098    }
00099 }
00100 
00101 void
00102 FWViewManagerManager::removeEventItem(const FWEventItem* iItem)
00103 {
00104    std::map<std::string, const FWEventItem*>::iterator itr =
00105       m_typeToItems.find(iItem->name());
00106    if ( itr != m_typeToItems.end() ) m_typeToItems.erase( itr );
00107 }
00108 
00109 
00110 //
00111 // const member functions
00112 //
00113 FWTypeToRepresentations
00114 FWViewManagerManager::supportedTypesAndRepresentations() const
00115 {
00116    FWTypeToRepresentations returnValue;
00117    for(std::vector<boost::shared_ptr<FWViewManagerBase> >::const_iterator itVM = m_viewManagers.begin();
00118        itVM != m_viewManagers.end();
00119        ++itVM) {
00120       FWTypeToRepresentations v = (*itVM)->supportedTypesAndRepresentations();
00121       returnValue.insert(v);
00122    }
00123    return returnValue;
00124 }
00125 
00126 void
00127 FWViewManagerManager::eventBegin()
00128 {
00129    gEve->DisableRedraw();
00130    for ( std::vector<boost::shared_ptr<FWViewManagerBase> >::iterator i = m_viewManagers.begin();
00131          i != m_viewManagers.end(); ++i )
00132       (*i)->eventBegin();
00133 }
00134 
00135 void
00136 FWViewManagerManager::eventEnd()
00137 {
00138    for ( std::vector<boost::shared_ptr<FWViewManagerBase> >::iterator i = m_viewManagers.begin();
00139          i != m_viewManagers.end(); ++i )
00140       (*i)->eventEnd();
00141    gEve->EnableRedraw();
00142 }
00143 
00144 //
00145 // static member functions
00146 //