/* hf_dialog_options.c - "Pot-pourri" of functions and structures * for managing the HF dialogs - created from hf_wrapper.c on 2006-01-01 * * Copyright (C) 2001, 2006 Patrice St-Gelais * patrstg@users.sourceforge.net * http://geomorph.sourceforge.net * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "hf.h" #include "hf_dialog_options.h" #include "hf_wrapper.h" #include "hf_filters_dialog.h" #include "hf_creation_dialog.h" #include "hf_tools_dialog.h" #include "fourier.h" #include "gl_preview.h" #include "draw_tools_dialog.h" #include "img_process_dialog.h" gpointer hf_options_dialog_new(GtkWidget *window, GtkWidget *creation_container, GtkTooltips *tooltips, gpointer widget_list, gpointer data, gpointer commit_fn_ptr, gpointer reset_fn_ptr, gpointer commit_data_ptr) { // Options structure related to the tools dialog, // initialized once for all the documents gint i; hf_options_struct *hf_options; hf_options = (hf_options_struct *) malloc(sizeof(hf_options_struct)); hf_options->tools_window = window; hf_options->tools_dialog = NULL; // hf_options->creation_widgets = (hf_creation_wdg_struct *) widget_list; hf_options->current_tools = NULL; hf_options->context = TRANSFORM_CONTEXT; hf_options->last_creation_action = NULL; hf_options->tooltips = tooltips; hf_options->current_callb = hfuniform_callb; hf_options->current_calculation = (gpointer) uniform; hf_options->subdiv1_dialog = NULL; hf_options->subdiv2_dialog = NULL; hf_options->subdiv2_direct_upd = TRUE; hf_options->waves_dialog = NULL; hf_options->surfadd_dialog = NULL; // hf_options->uniform_value = NULL; hf_options->subdiv1_options = NULL; hf_options->subdiv2_options = NULL; hf_options->surfadd_options = NULL; hf_options->waves_options = NULL; hf_options->wide_filter = NULL; hf_options->medium_filter1 = NULL; hf_options->medium_filter2 = NULL; hf_options->sharp_filter = NULL; hf_options->image_filter = NULL; hf_options->gauss_filter = NULL; hf_options->dist_matrix = dist_matrix_new(0); hf_options->creation_fd_struct = filter_dialog_new(window,tooltips,data); hf_options->fd_struct = hf_options->creation_fd_struct; hf_options->doc_list = NULL; // Default dialog hf_options->uniform_value = (hf_type *) malloc(sizeof(hf_type)); (*hf_options->uniform_value) = 32767; hf_options->current_options = (gpointer) hf_options->uniform_value; hf_options->uniform_dialog = uniform_dialog_new(data, *hf_options->uniform_value); gtk_widget_show(hf_options->uniform_dialog ); hf_options->current_dialog =hf_options->uniform_dialog ; // The default is to add the main filters dialog to the creation container gtk_container_add(GTK_CONTAINER(creation_container), hf_options->fd_struct->filter_dialog); hf_options->flag_uniform_done = FALSE; set_filter_defaults(hf_options->fd_struct); gtk_container_add(GTK_CONTAINER(creation_container), hf_options->uniform_dialog); hf_options->draw = NULL; // Cursors hf_options->default_cursor = gdk_cursor_new(GDK_LEFT_PTR); hf_options->current_cursor = hf_options->default_cursor; hf_options->pencil_cursor = gdk_cursor_new(GDK_PENCIL); hf_options->watch_cursor = gdk_cursor_new(GDK_WATCH); hf_options->fleur_cursor = gdk_cursor_new(GDK_FLEUR); hf_options->hf_size = 0; // Initialized by hf_wrapper_new and size_callb hf_options->img = NULL; hf_options->need_tmp_buf = FALSE; // Flag: if we need temp buffer for brightness / contrast // useful after an undo... // OpenGL preview hf_options->gl_defaults = gl_defaults_init ( ); for (i=0; igauss_list[i] = NULL; // Context management functions and data // The pointer field is inherited from app.h hf_options->commit_fn = commit_fn_ptr; hf_options->reset_fn = reset_fn_ptr; hf_options->commit_data = commit_data_ptr; hf_options->povray_pid = 0; hf_options->primit_surf = NULL; hf_options->fourier = fourier_dialog_new(); return (gpointer) hf_options; } void hf_options_dialog_free( hf_options_struct *hf_opt) { gint i; if (!hf_opt) return; // printf("HF_OPTIONS_DIALOG_FREE-1\n"); if (hf_opt->creation_widgets) free(hf_opt->creation_widgets); if (hf_opt->uniform_value) free(hf_opt->uniform_value); if (hf_opt->subdiv1_options) free(hf_opt->subdiv1_options); if (hf_opt->subdiv2_options) free(hf_opt->subdiv2_options); if (hf_opt->surfadd_options) free(hf_opt->surfadd_options); if (hf_opt->waves_options) free(hf_opt->waves_options); if (hf_opt->wide_filter) filter_free(hf_opt->wide_filter); if (hf_opt->medium_filter1) filter_free(hf_opt->medium_filter1); if (hf_opt->medium_filter2) filter_free(hf_opt->medium_filter2); if (hf_opt->sharp_filter) filter_free(hf_opt->sharp_filter); if (hf_opt->gauss_filter) filter_free(hf_opt->gauss_filter); for (i=0; igauss_list[i]) free(hf_opt->gauss_list[i]); if (hf_opt->img) img_dialog_free(hf_opt->img); if (hf_opt->draw) draw_tools_free(hf_opt->draw); if (hf_opt->fourier) fourier_dialog_free(hf_opt->fourier); free(hf_opt); // printf("HF_OPTIONS_DIALOG_FREE-2\n"); } void set_commit_reset_fns (hf_options_struct *hfo, gpointer commit_fn, gpointer reset_fn, gpointer data) { // Set the functions and data to execute when we change context *hfo->commit_fn = commit_fn; *hfo->reset_fn = reset_fn; *((hf_wrapper_struct **) hfo->commit_data) = data; } void hf_commit_or_reset (hf_options_struct *hfo) { // Commits or resets a change, with the functions and data given in hf_options if (hfo->commit_data && hfo->commit_fn && hfo->reset_fn) commit_or_reset (hfo->commit_fn, hfo->reset_fn, * (hf_wrapper_struct **) hfo->commit_data); }