QtRasterData.h

Go to the documentation of this file.
00001 #ifndef QTRASTERDATA_H_
00002 #define QTRASTERDATA_H_
00003  
00004 #include <casaqt/QwtConfig.h>
00005 #include <qwt_raster_data.h>
00006 #include <cstdio>
00007 
00008 class QwtPlotSpectrogram;
00009 
00010 namespace casa { 
00011 /* -------------------------------------------
00012  * QtRasterData derived from QwtRasterData
00013  * Saves the values for the plot
00014  * -------------------------------------------
00015 */
00016  
00017     class QtRasterData: public QwtRasterData {
00018         private:
00019             static int output_limit; 
00020 
00021             double * m_Array;
00022             double m_minValue;
00023             double m_maxValue;
00024  
00025             struct structMinMax {
00026                 double min;
00027                 double max;
00028             };
00029 
00030             struct structXY {
00031                 double x;
00032               double y;
00033             };
00034 
00035             structMinMax m_RangeX;
00036             structMinMax m_RangeY;
00037 
00038             structXY m_DataSize;
00039             QwtDoubleRect bounding_box;
00040             structXY m_RealToArray;
00041 
00042             void setData( const double *array, int sizex, int sizey, double min, double max );
00043             void fillAndFindMinMax( const QList<double> &array, double &min, double &max );
00044             int length_;
00045  
00046             QwtPlotSpectrogram *spect;
00047 
00048         public:
00049             // Constructor giving back the QwtRasterData Constructor
00050             QtRasterData( QwtPlotSpectrogram *s ) : m_Array(0), spect(s) {
00051                 setRangeX(0, 0); setRangeY(0, 0);
00052             }
00053  
00054             ~QtRasterData( ) { if ( m_Array ) delete [] m_Array; }
00055 
00056             void initRaster( const QwtDoubleRect &r, const QSize &raster );
00057             QwtRasterData *copy( ) const;
00058             double value(double x, double y) const;
00059             void setData(const QList<double> &array, int sizex, int sizey);
00060             QwtDoubleInterval range() const;
00061 
00062             void setBoundingRect( const QwtDoubleRect &rect );
00063 
00064             void setRangeX(const double min, const double max) {
00065                 m_RangeX.min = min;
00066                 m_RangeX.max = max;
00067             }
00068  
00069             void setRangeY(const double min, const double max) {
00070                 m_RangeY.min = min;
00071                 m_RangeY.max = max;
00072             }
00073  
00074             int ArrPos(const int x, const int y) const {
00075                 int result = static_cast<int>(y + m_DataSize.y * x);
00076                 /* if ( output_limit < 20 ) fprintf( stderr, "\t\t\t\t (%f,%f) (%d, %d) => %d\n", m_DataSize.x, m_DataSize.y, x, y, result); */
00077                 return result > length_ ? 0 : result;
00078             }
00079     };
00080 }
00081 
00082 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1