casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CanvasCurve.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 CANVASCURVE_H_
00026 #define CANVASCURVE_H_
00027 
00028 #include <casa/aips.h>
00029 #include <casa/Arrays/Vector.h>
00030 #include <vector>
00031 #include <utility>                      /***for std::pair***/
00032 #include <QColor>
00033 #include <QString>
00034 
00039 namespace casa {
00040 
00041 typedef std::vector<double> CurveData;
00042 typedef std::vector<double> ErrorData;
00043 
00044 class CanvasCurve {
00045 public:
00046         CanvasCurve();
00047         CanvasCurve( CurveData curveData, ErrorData errorData,
00048                         QString legend, QColor curveColor, int curveType );
00049         QColor getColor() const;
00050         void setColor( QColor color );
00051         QString getLegend() const;
00052         void setLegend( const QString& legend );
00053         int getCurveType() const;
00054         CurveData getCurveData();
00055         Vector<float> getXValues() const;
00056         Vector<float> getYValues() const;
00057         CurveData getErrorData();
00058 
00059         QString getToolTip( double x, double y , const double X_ERROR,
00060                         const double Y_ERROR, const QString& xUnit, const QString& yUnit ) const;
00061         void getMinMax(Double& xmin, Double& xmax, Double& ymin,
00062                         Double& ymax, bool plotError ) const;
00063         std::pair<double,double> getRangeFor(double xMin, double xMax, Bool& exists );
00064         void scaleYValues( const QString& oldDisplayUnits, const QString& yUnitDisplay, const QString& xUnits );
00065         double convertValue( double value, double freqValue, const QString& oldDisplayUnits, const QString& yUnitDisplay, const QString& xUnits);
00066         virtual ~CanvasCurve();
00067 
00068 private:
00069         Vector<float> getErrorValues() const;
00070         double getMaxY() const;
00071         double getMaxError() const;
00072         void storeData( const QString& oldUnits );
00073         void setYValues( const Vector<float>& yValues );
00074         void setErrorValues( const Vector<float>& errorValues );
00075 
00076         QColor curveColor;
00077         QString legend;
00078         CurveData curveData;
00079         ErrorData errorData;
00080         QString maxUnits;
00081         double maxValue;
00082         double maxErrorValue;
00083         int curveType;
00084 };
00085 
00086 } /* namespace casa */
00087 #endif /* CANVASCURVE_H_ */