GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4CreateNewCondition.cpp
Go to the documentation of this file.
1 // $Id$
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 #include "TGo4CreateNewCondition.h"
15 
16 #include "TGo4WinCond.h"
17 #include "TGo4PolyCond.h"
18 #include "TGo4ShapedCond.h"
19 #include "TGo4CondArray.h"
20 
22  : QDialog( parent )
23 
24 {
25  setObjectName("Go4CreateNewCondition");
26  setupUi(this);
27  setAcceptDrops(false);
28  CondName->setText("new_cond");
29  ClassnameCombo->setCurrentIndex(0);
30  ArraySizeSpin->setValue(1);
31 }
32 
34 {
35  QByteArray ba = CondName->text().toLatin1();
36 
37  if (ba.isEmpty()) return nullptr;
38 
39  const char *cname = ba.constData();
40  int arrsize = ArraySizeSpin->value();
41  int ctype = ClassnameCombo->currentIndex();
42 
43  TGo4Condition *cond = nullptr;
44 
45  if (arrsize>1 && ctype!=3) {
46  TGo4CondArray* arr = nullptr;
47  if (ctype == 2) {
48  arr = new TGo4CondArray(cname, arrsize, "TGo4PolyCond");
49  for (int n = 0; n < arrsize; n++) {
50  TGo4PolyCond *pcond = dynamic_cast<TGo4PolyCond *>(arr->At(n));
51  Double_t xx[5] = {0, 100, 100, 0, 0};
52  Double_t yy[5] = {0, 0, 100, 100, 0};
53  for (int indx = 0; indx < 5; indx++) {
54  xx[indx] += n * 20.;
55  yy[indx]+=n*20.;
56  }
57  if (pcond)
58  pcond->SetValues(xx, yy, 5);
59  }
60  } else {
61  arr = new TGo4CondArray(cname, arrsize, "TGo4WinCond");
62  for (int n = 0; n < arrsize; n++) {
63  TGo4WinCond *wcond = dynamic_cast<TGo4WinCond *>(arr->At(n));
64  if (!wcond)
65  continue;
66  if (ctype == 0)
67  wcond->SetValues(0., 100.);
68  else
69  wcond->SetValues(0., 100., 0., 100.);
70  }
71  }
72  cond = arr;
73  } else
74 
75  switch (ctype) {
76  case 0: {
77  TGo4WinCond *wcond = new TGo4WinCond(cname, "1-D window condition");
78  wcond->SetValues(0.,100.);
79  cond = wcond;
80  break;
81  }
82  case 1: {
83  TGo4WinCond *wcond = new TGo4WinCond(cname, "2-D window condition");
84  wcond->SetValues(0.,100.,0.,100.);
85  cond = wcond;
86  break;
87  }
88  case 2: {
89  TGo4PolyCond *pcond = new TGo4PolyCond(cname, "Polygon condition");
90  Double_t xx[5] = {0, 100, 100, 0, 0};
91  Double_t yy[5] = {0, 0, 100, 100, 0};
92  pcond->SetValues(xx, yy, 5);
93  cond = pcond;
94  break;
95  }
96  case 3: {
97  TGo4ShapedCond *econd = new TGo4ShapedCond(cname, "Shaped condition");
98  econd->SetEllipse(50,50,50,50,0,32);
99  cond = econd;
100  break;
101  }
102  }
103 
104  if(cond)
105  cond->Enable();
106 
107  return cond;
108 }
void SetEllipse(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta=0, Int_t npoints=0)
TGo4CreateNewCondition(QWidget *parent=nullptr)
void SetValues(Double_t *x, Double_t *y, Int_t len) override
void SetValues(Double_t low1, Double_t up1) override
virtual void Enable()
TGo4Condition * At(Int_t i) const