00001 //# Copyright (C) 2005 00002 //# Associated Universities, Inc. Washington DC, USA. 00003 //# 00004 //# This library is free software; you can redistribute it and/or modify it 00005 //# under the terms of the GNU Library General Public License as published by 00006 //# the Free Software Foundation; either version 2 of the License, or (at your 00007 //# option) any later version. 00008 //# 00009 //# This library is distributed in the hope that it will be useful, but WITHOUT 00010 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 //# License for more details. 00013 //# 00014 //# You should have received a copy of the GNU Library General Public License 00015 //# along with this library; if not, write to the Free Software Foundation, 00016 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00017 //# 00018 //# Correspondence concerning AIPS++ should be addressed as follows: 00019 //# Internet email: aips2-request@nrao.edu. 00020 //# Postal address: AIPS++ Project Office 00021 //# National Radio Astronomy Observatory 00022 //# 520 Edgemont Road 00023 //# Charlottesville, VA 22903-2475 USA 00024 //# 00025 #ifndef FITWIDGET_QO_H 00026 #define FITWIDGET_QO_H 00027 00028 #include <QtGui/QWidget> 00029 #include <QTextStream> 00030 #include <guitools/Histogram/FitWidget.ui.h> 00031 #include <casa/Arrays/Vector.h> 00032 00033 namespace casa { 00034 00035 class Fitter; 00036 class FitterGaussian; 00037 class FitterPoisson; 00038 00044 class FitWidget : public QWidget { 00045 Q_OBJECT 00046 00047 public: 00048 FitWidget(QWidget *parent = 0); 00049 void setCenterPeak( double center, double peak ); 00050 void setFWHM( double fwhm ); 00051 void setLambda( double lambda ); 00052 void setUnits( const QString& units ); 00053 void setValues( int id, Vector<Float> xValues, Vector<Float> yValues ); 00054 double getCenter() const; 00055 double getPeak() const; 00056 double getFWHM() const; 00057 double getLambda() const; 00058 Vector<Float> getFitValues() const; 00059 Vector<Float> getFitValuesX() const; 00060 bool isGaussian() const; 00061 void toAscii( QTextStream& out) const; 00062 void restrictDomain( double xMin, double xMax ); 00063 void clearDomainLimits(); 00064 ~FitWidget(); 00065 00066 signals: 00067 void fitModeChanged(); 00068 void dataFitted(const QString& msg); 00069 void gaussianFitChanged(); 00070 void poissonFitChanged(); 00071 void fitCleared(); 00072 00073 public slots: 00074 void clearFit(); 00075 00076 private slots: 00077 void centerEdited( const QString& centerText ); 00078 void peakEdited( const QString& peakText ); 00079 void fwhmEdited( const QString& fwhmText ); 00080 void lambdaEdited( const QString& lambdaText ); 00081 void fitSelected( int index ); 00082 void doFit(); 00083 00084 private: 00085 FitWidget( const FitWidget& ); 00086 FitWidget& operator=( const FitWidget& ); 00087 void setSolutionVisible( bool visible ); 00088 void resetFWHM( double newCenter ); 00089 enum FitMode {GAUSSIAN_MODE, POISSON_MODE, NO_MODE }; 00090 Fitter* fitter; 00091 FitterGaussian* fitterGaussian; 00092 FitterPoisson* fitterPoisson; 00093 Ui::FitWidgetClass ui; 00094 int fitId; 00095 }; 00096 } 00097 #endif // FITWIDGET_QO_H