source: tags/Mars-V0.10.2/mbase/MStatusDisplay.h

Last change on this file was 7827, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 9.5 KB
Line 
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
20class MLog;
21class MGList;
22class MParContainer;
23
24class TPad;
25class TTimer;
26class TMutex;
27class TCanvas;
28class TVirtualPS;
29
30class TGTab;
31class TGTextView;
32class TGStatusBar;
33class TGTabElement;
34class TGProgressBar;
35class TGHProgressBar;
36class TGCompositeFrame;
37class TRootEmbeddedCanvas;
38
39class MStatusDisplay : public TGMainFrame
40{
41 friend class MStatusArray;
42public:
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 } Status_t;
70
71 enum
72 {
73 // TGMainFrame::kDontCallClose = BIT(14)
74 kExitLoopOnExit = BIT(15),
75 kExitLoopOnClose = BIT(16)
76 };
77
78protected:
79 TString fName; // status display identifier (name) (gROOT->FindObject())
80 TString fTitle; // status display title
81
82 MLog *fLog;
83 MGList *fList;
84 TGCompositeFrame *fUserFrame;
85
86 Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2);
87
88private:
89 TGHProgressBar *fBar;
90 TGTab *fTab;
91 TGLayoutHints *fLayCanvas;
92
93 TTimer fTimer;
94 TMutex *fMutex;
95
96 TGStatusBar *fStatusBar;
97
98 Status_t fStatus;
99
100 Int_t fLogIdx;
101 TTimer fLogTimer;
102 TGTextView *fLogBox;
103
104 FontStruct_t fFont;
105
106 UInt_t fIsLocked;
107
108 TList *fBatch; //!
109
110 void AddMenuBar();
111 void AddUserFrame();
112 void AddTabs();
113 void AddProgressBar();
114 void AddStatusBar();
115 void AddMarsTab();
116 void AddLogTab();
117
118 TCanvas *GetCanvas(TGCompositeFrame *f) const;
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 TRootEmbeddedCanvas *GetEmbeddedCanvas(TGCompositeFrame *cf) const;
148
149 Bool_t SaveAsImage(Int_t num, TString name, TImage::EImageFileTypes type);
150 Int_t SaveAsVGF(Int_t num, TString name, const TString addon, const TString ext);
151
152 void PSToolsRange(TVirtualPS &vps, Float_t w, Float_t h) const;
153 void PSToolsTextNDC(TVirtualPS &vps, Double_t u, Double_t v, const char *string) const;
154 TString PrintDialog(TString &p, TString &c, TString &t, const char *ext=0);
155
156 void GetCanvasRange(Int_t &from, Int_t &to, Int_t num=-1) const;
157
158public:
159 MStatusDisplay(Int_t w=-1, Int_t h=-1, Long_t t=1000);
160 virtual ~MStatusDisplay();
161
162 void SetLogStream(MLog *log, Bool_t enable=kFALSE);
163
164 void StartUpdate(Int_t millisec=-1);
165 void StopUpdate();
166 void SetUpdateTime(Long_t t);
167
168 void SetProgressBarPosition(Float_t p);
169 TGProgressBar *GetBar() const { return (TGProgressBar*)fBar; }
170
171 void SetStatusLine1(const char *txt) { SetStatusLine(txt, 0); }
172 void SetStatusLine2(const char *txt) { SetStatusLine(txt, 1); }
173 void SetStatusLine2(const MParContainer &cont);
174
175 virtual void SetName(const char *name) { fName = name; }
176 virtual void SetTitle(const char *title="") { fTitle = title; }
177 virtual const char *GetName() const { return fName.Data(); }
178 virtual const char *GetTitle() const { return fTitle.Data(); }
179
180 TCanvas &AddTab(const char *name);
181 TGCompositeFrame *AddRawTab(const char *name);
182
183 Bool_t HasCanvas(const TCanvas *c) const;
184 TCanvas *GetCanvas(int i) const;
185 TCanvas *GetCanvas(const TString &name) const;
186 TVirtualPad *GetFullPad(const Int_t canvas, const Int_t pad);
187
188 Int_t Write(Int_t num, const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0) const;
189
190 Int_t Read(const char *name, const char *tab);
191 Int_t Read(const char *name="MStatusDisplay")
192 {
193 return Read(name, 0);
194 }
195 Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0)
196 {
197 return Write(-1, name, option, bufsize);
198 }
199 Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0) const
200 {
201 return Write(-1, name, option, bufsize);
202 }
203
204 Bool_t CdCanvas(const TString &name);
205 void Update() { HandleTimer(&fTimer); HandleTimer(&fLogTimer); }
206
207 void DrawClonePad(const char *tab, TCanvas &oldc)
208 {
209 DrawClonePad(AddTab(tab), oldc);
210 }
211
212 void SetNoContextMenu(Bool_t flag=kTRUE);
213
214 Int_t SaveAsPS(TString name="", const TString addon="") { return SaveAsVGF(-1, name, addon, "ps"); }
215 Int_t SaveAsPDF(TString name="", const TString addon="") { return SaveAsVGF(-1, name, addon, "pdf"); }
216 Int_t SaveAsSVG(TString name="", const TString addon="") { return SaveAsVGF(-1, name, addon, "svg"); }
217 Bool_t SaveAsPNG(TString name="") { return SaveAsPNG(-1, name); }
218 Bool_t SaveAsGIF(TString name="") { return SaveAsGIF(-1, name); }
219 Bool_t SaveAsXPM(TString name="") { return SaveAsXPM(-1, name); }
220 Bool_t SaveAsJPG(TString name="") { return SaveAsJPG(-1, name); }
221 //Bool_t SaveAsTIFF(TString name="") { return SaveAsTIFF(-1, name); }
222 //Bool_t SaveAsXCF(TString name="") { return SaveAsXCF(-1, name); }
223 Bool_t SaveAsBMP(TString name="") { return SaveAsBMP(-1, name); }
224 Bool_t SaveAsXML(TString name="") { return SaveAsXML(-1, name); }
225 Bool_t SaveAsC(TString name="") { return SaveAsC(-1, name); }
226 Int_t SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); }
227 Int_t SaveAs(TString name) { return SaveAs(-1, name); }
228 Int_t PrintPS() { return PrintPS(-1); }
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 ClassDef(MStatusDisplay, 0) // Window for a status display
275};
276
277#endif
Note: See TracBrowser for help on using the repository browser.