casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtRasterData.h
Go to the documentation of this file.
1 #ifndef QTRASTERDATA_H_
2 #define QTRASTERDATA_H_
3 
4 #include <casaqt/QwtConfig.h>
5 #include <qwt_raster_data.h>
6 #include <cstdio>
7 
8 class QwtPlotSpectrogram;
9 
10 namespace casa {
11 /* -------------------------------------------
12  * QtRasterData derived from QwtRasterData
13  * Saves the values for the plot
14  * -------------------------------------------
15 */
16 
17  class QtRasterData: public QwtRasterData {
18  private:
19  static int output_limit;
20 
21  double * m_Array;
22  double m_minValue;
23  double m_maxValue;
24 
25  struct structMinMax {
26  double min;
27  double max;
28  };
29 
30  struct structXY {
31  double x;
32  double y;
33  };
34 
37 
39  QwtDoubleRect bounding_box;
41 
42  void setData( const double *array, int sizex, int sizey, double min, double max );
43  void fillAndFindMinMax( const QList<double> &array, double &min, double &max );
44  int length_;
45 
46  QwtPlotSpectrogram *spect;
47 
48  public:
49  // Constructor giving back the QwtRasterData Constructor
50  QtRasterData( QwtPlotSpectrogram *s ) : m_Array(0), spect(s) {
51  setRangeX(0, 0); setRangeY(0, 0);
52  }
53 
54  ~QtRasterData( ) { if ( m_Array ) delete [] m_Array; }
55 
56  void initRaster( const QwtDoubleRect &r, const QSize &raster );
57  QwtRasterData *copy( ) const;
58  double value(double x, double y) const;
59  void setData(const QList<double> &array, int sizex, int sizey);
60  QwtDoubleInterval range() const;
61 
62  void setBoundingRect( const QwtDoubleRect &rect );
63 
64  void setRangeX(const double min, const double max) {
65  m_RangeX.min = min;
66  m_RangeX.max = max;
67  }
68 
69  void setRangeY(const double min, const double max) {
70  m_RangeY.min = min;
71  m_RangeY.max = max;
72  }
73 
74  int ArrPos(const int x, const int y) const {
75  int result = static_cast<int>(y + m_DataSize.y * x);
76  /* 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); */
77  return result > length_ ? 0 : result;
78  }
79  };
80 }
81 
82 #endif
void initRaster(const QwtDoubleRect &r, const QSize &raster)
#define max(a, b)
Definition: hio.h:44
void setBoundingRect(const QwtDoubleRect &rect)
#define min(a, b)
Definition: hio.h:45
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition: ExprNode.h:1886
static int output_limit
Definition: QtRasterData.h:19
structMinMax m_RangeY
Definition: QtRasterData.h:36
void setRangeX(const double min, const double max)
Definition: QtRasterData.h:64
int ArrPos(const int x, const int y) const
Definition: QtRasterData.h:74
double value(double x, double y) const
void setData(const double *array, int sizex, int sizey, double min, double max)
structMinMax m_RangeX
Definition: QtRasterData.h:35
structXY m_RealToArray
Definition: QtRasterData.h:40
QtRasterData(QwtPlotSpectrogram *s)
Constructor giving back the QwtRasterData Constructor.
Definition: QtRasterData.h:50
QwtRasterData * copy() const
void fillAndFindMinMax(const QList< double > &array, double &min, double &max)
QwtDoubleInterval range() const
QwtPlotSpectrogram * spect
Definition: QtRasterData.h:46
QwtDoubleRect bounding_box
Definition: QtRasterData.h:39
void setRangeY(const double min, const double max)
Definition: QtRasterData.h:69