00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 void TGo4CreateNewCondition::init()
00018 {
00019 setAcceptDrops(FALSE);
00020 CondName->setText("new_cond");
00021 ClassnameCombo->setCurrentItem(0);
00022 ArraySizeSpin->setValue(1);
00023 }
00024
00025 TGo4Condition* TGo4CreateNewCondition::MakeCondition()
00026 {
00027 const char* cname = CondName->text().latin1();
00028 int arrsize = ArraySizeSpin->value();
00029 int ctype = ClassnameCombo->currentItem();
00030
00031 if ((cname==0) || (*cname==0)) return 0;
00032 TGo4Condition* cond = 0;
00033
00034 if (arrsize>1) {
00035 TGo4CondArray* arr = 0;
00036 if (ctype==2) {
00037 arr = new TGo4CondArray(cname, arrsize, "TGo4PolyCond");
00038 for (int n=0;n<arrsize;n++) {
00039 TGo4PolyCond* pcond = dynamic_cast<TGo4PolyCond*> (arr->At(n));
00040 Double_t xx[5] = {0, 100, 100, 0, 0};
00041 Double_t yy[5] = {0, 0, 100, 100, 0};
00042 for(int indx=0;indx<5;indx++) {
00043 xx[indx]+=n*20.;
00044 yy[indx]+=n*20.;
00045 }
00046 if (pcond!=0)
00047 pcond->SetValues(xx, yy, 5);
00048 }
00049 } else {
00050 arr = new TGo4CondArray(cname, arrsize, "TGo4WinCond");
00051 for (int n=0;n<arrsize;n++) {
00052 TGo4WinCond* wcond = dynamic_cast<TGo4WinCond*> (arr->At(n));
00053 if (wcond==0) continue;
00054 if (ctype==0)
00055 wcond->SetValues(0.,100.);
00056 else
00057 wcond->SetValues(0.,100.,0.,100.);
00058 }
00059 }
00060 cond = arr;
00061 } else
00062
00063 switch (ctype) {
00064 case 0: {
00065 TGo4WinCond* wcond = new TGo4WinCond(cname, "1-D window condition");
00066 wcond->SetValues(0.,100.);
00067 cond = wcond;
00068 break;
00069 }
00070 case 1: {
00071 TGo4WinCond* wcond = new TGo4WinCond(cname, "2-D window condition");
00072 wcond->SetValues(0.,100.,0.,100.);
00073 cond = wcond;
00074 break;
00075 }
00076 case 2: {
00077 TGo4PolyCond* pcond = new TGo4PolyCond(cname, "Polygon condition");
00078 Double_t xx[5] = {0, 100, 100, 0, 0};
00079 Double_t yy[5] = {0, 0, 100, 100, 0};
00080 pcond->SetValues(xx, yy, 5);
00081 cond = pcond;
00082 break;
00083 }
00084 }
00085
00086 if(cond!=0)
00087 cond->Enable();
00088
00089 return cond;
00090 }
00091
00092