Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-14 11:45:00

0001 #ifndef Fireworks_Core_CmsShowMainBase_h
0002 #define Fireworks_Core_CmsShowMainBase_h
0003 
0004 #include "Fireworks/Core/interface/FWPhysicsObjectDesc.h"
0005 #include "Fireworks/Core/interface/FWGeometry.h"
0006 
0007 #include "DataFormats/Provenance/interface/EventID.h"
0008 
0009 #include <memory>
0010 #include <string>
0011 #include <cassert>
0012 #include "sigc++/signal.h"
0013 
0014 #include "TTimer.h"
0015 
0016 class FWEventItemsManager;
0017 class FWGUIManager;
0018 class FWJobMetadataManager;
0019 class FWNavigatorBase;
0020 
0021 // replace forfard declaration with include to avoid compilation warnigs
0022 /*
0023 class FWModelChangeManager;
0024 class FWSelectionManager;
0025 class FWViewManagerManager;
0026 class CmsShowTaskExecutor;
0027 class FWChangeManager;
0028 class FWColorManager;
0029 class FWConfigurationManager;
0030 */
0031 #include "Fireworks/Core/interface/FWColorManager.h"
0032 #include "Fireworks/Core/interface/FWModelChangeManager.h"
0033 #include "Fireworks/Core/interface/FWConfigurationManager.h"
0034 #include "Fireworks/Core/interface/FWEventItemsManager.h"
0035 #include "Fireworks/Core/interface/FWSelectionManager.h"
0036 #include "Fireworks/Core/interface/FWViewManagerManager.h"
0037 #include "Fireworks/Core/interface/CmsShowTaskExecutor.h"
0038 
0039 namespace fireworks {
0040   class Context;
0041 }
0042 
0043 /** This is the base class to be used for setting up the main loop and
0044     navigation. FF and standalone main should derive from this one,
0045     since it takes care of most of the set up and navigation logic. 
0046     Concrete implementations are actually supposed to create a concrete
0047     instance of the Context, FWNavigatorBase and FWJobMetadataManager. 
0048   */
0049 class CmsShowMainBase {
0050 public:
0051   CmsShowMainBase();
0052   virtual ~CmsShowMainBase() noexcept(false);
0053 
0054   FWModelChangeManager *changeManager() { return m_changeManager.get(); }
0055   FWColorManager *colorManager() { return m_colorManager.get(); }
0056   FWConfigurationManager *configurationManager() { return m_configurationManager.get(); }
0057   FWEventItemsManager *eiManager() { return m_eiManager.get(); }
0058   FWModelChangeManager *modelChangeManager() { return m_changeManager.get(); }
0059   FWSelectionManager *selectionManager() { return m_selectionManager.get(); }
0060   FWViewManagerManager *viewManager() { return m_viewManager.get(); }
0061   FWGUIManager *guiManager() {
0062     assert(m_guiManager.get() && "Call CmsShowMainBase::setup first!");
0063     return m_guiManager.get();
0064   }
0065 
0066   CmsShowTaskExecutor *startupTasks() { return m_startupTasks.get(); }
0067 
0068   void setup(FWNavigatorBase *navigator, fireworks::Context *context, FWJobMetadataManager *metadataManager);
0069 
0070   void setupActions();
0071   void setupViewManagers();
0072 
0073   // Configuration handling.
0074   void setConfigFilename(const std::string &f) { m_configFileName = f; };
0075   const char *configFilename() const { return m_configFileName.c_str(); };
0076 
0077   void writeToConfigFile(const std::string &config);
0078   void writeToCurrentConfigFile();
0079   void writePartialToConfigFile();
0080   void reloadConfiguration(const std::string &config);
0081   void partialWriteToConfigFile(const std::string &config);
0082   void partialLoadConfiguration(const std::string &config);
0083   void setupConfiguration();
0084 
0085   void registerPhysicsObject(const FWPhysicsObjectDesc &iItem);
0086   void draw();
0087 
0088   // Geometry handling
0089   void loadGeometry();
0090   void setGeometryFilename(const std::string &filename) { m_geometryFilename = filename; }
0091   const std::string &geometryFilename(void) { return m_geometryFilename; }
0092   FWGeometry &getGeom() { return m_geom; }
0093 
0094   void setSimGeometryFilename(const std::string &filename, const std::string &geoname) {
0095     m_simGeometryFilename = filename;
0096     m_TGeoName = geoname;
0097   }
0098 
0099   // Event navigation.
0100   void doFirstEvent();
0101   void doPreviousEvent();
0102   void doNextEvent();
0103   void doLastEvent();
0104   void goToRunEvent(edm::RunNumber_t, edm::LuminosityBlockNumber_t, edm::EventNumber_t);
0105   virtual void checkPosition() = 0;
0106   bool forward() const { return m_forward; }
0107   bool loop() const { return m_loop; }
0108   virtual void quit() = 0;
0109 
0110   void setupAutoLoad(float x);
0111   void startAutoLoadTimer();
0112   void stopAutoLoadTimer();
0113   void setupDebugSupport();
0114 
0115   void setPlayDelay(Float_t val);
0116   void playForward();
0117   void playBackward();
0118   bool isPlaying() const { return m_isPlaying; }
0119 
0120   virtual void checkKeyBindingsOnPLayEventsStateChanged() {}
0121   virtual void stopPlaying();
0122   virtual void autoLoadNewEvent() = 0;
0123 
0124   void setPlayLoop();
0125   void unsetPlayLoop();
0126 
0127   void setAutoSaveAllViewsFormat(const std::string &fmt) { m_autoSaveAllViewsFormat = fmt; }
0128   void setAutoSaveAllViewsHeight(int x) { m_autoSaveAllViewsHeight = x; }
0129 
0130   class SignalTimer : public TTimer {
0131   public:
0132     Bool_t Notify() override {
0133       timeout_();
0134       return true;
0135     }
0136     sigc::signal<void()> timeout_;
0137   };
0138 
0139 protected:
0140   void eventChangedSlot();
0141   virtual void eventChangedImp();
0142   void sendVersionInfo();
0143   fireworks::Context *context() { return m_contextPtr; }
0144 
0145 private:
0146   // The base class is responsible for the destruction of fwlite / FF
0147   // agnostic managers.
0148   std::unique_ptr<FWModelChangeManager> m_changeManager;
0149   std::unique_ptr<FWColorManager> m_colorManager;
0150   std::unique_ptr<FWConfigurationManager> m_configurationManager;
0151   std::unique_ptr<FWEventItemsManager> m_eiManager;
0152   std::unique_ptr<FWGUIManager> m_guiManager;
0153   std::unique_ptr<FWSelectionManager> m_selectionManager;
0154   std::unique_ptr<CmsShowTaskExecutor> m_startupTasks;
0155   std::unique_ptr<FWViewManagerManager> m_viewManager;
0156 
0157   std::unique_ptr<SignalTimer> m_autoLoadTimer;
0158 
0159   // These are actually set by the concrete implementation via the setup
0160   // method.
0161   FWNavigatorBase *m_navigatorPtr;
0162   FWJobMetadataManager *m_metadataManagerPtr;
0163   fireworks::Context *m_contextPtr;
0164 
0165   void setPlayLoopImp();
0166   void unsetPlayLoopImp();
0167 
0168   std::string m_autoSaveAllViewsFormat;
0169   int m_autoSaveAllViewsHeight;
0170   bool m_autoLoadTimerRunning;
0171   bool m_forward;
0172   bool m_isPlaying;
0173   bool m_loop;
0174   Float_t m_playDelay;
0175   std::string m_configFileName;
0176   std::string m_geometryFilename;
0177   FWGeometry m_geom;
0178   std::string m_simGeometryFilename;
0179   std::string m_TGeoName;
0180 };
0181 
0182 #endif