42 QFileDialog fd(
this,
"Select ROOT macro to execute in GUI", QString(),
43 "ROOT macro (*.C *.c);;Go4 hotstart script (*.hotstart);;Python script(*.py)");
44 fd.setFileMode( QFileDialog::ExistingFile);
46 if (fd.exec() != QDialog::Accepted)
return;
48 QStringList flst = fd.selectedFiles();
49 if (flst.isEmpty())
return;
50 bool iscint = fd.selectedNameFilter().contains(
".C") || fd.selectedNameFilter().contains(
".c");
51 bool ishot = fd.selectedNameFilter().contains(
".hotstart");
52 bool ispyth = fd.selectedNameFilter().contains(
".py");
56 cmd = QString(
".x ") + flst[0];
58 cmd = QString(
"$") + flst[0];
62 std::cout <<
"TGo4CommandLine NEVER COME HERE - unknown file type!\n-" << std::endl;
66 int index = InputLine->findText(cmd);
68 InputLine->insertItem(-1, cmd);
69 index = InputLine->findText(cmd);
71 InputLine->setCurrentIndex(index);
81 const char pyprompt =
'$';
82 QString pyinitfile=
"python/go4init.py";
83 QString str = InputLine->currentText();
87 if (str.contains(
"help") || str.contains(
".go4h"))
91 else if (str.contains(
".hotstart") && !str.contains(
".x"))
99 if (str.contains(pyprompt)) {
101 str.remove(0, str.indexOf(pyprompt) + 1);
103 const QString PY_EXT =
".py";
104 int imin = str.indexOf(PY_EXT +
" ");
105 int imax = str.length();
110 imin += PY_EXT.length();
113 QString scrstring = str.left(imin);
114 QString argstring = str.mid(imin);
116 str =
"TPython::Exec(\"import sys; sys.argv = [\'" + scrstring +
"\'] + \'" + argstring +
"\'.split()\");";
117 str +=
"TPython::LoadMacro(\"" + scrstring +
"\")";
121 str.prepend(
"TPython::LoadMacro(\"" + go4sys + pyinitfile +
"\");");
122 str.prepend(
"TPython::Bind(TGo4AbstractInterface::Instance(), \"go4\");");
133 gROOT->ProcessLineSync(str.toLatin1().constData());
134 go4sett->setCommandsHistoryGUI(InputLine->getHistory(50));
136 catch(std::exception& ex)
138 StatusMessage(QString(
"Error invoking command - Exception: ") + QString(ex.what()));
142 StatusMessage(QString(
"Error invoking command - unknown Exception!"));
152 QStringList histlist =
go4sett->getCommandsHistoryGUI();
153 InputLine->addItems(histlist);
156 auto load_macro = [](
const char *name) {
157 TString exec =
".L ";
159 gROOT->ProcessLineSync(exec.Data());
162 load_macro(
"macros/corrhistos.C");
163 load_macro(
"macros/hishisto.C");
164 load_macro(
"macros/addhistos.C");
165 load_macro(
"macros/divhistos.C");
166 load_macro(
"macros/profileX.C");
167 load_macro(
"macros/profileY.C");
168 load_macro(
"macros/projectionX.C");
169 load_macro(
"macros/projectionY.C");
170 load_macro(
"macros/rebin.C");
171 load_macro(
"macros/scalex.C");
172 load_macro(
"macros/fft.C");
179 if (md.exec() != QDialog::Accepted)
return;
181 InputLine->setCurrentIndex(0);
187 std::cout <<
"\n--- Go4 GUI command line short help --- " << std::endl;
188 std::cout <<
"- execute any command by pressing RETURN (Enter key)" << std::endl;
189 std::cout <<
"--" << std::endl;
190 std::cout <<
"- use '.h' for help concerning ROOT commands" << std::endl;
191 std::cout <<
"--" << std::endl;
192 std::cout <<
"- use 'go4->...' to access TGo4AbstractInterface for gui commands" << std::endl;
193 std::cout <<
"--" << std::endl;
194 std::cout <<
"- Some useful Go4 GUI command functions:" << std::endl;
196 std::cout <<
"\t- TObject *go4->GetObject(const char *itemname);"<< std::endl;
197 std::cout <<
"\t\t: get browser object by full pathname. " << std::endl;
198 std::cout <<
"\t- TString go4->FindItem(const char *name); " << std::endl;
199 std::cout <<
"\t\t: get full pathname of browser object by name " << std::endl;
200 std::cout <<
"\t- TString go4->SaveToMemory(const char *path, TObject *obj, Bool_t ownership = kFALSE);"<< std::endl;
201 std::cout <<
"\t\t: Put object obj into workspace memory under subfolder path. Returns full item pathname. " << std::endl;
202 std::cout <<
"\t- ViewPanelHandle go4->StartViewPanel()"<< std::endl;
203 std::cout <<
"\t\t: Open new Go4 viewpanel with default size. Returns handle of new panel." << std::endl;
204 std::cout <<
"\t- Bool_t go4->DrawItem(const char *itemname, ViewPanelHandle panel = nullptr, const char *drawopt = nullptr);"<< std::endl;
205 std::cout <<
"\t\t: Draw object of full name itemname onto viewpanel panel. Will open new viewpanel if panel not specified. \n\t ROOT drawoption may be set. " << std::endl;
206 std::cout <<
"\t- go4->OpenFile(const char *fname)" << std::endl;
207 std::cout <<
"\t\t: open ROOT file of fname in Go4 browser " << std::endl;
208 std::cout <<
"\t- go4->LaunchAnalysis()" << std::endl;
209 std::cout <<
"\t\t: Start Go4 analysis process with previous set up " << std::endl;
210 std::cout <<
"--" << std::endl;
211 std::cout <<
"---- Please: note the Go4 helpwindow with TGo4AbstractInterface full method documentation!" << std::endl;
212 std::cout <<
"---- see example scripts at $GO4SYS/macros !" << std::endl;
213 std::cout <<
"---- visit our website at: \t http://go4.gsi.de !" << std::endl;
214 std::cout <<
"------ " << std::endl;
215 HelpWindow(
"docs/Go4Reference.pdf",
"Show Go4 Reference manual...");
void enterPressedSingal()
virtual void PredefinedDialog()
virtual void FileSearchDialog()
virtual void LoadHistory()
virtual void ExecuteSlot()
virtual void enterPressedSlot()
TGo4CommandLine(QWidget *parent=nullptr, const char *name=nullptr)
static TString subGO4SYS(const char *subdir)
Return subdirectory in the GO4SYS.
static const char * GO4SYS()
Return GO4SYS environment variable or Go4 top directory during compile (if GO4SYS) not set.
const QString & getCommand()