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