void GLText::drawFreeString(const char *string, float x, float y) { glColor3fv(fontColor); glDisable(GL_DEPTH_TEST); gl_font(fontType, fontSize ); gl_draw(string, x, y ); }
void GLWidget::paintGL() { gl_draw(); if(m_text.size() > 0) { glColor4f(0.0, 0.0, 0.0, 1.0); renderText(size().width()-120, 22, QString(m_text), QFont("Helvetica",20)); } }
void GLText::drawFreeString(const char *string) { glColor3fv(fontColor); glDisable(GL_DEPTH_TEST); gl_font(fontType, fontSize ); gl_draw(string, 0.0f, 0.0f ); glEnable(GL_DEPTH_TEST); }
static void rot_y_upd (GtkWidget *wdg, gpointer data) { // Rotation around vertical axis (Y) gl_preview_struct *gl_preview = (gl_preview_struct *) data; camera_struct *camera = gl_preview->cameras[gl_preview->current_camera_id]; if (camera->rot_y == (gint) GTK_ADJUSTMENT(wdg)->value) return; camera->rot_y = (gint) GTK_ADJUSTMENT(wdg)->value; FLAG_CAMERA_CHANGE = TRUE; gl_draw (GTK_WIDGET(gl_preview->gl_area)); // gtk_widget_queue_draw(GTK_WIDGET(gl_preview->gl_area)); }
static void distance_upd (GtkWidget *wdg, gpointer data) { // Distance (depth / viewpoint translation on Z axis) gl_preview_struct *gl_preview = (gl_preview_struct *) data; camera_struct *camera = gl_preview->cameras[gl_preview->current_camera_id]; if (camera->distance == (gfloat) GTK_ADJUSTMENT(wdg)->value) return; camera->distance = (gfloat) GTK_ADJUSTMENT(wdg)->value; FLAG_CAMERA_CHANGE = TRUE; gl_draw (GTK_WIDGET(gl_preview->gl_area)); // gtk_widget_queue_draw(GTK_WIDGET(gl_preview->gl_area)); }
static void translate_y_upd (GtkWidget *wdg, gpointer data) { // Translation on Y axis (vertical) gl_preview_struct *gl_preview = (gl_preview_struct *) data; camera_struct *camera = gl_preview->cameras[gl_preview->current_camera_id]; if (camera->translate_y == (gfloat) GTK_ADJUSTMENT(wdg)->value) return; camera->translate_y = (gfloat) GTK_ADJUSTMENT(wdg)->value; FLAG_CAMERA_CHANGE = TRUE; gl_draw (GTK_WIDGET(gl_preview->gl_area)); // gtk_widget_queue_draw(GTK_WIDGET(gl_preview->gl_area)); }
static void angle_w_upd (GtkWidget *wdg, gpointer data) { // Angle variation // Specified in the widget as horizontal (the Povray standard), // must be transformed to vertical in OpenGL gl_preview_struct *gl_preview = (gl_preview_struct *) data; camera_struct *camera = gl_preview->cameras[gl_preview->current_camera_id]; if (camera->angle_w == (gint) GTK_ADJUSTMENT(wdg)->value) return; camera->angle_w = (gint) GTK_ADJUSTMENT(wdg)->value; set_perspective(camera); FLAG_CAMERA_CHANGE = TRUE; gl_draw (GTK_WIDGET(gl_preview->gl_area)); // gtk_widget_queue_draw(GTK_WIDGET(gl_preview->gl_area)); }
void shape_window::draw_overlay() { // the valid() property may be used to avoid reinitializing your // GL transformation for each redraw: if (!valid()) { valid(1); glLoadIdentity(); glViewport(0,0,w(),h()); } // draw an amazing graphic: gl_color(FL_RED); glBegin(GL_LINE_LOOP); for (int i=0; i<overlay_sides; i++) { double ang = i*2*M_PI/overlay_sides; glVertex3f(cos(ang),sin(ang),0); } glEnd(); glEnd(); gl_font(FL_HELVETICA, 12); gl_draw("overlay text", .1, .6); }
void shape_window::draw() { // the valid() property may be used to avoid reinitializing your // GL transformation for each redraw: if (!valid()) { valid(1); glLoadIdentity(); glViewport(0,0,w(),h()); } glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); for (int i=0; i<sides; i++) { double ang = i*2*M_PI/sides; glColor3f(float(i)/sides,float(i)/sides,float(i)/sides); glVertex3f(cos(ang),sin(ang),0); } glEnd(); gl_color(FL_WHITE); gl_font(FL_HELVETICA, 12); gl_draw("text", .1, .5); }
void GLText::drawFlatString(const char *string, float x, float y) { Geometry::Matrix<float,4,4> tempmat; glGetFloatv(GL_PROJECTION_MATRIX, (GLfloat *)&tempmat); glPushMatrix(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0f, pw, 0.0f, ph, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glColor3fv(fontColor); gl_font(fontType, fontSize ); gl_draw(string, x, y ); glPopMatrix(); glMatrixMode(GL_PROJECTION); glLoadMatrixf((GLfloat *)&tempmat); glMatrixMode(GL_MODELVIEW); }
void refresh_gl_callb(GtkWidget *refresh_button, gpointer data) { gl_preview_struct *gl_preview = (gl_preview_struct *) data; // gint t1; // printf("Refresh_gl_callb - 1\n"); if (!gl_preview) return; if (!gl_preview->gl_area) return; if (!gl_preview->refresh_on_mouse_down) return; // printf("Refresh_gl_callb - 2\n"); // t1 = clock(); // printf("(X,Y): (%d,%d); Mesh size: %d;\n",gl_preview->max_x, gl_preview->max_y, gl_preview->mesh_size); if (glIsList(gl_preview->hf_list)) glDeleteLists(gl_preview->hf_list,1); // if (glIsList(lights_list)) // glDeleteLists(lights_list,1); create_vertices(gl_preview); gl_preview->hf_list = create_hf_list(gl_preview); // lights_list = create_lights(); // Expose the gl_area widget gl_draw (GTK_WIDGET(gl_preview->gl_area)); // printf("Mesh size: %d; preview refresh delay: %d\n",gl_preview->mesh_size, clock() - t1); }
void gl_draw(const char* str, int n, float x, float y, float z) { glRasterPos3d(x, y, z); gl_draw(str, n); }
void gl_draw(const char* str, float x, float y, float z) { gl_draw(str, strlen(str), x, y, z); }
int main( void ) { int fullscreen; XEvent event; if( gl_data() ) { fprintf( stderr, "gl_data failed\n" ); return( 1 ); } fullscreen = 0; do { modeswitch = 0; fullscreen ^= 1; if( glx_init( fullscreen ) ) { fprintf( stderr, "glx_init failed\n" ); return( 1 ); } if( gl_init() ) { fprintf( stderr, "gl_init failed\n" ); return( 1 ); } gl_resize(); run = 1; while( run ) { if( active ) { gl_draw(); glXSwapBuffers( dpy, win ); } else { XPeekEvent( dpy, &event ); } while( XPending( dpy ) ) { XNextEvent( dpy, &event ); switch( event.type ) { case ButtonPress: { int x = event.xmotion.x, y = event.xmotion.y; switch( event.xbutton.button ) { case Button1: gl_event( 0, 0, x, y ); break; case Button3: gl_event( 0, 1, x, y ); break; } break; } case ButtonRelease: { int x = event.xmotion.x, y = event.xmotion.y; switch( event.xbutton.button ) { case Button1: gl_event( 1, 0, x, y ); break; case Button3: gl_event( 1, 1, x, y ); break; } break; } case MotionNotify: { int x = event.xmotion.x, y = event.xmotion.y; switch( event.xbutton.button ) { case Button1: gl_event( 2, 0, x, y ); break; case Button3: gl_event( 2, 1, x, y ); break; default: gl_event( 2, -1, x, y ); break; } break; } case KeyPress: { break; } case KeyRelease: { int key = XLookupKeysym( &event.xkey, 0 ); switch( key ) { case XK_Tab: modeswitch = 1; case XK_Escape: run = 0; break; default: gl_event( 4, key, -1, -1 ); break; } break; } case UnmapNotify: active = 0; break; case MapNotify: active = 1; break; case ConfigureNotify: { width = event.xconfigure.width; height = event.xconfigure.height; gl_resize(); break; } case ClientMessage: { if( event.xclient.data.l[0] == (int) wmDelete ) { active = run = 0; } break; } case ReparentNotify: break; default: { printf( "caught unknown event, type %d\n", event.type ); break; } } } } glXMakeCurrent( dpy, None, NULL ); glXDestroyContext( dpy, ctx ); XDestroyWindow( dpy, win ); XCloseDisplay( dpy ); } while( modeswitch ); return( 0 ); }
static void gl_area_redraw (GtkWidget *wdg, gpointer data) { // Simple redraw, for instance when changing the water plane height gl_preview_struct *gl_preview = (gl_preview_struct *) data; gl_draw (GTK_WIDGET(gl_preview->gl_area)); }
gint glarea_motion_notify (GtkWidget* widget, GdkEventMotion* event, gpointer data) { int x; int y; GdkModifierType state; camera_struct *camera; gl_preview_struct *gl_hf = (gl_preview_struct *) data; camera = gl_hf->cameras[gl_hf->current_camera_id]; if (event->is_hint) { gdk_window_get_pointer(event->window, &x, &y, &state); } else { x = event->x; y = event->y; state = event->state; } if (state & GDK_BUTTON1_MASK) { if (gl_hf->mouse_dragging1) { camera->rot_y += (gint) ((360.0 / (gfloat) gl_hf->view_size) * (gfloat) (x - gl_hf->last_x)); camera->rot_y = (360+camera->rot_y) % 360; gtk_adjustment_set_value( GTK_ADJUSTMENT(gl_hf->adj_rot_y), camera->rot_y); camera->rot_x += (gint) ((360.0 / (gfloat) gl_hf->view_size) * (gfloat) (y - gl_hf->last_y)); camera->rot_x = (360+camera->rot_x) % 360; gtk_adjustment_set_value( GTK_ADJUSTMENT(gl_hf->adj_rot_x), camera->rot_x); } } if (state & GDK_BUTTON2_MASK) { camera->translate_x += ((gfloat) (x - gl_hf->last_x)) / (gfloat) gl_hf->view_size; camera->translate_x = MAX(-1.0,MIN(camera->translate_x,1.0)); gtk_adjustment_set_value( GTK_ADJUSTMENT(gl_hf->adj_translate_x), camera->translate_x); camera->translate_y -= ((gfloat) (y - gl_hf->last_y)) / (gfloat) gl_hf->view_size; camera->translate_y = MAX(-1.0,MIN(camera->translate_y,1.0)); gtk_adjustment_set_value( GTK_ADJUSTMENT(gl_hf->adj_translate_y), camera->translate_y); } if (state & GDK_BUTTON3_MASK) { camera->distance += ((gfloat) (x - gl_hf->last_x)) / (gfloat) gl_hf->view_size; camera->distance -= ((gfloat) (y - gl_hf->last_y)) / (gfloat) gl_hf->view_size; camera->distance= MAX(0.0,MIN(camera->distance,5.0)); gtk_adjustment_set_value( GTK_ADJUSTMENT(gl_hf->adj_distance), camera->distance); } gl_hf->last_x = x; gl_hf->last_y = y; // gtk_widget_queue_draw(GTK_WIDGET(gl_hf->gl_area)); gl_draw(GTK_WIDGET(gl_hf->gl_area)); return TRUE; }
gl_preview_struct *create_gl_preview_dialog (gl_defaults_struct *gl_def, GtkWidget *window, gpointer input_grid, gint max_x, gint max_y, gint data_type, gboolean *use_water_ptr, gfloat *water_level_ptr) { GtkWidget *vbox, *vbox2, *hbox, *table, *wdg; gint i; gchar buf[2]=" "; gl_preview_struct *gl_preview; camera_struct *camera; GSList *group = NULL; // printf("CREATE_PREVIEW_DIALOG\n"); gl_preview = gl_preview_new (gl_def); gl_preview->grid = input_grid; gl_preview->max_x = max_x; gl_preview->max_y = max_y; gl_preview->data_type = data_type; gl_preview->use_water = use_water_ptr; gl_preview->water_level = water_level_ptr; if (!gl_preview) return NULL; gl_preview->gl_area = create_glarea(gl_preview, gl_def->view_size); if (!gl_preview->gl_area) { gl_preview_free(gl_preview); return NULL; } gl_preview->gl_dialog = frame_new("Preview",DEF_PAD); gl_preview->main_box = gtk_vbox_new(FALSE,0); gtk_widget_show(gl_preview->main_box); gtk_container_add(GTK_CONTAINER(gl_preview->gl_dialog), gl_preview->main_box); // Pack gl area + water plane in the main box // Create Hbox to put gl_area + water control Vbox hbox = gtk_hbox_new(FALSE,0); gtk_widget_show(GTK_WIDGET(hbox)); gtk_box_pack_start (GTK_BOX (hbox), gl_preview->gl_area, FALSE, FALSE, DEF_PAD*0.5); gtk_box_pack_start (GTK_BOX (hbox), gl_create_water_plane (gl_preview), FALSE, FALSE, DEF_PAD); gtk_box_pack_start (GTK_BOX (gl_preview->main_box), hbox, FALSE, FALSE, DEF_PAD); // Hbox for controls hbox = gtk_hbox_new(FALSE,0); gtk_widget_show(hbox); gl_preview->direct_upd = define_check_button_in_box ("Auto update",hbox, FALSE,FALSE,0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gl_preview->direct_upd), gl_def->direct_upd); gl_preview->refresh_button = gtk_button_new_with_label (_("Refresh")); gtk_signal_connect (GTK_OBJECT (gl_preview->refresh_button), "clicked", (GtkSignalFunc) refresh_gl_callb, gl_preview); gtk_widget_show(gl_preview->refresh_button); gtk_box_pack_start (GTK_BOX (hbox), gl_preview->refresh_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (gl_preview->main_box), align_widget(hbox,0.5,0.5), FALSE, FALSE, 0); hbox = gtk_hbox_new(FALSE,0); gtk_widget_show(hbox); define_label_in_box("Size", hbox, FALSE,TRUE, 0); wdg = gtk_button_new_with_label(" + "); gtk_widget_show(GTK_WIDGET(wdg)); gtk_signal_connect (GTK_OBJECT (wdg), "clicked", GTK_SIGNAL_FUNC (size_up_callb), (gpointer) gl_preview); gtk_box_pack_start (GTK_BOX (hbox), wdg, FALSE, FALSE, DEF_PAD*0.5); wdg = gtk_button_new_with_label(" - "); gtk_widget_show(GTK_WIDGET(wdg)); gtk_signal_connect (GTK_OBJECT (wdg), "clicked", GTK_SIGNAL_FUNC (size_down_callb), (gpointer) gl_preview); gtk_box_pack_start (GTK_BOX (hbox), wdg, FALSE, FALSE, 0); define_label_in_box(" ", hbox, FALSE,TRUE, 0); define_label_in_box("Detail", hbox, FALSE,TRUE, 0); wdg = gtk_button_new_with_label(" + "); gtk_widget_show(GTK_WIDGET(wdg)); gtk_signal_connect (GTK_OBJECT (wdg), "clicked", GTK_SIGNAL_FUNC (details_up_callb), gl_preview); gtk_box_pack_start (GTK_BOX (hbox), wdg, FALSE, FALSE, DEF_PAD*0.5); wdg = gtk_button_new_with_label(" - "); gtk_widget_show(GTK_WIDGET(wdg)); gtk_signal_connect (GTK_OBJECT (wdg), "clicked", GTK_SIGNAL_FUNC (details_down_callb), gl_preview); gtk_box_pack_start (GTK_BOX (hbox), wdg, FALSE, FALSE, 0); // Display details as % of HF size gl_preview->details_percent_lbl = define_label_in_box (" ", hbox, FALSE,TRUE,DEF_PAD*0.5); gl_update_details_display (gl_preview); gtk_box_pack_start (GTK_BOX (gl_preview->main_box), align_widget(hbox,0.5,0.5), FALSE, FALSE, 0); // Camera choice (radio buttons) hbox = gtk_hbox_new(FALSE,0); gtk_widget_show(hbox); define_label_in_box ("Camera", hbox, 0, 0, DEF_PAD); for (i=0; i<NBCAMERAS; i++) { snprintf (buf, 2, "%1d", i+1); define_radio_button_in_box_with_data (hbox, &group, buf, set_camera_callb, (gpointer) gl_preview,(gl_preview->current_camera_id==i)); } camera = gl_preview->cameras[gl_preview->current_camera_id]; gtk_box_pack_start_defaults (GTK_BOX (gl_preview->main_box),hbox); table = gtk_table_new(5, 3, FALSE); gtk_widget_show(GTK_WIDGET(table)); wdg = create_widget_from_xpm(window,rotate_y_xpm); gtk_table_attach (GTK_TABLE (table), wdg, 0, 1, 0, 1, 0, 0, 0, 0); gl_preview->adj_rot_y = gtk_adjustment_new (camera->rot_y, 0.0, 360.0, 1.0, 1.0, 0.0); define_scale_in_table(gl_preview->adj_rot_y,table,1, 2, 0, 1, 0, 0); gtk_signal_connect (GTK_OBJECT (gl_preview->adj_rot_y ), "value_changed", GTK_SIGNAL_FUNC (rot_y_upd), (gpointer) gl_preview); hbox = gtk_hbox_new(FALSE,0); gtk_widget_show(hbox); rotate_buttons_new(hbox, (gpointer) gl_preview->adj_rot_y); gtk_table_attach (GTK_TABLE (table), hbox, 2, 3, 0, 1, 0, 0, 0, 0); wdg = create_widget_from_xpm(window,rotate_x_xpm); gtk_table_attach (GTK_TABLE (table), wdg, 0, 1, 1, 2, 0, 0, 0, 0); gl_preview->adj_rot_x = gtk_adjustment_new (camera->rot_x, 0.0, 360.0, 1.0, 1.0, 0.0); define_scale_in_table(gl_preview->adj_rot_x,table,1, 2, 1, 2, 0, 0); gtk_signal_connect (GTK_OBJECT (gl_preview->adj_rot_x ), "value_changed", GTK_SIGNAL_FUNC (rot_x_upd), (gpointer) gl_preview); hbox = gtk_hbox_new(FALSE,0); gtk_widget_show(hbox); rotate_buttons_new(hbox, (gpointer) gl_preview->adj_rot_x); gtk_table_attach (GTK_TABLE (table), hbox, 2, 3, 1, 2, 0, 0, 0, 0); wdg = create_widget_from_xpm(window,depth_xpm); gtk_table_attach (GTK_TABLE (table), wdg, 0, 1, 2, 3, 0, 0, 0, 0); gl_preview->adj_distance = gtk_adjustment_new (camera->distance, 0.0, 5.0, 0.01, 0.05, 0.001); define_scale_in_table(gl_preview->adj_distance,table,1, 3, 2, 3, 2, 0); gtk_signal_connect (GTK_OBJECT (gl_preview->adj_distance), "value_changed", GTK_SIGNAL_FUNC (distance_upd), (gpointer) gl_preview); wdg = create_widget_from_xpm(window,vertical_xpm); gtk_table_attach (GTK_TABLE (table), wdg, 0, 1, 3, 4, 0, 0, 0, 0); gl_preview->adj_translate_y = gtk_adjustment_new (camera->translate_y, -1.0, 1.0, 0.01, 0.05, 0.001); define_scale_in_table(gl_preview->adj_translate_y,table,1, 3, 3, 4, 2, 0); gtk_signal_connect (GTK_OBJECT (gl_preview->adj_translate_y), "value_changed", GTK_SIGNAL_FUNC (translate_y_upd), (gpointer) gl_preview); wdg = create_widget_from_xpm(window,horizontal_xpm); gtk_table_attach (GTK_TABLE (table), wdg, 0, 1, 4, 5, 0, 0, 0, 0); gl_preview->adj_translate_x = gtk_adjustment_new (camera->translate_x, -1.0, 1.0, 0.01, 0.05, 0.001); define_scale_in_table(gl_preview->adj_translate_x,table,1, 3, 4, 5, 2, 0); gtk_signal_connect (GTK_OBJECT (gl_preview->adj_translate_x), "value_changed", GTK_SIGNAL_FUNC (translate_x_upd), (gpointer) gl_preview); // vbox for table and related widgets (angle, reset) vbox = gtk_vbox_new(FALSE,0); gtk_widget_show(vbox); gtk_box_pack_start_defaults(GTK_BOX(vbox), table); // Angle hbox = gtk_hbox_new(FALSE,0); gtk_widget_show(GTK_WIDGET(hbox)); define_label_in_box ("Angle", hbox, 0, 0, DEF_PAD); gl_preview->adj_angle_w = gtk_adjustment_new (camera->angle_w, 5, 100, 1, 1, 0.1); gtk_signal_connect (GTK_OBJECT (gl_preview->adj_angle_w), "value_changed", GTK_SIGNAL_FUNC(angle_w_upd), (gpointer) gl_preview); define_scale_in_box (gl_preview->adj_angle_w, hbox, 0, DEF_PAD*0.5); gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox); // Reset all wdg = gtk_button_new_with_label (_("Reset")); gtk_signal_connect (GTK_OBJECT (wdg), "clicked", (GtkSignalFunc) gl_reset_callb, (gpointer) gl_preview); gtk_widget_show(wdg); gtk_box_pack_start (GTK_BOX (vbox), align_widget(wdg,0.5,0.5), FALSE, FALSE, DEF_PAD*0.5); // Small arrows for hiding / showing the dialog... vbox2 = gtk_vbox_new(FALSE,0); gtk_widget_show(vbox2); gtk_box_pack_start(GTK_BOX(vbox2), hideshow_dialog_new(window, GTK_ORIENTATION_HORIZONTAL, vbox, &gl_def->show_subdialog), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox2), vbox, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (gl_preview->main_box), vbox2, FALSE, FALSE, 0); // gtk_widget_queue_draw(GTK_WIDGET(gl_preview->gl_area)) gl_draw (GTK_WIDGET(gl_preview->gl_area)); return gl_preview; }
void gl_draw(const char* str) { gl_draw(str, strlen(str)); }
void Plot::DrawAxis( float offx, float offy, float min, float max, float xdiv, float ydiv, float step_x, float step_y ) { // Calcolo la proporzione del grafico float eps = (float) this->w() / 300.0; // Calcolo la lunghezza degli assi float x_axis = (float) this->max_data * xdiv; // Imposto il colore glColor3ub( 255u, 255u, 255u ); // Imposto la dimensione della linea glLineWidth( (GLfloat) eps ); // Disegno gli assi del piano cartesiano glBegin( GL_LINES ); // Controllo se l'asse delle ascisse è visibile if ( min <= 0 && max >= 0 ) { // Asse delle ascisse glVertex2f( (GLfloat) offx, (GLfloat) offy ); glVertex2f( (GLfloat) offx + (GLfloat) x_axis, (GLfloat) offy ); glVertex2f( (GLfloat) offx + (GLfloat) x_axis, (GLfloat) offy - 4 ); glVertex2f( (GLfloat) offx + (GLfloat) x_axis, (GLfloat) offy + 3 ); } // Asse delle ordinate glVertex2f( (GLfloat) offx, (GLfloat) offy + max * ydiv ); glVertex2f( (GLfloat) offx, (GLfloat) offy + min * ydiv ); glEnd(); // Imposto il carattere del testo gl_font( FL_HELVETICA, (int) ( 8.0 * eps ) ); // Controllo se l'asse delle ascisse è visibile if ( min <= 0 && max >= 0 ) { // Disegno la nomenclatura dell'asse delle ascisse gl_draw( "x", offx + x_axis - (float) gl_width( "x" ) + 8.0 * (GLfloat) eps, offy ); } // Disegno la nomenclatura dell'asse delle ordinate gl_draw( "y", offx + 6.0 * (GLfloat) eps, offy + max * ydiv + (float) gl_width( "y" ) ); // Imposto il colore glColor3ub( 255u, 255u, 255u ); // Imposto la dimensione della linea glLineWidth( (GLfloat) eps ); // Imposto il carattere del testo gl_font( FL_HELVETICA, (int) ( 8.0 * eps ) ); // Buffer del testo char buffer[20]; // Iteratore float i; // Controllo se si vuole disegnare il righello nell'asse delle ascisse if ( this->x_ruler_step ) { // Flag di controllo bool alternate = false; // Disegno le tacche dell'asse delle ascisse for ( i = 0; i <= (float) this->data_set[0].size; i += step_x ) { // Calcolo la posizione verticale float xpos = offx + i * xdiv; // Disegno le tacche dell'asse glBegin( GL_LINES ); glVertex2f( (GLfloat) xpos, (GLfloat) offy ); glVertex2f( (GLfloat) xpos, (GLfloat) offy - 5 * eps ); glEnd(); // Controllo se si stanno usando numeri molto piccoli if ( step_x < 1.0 ) snprintf( buffer, 20, "%.2f", i * this->x_ruler_step ); else snprintf( buffer, 20, "%.1f", i * this->x_ruler_step ); // Disegno il valore della tacca nell'asse if ( (float) this->data_set[0].size / step_x < 5.0 || !alternate ) gl_draw( buffer, (float) xpos - (float) gl_width( buffer ) / 2.0f, offy - 17.0 * eps ); // Visualizzo le etichette a sbalzi alternate = ( alternate ) ? false : true; } } // Disegno le tacche dell'asse delle ordinate for ( i = min; i <= max; i += step_y ) { // Calcolo la posizione verticale float ypos = offy + i * ydiv; // Disegno le tacche dell'asse glBegin( GL_LINES ); glVertex2f( (GLfloat) offx, (GLfloat) ypos ); glVertex2f( (GLfloat) offx + 5 * eps, (GLfloat) ypos ); glEnd(); // Controllo se si stanno usando numeri molto piccoli if ( step_y < 1.0 ) snprintf( buffer, 20, "%.2f", i ); else snprintf( buffer, 20, "%.1f", i ); // Disegno il valore della tacca nell'asse gl_draw( buffer, (float) offx - (float) gl_width( buffer ) - 10, ypos - 3 ); } }