GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
QFitRangeCutWidget.cpp
Go to the documentation of this file.
1 // $Id$
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 "QFitRangeCutWidget.h"
15 
16 #include "QFitItem.h"
17 #include "TGo4FitComponent.h"
18 #include "TCutG.h"
19 
20 QFitRangeCutWidget::QFitRangeCutWidget(QWidget *parent, const char *name)
21  : QFitNamedWidget(parent, name)
22 {
23  setupUi(this);
24  QObject::connect(NumPointsSpin, QOverload<int>::of(&QSpinBox::valueChanged), this, &QFitRangeCutWidget::NumPointsSpin_valueChanged);
25  QObject::connect(ExcludeCutChk, &QCheckBox::toggled, this, &QFitRangeCutWidget::ExcludeCutChk_toggled);
26  QObject::connect(XYTable, &QTableWidget::cellChanged, this, &QFitRangeCutWidget::XYTable_valueChanged);
27 
28 }
29 
31 {
32  return dynamic_cast<TGo4FitComponent *>(GetItem()->Parent()->Object());
33 }
34 
36 {
37  return GetItem()->Tag();
38 }
39 
41 {
42  return dynamic_cast<TCutG*> (GetObject());
43 }
44 
46 {
48  TGo4FitComponent *comp = GetComp();
49  TCutG *cut = GetCut();
50  if (comp && cut) {
51  ExcludeCutChk->setChecked(comp->IsRangeCutExcluding(GetCutIndex()));
52  NumPointsSpin->setValue(cut->GetN());
54  }
55 }
56 
58 {
59  TCutG *cut = GetCut();
60  if (!cut) return;
61 
62  XYTable->setRowCount(cut->GetN());
63 
64  for (int n = 0; n < cut->GetN(); n++) {
65  Double_t x, y;
66  cut->GetPoint(n, x,y);
67  XYTable->setItem(n, 0, new QTableWidgetItem(QString::number(x)));
68  XYTable->setItem(n, 1, new QTableWidgetItem(QString::number(y)));
69  XYTable->setVerticalHeaderItem(n, new QTableWidgetItem(QString::number(n)));
70  }
71 }
72 
73 
75 {
76  if(!fbFillWidget && GetCut()) {
77  TCutG *cut = GetCut();
78  int old = cut->GetN();
79  Double_t x = 0., y = 0.;
80  if (old > 1)
81  cut->GetPoint(old - 2, x, y);
82  cut->Set(npoint);
83  for (int n = (old - 1 >= 0 ? old - 1 : 0); n < npoint - 1; n++)
84  cut->SetPoint(n, x, y + (n - old + 2) * 10);
85 
86  cut->GetPoint(0, x, y);
87  cut->SetPoint(npoint-1, x, y);
88 
89  fbFillWidget = true;
91  fbFillWidget = false;
92  }
93 }
94 
95 
97 {
98  if(!fbFillWidget && GetComp())
100 }
101 
102 
104 {
105  if(!fbFillWidget && GetCut()) {
106  TCutG *cut = GetCut();
107  bool ok;
108  double zn = XYTable->item(nrow, ncol)->text().toDouble(&ok);
109  if(ok) {
110  if (ncol == 0) cut->GetX()[nrow] = zn;
111  else cut->GetY()[nrow] = zn;
112  if ((nrow == 0) || (nrow == cut->GetN()-1)) {
113  int nrow1 = (nrow == 0) ? cut->GetN()-1 : 0;
114  fbFillWidget = true;
115  XYTable->setItem(nrow1, ncol, new QTableWidgetItem(XYTable->item(nrow, ncol)->text()));
116  if (ncol == 0) cut->GetX()[nrow1] = zn;
117  else cut->GetY()[nrow1] = zn;
118  fbFillWidget = false;
119  }
120  }
121  }
122 }
virtual TGo4FitComponent * GetComp()
virtual void FillXYPointsTable()
virtual void NumPointsSpin_valueChanged(int)
void SetRangeCutExcluding(Int_t n, Bool_t exclude=kTRUE)
virtual TCutG * GetCut()
bool fbFillWidget
Definition: QFitWidget.h:63
virtual void XYTable_valueChanged(int, int)
void FillSpecificData() override
virtual void ExcludeCutChk_toggled(bool)
Bool_t IsRangeCutExcluding(Int_t n) const
TObject * Object() const
Definition: QFitItem.h:27
virtual TObject * GetObject()
Definition: QFitWidget.cpp:50
QFitItem * Parent() const
Definition: QFitItem.h:35
virtual QFitItem * GetItem()
Definition: QFitWidget.cpp:45
QFitRangeCutWidget(QWidget *parent=nullptr, const char *name=nullptr)
int Tag() const
Definition: QFitItem.h:33
void FillSpecificData() override