Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "QFitRangeCutWidget.h"
00015
00016 #include "QFitItem.h"
00017 #include "TGo4FitComponent.h"
00018 #include "TCutG.h"
00019
00020 QFitRangeCutWidget::QFitRangeCutWidget(QWidget *parent, const char* name)
00021 : QFitNamedWidget(parent, name)
00022 {
00023 setupUi(this);
00024 }
00025
00026 TGo4FitComponent* QFitRangeCutWidget::GetComp() {
00027 return dynamic_cast<TGo4FitComponent*> (GetItem()->Parent()->Object());
00028 }
00029
00030 int QFitRangeCutWidget::GetCutIndex() {
00031 return GetItem()->Tag();
00032 }
00033
00034 TCutG* QFitRangeCutWidget::GetCut() {
00035 return dynamic_cast<TCutG*> (GetObject());
00036 }
00037
00038 void QFitRangeCutWidget::FillSpecificData() {
00039 QFitNamedWidget::FillSpecificData();
00040 TGo4FitComponent* comp = GetComp();
00041 TCutG* cut = GetCut();
00042 if (comp && cut) {
00043 ExcludeCutChk->setChecked(comp->IsRangeCutExcluding(GetCutIndex()));
00044 NumPointsSpin->setValue(cut->GetN());
00045 FillXYPointsTable();
00046 }
00047 }
00048
00049 void QFitRangeCutWidget::FillXYPointsTable() {
00050 TCutG* cut = GetCut();
00051 if (cut==0) return;
00052
00053 XYTable->setRowCount(cut->GetN());
00054
00055 for (int n=0;n<cut->GetN();n++) {
00056 Double_t x,y;
00057 cut->GetPoint(n, x,y);
00058 XYTable->setItem(n, 0, new QTableWidgetItem(QString::number(x)));
00059 XYTable->setItem(n, 1, new QTableWidgetItem(QString::number(y)));
00060 XYTable->setVerticalHeaderItem(n, new QTableWidgetItem(QString::number(n)));
00061 }
00062 }
00063
00064
00065 void QFitRangeCutWidget::NumPointsSpin_valueChanged( int npoint )
00066 {
00067 if(!fbFillWidget && (GetCut()!=0)) {
00068 TCutG* cut = GetCut();
00069 int old = cut->GetN();
00070 Double_t x=0., y=0.;
00071 if (old>1) cut->GetPoint(old-2, x, y);
00072 cut->Set(npoint);
00073 for(int n= (old-1>=0 ? old-1 : 0); n<npoint-1; n++)
00074 cut->SetPoint(n, x, y+(n-old+2)*10);
00075
00076 cut->GetPoint(0, x, y);
00077 cut->SetPoint(npoint-1, x, y);
00078
00079 fbFillWidget = true;
00080 FillXYPointsTable();
00081 fbFillWidget = false;
00082 }
00083 }
00084
00085
00086 void QFitRangeCutWidget::ExcludeCutChk_toggled( bool chk)
00087 {
00088 if(!fbFillWidget && (GetComp()!=0))
00089 GetComp()->SetRangeCutExcluding(GetCutIndex(), chk);
00090 }
00091
00092
00093 void QFitRangeCutWidget::XYTable_valueChanged( int nrow, int ncol)
00094 {
00095 if(!fbFillWidget && (GetCut()!=0)) {
00096 TCutG* cut = GetCut();
00097 bool ok;
00098 double zn = XYTable->item(nrow, ncol)->text().toDouble(&ok);
00099 if(ok) {
00100 if (ncol==0) cut->GetX()[nrow] = zn;
00101 else cut->GetY()[nrow] = zn;
00102 if ((nrow==0) || (nrow==cut->GetN()-1)) {
00103 int nrow1 = (nrow==0) ? cut->GetN()-1 : 0;
00104 fbFillWidget = true;
00105 XYTable->setItem(nrow1, ncol, new QTableWidgetItem(XYTable->item(nrow, ncol)->text()));
00106 if (ncol==0) cut->GetX()[nrow1] = zn;
00107 else cut->GetY()[nrow1] = zn;
00108 fbFillWidget = false;
00109 }
00110 }
00111 }
00112 }