Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4CommandLine.h"
00015
00016 #include "Riostream.h"
00017 #include "TROOT.h"
00018
00019 #include <QFileDialog>
00020
00021 #include "TGo4Log.h"
00022 #include "TGo4QSettings.h"
00023 #include "TGo4MacroDialog.h"
00024
00025 TGo4CommandLine::TGo4CommandLine(QWidget *parent, const char* name) :
00026 QGo4Widget(parent, name)
00027 {
00028 setupUi(this);
00029 LoadHistory();
00030 }
00031
00032
00033 void TGo4CommandLine::FileSearchDialog()
00034 {
00035 QFileDialog fd( this, "Select ROOT macro to execute in GUI", QString(),
00036 "ROOT macro (*.C *.c);;Go4 hotstart script (*.hotstart)");
00037 fd.setFileMode( QFileDialog::ExistingFile);
00038
00039 if (fd.exec() != QDialog::Accepted) return;
00040
00041 QStringList flst = fd.selectedFiles();
00042 if (flst.isEmpty()) return;
00043
00044 QString cmd;
00045 if(fd.selectedNameFilter().contains(".hotstart"))
00046 cmd = flst[0];
00047 else
00048 cmd = QString(".x ") + flst[0];
00049 if (InputLine->findText(cmd)<0) InputLine->addItem(cmd);
00050 InputLine->setCurrentIndex(InputLine->findText(cmd));
00051 }
00052
00053 void TGo4CommandLine::ExecuteSlot()
00054 {
00055 enterPressedSlot();
00056 }
00057
00058
00059 void TGo4CommandLine::enterPressedSlot()
00060 {
00061 QString str = InputLine->currentText();
00062 if (str.length()==0) return;
00063
00064 if(str.contains("help") || str.contains(".go4h")) {
00065 PrintHelp();
00066 } else
00067 if(str.contains(".hotstart") && !str.contains(".x")) {
00068 StatusMessage(QString("Executing hotstart script: ") + str);
00069 StartHotstart(str.toLatin1().constData());
00070 } else {
00071 StatusMessage(QString("Executing command: ") + str);
00072 gROOT->ProcessLineSync(str.toLatin1().constData());
00073 }
00074
00075 go4sett->setCommandsHistoryGUI(InputLine->getHistory(50));
00076 }
00077
00078 void TGo4CommandLine::LoadHistory()
00079 {
00080
00081 QStringList histlist = go4sett->getCommandsHistoryGUI();
00082 InputLine->addItems(histlist);
00083
00084 gROOT->ProcessLineSync(Form(".L %s", TGo4Log::subGO4SYS("macros/corrhistos.C").Data()));
00085 gROOT->ProcessLineSync(Form(".L %s", TGo4Log::subGO4SYS("macros/hishisto.C").Data()));
00086 gROOT->ProcessLineSync(Form(".L %s", TGo4Log::subGO4SYS("macros/addhistos.C").Data()));
00087 gROOT->ProcessLineSync(Form(".L %s", TGo4Log::subGO4SYS("macros/divhistos.C").Data()));
00088 gROOT->ProcessLineSync(Form(".L %s", TGo4Log::subGO4SYS("macros/profileX.C").Data()));
00089 gROOT->ProcessLineSync(Form(".L %s", TGo4Log::subGO4SYS("macros/profileY.C").Data()));
00090 gROOT->ProcessLineSync(Form(".L %s", TGo4Log::subGO4SYS("macros/projectionX.C").Data()));
00091 gROOT->ProcessLineSync(Form(".L %s", TGo4Log::subGO4SYS("macros/projectionY.C").Data()));
00092 gROOT->ProcessLineSync(Form(".L %s", TGo4Log::subGO4SYS("macros/rebin.C").Data()));
00093 gROOT->ProcessLineSync(Form(".L %s", TGo4Log::subGO4SYS("macros/scalex.C").Data()));
00094 gROOT->ProcessLineSync(Form(".L %s", TGo4Log::subGO4SYS("macros/fft.C").Data()));
00095
00096 }
00097
00098
00099 void TGo4CommandLine::PredefinedDialog()
00100 {
00101 TGo4MacroDialog md;
00102 if (md.exec() != QDialog::Accepted) return;
00103 InputLine->insertItem(0, md.getCommand());
00104 InputLine->setCurrentIndex(0);
00105 }
00106
00107
00108 void TGo4CommandLine::PrintHelp()
00109 {
00110 std::cout <<"\n--- Go4 GUI command line short help --- " << std::endl;
00111 std::cout <<"- execute any command by pressing RETURN (Enter key)" << std::endl;
00112 std::cout <<"--" << std::endl;
00113 std::cout <<"- use '.h' for help concerning ROOT commands" << std::endl;
00114 std::cout <<"--" << std::endl;
00115 std::cout <<"- use 'go4->...' to access TGo4AbstractInterface for gui commands" << std::endl;
00116 std::cout <<"--" << std::endl;
00117 std::cout <<"- Some useful Go4 GUI command functions:" << std::endl;
00118
00119 std::cout <<"\t- TObject* go4->GetObject(const char* itemname);"<< std::endl;
00120 std::cout <<"\t\t: get browser object by full pathname. " << std::endl;
00121 std::cout <<"\t- TString go4->FindItem(const char* name); " << std::endl;
00122 std::cout <<"\t\t: get full pathname of browser object by name " << std::endl;
00123 std::cout <<"\t- TString go4->SaveToMemory(const char* path, TObject* obj, Bool_t ownership = kFALSE);"<< std::endl;
00124 std::cout <<"\t\t: Put object obj into workspace memory under subfolder path. Returns full item pathname. " << std::endl;
00125 std::cout <<"\t- ViewPanelHandle go4->StartViewPanel()"<< std::endl;
00126 std::cout <<"\t\t: Open new Go4 viewpanel with default size. Returns handle of new panel." << std::endl;
00127 std::cout <<"\t- Bool_t go4->DrawItem(const char* itemname, ViewPanelHandle panel = 0, const char* drawopt = 0);"<< std::endl;
00128 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;
00129 std::cout <<"\t- go4->OpenFile(const char* fname)" << std::endl;
00130 std::cout <<"\t\t: open ROOT file of fname in Go4 browser " << std::endl;
00131 std::cout <<"\t- go4->LaunchAnalysis()" << std::endl;
00132 std::cout <<"\t\t: Start Go4 analysis process with previous set up " << std::endl;
00133 std::cout <<"--" << std::endl;
00134 std::cout <<"---- Please: note the Go4 helpwindow with TGo4AbstractInterface full method documentation!" << std::endl;
00135 std::cout <<"---- see example scripts at $GO4SYS/macros !" << std::endl;
00136 std::cout <<"---- visit our website at: \t http://go4.gsi.de !" << std::endl;
00137 std::cout <<"------ " << std::endl;
00138 HelpWindow("docs/Go4Reference.pdf", "Show Go4 Reference manual...");
00139 }