1 | #ifndef MARS_MStatusDisplay
|
---|
2 | #define MARS_MStatusDisplay
|
---|
3 |
|
---|
4 | #ifndef MARS_MAGIC
|
---|
5 | #include "MAGIC.h"
|
---|
6 | #endif
|
---|
7 |
|
---|
8 | #ifndef ROOT_TGFrame
|
---|
9 | #include <TGFrame.h>
|
---|
10 | #endif
|
---|
11 |
|
---|
12 | #ifndef ROOT_TTimer
|
---|
13 | #include <TTimer.h>
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | #ifndef ROOT_TImage
|
---|
17 | #include <TImage.h>
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | class MLog;
|
---|
21 | class MGList;
|
---|
22 | class MStatusArray;
|
---|
23 | class MParContainer;
|
---|
24 |
|
---|
25 | class TPad;
|
---|
26 | class TTimer;
|
---|
27 | class TMutex;
|
---|
28 | class TCanvas;
|
---|
29 | class TVirtualPS;
|
---|
30 |
|
---|
31 | class TGTab;
|
---|
32 | class TGTextView;
|
---|
33 | class TGStatusBar;
|
---|
34 | class TGTabElement;
|
---|
35 | class TGProgressBar;
|
---|
36 | class TGHProgressBar;
|
---|
37 | class TGCompositeFrame;
|
---|
38 | class TRootEmbeddedCanvas;
|
---|
39 |
|
---|
40 | class MStatusDisplay : public TGMainFrame
|
---|
41 | {
|
---|
42 | friend class MStatusArray;
|
---|
43 | public:
|
---|
44 | typedef enum {
|
---|
45 | // kFile
|
---|
46 | kFileBrowser, kFileCanvas, kFileTab, kFileOpen, kFileSave, kFileSaveAs,
|
---|
47 | kFileSaveAsPS, kFileSaveAsPDF, kFileSaveAsSVG, kFileSaveAsRoot,
|
---|
48 | kFileSaveAsPNG, kFileSaveAsGIF, kFileSaveAsJPG, kFileSaveAsXPM,
|
---|
49 | kFileSaveAsBMP, kFileSaveAsCSV, kFileSaveAsTIFF,
|
---|
50 | kFileSaveAsXML, kFileSaveAsC, kFilePrint, kFilePrinterName,
|
---|
51 | kFileClose, kFileExit, kFileReset,
|
---|
52 | // kLoop
|
---|
53 | kLoopNone, kLoopStop,
|
---|
54 | // kTab
|
---|
55 | kTabSave, kTabSaveAs, kTabSaveAsPS, kTabSaveAsPDF, kTabSaveAsSVG,
|
---|
56 | kTabSaveAsRoot, kTabSaveAsPNG, kTabSaveAsGIF, kTabSaveAsJPG,
|
---|
57 | kTabSaveAsXPM, kTabSaveAsBMP, kTabSaveAsCSV, kTabSaveAsTIFF,
|
---|
58 | kTabSaveAsXML, kTabSaveAsC,
|
---|
59 | kTabPrint, kTabNext, kTabPrevious, kTabRemove,
|
---|
60 | // kSize
|
---|
61 | kSize640, kSize768, kSize800, kSize960, kSize1024, kSize1152,
|
---|
62 | kSize1280, kSize1400, kSize1600, kSizeOptimum,
|
---|
63 | // kLog
|
---|
64 | kLogCopy, kLogClear, kLogSelect, kLogFind, kLogSave, kLogAppend,
|
---|
65 | kLogPrint,
|
---|
66 | // kPic
|
---|
67 | kPicMagic, kPicMars,
|
---|
68 | // kGui
|
---|
69 | kSearch, kTabs,
|
---|
70 | // kLastElement
|
---|
71 | kLastElement
|
---|
72 | } Status_t;
|
---|
73 |
|
---|
74 | enum
|
---|
75 | {
|
---|
76 | // TGMainFrame::kDontCallClose = BIT(14)
|
---|
77 | kExitLoopOnExit = BIT(15),
|
---|
78 | kExitLoopOnClose = BIT(16)
|
---|
79 | };
|
---|
80 |
|
---|
81 | protected:
|
---|
82 | TString fName; // status display identifier (name) (gROOT->FindObject())
|
---|
83 | TString fTitle; // status display title
|
---|
84 |
|
---|
85 | MLog *fLog;
|
---|
86 | MGList *fList;
|
---|
87 | TGCompositeFrame *fUserFrame;
|
---|
88 |
|
---|
89 | Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2);
|
---|
90 |
|
---|
91 | private:
|
---|
92 | TGHProgressBar *fBar;
|
---|
93 | TGTab *fTab;
|
---|
94 | TGLayoutHints *fLayCanvas;
|
---|
95 |
|
---|
96 | TTimer fTimer;
|
---|
97 | TMutex *fMutex;
|
---|
98 |
|
---|
99 | TGStatusBar *fStatusBar;
|
---|
100 |
|
---|
101 | Status_t fStatus;
|
---|
102 |
|
---|
103 | Int_t fLogIdx;
|
---|
104 | TTimer fLogTimer;
|
---|
105 | TGTextView *fLogBox;
|
---|
106 |
|
---|
107 | FontStruct_t fFont;
|
---|
108 |
|
---|
109 | UInt_t fIsLocked;
|
---|
110 |
|
---|
111 | TList *fBatch; //!
|
---|
112 |
|
---|
113 | // GUI setup
|
---|
114 | void AddMenuBar();
|
---|
115 | void AddUserFrame();
|
---|
116 | void AddTabs();
|
---|
117 | void AddProgressBar();
|
---|
118 | void AddStatusBar();
|
---|
119 | void AddMarsTab();
|
---|
120 | void AddLogTab();
|
---|
121 |
|
---|
122 | // GUI event handling
|
---|
123 | Bool_t ProcessMessageCommandMenu(Long_t mp1);
|
---|
124 | Bool_t ProcessMessageCommand(Long_t submsg, Long_t mp1, Long_t mp2);
|
---|
125 | Bool_t ProcessMessageTextview(Long_t submsg, Long_t mp1, Long_t mp2);
|
---|
126 | Bool_t ProcessMessageUser(Long_t submsg, Long_t mp1, Long_t mp2);
|
---|
127 | Bool_t Close();
|
---|
128 | void CloseWindow();
|
---|
129 | Bool_t HandleConfigureNotify(Event_t *);
|
---|
130 |
|
---|
131 | // Access to the tabs
|
---|
132 | TGCompositeFrame *GetTabContainer(const char *name) const;
|
---|
133 | TGTabElement *GetTabTab(const char *name) const;
|
---|
134 |
|
---|
135 | // Display update
|
---|
136 | Bool_t HandleTimer(TTimer *timer=NULL);
|
---|
137 | void UpdateTab(TGCompositeFrame *f);
|
---|
138 | void UpdateMemory() const;
|
---|
139 |
|
---|
140 | // Display helper functions
|
---|
141 | void RemoveTab(int i);
|
---|
142 | void SetStatusLine(const char *txt, Int_t idx);
|
---|
143 |
|
---|
144 | // Drawing helper
|
---|
145 | void DrawClonePad(TCanvas &newc, TCanvas &oldc) const;
|
---|
146 | void GetCanvasRange(Int_t &from, Int_t &to, Int_t num=-1) const;
|
---|
147 |
|
---|
148 | // MStatusArray interface
|
---|
149 | Bool_t Display(const TObjArray &list, const char *tab=0);
|
---|
150 | void FillArray(MStatusArray &list, Int_t num=-1) const;
|
---|
151 |
|
---|
152 | // I/O helper function
|
---|
153 | const TString &AddExtension(TString &name, const TString &ext, Int_t num=-1) const;
|
---|
154 |
|
---|
155 | TCanvas *InitWriteTab(Int_t num, TString &name);
|
---|
156 | TCanvas *InitWriteTab(Int_t num) { TString s; return InitWriteTab(num, s); }
|
---|
157 | Int_t InitWriteDisplay(Int_t num, TString &name, const TString &ext);
|
---|
158 |
|
---|
159 | void UpdatePSHeader(const TString &name) const;
|
---|
160 |
|
---|
161 | Bool_t SaveAsImage(Int_t num, TString name, TImage::EImageFileTypes type);
|
---|
162 | Int_t SaveAsVGF(Int_t num, TString name, const TString addon, const TString ext);
|
---|
163 |
|
---|
164 | void PSToolsRange(TVirtualPS &vps, Float_t w, Float_t h) const;
|
---|
165 | void PSToolsTextNDC(TVirtualPS &vps, Double_t u, Double_t v, const char *string) const;
|
---|
166 | TString PrintDialog(TString &p, TString &c, TString &t, const char *ext=0);
|
---|
167 |
|
---|
168 | public:
|
---|
169 | MStatusDisplay(Int_t w=-1, Int_t h=-1, Long_t t=1000);
|
---|
170 | virtual ~MStatusDisplay();
|
---|
171 |
|
---|
172 | // Name and title handling
|
---|
173 | virtual void SetName(const char *name) { fName = name; }
|
---|
174 | virtual void SetTitle(const char *title="") { SetTitle(title, kTRUE); }
|
---|
175 | virtual const char *GetName() const { return fName.Data(); }
|
---|
176 | virtual const char *GetTitle() const { return fTitle.Data(); }
|
---|
177 |
|
---|
178 | virtual void SetTitle(const char *title, Bool_t replace)
|
---|
179 | {
|
---|
180 | if (fTitle.IsNull() || replace) fTitle = title;
|
---|
181 | }
|
---|
182 |
|
---|
183 | // Getter / display access
|
---|
184 | Bool_t HasCanvas(const TCanvas *c) const;
|
---|
185 | TCanvas *GetCanvas(int i) const;
|
---|
186 | TCanvas *GetCanvas(const TString &name) const;
|
---|
187 | TVirtualPad *GetFullPad(const Int_t canvas, const Int_t pad);
|
---|
188 |
|
---|
189 | Bool_t CdCanvas(const TString &name);
|
---|
190 | Bool_t CheckTabForCanvas(int num) const;
|
---|
191 |
|
---|
192 | TObject *FindObjectInCanvas(const char *obj, const char *base, const char *canv) const;
|
---|
193 | TObject *FindObjectInCanvas(const char *obj, const char *canv) const { return FindObjectInCanvas(obj, obj, canv); }
|
---|
194 | TObject *FindObject(const char *obj, const char *base) const { return FindObjectInCanvas(obj, base, 0); }
|
---|
195 | TObject *FindObject(const char *obj) const { return FindObjectInCanvas(obj, obj, 0); }
|
---|
196 | TObject *FindObject(const TObject *) const { return 0; }
|
---|
197 |
|
---|
198 | void PrintContent(Option_t *o="") const;
|
---|
199 |
|
---|
200 | // Display Manipulation
|
---|
201 | TCanvas &AddTab(const char *name, const char *title=0);
|
---|
202 | TGCompositeFrame *AddRawTab(const char *name);
|
---|
203 |
|
---|
204 | void SetProgressBarPosition(Float_t p, Bool_t upd=kFALSE);
|
---|
205 | TGProgressBar *GetBar() const { return (TGProgressBar*)fBar; }
|
---|
206 |
|
---|
207 | void SetStatusLine1(const char *txt) { SetStatusLine(txt, 0); }
|
---|
208 | void SetStatusLine2(const char *txt) { SetStatusLine(txt, 1); }
|
---|
209 | void SetStatusLine2(const MParContainer &cont);
|
---|
210 |
|
---|
211 | void Reset();
|
---|
212 | void SetNoContextMenu(Bool_t flag=kTRUE);
|
---|
213 |
|
---|
214 | // Update handling
|
---|
215 | void StartUpdate(Int_t millisec=-1);
|
---|
216 | void StopUpdate();
|
---|
217 | void SetUpdateTime(Long_t t);
|
---|
218 |
|
---|
219 | void Update() { HandleTimer(&fTimer); HandleTimer(&fLogTimer); }
|
---|
220 |
|
---|
221 | // Log stream interface
|
---|
222 | void SetLogStream(MLog *log, Bool_t enable=kFALSE);
|
---|
223 |
|
---|
224 | // Size options
|
---|
225 | void SetCanvasWidth(UInt_t w);
|
---|
226 | void SetCanvasHeight(UInt_t h);
|
---|
227 |
|
---|
228 | void SetDisplayWidth(UInt_t w);
|
---|
229 | void SetDisplayHeight(UInt_t h);
|
---|
230 |
|
---|
231 | void SetOptimumSize();
|
---|
232 | void SetDisplaySize(UInt_t w, UInt_t h);
|
---|
233 |
|
---|
234 | // Graphics output
|
---|
235 | Int_t SaveAsPS(TString name="", const TString addon="") { return SaveAsVGF(-1, name, addon, "ps"); }
|
---|
236 | Int_t SaveAsPDF(TString name="", const TString addon="") { return SaveAsVGF(-1, name, addon, "pdf"); }
|
---|
237 | Int_t SaveAsSVG(TString name="", const TString addon="") { return SaveAsVGF(-1, name, addon, "svg"); }
|
---|
238 | Bool_t SaveAsPNG(TString name="") { return SaveAsPNG(-1, name); }
|
---|
239 | Bool_t SaveAsGIF(TString name="") { return SaveAsGIF(-1, name); }
|
---|
240 | Bool_t SaveAsXPM(TString name="") { return SaveAsXPM(-1, name); }
|
---|
241 | Bool_t SaveAsJPG(TString name="") { return SaveAsJPG(-1, name); }
|
---|
242 | Bool_t SaveAsTIFF(TString name="") { return SaveAsTIFF(-1, name); }
|
---|
243 | Bool_t SaveAsBMP(TString name="") { return SaveAsBMP(-1, name); }
|
---|
244 | Bool_t SaveAsXML(TString name="") { return SaveAsXML(-1, name); }
|
---|
245 | Bool_t SaveAsC(TString name="") { return SaveAsC(-1, name); }
|
---|
246 | Int_t SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); }
|
---|
247 | Int_t SaveAs(TString name) { return SaveAs(-1, name); }
|
---|
248 |
|
---|
249 | Bool_t SaveAsCSV(TString name="", Char_t delim='\t') { return SaveAsCSV(-1, name, delim); }
|
---|
250 | Int_t PrintPS() { return PrintPS(-1); }
|
---|
251 |
|
---|
252 | void SaveAs(const char *c, const Option_t *o) const;
|
---|
253 |
|
---|
254 | Int_t SaveAsPS(Int_t num, TString name="", const TString addon="") { return SaveAsVGF(num, name, addon, "ps"); }
|
---|
255 | Int_t SaveAsPDF(Int_t num, TString name="", const TString addon="") { return SaveAsVGF(num, name, addon, "pdf"); }
|
---|
256 | Int_t SaveAsSVG(Int_t num, TString name="", const TString addon="") { return SaveAsVGF(num, name, addon, "svg"); }
|
---|
257 | Bool_t SaveAsPNG(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kPng); }
|
---|
258 | Bool_t SaveAsGIF(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kGif); }
|
---|
259 | Bool_t SaveAsXPM(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kXpm); }
|
---|
260 | Bool_t SaveAsJPG(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kJpeg); }
|
---|
261 | Bool_t SaveAsTIFF(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kTiff); }
|
---|
262 | Bool_t SaveAsBMP(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kBmp); }
|
---|
263 | Bool_t SaveAsXML(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kXml); }
|
---|
264 | Bool_t SaveAsC(Int_t num, TString name="");
|
---|
265 | Int_t SaveAsRoot(Int_t num, TString name="");
|
---|
266 | Int_t SaveAs(Int_t num, TString name);
|
---|
267 |
|
---|
268 | Bool_t SaveAsCSV(Int_t num, TString name="", Char_t delim='\t');
|
---|
269 | Int_t PrintPS(Int_t num, const char *p=0, const char *cmd=0, const char *tmp=0);
|
---|
270 | Bool_t PrintLog(const char *p=0, const char *c=0);
|
---|
271 |
|
---|
272 | Bool_t SaveLogAsPS(const char *name) const;
|
---|
273 |
|
---|
274 | // I/O
|
---|
275 | Int_t SaveAs(Int_t num=-1);
|
---|
276 | Int_t Open(TString fname, const char *name="MStatusDisplay");
|
---|
277 | Int_t Open();
|
---|
278 |
|
---|
279 | // Root I/O
|
---|
280 | Int_t Write(Int_t num, const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0) const;
|
---|
281 |
|
---|
282 | Int_t Read(const char *name, const char *tab);
|
---|
283 | Int_t Read(const char *name="MStatusDisplay") { return Read(name, 0); }
|
---|
284 | Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0) { return Write(-1, name, option, bufsize); }
|
---|
285 | Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0) const { return Write(-1, name, option, bufsize); }
|
---|
286 |
|
---|
287 | // Eventloop interface
|
---|
288 | Status_t CheckStatus() const { return fStatus; }
|
---|
289 | void ClearStatus() { fStatus = kLoopNone; }
|
---|
290 |
|
---|
291 | void Lock() { fIsLocked++; }
|
---|
292 | void UnLock() { if (fIsLocked>0) fIsLocked--; }
|
---|
293 |
|
---|
294 | // GUI event handling
|
---|
295 | void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
|
---|
296 | Bool_t HandleEvent(Event_t *event);
|
---|
297 |
|
---|
298 | // Public helper functions
|
---|
299 | static TRootEmbeddedCanvas *GetEmbeddedCanvas(TGCompositeFrame &cf);
|
---|
300 | static TCanvas *GetCanvas(TGCompositeFrame &f);
|
---|
301 |
|
---|
302 | ClassDef(MStatusDisplay, 0) // Window for a status display
|
---|
303 | };
|
---|
304 |
|
---|
305 | #endif
|
---|