4#include <TGFileDialog.h>
31 fTab->Resize(
fTab->GetDefaultSize());
32 fMain->AddFrame(
fTab,
new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
33 fTab->MoveResize(2,2,300,300);
56 TGNumberFormat::kNEANonNegative,
57 TGNumberFormat::kNELLimitMinMax,
62 if(updatingBasedSeconds){
63 TGLabel *labelEv =
new TGLabel(
fHframe,
"Refresh each Xth second");
64 fHframe->AddFrame(labelEv,
new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
66 TGLabel *labelEv =
new TGLabel(
fHframe,
"Plot every Xth events");
67 fHframe->AddFrame(labelEv,
new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
80 fPauseButton->Connect(
"Clicked()",
"TMainDisplayWindow",
this,
"PauseResumeButtonAction()");
95 fSavePadButton->Connect(
"Clicked()",
"TMainDisplayWindow",
this,
"SavePadButtonAction()");
99 fSaveCanvasButton->Connect(
"Clicked()",
"TMainDisplayWindow",
this,
"SaveCanvasButtonAction()");
103 fOpenNewTBrowser->Connect(
"Clicked()",
"TMainDisplayWindow",
this,
"NewTBrowserButtonAction()");
116 fFreeRunningButton->Connect(
"Clicked()",
"TMainDisplayWindow",
this,
"FreeRunningButtonAction()");
124 fMain->AddFrame(
fHframe,
new TGLayoutHints(kLHintsNormal,2,2,2,2));
135 for(
int itab = 0; itab <
fTab->GetNumberOfTabs() ; itab++){
137 TGCompositeFrame* frame =
fTab->GetTabContainer(itab);
143 TList* mylist = frame->GetList();
146 while (TObject *obj = next()){
149 TGFrameElement *frame_element =
dynamic_cast<TGFrameElement*
>(obj);
152 frame_element->fFrame->Resize((frame_element->fFrame->GetDefaultSize().fWidth)
153 *(
fMain->GetSize().fWidth)/(
fMain->GetDefaultSize().fWidth),
154 (frame_element->fFrame->GetDefaultSize().fHeight)
155 *(
fMain->GetSize().fHeight)/(
fMain->GetDefaultSize().fHeight));
158 TGTab *this_tab =
dynamic_cast<TGTab*
>(frame_element->fFrame);
161 for(
int jtab = 0; jtab < this_tab->GetNumberOfTabs() ; jtab++){
163 TGCompositeFrame* frame2 = this_tab->GetTabContainer(jtab);
169 TList* mylist2 = frame2->GetList();
171 TIter next2(mylist2);
172 while (TObject *obj2 = next2()){
175 TGFrameElement *frame_element =
dynamic_cast<TGFrameElement*
>(obj2);
178 frame_element->fFrame->Resize((frame_element->fFrame->GetDefaultSize().fWidth)
179 *(
fMain->GetSize().fWidth)/(
fMain->GetDefaultSize().fWidth),
180 (frame_element->fFrame->GetDefaultSize().fHeight)
181 *(
fMain->GetSize().fHeight)/(
fMain->GetDefaultSize().fHeight));
190 std::cout <<
"TMainDisplayWindow::ResetSize:: Dynamic cast of obj to TGFrameElement failed." << std::endl;
202 TGCompositeFrame* frame =
fTab->GetTabContainer(index);
204 TList* mylist = frame->GetList();
207 while (TObject *obj = next()){
208 TGFrameElement *frame_element =
dynamic_cast<TGFrameElement*
>(obj);
211 TGTab *this_tab =
dynamic_cast<TGTab*
>(frame_element->fFrame);
212 if(this_tab)
return this_tab;
224 TGCompositeFrame *compositeFrame;
226 compositeFrame =
fTab->AddTab(name.c_str());
228 compositeFrame = tab->AddTab(name.c_str());
229 compositeFrame->SetLayoutManager(
new TGVerticalLayout(compositeFrame));
233 std::pair<int,int> index;
235 sprintf(cname,
"Canvas_%i",
fTab->GetNumberOfTabs() - 1);
236 index.first =
fTab->GetNumberOfTabs() - 1;
239 sprintf(cname,
"Canvas_%i_%i",mainTabIndex,tab->GetNumberOfTabs() - 1);
241 index.first = mainTabIndex;
242 index.second = tab->GetNumberOfTabs() - 1;
244 TRootEmbeddedCanvas *embed_canvas =
new TRootEmbeddedCanvas(cname, compositeFrame,
246 compositeFrame->AddFrame(embed_canvas,
new TGLayoutHints(kLHintsTop | kLHintsExpandX,5,5,5,0));
256 std::cout <<
"Adding new canvas in tab named '" << subtabname <<
"'" << std::endl;
262 int mainTabIndex = 0;
263 for(
int itab = 0; itab <
fTab->GetNumberOfTabs() ; itab++){
272 std::cout <<
"Adding new canvas in sub-tab named '" << subtabname <<
"' of tab " << tabname << std::endl;
277 TGCompositeFrame *compositeFrame =
fTab->AddTab(tabname.c_str());
278 compositeFrame->SetLayoutManager(
new TGVerticalLayout(compositeFrame));
279 subtab =
new TGTab(compositeFrame);
280 compositeFrame->AddFrame(subtab,
new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
282 std::cout <<
"Creating new tab named '"<< tabname <<
"'. "
283 <<
"Creating a new canvas in sub-tab named '" << subtabname <<
"'" << std::endl;
290 std::pair<int,int> tmp;
291 tmp.first =
fTab->GetCurrent();
294 tmp.second = subtab->GetCurrent();
305 fMain->MapSubwindows();
319 TList* mylist = frame->GetList();
322 while (TObject *obj = next()){
324 TGFrameElement *frame_element =
dynamic_cast<TGFrameElement*
>(obj);
328 TGFrame* frame = frame_element->fFrame;
329 TRootEmbeddedCanvas *embed_canvas =
dynamic_cast<TRootEmbeddedCanvas*
>(frame);
344 TGCompositeFrame* frame;
346 frame = subtab->GetTabContainer(index.second);
348 frame =
fTab->GetTabContainer(index.first);
355 TGCompositeFrame* frame;
357 frame = subtab->GetTabContainer(subtab->GetCurrent());
359 frame =
fTab->GetTabContainer(
fTab->GetCurrent());
376 for(
int itab = 0; itab <
fTab->GetNumberOfTabs() ; itab++){
379 TGCompositeFrame* frame =
fTab->GetTabContainer(itab);
385 for (
int isubtab = 0; isubtab < subtab->GetNumberOfTabs() ; isubtab++){
388 if(
GetTabName(subtab, isubtab).compare(name) == 0){
389 TGCompositeFrame* frame = subtab->GetTabContainer(isubtab);
407 if(embed)
return embed->GetCanvas();
416 if(tabindex.second == -1)
428 TIter nextTab(tab->GetList());
433 index = tab->GetCurrent();
435 TGTabElement *tabel = 0;
438 for(
int i = 0; i <= index; i++){
439 el = (TGFrameElement *) nextTab();
440 tabel = (TGTabElement *) el->fFrame;
441 el = (TGFrameElement *) nextTab();
445 return std::string(*tabel->GetText());
448 return std::string(
"not found");
454 TGTab *tab =
GetTab(tabindex);
455 if(!tab || tab->GetNumberOfTabs() == 0){
456 return std::string(
"not found");
466 std::cout <<
"Destructor! " << std::endl;
475 "JPG files",
"*.jpg",
476 "PNG files",
"*.png",
477 "EPS files",
"*.eps",
481 static TString dir(
".");
484 fi.fIniDir = StrDup(dir);
485 new TGFileDialog(gClient->GetRoot(),
fMain, kFDSave, &fi);
486 printf(
"Open file: %s (dir: %s)\n", fi.fFilename,
490 double xl = gPad->GetXlowNDC(), xh = gPad->GetXlowNDC() + gPad->GetWNDC();
491 double yl = gPad->GetYlowNDC(), yh = gPad->GetYlowNDC() + gPad->GetHNDC();
493 gPad->SetPad(0,0,1.0,1.0);
494 gPad->SaveAs(fi.fFilename);
495 gPad->SetPad(xl,yl,xh,yh);
502 static TString dir(
".");
505 fi.fIniDir = StrDup(dir);
506 new TGFileDialog(gClient->GetRoot(),
fMain, kFDSave, &fi);
507 printf(
"Open file: %s (dir: %s)\n", fi.fFilename,
510 gPad->GetCanvas()->SaveAs(fi.fFilename);
561 TGCompositeFrame* frame =
fTab->GetTabContainer(i);
565 TList* mylist = frame->GetList();
569 while (TObject *obj = next()){
570 TGFrameElement *frame_element =
dynamic_cast<TGFrameElement*
>(obj);
572 TGTab *this_tab =
dynamic_cast<TGTab*
>(frame_element->fFrame);
574 return this_tab->GetNumberOfTabs();
ClassImp(TMainDisplayWindow) TMainDisplayWindow
TRootEmbeddedCanvas * GetTRootEmbeddedCanvasFromTGCompositeFrame(TGCompositeFrame *frame)
Pull the embedded canvas out of the compositeframe.
static TInterestingEventManager * instance()
TGTextButton * fNextButton
std::pair< int, int > AddSingleTab(std::string name, TGTab *tab=0, int mainTabIndex=-1)
bool fProcessingFreeRunning
Is processing free-running? (offline)
std::string GetTabName(TGTab *tab, int index=-1)
TGTextButton * fNextInterestingButton
int fMainDisplayDefaultWidth
void SavePadButtonAction()
Method to call when 'save pad' button is pressed.
std::pair< int, int > GetCurrentTabIndex()
Return an pair<int> index for current tab/sub-tab;.
void NewTBrowserButtonAction()
TGTextButton * fPauseButton
TMainDisplayWindow(const TGWindow *p, UInt_t w, UInt_t h, bool isOffline, bool updatingBasedSeconds)
TGTextButton * fOpenNewTBrowser
std::pair< int, int > AddCanvas(std::string subtabname, std::string tabname=std::string(""))
TCanvas * GetCanvas(const char *name)
Get a particular canvas based on canvas name.
void SaveCanvasButtonAction()
Method to call when 'save canvas' button is pressed.
std::string GetCurrentTabName()
Return the canvas name for the current tab.
bool fProcessingPaused
Is processing paused? (online)
TGTab * GetSubTab(int index)
int fMainDisplayDefaultHeight
TRootEmbeddedCanvas * GetEmbeddedCanvas(const char *name)
TRootEmbeddedCanvas * GetCurrentEmbeddedCanvas()
Return the current embedded canvas.
virtual ~TMainDisplayWindow()
int GetNumberSubTabs(int i)
void FreeRunningButtonAction()
Method to call when 'free-running/resume' button is pressed.
TGTextButton * fSavePadButton
Buttons to make plots of current pad/canvas.
TGCompositeFrame * GetCompositeFrame(std::pair< int, int > index)
TGHorizontalFrame * fHframe
TGTextButton * fFreeRunningButton
TGTextButton * fResetButton
TGNumberEntry * fNumberSkipEventButton
TGCompositeFrame * GetCurrentCompositeFrame()
void PauseResumeButtonAction()
Method to call when 'pause/resume' button is pressed.
TGTextButton * fSaveCanvasButton
TGTextButton * fQuitButton