source: trunk/MagicSoft/Mars/mbase/MStatusDisplay.h@ 7458

Last change on this file since 7458 was 7458, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 9.0 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 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 kTabSaveAsC,
58 kTabPrint, kTabNext, kTabPrevious, kTabRemove,
59 // kSize
60 kSize640, kSize768, kSize800, kSize960, kSize1024, kSize1152,
61 kSize1280, kSize1400, kSize1600,
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
157public:
158 MStatusDisplay(Long_t t=1000);
159 virtual ~MStatusDisplay();
160
161 void SetLogStream(MLog *log, Bool_t enable=kFALSE);
162
163 void StartUpdate(Int_t millisec=-1);
164 void StopUpdate();
165 void SetUpdateTime(Long_t t);
166
167 void SetProgressBarPosition(Float_t p);
168 TGProgressBar *GetBar() const { return (TGProgressBar*)fBar; }
169
170 void SetStatusLine1(const char *txt) { SetStatusLine(txt, 0); }
171 void SetStatusLine2(const char *txt) { SetStatusLine(txt, 1); }
172 void SetStatusLine2(const MParContainer &cont);
173
174 virtual void SetName(const char *name) { fName = name; }
175 virtual void SetTitle(const char *title="") { fTitle = title; }
176 virtual const char *GetName() const { return fName.Data(); }
177 virtual const char *GetTitle() const { return fTitle.Data(); }
178
179 TCanvas &AddTab(const char *name);
180 TGCompositeFrame *AddRawTab(const char *name);
181
182 Bool_t HasCanvas(const TCanvas *c) const;
183 TCanvas *GetCanvas(int i) const;
184 TCanvas *GetCanvas(const TString &name) const;
185 TVirtualPad *GetFullPad(const Int_t canvas, const Int_t pad);
186
187 Int_t Write(Int_t num, const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0) const;
188
189 Int_t Read(const char *name, const char *tab);
190 Int_t Read(const char *name="MStatusDisplay")
191 {
192 return Read(name, 0);
193 }
194 Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0)
195 {
196 return Write(-1, name, option, bufsize);
197 }
198 Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0) const
199 {
200 return Write(-1, name, option, bufsize);
201 }
202
203 Bool_t CdCanvas(const TString &name);
204 void Update() { HandleTimer(&fTimer); HandleTimer(&fLogTimer); }
205
206 void DrawClonePad(const char *tab, TCanvas &oldc)
207 {
208 DrawClonePad(AddTab(tab), oldc);
209 }
210
211 void SetNoContextMenu(Bool_t flag=kTRUE);
212
213 Int_t SaveAsPS(TString name="", const TString addon="") { return SaveAsVGF(-1, name, addon, "ps"); }
214 Int_t SaveAsPDF(TString name="", const TString addon="") { return SaveAsVGF(-1, name, addon, "pdf"); }
215 Int_t SaveAsSVG(TString name="", const TString addon="") { return SaveAsVGF(-1, name, addon, "svg"); }
216 Bool_t SaveAsPNG(TString name="") { return SaveAsPNG(-1, name); }
217 Bool_t SaveAsGIF(TString name="") { return SaveAsGIF(-1, name); }
218 Bool_t SaveAsXPM(TString name="") { return SaveAsXPM(-1, name); }
219 Bool_t SaveAsJPG(TString name="") { return SaveAsJPG(-1, name); }
220 //Bool_t SaveAsTIFF(TString name="") { return SaveAsTIFF(-1, name); }
221 //Bool_t SaveAsXCF(TString name="") { return SaveAsXCF(-1, name); }
222 //Bool_t SaveAsBMP(TString name="") { return SaveAsBMP(-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 Int_t SaveAsPS(Int_t num, TString name="", const TString addon="") { return SaveAsVGF(num, name, addon, "ps"); }
229 Int_t SaveAsPDF(Int_t num, TString name="", const TString addon="") { return SaveAsVGF(num, name, addon, "pdf"); }
230 Int_t SaveAsSVG(Int_t num, TString name="", const TString addon="") { return SaveAsVGF(num, name, addon, "svg"); }
231 Bool_t SaveAsPNG(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kPng); }
232 Bool_t SaveAsGIF(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kGif); }
233 Bool_t SaveAsXPM(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kXpm); }
234 Bool_t SaveAsJPG(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kJpeg); }
235 //Bool_t SaveAsTIFF(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kTiff); }
236 //Bool_t SaveAsXCF(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kXcf); }
237 //Bool_t SaveAsBMP(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kBmp); }
238 Bool_t SaveAsC(Int_t num, TString name="");
239 Int_t SaveAsRoot(Int_t num, TString name="");
240 Int_t SaveAs(Int_t num, TString name);
241 Int_t PrintPS(Int_t num, const char *p=0, const char *cmd=0, const char *tmp=0);
242 Bool_t PrintLog(const char *p=0, const char *c=0);
243 Bool_t SaveLogAsPS(const char *name) const;
244
245 Int_t SaveAs(Int_t num=-1);
246 Int_t Open(TString fname, const char *name="MStatusDisplay");
247 Int_t Open();
248
249 Status_t CheckStatus() const { return fStatus; }
250 void ClearStatus() { fStatus = kLoopNone; }
251
252 void Lock() { fIsLocked++; }
253 void UnLock() { if (fIsLocked>0) fIsLocked--; }
254
255 void Reset();
256
257 Bool_t CheckTabForCanvas(int num) const;
258
259 void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
260
261 ClassDef(MStatusDisplay, 0) // Window for a status display
262};
263
264#endif
Note: See TracBrowser for help on using the repository browser.