Added code for stars to Astropulse client

Added support for draw_rotated_text
Changed axes drawing methods

svn path=/trunk/boinc/; revision=2321
This commit is contained in:
Oliver Wang 2003-09-10 23:44:46 +00:00
parent 626ab44e15
commit d1341edcec
5 changed files with 116 additions and 5 deletions

View File

@ -194,6 +194,7 @@ static void draw_text_start(GLfloat* pos, GLfloat char_height, GLfloat line_widt
glTranslatef(pos[0], pos[1], pos[2]); glTranslatef(pos[0], pos[1], pos[2]);
float w = char_height/STROKE_SCALE; float w = char_height/STROKE_SCALE;
glScalef(w, w, w); glScalef(w, w, w);
} }
static void draw_text_end() { static void draw_text_end() {
@ -228,6 +229,17 @@ void draw_text_line(
draw_text_end(); 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 // draw multiple lines of text
// //
void draw_text( void draw_text(

View File

@ -45,6 +45,11 @@ extern void draw_text_line(
extern void draw_text( extern void draw_text(
GLfloat* pos, GLfloat height, GLfloat width, GLfloat spacing, char *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 GLfloat text_width(char* text);
extern void draw_text_panel( extern void draw_text_panel(
GLfloat* _pos, GLfloat* size, GLfloat margin, COLOR color, GLfloat* _pos, GLfloat* size, GLfloat margin, COLOR color,

View File

@ -394,7 +394,98 @@ void REDUCED_ARRAY::draw_part(double frac) {
draw(0, nr); 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() { 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); glBegin(GL_QUADS);
glColor3d(.2, .2, .2); 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_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_pos[2]+draw_size[2]);
glEnd(); glEnd();
*/
} }

View File

@ -73,4 +73,5 @@ public:
void draw_all(); void draw_all();
void draw_part(double frac); void draw_part(double frac);
void draw_axes(); void draw_axes();
void draw_axis_labels();
}; };