25 Baxis() {
id=0; lab=0; mn=0; mx=0; ic=0; flg=0; }
30 double min() {
return mn; }
31 void min(
double v) { mn = v; }
32 double max() {
return mx; }
33 void max(
double v) { mx = v; }
34 double inc() {
return ic; }
35 void inc(
double v) { ic = v; }
37 void color(
double r,
double g,
double b) { cl[0]=r; cl[1]=g; cl[2]=b; }
65 void label(
const char* s) { lab = s; }
67 void type(
long v) { tp = v; }
69 void axis(
long v) { ax = v; }
70 double min() {
return mn; }
71 void min(
double v) { mn = v; }
72 double max() {
return mx; }
73 void max(
double v) { mx = v; }
77 void color(
double r,
double g,
double b) { cl[0]=r; cl[1]=g; cl[2]=b; }
78 double red() {
return cl[0]; }
79 double green() {
return cl[1]; }
80 double blue() {
return cl[2]; }
92 tit = 0; txt = NULL; num = 0; nc = 0;
102 void title(
const char* t) { tit = t; }
111 if ( i<nc )
return col[i];
112 cerr <<
"Error: The column requested, " << i <<
" for page " << num <<
113 " is greater than the number of columns, " << nc << endl << endl;
116 void axes() {
for (
long i=0; i<5; i++ ) ax[i].which(i+1); }
118 if (
id > 0 &&
id < 6 )
return ax[
id-1];
126 for ( c=0; c<nc; c++ ) {
128 if ( i > 0 && i < 6 ) {
131 if ( ax[i].min() == ax[i].max() ) {
132 ax[i].
min(col[c].min());
133 ax[i].
max(col[c].max());
138 for ( i=0; i<5; i++ ) {
139 if ( ax[i].min() == ax[i].max() ) ax[i].
max(ax[i].min() + 1);
140 if ( ax[i].inc() == 0 ) ax[i].
inc((ax[i].max() - ax[i].min())/10);
157 void initialize(
long npage=0,
long nrow=0,
long ncol=0) {
169 data =
new double[nc*nr];
170 for (
long i=0; i<nr*nc; i++ ) data[i] = 0;
175 Bplot(
long npage,
long nrow,
long ncol) {
176 initialize(npage, nrow, ncol);
181 delete[] pg; pg = NULL;
182 delete[] data; data = NULL;
184 void reset(
long npage,
long nrow,
long ncol) {
185 if ( pg )
delete[] pg;
186 if ( data )
delete[] data;
187 initialize(npage, nrow, ncol);
190 while ( i < 0 ) i += nr*nc;
191 while ( i >= nr*nc ) i -= nr*nc;
196 void title(
const char* t) { tit = t; }
200 void size(
long w,
long h) { gw = w; gh = h; }
203 void origin(
long l,
long b) { gl = l; gb = b; }
209 for (
long i=0; i<np; i++ ) pg[i].number(i+1);
217 if ( pg && i >=0 && i < np )
return pg[i];
219 cerr <<
"Error: The plot page " << i <<
" cannot be found!" << endl;
229 for ( n=0; n<np; n++ ) {
230 for ( c=0; c<pg[n].
columns(); c++ ) {
232 if ( col.
min() == col.
max() ) {
233 min = 1e100; max = -1e100;
234 for ( i=col.
number()*nr, j=0; j<nr; i++, j++ ) {
235 if ( min > data[i] ) min = data[i];
236 if ( max < data[i] ) max = data[i];
246 for (
long i=start*nr; i<nr*nc; i++ ) data[i] += p->data[i];
249 for (
long i=0; i<nr*nc; i++ ) data[i] *= d;
251 double cut(
long icol,
double threshold,
int dir=1) {
253 double val((data[0]+data[1])/2);
254 for ( i=0, i1=1, j=icol*nr, j1=j+1; i1<nr; i++, i1++, j++, j1++ ) {
256 if ( data[j] >= threshold && data[j1] < threshold )
257 val = data[i] + (data[i1] - data[i])*(threshold - data[j])/(data[j1] - data[j]);
259 if ( data[j] <= threshold && data[j1] > threshold )
260 val = data[i] + (data[i1] - data[i])*(threshold - data[j])/(data[j1] - data[j]);
263 if ( val < data[1] ) {
265 if ( data[j] > threshold ) val = data[i];
267 if ( data[j] < threshold ) val = data[i];
274 ofstream ftsv(filename.
c_str());
275 if ( ftsv.fail() )
return;
279 for ( i=0; i<nr; i++ ) {
281 for ( j=1, k=nr+i; j<nc; j++, k+=nr ) ftsv <<
tab << data[k];