Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:57

0001 /****************************************************************************\
0002  *    Poms.h, header for:
0003  *
0004  *    PomsClient.C -- A program to graphically launch and control all online
0005  *        monitoring for PHENIX subsystems.
0006  *    This program requires the ROOT runtime environment and each subsystems
0007  *        individual online monitoring client macros.
0008  *    
0009  *    Program developed at Brookhaven National Laboratory for the PHENIX
0010  *        collaboration to be used by offline shifters.
0011  *
0012  *
0013  *
0014  *    Copyright 2003 Phenix Collaboration
0015  *
0016  *
0017  *    M. McCain (mcm99c@acu.edu)    January 2003
0018  *
0019  *    Credit to Ryan Roth (LANL) for coding style and example of ROOT GUI
0020  *    in his implementation of HVDP (High Voltage Display Program)
0021  ****************************************************************************
0022  */
0023 
0024 /* ROOT headers */
0025 #pragma GCC diagnostic push
0026 #pragma GCC diagnostic ignored "-Woverloaded-virtual"
0027 #include <TGFrame.h>
0028 #include <TGShutter.h>
0029 #pragma GCC diagnostic pop
0030 
0031 /* Standard C++ headers */
0032 
0033 #include <list>
0034 #include <map>
0035 #include <string>
0036 
0037 /* forward declarations to speed up compilation */
0038 class TList;
0039 class TGMenuBar;
0040 class TGButton;
0041 class TGPopupMenu;
0042 class TGHotString;
0043 class TGWindow;
0044 
0045 #define POMS_VER "POMS Ver 1.0: "
0046 
0047 enum EMessageID
0048 {
0049   M_FILE_TEST,
0050   M_FILE_EXIT,
0051   M_WINDOW_ALIGNRIGHT,
0052   M_WINDOW_TILEALL,
0053   B_QUIT
0054 };
0055 
0056 // Declare all classes to preven compiler errors
0057 class SubSystem;
0058 class SubSystemAction;
0059 
0060 // Declare list types
0061 typedef std::list<SubSystem*> SubSystemList;
0062 typedef std::list<SubSystemAction*> SubSystemActionList;
0063 typedef std::less<int> lessp;
0064 typedef std::map<int, SubSystemAction*, lessp> SubSystemActionMap;
0065 
0066 /////////////////////////////////////////////////////////////////////////////
0067 //    Class that defines the main Window                                   //
0068 //                                                                         //
0069 //    (actual main window obtained from gClient->GetRoot() since we        //
0070 //    are running in CINT environment)                                     //
0071 //                                                                         //
0072 //    Implements Singleton Pattern                                         //
0073 /////////////////////////////////////////////////////////////////////////////
0074 
0075 class PomsMainFrame : public TGMainFrame
0076 {
0077  private:
0078   static PomsMainFrame* _instance;
0079 
0080   //Paths
0081   std::string _macroPath;
0082 
0083   int looping;
0084   //Root Screen Properties
0085   /*** See constructor to change default values ***/
0086   UInt_t _rootWidth;
0087   UInt_t _rootHeight;
0088   UInt_t _rootHorizPad;
0089   UInt_t _rootVertPad;
0090   UInt_t _windowPad;
0091 
0092   //GUI OBJECTS -- Main Window
0093   TGButton* _closeButton;
0094   TGMenuBar* _menuBar;
0095   TGPopupMenu* _menuFile;
0096   TGPopupMenu* _menuWindow;
0097   TGShutter* _shutter;
0098 
0099   TGButton* startloop;
0100   TGButton* stoploop;
0101   //Collections
0102   SubSystemList _subSystemList;
0103 
0104   //MEMBER FUNCTIONS
0105   TGShutter* BuildShutter();
0106   int HandleButtonPoms(Long_t parm1);
0107   void LoopDiLoop();
0108 
0109   // Singleton, private constructure
0110   PomsMainFrame(const TGWindow* p, UInt_t w, UInt_t h);
0111 
0112  public:
0113   static PomsMainFrame* Instance();
0114   virtual ~PomsMainFrame();
0115   void StopLoop();
0116 
0117   void SetMacroPath(const char* path);
0118   virtual void CloseWindow();
0119   virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t /* parm2 */);
0120 #pragma GCC diagnostic push
0121 #pragma GCC diagnostic ignored "-Woverloaded-virtual"
0122   void Draw();
0123 #pragma GCC diagnostic pop
0124   void AlignRight();
0125   void TileCanvases(TList* canvasList);
0126   void CascadeCanvases(TList* canvasList);
0127   void TileAllCanvases();
0128 
0129   //Accessors
0130   UInt_t GetRootWidth() { return _rootWidth; };
0131   UInt_t GetRootHeight() { return _rootHeight; };
0132   const std::string& GetMacroPath() { return _macroPath; };
0133 
0134   //CONFIGURATION FUNCTIONS
0135   SubSystem* RegisterSubSystem(const char* name, const char* prefix,
0136                                int addDefaultActions = 1, int loadLibrary = 1);
0137   SubSystem* RegisterSubSystem(SubSystem* subSystem);
0138 };
0139 
0140 /////////////////////////////////////////////////////////////////////////////
0141 //    Class to store information on each subsystem that is registered      //
0142 /////////////////////////////////////////////////////////////////////////////
0143 
0144 class SubSystem
0145 {
0146  private:
0147   std::string _name;
0148   std::string _prefix;
0149   TList* _canvasList;
0150   SubSystemActionList _actions;
0151   int _initialized;
0152 
0153  public:
0154   SubSystem(const char* name, const char* prefix, int loadLibrary = 1);
0155   virtual ~SubSystem();
0156 
0157   // Public Functions
0158   TList* GetCanvases(int forceReQuery = 0);
0159   void PrintCanvasList();
0160   void ShowCanvases();
0161 
0162   SubSystemAction* AddAction(const char* cmd, const char* description);
0163   SubSystemAction* AddAction(const std::string& cmd, const std::string& description);
0164   SubSystemAction* AddAction(SubSystemAction* action);
0165   void AddDefaultActions();
0166 
0167   void TileCanvases();
0168   void CascadeCanvases();
0169 
0170   // Accessor Methods
0171   const std::string& GetName() { return _name; };
0172   const std::string& GetPrefix() { return _prefix; };
0173   SubSystemActionList* GetActions() { return &_actions; };
0174   int isInitialized() { return _initialized; }
0175   void setInitialized(const int i) { _initialized = i; }
0176 };
0177 
0178 /////////////////////////////////////////////////////////////////////////////
0179 //    Class to store subsystem actions, commands to be added to shutter    //
0180 /////////////////////////////////////////////////////////////////////////////
0181 
0182 class SubSystemAction
0183 {
0184  protected:
0185   bool _running;
0186   int _id;
0187   static int _nextId;
0188   static SubSystemActionMap _map;
0189 
0190   // Member Functions
0191   int NextId() { return _nextId++; };
0192 
0193   SubSystem* _parent;
0194   std::string _cmd;
0195   std::string _description;
0196 
0197  public:
0198   SubSystemAction(SubSystem* parent);
0199   SubSystemAction(SubSystem* parent, const char* description);
0200   SubSystemAction(SubSystem* parent, const char* cmd, const char* description);
0201   virtual ~SubSystemAction();
0202 
0203   virtual int Execute();
0204 
0205   // Accessor Methods
0206   const std::string& GetCmd() { return _cmd; };
0207   const std::string& GetDescription() { return _description; };
0208   int GetId() const { return _id; };
0209   static SubSystemAction* FindById(int id) { return _map[id]; };
0210 };
0211 
0212 class SubSystemActionDraw : public SubSystemAction
0213 {
0214  public:
0215   SubSystemActionDraw(SubSystem* parent);
0216   virtual ~SubSystemActionDraw(){};
0217   int Execute();
0218 };
0219 
0220 class SubSystemActionSavePlot : public SubSystemAction
0221 {
0222  public:
0223   SubSystemActionSavePlot(SubSystem* parent);
0224   virtual ~SubSystemActionSavePlot(){};
0225   int Execute();
0226 };
0227 
0228 class SubSystemActionDrawPS : public SubSystemAction
0229 {
0230  public:
0231   SubSystemActionDrawPS(SubSystem* parent);
0232   virtual ~SubSystemActionDrawPS(){};
0233   int Execute();
0234 };
0235 
0236 class SubSystemActionDrawHtml : public SubSystemAction
0237 {
0238  public:
0239   SubSystemActionDrawHtml(SubSystem* parent);
0240   virtual ~SubSystemActionDrawHtml(){};
0241   int Execute();
0242 };
0243 
0244 class SubSystemActionShowCanvases : public SubSystemAction
0245 {
0246  public:
0247   SubSystemActionShowCanvases(SubSystem* parent);
0248   virtual ~SubSystemActionShowCanvases(){};
0249   int Execute();
0250 };
0251 
0252 class SubSystemActionTileCanvases : public SubSystemAction
0253 {
0254  public:
0255   SubSystemActionTileCanvases(SubSystem* parent);
0256   virtual ~SubSystemActionTileCanvases(){};
0257   int Execute();
0258 };
0259 
0260 class ColorShutterItem : public TGShutterItem
0261 {
0262  public:
0263   ColorShutterItem(const ULong_t bgColor, const TGWindow* p, TGHotString* s,
0264                    Int_t id = -1, UInt_t options = 0);
0265   virtual ~ColorShutterItem(){};
0266 };