GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
QFitParCfgWidget.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 "QFitParCfgWidget.h"
15 
16 #include "QFitItem.h"
17 #include "TGo4FitParsList.h"
18 #include "TGo4FitParameter.h"
19 
20 
21 QFitParCfgWidget::QFitParCfgWidget(QWidget *parent, const char *name)
22  : QFitWidget(parent, name)
23 {
24  setupUi(this);
25  QObject::connect(ParNameEdit, &QGo4LineEdit::textChanged, this, &QFitParCfgWidget::ParNameEdit_textChanged);
26  QObject::connect(ParFixedChk, &QCheckBox::toggled, this, &QFitParCfgWidget::ParFixedChk_toggled);
27  QObject::connect(RangeMinEdit, &QGo4LineEdit::textChanged, this, &QFitParCfgWidget::RangeMinEdit_textChanged);
28  QObject::connect(RangeMaxEdit, &QGo4LineEdit::textChanged, this, &QFitParCfgWidget::RangeMaxEdit_textChanged);
29  QObject::connect(EpsilonEdit, &QGo4LineEdit::textChanged, this, &QFitParCfgWidget::EpsilonEdit_textChanged);
30 }
31 
32 
34 {
35  return dynamic_cast<TGo4FitParameter *>(GetObject());
36 }
37 
39 {
40  if (GetPar()) {
41  ParNameEdit->setText(GetPar()->GetName());
42  ParFixedChk->setChecked(GetPar()->GetFixed());
43  Double_t min,max;
44  if (GetPar()->GetRange(min,max)) {
45  RangeMinEdit->setText(QString::number(min));
46  RangeMaxEdit->setText(QString::number(max));
47  } else {
48  RangeMinEdit->setText("");
49  RangeMaxEdit->setText("");
50  }
51  Double_t eps;
52  if (GetPar()->GetEpsilon(eps)) EpsilonEdit->setText(QString::number(eps));
53  else EpsilonEdit->setText("");
54  }
55 }
56 
58 {
59  if (RangeMinEdit->text().isEmpty() && RangeMaxEdit->text().isEmpty()) {
60  GetPar()->SetRangeUse(kFALSE);
61  return;
62  }
63  bool okmin = false, okmax = false;
64 
65  double min = RangeMinEdit->text().toDouble(&okmin);
66  double max = RangeMaxEdit->text().toDouble(&okmax);
67 
68  if (RangeMinEdit->text().isEmpty()) {
69  min = max;
70  okmin = okmax;
71  }
72  if (RangeMaxEdit->text().isEmpty()) {
73  max = min;
74  okmax = okmin;
75  }
76 
77  if (okmin && okmax)
78  GetPar()->SetRange(min,max);
79 }
80 
81 
82 void QFitParCfgWidget::ParNameEdit_textChanged( const QString & name)
83 {
84  if(!fbFillWidget && GetPar() && (name.length() > 0)) {
85  TGo4FitParsList* pars = dynamic_cast<TGo4FitParsList*> (GetItem()->Parent()->Object());
86  if (!pars) return;
87  if (pars->FindPar(name.toLatin1().constData())) return;
88  GetPar()->SetName(name.toLatin1().constData());
89  GetItem()->setText(0,name.toLatin1().constData());
90  }
91 }
92 
93 
95 {
96  if(!fbFillWidget && GetPar())
97  GetPar()->SetFixed(chk);
98 }
99 
101 {
102  if(!fbFillWidget && GetPar())
104 }
105 
107 {
108  if(!fbFillWidget && GetPar())
110 }
111 
112 void QFitParCfgWidget::EpsilonEdit_textChanged( const QString & value)
113 {
114  if (!fbFillWidget && GetPar()) {
115  if (value.isEmpty()) {
116  GetPar()->SetEpsilonUse(kFALSE);
117  } else {
118  bool res = false;
119  double zn = value.toDouble(&res);
120  if (res)
121  GetPar()->SetEpsilon(zn);
122  }
123  }
124 }
void SetRangeUse(Bool_t use)
QFitParCfgWidget(QWidget *parent=nullptr, const char *name=nullptr)
void SetEpsilonUse(Bool_t use)
virtual void RangeMaxEdit_textChanged(const QString &)
virtual TGo4FitParameter * GetPar()
virtual void ParFixedChk_toggled(bool)
bool fbFillWidget
Definition: QFitWidget.h:63
TGo4FitParameter * FindPar(const char *ParName)
void FillSpecificData() override
virtual void AnalyzeRangeValues()
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
void SetEpsilon(Double_t iEpsilon)
virtual void RangeMinEdit_textChanged(const QString &)
virtual void EpsilonEdit_textChanged(const QString &)
void SetFixed(Bool_t iFixed)
virtual void ParNameEdit_textChanged(const QString &)
void SetRange(Double_t iRangeMin, Double_t iRangeMax)