casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QtPlotSettings.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 
00026 #ifndef QTPLOTSETTINGS_H
00027 #define QTPLOTSETTINGS_H
00028 
00029 #include <cmath>
00030 #include <QString>
00031 #include <utility>              /***for std::pair***/
00032 
00033 using namespace std;
00034  
00035 namespace casa { 
00036 
00037 class QtPlotSettings
00038 {
00039 public:
00040     QtPlotSettings();
00041     void adjust( const QString& topUnits, const QString& bottomUnits, bool autoScaleX, bool autoScaleY );
00042     void zoomOut( double zoomFactor, const QString& topUnits, const QString& bottomUnits,
00043                 bool autoScaleX, bool autoScaleY );
00044     void zoomIn( double zoomFactor, const QString& topUnits, const QString& bottomUnits,
00045                 bool autoScaleX, bool autoScaleY );
00046     void zoomY( double minY, double maxY, bool autoScaleY );
00047     pair<double,double> getZoomInY( double zoomFactor ) const;
00048     pair<double,double> getZoomOutY( double zoomFactor ) const;
00049 
00050     void scroll(int dx, int dy);
00051     enum AxisIndex {xBottom, xTop, END_AXIS_INDEX };
00052     double spanX( AxisIndex index ) const {
00053         return maxX[static_cast<int>(index)] - minX[static_cast<int>(index)];
00054     }
00055     double spanY() const { return maxY - minY; }
00056     double getMinX( AxisIndex index ) const {
00057         return minX[static_cast<int>(index)];
00058     }
00059     void setMinX( AxisIndex index, double value );
00060     double getMaxX( AxisIndex index ) const {
00061         return maxX[static_cast<int>(index)];
00062     }
00063     void setMaxX( AxisIndex index, double value );
00064     double getMinY() const {
00065         return minY;
00066     }
00067 
00068     void setMinY( double value );
00069     double getMaxY() const {
00070         return maxY;
00071     }
00072 
00073     void setMaxY( double value );
00074     int getNumTicksX( ) const {
00075         return numXTicks;
00076     }
00077     int getNumTicksY() const {
00078         return numYTicks;
00079     }
00080 
00081 
00082 
00083 private:
00084 
00085     void adjustAxis(double &min, double &max, int &numTicks);
00086     void adjustAxisTop( double &min, double &max, const QString& topUnits,
00087                 const QString& bottomUnits );
00088     double minX[END_AXIS_INDEX];
00089     double maxX[END_AXIS_INDEX];
00090     int numXTicks;
00091     double minY;
00092     double maxY;
00093     double minPercentage;
00094     double maxPercentage;
00095     double originalMinX;
00096     double originalMaxX;
00097     int numYTicks;
00098 };
00099 
00100 
00101 }
00102 #endif
00103