GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4AnalysisConfiguration.cpp
Go to the documentation of this file.
1 // $Id: TGo4AnalysisConfiguration.cpp 1506 2015-06-10 08:27:32Z 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 für 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 "TClass.h"
18 #include "TGo4ConfigStep.h"
19 #include "TGo4AnalysisStatus.h"
20 #include "TGo4AnalysisStepStatus.h"
21 #include "TGo4ServerProxy.h"
22 #include "TGo4AnalysisProxy.h"
23 
24 
25 TGo4AnalysisConfiguration::TGo4AnalysisConfiguration(QWidget *parent, const char* name) :
26  QGo4Widget(parent, name)
27 {
28  setupUi(this);
29 
30  fSourcePath = ".";
31  fStorePath = ".";
32  fConfigPath = ".";
33  fAutoSavePath = ".";
34  fbTypingMode = true;
35  setCanDestroyWidget(false);
36 }
37 
38 
39 bool TGo4AnalysisConfiguration::IsAcceptDrag(const char* itemname, TClass* cl, int kind)
40 {
41  return false;
42 // if (cl==0) return false;
43 // return cl->InheritsFrom(TGo4AnalysisStatus::Class());
44 }
45 
46 void TGo4AnalysisConfiguration::DropItem(const char* itemname, TClass* cl, int kind)
47 {
48 // if (cl==0) return;
49 
50 // if (cl->InheritsFrom(TGo4AnalysisStatus::Class()))
51 // WorkWithStatus(itemname);
52 }
53 
54 void TGo4AnalysisConfiguration::linkedObjectUpdated(const char* linkname, TObject* obj)
55 {
56  if (strcmp(linkname,"Status")==0) {
57  parentWidget()->raise();
58  parentWidget()->show();
59  if (parentWidget()->isMinimized()) parentWidget()->showNormal();
60  RefreshWidget();
61 
62  TGo4ServerProxy* anal =
63  dynamic_cast<TGo4ServerProxy*>(GetLinked("Analysis", 0));
64  if (anal!=0)
65  anal->RefreshNamesList();
66  }
67 }
68 
70 {
71  ShootCloseWidget(true);
72 }
73 
75 {
76  ResetWidget();
77 
78  if (anal==0) {
79  ShootCloseWidget(true);
80  return;
81  }
82 
83  AddLink(anal->ParentSlot(), "Analysis");
84  AddLink(anal->SettingsSlot(), "Status");
85 
86  RefreshWidget();
87 }
88 
90 {
92 
93  QWidget* w = 0;
94  do {
95  w = TabSteps->currentWidget();
96  if (w!=0) {
97  TabSteps->removeTab(TabSteps->indexOf(w));
98  delete w;
99  }
100  } while (w!=0);
101 }
102 
104 {
105  TGo4AnalysisStatus* status =
106  dynamic_cast<TGo4AnalysisStatus*> (GetLinked("Status",0));
107  TGo4ServerProxy* anal =
108  dynamic_cast<TGo4ServerProxy*>(GetLinked("Analysis", 0));
109 
110  if ((status==0) || (anal==0)) return;
111 
112  SubmitPushButton->setEnabled(anal->CanSubmitObjects());
113  SubmitAndStartButton->setEnabled(anal->CanSubmitObjects());
114 
115  fbTypingMode = false;
116 
117  QWidget* w = 0;
118  do {
119  w = TabSteps->currentWidget();
120  if (w!=0) {
121  TabSteps->removeTab(TabSteps->indexOf(w));
122  delete w;
123  }
124  } while (w!=0);
125 
126  for(int i=0; i<status->GetNumberOfSteps(); i++) {
127  TGo4AnalysisStepStatus* stepstatus = status->GetStepStatus(i);
128  if (stepstatus==0) continue;
129  QString StepName = stepstatus->GetName();
130  TGo4ConfigStep* NewStep = new TGo4ConfigStep(TabSteps, StepName.toLatin1().constData());
131  NewStep->SetStepStatus(this, stepstatus, status->GetNumberOfSteps() > 1 ? i : -1);
132  TabSteps->insertTab(i, NewStep, NewStep->GetTabTitle());
133  }
134 
135  TabSteps->setCurrentIndex(0);
136  TabSteps->adjustSize();
137 
139  status->GetAutoSaveInterval(),
140  status->GetAutoSaveCompression(),
141  status->IsAutoSaveOn(),
142  status->IsAutoSaveOverwrite());
143 
145 
146  parentWidget()->showNormal();
147  parentWidget()->adjustSize();
148 
149  fbTypingMode = true;
150 }
151 
153 {
154  if (number>=0)
155  TabSteps->setTabText(number, step->GetTabTitle());
156 }
157 
158 
160 {
161  return fSourcePath;
162 }
163 
165 {
166  return fStorePath;
167 }
168 
170 {
171  fSourcePath = v;
172 }
173 
175 {
176  fStorePath = v;
177 }
178 
180 {
181  TGo4ServerProxy* anal =
182  dynamic_cast<TGo4ServerProxy*>(GetLinked("Analysis", 0));
183  if (anal!=0)
184  anal->RequestAnalysisSettings();
185 }
186 
188 {
189  QFileDialog fd(this,
190  "Select a configuration file",
191  fConfigPath,
192  " Configuration file (*.root)");
193  fd.setFileMode( QFileDialog::AnyFile);
194  if (fd.exec() != QDialog::Accepted) return;
195  QStringList flst = fd.selectedFiles();
196  QString fileName = flst.isEmpty() ? QString() : flst[0];
197  fConfigPath = fd.directory().path();
198  if(!fileName.endsWith(".root")) fileName.append(".root");
199  ConfigFileName->setText(fileName);
200 }
201 
203 {
204  QFileDialog fd( this,
205  "Select file name for autosaving",
207  "Auto Save File (*.root)");
208  fd.setFileMode(QFileDialog::AnyFile);
209  fd.setAcceptMode(QFileDialog::AcceptSave);
210  if (fd.exec() != QDialog::Accepted) return;
211 
212  QStringList flst = fd.selectedFiles();
213  if (flst.isEmpty()) return;
214 
215  QString fileName = flst[0];
216  fAutoSavePath = fd.directory().path();
217  if(!fileName.endsWith(".root")) fileName.append(".root");
218  AutoSaveFileName->setText(fileName);
220 }
221 
223 {
224  QString fname = AutoSaveFileName->text().trimmed();
225  TGo4AnalysisStatus* status =
226  dynamic_cast<TGo4AnalysisStatus*> (GetLinked("Status",0));
227  if ((status!=0) && fbTypingMode)
228  status->SetAutoFileName(fname.toLatin1().constData());
229 }
230 
232 {
233  TGo4AnalysisStatus* status =
234  dynamic_cast<TGo4AnalysisStatus*> (GetLinked("Status",0));
235  if ((status!=0) && fbTypingMode)
236  status->SetAutoSaveCompression(t);
237 }
238 
240 {
241  QString fname = ConfigFileName->text().trimmed();
242  TGo4ServerProxy* anal =
243  dynamic_cast<TGo4ServerProxy*>(GetLinked("Analysis", 0));
244  if (anal!=0)
245  anal->LoadConfigFile(fname.toLatin1().constData());
247 }
248 
250 {
251  QString fname = ConfigFileName->text().trimmed();
252  TGo4ServerProxy* anal =
253  dynamic_cast<TGo4ServerProxy*>(GetLinked("Analysis", 0));
254  if (anal!=0)
255  anal->SaveConfigFile(fname.toLatin1().constData());
256 }
257 
259 {
260  ServiceCall("SubmitAnalysisSettings");
261 }
262 
264 {
265  ServiceCall("SubmitStartAnalysis");
266  parentWidget()->hide();
267 }
268 
270 {
271  ServiceCall("CloseAnalysisSettings");
272 }
273 
275 {
276  TGo4AnalysisStatus* status =
277  dynamic_cast<TGo4AnalysisStatus*> (GetLinked("Status",0));
278  if ((status!=0) && fbTypingMode)
279  status->SetAutoSaveInterval(t);
280 }
281 
283 {
284  TGo4AnalysisStatus* status =
285  dynamic_cast<TGo4AnalysisStatus*> (GetLinked("Status",0));
286  if ((status!=0) && fbTypingMode)
287  status->SetAutoSaveOverwrite(overwrite);
288 }
289 
291 {
292  TGo4AnalysisStatus* status =
293  dynamic_cast<TGo4AnalysisStatus*> (GetLinked("Status",0));
294  TGo4ServerProxy* anal =
295  dynamic_cast<TGo4ServerProxy*>(GetLinked("Analysis", 0));
296 
297  if ((anal!=0) && (status!=0))
298  anal->WriteAutoSave(status->GetAutoFileName(),
299  status->GetAutoSaveCompression(),
300  status->IsAutoSaveOverwrite());
301 }
302 
304 {
305  TGo4AnalysisStatus* status =
306  dynamic_cast<TGo4AnalysisStatus*> (GetLinked("Status",0));
307  if ((status!=0) && fbTypingMode)
308  status->SetAutoSaveOn(enabled);
309  AutoSaveInterval->setEnabled(enabled);
310 }
311 
313 {
314  return TabSteps->count();
315 }
316 
318 {
319  if ((n<0) || (n>=TabSteps->count())) return 0;
320  return dynamic_cast<TGo4ConfigStep*> (TabSteps->widget(n));
321 }
322 
324 {
325  for (int n=0;n<GetNumSteps();n++) {
326  TGo4ConfigStep* conf = GetStepConfig(n);
327  if (conf!=0)
328  if (conf->GetStepName()==name) return conf;
329  }
330  return 0;
331 }
332 
334  int interval,
335  int compression,
336  bool enabled,
337  bool overwrite)
338 {
339  AutoSaveFileName->setText(filename);
340  AutoSaveInterval->setValue(interval);
341  CompLevel->setValue(compression);
342 
343  AutoSaveOverwrite->setChecked(overwrite);
344  AutoSaveEnable->setChecked(enabled);
345 
346  AutoSaveInterval->setEnabled(enabled);
347 }
348 
350  int& interval,
351  int& compression,
352  bool& enabled,
353  bool& overwrite)
354 {
355  filename = AutoSaveFileName->text();
356  interval = AutoSaveInterval->value();
357  compression = CompLevel->value();
358 
359  overwrite = AutoSaveOverwrite->isChecked();
360  enabled = AutoSaveEnable->isChecked();
361 }
362 
364 {
365  ConfigFileName->setText(filename);
366 }
367 
369 {
370  filename = ConfigFileName->text();
371 }
372 
373 void TGo4AnalysisConfiguration::DisplayMbsMonitor(const QString& mbsname )
374 {
375  ServiceCall("DisplayMbsMonitor", (void*) mbsname.toLatin1().constData());
376 }
377 
379 {
380  e->ignore(); // destroying this would mix up the upper level management
381  QWidget* mdi = parentWidget();
382  if (mdi==0) return;
383  mdi->hide(); // instead of destroying, we just hide it when X is clicked. JAM
384 }
385 
virtual void WriteAutoSave(const char *fname, Int_t complevel, Bool_t overwrite)
virtual void ResetWidget()
Definition: QGo4Widget.cpp:51
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:69
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:176
virtual void linkedObjectRemoved(const char *linkname)
void setCanDestroyWidget(bool on=true)
Definition: QGo4Widget.h:198
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:402
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:121
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)