00001 // $Id: QFitParCfgWidget.cpp 1134 2014-01-22 14:53:40Z linev $ 00002 //----------------------------------------------------------------------- 00003 // The GSI Online Offline Object Oriented (Go4) Project 00004 // Experiment Data Processing at EE department, GSI 00005 //----------------------------------------------------------------------- 00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH 00007 // Planckstr. 1, 64291 Darmstadt, Germany 00008 // Contact: http://go4.gsi.de 00009 //----------------------------------------------------------------------- 00010 // This software can be used under the license agreements as stated 00011 // in Go4License.txt file which is part of the distribution. 00012 //----------------------------------------------------------------------- 00013 00014 #include "QFitParCfgWidget.h" 00015 00016 #include "QFitItem.h" 00017 #include "TGo4FitParsList.h" 00018 #include "TGo4FitParameter.h" 00019 00020 00021 QFitParCfgWidget::QFitParCfgWidget(QWidget *parent, const char* name) 00022 : QFitWidget(parent, name) 00023 { 00024 setupUi(this); 00025 } 00026 00027 00028 TGo4FitParameter * QFitParCfgWidget::GetPar() 00029 { 00030 return dynamic_cast<TGo4FitParameter*> (GetObject()); 00031 } 00032 00033 void QFitParCfgWidget::FillSpecificData() 00034 { 00035 if (GetPar()) { 00036 ParNameEdit->setText(GetPar()->GetName()); 00037 ParFixedChk->setChecked(GetPar()->GetFixed()); 00038 Double_t min,max; 00039 if (GetPar()->GetRange(min,max)) { 00040 RangeMinEdit->setText(QString::number(min)); 00041 RangeMaxEdit->setText(QString::number(max)); 00042 } else { 00043 RangeMinEdit->setText(""); 00044 RangeMaxEdit->setText(""); 00045 } 00046 Double_t eps; 00047 if (GetPar()->GetEpsilon(eps)) EpsilonEdit->setText(QString::number(eps)); 00048 else EpsilonEdit->setText(""); 00049 } 00050 } 00051 00052 void QFitParCfgWidget::AnalyzeRangeValues() 00053 { 00054 if ((RangeMinEdit->text().length()==0) && (RangeMaxEdit->text().length()==0)) 00055 { GetPar()->SetRangeUse(kFALSE); return; } 00056 double min,max; 00057 bool okmin = false, okmax = false; 00058 00059 min = RangeMinEdit->text().toDouble(&okmin); 00060 max = RangeMaxEdit->text().toDouble(&okmax); 00061 00062 if (RangeMinEdit->text().length()==0) { min = max; okmin = okmax; } 00063 if (RangeMaxEdit->text().length()==0) { max = min; okmax = okmin; } 00064 00065 if (okmin && okmax) 00066 GetPar()->SetRange(min,max); 00067 } 00068 00069 00070 void QFitParCfgWidget::ParNameEdit_textChanged( const QString & name) 00071 { 00072 if(!fbFillWidget && GetPar() && (name.length()>0)) { 00073 TGo4FitParsList* pars = dynamic_cast<TGo4FitParsList*> (GetItem()->Parent()->Object()); 00074 if (pars==0) return; 00075 if (pars->FindPar(name.toLatin1().constData())) return; 00076 GetPar()->SetName(name.toLatin1().constData()); 00077 GetItem()->setText(0,name.toLatin1().constData()); 00078 } 00079 } 00080 00081 00082 void QFitParCfgWidget::ParFixedChk_toggled( bool chk) 00083 { 00084 if(!fbFillWidget && GetPar()) 00085 GetPar()->SetFixed(chk); 00086 } 00087 00088 00089 void QFitParCfgWidget::RangeMinEdit_textChanged( const QString &) 00090 { 00091 if(!fbFillWidget && GetPar()) 00092 AnalyzeRangeValues(); 00093 } 00094 00095 00096 void QFitParCfgWidget::RangeMaxEdit_textChanged( const QString &) 00097 { 00098 if(!fbFillWidget && GetPar()) 00099 AnalyzeRangeValues(); 00100 } 00101 00102 void QFitParCfgWidget::EpsilonEdit_textChanged( const QString & value) 00103 { 00104 if(!fbFillWidget && GetPar()) 00105 if (value.length()==0) GetPar()->SetEpsilonUse(kFALSE); else { 00106 bool res = false; 00107 double zn = value.toDouble(&res); 00108 if(res) GetPar()->SetEpsilon(zn); 00109 } 00110 }