casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SpecFitSettingsWidgetRadio.qo.h
Go to the documentation of this file.
1 //# Copyright (C) 2005
2 //# Associated Universities, Inc. Washington DC, USA.
3 //#
4 //# This library is free software; you can redistribute it and/or modify it
5 //# under the terms of the GNU Library General Public License as published by
6 //# the Free Software Foundation; either version 2 of the License, or (at your
7 //# option) any later version.
8 //#
9 //# This library is distributed in the hope that it will be useful, but WITHOUT
10 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 //# License for more details.
13 //#
14 //# You should have received a copy of the GNU Library General Public License
15 //# along with this library; if not, write to the Free Software Foundation,
16 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
17 //#
18 //# Correspondence concerning AIPS++ should be addressed as follows:
19 //# Internet email: aips2-request@nrao.edu.
20 //# Postal address: AIPS++ Project Office
21 //# National Radio Astronomy Observatory
22 //# 520 Edgemont Road
23 //# Charlottesville, VA 22903-2475 USA
24 //#
25 #ifndef SPECFITSETTINGSWIDGETRADIO_QO_H
26 #define SPECFITSETTINGSWIDGETRADIO_QO_H
27 
28 #include <QWidget>
29 #include <QProgressDialog>
30 #include <display/QtPlotter/SpecFitSettingsWidgetRadio.ui.h>
33 #include <casa/Containers/Record.h>
35 
36 namespace casa {
37 
38  class ImageProfileFitter;
39  class SpectralList;
40  class SpectralElement;
41  class SpecFit;
42  class SpecFitThread;
43 
44  class SpecFitSettingsWidgetRadio : public QWidget, public ProfileTaskFacilitator {
45  Q_OBJECT
46 
47  public:
48  SpecFitSettingsWidgetRadio(QWidget *parent = 0);
50  void setUnits( QString units );
51  void setDisplayYUnits( const QString& units );
52  void setImageYUnits( const QString& units );
53  void setCurveName( const QString& curveName );
54  void addCurveName( const QString& curveName );
55  void setRange(double start, double end );
56  void reset();
57  void pixelsChanged( int pixX, int pixY );
58 
59  signals:
60  void gaussEstimateCountChanged( int count );
61 
62  private slots:
63  void polyFitChanged( int state );
64  void gaussCountChanged( int count );
65  void fitRatioChanged( int count );
66  void clean();
67  void specLineFit();
68  void setOutputLogFile();
69  void viewOutputLogFile();
70  void saveOutputChanged( int state );
71  void specFitEstimateSpecified(double xValue,double yValue, bool centerPeak);
72  void fitDone( bool newData = true );
73  void cancelFit();
76 
77  private:
78 
79  bool _constructFitter( std::shared_ptr<const casacore::ImageInterface<float> >& image,
80  const casacore::String& region, const casacore::Record* const &regionPtr, const casacore::String& box,
81  const casacore::String& chans, const casacore::String& stokes, const casacore::String& mask, const int axis,
82  const casacore::uInt ngauss, const SpectralList& spectralList );
87  void setEstimateValue( int row, int col, double val );
88  bool isValidEstimate( QString& peakStr, QString& centerStr,
89  QString& fwhmStr, QString& fixedStr, int rowIndex );
90  SpectralList buildSpectralList( int nGauss, bool& validList );
91  bool isValidFitSpecification( int gaussCount, bool polyFit );
92  void setCanvas( QtCanvas* canvas );
93  void doFit( float startVal, float endVal, uint gaussCount, bool fitPoly, int polyN );
94  casacore::String getChannels( float startVal, float endVal, const casacore::Vector<float>& specValues ) const;
95  void getFitBounds( float& startVal, float& endVal ) const;
96  int getFitCount(int& startChannelIndex, int& endChannelIndex );
97  void setFitEstimate( int row, double xValue, double yValue, bool centerPeak );
98  void clearEstimates();
99  void clear();
100  void emptyCurveList();
101  void resolveOutputLogFile( );
105  void getConversion( const casacore::String& unitStr, bool& velocity, bool& wavelength ) const ;
106  bool processFitResults(casacore::Vector<float>& xValues, casacore::Vector<float>& xValuesPix, const casacore::String& yUnit);
107  void getEstimateStrings( int index, QString& peakStr, QString& centerStr, QString& fwhmStr ) const;
108  bool processFitResultGaussian( const SpectralElement* solution,
109  int index, QList<SpecFit*>& curves, const casacore::String& yUnit);
110  bool processFitResultPolynomial( const SpectralElement* solution,
111  QList<SpecFit*>& curves);
112  bool isInRange( double xValue ) const;
113  QString settingsToString() const;
114  double toPixels( double val, casacore::String units, casacore::SpectralCoordinate& coord ) const;
115  void drawCurves( int pixelX, int pixelY );
116 
118  Ui::SpecFitSettingsWidgetRadio ui;
120  SpecFitThread* specFitThread;
121  QProgressDialog progressDialog;
124 
125 
126  QString outputLogPath;
127  QString displayYUnits;
128  QString imageYUnits;
129  QList<QList<SpecFit*> > curveList;
132  volatile bool fitCancelled;
133  };
134 }
135 #endif // SPECFITSETTINGSWIDGETRADIO_H
void addCurveName(const QString &curveName)
bool isValidFitSpecification(int gaussCount, bool polyFit)
void setEstimateValue(int row, int col, double val)
Places the passed in Gaussian estimate val into the indicated row and column of the initial Gaussian ...
void gaussEstimateCountChanged(int count)
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
bool _constructFitter(std::shared_ptr< const casacore::ImageInterface< float > > &image, const casacore::String &region, const casacore::Record *const &regionPtr, const casacore::String &box, const casacore::String &chans, const casacore::String &stokes, const casacore::String &mask, const int axis, const casacore::uInt ngauss, const SpectralList &spectralList)
SpectralList buildSpectralList(int nGauss, bool &validList)
void setFitEstimate(int row, double xValue, double yValue, bool centerPeak)
int getFitCount(int &startChannelIndex, int &endChannelIndex)
SpecFitSettingsWidgetRadio(QWidget *parent=0)
void fitDone(bool newData=true)
void setCanvas(QtCanvas *canvas)
void pixelsChanged(int pixX, int pixY)
const_iterator end() const
bool processFitResultPolynomial(const SpectralElement *solution, QList< SpecFit * > &curves)
Describes (a set of related) spectral lines.
bool isValidEstimate(QString &peakStr, QString &centerStr, QString &fwhmStr, QString &fixedStr, int rowIndex)
bool processFitResults(casacore::Vector< float > &xValues, casacore::Vector< float > &xValuesPix, const casacore::String &yUnit)
void setImageYUnits(const QString &units)
bool isInRange(double xValue) const
void setCurveName(const QString &curveName)
A hierarchical collection of named fields of various types.
Definition: Record.h:180
double toPixels(double val, casacore::String units, casacore::SpectralCoordinate &coord) const
void drawCurves(int pixelX, int pixelY)
void getFitBounds(float &startVal, float &endVal) const
Interconvert pixel and frequency values.
A set of SpectralElements.
Definition: SpectralList.h:85
casacore::String getChannels(float startVal, float endVal, const casacore::Vector< float > &specValues) const
void specFitEstimateSpecified(double xValue, double yValue, bool centerPeak)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
bool processFitResultGaussian(const SpectralElement *solution, int index, QList< SpecFit * > &curves, const casacore::String &yUnit)
void doFit(float startVal, float endVal, uint gaussCount, bool fitPoly, int polyN)
void setUnits(QString units)
void getEstimateStrings(int index, QString &peakStr, QString &centerStr, QString &fwhmStr) const
void setDisplayYUnits(const QString &units)
void getConversion(const casacore::String &unitStr, bool &velocity, bool &wavelength) const
Decides if the units represent velocity, wavelength, or frequency.
unsigned int uInt
Definition: aipstype.h:51
void setRange(double start, double end)