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