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