-// Author: Benjamin Hess 25/09/2008
+// Author: Benjamin Hess 30/10/2009
/*************************************************************************
- * Copyright (C) 2008, Alexandru Bercuci, Benjamin Hess. *
+ * Copyright (C) 2008-2009, Alexandru Bercuci, Benjamin Hess. *
* All rights reserved. *
*************************************************************************/
,fText(0x0)
,fCombo(0x0)
,fTextEdit(0x0)
+ ,fbCreate(0x0)
+ ,fbCancel(0x0)
{
const Int_t width = 300;
fCombo->Resize(width, fText->GetDefaultHeight());
fFrameType->AddFrame(fCombo, new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2));
+ // horizontal frame
+ TGHorizontalFrame *fFrameAction = new TGHorizontalFrame(this,10,10,kHorizontalFrame);
+ fbCancel = new TGTextButton(fFrameAction, "Cancel");
+ fbCancel->SetToolTipText("Exit macro creation wizzard");
+ fFrameAction->AddFrame(fbCancel, new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2));
+ fbCreate = new TGTextButton(fFrameAction, "Done");
+ fbCreate->SetToolTipText("Use settings to create the macro");
+ fFrameAction->AddFrame(fbCreate, new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2));
+
// horizontal frame
TGHorizontalFrame *fFrameText = new TGHorizontalFrame(this,10,10,kHorizontalFrame);
AddFrame(fFrameName, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX,2,2,2,2));
AddFrame(fFrameComment, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX,2,2,2,2));
AddFrame(fFrameType, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX,2,2,2,2));
+ AddFrame(fFrameAction, new TGLayoutHints(kLHintsRight | kLHintsTop | kLHintsExpandX,2,2,2,2));
TGHorizontal3DLine *fLine = new TGHorizontal3DLine(this, 281, 2);
AddFrame(fLine, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX,2,2,2,2));
MapWindow();
// Do the linking
- fCombo->Connect("Selected(Int_t)", "AliEveTRDMacroWizzard", this, "Create(Int_t)");
+ //fCombo->Connect("Selected(Int_t)", "AliEveTRDMacroWizzard", this, "Create(Int_t)");
+ fbCreate->Connect("Clicked()", "AliEveTRDMacroWizzard", this, "HandleCreate()");
+ fbCancel->Connect("Clicked()", "AliEveTRDMacroWizzard", this, "CloseWindow()");
+
+ // Standard choice
+ fCombo->Select(1, kFALSE);
}
const Char_t *fIncludes =
," if (!track) return kFALSE;\n"
," n = 0;\n"
-" r=0x0;\n"
+" r = 0x0;\n"
" if (!track) return;\n"
," if (!track) return 0x0;\n"
-" TH1* h = 0x0;\n"
+" TH1* h = 0x0;\n\n"
+"// Set bins, xmin and xmax here\n"
+" Int_t n = 1;\n"
+" Double_t xmin = 0;\n"
+" Double_t xmax = 100;\n\n"
" if(!(h = (TH1*)gROOT->FindObject(\"h\"))){\n"
" h = new TH1(\"h\", \"Title\", n, xmin, xmax);\n"
" h->GetXaxis()->SetTitle("");\n"
" if (!track2) return kFALSE;\n"
," n = 0;\n"
-" r=0x0;\n"
+" r = 0x0;\n"
" if (!track) return;\n"
" if (!track2) return;\n"
," if (!track) return 0x0;\n"
" if (!track2) return 0x0;\n"
-" TH1* h = 0x0;\n"
+" TH1* h = 0x0;\n\n"
+"// Set bins, xmin and xmax here\n"
+" Int_t n = 1;\n"
+" Double_t xmin = 0;\n"
+" Double_t xmax = 100;\n\n"
" if(!(h = (TH1*)gROOT->FindObject(\"h\"))){\n"
" h = new TH1(\"h\", \"Title\", n, xmin, xmax);\n"
" h->GetXaxis()->SetTitle("");\n"
const Char_t *name = fText->GetText();
if(strcmp(name,"")==0){
AliInfo("Please specify a name for your macro.");
- fCombo->Select(-1);
+ new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error",
+ "Please specify a name for your macro.", kMBIconExclamation, kMBOk);
+ //fCombo->Select(-1);
+ return;
+ }
+
+ // Note: gSystem->AccessPathName(...) returns kTRUE, if the access FAILED!
+ if(!gSystem->AccessPathName(Form("./%s.C", name))){
+ // If there is already a file with this name -> Error
+ AliInfo(Form("A macro \"%s.C\" already exists in the current directory!\nPlease choose another name!", name));
+ new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error",
+ Form("A macro \"%s.C\" already exists in the current directory!\nPlease choose another name!", name), kMBIconExclamation, kMBOk);
+ //fCombo->Select(-1);
return;
}
FILE* fp = 0x0;
if(!(fp = fopen(Form("%s.C", name), "wt"))){
AliInfo("Couldn't create macro file.");
- fCombo->Select(-1);
+ new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error",
+ "Couldn't create macro file.", kMBIconExclamation, kMBOk);
+ //fCombo->Select(-1);
return;
}
break;
default:
AliInfo(Form("Unknown typ[%d]", typ));
+ new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error",
+ Form("Unknown typ[%d]", typ), kMBIconExclamation, kMBOk);
fclose(fp);
gSystem->Exec(Form("rm -f %s.C", name));
- fCombo->Select(-1);
+ //fCombo->Select(-1);
return;
}
{
Emit("Create(Char_t*)", Form("%s.C", name));
}
+
+//______________________________________________________
+void AliEveTRDMacroWizzard::HandleCreate()
+{
+ Create(fCombo->GetSelected());
+}