CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/Fireworks/Core/src/CSGActionSupervisor.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     CSGActionSupervisor
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Alja Mrak-Tadel
00010 //         Created:  Aug 2009
00011 //
00012 #include <sigc++/sigc++.h>
00013 
00014 #include "Fireworks/Core/interface/CSGActionSupervisor.h"
00015 #include "Fireworks/Core/interface/CSGAction.h"
00016 #include "Fireworks/Core/interface/fwLog.h"
00017 
00018 // constructors and destructor
00019 //
00020 CSGActionSupervisor::CSGActionSupervisor():
00021    m_tooltipDelay(3)
00022 {
00023 }
00024 
00025 CSGActionSupervisor::~CSGActionSupervisor()
00026 {
00027    for(std::vector<CSGAction*>::iterator it= m_actionList.begin(),itEnd = m_actionList.end();
00028        it != itEnd;
00029        ++it) {
00030       delete *it;
00031    }
00032 }
00033 
00034 CSGAction*
00035 CSGActionSupervisor::getAction(const std::string& name)
00036 {
00037    std::vector<CSGAction*>::iterator it_act;
00038    for (it_act = m_actionList.begin(); it_act != m_actionList.end(); ++it_act) {
00039       if ((*it_act)->getName() == name)
00040          return *it_act;
00041    }
00042    fwLog(fwlog::kWarning) << "No action is found with name " <<  name.c_str() << std::endl;
00043    return 0;
00044 }
00045 
00046 void CSGActionSupervisor::addToActionMap(CSGAction *action) {
00047    m_actionList.push_back(action);
00048 }
00049 
00050 const std::vector<CSGAction *>& CSGActionSupervisor::getListOfActions() const {
00051    return m_actionList;
00052 }
00053 
00054 void
00055 CSGActionSupervisor::defaultAction()
00056 {
00057    fwLog(fwlog::kInfo) << "Default action.\n";
00058 }
00059 
00060 void
00061 CSGActionSupervisor::enableActions(bool enable)
00062 {
00063    std::vector<CSGAction*>::iterator it_act;
00064    for (it_act = m_actionList.begin(); it_act != m_actionList.end(); ++it_act) {
00065       if (enable)
00066          (*it_act)->globalEnable();
00067       else
00068          (*it_act)->globalDisable();
00069    }
00070 }
00071 
00072 Bool_t CSGActionSupervisor::activateMenuEntry(int entry) {
00073    std::vector<CSGAction*>::iterator it_act;
00074    for (it_act = m_actionList.begin(); it_act != m_actionList.end(); ++it_act) {
00075       if (entry == (*it_act)->getMenuEntry()) {
00076          (*it_act)->activated.emit();
00077          return kTRUE;
00078       }
00079    }
00080    return kFALSE;
00081 }
00082 
00083 Bool_t CSGActionSupervisor::activateToolBarEntry(int entry) {
00084    std::vector<CSGAction*>::iterator it_act;
00085    for (it_act = m_actionList.begin(); it_act != m_actionList.end(); ++it_act) {
00086       if ((*it_act)->getToolBarData() && (*it_act)->getToolBarData()->fId == entry) {
00087          (*it_act)->activated.emit();
00088          return kTRUE;
00089       }
00090    }
00091    return kFALSE;
00092 }
00093 
00094 void CSGActionSupervisor::HandleMenu(int id) {
00095 }
00096 
00097 void CSGActionSupervisor::resizeMenu(TGPopupMenu *menu) {
00098    std::vector<CSGAction*>::iterator it_act;
00099    for (it_act = m_actionList.begin(); it_act != m_actionList.end(); ++it_act) {
00100       if ((*it_act)->getMenu() == menu && (*it_act)->getKeycode() != 0) {
00101          (*it_act)->resizeMenuEntry();
00102       }
00103    }
00104 }
00105 
00106 Long_t CSGActionSupervisor::getToolTipDelay() const {
00107    return m_tooltipDelay;
00108 }