GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ConditionEditor.cpp
Go to the documentation of this file.
1 // $Id: TGo4ConditionEditor.cpp 3120 2021-03-30 07:42:45Z 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 
14 
15 #include "TGo4ConditionEditor.h"
16 
17 #include <QMessageBox>
18 #include <QMenu>
19 #include <QtCore/QSignalMapper>
20 
21 #include "TH1.h"
22 #include "TMath.h"
23 #include "TCutG.h"
24 #include "TClass.h"
25 #include "TPad.h"
26 #include "TArrayD.h"
27 #include "TGo4Slot.h"
28 #include "TGo4WinCond.h"
29 #include "TGo4PolyCond.h"
30 #include "TGo4ShapedCond.h"
31 #include "TGo4ListCond.h"
32 #include "TGo4CondArray.h"
33 #include "TGo4ViewPanel.h"
34 #include "TGo4BrowserProxy.h"
35 #include "TGo4AnalysisProxy.h"
36 
37 
38 TGo4ConditionEditor::TGo4ConditionEditor(QWidget *parent, const char* name) :
39  QGo4Widget(parent, name)
40 {
41  setupUi(this);
42 
43  QObject::connect(CloseWin, SIGNAL(clicked()), this, SLOT(CloseMDIParentSlot()));
44  QObject::connect(UpdateCon, SIGNAL(clicked()), this, SLOT(UpdatePressed()));
45  QObject::connect(ArrayElements, SIGNAL(valueChanged(int)), this, SLOT(SelectedCond(int)));
46  QObject::connect(ResultCombo, SIGNAL(activated(int)), this, SLOT(SetResultMode(int)));
47  QObject::connect(InvertCombo, SIGNAL(activated(int)), this, SLOT(SetInvertMode(int)));
48  QObject::connect(ClearCondCount, SIGNAL(clicked()), this, SLOT(ClearCounters()));
49  QObject::connect(DisplayB, SIGNAL(clicked()), this, SLOT(DisplayPressed()));
50  QObject::connect(RefreshButton, SIGNAL(clicked()), this, SLOT(RefreshClicked()));
51  QObject::connect(Win1_low, SIGNAL(returnPressed()), this, SLOT(LimitsReturnPressed()));
52  QObject::connect(Win1_up, SIGNAL(returnPressed()), this, SLOT(LimitsReturnPressed()));
53  QObject::connect(Win2_low, SIGNAL(returnPressed()), this, SLOT(LimitsReturnPressed()));
54  QObject::connect(Win2_up, SIGNAL(returnPressed()), this, SLOT(LimitsReturnPressed()));
55  QObject::connect(Win1_low, SIGNAL(textChanged(QString)), this, SLOT(LimitsChanged(QString)));
56  QObject::connect(Win1_up, SIGNAL(textChanged(QString)), this, SLOT(LimitsChanged(QString)));
57  QObject::connect(Win2_low, SIGNAL(textChanged(QString)), this, SLOT(LimitsChanged(QString)));
58  QObject::connect(Win2_up, SIGNAL(textChanged(QString)), this, SLOT(LimitsChanged(QString)));
59  QObject::connect(CondLimits, SIGNAL(toggled(bool)), this, SLOT(SetDrawLimits(bool)));
60  QObject::connect(CondLabel, SIGNAL(toggled(bool)), this, SLOT(SetLabel(bool)));
61  QObject::connect(IntBox, SIGNAL(toggled(bool)), this, SLOT(SetIntDraw(bool)));
62  QObject::connect(MaxXBox, SIGNAL(toggled(bool)), this, SLOT(SetXMaxDraw(bool)));
63  QObject::connect(MaxYBox, SIGNAL(toggled(bool)), this, SLOT(SetYMaxDraw(bool)));
64  QObject::connect(MaxCBox, SIGNAL(toggled(bool)), this, SLOT(SetCMaxDraw(bool)));
65  QObject::connect(ArrayAllButton, SIGNAL(clicked()), this, SLOT(ArrayAll()));
66  QObject::connect(PrintLog, SIGNAL(clicked()), this, SLOT(PrintConditionLog()));
67  QObject::connect(SaveCon, SIGNAL(clicked()), this, SLOT(SaveCondition()));
68  QObject::connect(Win1_low, SIGNAL(returnPressed()), Win1_up, SLOT(selectAll()));
69  QObject::connect(Win1_up, SIGNAL(returnPressed()), Win2_low, SLOT(selectAll()));
70  QObject::connect(Win2_low, SIGNAL(returnPressed()), Win2_up, SLOT(selectAll()));
71  QObject::connect(Win2_up, SIGNAL(returnPressed()), Win1_low, SLOT(selectAll()));
72  QObject::connect(Win1_low, SIGNAL(returnPressed()), Win1_up, SLOT(setFocus()));
73  QObject::connect(Win1_up, SIGNAL(returnPressed()), Win2_low, SLOT(setFocus()));
74  QObject::connect(Win2_low, SIGNAL(returnPressed()), Win2_up, SLOT(setFocus()));
75  QObject::connect(Win2_up, SIGNAL(returnPressed()), Win1_low, SLOT(setFocus()));
76  QObject::connect(XMeanBox, SIGNAL(toggled(bool)), this, SLOT(SetXMeanDraw(bool)));
77  QObject::connect(YMeanBox, SIGNAL(toggled(bool)), this, SLOT(SetYMeanDraw(bool)));
78  QObject::connect(XRMSBox, SIGNAL(toggled(bool)), this, SLOT(SetXRMSDraw(bool)));
79  QObject::connect(YRMSBox, SIGNAL(toggled(bool)), this, SLOT(SetYRMSDraw(bool)));
80  QObject::connect(CondVisibleChk, SIGNAL(toggled(bool)), this, SLOT(SetCondVisible(bool)));
81  QObject::connect(ModifyButton, SIGNAL(clicked()), this, SLOT(ModifyButton_clicked()));
82  QObject::connect(NPointsSpin, SIGNAL(valueChanged(int)), this, SLOT(NPointsSpin_valueChanged(int)));
83  QObject::connect(CutTable, SIGNAL(cellChanged(int,int)), this, SLOT(CutTable_valueChanged(int,int)));
84  QObject::connect(CutTable, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(CutTable_contextMenuRequested(const QPoint &)));
85  QObject::connect(EllipseTiltDial, SIGNAL(valueChanged(int)), this, SLOT(EllipseTheta_valueChanged(int)));
86  QObject::connect(AutoRefreshBox, SIGNAL(toggled(bool)), this, SLOT(EllipseRefreshBox_toggled(bool)));
87  QObject::connect(EllipseA1Spinbox, SIGNAL(valueChanged(double)), this, SLOT(EllipseA1_valueChanged(double)));
88  QObject::connect(EllipseA2Spinbox, SIGNAL(valueChanged(double)), this, SLOT(EllipseA2_valueChanged(double)));
89  QObject::connect(EllipseCxSpinbox, SIGNAL(valueChanged(double)), this, SLOT(EllipseCx_valueChanged(double)));
90  QObject::connect(EllipseCySpinbox, SIGNAL(valueChanged(double)), this, SLOT(EllipseCy_valueChanged(double)));
91  QObject::connect(EllipseTiltEdit, SIGNAL(returnPressed()), this, SLOT(EllipseTheta_returnPressed()));
92  QObject::connect(EllipseNptsSpin, SIGNAL(valueChanged(int)), this, SLOT(EllipseNPoints_valueChanged(int)));
93  QObject::connect(CircleBox, SIGNAL(toggled(bool)), EllipseA2Spinbox, SLOT(setDisabled(bool)));
94  QObject::connect(CircleBox, SIGNAL(toggled(bool)), EllipseTiltDial, SLOT(setDisabled(bool)));
95  QObject::connect(CircleBox, SIGNAL(toggled(bool)), EllipseTiltEdit, SLOT(setDisabled(bool)));
96  QObject::connect(BoxshapeBox, SIGNAL(toggled(bool)), EllipseNptsSpin, SLOT(setDisabled(bool)));
97  QObject::connect(FreeshapeBox, SIGNAL(toggled(bool)), EllipseCxSpinbox, SLOT(setDisabled(bool)));
98  QObject::connect(FreeshapeBox, SIGNAL(toggled(bool)), EllipseCySpinbox, SLOT(setDisabled(bool)));
99  QObject::connect(FreeshapeBox, SIGNAL(toggled(bool)), EllipseA1Spinbox, SLOT(setDisabled(bool)));
100  QObject::connect(FreeshapeBox, SIGNAL(toggled(bool)), EllipseA2Spinbox, SLOT(setDisabled(bool)));
101  QObject::connect(FreeshapeBox, SIGNAL(toggled(bool)), EllipseTiltDial, SLOT(setDisabled(bool)));
102  QObject::connect(FreeshapeBox, SIGNAL(toggled(bool)), EllipseTiltEdit, SLOT(setDisabled(bool)));
103  QObject::connect(CircleBox, SIGNAL(clicked(bool)), this, SLOT(EllipseCircleBox_toggled(bool)));
104  QObject::connect(BoxshapeBox, SIGNAL(clicked(bool)), this, SLOT(EllipseCircleBox_toggled(bool)));
105  QObject::connect(EllipseBox, SIGNAL(clicked(bool)), this, SLOT(EllipseCircleBox_toggled(bool)));
106  QObject::connect(FreeshapeBox, SIGNAL(clicked(bool)), this, SLOT(EllipseCircleBox_toggled(bool)));
107 
108 #if QT_VERSION >= QT_VERSION_CHECK(4,6,0)
109  LCDCounts->setDigitCount(10);
110  LCDTrueCounts->setDigitCount(10);
111 #else
112  LCDCounts->setNumDigits(10);
113  LCDTrueCounts->setNumDigits(10);
114 #endif
115 
116  setWindowTitle("Condition editor");
117  ResetWidget();
118  fiSelectedIndex = -1;
119  parentWidget()->adjustSize();
120  fbDrawOnNextRefresh = false;
121  fbEllipseAutoRefresh = false;
122  fiLastChangeValue = -1;
123  CutTable->setContextMenuPolicy(Qt::CustomContextMenu);
124  fbNewWindow=true;
125 }
126 
127 
128 bool TGo4ConditionEditor::IsAcceptDrag(const char* itemname, TClass* cl, int kind)
129 {
130  if (cl==0) return false;
131  bool res = cl->InheritsFrom(TGo4Condition::Class());
132 // res = res || cl->InheritsFrom(TH1::Class());
133  return res;
134 }
135 
136 void TGo4ConditionEditor::DropItem(const char* itemname, TClass* cl, int kind)
137 {
138  if (cl==0) return;
139 
140  if (cl->InheritsFrom(TGo4Condition::Class()))
141  WorkWithCondition(itemname);
142 
143 // uncomment this to enable histogram drop on condition editor
144 
145 // else
146 // if (cl->InheritsFrom(TH1::Class()) && (fiSelectedIndex==-1)) {
147 // RemoveLink("Histogram");
148 // AddLink(itemname, "Histogram");
149 // GetLinked("Histogram", 1);
150 //
151 // TGo4Condition* cond = dynamic_cast<TGo4Condition*>(GetLinked("Condition", 0));
152 // if (cond!=0) {
153 // cond->SetHistogram(itemname);
154 // cond->SetHistogramLink(kTRUE);
155 // }
156 // CondTabs->setCurrentIndex(1);
157 // PleaseUpdateSlot();
158 // RefreshWidget();
159 // }
160 
161 }
162 
163 void TGo4ConditionEditor::linkedObjectUpdated(const char* linkname, TObject* obj)
164 {
165  if (strcmp(linkname,"Condition")==0) {
166  TGo4Condition* cond = dynamic_cast<TGo4Condition*> (obj);
167  if (cond!=0) cond->SetChanged(kFALSE);
168  }
169 
170  RefreshWidget(false);
171 }
172 
174 {
175  if (strcmp(linkname,"Condition")==0)
176  ShootCloseWidget(true);
177 }
178 
179 void TGo4ConditionEditor::WorkWithCondition(const char* itemname)
180 {
181  const char* conditemname = GetLinkedName("Condition");
182 
183  TGo4Condition* con = dynamic_cast<TGo4Condition*> (GetLinked("Condition",0));
184  if ((con!=0) && (con->IsChanged()!=0) && (strcmp(conditemname,itemname)!=0)) {
185 
186  int res = QMessageBox::warning(this, "Condition editor",
187  QString("Current condition %1 is modified!\n"
188  "New condition %2 is selected.").arg(conditemname).arg(itemname),
189  QString("Continue with current"),
190  QString("Start with new"), QString(), 0);
191 // (BrowserItemRemote(conditemname) ? QString("Update in analysis and start new") : QString()), 0);
192  if (res==0) return;
193 // if (res==2) UpdateItemInAnalysis(conditemname);
194  }
195 
196  if ((conditemname==0) || (strcmp(conditemname,itemname)!=0)) {
197  ResetWidget();
198  CondNameLbl->setText(itemname);
199  AddLink(itemname, "Condition");
200  }
201 
202  QString iconname = ":/icons/right.png";
203  QString tooltip = "Refresh condition from analysis";
204  if (!BrowserItemRemote(itemname)) {
205  iconname = ":/icons/refresh.png";
206  tooltip = "Refresh condition from source";
207  }
208  RefreshButton->setIcon( QIcon(iconname) );
209  RefreshButton->setToolTip(tooltip);
210 
211  TGo4ViewPanel* panel = WhereItemDrawn(itemname);
212 
213  if (panel==0) {
214  GetLinked("Condition", 2);
215  fbDrawOnNextRefresh = true;
216  fiSelectedIndex = -1;
217  } else {
218  TPad* pad = panel->FindPadWithItem(itemname);
220  panel->setFocus();
221  }
222 
223  RefreshWidget(false);
224  setFocus();
225 
226 }
227 
229 {
231  CondNameLbl->setText("");
232  CondClassLbl->setText("");
233 
234  PleaseUpdateLabel->setVisible(false);
235 
236  ArrayAllButton->setVisible(false);
237  ArrayElements->setVisible(false);
238 
239  HistogramChk->setVisible(false);
240  HistogramChk->setChecked(false);
241  HistogramChk->setText("null");
242  HistogramChk->setEnabled(false);
243 
244  CondVisibleChk->setVisible(false);
245  DrawInfoLbl->setText("");
246  CondTabs->setEnabled(false);
247 
248  LCDCounts->display(0);
249  LCDTrueCounts->display(0);
250 
251  Win1_low->setDisabled(true);
252  Win1_up->setDisabled(true);
253  Win2_low->setDisabled(true);
254  Win2_up->setDisabled(true);
255 
256  ResultCombo->setEnabled(false);
257  InvertCombo->setEnabled(false);
258 
259  //CondTabs->setTabEnabled(1, false);
260  //CondTabs->setTabEnabled(2, false);
261 }
262 
264 {
265  TGo4Condition* cond = dynamic_cast<TGo4Condition*>(GetLinked("Condition", 0));
266  if (cond==0) return;
267  const char* conditemname = GetLinkedName("Condition");
268  TGo4ViewPanel* panel = WhereItemDrawn(conditemname);
269  TPad* pad = panel==0 ? 0 : panel->FindPadWithItem(conditemname);
270 
271  TGo4BrowserProxy* br = Browser();
272  TGo4ServerProxy* serv = br ? br->DefineServerObject(conditemname) : 0;
273  UpdateCon->setEnabled((serv==0) || serv->CanSubmitObjects());
274 
275  PleaseUpdateLabel->setVisible(cond->IsChanged()!=0);
276  fiLastChangeValue = cond->IsChanged();
277 
278  QString hitemname;
279  TH1* histo = 0;
280  if ((panel!=0) && (pad!=0)) {
281  histo = panel->GetPadHistogram(pad);
282  hitemname = panel->GetDrawObjectLinkName(pad, histo);
283  if (checkindex) {
284  QString selname = panel->GetSelectedMarkerName(pad);
285  int selindex = panel->GetSelectedMarkerIndex(pad);
286  if (selname==cond->GetName())
287  fiSelectedIndex = selindex;
288  }
289  }
290  if (histo==0) histo = dynamic_cast<TH1*>(GetLinked("Histogram", 0));
291 
292  fbTypingMode = false;
293 
294  TGo4CondArray* arr = dynamic_cast<TGo4CondArray*> (cond);
295 
296  ArrayAllButton->setVisible(arr!=0);
297  ArrayElements->setVisible(arr!=0);
298  if (arr==0) {
299  fiSelectedIndex = -1;
300  } else {
301  ArrayElements->setMaximum(arr->GetNumber()-1);
302  if (fiSelectedIndex>=arr->GetNumber()-1)
303  fiSelectedIndex=arr->GetNumber()-1;
304  ArrayElements->setValue(fiSelectedIndex);
305 
306  cond = SelectedCondition();
307  }
308 
309  ModifyButton->setVisible((panel!=0) && ((arr==0) || (fiSelectedIndex>=0)));
310 
311  TGo4WinCond* wcond = dynamic_cast<TGo4WinCond*> (cond);
312  TGo4PolyCond* pcond = dynamic_cast<TGo4PolyCond*> (cond);
313  TGo4ShapedCond* econd = dynamic_cast<TGo4ShapedCond*> (cond);
314  TGo4ListCond* lcond = dynamic_cast<TGo4ListCond*> (cond);
315 
316  if (wcond != 0)
317  {
318  if (wcond->GetDimension() == 2)
319  CondClassLbl->setText("Win 2-D ");
320  else
321  CondClassLbl->setText("Win 1-D ");
322  }
323  else if (econd != 0)
324  {
325  if(econd->IsEllipse())
326  CondClassLbl->setText("Ellipse ");
327  else if (econd->IsCircle())
328  CondClassLbl->setText("Circle ");
329  else if (econd->IsBox())
330  CondClassLbl->setText("Box ");
331  else
332  CondClassLbl->setText("Free shape ");
333  }
334  else if (pcond != 0)
335  CondClassLbl->setText("Polygon ");
336  else if (lcond != 0)
337  CondClassLbl->setText("Value list ");
338 
339  else
340  CondClassLbl->setText("");
341 
342  QString infolbl;
343 
344  const char* hname = cond->GetLinkedHistogram();
345  if ((hname==0) || (*hname==0)) {
346  HistogramChk->setChecked(false);
347  HistogramChk->setText("null");
348  HistogramChk->setEnabled(false);
349 // DisplayB->setEnabled(false);
350  } else {
351  HistogramChk->setChecked(cond->IsHistogramLink());
352  HistogramChk->setText(hname);
353  HistogramChk->setEnabled(true);
354  infolbl = "Hist: ";
355  if (hitemname.length()>0)
356  infolbl += hitemname;
357  else
358  infolbl += hname;
359 // DisplayB->setEnabled(true);
360  }
361 
362  CondVisibleChk->setVisible(true);
363  CondVisibleChk->setChecked(cond->IsVisible());
364 
365  if (panel!=0) {
366  if (infolbl.length()>0) infolbl+=" ";
367  infolbl += "Drawn: ";
368  infolbl += panel->objectName();
369  if ((pad!=0) && (pad!=(TPad*)panel->GetCanvas())) {
370  infolbl += ", ";
371  infolbl += pad->GetName();
372  }
373  }
374  DrawInfoLbl->setText(infolbl);
375 
376  CondTabs->setEnabled(true);
377 
378  ResultCombo->setEnabled(true);
379  InvertCombo->setEnabled(true);
380 
381  if(cond->IsEnabled())
382  ResultCombo->setCurrentIndex(0);
383  else
384  if (cond->FixedResult())
385  ResultCombo->setCurrentIndex(1);
386  else
387  ResultCombo->setCurrentIndex(2);
388 
389  if(cond->IsTrue()) InvertCombo->setCurrentIndex(0);
390  else InvertCombo->setCurrentIndex(1);
391 
392  LCDCounts->display(cond->Counts());
393  LCDTrueCounts->display(cond->TrueCounts());
394 
395  double ratio = 0;
396  if (cond->Counts()>0)
397  ratio = 1.*cond->TrueCounts() / cond->Counts();
398  QString sratio;
399  if ((ratio>=0.) && (ratio<=100.))
400  sratio = QString("%1%2").arg(ratio*100,4,'f',2).arg("%");
401  else
402  sratio = "?.?? %";
403  PercentLabel->setText(sratio);
404 
405  CondLimits->setChecked(cond->IsLimitsDraw());
406  CondLabel->setChecked(cond->IsLabelDraw());
407 
408  Win1_low->setText(QString::number(cond->GetXLow()));
409  Win1_up->setText(QString::number(cond->GetXUp()));
410 
411  if (cond->GetDimension()==2) {
412  Win2_low->setText(QString::number(cond->GetYLow()));
413  Win2_up->setText(QString::number(cond->GetYUp()));
414  } else {
415  Win2_low->setText("");
416  Win2_up->setText("");
417  }
418 
419  if (wcond!=0) {
420  Win1_low->setEnabled(true);
421  Win1_up->setEnabled(true);
422  Win2_low->setEnabled(wcond->GetDimension()==2);
423  Win2_up->setEnabled(wcond->GetDimension()==2);
424  } else {
425  Win1_low->setDisabled(true);
426  Win1_up->setDisabled(true);
427  Win2_low->setDisabled(true);
428  Win2_up->setDisabled(true);
429  }
430 
431  ShowEllipseWidget(econd!=0); // hide all elements on shape tab to reduce minimum window size
432  int oldindex = CondTabs->currentIndex();
433  CondTabs->setCurrentIndex(2); // JAM: need this trick to retrieve actual tab limits with hidden icons?
434  CondTabs->setCurrentIndex(oldindex);
435 
436  if ((pcond==0) && ((CondTabs->currentIndex()==1) || (CondTabs->currentIndex()==2)))
437  CondTabs->setCurrentIndex(0); // switch to wincond defaults when changing from polycond type
438 
439  if ((econd==0) && (pcond!=0) && (CondTabs->currentIndex()==2))
440  CondTabs->setCurrentIndex(1); // switch to polycond defaults when changing from shape type
441 
442  if(lcond!=0)
443  CondTabs->setCurrentIndex(1);
444 
445  CondTabs->setTabEnabled(1, (pcond!=0 || (lcond!=0)));
446  CondTabs->setTabEnabled(2, (econd!=0));
447 
448  CondTabs->setTabEnabled(3, (lcond==0));
449  CondTabs->setTabEnabled(4, (lcond==0));
450  CondTabs->setTabEnabled(5, (lcond==0));
451 
452  if (pcond != 0)
453  {
454  FillCutWidget(pcond->GetCut(kFALSE));
455  CondTabs->setTabText(1,"Cut");
456  if (econd != 0)
457  {
458  FillEllipseWidget(econd);
459  if (fbNewWindow) CondTabs->setCurrentIndex(2);
460  }
461  else
462  {
463  if (fbNewWindow) CondTabs->setCurrentIndex(1);
464  }
465  }
466  else if (lcond !=0)
467  {
468  FillListWidget(lcond);
469  CondTabs->setTabText(1,"Values");
470  if (fbNewWindow) CondTabs->setCurrentIndex(1);
471  }
472  else
473  {
474  if (fbNewWindow) CondTabs->setCurrentIndex(0);
475  }
476 
477  IntBox->setChecked(cond->IsIntDraw());
478  MaxCBox->setChecked(cond->IsCMaxDraw());
479  MaxXBox->setChecked(cond->IsXMaxDraw());
480  MaxYBox->setChecked(cond->IsYMaxDraw());
481 
482  XMeanBox->setChecked(cond->IsXMeanDraw());
483  YMeanBox->setChecked(cond->IsYMeanDraw());
484  XRMSBox->setChecked(cond->IsXRMSDraw());
485  YRMSBox->setChecked(cond->IsYRMSDraw());
486 
487  IntBox->setText(QString("Integr: ") + QString::number(cond->GetIntegral(histo,"")));
488  MaxXBox->setText(QString("MaxX: ") + QString::number(cond->GetXMax(histo)));
489  MaxYBox->setText(QString("MaxY: ") + QString::number(cond->GetYMax(histo)));
490  MaxCBox->setText(QString("Max: ") + QString::number(cond->GetCMax(histo)));
491 
492  XMeanBox->setText(QString("XMean: ") + QString::number(cond->GetMean(histo, 1)));
493  XRMSBox->setText(QString("XRMS: ") + QString::number(cond->GetRMS(histo, 1)));
494  YMeanBox->setText(QString("YMean: ") + QString::number(cond->GetMean(histo, 2)));
495  YRMSBox->setText(QString("YRMS: ") + QString::number(cond->GetRMS(histo, 2)));
496 
497  fbTypingMode = true;
498 
499  if (fbDrawOnNextRefresh) {
500  fbDrawOnNextRefresh = false;
501  TString hitemname;
502  if ((panel==0) && HistogramChk->isChecked() &&
503  Browser()->DefineRelatedObject(conditemname, hname, hitemname))
504  DrawCondition(false);
505  }
506  fbNewWindow=false;
507 }
508 
510 {
511  TGo4Condition* cond = dynamic_cast<TGo4Condition*>(GetLinked("Condition", 0));
512  if (cond==0) return 0;
513 
514  TGo4CondArray* arr = dynamic_cast<TGo4CondArray*> (cond);
515 
516  if ((arr==0) || (fiSelectedIndex==-1))
517  {
518  if(arr) arr->SetMultiEdit(kTRUE);
519  return cond;
520  }
521  if (fiSelectedIndex<arr->GetNumber())
522  {
523  arr->SetMultiEdit(kFALSE);
525  return arr->At(fiSelectedIndex);
526  }
527  return cond;
528 }
529 
531 {
532  TGo4Condition* cond = dynamic_cast<TGo4Condition*> (GetLinked("Condition",0));
533  SetChangeFlag(true);
534  PleaseUpdateLabel->setVisible(true);
535 }
536 
538 {
539  if (!fbTypingMode) return;
540  if (fiSelectedIndex==t) return;
541 
542  fiSelectedIndex = t;
543  RefreshWidget(false);
544  RedrawCondition();
545 }
546 
548 {
549  ArrayElements->setValue(-1);
550 }
551 
553 {
555  if (!fbTypingMode || (cond==0)) return;
556  switch (mode) {
557  case 0: cond->Enable(); break;
558  case 1: cond->Disable(kTRUE); break;
559  case 2: cond->Disable(kFALSE ); break;
560  default: cond->Enable(); break;
561  }
563 }
564 
566 {
568  if (!fbTypingMode || (cond==0)) return;
569  cond->Invert(mode==1);
571 }
572 
574 {
575  const char* conditemname = GetLinkedName("Condition");
576  TGo4Condition* con = dynamic_cast<TGo4Condition*> (GetLinked("Condition",0));
577 
578  if ((con==0) || (conditemname==0)) return;
579 
580  TString objname;
581  TGo4ServerProxy* an = Browser()->DefineAnalysisObject(conditemname, objname);
582  if (an!=0) {
583  an->ClearAnalysisObject(objname.Data());
584  GetLinked("Condition", 2);
585  } else {
586  con->ResetCounts();
588  RefreshWidget(false);
589  }
590 }
591 
593 {
594  UpdateLimits();
595 }
596 
598 {
599  if (UpdateLimits())
600  RedrawCondition();
601 }
602 
604 {
606  if (!fbTypingMode || (cond==0)) return false;
607 
608  bool okx1, okx2, res = false;
609  Double_t x1 = Win1_low->text().toDouble(&okx1);
610  Double_t x2 = Win1_up->text().toDouble(&okx2);
611 
612  if (cond->GetDimension()==2) {
613  bool oky1, oky2;
614  Double_t y1 = Win2_low->text().toDouble(&oky1);
615  Double_t y2 = Win2_up->text().toDouble(&oky2);
616  if (okx1 && okx2 && oky1 && oky2) {
617  cond->SetValues(x1, x2, y1, y2);
618  res = true;
619  }
620  } else
621  if (okx1 && okx2) {
622  cond->SetValues(x1, x2);
623  res = true;
624  }
625  if (res) PleaseUpdateSlot();
626  return res;
627 }
628 
630 {
632  if (!fbTypingMode || (cond==0)) return;
633  switch(id) {
634  case 0: cond->SetLabelDraw(on); break;
635  case 1: cond->SetLimitsDraw(on); break;
636  case 2: cond->SetIntDraw(on); break;
637  case 3: cond->SetXMeanDraw(on); break;
638  case 4: cond->SetXRMSDraw(on); break;
639  case 5: cond->SetYRMSDraw(on); break;
640  case 6: cond->SetYMeanDraw(on); break;
641  case 7: cond->SetXMaxDraw(on); break;
642  case 8: cond->SetYMaxDraw(on); break;
643  case 9: cond->SetCMaxDraw(on); break;
644  case 10: cond->SetVisible(on); break;
645  default: return;
646  }
648  RedrawCondition();
649 }
650 
651 
653 {
655 }
656 
657 
659 {
661 }
662 
664 {
666 }
667 
669 {
671 }
672 
674 {
676 }
677 
679 {
681 }
682 
684 {
686 }
687 
689 {
691 }
692 
694 {
696 }
697 
699 {
701 }
702 
704 {
705  ChangeConditionProperty(10, on);
706 }
707 
708 
710 {
711  TGo4Condition* cond = dynamic_cast<TGo4Condition*>(GetLinked("Condition", 0));
712 
713  if (cond && (fiLastChangeValue != cond->IsChanged()))
714  RefreshWidget(true);
715 }
716 
718 {
719 }
720 
722 {
723  GetLinked("Condition", 2);
724  RefreshWidget(false);
725 }
726 
728 {
729  DrawCondition(true);
730 }
731 
733 {
734  TGo4Condition* cond = dynamic_cast<TGo4Condition*> (GetLinked("Condition",0));
735  if (cond) cond->SetChanged(changed);
736 }
737 
739 {
740  if (PrepareForAnalysis()) {
741  const char* conditem = GetLinkedName("Condition");
742  if (UpdateItemInAnalysis(conditem) && BrowserItemRemote(conditem))
743  RefreshClicked();
744  else {
745  SetChangeFlag(false);
746  RefreshWidget(false);
747  }
748  }
749 }
750 
752 {
753  if (PrepareForAnalysis())
754  if (SaveItemToFile(GetLinkedName("Condition"), "Conditions")) {
755  SetChangeFlag(false);
756  RefreshWidget(false);
757  }
758 }
759 
761 {
762  TGo4Condition* cond = dynamic_cast<TGo4Condition*>(GetLinked("Condition", 0));
763  if (cond==0) return;
764 
765  const char* conditemname = GetLinkedName("Condition");
766  if (conditemname==0) return;
767 
768  TGo4ViewPanel* panel = 0;
769 
770  if (useactive) panel = LastActivePanel();
771  if (panel!=0) {
772  DrawItem(conditemname, panel, 0, false, 0);
773  RedrawCondition();
774  RefreshWidget(false);
775  panel->setFocus();
776  setFocus();
777  return;
778  }
779 
780  panel = WhereItemDrawn(conditemname);
781  TPad* pad = panel==0 ? 0 : panel->FindPadWithItem(conditemname);
782 
783  if (panel!=0) {
784  if (pad!=0)
785  RedrawCondition();
786  else {
787  DrawItem(conditemname, panel, panel->GetActivePad(), false, 0);
788  panel->SetSelectedMarker(pad, cond->GetName(), fiSelectedIndex);
789  panel->MarkPadModified(pad);
790  panel->ShootRepaintTimer(pad);
791  }
792  panel->setFocus();
793  setFocus();
794  return;
795  }
796 
797  const char* hname = 0;
798  if (cond->IsHistogramLink())
799  hname = cond->GetLinkedHistogram();
800  TString hitemname;
801 
802  TGo4BrowserProxy* br = Browser();
803 
804  if (hname!=0)
805  if (br->DefineRelatedObject(conditemname, hname, hitemname)) {
806  panel = DrawItem(hitemname.Data(), 0);
807  RemoveLink("Histogram");
808  AddLink(hitemname.Data(), "Histogram");
809  DrawItem(conditemname, panel, 0, false, 0);
810  RefreshWidget(false);
811  RedrawCondition();
812  panel->setFocus();
813  setFocus();
814  }
815 }
816 
818 {
819  const char* conditemname = GetLinkedName("Condition");
820  if (conditemname==0) return;
821 
822  TGo4Condition* cond = dynamic_cast<TGo4Condition*>(GetLinked("Condition", 0));
823  if (cond==0) return;
824 
825  TGo4ViewPanel* panel = WhereItemDrawn(conditemname);
826  if (panel==0) return;
827 
828  TPad* pad = panel->FindPadWithItem(conditemname);
829  if (pad==0) return;
830 
831  panel->SetSelectedMarker(pad, cond->GetName(), fiSelectedIndex);
832  panel->MarkPadModified(pad);
833  panel->ShootRepaintTimer(pad);
834 }
835 
837 {
838  TGo4Condition* cond = dynamic_cast<TGo4Condition*>(GetLinked("Condition", 0));
839  if (cond!=0)
840  {
841  cond->PrintCondition(kFALSE); // JAM want additional output of specific infos, no poly coords
842  cond->Print("go4log-limits-stats");
843  }
844  }
845 
847 {
848  TGo4Condition* cond = dynamic_cast<TGo4Condition*>(GetLinked("Condition", 0));
849  if (cond==0) return false;
850 
851  SetChangeFlag(false);
852 
853  const char* hname = cond->GetLinkedHistogram();
854  if ((hname!=0) && (strlen(hname)!=0)) {
855  TString foldername, objname;
856  TGo4Slot::ProduceFolderAndName(hname, foldername, objname);
857  cond->SetHistogram(objname.Data());
858  }
859  return true;
860 }
861 
863 {
864  TGo4Condition* cond = dynamic_cast<TGo4Condition*>(GetLinked("Condition", 0));
865  if (cond==0) return;
866 
867  const char* conditemname = GetLinkedName("Condition");
868  TGo4ViewPanel* panel = WhereItemDrawn(conditemname);
869  TPad* pad = panel==0 ? 0 : panel->FindPadWithItem(conditemname);
870 
871  if ((panel==0) || (pad==0)) return;
872 
873  panel->SetActivePad(pad);
874 
875  panel->setFocus();
876 
877  panel->SetSelectedMarker(pad, cond->GetName(), fiSelectedIndex);
878 
879  panel->StartConditionEditing(pad);
880 }
881 
883 {
884  bool old = fbTypingMode;
885  fbTypingMode = false;
886  CutTable->setColumnCount(2);
887  if (cut==0) {
888  CutTable->setRowCount(0);
889  NPointsSpin->setValue(0);
890  } else {
891  CutTable->setRowCount(cut->GetN());
892  NPointsSpin->setValue(cut->GetN());
893  for (int n=0;n<cut->GetN();n++) {
894  Double_t x,y;
895  cut->GetPoint(n, x,y);
896  CutTable->setItem(n, 0, new QTableWidgetItem(QString::number(x)));
897  CutTable->setItem(n, 1, new QTableWidgetItem(QString::number(y)));
898  CutTable->setVerticalHeaderItem(n, new QTableWidgetItem(QString::number(n)));
899  }
900  }
901 
902  fbTypingMode = old;
903 }
904 
906 {
907  if(elli==0) return;
908  bool old = fbTypingMode;
909  fbTypingMode = false;
910  double a1=0,a2=0,x=0,y=0;
911  int theta=0;
912 
913  elli->GetRadius(a1,a2);
914  elli-> GetCenter(x,y);
915  theta= (int) elli->GetTheta();
916 
917  EllipseCxSpinbox->setValue(x);
918  EllipseCySpinbox->setValue(y);
919  EllipseA1Spinbox->setValue(a1);
920  EllipseA2Spinbox->setValue(a2);
921  EllipseTiltDial->setValue(theta);
922  EllipseTiltEdit->setText(QString::number(theta));
923 
924  CircleBox->setChecked(elli->IsCircle());
925  EllipseBox->setChecked(elli->IsEllipse());
926  BoxshapeBox->setChecked(elli->IsBox());
927  FreeshapeBox->setChecked(elli->IsFreeShape());
928  EllipseNptsSpin->setValue(elli->GetResolution());
929  fbTypingMode = old;
930 }
931 
933 {
934 
935 
936  EllipseCxSpinbox->setVisible(show);
937  EllipseCySpinbox->setVisible(show);
938  EllipseA1Spinbox->setVisible(show);
939  EllipseA2Spinbox->setVisible(show);
940  EllipseTiltDial->setVisible(show);
941  EllipseTiltEdit->setVisible(show);
942 
943  ShapegroupBox->setVisible(show);
944  CircleBox->setVisible(show);
945  EllipseBox->setVisible(show);
946  BoxshapeBox->setVisible(show);
947  FreeshapeBox->setVisible(show);
948  EllipseNptsSpin->setVisible(show);
949 
950  AutoRefreshBox->setVisible(show);
951  EllipseCenterLabel->setVisible(show);
952  EllipseTitlLabel->setVisible(show);
953  EllipseRadiusLabel->setVisible(show);
954  EllipseNptsLabel->setVisible(show);
955  EllipsCxLabel->setVisible(show);
956  EllipsCyLabel->setVisible(show);
957  EllipsA1Label->setVisible(show);
958  EllipsA2Label->setVisible(show);
959 
960  verticalLayout_2->setEnabled(show);
961  verticalLayout_5->setEnabled(show);
962  horizontalLayout_4->setEnabled(show);
963 
964 }
965 
967 {
968  bool old = fbTypingMode;
969  fbTypingMode = false;
970  CutTable->setColumnCount(1);
971  if (lcon==0) {
972  CutTable->setRowCount(0);
973  NPointsSpin->setValue(0);
974  } else {
975  int points=lcon->GetNumValues();
976  CutTable->setRowCount(points);
977  NPointsSpin->setValue(points);
978  for (int n=0;n<points;n++) {
979  int val=lcon->GetValue(n);
980  CutTable->setItem(n, 0, new QTableWidgetItem(QString::number(val)));
981  //CutTable->setItem(n, 1, new QTableWidgetItem(QString::number(y)));
982  CutTable->setVerticalHeaderItem(n, new QTableWidgetItem(QString::number(n)));
983  }
984  }
985 
986  fbTypingMode = old;
987 }
988 
989 
991 {
992  if (!fbTypingMode) return;
993  //printf ("NPointsSpin_valueChanged with npoint= %d \n",npoint);
994  TGo4PolyCond* pcond = dynamic_cast<TGo4PolyCond*> (SelectedCondition());
995  TGo4ListCond* lcond = dynamic_cast<TGo4ListCond*> (SelectedCondition());
996  if (pcond)
997  {
998  TCutG* cut = pcond->GetCut(kFALSE);
999 
1000  if (cut==0) {
1001  cut = new TCutG("conditioncut", npoint);
1002  Double_t x=0., y=0.;
1003  for (int n=0;n<npoint-1; n++)
1004  cut->SetPoint(n, n*10, n*10);
1005  cut->GetPoint(0, x, y);
1006  cut->SetPoint(npoint-1, x, y);
1007  pcond->SetValues(cut);
1008  } else {
1009  if (npoint==0) {
1010  pcond->SetValues(0);
1011  cut = 0;
1012  } else {
1013  int old = cut->GetN();
1014  Double_t x=0., y=0.;
1015  if (old>1) cut->GetPoint(old-2, x, y);
1016  cut->Set(npoint);
1017  for(int n= (old-1>=0 ? old-1 : 0); n<npoint-1; n++)
1018  cut->SetPoint(n, x, y+(n-old+2)*10);
1019  cut->GetPoint(0, x, y);
1020  cut->SetPoint(npoint-1, x, y);
1021  }
1022  }
1023  PleaseUpdateSlot();
1024  FillCutWidget(cut);
1025 
1026 
1027  }
1028  else if(lcond)
1029  {
1030  lcond->Resize(npoint);
1031  PleaseUpdateSlot();
1032  FillListWidget(lcond);
1033  }
1034  RedrawCondition();
1035 }
1036 
1038 {
1039  if (!fbTypingMode) return;
1040  //printf ("CutTable_valueChanged\n");
1041  TGo4PolyCond* pcond = dynamic_cast<TGo4PolyCond*> (SelectedCondition());
1042  TGo4ListCond* lcond = dynamic_cast<TGo4ListCond*> (SelectedCondition());
1043  bool ok;
1044  double zn = CutTable->item(nrow, ncol)->text().toDouble(&ok);
1045  if (!ok) return;
1046 
1047  if(pcond)
1048  {
1049  TCutG* cut = pcond==0 ? 0 : pcond->GetCut(kFALSE);
1050  if (cut==0) return;
1051  if (ncol==0) cut->GetX()[nrow] = zn;
1052  else cut->GetY()[nrow] = zn;
1053  if ((nrow==0) || (nrow==cut->GetN()-1)) {
1054  int nrow1 = (nrow==0) ? cut->GetN()-1 : 0;
1055  fbTypingMode = false;
1056  CutTable->setItem(nrow1, ncol, new QTableWidgetItem(CutTable->item(nrow, ncol)->text()));
1057  if (ncol==0) cut->GetX()[nrow1] = zn;
1058  else cut->GetY()[nrow1] = zn;
1059  fbTypingMode = true;
1060  }
1061  }
1062  else if (lcond)
1063  {
1064  // printf ("CutTable_valueChanged- listcondition for row %d and value %f\n",nrow,zn);
1065  lcond->SetValue(nrow,zn);
1066  int numvals=lcond->GetNumValues();
1067  if ((nrow==0) || (nrow==numvals-1)) {
1068  int nrow1 = (nrow==0) ? numvals-1 : 0;
1069  fbTypingMode = false;
1070  CutTable->setItem(nrow1, ncol, new QTableWidgetItem(CutTable->item(nrow, ncol)->text()));
1071  lcond->SetValue(nrow1,zn);
1072  fbTypingMode = true;
1073  }
1074  }
1075  else
1076  {
1077  return;
1078  }
1079 
1080 
1081  PleaseUpdateSlot();
1082 
1083  RedrawCondition();
1084 }
1085 
1086 
1088 {
1089  if (!fbTypingMode) return;
1090  //printf ("CutTable_contextMenuRequested \n");
1091  QTableWidgetItem* item = CutTable->itemAt (pos);
1092  if (item==0) return;
1093  TGo4PolyCond* pcond = dynamic_cast<TGo4PolyCond*> (SelectedCondition());
1094  TGo4ListCond* lcond = dynamic_cast<TGo4ListCond*> (SelectedCondition());
1095  if((pcond==0) && (lcond == 0)) return;
1096 
1097 
1098  int maxn=0;
1099  if(pcond)
1100  {
1101  TCutG* cut = pcond->GetCut(kFALSE);
1102  if (cut==0)return;
1103  maxn=cut->GetN();
1104  // only internal points should be allowed to deleted
1105  }
1106  else if(lcond)
1107  {
1108  maxn=lcond->GetNumValues();
1109  }
1110  else
1111  {
1112  return;
1113  }
1114  int nrow = CutTable->row(item);
1115  QMenu menu(this);
1116  QSignalMapper map(this);
1117  AddIdAction(&menu, &map, "Insert point", nrow);
1118  AddIdAction(&menu, &map, "Delete point", nrow+1000000, (nrow>0) && (nrow<maxn-1));
1119  connect(&map, SIGNAL(mapped(int)), this, SLOT(ContextMenuSlot(int)));
1120  menu.exec(CutTable->mapToGlobal(pos));
1121 }
1122 
1124 {
1125  TGo4PolyCond* pcond = dynamic_cast<TGo4PolyCond*> (SelectedCondition());
1126  TGo4ListCond* lcond = dynamic_cast<TGo4ListCond*> (SelectedCondition());
1127 
1128  if(pcond)
1129  {
1130  TCutG* cut = pcond==0 ? 0 : pcond->GetCut(kFALSE);
1131  if (cut==0) return;
1132 
1133  if (id>=1000000) { // delete point
1134  id-=1000000;
1135  cut->RemovePoint(id);
1136  } else { // insert point
1137  Int_t npoints = cut->GetN();
1138  if (id>=npoints) return;
1139  cut->Set(npoints+1);
1140 
1141  Double_t x,y;
1142 
1143  for(int n=npoints;n>id;n--) {
1144  cut->GetPoint(n-1, x, y);
1145  cut->SetPoint(n, x, y);
1146  }
1147 
1148  if (id>0) {
1149  Double_t x1, y1;
1150  cut->GetPoint(id-1, x1, y1);
1151  cut->SetPoint(id, (x1+x)/2., (y+y1)/2.);
1152  }
1153  }
1154 
1155  FillCutWidget(cut);
1156 
1157  }
1158  else if(lcond)
1159  {
1160  if (id>=1000000) { // delete point
1161  id-=1000000;
1162  lcond->RemoveValue(id);
1163  } else { // insert point
1164  Int_t npoints = lcond->GetNumValues();
1165  if (id>=npoints) return;
1166  int x1=lcond->GetValue(id);
1167  int x2=lcond->GetValue(id-1);
1168  lcond->InsertValue(id,((x1+x2)/2));
1169  }
1170  FillListWidget(lcond);
1171  }
1172  PleaseUpdateSlot();
1173  RedrawCondition();
1174 }
1175 
1176 
1177 
1179 {
1180  if (!fbTypingMode) return;
1181  //std::cout <<"EllipseTheta_valueChanged to "<< deg << std::endl;
1182  EllipseTiltEdit->setText(QString::number(deg));
1184  {
1185  TGo4ShapedCond* econd = dynamic_cast<TGo4ShapedCond*> (SelectedCondition());
1186  if(econd) econd->SetTheta((double) deg);
1187  PleaseUpdateSlot();
1188  RedrawCondition();
1189  }
1190 
1191 }
1192 
1193 
1195 {
1196  if (!fbTypingMode) return;
1197  //std::cout <<"EllipseCx_valueChanged to "<< x << std::endl;
1199  {
1200  TGo4ShapedCond* econd = dynamic_cast<TGo4ShapedCond*> (SelectedCondition());
1201  if(econd) {
1202  double y=EllipseCySpinbox->value();
1203  econd->SetCenter(x, y);
1204  PleaseUpdateSlot();
1205  RedrawCondition();
1206  }
1207  }
1208 }
1210 {
1211  if (!fbTypingMode) return;
1212  //std::cout <<"EllipseCy_valueChanged to "<< y << std::endl;
1214  {
1215  TGo4ShapedCond* econd = dynamic_cast<TGo4ShapedCond*> (SelectedCondition());
1216  if(econd) {
1217  double x=EllipseCxSpinbox->value();
1218  econd->SetCenter(x,y);
1219  }
1220  PleaseUpdateSlot();
1221  RedrawCondition();
1222  }
1223 }
1224 
1225 
1227 {
1228  if (!fbTypingMode) return;
1229  //std::cout <<"EllipseA1_valueChanged to "<< r1 << std::endl;
1231 }
1232 
1234 {
1235  if (!fbTypingMode) return;
1236  //std::cout <<"EllipseA2_valueChanged to "<< r2 << std::endl;
1238 }
1239 
1240 
1242 {
1243  if (!fbTypingMode) return;
1244  //std::cout <<"EllipseRefreshBox_toggled "<< on<< std::endl;
1247 
1248 
1249 }
1250 
1251 
1253 {
1254  if (!fbTypingMode) return;
1255  //std::cout <<"EllipseCircleBox_toggled "<< on<< std::endl;
1257 
1258 
1259 }
1260 
1261 
1263 {
1264  if (!fbTypingMode) return;
1265  //std::cout <<"EllipseTheta_returnPressed() "<< std::endl;
1266  bool ok = false;
1267  Int_t theta = EllipseTiltEdit->text().toInt(&ok);
1268  if(theta<0) theta=0;
1269  theta = theta % 360;
1270  if(ok)
1271  {
1272  EllipseTiltDial->setValue(theta);
1273  }
1275 
1276 }
1277 
1279 {
1280  if (!fbTypingMode) return;
1281  //std::cout <<"EllipseNPoints_valueChanged "<< std::endl;
1283 }
1284 
1285 
1287 {
1288 
1289  TGo4ShapedCond* econd = dynamic_cast<TGo4ShapedCond*> (SelectedCondition());
1290  if(econd==0){
1291  std::cout <<"UpdateEllipse did not find ellipse condition!!!"<< std::endl;
1292  return;
1293  }
1294 
1295 
1296 
1297  if (FreeshapeBox->isChecked())
1298  {
1299  econd->SetFreeShape();
1300  }
1301  else
1302  {
1303  double cx = EllipseCxSpinbox->value();
1304  double cy = EllipseCySpinbox->value();
1305  double a1 = EllipseA1Spinbox->value();
1306  double a2 = EllipseA2Spinbox->value();
1307  double th = EllipseTiltDial->value();
1308  if(econd->IsFreeShape())
1309  {
1310  // transition from free shape to other form: use polygon geometry to init pars:
1311  cx= (econd->GetXUp() + econd->GetXLow())/2; // mean of coordinates is center
1312  cy= (econd->GetYUp() + econd->GetYLow())/2;
1313  //a1=(econd->GetXUp() - econd->GetXLow())/2; // half diameter is radius
1314  //a2=(econd->GetYUp() - econd->GetYLow())/2;
1315  // better: use minimum and maximum radial distance
1316  TCutG* cut=econd->GetCut(false);
1317  Int_t n = cut->GetN();
1318  Double_t* xarr=cut->GetX();
1319  Double_t* yarr=cut->GetY();
1320  TArrayD rarr(n);
1321  for (int i=0; i<n; ++i)
1322  {
1323  rarr[i]= TMath::Sqrt(TMath::Power((xarr[i]-cx),2) + TMath::Power((yarr[i]-cy),2));
1324  }
1325  Int_t nrmax=TMath::LocMax(n,rarr.GetArray());
1326  Int_t nrmin=TMath::LocMin(n,rarr.GetArray());
1327  a1=rarr[nrmax];
1328  a2=rarr[nrmin];
1329  // now evaluate angle:
1330  th=0;
1331  if(a1){
1332  th= TMath::ACos((econd->GetXUp() - cx)/a1) * 180/TMath::Pi();
1333  }
1334  }
1335 
1336 
1337  if (CircleBox->isChecked())
1338  econd->SetCircle(cx, cy, a1, EllipseNptsSpin->value());
1339  else if (EllipseBox->isChecked())
1340  econd->SetEllipse(cx, cy, a1, a2, th, EllipseNptsSpin->value());
1341  else if (BoxshapeBox->isChecked())
1342  {
1343  if (econd->IsFreeShape())
1344  {
1345  // transition to box will use different defaults for extensions, otherwise we always get increasing box
1346  a1 = (econd->GetXUp() - econd->GetXLow()) / 2; // half diameter is radius
1347  a2 = (econd->GetYUp() - econd->GetYLow()) / 2;
1348  th = 0; // todo: correctly conserve tilt angle when switching to/fro between free and box
1349  }
1350 
1351  econd->SetBox(cx, cy, a1, a2, th);
1352  }
1353  } // no freeshape selected
1354  PleaseUpdateSlot();
1355  RedrawCondition();
1356  FillEllipseWidget(econd);
1357 }
virtual void ShootRepaintTimer()
virtual Bool_t IsXRMSDraw()
virtual void ResetWidget()
Definition: QGo4Widget.cpp:52
void SetTheta(Double_t angle)
Bool_t IsHistogramLink()
virtual void SetYMeanDraw(bool on)
virtual void LimitsReturnPressed()
void GetRadius(Double_t &a1, Double_t &a2)
virtual Bool_t IsLimitsDraw()
virtual void SetIntDraw(Bool_t on)
void SetEllipse(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta=0, Int_t npoints=0)
virtual void enterEvent(QEvent *)
virtual Double_t GetXUp()
virtual Double_t GetRMS(TH1 *, Int_t=1)
bool UpdateItemInAnalysis(const char *itemname, TObject *obj=0)
Definition: QGo4Widget.cpp:386
virtual Bool_t IsCMaxDraw()
virtual const char * GetDrawObjectLinkName(TPad *pad, TObject *obj)
virtual void SelectedCond(int t)
Bool_t IsCircle() const
virtual void SetYMaxDraw(Bool_t on)
virtual void RefreshWidget(bool checkindex)
virtual void SetActivePad(TPad *pad)
virtual void PrintConditionLog()
virtual Bool_t IsIntDraw()
void RemoveValue(UInt_t ix)
Definition: TGo4ListCond.h:60
Bool_t IsFreeShape() const
void ShootCloseWidget(bool closeparent=false)
Definition: QGo4Widget.cpp:70
virtual QString GetSelectedMarkerName(TPad *pad)
virtual void StartConditionEditing(TPad *pad)
virtual Int_t IsChanged()
virtual void SetCMaxDraw(Bool_t on)
virtual void SetXMeanDraw(bool on)
virtual void leaveEvent(QEvent *)
void InsertValue(UInt_t ix, Int_t val)
Definition: TGo4ListCond.h:56
virtual void SetChangeFlag(bool changed)
virtual Double_t GetYUp()
TObject * GetLinked(const char *linkname, int updatelevel)
Definition: QGo4Widget.cpp:177
Int_t GetDimension()
virtual void EllipseTheta_valueChanged(int deg)
virtual void PrintCondition(Bool_t full=kTRUE)
virtual bool PrepareForAnalysis()
virtual void SetYRMSDraw(Bool_t on)
virtual Bool_t IsVisible()
virtual void EllipseNPoints_valueChanged(int npoint)
TGo4ServerProxy * DefineServerObject(const char *itemname, TString *objname=0, Bool_t onlyanalysis=kTRUE)
Bool_t IsEnabled() const
Definition: TGo4Condition.h:82
virtual Bool_t IsLabelDraw()
virtual void EllipseA1_valueChanged(double r1)
Bool_t IsEllipse() const
Int_t GetResolution()
virtual void SetValues()
Definition: TGo4Condition.h:93
virtual TGo4Condition * SelectedCondition()
virtual void SetYRMSDraw(bool on)
Bool_t IsBox() const
void SetCenter(Double_t x, Double_t y)
virtual void SetXMeanDraw(Bool_t on)
virtual void SetYMaxDraw(bool on)
const char * GetLinkedName(const char *linkname)
Definition: QGo4Widget.cpp:158
virtual void ChangeConditionProperty(int id, bool on)
virtual Double_t GetIntegral(TH1 *, Option_t *="")
virtual void SetIntDraw(bool on)
virtual void ShowEllipseWidget(bool show)
virtual void linkedObjectRemoved(const char *linkname)
virtual Double_t GetXLow()
TGo4BrowserProxy * Browser()
Definition: QGo4Widget.cpp:224
virtual void FillListWidget(TGo4ListCond *lcon)
virtual void ResetCounts()
virtual void ClearAnalysisObject(const char *fullpath)
Bool_t FixedResult() const
virtual void LimitsChanged(const QString &)
virtual void EllipseCircleBox_toggled(bool on)
virtual bool IsAcceptDrag(const char *itemname, TClass *cl, int kind)
virtual void SetValues(Double_t *x, Double_t *y, Int_t len)
virtual void SetInvertMode(int mode)
TCutG * GetCut(Bool_t changeowner)
virtual void Enable()
virtual void RedrawCondition()
virtual void ModifyButton_clicked()
virtual Bool_t IsYMaxDraw()
virtual Double_t GetYUp()
bool BrowserItemRemote(const char *itemname)
Definition: QGo4Widget.cpp:217
virtual void SetXMaxDraw(Bool_t on)
Int_t GetValue(UInt_t ix) const
Definition: TGo4ListCond.h:49
virtual void SetSelectedMarker(TPad *pad, const QString &selname, int selindex)
void SetValue(UInt_t ix, Int_t val)
Definition: TGo4ListCond.h:51
virtual void ContextMenuSlot(int)
void RemoveLink(const char *linkname, bool blockreset=true)
Definition: QGo4Widget.cpp:193
virtual void MarkPadModified(TPad *pad)
virtual void EllipseCy_valueChanged(double y)
TGo4ViewPanel * DrawItem(const QString &itemname, TGo4ViewPanel *panel=0, TPad *pad=0, bool activate=true, int updatelevel=-1)
Definition: QGo4Widget.cpp:312
virtual void Print(Option_t *opt="") const
virtual void DrawCondition(bool useactive)
void SetCircle(Double_t cx, Double_t cy, Double_t r, Int_t npoints=0)
virtual Bool_t IsXMeanDraw()
virtual void SetCMaxDraw(bool on)
virtual TPad * FindPadWithItem(const char *itemname)
void SetHistogram(const char *name)
Bool_t IsTrue() const
virtual void SetXRMSDraw(bool on)
virtual void Disable(Bool_t result)
virtual Bool_t IsXMaxDraw()
virtual Bool_t CanSubmitObjects()
Bool_t DefineRelatedObject(const char *itemname, const char *objectname, TString &objectitem, Int_t mask=3)
TGo4ConditionEditor(QWidget *parent=0, const char *name=0)
virtual void FillCutWidget(TCutG *cut)
virtual int GetSelectedMarkerIndex(TPad *pad)
virtual Double_t GetYLow()
virtual void SetXRMSDraw(Bool_t on)
virtual void SetLimitsDraw(Bool_t on)
void SetMultiEdit(Bool_t on)
virtual void CutTable_valueChanged(int ncol, int nrow)
TGo4ViewPanel * LastActivePanel()
Definition: QGo4Widget.cpp:345
virtual Bool_t IsYMeanDraw()
virtual Bool_t IsYRMSDraw()
static QAction * AddIdAction(QMenu *menu, QSignalMapper *map, const QString &text, int id, int enabled=-1, int checked=-1)
Definition: QGo4Widget.cpp:422
virtual void EllipseRefreshBox_toggled(bool on)
static void ProduceFolderAndName(const char *fullname, TString &foldername, TString &objectname)
Definition: TGo4Slot.cxx:664
virtual void EllipseTheta_returnPressed()
virtual void EllipseA2_valueChanged(double r2)
virtual void SetChanged(Bool_t on=kTRUE)
virtual TH1 * GetPadHistogram(TPad *pad)
TGo4ViewPanel * WhereItemDrawn(const char *itemname)
Definition: QGo4Widget.cpp:323
virtual void FillEllipseWidget(TGo4ShapedCond *elli)
virtual void EllipseCx_valueChanged(double x)
Double_t GetTheta()
virtual Double_t GetMean(TH1 *, Int_t=1)
virtual Double_t GetYMax(TH1 *)
virtual void SetDrawLimits(bool on)
virtual void SetLabel(bool on)
virtual void PleaseUpdateSlot()
TGo4ServerProxy * DefineAnalysisObject(const char *itemname, TString &analysisname)
bool SaveItemToFile(const char *itemname, const char *subfolder=0)
Definition: QGo4Widget.cpp:375
virtual void SetXMaxDraw(bool on)
virtual void NPointsSpin_valueChanged(int npoint)
void AddLink(const char *itemname, const char *linkname)
Definition: QGo4Widget.cpp:122
TGo4Condition * At(Int_t i)
virtual void SetResultMode(int mode)
virtual void SetCurrentIndex(Int_t ix)
void SetBox(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta=0)
const char * GetLinkedHistogram()
virtual void SetYMeanDraw(Bool_t on)
virtual void SetCondVisible(bool on)
virtual Int_t TrueCounts()
virtual void linkedObjectUpdated(const char *linkname, TObject *obj)
virtual Int_t Counts()
virtual TPad * GetActivePad()
void Resize(size_t newsize)
Definition: TGo4ListCond.h:62
virtual Double_t GetXLow()
virtual Double_t GetXUp()
virtual void CutTable_contextMenuRequested(const QPoint &)
virtual void DropItem(const char *itemname, TClass *cl, int kind)
virtual TCanvas * GetCanvas()
virtual void SetLabelDraw(Bool_t on)
UInt_t GetNumValues() const
Definition: TGo4ListCond.h:48
Int_t GetNumber() const
virtual void SetVisible(Bool_t on)
virtual void WorkWithCondition(const char *itemname)
virtual Double_t GetCMax(TH1 *)
virtual void Invert(Bool_t on)
void CloseMDIParentSlot()
Definition: QGo4Widget.cpp:79
virtual Double_t GetXMax(TH1 *)
virtual Double_t GetYLow()