casa
$Rev:20696$
|
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 SPECFITSETTINGSWIDGETRADIO_QO_H 00026 #define SPECFITSETTINGSWIDGETRADIO_QO_H 00027 00028 #include <QtGui/QWidget> 00029 #include <QProgressDialog> 00030 #include <display/QtPlotter/SpecFitSettingsWidgetRadio.ui.h> 00031 #include <display/QtPlotter/ProfileTaskFacilitator.h> 00032 #include <display/QtPlotter/GaussianEstimateDialog.qo.h> 00033 #include <casa/Containers/Record.h> 00034 #include <coordinates/Coordinates/CoordinateSystem.h> 00035 00036 namespace casa { 00037 00038 class ImageProfileFitter; 00039 class SpectralList; 00040 class SpectralElement; 00041 class SpecFit; 00042 class SpecFitThread; 00043 00044 class SpecFitSettingsWidgetRadio : public QWidget, public ProfileTaskFacilitator 00045 { 00046 Q_OBJECT 00047 00048 public: 00049 SpecFitSettingsWidgetRadio(QWidget *parent = 0); 00050 ~SpecFitSettingsWidgetRadio(); 00051 void setUnits( QString units ); 00052 void setDisplayYUnits( const QString& units ); 00053 void setImageYUnits( const QString& units ); 00054 void setCurveName( const QString& curveName ); 00055 void addCurveName( const QString& curveName ); 00056 void setRange(double start, double end ); 00057 void reset(); 00058 void pixelsChanged( int pixX, int pixY ); 00059 00060 00061 private slots: 00062 void polyFitChanged( int state ); 00063 void gaussCountChanged( int count ); 00064 void fitRatioChanged( int count ); 00065 void clean(); 00066 void specLineFit(); 00067 void setOutputLogFile(); 00068 void viewOutputLogFile(); 00069 void saveOutputChanged( int state ); 00070 void specFitEstimateSpecified(double xValue,double yValue, bool centerPeak); 00071 void fitDone( bool newData = true ); 00072 void cancelFit(); 00073 void specifyGaussianEstimates(); 00074 void gaussianEstimatesChanged(); 00075 00076 private: 00081 void setEstimateValue( int row, int col, double val ); 00082 bool isValidEstimate( QString& peakStr, QString& centerStr, 00083 QString& fwhmStr, QString& fixedStr, int rowIndex ); 00084 SpectralList buildSpectralList( int nGauss, Bool& validList ); 00085 bool isValidFitSpecification( int gaussCount, bool polyFit ); 00086 void setCanvas( QtCanvas* canvas ); 00087 void doFit( float startVal, float endVal, uint gaussCount, bool fitPoly, int polyN ); 00088 String getChannels( float startVal, float endVal, const Vector<Float>& specValues ) const; 00089 void getFitBounds( Float& startVal, Float& endVal ) const; 00090 int getFitCount(Int& startChannelIndex, Int& endChannelIndex ); 00091 void clearEstimates(); 00092 void clear(); 00093 void emptyCurveList(); 00094 void resolveOutputLogFile( ); 00098 void getConversion( const String& unitStr, Bool& velocity, Bool& wavelength ) const ; 00099 bool processFitResults(Vector<float>& xValues, Vector<float>& xValuesPix); 00100 void getEstimateStrings( int index, QString& peakStr, QString& centerStr, QString& fwhmStr ) const; 00101 bool processFitResultGaussian( const SpectralElement* solution, 00102 int index, QList<SpecFit*>& curves); 00103 bool processFitResultPolynomial( const SpectralElement* solution, 00104 QList<SpecFit*>& curves); 00105 bool isInRange( double xValue ) const; 00106 QString settingsToString() const; 00107 double toPixels( double val) const; 00108 void drawCurves( int pixelX, int pixelY ); 00109 SpectralCoordinate getSpectralCoordinate() const; 00110 00111 enum TableHeaders {PEAK,CENTER,FWHM,FIXED,END_COLUMN}; 00112 Ui::SpecFitSettingsWidgetRadio ui; 00113 ImageProfileFitter* fitter; 00114 SpecFitThread* specFitThread; 00115 QProgressDialog progressDialog; 00116 GaussianEstimateDialog gaussEstimateDialog; 00117 00118 00119 QString outputLogPath; 00120 QString displayYUnits; 00121 QString imageYUnits; 00122 QList<QList<SpecFit*> > curveList; 00123 int SUM_FIT_INDEX; 00124 00125 volatile bool fitCancelled; 00126 }; 00127 } 00128 #endif // SPECFITSETTINGSWIDGETRADIO_H