00001
00002
00003
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024
00025
00026 #include "TFndBaseMonGUI.h"
00027
00028 ClassImp(TFndBaseMonGUI)
00029
00030
00031 TFndBaseMonGUI::TFndBaseMonGUI(){
00032
00033
00034 fDebugLev = 0;
00035
00036 fCurLogFile = 0;
00037 fCurTmpFile = 0;
00038 fCurTmpFileName = ".tmp_baseGUI_info";
00039
00040 LoadFonts();
00041 }
00042
00043
00044 TFndBaseMonGUI::~TFndBaseMonGUI(){
00045
00046
00047 CloseLogFile(kFALSE);
00048 CloseLogFile(kTRUE);
00049 CloseGUI();
00050 }
00051
00052
00053 void TFndBaseMonGUI::LoadFonts(){
00054
00055 fFontType = "-adobe-helvetica-medium-r-*-*-";
00056 fFontSize = 10;
00057 fFontISO = "-*-*-*-*-*-iso8859-1";
00058 GCValues_t g_context_title;
00059
00060
00061 SetFontType(fFontType);
00062 SetFontSize(18);
00063 fFont_Title = gClient->GetFont(fFontString.Data());
00064
00065
00066 g_context_title.fMask = kGCForeground | kGCBackground | kGCFillStyle | kGCFont | kGCGraphicsExposures;
00067 gClient->GetColorByName("#000000",g_context_title.fForeground);
00068 gClient->GetColorByName("#c6c2c6",g_context_title.fBackground);
00069 g_context_title.fFillStyle = kFillSolid;
00070 g_context_title.fFont = fFont_Title->GetFontHandle();
00071 g_context_title.fGraphicsExposures = kFALSE;
00072 fFontGC_Title = gClient->GetGC(&g_context_title, kTRUE);
00073
00074
00075 SetFontType(fFontType);
00076 SetFontSize(12);
00077 fFont_GrpTitle = gClient->GetFont(fFontString.Data());
00078
00079
00080 g_context_title.fMask = kGCForeground | kGCBackground | kGCFillStyle | kGCFont | kGCGraphicsExposures;
00081 gClient->GetColorByName("#000000",g_context_title.fForeground);
00082 gClient->GetColorByName("#c6c2c6",g_context_title.fBackground);
00083 g_context_title.fFillStyle = kFillSolid;
00084 g_context_title.fFont = fFont_GrpTitle->GetFontHandle();
00085 g_context_title.fGraphicsExposures = kFALSE;
00086 fFontGC_GrpTitle = gClient->GetGC(&g_context_title, kTRUE);
00087
00088
00089 SetFontType(fFontType);
00090 SetFontSize(8);
00091 fFont_LabNorm = gClient->GetFont(fFontString.Data());
00092
00093
00094 g_context_title.fMask = kGCForeground | kGCBackground | kGCFillStyle | kGCFont | kGCGraphicsExposures;
00095 gClient->GetColorByName("#000000",g_context_title.fForeground);
00096 gClient->GetColorByName("#c6c2c6",g_context_title.fBackground);
00097 g_context_title.fFillStyle = kFillSolid;
00098 g_context_title.fFont = fFont_LabNorm->GetFontHandle();
00099 g_context_title.fGraphicsExposures = kFALSE;
00100 fFontGC_LabNorm = gClient->GetGC(&g_context_title, kTRUE);
00101
00102
00103 SetFontType(fFontType);
00104 SetFontSize(10);
00105 fFont_LabEnl = gClient->GetFont(fFontString.Data());
00106
00107
00108 g_context_title.fMask = kGCForeground | kGCBackground | kGCFillStyle | kGCFont | kGCGraphicsExposures;
00109 gClient->GetColorByName("#000000",g_context_title.fForeground);
00110 gClient->GetColorByName("#c6c2c6",g_context_title.fBackground);
00111 g_context_title.fFillStyle = kFillSolid;
00112 g_context_title.fFont = fFont_LabEnl->GetFontHandle();
00113 g_context_title.fGraphicsExposures = kFALSE;
00114 fFontGC_LabEnl = gClient->GetGC(&g_context_title, kTRUE);
00115
00116
00117 SetFontType(fFontType);
00118 SetFontSize(12);
00119 fFont_But = gClient->GetFont(fFontString.Data());
00120
00121
00122 g_context_title.fMask = kGCForeground | kGCBackground | kGCFillStyle | kGCFont | kGCGraphicsExposures;
00123 gClient->GetColorByName("#000000",g_context_title.fForeground);
00124 gClient->GetColorByName("#c6c2c6",g_context_title.fBackground);
00125 g_context_title.fFillStyle = kFillSolid;
00126 g_context_title.fFont = fFont_But->GetFontHandle();
00127 g_context_title.fGraphicsExposures = kFALSE;
00128 fFontGC_But = gClient->GetGC(&g_context_title, kTRUE);
00129
00130 }
00131
00132
00133 void TFndBaseMonGUI::SetFontType(TString ftype){
00134
00135 TString fontstring = ftype;
00136 fontstring+=(Int_t)(Gui::GetTGadj(1) * (Double_t)(fFontSize));
00137 fontstring+=fFontISO;
00138
00139 if(!gClient->GetFontPool()->GetFont(fontstring.Data(),0)){
00140 Warning("SetFontType","selected font is not available: \"%s\"",ftype.Data());
00141 return;
00142 }
00143 fFontType = ftype;
00144 fFontString = fontstring;
00145
00146 }
00147
00148
00149 void TFndBaseMonGUI::SetFontSize(Float_t fsize){
00150
00151 Int_t check_size = (Int_t) (Gui::GetTGadj(1) * fsize );
00152
00153 TString fontstring;
00154
00155 Int_t accepted = kFALSE;
00156 while(!accepted){
00157 if(check_size <=0){
00158 Error("SetFontSize","Problems while setting font size: using \"8\".");
00159 fFontSize = 8;
00160 fFontString = fFontType;
00161 fFontString+=fFontSize;
00162 fFontString+=fFontISO;
00163 return;
00164 }
00165 fontstring = fFontType;
00166 fontstring+=check_size;
00167 fontstring+=fFontISO;
00168
00169 accepted = (Int_t)gClient->GetFontPool()->GetFont(fontstring.Data(),0);
00170 if(fDebugLev > 1) Printf("accepted = \"%x\"",accepted);
00171 if(!accepted){
00172 Warning("SetFontType","selected font size (\"%d\") not available: trying \"%d\"",check_size,check_size-1);
00173 check_size--;
00174 }
00175 }
00176
00177 fFontSize = check_size;
00178 fFontString = fontstring;
00179 }
00180
00181
00182 void TFndBaseMonGUI::UpdateDisplayPad(){
00183
00184 if(!fShowCanvas){
00185 Warning("ResetDisplayPad","Display pad not available");
00186 return;
00187 }
00188
00189 fShowCanvas->Modified();
00190 fShowCanvas->Update();
00191 }
00192
00193
00194 void TFndBaseMonGUI::ResetDisplayPad(Int_t ncols,Int_t nraws){
00195
00196 if(!fShowCanvas){
00197 Warning("ResetDisplayPad","Display pad not available");
00198 return;
00199 }
00200
00201 ResetDaughter();
00202
00203 fShowCanvas->Clear();
00204
00205
00206 if(ncols != 0 || nraws !=0) fShowCanvas->Divide(ncols,nraws);
00207 UpdateDisplayPad();
00208 }
00209
00210
00211 void TFndBaseMonGUI::MapGUI(){
00212
00213 if(!fMainFrame){
00214 Warning("MapGUI","fMainFrame not available");
00215 return;
00216 }
00217 fMainFrame->MapSubwindows();
00218
00219 fMainFrame->Resize(fMainFrame->GetDefaultSize());
00220 fMainFrame->MapWindow();
00221
00222 Gui::MoveResizeSafe(10, 10,1000,650,fMainFrame);
00223
00224 }
00225
00226
00227 Bool_t TFndBaseMonGUI::MakeConnections(Bool_t Connect){
00228
00229 Bool_t ok = kTRUE;
00230
00231 if(Connect){
00232 ok = ok && fMainFrame->Connect("CloseWindow()", "TFndBaseMonGUI", this, "CloseGUI()");
00233
00234 ok = ok && fSteer_Combo->Connect("Selected(Int_t)", "TFndBaseMonGUI", this, "Exe_SteerCombo(Int_t)");
00235 ok = ok && fSel_Combo1->Connect("Selected(Int_t)", "TFndBaseMonGUI", this, "Exe_SelCombo1(Int_t)");
00236 ok = ok && fSel_Combo2->Connect("Selected(Int_t)", "TFndBaseMonGUI", this, "Exe_SelCombo2(Int_t)");
00237
00238 ok = ok && fShowCanvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)","TFndBaseMonGUI",this,"HandleMouseActions(Int_t,Int_t,Int_t,TObject*)");
00239 }
00240 else{
00241 ok = ok && fMainFrame->Disconnect("CloseWindow()", "TFndBaseMonGUI", this, "CloseGUI()");
00242
00243 ok = ok && fSteer_Combo->Disconnect("Selected(Int_t)", "TFndBaseMonGUI", this, "Exe_SteerCombo(Int_t)");
00244 ok = ok && fSel_Combo1->Disconnect("Selected(Int_t)", "TFndBaseMonGUI", this, "Exe_SelCombo1(Int_t)");
00245 ok = ok && fSel_Combo2->Disconnect("Selected(Int_t)", "TFndBaseMonGUI", this, "Exe_SelCombo2(Int_t)");
00246
00247 ok = ok && fShowCanvas->Disconnect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)","TFndBaseMonGUI",this,"HandleMouseActions(Int_t,Int_t,Int_t,TObject*)");
00248 }
00249
00250 if(!ok) Warning("MakeConnections","At least one broken connection found.");
00251 return ok;
00252
00253 }
00254
00255
00256 void TFndBaseMonGUI::FillCombo_Steer(){
00257
00258 if(!fSteer_Combo) return;
00259
00260 if(fSteer_Combo->GetNumberOfEntries() != 0) fSteer_Combo->RemoveAll();
00261
00262 fSteer_Combo->AddEntry("Steer 0",0);
00263 fSteer_Combo->AddEntry("Steer 1",1);
00264 fSteer_Combo->AddEntry("Steer 2",2);
00265 fSteer_Combo->AddEntry("Steer 3",3);
00266
00267 }
00268
00269
00270 void TFndBaseMonGUI::FillCombo_Sel1(){
00271
00272
00273 if(!fSel_Combo1) return;
00274
00275 if(fSel_Combo1->GetNumberOfEntries() != 0) fSel_Combo1->RemoveAll();
00276
00277 fSel_Combo1->AddEntry("Combo master 0",0);
00278 fSel_Combo1->AddEntry("Combo master 1",1);
00279 fSel_Combo1->AddEntry("Combo master 2",2);
00280 fSel_Combo1->AddEntry("Combo master 3",3);
00281
00282 }
00283
00284
00285 void TFndBaseMonGUI::FillCombo_Sel2(){
00286
00287
00288 if(!fSel_Combo2) return;
00289
00290 if(fSel_Combo2->GetNumberOfEntries() != 0) fSel_Combo2->RemoveAll();
00291
00292 fSel_Combo2->AddEntry("Combo slave 0",0);
00293 fSel_Combo2->AddEntry("Combo slave 1",1);
00294 fSel_Combo2->AddEntry("Combo slave 2",2);
00295 fSel_Combo2->AddEntry("Combo slave 3",3);
00296
00297 }
00298
00299
00300 void TFndBaseMonGUI::Exe_SteerCombo(Int_t id){
00301
00302 if(fDebugLev > 0) Info("Exe_SteerCombo","Executing command id: %d",id);
00303 }
00304
00305
00306 void TFndBaseMonGUI::Exe_SelCombo1(Int_t id){
00307
00308 if(fDebugLev > 0) Info("Exe_SelCombo1","Executing command id: %d",id);
00309 }
00310
00311
00312 void TFndBaseMonGUI::Exe_SelCombo2(Int_t id){
00313
00314 if(fDebugLev > 0) Info("Exe_SelCombo2","Executing command id: %d",id);
00315 }
00316
00317
00318 void TFndBaseMonGUI::BuildBaseGUI(){
00319
00320
00321 fMainFrame = new TGMainFrame(gClient->GetRoot(),10,10,kMainFrame | kVerticalFrame);
00322 fMainFrame->SetLayoutBroken(kTRUE);
00323 fMainFrame->SetCleanup(kDeepCleanup);
00324 fMainFrame->SetWindowName("Base GUI for monitoring applications");
00325
00326
00327 fVertFrm_CL1 = new TGVerticalFrame(fMainFrame,1190,856,kVerticalFrame);
00328 fVertFrm_CL1->SetLayoutBroken(kTRUE);
00329
00330
00331 fHorFrm_CL2 = new TGHorizontalFrame(fVertFrm_CL1,1186,832,kHorizontalFrame);
00332 fHorFrm_CL2->SetLayoutBroken(kTRUE);
00333
00334
00335 LoadFonts();
00336
00337
00338 fShowEmbeddedCanvas = new TRootEmbeddedCanvas(0,fHorFrm_CL2,1000,830);
00339 fShowCanvas = fShowEmbeddedCanvas->GetCanvas();
00340
00341 fShowCanvas->SetName("fShowCanvas");
00342 fShowCanvas->SetTitle("Show Canvas");
00343
00344
00345 fShowCanvas->SetWindowSize(800,600);
00346
00347
00348
00349
00350
00351
00352 fHorFrm_CL2->AddFrame(fShowEmbeddedCanvas, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00353
00354 Gui::MoveResizeSafe(170, 20,826,605,fShowEmbeddedCanvas);
00355
00356
00357 fGrpFrm_SteerCmd = new TGGroupFrame(fHorFrm_CL2,"fGrpFrm_SteerCmd");
00358 fGrpFrm_SteerCmd->SetLayoutBroken(kTRUE);
00359 fGrpFrm_SteerCmd->SetTitlePos(TGGroupFrame::kCenter);
00360 fGrpFrm_SteerCmd->SetTextFont(fFont_GrpTitle->GetName());
00361
00362 ULong_t ucolor;
00363 gClient->GetColorByName("#ffffff",ucolor);
00364
00365
00366 fSteer_Combo_Lbl = new TGLabel(fGrpFrm_SteerCmd,"fSteer_Combo_Lbl",
00367 fFontGC_LabNorm->GetGC(),
00368 fFont_LabNorm->GetFontStruct(),
00369 kSunkenFrame | kDoubleBorder | kOwnBackground);
00370
00371 fSteer_Combo_Lbl->SetTextJustify(36);
00372 fGrpFrm_SteerCmd->AddFrame(fSteer_Combo_Lbl, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00373 Gui::MoveResizeSafe(10,20,75,17, fSteer_Combo_Lbl);
00374
00375 fSteer_Combo = new TGComboBox(fGrpFrm_SteerCmd,-1,kHorizontalFrame | kSunkenFrame | kDoubleBorder | kOwnBackground);
00376 fSteer_Combo->AddEntry("Entry 1 ",0);
00377 fSteer_Combo->AddEntry("Entry 2 ",1);
00378 fSteer_Combo->AddEntry("Entry 3 ",2);
00379 fSteer_Combo->AddEntry("Entry 4 ",3);
00380 fSteer_Combo->AddEntry("Entry 5 ",4);
00381 fSteer_Combo->AddEntry("Entry 6 ",5);
00382 fSteer_Combo->AddEntry("Entry 7 ",6);
00383 fSteer_Combo->Select(-1);
00384 fGrpFrm_SteerCmd->AddFrame(fSteer_Combo, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00385 Gui::MoveResizeSafe(90,20,70,17, fSteer_Combo);
00386
00387 fSteer_Num1_Lbl = new TGLabel(fGrpFrm_SteerCmd,"fSteer_Num1_Lbl",
00388 fFontGC_LabNorm->GetGC(),
00389 fFont_LabNorm->GetFontStruct(),
00390 kSunkenFrame | kDoubleBorder | kOwnBackground);
00391
00392 fSteer_Num1_Lbl->SetTextJustify(36);
00393 fGrpFrm_SteerCmd->AddFrame(fSteer_Num1_Lbl, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00394 Gui::MoveResizeSafe(10,40,75,17, fSteer_Num1_Lbl);
00395
00396 fSteer_Num1 = new TGNumberEntry(fGrpFrm_SteerCmd, (Double_t) 0,8,-1,(TGNumberFormat::EStyle) 5);
00397 fGrpFrm_SteerCmd->AddFrame(fSteer_Num1, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00398 Gui::MoveResizeSafe(90,40,69,17, fSteer_Num1);
00399
00400 fSteer_Num2_Lbl = new TGLabel(fGrpFrm_SteerCmd,"fSteer_Num2_Lbl",
00401 fFontGC_LabNorm->GetGC(),
00402 fFont_LabNorm->GetFontStruct(),
00403 kSunkenFrame | kDoubleBorder | kOwnBackground);
00404
00405 fSteer_Num2_Lbl->SetTextJustify(36);
00406 fGrpFrm_SteerCmd->AddFrame(fSteer_Num2_Lbl, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00407 Gui::MoveResizeSafe(10,60,75,17, fSteer_Num2_Lbl);
00408
00409 fSteer_Num2 = new TGNumberEntry(fGrpFrm_SteerCmd, (Double_t) 0,8,-1,(TGNumberFormat::EStyle) 5);
00410 fGrpFrm_SteerCmd->AddFrame(fSteer_Num2, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00411 Gui::MoveResizeSafe(90,60,69,17, fSteer_Num2);
00412
00413
00414 fSteer_But1 = new TGTextButton(fGrpFrm_SteerCmd,"fSteer_But1");
00415 fSteer_But1->SetTextJustify(36);
00416 fSteer_But1->SetFont(fFont_But->GetName());
00417 fGrpFrm_SteerCmd->AddFrame(fSteer_But1, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00418 Gui::MoveResizeSafe(10,90,70,30, fSteer_But1);
00419
00420 fSteer_But2 = new TGTextButton(fGrpFrm_SteerCmd,"fSteer_But2");
00421 fSteer_But2->SetTextJustify(36);
00422 fSteer_But2->SetFont(fFont_But->GetName());
00423 fGrpFrm_SteerCmd->AddFrame(fSteer_But2, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00424 Gui::MoveResizeSafe(87,90,70,30, fSteer_But2);
00425
00426 fGrpFrm_SteerCmd->SetLayoutManager(new TGVerticalLayout(fGrpFrm_SteerCmd));
00427 fHorFrm_CL2->AddFrame(fGrpFrm_SteerCmd, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00428 Gui::MoveResizeSafe(2,20,165,150,fGrpFrm_SteerCmd);
00429
00430
00431 fGrpFrm_SelectCmd = new TGGroupFrame(fHorFrm_CL2,"fGrpFrm_SelectCmd");
00432 fGrpFrm_SelectCmd->SetLayoutBroken(kTRUE);
00433 fGrpFrm_SelectCmd->SetTitlePos(TGGroupFrame::kCenter);
00434 fGrpFrm_SelectCmd->SetTextFont(fFont_GrpTitle->GetName());
00435
00436 gClient->GetColorByName("#ffffff",ucolor);
00437
00438
00439 fSel_Combo1_Lbl = new TGLabel(fGrpFrm_SelectCmd,"fSel_Combo1_Lbl",
00440 fFontGC_LabEnl->GetGC(),
00441 fFont_LabEnl->GetFontStruct(),
00442 kSunkenFrame | kDoubleBorder | kOwnBackground);
00443
00444 fSel_Combo1_Lbl->SetTextJustify(36);
00445 fGrpFrm_SelectCmd->AddFrame(fSel_Combo1_Lbl, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00446 Gui::MoveResizeSafe(20,20,130,20, fSel_Combo1_Lbl);
00447
00448 fSel_Combo1 = new TGComboBox(fGrpFrm_SelectCmd,-1,kHorizontalFrame | kSunkenFrame | kDoubleBorder | kOwnBackground);
00449 fSel_Combo1->AddEntry("Entry 1 ",0);
00450 fSel_Combo1->AddEntry("Entry 2 ",1);
00451 fSel_Combo1->AddEntry("Entry 3 ",2);
00452 fSel_Combo1->AddEntry("Entry 4 ",3);
00453 fSel_Combo1->AddEntry("Entry 5 ",4);
00454 fSel_Combo1->AddEntry("Entry 6 ",5);
00455 fSel_Combo1->AddEntry("Entry 7 ",6);
00456 fSel_Combo1->Select(-1);
00457 fGrpFrm_SelectCmd->AddFrame(fSel_Combo1, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00458 Gui::MoveResizeSafe(20,40,130,20, fSel_Combo1);
00459
00460 gClient->GetColorByName("#ffffff",ucolor);
00461
00462
00463 fSel_Combo2_Lbl = new TGLabel(fGrpFrm_SelectCmd,"fSel_Combo2_Lbl",
00464 fFontGC_LabEnl->GetGC(),
00465 fFont_LabEnl->GetFontStruct(),
00466 kSunkenFrame | kDoubleBorder | kOwnBackground);
00467
00468 fSel_Combo2_Lbl->SetTextJustify(36);
00469 fGrpFrm_SelectCmd->AddFrame(fSel_Combo2_Lbl, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00470 Gui::MoveResizeSafe(20,80,130,20, fSel_Combo2_Lbl);
00471
00472
00473 fSel_Combo2 = new TGComboBox(fGrpFrm_SelectCmd,-1,kHorizontalFrame | kSunkenFrame | kDoubleBorder | kOwnBackground);
00474 fSel_Combo2->AddEntry("Entry 1 ",0);
00475 fSel_Combo2->AddEntry("Entry 2 ",1);
00476 fSel_Combo2->AddEntry("Entry 3 ",2);
00477 fSel_Combo2->AddEntry("Entry 4 ",3);
00478 fSel_Combo2->AddEntry("Entry 5 ",4);
00479 fSel_Combo2->AddEntry("Entry 6 ",5);
00480 fSel_Combo2->AddEntry("Entry 7 ",6);
00481 fSel_Combo2->Select(-1);
00482 fGrpFrm_SelectCmd->AddFrame(fSel_Combo2, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00483 Gui::MoveResizeSafe(20,100,130,20, fSel_Combo2);
00484
00485 fGrpFrm_SelectCmd->SetLayoutManager(new TGVerticalLayout(fGrpFrm_SelectCmd));
00486 fHorFrm_CL2->AddFrame(fGrpFrm_SelectCmd, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00487 Gui::MoveResizeSafe(2,240,165,150, fGrpFrm_SelectCmd);
00488
00489
00490 fGrpFrm_Msg = new TGGroupFrame(fHorFrm_CL2,"fGrpFrm_Msg");
00491 fGrpFrm_Msg->SetLayoutBroken(kTRUE);
00492 fGrpFrm_Msg->SetTitlePos(TGGroupFrame::kCenter);
00493 fGrpFrm_Msg->SetTextFont(fFont_GrpTitle->GetName());
00494
00495 fMsg_TxtEdit = new TGTextEdit(fGrpFrm_Msg,168,288);
00496 fMsg_TxtEdit->LoadFile("FndBaseMonGUI.log");
00497 fGrpFrm_Msg->AddFrame(fMsg_TxtEdit, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00498 Gui::MoveResizeSafe(5,18,156,205,fMsg_TxtEdit);
00499
00500 fGrpFrm_Msg->SetLayoutManager(new TGVerticalLayout(fGrpFrm_Msg));
00501 fHorFrm_CL2->AddFrame(fGrpFrm_Msg, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00502 Gui::MoveResizeSafe(2,395,165,233,fGrpFrm_Msg);
00503
00504 fVertFrm_CL1->AddFrame(fHorFrm_CL2, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00505 Gui::MoveResizeSafe(2, 2,1000,630,fHorFrm_CL2);
00506
00507
00508 fStatBar1 = new TGStatusBar(fVertFrm_CL1,1188,20);
00509 fVertFrm_CL1->AddFrame(fStatBar1, new TGLayoutHints(kLHintsBottom | kLHintsExpandX));
00510 Gui::MoveResizeSafe(0, 630,1000,20,fStatBar1);
00511 Int_t parr[2] = {55,45};
00512 fStatBar1->SetParts(parr,2);
00513
00514
00515 fMainFrame->AddFrame(fVertFrm_CL1, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00516 Gui::MoveResizeSafe(0, 0,1000,650,fVertFrm_CL1);
00517
00518 }
00519
00520
00521 void TFndBaseMonGUI::CustomizeGUI(){
00522
00523 FillCombo_Steer();
00524 FillCombo_Sel1();
00525 FillCombo_Sel2();
00526 }
00527
00528
00529 void TFndBaseMonGUI::WriteStatusMessage(const TString &msg,Int_t partidx){
00530
00531 fStatBar1->SetText(msg,partidx);
00532 }
00533
00535
00536 void TFndBaseMonGUI::OpenLogFile(const TString &fdir, const TString &fnam,const Bool_t &is_temp,const Bool_t &reset_old){
00537
00538 CloseLogFile(is_temp);
00539
00540 TString path_str;
00541 path_str.Form("%s/%s",ExpandPathName(fdir).Data(),fnam.Data());
00542
00543 if(is_temp){
00544
00545 fCurTmpFile = new ofstream();
00546 if(reset_old) fCurTmpFile->open(path_str.Data(),ofstream::out | ofstream::trunc);
00547 else fCurTmpFile->open(path_str.Data(),ofstream::out | ofstream::app);
00548 }
00549 else{
00550 fCurLogFile = new ofstream();
00551 if(reset_old) fCurLogFile->open(path_str.Data(),ofstream::out | ofstream::trunc);
00552 else fCurLogFile->open(path_str.Data(),ofstream::out | ofstream::app);
00553 }
00554 }
00555
00556
00557 void TFndBaseMonGUI::CloseLogFile(const Bool_t &is_temp){
00558
00559 if(is_temp){
00560 if(!fCurTmpFile) return;
00561 fCurTmpFile->close();
00562 delete fCurTmpFile;
00563 fCurTmpFile = 0;
00564 }
00565 else{
00566 if(!fCurLogFile) return;
00567 fCurLogFile->close();
00568 delete fCurLogFile;
00569 fCurLogFile = 0;
00570 }
00571
00572 }
00573
00574
00575 void TFndBaseMonGUI::WriteLogFile(const TString &line,const Bool_t &is_temp){
00576
00577 if(is_temp){
00578 if(!fCurTmpFile) return;
00579 *fCurTmpFile << line.Data() << endl;
00580 }
00581 else{
00582 if(!fCurLogFile) return;
00583 *fCurLogFile << line.Data() << endl;
00584 }
00585
00586 }
00587
00588
00589 Int_t TFndBaseMonGUI::WriteTextEdit(const TString &txt_filename){
00590
00591
00592
00593
00594
00595
00596
00597 if(gSystem->AccessPathName(ExpandPathName(txt_filename))){
00598 Warning("WriteTextEdit","text file \"%s\" not found",txt_filename.Data());
00599 return -1;
00600 }
00601
00602 fMsg_TxtEdit->LoadFile(ExpandPathName(txt_filename).Data());
00603
00604 return 0;
00605 }
00606
00607
00608 void TFndBaseMonGUI::AddTextMessage(const TString &msg,Bool_t reset,Bool_t refresh){
00609
00610
00611
00612
00613
00614 OpenLogFile(ExpandPathName("$PWD"),fCurTmpFileName,kTRUE,reset);
00615 WriteLogFile(msg,kTRUE);
00616 if(refresh) WriteTextEdit(fCurTmpFileName);
00617 }
00618
00619
00620 void TFndBaseMonGUI::SetBackgroundColor(const Int_t &col){
00621
00622 fShowCanvas->cd();
00623 fShowCanvas->SetFillColor(col);
00624 fShowCanvas->Modified();
00625
00626 TPad *curpad = 0;
00627 for(Int_t i=1; i<100; i++){
00628 if(! fShowCanvas->GetPad(i) ) break;
00629 curpad = (TPad *) fShowCanvas->cd(i);
00630
00631 gPad->SetFillColor(col);
00632 gPad->GetFrame()->SetFillColor(col);
00633 gPad->Modified();
00634 gPad->Update();
00635
00636 }
00637
00638 fShowCanvas->Modified();
00639 fShowCanvas->Update();
00640
00641 }
00642
00643
00644 void TFndBaseMonGUI::CloseGUI(){
00645
00646
00647
00648 if(!fMainFrame){
00649 Warning("CloseGUI","fMainFrame not available");
00650 return;
00651 }
00652
00653 if(fDebugLev > 1) Info("CloseGUI","Deleting mainframe");
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667 fMainFrame->Cleanup();
00668
00669 delete fMainFrame;
00670
00671
00672
00673
00674 return;
00675 }
00676
00678
00679
00680 void TFndBaseMonGUI::HandleMouseActions(Int_t event, Int_t x, Int_t y, TObject *selected){
00681
00682 if(fDebugLev > 2) cout << "event: " << event << " ===> (" << x << ";" << y << "): " << selected->ClassName() << " -> " << selected->GetName() << endl;
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703 TString msg = "";
00704
00705 const Int_t ncmps = 6;
00706 TString cmpstr[ncmps] = {""};
00707 cmpstr[0] = "TFndMultiGraph";
00708 cmpstr[1] = "TMultiGraph";
00709 cmpstr[2] = "TFndGraph";
00710 cmpstr[3] = "TProfile";
00711 cmpstr[4] = "TGraph";
00712 cmpstr[5] = "TH";
00713 Bool_t sel_ok = kFALSE;
00714 TString cutnam = "";
00715
00716 switch(event){
00717
00718
00719 case 51:
00720 for(Int_t i=0;i<ncmps;i++){
00721 cutnam = selected->ClassName();
00722 cutnam.Resize(cmpstr[i].Sizeof()-1);
00723
00724 if(cmpstr[i].CompareTo(cutnam) == 0){
00725 sel_ok = kTRUE;
00726 break;
00727 }
00728 }
00729
00730 if(sel_ok){
00731 msg.Form("Moving on: %s: \"%s\" (%s) ---> ",selected->ClassName(),selected->GetName(),selected->GetTitle());
00732 msg+=selected->GetObjectInfo(x,y);
00733 }
00734
00735 break;
00736 case 53:
00737 break;
00738 case 52:
00739 break;
00740
00741
00742 case 1:
00743
00744 break;
00745
00746 case 11:
00747
00748 break;
00749
00750 case 61:
00751 break;
00752
00753 default: break;
00754 }
00755
00756
00757 if( ! msg.IsNull() ) WriteStatusMessage(msg,0);
00758
00759 HandleMouseActionsDaughter(event, x, y, selected);
00760
00761 }
00762
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00784
00785
00786
00790 ClassImp(TFndGTransientProgress)
00791
00792
00793 TFndGTransientProgress::TFndGTransientProgress():
00794 TGMainFrame(gClient->GetRoot(),10,10,kMainFrame | kVerticalFrame)
00795 {
00796
00797 fIsCancelled = kFALSE;
00798
00799 SetLayoutBroken(kTRUE);
00800 SetCleanup(kDeepCleanup);
00801 DontCallClose();
00802
00803 BuildGUI();
00804 MakeConnections();
00805 DisplayGUI();
00806
00807 }
00808
00809
00810 TFndGTransientProgress::~TFndGTransientProgress(){
00811
00812 Cleanup();
00813 }
00814
00815
00816
00817
00818 void TFndGTransientProgress::BuildGUI(){
00819
00820
00821 fFrmVert = new TGVerticalFrame(this,324,200,kVerticalFrame);
00822 fFrmVert->SetLayoutBroken(kTRUE);
00823
00824
00825 ULong_t ucolor;
00826 gClient->GetColorByName("#ffffff",ucolor);
00827
00828
00829 fLblTitle = new TGLabel(fFrmVert,"Progress Frame");
00830 fLblTitle->SetTextJustify(36);
00831 fFrmVert->AddFrame(fLblTitle, new TGLayoutHints(kLHintsLeft | kLHintsCenterX | kLHintsTop,2,2,2,2));
00832 MoveResizeSafe(16,8,296,56,fLblTitle);
00833
00834
00835 fPrgBar = new TGHProgressBar(fFrmVert,296);
00836 fPrgBar->SetFillType(TGProgressBar::kSolidFill);
00837 fPrgBar->ChangeOptions(kSunkenFrame | kDoubleBorder | kOwnBackground);
00838 fPrgBar->SetBackgroundColor(ucolor);
00839 fPrgBar->SetPosition(25);
00840 fFrmVert->AddFrame(fPrgBar, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00841 MoveResizeSafe(16,80,296,24,fPrgBar);
00842
00843
00844 fTxtButCancel = new TGTextButton(fFrmVert,"CANCEL");
00845 fTxtButCancel->SetTextJustify(36);
00846 fTxtButCancel->Resize(192,48);
00847 fFrmVert->AddFrame(fTxtButCancel, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
00848 MoveResizeSafe(72,112,192,48,fTxtButCancel);
00849
00850
00851 fStatBar = new TGStatusBar(fFrmVert,324,24);
00852 fFrmVert->AddFrame(fStatBar, new TGLayoutHints(kLHintsBottom | kLHintsExpandX));
00853 MoveResizeSafe(0,176,324,24,fStatBar);
00854
00855
00856 AddFrame(fFrmVert, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX | kLHintsExpandY,2,2,2,2));
00857 MoveResizeSafe(2,2,324,200,fFrmVert);
00858
00859 }
00860
00861
00862 void TFndGTransientProgress::DisplayGUI(){
00863
00864
00865 MapSubwindows();
00866
00867 Resize(GetDefaultSize());
00868 MapWindow();
00869 MoveResizeSafe(300,300,328,204,this);
00870 }
00871
00872
00873 void TFndGTransientProgress::MakeConnections(){
00874 fTxtButCancel->Connect("Clicked()","TFndGTransientProgress",this,"DoCancel()");
00875 }
00876
00877
00878 void TFndGTransientProgress::UpdateGUI(){
00879
00880 gClient->NeedRedraw(this);
00881 }
00882
00883
00884 void TFndGTransientProgress::DoCancel(){
00885
00886 cout << "Doing Cancel" << endl;
00887 fIsCancelled = kTRUE;
00888 }
00889
00890
00891 void TFndGTransientProgress::SetTitle(const TString &tit){
00892
00893 fLblTitle->SetText(tit);
00894 }
00895
00896
00897 void TFndGTransientProgress::ReSetStatusMessage(TString msg){
00898
00899 fStatBar->SetText(msg);
00900 }
00901
00902
00903 void TFndGTransientProgress::SetProgressBar(const Float_t &pos_perc){
00904
00905
00906 fPrgBar->SetPosition(pos_perc);
00907 }
00908
00909
00910 void TFndGTransientProgress::SetProgressBar(const Float_t ¤t,const Float_t &total){
00911
00912 Float_t perc = current/total;
00913 perc = perc *100;
00914 if( current > total ){
00915 Warning("SetProgressBar","Percent = %.2f",perc);
00916 perc = 100;
00917 }
00918 SetProgressBar(perc);
00919
00920 }