GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4CreateNewCondition.cpp
Go to the documentation of this file.
1 // $Id: TGo4CreateNewCondition.cpp 2761 2020-04-16 13:36:13Z 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 #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.length()==0) return 0;
38 
39  const char* cname = ba.constData();
40  int arrsize = ArraySizeSpin->value();
41  int ctype = ClassnameCombo->currentIndex();
42 
43  TGo4Condition* cond = 0;
44 
45  if (arrsize>1 && ctype!=3) {
46  TGo4CondArray* arr = 0;
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!=0)
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==0) continue;
65  if (ctype==0)
66  wcond->SetValues(0.,100.);
67  else
68  wcond->SetValues(0.,100.,0.,100.);
69  }
70  }
71  cond = arr;
72  } else
73 
74  switch (ctype) {
75  case 0: {
76  TGo4WinCond* wcond = new TGo4WinCond(cname, "1-D window condition");
77  wcond->SetValues(0.,100.);
78  cond = wcond;
79  break;
80  }
81  case 1: {
82  TGo4WinCond* wcond = new TGo4WinCond(cname, "2-D window condition");
83  wcond->SetValues(0.,100.,0.,100.);
84  cond = wcond;
85  break;
86  }
87  case 2: {
88  TGo4PolyCond* pcond = new TGo4PolyCond(cname, "Polygon condition");
89  Double_t xx[5] = {0, 100, 100, 0, 0};
90  Double_t yy[5] = {0, 0, 100, 100, 0};
91  pcond->SetValues(xx, yy, 5);
92  cond = pcond;
93  break;
94  }
95  case 3: {
96  TGo4ShapedCond* econd = new TGo4ShapedCond(cname, "Shaped condition");
97  econd->SetEllipse(50,50,50,50,0,32);
98  cond = econd;
99  break;
100  }
101  }
102 
103  if(cond!=0)
104  cond->Enable();
105 
106  return cond;
107 }
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)