GtkWidget *voronoi_dialog_new (gpointer data) { GtkWidget *vbox, *vbox2, *vbox3, *guide_box, *hbox, *hbox1, *hbox2, *frame, *frame2, *button, *wdg, *check_box, *lblmax, *lblwidth, *button_uniform, *preview_box, *scale; GtkObject *adj; GSList *group = NULL, *group1 = NULL, *group2 = NULL, *group3 = NULL; voronoi_struct *vs; voronoi_dialog_struct *vds; hf_wrapper_struct *hfw; hfw = (hf_wrapper_struct *) * (hf_wrapper_struct **) data; vs = hfw->hf_options->img->voronoi; vds = hfw->hf_options->img->voronoi_dialog; frame = options_frame_new("Cracks network"); vbox = gtk_vbox_new(FALSE,DEF_PAD); gtk_widget_show(GTK_WIDGET(vbox)); hbox = gtk_hbox_new(FALSE,DEF_PAD); gtk_widget_show(GTK_WIDGET(hbox)); define_label_in_box("Average cell size", hbox, FALSE,TRUE, DEF_PAD); vds->adj_cell_size = gtk_adjustment_new ( vs->cell_size,0.0, 50.0, 0.1, 0.1, 0.0); define_scale_in_box(vds->adj_cell_size,hbox,1,DEF_PAD); gtk_signal_connect (GTK_OBJECT (vds->adj_cell_size), "value_changed", GTK_SIGNAL_FUNC (gdouble_adj_callb), (gpointer) &vs->cell_size); gtk_signal_connect (GTK_OBJECT (vds->adj_cell_size), "value_changed", GTK_SIGNAL_FUNC (gboolean_set_false), (gpointer) &hfw->if_calculated); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), seed_dialog_new(data, vs->seed, change_voronoi_seed), TRUE, TRUE, 0); // ******** Distribution of cells // Box for radio buttons vbox2 = gtk_vbox_new(FALSE,0); gtk_widget_show(GTK_WIDGET(vbox2)); frame2 = define_frame_with_hiding_arrows ("Cell distribution", vbox2, hfw->hf_options->tools_window, FALSE); gtk_box_pack_start(GTK_BOX(vbox), frame2, TRUE, TRUE, 0); // We need a scale for the REGULAR option, for controlling the perturbation hbox = gtk_hbox_new(FALSE,DEF_PAD); gtk_widget_show(GTK_WIDGET(hbox)); define_label_in_box("Random variation", hbox, FALSE,TRUE, DEF_PAD); vds->adj_random_variation = gtk_adjustment_new ( vs->random_variation,0.0, 100.0, 1, 1, 0.0); wdg = define_scale_in_box(vds->adj_random_variation,hbox,0,DEF_PAD); gtk_signal_connect (GTK_OBJECT (vds->adj_random_variation), "value_changed", GTK_SIGNAL_FUNC (gint_adj_callb), (gpointer) &vs->random_variation); gtk_signal_connect (GTK_OBJECT (vds->adj_random_variation), "value_changed", GTK_SIGNAL_FUNC (gboolean_set_false), (gpointer) &hfw->if_calculated); // We need a row of buttons for controlling the scale (multiple or not) hbox1 = gtk_hbox_new(FALSE,DEF_PAD); define_label_in_box("Scale", hbox1, FALSE,TRUE, DEF_PAD); gtk_widget_show(GTK_WIDGET(hbox1)); define_radio_button_in_box_with_data (hbox1, &group1, "1X", set_scale_1x, &vs->scale, (vs->scale==SCALE_1X)) ; define_radio_button_in_box_with_data (hbox1, &group1, "1X+2X", set_scale_1x_2x, &vs->scale, (vs->scale==SCALE_1X_2X)) ; define_radio_button_in_box_with_data (hbox1, &group1, "1X+2X+4X", set_scale_1x_2x_4x, &vs->scale, (vs->scale==SCALE_1X_2X_4X)) ; button = define_radio_button_in_box_with_data (vbox2, &group, "Uniform / random", set_uniform_distrib, &vs->distribution_type, (vs->distribution_type==UNIFORM)) ; gtk_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) hide_if_true, (gpointer) hbox); gtk_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) show_if_true, (gpointer) hbox1); button = define_radio_button_in_box_with_data (vbox2, &group, "Centered / random", set_centered_distrib, &vs->distribution_type, (vs->distribution_type==CENTERED)) ; gtk_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) hide_if_true, (gpointer) hbox); gtk_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) show_if_true, (gpointer) hbox1); button = define_radio_button_in_box_with_data (vbox2, &group, "Regular / perturbated", set_regular_distrib, &vs->distribution_type, (vs->distribution_type==REGULAR)) ; gtk_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) show_if_true, (gpointer) hbox); gtk_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) hide_if_true, (gpointer) hbox1); // At the end, We add the random variation scale for REGULAR // and the radio buttons for the multiple scale control gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0); if (vs->distribution_type!=REGULAR) gtk_widget_hide(GTK_WIDGET(hbox)); else gtk_widget_hide(GTK_WIDGET(hbox1)); /*****************************************************/ // Now specify how the current HF should be used vbox2 = gtk_vbox_new(FALSE,0); gtk_widget_show(GTK_WIDGET(vbox2)); frame2 = define_frame_with_hiding_arrows ("Use of current height field", vbox2, hfw->hf_options->tools_window, FALSE); gtk_box_pack_start(GTK_BOX(vbox), frame2, FALSE, FALSE, 0.5*DEF_PAD); // Vbox3: "USE AS GUIDE" dialog (for adding noise) guide_box = gtk_vbox_new(FALSE,DEF_PAD); gtk_widget_show(GTK_WIDGET(guide_box)); check_box = define_check_button_in_box ("Gener noise anyway?", guide_box, 0, 0, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_box),vs->gener_noise); gtk_signal_connect (GTK_OBJECT(check_box), "toggled", GTK_SIGNAL_FUNC(toggle_check_button_callb), (gpointer) &vs->gener_noise); // Preview box preview_box = gtk_hbox_new(FALSE,DEF_PAD); gtk_widget_show(GTK_WIDGET(preview_box)); vds->noise_preview = view_struct_new(NOISE_PREVIEW_SIZE,NOISE_PREVIEW_SIZE,(gpointer) compute_noise_preview,(gpointer) hfw->hf_options->img); gtk_box_pack_start(GTK_BOX(preview_box), vds->noise_preview->area, TRUE, TRUE, DEF_PAD *0.5); vbox3 = seed_dialog_new_lbl(hfw->hf_options->img, vs->noise_opt->seed, change_noise_seed, FALSE, VERTICAL_BOX ); adj = gtk_adjustment_new (0, -4, 4, 1, 1, 0.1); scale = gtk_hscale_new (GTK_ADJUSTMENT (adj)); gtk_widget_set_usize(scale,75,0); gtk_scale_set_digits (GTK_SCALE (scale), 0); gtk_box_pack_start (GTK_BOX (vbox3), scale, TRUE, TRUE, DEF_PAD*0.5); gtk_widget_show (scale); gtk_signal_connect (GTK_OBJECT (adj), "value_changed", GTK_SIGNAL_FUNC(gint_adj_callb), &vs->noise_opt->roughness); gtk_signal_connect (GTK_OBJECT (adj), "value_changed", GTK_SIGNAL_FUNC(draw_area_callb), vds->noise_preview); gtk_box_pack_start(GTK_BOX(preview_box), vbox3, TRUE, TRUE, DEF_PAD*0.5); gtk_box_pack_start(GTK_BOX(guide_box), preview_box, FALSE, FALSE, 0.5*DEF_PAD); gtk_signal_connect (GTK_OBJECT (check_box), "toggled", (GtkSignalFunc) show_if_true, (gpointer) preview_box); if (vs->gener_noise==FALSE) gtk_widget_hide(GTK_WIDGET(preview_box)); // Scale for the noise level hbox2 = gtk_hbox_new(FALSE,DEF_PAD); gtk_widget_show(GTK_WIDGET(hbox2)); define_label_in_box("Noise level", hbox2, FALSE,TRUE, DEF_PAD); vds->adj_noise_level = gtk_adjustment_new ( vs->noise_level,0.0, 100.0, 1, 1, 0.0); wdg = define_scale_in_box(vds->adj_noise_level,hbox2,0,DEF_PAD); gtk_signal_connect (GTK_OBJECT (vds->adj_noise_level), "value_changed", GTK_SIGNAL_FUNC (gint_adj_callb), (gpointer) &vs->noise_level); gtk_signal_connect (GTK_OBJECT (vds->adj_noise_level), "value_changed", GTK_SIGNAL_FUNC (gboolean_set_false), (gpointer) &hfw->if_calculated); gtk_signal_connect (GTK_OBJECT (check_box), "toggled", (GtkSignalFunc) show_if_true, (gpointer) hbox2); // hbox for NOISE vs GUIDE radio buttons hbox = gtk_hbox_new(FALSE,0); gtk_widget_show(GTK_WIDGET(hbox)); button = define_radio_button_in_box_with_data (hbox, &group2, "As noise", set_use_as_noise, &vs->hf_use, (vs->hf_use==USE_AS_NOISE)) ; gtk_signal_connect (GTK_OBJECT (button), "toggled", (GtkSignalFunc) hide_if_true, (gpointer) check_box); // Always show the noise scale in that case gtk_signal_connect_object(GTK_OBJECT(button), "toggled", GTK_SIGNAL_FUNC(gtk_widget_show), (gpointer) wdg); button = define_radio_button_in_box_with_data (hbox, &group2, "As guide", set_use_as_guide, &vs->hf_use, (vs->hf_use==USE_AS_GUIDE)) ; gtk_signal_connect (GTK_OBJECT (button), "toggled", (GtkSignalFunc) show_if_true, (gpointer) guide_box); if (vs->hf_use==USE_AS_NOISE) gtk_widget_hide(GTK_WIDGET(guide_box)); gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox2), guide_box, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0); /*********************** Crack width **************************/ vbox2 = gtk_vbox_new(FALSE,0); gtk_widget_show(GTK_WIDGET(vbox2)); frame2 = define_frame_with_hiding_arrows ("Crack width", vbox2, hfw->hf_options->tools_window, FALSE); gtk_box_pack_start(GTK_BOX(vbox), frame2, FALSE, FALSE, 0.5*DEF_PAD); hbox = gtk_hbox_new(FALSE,DEF_PAD); gtk_widget_show(GTK_WIDGET(hbox)); button_uniform = define_radio_button_in_box_with_data (hbox, &group3, "Uniform", set_fixed_width, &vs->crack_width_type, vs->crack_width_type==FIXED_WIDTH) ; button = define_radio_button_in_box_with_data (hbox, &group3, "From distance",set_from_distance, &vs->crack_width_type, vs->crack_width_type==FROM_DISTANCE) ; gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); // Width: in pixels for "Uniform", relative for "Varies with distance" hbox = gtk_hbox_new(FALSE,DEF_PAD); gtk_widget_show(GTK_WIDGET(hbox)); define_label_in_box("Min", hbox, FALSE,TRUE, DEF_PAD); vds->adj_min_width = gtk_adjustment_new ( vs->min_width,0.0, 10.0, 1, 1, 0.0); wdg = define_scale_in_box(vds->adj_min_width,hbox,0,DEF_PAD); gtk_signal_connect (GTK_OBJECT (vds->adj_min_width), "value_changed", GTK_SIGNAL_FUNC (gint_adj_callb), (gpointer) &vs->min_width); gtk_signal_connect (GTK_OBJECT (vds->adj_min_width), "value_changed", GTK_SIGNAL_FUNC (gboolean_set_false), (gpointer) &hfw->if_calculated); gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (button_uniform), "toggled", (GtkSignalFunc) hide_if_true, (gpointer) hbox); if (vs->crack_width_type==FIXED_WIDTH) gtk_widget_hide(GTK_WIDGET(hbox)); hbox = gtk_hbox_new(FALSE,DEF_PAD); gtk_widget_show(GTK_WIDGET(hbox)); lblmax = define_label_in_box("Max", hbox, FALSE,TRUE, DEF_PAD); lblwidth = define_label_in_box("Width", hbox, FALSE,TRUE, DEF_PAD); vds->adj_max_width = gtk_adjustment_new ( vs->max_width,0.0, 10.0, 1, 1, 0.0); wdg = define_scale_in_box(vds->adj_max_width,hbox,0,DEF_PAD); gtk_signal_connect (GTK_OBJECT (vds->adj_max_width), "value_changed", GTK_SIGNAL_FUNC (gint_adj_callb), (gpointer) &vs->max_width); gtk_signal_connect (GTK_OBJECT (vds->adj_max_width), "value_changed", GTK_SIGNAL_FUNC (gboolean_set_false), (gpointer) &hfw->if_calculated); // Consistency controls (min should be <= max) gtk_signal_connect (GTK_OBJECT (vds->adj_min_width), "value_changed", GTK_SIGNAL_FUNC (check_max_width), (gpointer) hfw->hf_options->img); gtk_signal_connect (GTK_OBJECT (vds->adj_max_width), "value_changed", GTK_SIGNAL_FUNC (check_min_width), (gpointer) hfw->hf_options->img); gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (button_uniform), "toggled", (GtkSignalFunc) hide_if_true, (gpointer) lblmax); gtk_signal_connect (GTK_OBJECT (button_uniform), "toggled", (GtkSignalFunc) show_if_true, (gpointer) lblwidth); if (vs->crack_width_type==FIXED_WIDTH) gtk_widget_hide(GTK_WIDGET(lblmax)); button = gtk_button_new_with_label (_("Apply")); gtk_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) apply_voronoi_callb, data); gtk_widget_show(button); gtk_box_pack_start(GTK_BOX(vbox), align_widget(button,0.5,0.5), FALSE, FALSE, DEF_PAD); /************************ Edge level control ************************/ hbox = gtk_hbox_new(FALSE,DEF_PAD); gtk_widget_show(GTK_WIDGET(hbox)); define_label_in_box("Edge raising", hbox, FALSE,TRUE, DEF_PAD); vds->adj_edges_level = gtk_adjustment_new ( vs->edges_level,0.0, 100.0, 1, 1, 0.0); vds->wdg_edges_level = define_scale_in_box(vds->adj_edges_level,hbox,0,DEF_PAD); gtk_signal_connect (GTK_OBJECT (vds->adj_edges_level), "value_changed", GTK_SIGNAL_FUNC (gint_adj_callb), (gpointer) &vs->edges_level); gtk_signal_connect (GTK_OBJECT (vds->adj_edges_level), "value_changed", GTK_SIGNAL_FUNC (edges_level_callb), data); gtk_signal_connect (GTK_OBJECT (vds->adj_edges_level), "value_changed", GTK_SIGNAL_FUNC (gboolean_set_false), (gpointer) &hfw->if_calculated); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); // We activate when apply is clicked gtk_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) set_sensitive_callb, (gpointer) vds->wdg_edges_level); gtk_widget_set_sensitive (GTK_WIDGET(vds->wdg_edges_level),FALSE); // Controls gtk_box_pack_start (GTK_BOX (vbox), reset_accept_buttons_new (data, &vds->accept), FALSE, FALSE, DEF_PAD); gtk_container_add(GTK_CONTAINER(frame), vbox); return frame; }
GtkWidget * surfadd_dialog_new(gpointer hfo_ptr) { GtkObject *adj; GtkWidget *button, *table, *hbox, *vbox, *scale, *scrolled_window; GtkWidget *frame; static gboolean dummy_flag; gpointer data; hf_options_struct *hfo = (hf_options_struct *) hfo_ptr; if (!hfo) return gtk_label_new(_("No surface addition dialog")); data = hfo->hfw_ptr_ptr; // Main dialog box vbox = gtk_vbox_new(FALSE,0); gtk_widget_show(GTK_WIDGET(vbox)); // 2008-02 Now with scrolled window scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_widget_show (scrolled_window); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(scrolled_window), vbox); gtk_widget_set_size_request (scrolled_window, -1, gdk_screen_get_height(gdk_screen_get_default())/3); // Seed gtk_box_pack_start_defaults(GTK_BOX(vbox), seed_dialog_new(data, hfo->surfadd_options->seed, change_surfadd_seed)); table = gtk_table_new(4, 2, FALSE); gtk_widget_show(table); // Slope / roughness (kind of) // From 0 to 100% // 100: we keep the same H for each step, even if the surfaces to add are smaller // 50: we divide the H by 2 for each step (default), because the surfaces are divided by two // 100: we divide the H by 3 for each step. define_label_in_table("Slope",table, 0, 1, 0, 1, 0); adj = gtk_adjustment_new (hfo->surfadd_options->slope, 0, 100, 1, 1, 0.01); scale = define_scale_in_table(adj,table,1,2,0,1,0,DEF_PAD*0.5); g_signal_connect (G_OBJECT (adj), "value_changed", GTK_SIGNAL_FUNC (slope_upd), data); g_signal_connect (G_OBJECT (scale), "button_release_event", GTK_SIGNAL_FUNC (compute_hf_callb), data); // Random x-y displacement scale // From 0 to 100 % (100 % = twice the size of the current surface to add) define_label_in_table("XZ Displacement ",table, 0, 1, 1, 2, 0); adj = gtk_adjustment_new (hfo->surfadd_options->xy_random_range, 0, 100, 1, 1, 0.01); scale = define_scale_in_table(adj,table,1,2,1,2,0,DEF_PAD*0.5); g_signal_connect (G_OBJECT (adj), "value_changed", GTK_SIGNAL_FUNC (xy_scale_upd), data); g_signal_connect (G_OBJECT (scale), "button_release_event", GTK_SIGNAL_FUNC (compute_hf_callb), data); // Random height displacement scale // From 0 to 100 % (100 % = twice the height of the current surface to add) define_label_in_table("H Displacement ",table, 0, 1, 2, 3, 0); adj = gtk_adjustment_new (hfo->surfadd_options->h_random_range, 0, 100, 1, 1, 0.01); scale = define_scale_in_table(adj,table,1,2,2,3,0,DEF_PAD*0.5); g_signal_connect (G_OBJECT (adj), "value_changed", GTK_SIGNAL_FUNC (h_scale_upd), data); g_signal_connect (G_OBJECT (scale), "button_release_event", GTK_SIGNAL_FUNC (compute_hf_callb), data); // Lateral density variation // From 0 to 100 % (100 % = twice the default density) define_label_in_table("Density",table, 0, 1, 3, 4, 0); adj = gtk_adjustment_new (hfo->surfadd_options->density, 0, 100, 1, 1, 0.01); scale = define_scale_in_table(adj,table,1,2,3,4,0,DEF_PAD*0.5); g_signal_connect (G_OBJECT (adj), "value_changed", GTK_SIGNAL_FUNC (density_upd), data); g_signal_connect (G_OBJECT (scale), "button_release_event", GTK_SIGNAL_FUNC (compute_hf_callb), data); hbox = gtk_hbox_new(FALSE,0); gtk_widget_show(hbox); gtk_box_pack_start_defaults(GTK_BOX(hbox), table); gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox); // Filters for the primitive surface and preview frame = frame_new("Primitive surface", DEF_PAD*0.5); gtk_container_add(GTK_CONTAINER(vbox), frame); // HBOX will contain the shape filter dialog and the preview hbox = gtk_hbox_new(FALSE,0); gtk_widget_show(hbox); gtk_container_add(GTK_CONTAINER(frame), hbox); // We create the primitive surface, and the preview area at the same time hfo->primit_surf = hf_wrapper_new(NULL,NULL,hbox, hbox, hf_options_dialog_new(hfo->tools_window, hbox, hfo->tooltips, NULL, &hfo->primit_surf, hfo->stack, hfo->doc_type, hfo->all_docs, hfo->get_doc_list_from_type), &dummy_flag, &dummy_flag, NULL, NULL, NULL, NULL, HFPRIMITIVE); // Shared data: ((hf_wrapper_struct *)hfo->primit_surf)->hf_options->dist_matrix = hfo->dist_matrix; ((hf_wrapper_struct *)hfo->primit_surf)->hf_options->current_calculation = (gpointer) uniform; ((hf_wrapper_struct *)hfo->primit_surf)->hf_options->current_callb = NULL; ((hf_wrapper_struct *)hfo->primit_surf)->hf_options->current_options = (gpointer) hfo->uniform_value; set_filter_type (((hf_wrapper_struct *) hfo->primit_surf)->hf_options->creation_fd_struct, MEDIUM_FILTER_1); set_dependent_process ((hf_wrapper_struct *) hfo->primit_surf, gener_hf_from_ptr_ptr, hfo->hfw_ptr_ptr); // Set the merge operation to MULTIPLY: set_filter_merge(((hf_wrapper_struct *) hfo->primit_surf)->hf_options->creation_fd_struct, 1); // Frequency dialog gtk_box_pack_start(GTK_BOX(vbox), surfadd_frq_dialog_new(hfo_ptr), FALSE, FALSE,0); return define_options_frame_with_hiding_arrows("sum of surfaces", scrolled_window, hfo->tools_window, TRUE); }