From d1341edcec1a950d3b6bc3f3f80d2c400867dfbd Mon Sep 17 00:00:00 2001 From: Oliver Wang Date: Wed, 10 Sep 2003 23:44:46 +0000 Subject: [PATCH] Added code for stars to Astropulse client Added support for draw_rotated_text Changed axes drawing methods svn path=/trunk/boinc/; revision=2321 --- api/gutil.C | 18 ++++++++-- api/gutil.h | 5 +++ api/reduce.C | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++- api/reduce.h | 1 + apps/concat.C | 2 +- 5 files changed, 116 insertions(+), 5 deletions(-) diff --git a/api/gutil.C b/api/gutil.C index b71c9d0ded..1a9bcd956d 100755 --- a/api/gutil.C +++ b/api/gutil.C @@ -190,13 +190,14 @@ static void draw_text_line_aux(char *text) { static void draw_text_start(GLfloat* pos, GLfloat char_height, GLfloat line_width) { glLineWidth(line_width); - glPushMatrix(); + glPushMatrix(); glTranslatef(pos[0], pos[1], pos[2]); float w = char_height/STROKE_SCALE; - glScalef(w, w, w); + glScalef(w, w, w); + } -static void draw_text_end() { +static void draw_text_end() { glPopMatrix(); } @@ -228,6 +229,17 @@ void draw_text_line( draw_text_end(); } +// draw rotated text +void draw_rotated_text( + GLfloat* pos, GLfloat height, GLfloat width, GLfloat spacing, char *text, + GLfloat rotation, GLfloat* rotation_vector) +{ + draw_text_start(pos, height, width); + glRotatef(rotation,rotation_vector[0],rotation_vector[1],rotation_vector[2]); + draw_text_line_aux(text); + draw_text_end(); +} + // draw multiple lines of text // void draw_text( diff --git a/api/gutil.h b/api/gutil.h index c5e28c7d95..bfe214e0a7 100755 --- a/api/gutil.h +++ b/api/gutil.h @@ -45,6 +45,11 @@ extern void draw_text_line( extern void draw_text( GLfloat* pos, GLfloat height, GLfloat width, GLfloat spacing, char *text ); + +extern void draw_rotated_text( + GLfloat* pos, GLfloat height, GLfloat width, GLfloat spacing, char *text, GLfloat rotation, GLfloat* rotation_vector +); + extern GLfloat text_width(char* text); extern void draw_text_panel( GLfloat* _pos, GLfloat* size, GLfloat margin, COLOR color, diff --git a/api/reduce.C b/api/reduce.C index 926e49e079..3efed44c2d 100644 --- a/api/reduce.C +++ b/api/reduce.C @@ -258,7 +258,7 @@ void REDUCED_ARRAY::draw_row_quad(int row) { #endif } -void REDUCED_ARRAY::draw_row_rect_x(int row) { +void REDUCED_ARRAY::draw_row_rect_x(int row) { float z0 = draw_pos[2] + (draw_size[2]*row)/rdimy; float x0, x1, y0, y1; float* row0 = rrow(row); @@ -394,7 +394,98 @@ void REDUCED_ARRAY::draw_part(double frac) { draw(0, nr); } + +void REDUCED_ARRAY::draw_axis_labels() +{ + GLfloat char_height = .5f; + GLfloat line_width = 3.0f; + GLfloat spacing = 2.0f; + GLfloat rotation = -90; + GLfloat rotation_vector[3] = {0,0,0}; + + float w; + + char* x_label = "Time"; + char* y_label = "Frequency"; + char* y_begin_label = "0"; + char* y_end_label = "9 Khz"; + + float x_text_pos[3] = {0,0,0}; + w = text_width(x_label); + x_text_pos[0]=draw_pos[0]-.3;//+draw_size[0]; + x_text_pos[1]=draw_pos[1];//+draw_size[1]; + x_text_pos[2]=draw_pos[2]+draw_size[2]-(w/2.0f); + + rotation_vector[0]=0; + rotation_vector[1]=draw_size[1]; + rotation_vector[2]=0; + + draw_rotated_text(x_text_pos,char_height,line_width,spacing,x_label,rotation,rotation_vector); + //draw_text_line(x_text_pos,char_height,line_width,x_label,0); + +} + void REDUCED_ARRAY::draw_axes() { + + mode_unshaded(); + + glLineWidth(1.0); + glEnable(GL_LINE_SMOOTH); + glBegin(GL_LINES); + glColor4d(1,1,1,.9); + + //base square + glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]); + glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1], draw_pos[2]); + + glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]); + glVertex3f(draw_pos[0], draw_pos[1]+draw_size[1], draw_pos[2]); + + glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1], draw_pos[2]); + glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1]+draw_size[1], draw_pos[2]); + + glVertex3f(draw_pos[0], draw_pos[1]+draw_size[1], draw_pos[2]); + glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1]+draw_size[1], draw_pos[2]); + + //top square + glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]+draw_size[2]); + glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1], draw_pos[2]+draw_size[2]); + + glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]+draw_size[2]); + glVertex3f(draw_pos[0], draw_pos[1]+draw_size[1], draw_pos[2]+draw_size[2]); + + glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1], draw_pos[2]+draw_size[2]); + glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1]+draw_size[1], draw_pos[2]+draw_size[2]); + + glVertex3f(draw_pos[0], draw_pos[1]+draw_size[1], draw_pos[2]+draw_size[2]); + glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1]+draw_size[1], draw_pos[2]+draw_size[2]); + + //connecting lines + glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]); + glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]+draw_size[2]); + + glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1], draw_pos[2]); + glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1], draw_pos[2]+draw_size[2]); + + glVertex3f(draw_pos[0], draw_pos[1]+draw_size[1], draw_pos[2]); + glVertex3f(draw_pos[0], draw_pos[1]+draw_size[1], draw_pos[2]+draw_size[2]); + + glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1]+draw_size[1], draw_pos[2]); + glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1]+draw_size[1], draw_pos[2]+draw_size[2]); + glEnd(); + + //text + + + +//mode_texture(); + + GLfloat violet[] = {0.6f, 0.3f, .8f, .7f}; + mode_shaded(violet); +//mode_unshaded(); +//mode_lines(); + + /* glBegin(GL_QUADS); glColor3d(.2, .2, .2); @@ -403,4 +494,6 @@ void REDUCED_ARRAY::draw_axes() { glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1], draw_pos[2]+draw_size[2]); glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]+draw_size[2]); glEnd(); + */ + } diff --git a/api/reduce.h b/api/reduce.h index edfc5345a9..0af73d0644 100644 --- a/api/reduce.h +++ b/api/reduce.h @@ -73,4 +73,5 @@ public: void draw_all(); void draw_part(double frac); void draw_axes(); + void draw_axis_labels(); }; diff --git a/apps/concat.C b/apps/concat.C index 56f58655d4..aa9f52f267 100644 --- a/apps/concat.C +++ b/apps/concat.C @@ -85,7 +85,7 @@ void file_append(FILE* in, MFILE &out, int skip, int filenum) { #ifdef _WIN32 #include int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR Args, int WinMode) { - LPWSTR command_line; + LPWSTR command_line; LPWSTR *args; char* argv[100]; int i, argc;