// Berkeley Open Infrastructure for Network Computing // http://boinc.berkeley.edu // Copyright (C) 2005 University of California // // This 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 2.1 of the License, or (at your option) any later version. // // This software 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. // // To view the GNU Lesser General Public License visit // http://www.gnu.org/copyleft/lesser.html // or write to the Free Software Foundation, Inc., // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // shared-library part of the implementation of REDUCE #if defined(_WIN32) && !defined(__STDWX_H__) && !defined(_BOINC_WIN_) && !defined(_AFX_STDAFX_H_) #include "boinc_win.h" #endif #ifdef _WIN32 #include #endif #include #include "boinc_gl.h" #include "gutil.h" #include "reduce.h" void REDUCED_ARRAY::draw_row_quad(int row) { float z0 = draw_pos[2] + (draw_size[2]*row)/rdimy; float z1 = z0 + draw_deltaz; float x0, x1, y00, y01, y10, y11; float* row0 = rrow(row); float* row1 = rrow(row+1); int i; glBegin(GL_QUADS); // TODO: use GL_QUADSTRIP for (i=0; i 1) hue -= 1; double sat = 1.; double lum = .5 + h/2; COLOR color; HLStoRGB(hue, lum, sat, color); glColor4f(color.r, color.g, color.b, alpha); glVertex3f(x0, y00, z0); glVertex3f(x1, y01, z0); glVertex3f(x1, y11, z1); glVertex3f(x0, y10, z1); } glEnd(); #if 0 // draw a black line on front and right edge of each quad // glLineWidth(4.0); glDisable(GL_LINE_SMOOTH); glBegin(GL_LINES); glColor4f(0., 0., 0., 1.0); for (i=0; i 1) hue -= 1; sat = 1.; lum = .5 + h/2; HLStoRGB(hue, lum, sat, color); glColor4f(color.r, color.g, color.b, alpha); //front glVertex3f(x0, y0, z0); glVertex3f(x1, y0, z0); glVertex3f(x1, y1, z0); glVertex3f(x0, y1, z0); /* //back glVertex3f(x0, y0, z1); glVertex3f(x1, y0, z1); glVertex3f(x1, y1, z1); glVertex3f(x0, y1, z1); //left glVertex3f(x0, y0, z0); glVertex3f(x0, y0, z1); glVertex3f(x0, y1, z1); glVertex3f(x0, y1, z0); //right glVertex3f(x1, y0, z0); glVertex3f(x1, y0, z1); glVertex3f(x1, y1, z1); glVertex3f(x1, y1, z0); //top glVertex3f(x0, y1, z0); glVertex3f(x0, y1, z1); glVertex3f(x1, y1, z1); glVertex3f(x1, y1, z0); */ } glEnd(); #if 0 //draw lines mode_unshaded(); glLineWidth(.5f); glBegin(GL_LINES); glColor4f(0,0,0,1); for (i=0; i 1) hue -= 1; sat = 1.; lum = .5 + h/2; HLStoRGB(hue, lum, sat, color); glColor4f(color.r, color.g, color.b, alpha); if(row!=0) { float lh = (trow0[i]-rdata_min)/(rdata_max-rdata_min); float ly = draw_pos[1] + draw_size[1]*lh; float lz = draw_pos[2] + (draw_size[2]*trow)/rdimy + .14f; glVertex3f(xm,ly,lz); glVertex3f(xm,y1,z1); } } glEnd(); break; case GRAPH_STYLE_WIREFRAME: glLineWidth(1.0f); z0 = draw_pos[2] + (draw_size[2]*row)/rdimy; z1 = z0+.14f; row0 = rrow(row); if(row!=0) trow0 = rrow(trow); glEnable(GL_LINE_SMOOTH); glBegin(GL_LINES); for (i=0; i 1) hue -= 1; sat = 1.; lum = .5 + h/2; HLStoRGB(hue, lum, sat, color); glColor4f(color.r, color.g, color.b, alpha); if(i!=rdimx-1) glVertex3f(x0+((x1-x0)/2.0f), y1, z0); if(row!=0) { float h2 = (trow0[i]-rdata_min)/(rdata_max-rdata_min); float z2 = draw_pos[2] + (draw_size[2]*trow)/rdimy; float y2 = draw_pos[1] + draw_size[1]*h2; glVertex3f(x0+((x1-x0)/2.0f), y1, z0); glVertex3f(x0+((x1-x0)/2.0f), y2, z2); } if(i!=0) glVertex3f(x0+((x1-x0)/2.0f), y1, z0); } glEnd(); glDisable(GL_LINE_SMOOTH); break; case GRAPH_STYLE_PLANES: z0 = draw_pos[2] + (draw_size[2]*row)/rdimy; z1 = z0+.14f; row0 = rrow(row); i=0; x0 = draw_pos[0] + (draw_size[0]*i)/rdimx; x1 = x0 + draw_deltax*.8f; h = (row0[i]-rdata_min)/(rdata_max-rdata_min); y0 = draw_pos[1]; y1 = draw_pos[1] + draw_size[1]*h; hue = hue0 + (dhue*i)/rdimx; if (hue > 1) hue -= 1; sat = 1.; lum = .5 + h/2; HLStoRGB(hue, lum, sat, color); glColor4f(color.r, color.g, color.b, alpha); glVertex3f(draw_pos[0],draw_pos[1],z0); glVertex3f(draw_pos[0],draw_pos[1],draw_pos[2] + (draw_size[2]*trow)/rdimy); glBegin(GL_QUAD_STRIP); for (i=0; i 1) hue -= 1; sat = 1.; lum = .5 + h/2; HLStoRGB(hue, lum, sat, color); glColor4f(color.r, color.g, color.b, alpha); glVertex3d(x1,y0,z0); glVertex3d(x1,y1,z0); } glEnd(); break; default: break; } } void REDUCED_ARRAY::draw_row_rect_y(int row) { float z0 = draw_pos[2] + (draw_size[2]*row)/rdimy; float z1 = z0 + draw_deltaz*.8f; float x0, y0, y1; float* row0 = rrow(row); int i; glBegin(GL_QUADS); for (i=0; i 1) hue -= 1; double sat = 1.; double lum = .5 + h/2; COLOR color; HLStoRGB(hue, lum, sat, color); glColor4f(color.r, color.g, color.b, alpha); glVertex3f(x0, y0, z0); glVertex3f(x0, y1, z0); glVertex3f(x0, y1, z1); glVertex3f(x0, y0, z1); } glEnd(); // draw a black line on top of rectangle // #if 0 glBegin(GL_LINES); glColor4f(0., 0., 0., 1.0); for (i=0; i (double)w) { model[1]*=1.0f/(((double)w/aspect_ratio)/(double)h); model[5]*=1.0f/(((double)w/aspect_ratio)/(double)h); model[9]*=1.0f/(((double)w/aspect_ratio)/(double)h); } else { model[0]*=1.0f/(((double)h*aspect_ratio)/(double)w); model[4]*=1.0f/(((double)h*aspect_ratio)/(double)w); model[8]*=1.0f/(((double)h*aspect_ratio)/(double)w); } //project to ortho coordinates viewport[0]=0; viewport[1]=0; viewport[2]=1; viewport[3]=1; get_2d_positions(draw_pos[0],draw_pos[1],draw_pos[2]+(draw_size[2]/2.0f), model, proj, viewport,z_pos ); get_2d_positions(draw_pos[0]+draw_size[0]/2.0f,draw_pos[1],draw_pos[2]+draw_size[2], model, proj, viewport,x_pos ); get_2d_positions(draw_pos[0]+draw_size[0]+.2f,draw_pos[1]+.6f,draw_pos[2]+draw_size[2]-.4f, model, proj, viewport,p_pos ); glPopMatrix(); mode_ortho(); mode_unshaded(); glColor3d(1,1,1); float zpos[3]={(float)z_pos[0],(float)z_pos[1],(float)z_pos[2]}; float xpos[3]={(float)x_pos[0],(float)x_pos[1],(float)x_pos[2]}; float ppos[3]={(float)p_pos[0],(float)p_pos[1],(float)p_pos[2]}; draw_text_right(zpos,ch,lw,ls,zlabel); draw_text(xpos,ch,lw,ls,xlabel); draw_text(ppos,ch,lw,ls,ylabel); ortho_done(); } const char *BOINC_RCSID_f4749d0d37="$Id$";