Roody.h

Go to the documentation of this file.
00001 //
00002 // Roody.h
00003 //
00004 // $Id$
00005 //
00006 
00007 #ifndef Roody_H
00008 #define Roody_H
00009 
00010 #include <cstdlib>
00011 #include <iostream>
00012 #include <string>
00013 #include <vector>
00014 #include <map>
00015 #include <assert.h>
00016 
00017 class THbookFile;
00018 class TPeakFindPanel;
00019 class TGListTreeItem;
00020 class MTGListTree;
00021 class RoodyXML;
00022 class TPad;
00023 class TGPopupMenu;
00024 class TGStatusBar;
00025 class TGTextButton;
00026 class TCanvas;
00027 class TVirtualPad;
00028 
00029 typedef struct mxml_struct *PMXML_NODE;
00030 class CanvasLimits;
00031 
00032 #include "TGFrame.h"
00033 #include "DataSourceBase.h"
00034 
00035 struct PadObject
00036 {
00037   int          fPadNumber;
00038   TObject*     fObject;
00039   ObjectPath   fSource;
00040   std::string  fDrawOption;
00041 
00042   PadObject() { assert(!"PadObject::PadObject() constructor should not be called directly!"); };
00043   PadObject(int padnum, TObject*obj, const ObjectPath* src, const char* drawOption)
00044   {
00045     fPadNumber  = padnum;
00046     fObject     = obj;
00047     fSource     = *src;
00048     fDrawOption = drawOption;
00049   };
00050   ~PadObject()
00051   {
00052     fObject = NULL;
00053   };
00054 };
00055 
00056 struct PadObjectVec : std::vector<PadObject>
00057 {
00058 };
00059 
00060 //#include "RQ_OBJECT.h"
00061 //
00062 // Only required if a class is constructed which doesn't inherit from
00063 // a class which has the line RQ_OBJECT(class name)
00064 //
00065 class Roody : public TGMainFrame
00066 {
00067   //  RQ_OBJECT("Roody")
00068 
00069 public:
00070   Roody(const TGWindow* p = NULL,UInt_t w = 800,UInt_t h = 800);
00071   virtual ~Roody();
00072 
00073   void RestoreFile(const char* xmlfilename);
00074   bool OpenFile(const char* filename);
00075   void ConnectServer(const char* server, bool complain = true);
00076   void ConnectNetDirectory(const char* server, bool complain = true);
00077 
00078   TObject* GetObject(const ObjectPath& src);
00079   TObject* RereadObject(const ObjectPath& src);
00080 
00081   Bool_t ProcessMessage( Long_t, Long_t, Long_t );
00082   void CloseWindow();
00083 
00084   void PopupPlot(int, int); // menu for each normal item
00085   void PopupPlotFolder(int, int); // menu for each folder
00086   void PopupPlotSource(int, int); // menu for each source
00087   void PopupTopGroup( int, int ); // top level group menu
00088   void PopupGroup( int, int ); // menu for each group
00089   TGListTreeItem* PopupNewGroup(int x, int y); // make new group
00090 
00091   void PeakFind();
00092   void SelectPad( Int_t, Int_t, Int_t, TObject* );
00093   void AxisLimits();
00094   void SetCut( TObject * );
00095   void ZoomOption();
00096 
00097   void RefreshAll();
00098 
00099   void RedrawCanvas(TVirtualPad* pad = NULL, bool reread = false);
00100   void AddObjectToVec(PadObjectVec* padvec, TVirtualPad* pad, const ObjectPath* src, TObject* obj, const char* drawOpt);
00101   void AddPadToVec(PadObjectVec* padvec, TVirtualPad* pad, bool reread = false);
00102 
00103   ClassDef(Roody,0); // ROOT implementation of ONLINE/OFFLINE GUI
00104 
00105 protected:
00106   enum ECommandMenuEntry
00107   {
00108       M_NEW_CANVAS,
00109       M_REDRAW_CANVAS,
00110 
00111       M_FILE_OPEN,
00112       M_FILE_ONLINE,
00113       M_FILE_NetDirectory,
00114       M_FILE_SAVE_DEFAULT,
00115       M_FILE_SAVE,
00116       M_FILE_RESTORE,
00117       M_FILE_EXIT,
00118 
00119       M_REFRESH_OFF,
00120       M_REFRESH_NOW,
00121       M_REFRESH_1SEC,
00122       M_REFRESH_3SEC,
00123       M_REFRESH_5SEC,
00124       M_REFRESH_10SEC,
00125       M_REFRESH_DIALOG,
00126 
00127       M_REOPEN_BUTTON,
00128       M_REFRESH_BUTTON,
00129 
00130       M_ZONES_11,
00131       M_ZONES_12,
00132       M_ZONES_13,
00133       M_ZONES_21,
00134       M_ZONES_22,
00135       M_ZONES_33,
00136       M_ZONES_44,
00137       M_ZONES_USER,
00138       M_ZONES_DIALOG,
00139 
00140       M_PLOT_NEW,
00141       M_PLOT_SAME,
00142       M_PLOT_REPLACE,
00143       M_PLOT_NEXT,
00144 
00145       C_PLOT_FOLDER,
00146       C_RESET_FOLDER,
00147 
00148       C_PLOT_NEW,
00149       C_PLOT_SAME,
00150       C_PLOT_REPLACE,
00151       C_PLOT_NEXT,
00152       C_RESET_OBJECT,
00153 
00154       C_REOPEN_SOURCE,
00155       C_CLOSE_SOURCE,
00156 
00157       C_NEW_GROUP,
00158       C_DELETE_GROUP,
00159       C_DRAW_GROUP,
00160       C_ADD_TO_GROUP,
00161       C_RESET_GROUP,
00162 
00163       M_RESET_ALL,
00164 
00165       M_HELP_ABOUT,
00166       M_HELP_CONTENTS,
00167       
00168       M_CURRENT_PAD,
00169       M_NEXT_PAD,
00170       M_NEW_PAD
00171   };
00172 
00173   enum EDrawDestination
00174   {
00175       D_PLOT_DEFAULT = -1,
00176       D_PLOT_NEW     = M_PLOT_NEW,
00177       D_PLOT_SAME    = M_PLOT_SAME,
00178       D_PLOT_REPLACE = M_PLOT_REPLACE,
00179       D_PLOT_NEXT    = M_PLOT_NEXT
00180   };
00181 
00182   typedef std::vector<TGListTreeItem*> ItemVec;
00183   
00184   MTGListTree    *fContents;
00185   TGListTreeItem *fTreeItemOnline;
00186   TGListTreeItem *fTreeItemFiles;
00187   TGListTreeItem *fTreeItemGroups;
00188 
00189 private:
00190   TGPopupMenu *fMenuRefresh;
00191   TGPopupMenu *fMenuZones;
00192   TGPopupMenu *fMenuPlot;
00193   TGPopupMenu *fPopupMenu;
00194   TGStatusBar *fStatusBar;
00195 
00196   static TPeakFindPanel *fgPeakFindPanel;
00197 
00198   EDrawDestination fDefaultDrawDestination; // where to Draw() things, value is one of D_PLOT_XXX
00199 
00200   int  fUpdateTimerSec;  // refresh time in sec, 0 means no refresh
00201   bool fUpdatePause;
00202 
00203   int fZoneColumns;   // default zone setting: columns
00204   int fZoneRows;      // default zone setting: rows
00205 
00206   std::map<TVirtualPad*,int> fCanvasColumns;
00207   std::map<TVirtualPad*,int> fCanvasRows;
00208 
00209   std::vector<std::string> fRootFiles;
00210   std::vector<std::string> fHbookFiles;
00211   std::vector<std::string> fOnlineFiles;
00212 
00213   TTimer *fUpdateTimer; // used for updating online histograms
00214 
00215   ItemVec fGroupFolders;
00216 
00217   TGPopupMenu *fAddToGroupPopup;
00218   int fXSave, fYSave;
00219 
00220   Int_t fCanvasCount;
00221 
00222   std::map<int,CanvasLimits*> fCanvasLimits;
00223 
00224   TCanvas *fZoomCanvas;
00225 
00226   TGTextButton *fReopenButton;
00227   TGTextButton *fRefreshButton;
00228 
00229   void LayoutGUI();
00230   void LayoutMenuBar();
00231   void OpenFileDialog();
00232   bool OpenRootFile(const char* filename);
00233   bool OpenHbookFile(const char* filename);
00234 
00235   bool OpenNetDirectory(const char* dest);
00236   bool OpenXmlServer(const char* url);
00237 
00238   void AddDataSource(DataSourceBase* source, MTGListTree* tree, TGListTreeItem* branch, bool reopen=false);
00239 
00240   void AddPeakFind();
00241   void AddAxisLimits();
00242   void AddSetCut();
00243   void AddZoomOption();
00244 
00245   void SetupZones(int columns, int rows);
00246   void SetDestination(EDrawDestination newdest);
00247   void PlotItems(const ItemVec* items, EDrawDestination dest);
00248   void UpdateObjectClass(TGListTreeItem *item, TObject* obj);
00249   void DrawItem(TGListTreeItem *item, EDrawDestination dest = D_PLOT_DEFAULT);
00250   void DrawItemOnPad(TGListTreeItem *item, TVirtualPad* dest, bool replace);
00251   void DrawItemsOnNewCanvas(const char* title, const ItemVec* items);
00252   std::string GetZoneSetting(int columns,int rows);
00253 
00254   void StartUpdateTimer();
00255 
00256   void SetRefreshRate(int newrefresh);
00257 
00258   void OpenRefreshDialog();
00259   void OpenZoneDialog();
00260   void UncheckAllZones();
00261 
00262   void CloseSource(TGListTreeItem* item);
00263   void ReopenSource(TGListTreeItem* item);
00264 
00265   void GetFolderItems(ItemVec* items, TGListTreeItem* item);
00266 
00267   TGListTreeItem* MakeNewGroup(const char* groupname);
00268   void AddToGroup(TGListTreeItem* groupItem, ItemVec* items);
00269   void DeleteGroup(TGListTreeItem* groupItem);
00270   void DrawGroup(TGListTreeItem* groupItem);
00271   void AddHistogramToGroup(TGListTreeItem *groupItem, const char* name, TGListTreeItem *origItem );
00272 
00273   void OpenRestoreDialog();
00274   void OpenSaveDialog();
00275   void SaveFile( char const * );
00276   void SaveFilePadContents(RoodyXML& xml, std::ofstream& output, std::string space, const PadObjectVec& contents);
00277 
00278   std::string GetRunNumber( char const * );
00279 
00280   TCanvas* MakeNewCanvas(const char* title, int columns, int rows, int topx=0, int topy=0, int width=0, int height=0);
00281 
00282   void SetZonesUser();
00283   void SetupZonesMenu();
00284 
00285   void ResetAll();
00286   void ResetMultiple(const ItemVec* items);
00287   void ResetItem(TGListTreeItem* item);
00288 
00289   TObject* ApplyCanvasLimits(const CanvasLimits* limits, const ObjectPath* src, TObject *h);
00290 
00291   void RestoreObjects(RoodyXML *xml, TVirtualPad *pad, PMXML_NODE parent);
00292 };
00293 
00294 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends

Generated on 15 Nov 2016 for Roody by  doxygen 1.6.1