GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4AnalysisConfiguration.cpp
Go to the documentation of this file.
1 // $Id: TGo4AnalysisConfiguration.cpp 3117 2021-03-30 07:12:07Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
15 
16 #include <QFileDialog>
17 #include <QCloseEvent>
18 
19 #include "TGo4ConfigStep.h"
20 #include "TGo4AnalysisStatus.h"
21 #include "TGo4AnalysisStepStatus.h"
22 #include "TGo4ServerProxy.h"
23 
24 
25 TGo4AnalysisConfiguration::TGo4AnalysisConfiguration(QWidget *parent, const char* name) :
26  QGo4Widget(parent, name)
27 {
28  setupUi(this);
29 
30  QObject::connect(SubmitPushButton, SIGNAL(pressed()), this, SLOT(SubmitConfiguration()));
31  QObject::connect(AnalysisSaveConf, SIGNAL(clicked()), this, SLOT(SaveConfiguration()));
32  QObject::connect(LoadConfigFileName, SIGNAL(clicked()), this, SLOT(FileDialog_ConfFile()));
33  QObject::connect(LoadAutoSaveFileName, SIGNAL(clicked()), this, SLOT(FileDialog_AutoSave()));
34  QObject::connect(AutoSaveFileName, SIGNAL(textChanged(QString)), this, SLOT(LineEdit_AutoSaveFile()));
35  QObject::connect(GetActiveConfigButton, SIGNAL(clicked()), this, SLOT(RequestAnalysisStatus()));
36  QObject::connect(CompLevel, SIGNAL(valueChanged(int)), this, SLOT(SetCompressionLevel(int)));
37  QObject::connect(AnalysisLoadConf, SIGNAL(clicked()), this, SLOT(LoadConfiguration()));
38  QObject::connect(AutoSaveInterval, SIGNAL(valueChanged(int)), this, SLOT(SetAutoSaveInterval(int)));
39  QObject::connect(AutoSaveOverwrite, SIGNAL(toggled(bool)), this, SLOT(SetAutoSaveOverwrite(bool)));
40  QObject::connect(SaveNowB, SIGNAL(clicked()), this, SLOT(WriteAutoSave()));
41  QObject::connect(AutoSaveEnable, SIGNAL(toggled(bool)), this, SLOT(EnableAutoSaveSlot(bool)));
42  QObject::connect(SubmitAndStartButton, SIGNAL(clicked()), this, SLOT(SubmitAndStart()));
43  QObject::connect(ClosePushButton, SIGNAL(clicked()), this, SLOT(CloseAnalysis()));
44 
45  fSourcePath = ".";
46  fStorePath = ".";
47  fConfigPath = ".";
48  fAutoSavePath = ".";
49  fbTypingMode = true;
50  setCanDestroyWidget(false);
51 }
52 
53 
54 bool TGo4AnalysisConfiguration::IsAcceptDrag(const char* itemname, TClass* cl, int kind)
55 {
56  return false;
57 // if (cl==0) return false;
58 // return cl->InheritsFrom(TGo4AnalysisStatus::Class());
59 }
60 
61 void TGo4AnalysisConfiguration::DropItem(const char* itemname, TClass* cl, int kind)
62 {
63 // if (cl==0) return;
64 
65 // if (cl->InheritsFrom(TGo4AnalysisStatus::Class()))
66 // WorkWithStatus(itemname);
67 }
68 
69 void TGo4AnalysisConfiguration::linkedObjectUpdated(const char* linkname, TObject* obj)
70 {
71  if (strcmp(linkname,"Status")==0) {
72  parentWidget()->raise();
73  parentWidget()->show();
74  if (parentWidget()->isMinimized()) parentWidget()->showNormal();
75  RefreshWidget();
76 
77  TGo4ServerProxy* anal =
78  dynamic_cast<TGo4ServerProxy*>(GetLinked("Analysis", 0));
79  if (anal!=0)
80  anal->RefreshNamesList();
81  }
82 }
83 
85 {
86  ShootCloseWidget(true);
87 }
88 
90 {
91  ResetWidget();
92 
93  if (anal==0) {
94  ShootCloseWidget(true);
95  return;
96  }
97 
98  AddLink(anal->ParentSlot(), "Analysis");
99  AddLink(anal->SettingsSlot(), "Status");
100 
101  RefreshWidget();
102 }
103 
105 {
107 
108  QWidget* w = 0;
109  do {
110  w = TabSteps->currentWidget();
111  if (w!=0) {
112  TabSteps->removeTab(TabSteps->indexOf(w));
113  delete w;
114  }
115  } while (w!=0);
116 }
117 
119 {
120  TGo4AnalysisStatus* status =
121  dynamic_cast<TGo4AnalysisStatus*> (GetLinked("Status",0));
122  TGo4ServerProxy* anal =
123  dynamic_cast<TGo4ServerProxy*>(GetLinked("Analysis", 0));
124 
125  if ((status==0) || (anal==0)) return;
126 
127  SubmitPushButton->setEnabled(anal->CanSubmitObjects());
128  SubmitAndStartButton->setEnabled(anal->CanSubmitObjects());
129 
130  fbTypingMode = false;
131 
132  QWidget* w = 0;
133  do {
134  w = TabSteps->currentWidget();
135  if (w!=0) {
136  TabSteps->removeTab(TabSteps->indexOf(w));
137  delete w;
138  }
139  } while (w!=0);
140 
141  for(int i=0; i<status->GetNumberOfSteps(); i++) {
142  TGo4AnalysisStepStatus* stepstatus = status->GetStepStatus(i);
143  if (stepstatus==0) continue;
144  QString StepName = stepstatus->GetName();
145  TGo4ConfigStep* NewStep = new TGo4ConfigStep(TabSteps, StepName.toLatin1().constData());
146  NewStep->SetStepStatus(this, stepstatus, status->GetNumberOfSteps() > 1 ? i : -1);
147  TabSteps->insertTab(i, NewStep, NewStep->GetTabTitle());
148  }
149 
150  TabSteps->setCurrentIndex(0);
151  TabSteps->adjustSize();
152 
154  status->GetAutoSaveInterval(),
155  status->GetAutoSaveCompression(),
156  status->IsAutoSaveOn(),
157  status->IsAutoSaveOverwrite());
158 
160 
161  parentWidget()->showNormal();
162  parentWidget()->adjustSize();
163 
164  fbTypingMode = true;
165 }
166 
168 {
169  if (number>=0)
170  TabSteps->setTabText(number, step->GetTabTitle());
171 }
172 
173 
175 {
176  return fSourcePath;
177 }
178 
180 {
181  return fStorePath;
182 }
183 
185 {
186  fSourcePath = v;
187 }
188 
190 {
191  fStorePath = v;
192 }
193 
195 {
196  TGo4ServerProxy* anal =
197  dynamic_cast<TGo4ServerProxy*>(GetLinked("Analysis", 0));
198  if (anal!=0)
199  anal->RequestAnalysisSettings();
200 }
201 
203 {
204  QFileDialog fd(this,
205  "Select a configuration file",
206  fConfigPath,
207  " Configuration file (*.root)");
208  fd.setFileMode( QFileDialog::AnyFile);
209  if (fd.exec() != QDialog::Accepted) return;
210  QStringList flst = fd.selectedFiles();
211  QString fileName = flst.isEmpty() ? QString() : flst[0];
212  fConfigPath = fd.directory().path();
213  if(!fileName.endsWith(".root")) fileName.append(".root");
214  ConfigFileName->setText(fileName);
215 }
216 
218 {
219  QFileDialog fd( this,
220  "Select file name for autosaving",
222  "Auto Save File (*.root)");
223  fd.setFileMode(QFileDialog::AnyFile);
224  fd.setAcceptMode(QFileDialog::AcceptSave);
225  if (fd.exec() != QDialog::Accepted) return;
226 
227  QStringList flst = fd.selectedFiles();
228  if (flst.isEmpty()) return;
229 
230  QString fileName = flst[0];
231  fAutoSavePath = fd.directory().path();
232  if(!fileName.endsWith(".root")) fileName.append(".root");
233  AutoSaveFileName->setText(fileName);
235 }
236 
238 {
239  QString fname = AutoSaveFileName->text().trimmed();
240  TGo4AnalysisStatus* status =
241  dynamic_cast<TGo4AnalysisStatus*> (GetLinked("Status",0));
242  if ((status!=0) && fbTypingMode)
243  status->SetAutoFileName(fname.toLatin1().constData());
244 }
245 
247 {
248  TGo4AnalysisStatus* status =
249  dynamic_cast<TGo4AnalysisStatus*> (GetLinked("Status",0));
250  if ((status!=0) && fbTypingMode)
251  status->SetAutoSaveCompression(t);
252 }
253 
255 {
256  QString fname = ConfigFileName->text().trimmed();
257  TGo4ServerProxy* anal =
258  dynamic_cast<TGo4ServerProxy*>(GetLinked("Analysis", 0));
259  if (anal!=0)
260  anal->LoadConfigFile(fname.toLatin1().constData());
262 }
263 
265 {
266  QString fname = ConfigFileName->text().trimmed();
267  TGo4ServerProxy* anal =
268  dynamic_cast<TGo4ServerProxy*>(GetLinked("Analysis", 0));
269  if (anal!=0)
270  anal->SaveConfigFile(fname.toLatin1().constData());
271 }
272 
274 {
275  ServiceCall("SubmitAnalysisSettings");
276 }
277 
279 {
280  ServiceCall("SubmitStartAnalysis");
281  parentWidget()->hide();
282 }
283 
285 {
286  ServiceCall("CloseAnalysisSettings");
287 }
288 
290 {
291  TGo4AnalysisStatus* status =
292  dynamic_cast<TGo4AnalysisStatus*> (GetLinked("Status",0));
293  if ((status!=0) && fbTypingMode)
294  status->SetAutoSaveInterval(t);
295 }
296 
298 {
299  TGo4AnalysisStatus* status =
300  dynamic_cast<TGo4AnalysisStatus*> (GetLinked("Status",0));
301  if ((status!=0) && fbTypingMode)
302  status->SetAutoSaveOverwrite(overwrite);
303 }
304 
306 {
307  TGo4AnalysisStatus* status =
308  dynamic_cast<TGo4AnalysisStatus*> (GetLinked("Status",0));
309  TGo4ServerProxy* anal =
310  dynamic_cast<TGo4ServerProxy*>(GetLinked("Analysis", 0));
311 
312  if ((anal!=0) && (status!=0))
313  anal->WriteAutoSave(status->GetAutoFileName(),
314  status->GetAutoSaveCompression(),
315  status->IsAutoSaveOverwrite());
316 }
317 
319 {
320  TGo4AnalysisStatus* status =
321  dynamic_cast<TGo4AnalysisStatus*> (GetLinked("Status",0));
322  if ((status!=0) && fbTypingMode)
323  status->SetAutoSaveOn(enabled);
324  AutoSaveInterval->setEnabled(enabled);
325 }
326 
328 {
329  return TabSteps->count();
330 }
331 
333 {
334  if ((n<0) || (n>=TabSteps->count())) return 0;
335  return dynamic_cast<TGo4ConfigStep*> (TabSteps->widget(n));
336 }
337 
339 {
340  for (int n=0;n<GetNumSteps();n++) {
341  TGo4ConfigStep* conf = GetStepConfig(n);
342  if (conf!=0)
343  if (conf->GetStepName()==name) return conf;
344  }
345  return 0;
346 }
347 
349  int interval,
350  int compression,
351  bool enabled,
352  bool overwrite)
353 {
354  AutoSaveFileName->setText(filename);
355  AutoSaveInterval->setValue(interval);
356  CompLevel->setValue(compression);
357 
358  AutoSaveOverwrite->setChecked(overwrite);
359  AutoSaveEnable->setChecked(enabled);
360 
361  AutoSaveInterval->setEnabled(enabled);
362 }
363 
365  int& interval,
366  int& compression,
367  bool& enabled,
368  bool& overwrite)
369 {
370  filename = AutoSaveFileName->text();
371  interval = AutoSaveInterval->value();
372  compression = CompLevel->value();
373 
374  overwrite = AutoSaveOverwrite->isChecked();
375  enabled = AutoSaveEnable->isChecked();
376 }
377 
379 {
380  ConfigFileName->setText(filename);
381 }
382 
384 {
385  filename = ConfigFileName->text();
386 }
387 
388 void TGo4AnalysisConfiguration::DisplayMbsMonitor(const QString& mbsname )
389 {
390  ServiceCall("DisplayMbsMonitor", (void*) mbsname.toLatin1().constData());
391 }
392 
394 {
395  e->ignore(); // destroying this would mix up the upper level management
396  QWidget* mdi = parentWidget();
397  if (mdi==0) return;
398  mdi->hide(); // instead of destroying, we just hide it when X is clicked. JAM
399 }
400 
virtual void WriteAutoSave(const char *fname, Int_t complevel, Bool_t overwrite)
virtual void ResetWidget()
Definition: QGo4Widget.cpp:52
void SetAutoFileName(const char *name)
virtual bool IsAcceptDrag(const char *itemname, TClass *cl, int kind)
virtual void SetStepStatus(TGo4AnalysisConfiguration *panel, TGo4AnalysisStepStatus *StepStatus, int number=-1)
Int_t GetAutoSaveCompression() const
virtual void GetAnalysisConfigFile(QString &filename)
virtual void SaveConfigFile(const char *fname)
void ShootCloseWidget(bool closeparent=false)
Definition: QGo4Widget.cpp:70
virtual QString GetTabTitle()
const char * GetConfigFileName() const
virtual void SetAutoSaveConfig(QString filename, int interval, int compression, bool enbaled, bool overwrite)
void SetAutoSaveOn(Bool_t on=kTRUE)
TGo4ConfigStep * GetStepConfig(int n)
virtual void SetSourcePath(const QString &v)
virtual void SetAutoSaveOverwrite(bool overwrite)
TObject * GetLinked(const char *linkname, int updatelevel)
Definition: QGo4Widget.cpp:177
virtual void linkedObjectRemoved(const char *linkname)
void setCanDestroyWidget(bool on=true)
Definition: QGo4Widget.h:200
virtual Bool_t RefreshNamesList()
virtual void RequestAnalysisSettings()
const char * GetAutoFileName() const
Int_t IsAutoSaveOverwrite() const
virtual void GetAutoSaveConfig(QString &filename, int &interval, int &compression, bool &enbaled, bool &overwrite)
TGo4Slot * SettingsSlot()
virtual QString GetStepName()
void ServiceCall(const char *name, void *par=0)
Definition: QGo4Widget.cpp:405
Int_t IsAutoSaveOn() const
TGo4Slot * ParentSlot()
TGo4AnalysisStepStatus * GetStepStatus(const char *name)
virtual Bool_t CanSubmitObjects()
virtual void closeEvent(QCloseEvent *e)
TGo4AnalysisConfiguration(QWidget *parent=0, const char *name=0)
virtual void DropItem(const char *itemname, TClass *cl, int kind)
void SetAutoSaveOverwrite(Bool_t over=kTRUE)
TGo4ConfigStep * FindStepConfig(QString name)
virtual void SetStorePath(const QString &v)
virtual void EnableAutoSaveSlot(bool disabled)
void AddLink(const char *itemname, const char *linkname)
Definition: QGo4Widget.cpp:122
virtual void WorkWithAnalysis(TGo4ServerProxy *anal)
virtual void DisplayMbsMonitor(const QString &mbsname)
void SetAutoSaveInterval(Int_t i)
virtual void linkedObjectUpdated(const char *linkname, TObject *obj)
virtual void SetAnalysisConfigFile(QString filename)
void ChangeTabTitle(TGo4ConfigStep *step, int number)
void SetAutoSaveCompression(Int_t i=5)
Int_t GetAutoSaveInterval() const
virtual void LoadConfigFile(const char *fname)