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