From 7d8d56c2d44aa757b50039c25b7c0e83895d90c2 Mon Sep 17 00:00:00 2001 From: Wilrik de Loose Date: Wed, 9 Jan 2008 10:45:34 +0000 Subject: isoline gui --- Smoke/Week 2.suo | Bin 66560 -> 66560 bytes Smoke/fluids.c | 4 +--- Smoke/gtk_isolines.c | 40 ++++++++++++++++++++++++++++++++-------- Smoke/gui_requirements.txt | 4 ++-- Smoke/isolines.c | 40 +++++++++++++++++++++++++++++++++++++++- Smoke/isolines.h | 10 +++++++++- Smoke/renderer_gl.c | 12 ++++++++---- 7 files changed, 91 insertions(+), 19 deletions(-) diff --git a/Smoke/Week 2.suo b/Smoke/Week 2.suo index d064c06..776d701 100644 Binary files a/Smoke/Week 2.suo and b/Smoke/Week 2.suo differ diff --git a/Smoke/fluids.c b/Smoke/fluids.c index 21bb554..e56fcc9 100644 --- a/Smoke/fluids.c +++ b/Smoke/fluids.c @@ -22,6 +22,7 @@ #include "glyphs.h" #include "heightplots.h" #include "normals.h" +#include "isolines.h" //--- SIMULATION PARAMETERS ------------------------------------------------------------------------ int var_dims = 25; @@ -45,9 +46,6 @@ int active_slider = 0; int glyph_scalar = SCALAR_RHO; int glyph_vector = VECTOR_VEL; GLuint startList; -float threshold1 = 0.2f; -float threshold2 = 2.0f; -int isolines_nr = 1; static int fluids_calculate = TRUE; static int DIM; //size of simulation grid diff --git a/Smoke/gtk_isolines.c b/Smoke/gtk_isolines.c index 3ce4b0a..1f4dd6a 100644 --- a/Smoke/gtk_isolines.c +++ b/Smoke/gtk_isolines.c @@ -21,6 +21,14 @@ static gboolean select_num_colors(GtkRange *adjustment, gpointer data) isolines_set_num_colors((int)gtk_range_get_value(adjustment)); } + +static gboolean select_num_isolines(GtkRange *adjustment, gpointer data) +{ + printf("%f", gtk_range_get_value(adjustment)); + isolines_set_nr((int)gtk_range_get_value(adjustment)); +} + + static gboolean select_alpha(GtkRange *adjustment, gpointer data) { isolines_set_alpha((float)gtk_range_get_value(adjustment)); @@ -37,8 +45,8 @@ GtkWidget *create_isolines_page(void) GtkWidget *label; GtkWidget *button; GtkWidget *combo; - GtkAdjustment *color_adjustment; - GtkWidget *color_scale; + GtkAdjustment *adjustment; + GtkWidget *scale; GSList *dataset_group; page = gtk_vbox_new(FALSE, 0); @@ -131,14 +139,14 @@ GtkWidget *create_isolines_page(void) gtk_widget_show(label); - color_adjustment = GTK_ADJUSTMENT(gtk_adjustment_new( + adjustment = GTK_ADJUSTMENT(gtk_adjustment_new( isolines_get_num_colors(), 1, PALETTE_MAXCOLORS, 0.5, 5, 0.1)); - color_scale = gtk_hscale_new(color_adjustment); - gtk_scale_set_digits(GTK_SCALE(color_scale), 0); - g_signal_connect(GTK_RANGE(color_scale), "value-changed", G_CALLBACK(select_num_colors), NULL); + scale = gtk_hscale_new(adjustment); + gtk_scale_set_digits(GTK_SCALE(scale), 0); + g_signal_connect(GTK_RANGE(scale), "value-changed", G_CALLBACK(select_num_colors), NULL); - gtk_box_pack_start(GTK_BOX(box), color_scale, FALSE, TRUE, 0); - gtk_widget_show(color_scale); + gtk_box_pack_start(GTK_BOX(box), scale, FALSE, TRUE, 0); + gtk_widget_show(scale); //label = gtk_label_new("Alpha"); @@ -156,6 +164,22 @@ GtkWidget *create_isolines_page(void) gtk_container_add(GTK_CONTAINER(frame), box); gtk_widget_show(box); + + label = gtk_label_new("Number of isolines"); + + gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0); + gtk_widget_show(label); + + adjustment = GTK_ADJUSTMENT(gtk_adjustment_new(isolines_get_nr(), 0, 8, 0.5, 5, 0.1)); + scale = gtk_hscale_new(adjustment); + gtk_scale_set_digits(GTK_SCALE(scale), 0); + g_signal_connect(GTK_RANGE(scale), "value-changed", G_CALLBACK(select_num_isolines), NULL); + + gtk_box_pack_start(GTK_BOX(box), scale, FALSE, TRUE, 0); + gtk_widget_show(scale); + + gtk_container_add(GTK_CONTAINER(frame), box); + gtk_widget_show(box); gtk_box_pack_start(GTK_BOX(page), frame, FALSE, TRUE, 0); diff --git a/Smoke/gui_requirements.txt b/Smoke/gui_requirements.txt index 5621ca1..f63ee38 100644 --- a/Smoke/gui_requirements.txt +++ b/Smoke/gui_requirements.txt @@ -24,8 +24,8 @@ DIVERGENCE ISOLINES + render isoline -- select isoline colormap -- alter number of isolines ++ select isoline colormap ++ / - alter number of isolines - alter min and max threshold HEIGHT PLOTS diff --git a/Smoke/isolines.c b/Smoke/isolines.c index 882b26a..8513294 100644 --- a/Smoke/isolines.c +++ b/Smoke/isolines.c @@ -18,7 +18,9 @@ static int isolines_colormap = PALETTE_BLACKWHITE; static float isolines_alpha = 1.0f; static fftw_real *isolines_frame; - +static float isolines_threshold_min = 0.2f; +static float isolines_threshold_max = 2.0f; +static int isolines_nr = 1; void isolines_set_render(int render_isolines) { @@ -80,3 +82,39 @@ struct color4f isolines_get_color(float value) return return_value; } + + + +void isolines_set_nr(int nr) +{ + isolines_nr = nr; +} + +int isolines_get_nr(void) +{ + return isolines_nr; +} + + + +void isolines_set_threshold_min(float threshold_min) +{ + isolines_threshold_min = threshold_min; +} + +float isolines_get_threshold_min(void) +{ + return isolines_threshold_min; +} + + + +void isolines_set_threshold_max(float threshold_max) +{ + isolines_threshold_max = threshold_max; +} + +float isolines_get_threshold_max(void) +{ + return isolines_threshold_max; +} \ No newline at end of file diff --git a/Smoke/isolines.h b/Smoke/isolines.h index 830f4f1..aa5c661 100644 --- a/Smoke/isolines.h +++ b/Smoke/isolines.h @@ -16,7 +16,15 @@ float isolines_get_alpha(void); void isolines_set_frame(fftw_real *frame); fftw_real *isolines_get_frame(void); - struct color4f isolines_get_color(float value); +void isolines_set_nr(int nr); +int isolines_get_nr(void); + +void isolines_set_threshold_min(float threshold_min); +float isolines_get_threshold_min(void); + +void isolines_set_threshold_max(float threshold_max); +float isolines_get_threshold_max(void); + #endif diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c index 78d9867..ae4d894 100644 --- a/Smoke/renderer_gl.c +++ b/Smoke/renderer_gl.c @@ -567,13 +567,17 @@ static void render_isolines(void) wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height - if (isolines_nr) { - iso_scale = (float)(fabs(threshold1 - threshold2) / (float)isolines_nr); + iso_scale = isolines_get_threshold_min(); + iso_scale = isolines_get_threshold_max(); + iso_scale = isolines_get_nr(); + + if (isolines_get_nr()) { + iso_scale = (float)(fabs(isolines_get_threshold_min() - isolines_get_threshold_max()) / (float)isolines_get_nr()); } else { iso_scale = 0.0f; } - for (count = 0; count < isolines_nr; count++) + for (count = 0; count < isolines_get_nr(); count++) { int idx; int i, j; @@ -590,7 +594,7 @@ static void render_isolines(void) v0 = v1 = v2 = v3 = 0.0f; x0 = y0 = x1 = y1 = 0.0f; - threshold = min(threshold1, threshold2) + count * iso_scale; + threshold = min(isolines_get_threshold_min(), isolines_get_threshold_max()) + count * iso_scale; glDisable(GL_LIGHTING); glLineWidth(2.0f); -- cgit v0.12