void size_callb (gpointer data,GtkWidget *wdg) { // Sets size when creating a new HF gint hf_size; static gchar area_label[12]; omenu_struct_type *opt_menu; hf_wrapper_struct *hfw; hf_options_struct *hfo; opt_menu = (omenu_struct_type *) data; // printf("DATA in SIZE_CALLB: %d;\n",data); hfo = (hf_options_struct *) opt_menu->data; // printf("HFO in SIZE_CALLB: %d;\n",hfo); if (!hfo) return; hfw = (hf_wrapper_struct *) * (hf_wrapper_struct **) hfo->hfw_ptr_ptr; hf_size = opt_menu->list[opt_menu->current_index].num; if (!hfw) return; if (!hfw->hf_struct) return; if (hf_size == hfw->hf_struct->max_x) // No change! return; sprintf(area_label, "%d x %d", hf_size, hf_size); gtk_frame_set_label(GTK_FRAME(hfw->draw_area_frame), area_label); hf_free(hfw->hf_struct); hfw->hf_options->hf_size = hf_size; hfw->hf_struct = (hf_struct_type *) hf_new(hf_size); hfw->display_scale = get_display_scale(hf_size); hfw->hf_buf8 = (unsigned char *) x_malloc((RIGHT_SHIFT(hf_size, hfw->display_scale)) * (RIGHT_SHIFT(hf_size,hfw->display_scale))*sizeof(unsigned char), "unsigned char (hfw->buf8 in size_callb)"); hfw->if_rgb = FALSE; hfw->area_size = RIGHT_SHIFT(hf_size,hfw->display_scale); set_current_button (hfw->sbs, hfw->display_scale); hfw->size_change_request = TRUE; gtk_widget_set_size_request (hfw->draw_area_frame, hfw->area_size+SCALE_PAD, hfw->area_size+SCALE_PAD); // printf("SIZE_CALLB: HFW: %d; HF_SIZE: %d; DISPLAY_SCALE: %d; AREA_SIZE: %d\n", hfw, hf_size, hfw->display_scale, hfw->area_size); init_render_struct(hfw->hf_options->render_str, hfw->dirname, hfw->filename, &hfw->creation_mode, hfw->if_modified, hfw->gl_preview, hfw->hf_struct->hf_buf, hfw->hf_struct->max_x, hfw->hf_struct->max_y); gl_set_input_grid (hfw->gl_preview, hfw->hf_struct->hf_buf, hfw->hf_struct->max_x, hfw->hf_struct->max_y, HF_TYPE_ID); gl_update_details_display (hfw->gl_preview); gtk_drawing_area_size(GTK_DRAWING_AREA(hfw->area), hfw->area_size, hfw->area_size); }
static void details_down_callb (GtkWidget *wdg, gpointer data) { // Decrease by 50% the number of polygons gl_preview_struct *gl_preview = (gl_preview_struct *) data; gl_preview->mesh_size = gl_preview->mesh_size >> 1; if ( gl_preview->mesh_size < MESH_SIZE_MIN ) { gl_preview->mesh_size = gl_preview->mesh_size_backup; return; } gl_preview->mesh_size_backup = gl_preview->mesh_size; gl_preview->defaults->mesh_size = gl_preview->mesh_size; gl_update_details_display (gl_preview); refresh_gl_callb(wdg,data); }
static void details_up_callb (GtkWidget *wdg, gpointer data) { // Increase by 100% the number of polygons gl_preview_struct *gl_preview = (gl_preview_struct *) data; gl_preview->mesh_size = gl_preview->mesh_size << 1; if ( (gl_preview->mesh_size > MESH_SIZE_MAX) || (gl_preview->mesh_size > gl_preview->max_x) ) { gl_preview->mesh_size = gl_preview->mesh_size_backup; return; } gl_preview->mesh_size_backup = gl_preview->mesh_size; gl_preview->defaults->mesh_size = gl_preview->mesh_size; gl_update_details_display (gl_preview); refresh_gl_callb(wdg,data); }
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; }