casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GaussianEstimateWidget.qo.h
Go to the documentation of this file.
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 GAUSSIANESTIMATEWIDGET_QO_H
00026 #define GAUSSIANESTIMATEWIDGET_QO_H
00027 
00028 #include <QWidget>
00029 #include <casa/Arrays/Vector.h>
00030 #include <display/QtPlotter/GaussianEstimateWidget.ui.h>
00031 #include <display/QtPlotter/SpecFitGaussian.h>
00032 #include <display/QtPlotter/conversion/Converter.h>
00033 
00034 class QwtPlot;
00035 class QwtPlotCurve;
00036 
00037 namespace casa {
00038 
00039 class MolecularLine;
00040 
00041 class GaussianEstimateWidget : public QWidget
00042 {
00043     Q_OBJECT
00044 
00045 public:
00046     static void setEstimateColor( QColor estimateColor );
00047     GaussianEstimateWidget(QWidget *parent = 0);
00048     void setCurveData(const Vector<float>& xValues, const Vector<float>& yValues);
00049     void setCurveColor( QColor color );
00050     void setTitle( const QString& titleStr );
00051     void setRangeX( Float xValue, Float yValue );
00052     void setRangeY( Float xValue, Float yValue );
00053     void setDisplayYUnits( const QString& units );
00054     void molecularLineChanged( float peak, float center, const QString& label,
00055                 const QString& chemicalName, const QString& resolvedQNs, const QString& frequencyUnits );
00056     SpecFitGaussian getEstimate();
00057     void setEstimate( const SpecFitGaussian& estimate );
00058     void unitsChanged( const QString& oldUnits, const QString& newUnits);
00059     void setSliderValueFWHM( float value );
00060     void updateUIBasedOnEstimate();
00061     void clearMolecularLines();
00062     ~GaussianEstimateWidget();
00063 
00064 signals:
00065         void coordinatedValuesChanged(float);
00066 
00067 private slots:
00068         void peakSliderChanged( int value );
00069         void centerSliderChanged( int value );
00070         void fwhmSliderChanged( int value );
00071         void peakTextChanged();
00072         void centerTextChanged();
00073         void fwhmTextChanged();
00074         void peakFixedChanged( bool fixed );
00075         void centerFixedChanged( bool fixed );
00076         void fwhmFixedChanged( bool fixed );
00077 
00078 private:
00079     float scale( int value, Float min, Float max ) const;
00080     float scaleY( int value ) const;
00081     float scaleX( int value ) const;
00082     int reverseScale( float value, Float min, Float max ) const;
00083     int reverseScaleY( float value ) const;
00084     int reverseScaleX( float value ) const;
00085     float getFwhmRange() const;
00086     void peakChanged( float value );
00087     void centerChanged( float value );
00088     void fwhmChanged( float value );
00089     void updateFit();
00090     void copyVectors( const Vector<float>& values, QVector<double>& vals, bool reverseOrder );
00091     void copyVectors( const Vector<float>& sourceValues, Vector<float>& destinationValues, bool reverseOrder );
00092     float adjustValue( float val ) const;
00093     void setSliderValuePeak( float value );
00094     void setSliderValueCenter( float value );
00095     float reasonableFWHM( float value ) const;
00096     float reasonableCenter( float value ) const;
00097     float reasonablePeak( float value ) const;
00098 
00099     QwtPlotCurve* initCurve( QColor color );
00100     void clearCurve( QwtPlotCurve*& curve );
00101 
00102     QwtPlot* plot;
00103     QwtPlotCurve* curve;
00104     QwtPlotCurve* fitCurve;
00105     Ui::GaussianEstimateWidgetClass ui;
00106     SpecFitGaussian gaussianEstimate;
00107     Vector<float> xValues;
00108     Vector<float> yValues;
00109     Float minX;
00110     Float maxX;
00111     Float minY;
00112     Float maxY;
00113     QColor curveColor;
00114     static QColor fitCurveColor;
00115     QMap<QString,MolecularLine*> molecularLineMap;
00116 };
00117 }
00118 
00119 #endif // GAUSSIANESTIMATEWIDGET_QO_H