2003-01-29 21:13:15 +00:00
|
|
|
// Stores a "reduced" (i.e. lower-resolution) version of a 2-D array.
|
|
|
|
// The source data is passed one row at a time.
|
|
|
|
//
|
|
|
|
// This is used to draw graphs of 2-D data that may have much higher
|
|
|
|
// resolution in either or both dimensions than is useful for screen display.
|
|
|
|
//
|
|
|
|
// To use this:
|
|
|
|
//
|
|
|
|
// call set_max_dims() to set maximum dimensions of reduced array.
|
|
|
|
// (change this when window size changes)
|
|
|
|
// call init() to prepare to reduce a source array.
|
|
|
|
// call add_source_row() for each row of the source array.
|
|
|
|
// read nvalid_rows to see how many rows are in reduced array so far
|
|
|
|
// call rrow() to get a pointer to a particular row
|
|
|
|
// or call draw() to generate a picture.
|
|
|
|
// This is currently implemented as follows:
|
|
|
|
// If both dimensions are reduced (source dimension greater than reduced dim)
|
|
|
|
// then draw the graph as vertical lines.
|
|
|
|
// If reduced in one dimension, draw vertical rectangles.
|
|
|
|
// Otherwise draw quadrilaterals.
|
|
|
|
|
2003-02-19 00:06:05 +00:00
|
|
|
|
|
|
|
#define REDUCE_METHOD_AVG 0 // Take the average of reduced elements
|
|
|
|
#define REDUCE_METHOD_SUM 1 // Take the sum of reduced elements
|
|
|
|
#define REDUCE_METHOD_MAX 2 // Take the maximum of reduced elements
|
|
|
|
#define REDUCE_METHOD_MIN 3 // Take the minimum of reduced elements
|
|
|
|
|
2003-01-29 21:13:15 +00:00
|
|
|
class REDUCED_ARRAY {
|
|
|
|
public:
|
|
|
|
int sdimx, sdimy; // size of the source array
|
|
|
|
int rdimx, rdimy; // size of the reduced array
|
|
|
|
int rdimx_max, rdimy_max; // maximum sizes of reduced array
|
|
|
|
// (determined by window size)
|
|
|
|
int scury; // next row of source array
|
|
|
|
float* rdata;
|
|
|
|
float rdata_max; // estimated or actual maximum
|
2003-02-19 00:06:05 +00:00
|
|
|
float rdata_min; // estimated or actual minimum
|
2003-01-29 21:13:15 +00:00
|
|
|
float* ftemp;
|
|
|
|
int* itemp;
|
|
|
|
// the following 2 are relevant only if sdimy > rdimy
|
|
|
|
int last_ry; // last row index accumulated into
|
|
|
|
int last_ry_count; // number of source rows accumulated so far
|
|
|
|
int nvalid_rows; // number of valid rows in reduced array
|
|
|
|
int ndrawn_rows; // number of rows drawn so far
|
|
|
|
float draw_pos[3];
|
|
|
|
float draw_size[3];
|
|
|
|
float draw_deltax;
|
|
|
|
float draw_deltaz;
|
2003-02-19 00:06:05 +00:00
|
|
|
int reduce_method; // Which method to use for data row reduction
|
2003-01-29 21:13:15 +00:00
|
|
|
double hue0;
|
|
|
|
double dhue;
|
|
|
|
|
|
|
|
REDUCED_ARRAY();
|
|
|
|
~REDUCED_ARRAY();
|
|
|
|
void init(int, int);
|
|
|
|
void init_draw(float*, float*, double, double);
|
|
|
|
void set_max_dims(int, int);
|
|
|
|
void reduce_source_row(float*, float*);
|
|
|
|
void add_source_row(float*);
|
|
|
|
bool full();
|
|
|
|
void reset();
|
|
|
|
void update_max(int row);
|
|
|
|
float* rrow(int j) {
|
|
|
|
return rdata + j*rdimx;
|
|
|
|
}
|
|
|
|
void draw_row_quad(int);
|
|
|
|
void draw_row_rect_x(int);
|
|
|
|
void draw_row_rect_y(int);
|
|
|
|
void draw_row_line(int);
|
|
|
|
void draw(int, int);
|
|
|
|
void draw_new();
|
|
|
|
void draw_all();
|
2003-02-06 00:24:30 +00:00
|
|
|
void draw_part(double frac);
|
2003-01-29 21:13:15 +00:00
|
|
|
void draw_axes();
|
2003-02-06 00:24:30 +00:00
|
|
|
};
|