CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Fireworks/Core/interface/CmsShowMainBase.h

Go to the documentation of this file.
00001 #ifndef Fireworks_Core_CmsShowMainBase_h
00002 #define Fireworks_Core_CmsShowMainBase_h
00003 
00004 #include "Fireworks/Core/interface/FWPhysicsObjectDesc.h"
00005 #include "Fireworks/Core/interface/FWGeometry.h"
00006 
00007 #include "DataFormats/Provenance/interface/EventID.h"
00008 
00009 #include <memory>
00010 #include <string>
00011 #include <cassert>
00012 #include "sigc++/signal.h"
00013 
00014 #include "TTimer.h"
00015 
00016 class FWEventItemsManager;
00017 class FWGUIManager;
00018 class FWJobMetadataManager;
00019 class FWNavigatorBase;
00020 
00021 // replace forfard declaration with include to avoid compilation warnigs
00022 /*
00023 class FWModelChangeManager;
00024 class FWSelectionManager;
00025 class FWViewManagerManager;
00026 class CmsShowTaskExecutor;
00027 class FWChangeManager;
00028 class FWColorManager;
00029 class FWConfigurationManager;
00030 */
00031 #include "Fireworks/Core/interface/FWColorManager.h"
00032 #include "Fireworks/Core/interface/FWModelChangeManager.h"
00033 #include "Fireworks/Core/interface/FWConfigurationManager.h"
00034 #include "Fireworks/Core/interface/FWEventItemsManager.h"
00035 #include "Fireworks/Core/interface/FWSelectionManager.h"
00036 #include "Fireworks/Core/interface/FWViewManagerManager.h"
00037 #include "Fireworks/Core/src/CmsShowTaskExecutor.h"
00038 
00039 namespace fireworks {
00040    class Context;
00041 }
00042 
00049 class CmsShowMainBase
00050 {
00051 public:
00052    CmsShowMainBase();
00053    virtual ~CmsShowMainBase();
00054 
00055    FWModelChangeManager       *changeManager() {return m_changeManager.get(); }
00056    FWColorManager             *colorManager() { return  m_colorManager.get(); }
00057    FWConfigurationManager     *configurationManager() { return m_configurationManager.get(); }
00058    FWEventItemsManager        *eiManager() { return m_eiManager.get(); }
00059    FWModelChangeManager       *modelChangeManager() { return m_changeManager.get(); }
00060    FWSelectionManager         *selectionManager() { return m_selectionManager.get(); }
00061    FWViewManagerManager       *viewManager() { return m_viewManager.get(); }
00062    FWGUIManager               *guiManager() 
00063    { 
00064       assert(m_guiManager.get() && "Call CmsShowMainBase::setup first!"); 
00065       return m_guiManager.get(); 
00066    }
00067    
00068    CmsShowTaskExecutor        *startupTasks() { return m_startupTasks.get(); }
00069    
00070    void setup(FWNavigatorBase             *navigator,
00071               fireworks::Context          *context,
00072               FWJobMetadataManager        *metadataManager);
00073 
00074    void setupActions();
00075    void setupViewManagers();
00076 
00077    // Configuration handling.
00078    void setConfigFilename(const std::string &f) { m_configFileName = f; };
00079    const char *configFilename() const { return m_configFileName.c_str(); };
00080 
00081    void writeToConfigFile(const std::string &config);
00082    void writeToCurrentConfigFile();
00083    void reloadConfiguration(const std::string &config);
00084    void setupConfiguration();
00085    
00086    void registerPhysicsObject(const FWPhysicsObjectDesc&iItem);
00087    void draw();
00088 
00089    // Geometry handling
00090    void loadGeometry();
00091    void setGeometryFilename(const std::string &filename) {m_geometryFilename = filename; }
00092    const std::string &geometryFilename(void) { return m_geometryFilename; }
00093    FWGeometry& getGeom() { return m_geom; }
00094    
00095    // Event navigation.
00096    void doFirstEvent();
00097    void doPreviousEvent();
00098    void doNextEvent();
00099    void doLastEvent();
00100    void goToRunEvent(edm::RunNumber_t, edm::LuminosityBlockNumber_t, edm::EventNumber_t);
00101    virtual void checkPosition() = 0;
00102    bool forward() const { return m_forward; }
00103    bool loop() const { return m_loop; }
00104    virtual void quit() = 0;
00105    
00106    void setupAutoLoad(float x);
00107    void startAutoLoadTimer();
00108    void stopAutoLoadTimer();
00109    void setupDebugSupport();
00110    
00111    void setPlayDelay(Float_t val);
00112    void playForward();
00113    void playBackward();
00114    bool isPlaying() const { return m_isPlaying; }
00115    void setIsPlaying(bool value) { m_isPlaying = value; }
00116    virtual void stopPlaying() = 0;
00117    virtual void autoLoadNewEvent() = 0;
00118 
00119    void setPlayLoop();
00120    void unsetPlayLoop();
00121 
00122    void setAutoSaveAllViewsFormat(const std::string& fmt) { m_autoSaveAllViewsFormat = fmt; }
00123 
00124 protected: 
00125    class SignalTimer : public TTimer {
00126    public:
00127       virtual Bool_t Notify() {
00128          timeout_();
00129          return true;
00130       }
00131       sigc::signal<void> timeout_;
00132    };
00133 
00134    void eventChangedSlot();
00135    virtual void eventChangedImp();
00136 
00137 private:
00138    // The base class is responsible for the destruction of fwlite / FF
00139    // agnostic managers.
00140    std::auto_ptr<FWModelChangeManager>   m_changeManager;
00141    std::auto_ptr<FWColorManager>         m_colorManager;
00142    std::auto_ptr<FWConfigurationManager> m_configurationManager;
00143    std::auto_ptr<FWEventItemsManager>    m_eiManager;
00144    std::auto_ptr<FWGUIManager>           m_guiManager;
00145    std::auto_ptr<FWSelectionManager>     m_selectionManager;
00146    std::auto_ptr<CmsShowTaskExecutor>    m_startupTasks;
00147    std::auto_ptr<FWViewManagerManager>   m_viewManager;
00148 
00149   
00150 
00151    std::auto_ptr<SignalTimer>                 m_autoLoadTimer;
00152    
00153    // These are actually set by the concrete implementation via the setup 
00154    // method.
00155    FWNavigatorBase                      *m_navigatorPtr;
00156    FWJobMetadataManager                 *m_metadataManagerPtr;
00157    fireworks::Context                   *m_contextPtr;
00158 
00159    void setPlayLoopImp();
00160    void unsetPlayLoopImp();
00161    
00162    std::string                           m_autoSaveAllViewsFormat;
00163    bool                                  m_autoLoadTimerRunning;             
00164    bool                                  m_forward;
00165    bool                                  m_isPlaying;
00166    bool                                  m_loop;
00167    Float_t                               m_playDelay;
00168    std::string                           m_configFileName;
00169    std::string                           m_geometryFilename;
00170    FWGeometry                            m_geom;
00171 };
00172 
00173 #endif