Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4CreateNewCondition.h"
00015
00016 #include "TGo4Condition.h"
00017 #include "TGo4WinCond.h"
00018 #include "TGo4PolyCond.h"
00019 #include "TGo4CondArray.h"
00020
00021
00022 TGo4CreateNewCondition::TGo4CreateNewCondition( QWidget* parent)
00023 : QDialog( parent )
00024
00025 {
00026 setObjectName("Go4CreateNewCondition");
00027 setupUi(this);
00028 setAcceptDrops(false);
00029 CondName->setText("new_cond");
00030 ClassnameCombo->setCurrentIndex(0);
00031 ArraySizeSpin->setValue(1);
00032 }
00033
00034 TGo4Condition* TGo4CreateNewCondition::MakeCondition()
00035 {
00036 QByteArray ba = CondName->text().toLatin1();
00037
00038 if (ba.length()==0) return 0;
00039
00040 const char* cname = ba.constData();
00041 int arrsize = ArraySizeSpin->value();
00042 int ctype = ClassnameCombo->currentIndex();
00043
00044 TGo4Condition* cond = 0;
00045
00046 if (arrsize>1) {
00047 TGo4CondArray* arr = 0;
00048 if (ctype==2) {
00049 arr = new TGo4CondArray(cname, arrsize, "TGo4PolyCond");
00050 for (int n=0;n<arrsize;n++) {
00051 TGo4PolyCond* pcond = dynamic_cast<TGo4PolyCond*> (arr->At(n));
00052 Double_t xx[5] = {0, 100, 100, 0, 0};
00053 Double_t yy[5] = {0, 0, 100, 100, 0};
00054 for(int indx=0;indx<5;indx++) {
00055 xx[indx]+=n*20.;
00056 yy[indx]+=n*20.;
00057 }
00058 if (pcond!=0)
00059 pcond->SetValues(xx, yy, 5);
00060 }
00061 } else {
00062 arr = new TGo4CondArray(cname, arrsize, "TGo4WinCond");
00063 for (int n=0;n<arrsize;n++) {
00064 TGo4WinCond* wcond = dynamic_cast<TGo4WinCond*> (arr->At(n));
00065 if (wcond==0) continue;
00066 if (ctype==0)
00067 wcond->SetValues(0.,100.);
00068 else
00069 wcond->SetValues(0.,100.,0.,100.);
00070 }
00071 }
00072 cond = arr;
00073 } else
00074
00075 switch (ctype) {
00076 case 0: {
00077 TGo4WinCond* wcond = new TGo4WinCond(cname, "1-D window condition");
00078 wcond->SetValues(0.,100.);
00079 cond = wcond;
00080 break;
00081 }
00082 case 1: {
00083 TGo4WinCond* wcond = new TGo4WinCond(cname, "2-D window condition");
00084 wcond->SetValues(0.,100.,0.,100.);
00085 cond = wcond;
00086 break;
00087 }
00088 case 2: {
00089 TGo4PolyCond* pcond = new TGo4PolyCond(cname, "Polygon condition");
00090 Double_t xx[5] = {0, 100, 100, 0, 0};
00091 Double_t yy[5] = {0, 0, 100, 100, 0};
00092 pcond->SetValues(xx, yy, 5);
00093 cond = pcond;
00094 break;
00095 }
00096 }
00097
00098 if(cond!=0)
00099 cond->Enable();
00100
00101 return cond;
00102 }