2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
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.
|
|
|
|
|
2017-04-08 06:54:49 +00:00
|
|
|
#ifndef BOINC_REDUCE_H
|
|
|
|
#define BOINC_REDUCE_H
|
2003-02-19 00:06:05 +00:00
|
|
|
|
2007-10-22 23:12:42 +00:00
|
|
|
#define MAX_DATA 65536
|
|
|
|
#define MAX_DIMX 1024
|
|
|
|
|
|
|
|
struct REDUCED_ARRAY_DATA {
|
|
|
|
float rdata[MAX_DATA];
|
|
|
|
int rdimx, rdimy; // size of the reduced array
|
|
|
|
float rdata_max; // max value in array
|
|
|
|
float rdata_min; // min value in array
|
|
|
|
inline float* rrow(int j) {
|
|
|
|
return rdata + j*rdimx;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// THE PART RELEVANT TO GENERATION FOLLOWS
|
|
|
|
|
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
|
|
|
|
|
2007-10-22 23:12:42 +00:00
|
|
|
struct REDUCED_ARRAY_GEN: REDUCED_ARRAY_DATA {
|
|
|
|
float ftemp[MAX_DIMX];
|
|
|
|
int itemp[MAX_DIMX];
|
|
|
|
int sdimx, sdimy; // size of the source array
|
|
|
|
int scury; // next row of source array
|
|
|
|
// 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 reduce_method; // Which method to use for data row reduction
|
|
|
|
|
|
|
|
void init_data(int, int);
|
|
|
|
void reduce_source_row(float*, float*);
|
|
|
|
void add_source_row(float*);
|
|
|
|
bool full();
|
|
|
|
void reset();
|
|
|
|
void update_max(int row);
|
|
|
|
};
|
|
|
|
|
|
|
|
// THE PART RELEVANT TO RENDERING FOLLOWS
|
|
|
|
|
2003-10-09 00:55:38 +00:00
|
|
|
enum GRAPH_STYLE {
|
|
|
|
GRAPH_STYLE_RECTANGLES,
|
|
|
|
GRAPH_STYLE_PLANES,
|
|
|
|
GRAPH_STYLE_WIREFRAME,
|
|
|
|
GRAPH_STYLE_SURFACE
|
2003-10-06 16:10:33 +00:00
|
|
|
};
|
2003-09-18 23:55:11 +00:00
|
|
|
|
2007-10-22 23:12:42 +00:00
|
|
|
struct REDUCED_ARRAY_RENDER: REDUCED_ARRAY_DATA {
|
2003-01-29 21:13:15 +00:00
|
|
|
int ndrawn_rows; // number of rows drawn so far
|
|
|
|
float draw_pos[3];
|
|
|
|
float draw_size[3];
|
|
|
|
float draw_deltax;
|
|
|
|
float draw_deltaz;
|
|
|
|
double hue0;
|
|
|
|
double dhue;
|
2003-02-28 23:32:20 +00:00
|
|
|
float alpha;
|
2003-10-24 21:21:46 +00:00
|
|
|
char* xlabel,*ylabel,*zlabel;
|
2003-10-09 00:55:38 +00:00
|
|
|
GRAPH_STYLE draw_style;
|
2007-10-22 23:12:42 +00:00
|
|
|
double start_time;
|
2003-01-29 21:13:15 +00:00
|
|
|
|
2007-10-22 23:12:42 +00:00
|
|
|
void init(double grow, double hold);
|
2003-10-31 22:37:46 +00:00
|
|
|
void init_display(
|
|
|
|
GRAPH_STYLE, float*, float*, double, double, float, char*, char*, char*
|
|
|
|
);
|
2007-11-27 19:28:57 +00:00
|
|
|
void new_array();
|
2003-01-29 21:13:15 +00:00
|
|
|
void draw_row_quad(int);
|
2003-09-26 20:10:45 +00:00
|
|
|
void draw_row_rect_x(int);
|
2003-01-29 21:13:15 +00:00
|
|
|
void draw_row_rect_y(int);
|
|
|
|
void draw_row_line(int);
|
2003-09-26 20:10:45 +00:00
|
|
|
void draw(int, int);
|
2003-01-29 21:13:15 +00:00
|
|
|
void draw_new();
|
|
|
|
void draw_all();
|
2003-09-26 20:10:45 +00:00
|
|
|
void draw_part(double frac);
|
2003-01-29 21:13:15 +00:00
|
|
|
void draw_axes();
|
2003-09-10 23:44:46 +00:00
|
|
|
void draw_axis_labels();
|
2023-05-05 18:05:20 +00:00
|
|
|
void draw_labels();
|
2003-02-06 00:24:30 +00:00
|
|
|
};
|
2003-10-03 22:51:28 +00:00
|
|
|
|
2003-10-23 15:39:54 +00:00
|
|
|
#endif
|