CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/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    void setSimGeometryFilename(const std::string &filename) {m_simGeometryFilename = filename; }
00096    
00097    // Event navigation.
00098    void doFirstEvent();
00099    void doPreviousEvent();
00100    void doNextEvent();
00101    void doLastEvent();
00102    void goToRunEvent(edm::RunNumber_t, edm::LuminosityBlockNumber_t, edm::EventNumber_t);
00103    virtual void checkPosition() = 0;
00104    bool forward() const { return m_forward; }
00105    bool loop() const { return m_loop; }
00106    virtual void quit() = 0;
00107    
00108    void setupAutoLoad(float x);
00109    void startAutoLoadTimer();
00110    void stopAutoLoadTimer();
00111    void setupDebugSupport();
00112    
00113    void setPlayDelay(Float_t val);
00114    void playForward();
00115    void playBackward();
00116    bool isPlaying() const { return m_isPlaying; }
00117    void setIsPlaying(bool value) { m_isPlaying = value; }
00118    virtual void stopPlaying() = 0;
00119    virtual void autoLoadNewEvent() = 0;
00120 
00121    void setPlayLoop();
00122    void unsetPlayLoop();
00123 
00124    void setAutoSaveAllViewsFormat(const std::string& fmt) { m_autoSaveAllViewsFormat = fmt; }
00125 
00126 protected: 
00127    class SignalTimer : public TTimer {
00128    public:
00129       virtual Bool_t Notify() {
00130          timeout_();
00131          return true;
00132       }
00133       sigc::signal<void> timeout_;
00134    };
00135 
00136    void eventChangedSlot();
00137    virtual void eventChangedImp();
00138    void sendVersionInfo();
00139 
00140 private:
00141    // The base class is responsible for the destruction of fwlite / FF
00142    // agnostic managers.
00143    std::auto_ptr<FWModelChangeManager>   m_changeManager;
00144    std::auto_ptr<FWColorManager>         m_colorManager;
00145    std::auto_ptr<FWConfigurationManager> m_configurationManager;
00146    std::auto_ptr<FWEventItemsManager>    m_eiManager;
00147    std::auto_ptr<FWGUIManager>           m_guiManager;
00148    std::auto_ptr<FWSelectionManager>     m_selectionManager;
00149    std::auto_ptr<CmsShowTaskExecutor>    m_startupTasks;
00150    std::auto_ptr<FWViewManagerManager>   m_viewManager;
00151 
00152   
00153 
00154    std::auto_ptr<SignalTimer>                 m_autoLoadTimer;
00155    
00156    // These are actually set by the concrete implementation via the setup 
00157    // method.
00158    FWNavigatorBase                      *m_navigatorPtr;
00159    FWJobMetadataManager                 *m_metadataManagerPtr;
00160    fireworks::Context                   *m_contextPtr;
00161 
00162    void setPlayLoopImp();
00163    void unsetPlayLoopImp();
00164    
00165    std::string                           m_autoSaveAllViewsFormat;
00166    bool                                  m_autoLoadTimerRunning;             
00167    bool                                  m_forward;
00168    bool                                  m_isPlaying;
00169    bool                                  m_loop;
00170    Float_t                               m_playDelay;
00171    std::string                           m_configFileName;
00172    std::string                           m_geometryFilename;
00173    FWGeometry                            m_geom;
00174    std::string                           m_simGeometryFilename;
00175 };
00176 
00177 #endif