From b83fcd9e5721b107a15ce51e74984ce38623e44b Mon Sep 17 00:00:00 2001 From: Wilrik de Loose Date: Thu, 10 Jan 2008 12:23:53 +0000 Subject: small changes --- Smoke/Week 2.suo | Bin 76288 -> 77312 bytes Smoke/colormap.c | 2 +- Smoke/gtk.c | 8 +-- Smoke/gtk_colormap.c | 91 ++++++++++++++++++++++- Smoke/gtk_flowvis.c | 2 +- Smoke/gtk_glyphs.c | 2 +- Smoke/gtk_heightplots.c | 2 +- Smoke/gtk_isolines.c | 2 +- Smoke/gtk_main.c | 164 +++++++++++++++--------------------------- Smoke/gtk_streamlines.c | 2 +- Smoke/heightplots.c | 8 +-- Smoke/palette.c | 24 +++++-- Smoke/palette.h | 14 ++-- Smoke/renderer_gl.c | 127 +++++++++++++++++++++++++++----- Smoke/renderer_gl.h | 3 + Smoke/report/2IV35-Report.log | 26 +++---- Smoke/report/2IV35-Report.pdf | Bin 855412 -> 855419 bytes Smoke/report/2IV35-Report.tex | 3 +- Smoke/smoke.c | 20 +++++- Smoke/smoke.h | 3 + 20 files changed, 334 insertions(+), 169 deletions(-) diff --git a/Smoke/Week 2.suo b/Smoke/Week 2.suo index cb0ea2e..ee33852 100644 Binary files a/Smoke/Week 2.suo and b/Smoke/Week 2.suo differ diff --git a/Smoke/colormap.c b/Smoke/colormap.c index f928bce..c3a5c8f 100644 --- a/Smoke/colormap.c +++ b/Smoke/colormap.c @@ -19,7 +19,7 @@ static int colormap_colormap = PALETTE_BLACKWHITE; static int colormap_num_colors = PALETTE_MAXCOLORS; -static float colormap_alpha = 1.0f; +static float colormap_alpha = 0.9f; static int colormap_scaling = FALSE; diff --git a/Smoke/gtk.c b/Smoke/gtk.c index 6e519b5..755d821 100644 --- a/Smoke/gtk.c +++ b/Smoke/gtk.c @@ -767,7 +767,7 @@ create_window (GdkGLConfig *glconfig, struct vis_data_arrays *vis_data) gtk_notebook_append_page(GTK_NOTEBOOK(settings_notebook), notebook_page, notebook_page_label); - notebook_page_label = gtk_label_new("Colormap"); + notebook_page_label = gtk_label_new("Smoke"); gtk_widget_show(notebook_page_label); notebook_page = create_colormap_page(); @@ -799,7 +799,7 @@ create_window (GdkGLConfig *glconfig, struct vis_data_arrays *vis_data) gtk_notebook_append_page(GTK_NOTEBOOK(settings_notebook), notebook_page, notebook_page_label); - notebook_page_label = gtk_label_new("Height Plots"); + notebook_page_label = gtk_label_new("Height plots"); gtk_widget_show(notebook_page_label); notebook_page = create_heightplots_page(); @@ -807,7 +807,7 @@ create_window (GdkGLConfig *glconfig, struct vis_data_arrays *vis_data) gtk_notebook_append_page(GTK_NOTEBOOK(settings_notebook), notebook_page, notebook_page_label); - notebook_page_label = gtk_label_new("Stream Tubes"); + notebook_page_label = gtk_label_new("Stream tubes"); gtk_widget_show(notebook_page_label); notebook_page = create_streamlines_page(); @@ -815,7 +815,7 @@ create_window (GdkGLConfig *glconfig, struct vis_data_arrays *vis_data) gtk_notebook_append_page(GTK_NOTEBOOK(settings_notebook), notebook_page, notebook_page_label); - notebook_page_label = gtk_label_new("Flow Vis"); + notebook_page_label = gtk_label_new("Flow vis"); gtk_widget_show(notebook_page_label); notebook_page = create_flowvis_page(); diff --git a/Smoke/gtk_colormap.c b/Smoke/gtk_colormap.c index 657c586..09d04fe 100644 --- a/Smoke/gtk_colormap.c +++ b/Smoke/gtk_colormap.c @@ -2,6 +2,7 @@ #include +#include "fluids.h" #include "palette.h" #include "colormap.h" @@ -42,12 +43,21 @@ static gboolean select_alpha(GtkRange *adjustment, gpointer data) return TRUE; } -static gboolean set_autoscaling(GtkToggleButton *button, gpointer data) { +static gboolean adjust_autoscaling(GtkToggleButton *button, gpointer data) { colormap_set_autoscaling(gtk_toggle_button_get_active(button)); return TRUE; } +static gboolean set_dataset(GtkToggleButton *button, gpointer data) +{ + if (gtk_toggle_button_get_active(button)) { + smoke_set_dataset((int)data); + } + + return TRUE; +} + GtkWidget *create_colormap_page(void) { @@ -61,6 +71,7 @@ GtkWidget *create_colormap_page(void) GtkWidget *combo; GtkAdjustment *color_adjustment; GtkWidget *color_scale; + GSList *dataset_group; page = gtk_vbox_new(FALSE, 0); @@ -87,7 +98,7 @@ GtkWidget *create_colormap_page(void) button = gtk_check_button_new_with_label("AutoScale"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), colormap_get_autoscaling()); - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_autoscaling), NULL); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(adjust_autoscaling), NULL); gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0); gtk_widget_show(button); @@ -98,6 +109,80 @@ GtkWidget *create_colormap_page(void) gtk_widget_show(frame); + frame = gtk_frame_new("Dataset"); + + box = gtk_vbox_new(FALSE, 0); + + box2 = gtk_hbox_new(FALSE, 0); + + button = gtk_radio_button_new_with_label (NULL, "Rho"); + if (smoke_get_dataset() == DATASET_RHO) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); + } else { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); + } + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_dataset), (gpointer)DATASET_RHO); + gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + dataset_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button)); + + button = gtk_radio_button_new_with_label(dataset_group, "Velocity"); + if (smoke_get_dataset() == DATASET_VEL) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); + } else { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); + } + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_dataset), (gpointer)DATASET_VEL); + gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), "Force"); + if (smoke_get_dataset() == DATASET_FORCE) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); + } else { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); + } + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_dataset), (gpointer)DATASET_FORCE); + gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + gtk_box_pack_start(GTK_BOX(box), box2, TRUE, TRUE, 0); + gtk_widget_show(box2); + + box2 = gtk_hbox_new(FALSE, 0); + + dataset_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button)); + + button = gtk_radio_button_new_with_label(dataset_group, "Velocity divergence"); + if (smoke_get_dataset() == DATASET_DIVV) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); + } else { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); + } + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_dataset), (gpointer)DATASET_DIVV); + gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), "Force divergence"); + if (smoke_get_dataset() == DATASET_DIVF) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); + } else { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); + } + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_dataset), (gpointer)DATASET_DIVF); + gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + + gtk_box_pack_start(GTK_BOX(box), box2, TRUE, TRUE, 0); + gtk_widget_show(box2); + + gtk_container_add(GTK_CONTAINER(frame), box); + gtk_widget_show(box); + + gtk_box_pack_start (GTK_BOX(page), frame, FALSE, TRUE, 0); + gtk_widget_show(frame); frame = gtk_frame_new("Colors"); @@ -115,7 +200,7 @@ GtkWidget *create_colormap_page(void) gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BLACKWHITE); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_RAINBOW); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BANDS); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BLUE_GREEN_RED); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_GREY_BANDS); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_WILRIK); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_OLIVER); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_RED); diff --git a/Smoke/gtk_flowvis.c b/Smoke/gtk_flowvis.c index ef78326..5db3b62 100644 --- a/Smoke/gtk_flowvis.c +++ b/Smoke/gtk_flowvis.c @@ -64,7 +64,7 @@ GtkWidget *create_flowvis_page(void) gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BLACKWHITE); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_RAINBOW); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BANDS); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BLUE_GREEN_RED); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_GREY_BANDS); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_WILRIK); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_OLIVER); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_RED); diff --git a/Smoke/gtk_glyphs.c b/Smoke/gtk_glyphs.c index 8db7eb3..4318163 100644 --- a/Smoke/gtk_glyphs.c +++ b/Smoke/gtk_glyphs.c @@ -225,7 +225,7 @@ GtkWidget *create_glyphs_page(void) gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BLACKWHITE); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_RAINBOW); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BANDS); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BLUE_GREEN_RED); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_GREY_BANDS); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_WILRIK); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_OLIVER); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_RED); diff --git a/Smoke/gtk_heightplots.c b/Smoke/gtk_heightplots.c index 0f74dc8..0586eb2 100644 --- a/Smoke/gtk_heightplots.c +++ b/Smoke/gtk_heightplots.c @@ -69,7 +69,7 @@ static void init_adjustments(void) g_object_ref(rho_adj); heightplots_set_dataset(DATASET_VEL); vel_adj = GTK_ADJUSTMENT(gtk_adjustment_new( - heightplots_get_height(), 1, 5000, 5, 50, 0)); + heightplots_get_height(), 1, 6000, 5, 50, 0)); g_object_ref(vel_adj); heightplots_set_dataset(DATASET_FORCE); force_adj = GTK_ADJUSTMENT(gtk_adjustment_new( diff --git a/Smoke/gtk_isolines.c b/Smoke/gtk_isolines.c index a2b213a..d0662e4 100644 --- a/Smoke/gtk_isolines.c +++ b/Smoke/gtk_isolines.c @@ -138,7 +138,7 @@ GtkWidget *create_isolines_page(void) gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BLACKWHITE); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_RAINBOW); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BANDS); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BLUE_GREEN_RED); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_GREY_BANDS); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_WILRIK); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_OLIVER); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_RED); diff --git a/Smoke/gtk_main.c b/Smoke/gtk_main.c index 5f9e876..ebc1fe1 100644 --- a/Smoke/gtk_main.c +++ b/Smoke/gtk_main.c @@ -33,6 +33,13 @@ static gboolean select_render_smoke(GtkWidget *button, gpointer data) { } +static gboolean select_render_grid_smoke(GtkWidget *button, gpointer data) { + smoke_grid_set_render(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))); + + return TRUE; +} + + static gboolean select_render_glyphs(GtkWidget *button, gpointer data) { glyphs_set_render(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))); @@ -63,15 +70,6 @@ static gboolean select_calculate(GtkWidget *button, gpointer data) { return TRUE; } -static gboolean set_dataset(GtkToggleButton *button, gpointer data) -{ - if (gtk_toggle_button_get_active(button)) { - smoke_set_dataset((int)data); - } - - return TRUE; -} - static gboolean select_normals(GtkWidget *button, gpointer data) { normals_set_render(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))); @@ -139,6 +137,13 @@ static gboolean select_zoom_speed(GtkRange *adjustment, gpointer data) return TRUE; } +static gboolean select_cell_size(GtkRange *adjustment, gpointer data) +{ + renderer_set_grid_cell_size((int)gtk_range_get_value(adjustment)); + + return TRUE; +} + static gboolean reset_simulation(GtkWidget *button, gpointer data) { fluids_reset_simulation(); @@ -156,68 +161,73 @@ GtkWidget *create_main_page(void) GtkWidget *button; GtkAdjustment *adjustment; GtkWidget *scale; - GSList *dataset_group; page = gtk_vbox_new(FALSE, 0); frame = gtk_frame_new("Simulation"); box = gtk_vbox_new(FALSE, 0); - button = gtk_check_button_new_with_label("Draw Grid"); + button = gtk_check_button_new_with_label("Draw grid"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), renderer_get_render_grid()); g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(select_render_grid), NULL); gtk_box_pack_start (GTK_BOX(box), button, TRUE, TRUE, 0); gtk_widget_show(button); - button = gtk_check_button_new_with_label("Draw Smoke"); + button = gtk_check_button_new_with_label("Draw smoke"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), smoke_get_render()); g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(select_render_smoke), NULL); gtk_box_pack_start (GTK_BOX(box), button, TRUE, TRUE, 0); gtk_widget_show(button); - button = gtk_check_button_new_with_label("Draw Glyphs"); + button = gtk_check_button_new_with_label("Draw grid-smoke"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), smoke_grid_get_render()); + g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(select_render_grid_smoke), NULL); + gtk_box_pack_start (GTK_BOX(box), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + button = gtk_check_button_new_with_label("Draw glyphs"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), glyphs_get_render()); g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(select_render_glyphs), NULL); gtk_box_pack_start (GTK_BOX(box), button, TRUE, TRUE, 0); gtk_widget_show(button); - button = gtk_check_button_new_with_label("Draw Isolines"); + button = gtk_check_button_new_with_label("Draw isolines"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), isolines_get_render()); g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(select_render_isolines), NULL); gtk_box_pack_start (GTK_BOX(box), button, TRUE, TRUE, 0); gtk_widget_show(button); - button = gtk_check_button_new_with_label("Draw Streamlines"); + button = gtk_check_button_new_with_label("Draw streamlines"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), streamlines_get_render()); g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(select_render_streamlines), NULL); gtk_box_pack_start (GTK_BOX(box), button, TRUE, TRUE, 0); gtk_widget_show(button); - button = gtk_check_button_new_with_label("Draw Flowvis"); + button = gtk_check_button_new_with_label("Draw flowvis"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), flowvis_get_render()); g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(select_render_flowvis), NULL); gtk_box_pack_start (GTK_BOX(box), button, TRUE, TRUE, 0); gtk_widget_show(button); - button = gtk_check_button_new_with_label("Toggle Calculation"); + button = gtk_check_button_new_with_label("Toggle calculation"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), fluids_get_calculate()); g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(select_calculate), NULL); gtk_box_pack_start (GTK_BOX(box), button, TRUE, TRUE, 0); gtk_widget_show(button); - button = gtk_check_button_new_with_label("Draw Normals Vectors"); + button = gtk_check_button_new_with_label("Draw normal vectors"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), normals_get_render()); g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(select_normals), NULL); gtk_box_pack_start (GTK_BOX(box), button, TRUE, TRUE, 0); gtk_widget_show(button); - button = gtk_check_button_new_with_label("Draw Normals2 Vectors"); + button = gtk_check_button_new_with_label("Draw normal vectors 2"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), normals_get_render2()); g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(select_normals2), NULL); gtk_box_pack_start (GTK_BOX(box), button, TRUE, TRUE, 0); gtk_widget_show(button); - button = gtk_button_new_with_label("Reset Simulation"); + button = gtk_button_new_with_label("Reset simulation"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_simulation), NULL); gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0); gtk_widget_show(button); @@ -228,104 +238,28 @@ GtkWidget *create_main_page(void) gtk_box_pack_start (GTK_BOX(page), frame, FALSE, TRUE, 0); gtk_widget_show(frame); - frame = gtk_frame_new("Dataset"); - - box = gtk_vbox_new(FALSE, 0); - - box2 = gtk_hbox_new(FALSE, 0); - - button = gtk_radio_button_new_with_label (NULL, "Rho"); - if (smoke_get_dataset() == DATASET_RHO) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); - } else { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); - } - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_dataset), (gpointer)DATASET_RHO); - gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); - gtk_widget_show(button); - - dataset_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button)); - - button = gtk_radio_button_new_with_label(dataset_group, "Velocity"); - if (smoke_get_dataset() == DATASET_VEL) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); - } else { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); - } - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_dataset), (gpointer)DATASET_VEL); - gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); - gtk_widget_show(button); - - button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), "Force"); - if (smoke_get_dataset() == DATASET_FORCE) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); - } else { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); - } - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_dataset), (gpointer)DATASET_FORCE); - gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); - gtk_widget_show(button); - - gtk_box_pack_start(GTK_BOX(box), box2, TRUE, TRUE, 0); - gtk_widget_show(box2); - - box2 = gtk_hbox_new(FALSE, 0); - - dataset_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button)); - - button = gtk_radio_button_new_with_label(dataset_group, "Divergence Velocity"); - if (smoke_get_dataset() == DATASET_DIVV) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); - } else { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); - } - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_dataset), (gpointer)DATASET_DIVV); - gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); - gtk_widget_show(button); - - button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), "Divergence Force"); - if (smoke_get_dataset() == DATASET_DIVF) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); - } else { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); - } - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_dataset), (gpointer)DATASET_DIVF); - gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); - gtk_widget_show(button); - - - gtk_box_pack_start(GTK_BOX(box), box2, TRUE, TRUE, 0); - gtk_widget_show(box2); - - gtk_container_add(GTK_CONTAINER(frame), box); - gtk_widget_show(box); - - gtk_box_pack_start (GTK_BOX(page), frame, FALSE, TRUE, 0); - gtk_widget_show(frame); - - frame = gtk_frame_new("View"); box = gtk_hbox_new(FALSE, 0); - button = gtk_button_new_with_label("Reset All"); + button = gtk_button_new_with_label("Reset all"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_all), NULL); gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0); gtk_widget_show(button); box2 = gtk_vbox_new(FALSE, 0); - button = gtk_button_new_with_label("Reset Zoom"); + button = gtk_button_new_with_label("Reset zoom"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_zoom), NULL); gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); gtk_widget_show(button); - button = gtk_button_new_with_label("Reset Position"); + button = gtk_button_new_with_label("Reset position"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_pos), NULL); gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); gtk_widget_show(button); - button = gtk_button_new_with_label("Reset Rotate"); + button = gtk_button_new_with_label("Reset rotate"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_rotate), NULL); gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); gtk_widget_show(button); @@ -335,17 +269,17 @@ GtkWidget *create_main_page(void) box2 = gtk_vbox_new(FALSE, 0); - button = gtk_button_new_with_label("Reset Yaw"); + button = gtk_button_new_with_label("Reset yaw"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_yaw), NULL); gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); gtk_widget_show(button); - button = gtk_button_new_with_label("Reset Pitch"); + button = gtk_button_new_with_label("Reset pitch"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_pitch), NULL); gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); gtk_widget_show(button); - button = gtk_button_new_with_label("Reset Roll"); + button = gtk_button_new_with_label("Reset roll"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_roll), NULL); gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0); gtk_widget_show(button); @@ -359,12 +293,12 @@ GtkWidget *create_main_page(void) gtk_box_pack_start (GTK_BOX(page), frame, FALSE, TRUE, 0); gtk_widget_show(frame); - frame = gtk_frame_new("Zoom Speed"); + frame = gtk_frame_new("Zoom speed"); box = gtk_vbox_new(FALSE, 0); adjustment = GTK_ADJUSTMENT(gtk_adjustment_new( - renderer_get_zoomspeed(), 1, 100, 5, 5, 0.1)); + renderer_get_zoomspeed(), 1, 256, 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_zoom_speed), NULL); @@ -379,5 +313,25 @@ GtkWidget *create_main_page(void) gtk_widget_show(frame); + frame = gtk_frame_new("Grid cell size"); + + box = gtk_vbox_new(FALSE, 0); + + adjustment = GTK_ADJUSTMENT(gtk_adjustment_new( + renderer_get_grid_cell_size(), 16, 128, 1, 8, 0.0)); + scale = gtk_hscale_new(adjustment); + gtk_scale_set_digits(GTK_SCALE(scale), 0); + g_signal_connect(GTK_RANGE(scale), "value-changed", G_CALLBACK(select_cell_size), NULL); + + gtk_box_pack_start(GTK_BOX(box), scale, FALSE, TRUE, 0); + gtk_widget_show(scale); + + gtk_widget_show(box); + gtk_container_add(GTK_CONTAINER(frame), box); + + gtk_box_pack_start (GTK_BOX(page), frame, FALSE, TRUE, 0); + gtk_widget_show(frame); + + return page; } diff --git a/Smoke/gtk_streamlines.c b/Smoke/gtk_streamlines.c index 8096b24..187df55 100644 --- a/Smoke/gtk_streamlines.c +++ b/Smoke/gtk_streamlines.c @@ -74,7 +74,7 @@ GtkWidget *create_streamlines_page(void) gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BLACKWHITE); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_RAINBOW); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BANDS); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_BLUE_GREEN_RED); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_GREY_BANDS); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_WILRIK); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_OLIVER); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), PALETTE_NAME_RED); diff --git a/Smoke/heightplots.c b/Smoke/heightplots.c index 669bbfd..bc72c5b 100644 --- a/Smoke/heightplots.c +++ b/Smoke/heightplots.c @@ -23,11 +23,11 @@ static float heightplots_alpha = 1.0f; static int heightplots_dataset = DATASET_RHO; -static int heightplots_rho = 16; -static int heightplots_vel = 5000; +static int heightplots_rho = 32; +static int heightplots_vel = 2000; static int heightplots_force = 100; -static int heightplots_divv = 100; -static int heightplots_divf = 100; +static int heightplots_divv = 100; +static int heightplots_divf = 100; static fftw_real *heightplots_frame; diff --git a/Smoke/palette.c b/Smoke/palette.c index a653db7..d8b10a9 100644 --- a/Smoke/palette.c +++ b/Smoke/palette.c @@ -13,8 +13,8 @@ static float trip_like_i_do_arr[10][3] = { - {0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 1.0f, 0.0f}, {0.0f, 1.0f, 1.0f}, - {1.0f, 0.0f, 1.0f}, {1.0f, 0.5f, 0.5f}, {0.5f, 0.5f, 1.0f}, {0.5f, 1.0f, 0.5f}, {0.0f, 1.0f, 0.0f}, + {0.0f, 0.0f, 0.0f}, {0.1f, 0.1f, 0.1f}, {0.2f, 0.2f, 0.2f}, {0.3f, 0.3f, 0.3f}, {0.4f, 0.4f, 0.4f}, + {0.5f, 0.5f, 0.5f}, {0.6f, 0.6f, 0.6f}, {0.7f, 0.7f, 0.7f}, {0.8f, 0.8f, 0.8f}, {0.9f, 0.9f, 0.9f}, }; void HSVtoRGB(float *r, float *g, float *b, float h, float s, float v) @@ -136,6 +136,21 @@ static struct color4f rainbow(float value) } +static struct color4f puke_like_he_does(float value) +{ + struct color4f return_value; + float val; + + val = (float)(((int)(value * 100)) % 10); + + return_value.r = val/10.0f; + return_value.g = val/10.0f; + return_value.b = val/10.0f; + + return return_value; +} + + static struct color4f trip_like_i_do(float value) { struct color4f return_value; @@ -223,15 +238,14 @@ struct color4f set_palette(int colormap_sort, float value, int num_colors) value/= 7; return_value = rainbow(value); break; - case PALETTE_BLUE_GREEN_RED: - return_value = bluegreenred(value); - break; case PALETTE_WILRIK: return_value = colormap_fire(value); break; case PALETTE_OLIVER: return_value = trip_like_i_do(value); break; + case PALETTE_GREY_BANDS: + return_value = puke_like_he_does(value); case PALETTE_RED: return_value.r = 1.0f; break; diff --git a/Smoke/palette.h b/Smoke/palette.h index a5ad512..d560cb8 100644 --- a/Smoke/palette.h +++ b/Smoke/palette.h @@ -4,22 +4,22 @@ #define PALETTE_BLACKWHITE 0 #define PALETTE_RAINBOW 1 #define PALETTE_BANDS 2 -#define PALETTE_BLUE_GREEN_RED 3 +#define PALETTE_GREY_BANDS 3 #define PALETTE_WILRIK 4 #define PALETTE_OLIVER 5 #define PALETTE_RED 6 #define PALETTE_GREEN 7 #define PALETTE_BLUE 8 -#define PALETTE_NAME_BLACKWHITE "Black and White" +#define PALETTE_NAME_BLACKWHITE "Black and white" #define PALETTE_NAME_RAINBOW "Rainbow" -#define PALETTE_NAME_BANDS "7 Band Rainbow" -#define PALETTE_NAME_BLUE_GREEN_RED "Blue Green Red" +#define PALETTE_NAME_BANDS "7 band rainbow" +#define PALETTE_NAME_GREY_BANDS "Grey bands" #define PALETTE_NAME_WILRIK "Wilrik" #define PALETTE_NAME_OLIVER "Oliver" -#define PALETTE_NAME_RED "Red Only!" -#define PALETTE_NAME_GREEN "Green Only!" -#define PALETTE_NAME_BLUE "Blue Only!" +#define PALETTE_NAME_RED "Red only" +#define PALETTE_NAME_GREEN "Green only" +#define PALETTE_NAME_BLUE "Blue only" #define PALETTE_MAXCOLORS 256 diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c index 8b81d46..1e06356 100644 --- a/Smoke/renderer_gl.c +++ b/Smoke/renderer_gl.c @@ -34,7 +34,7 @@ #define DEFAULT_ZOOM -750.0f #define MIN_ZOOM -100.0f #define MAX_ZOOM -4000.0f -#define DEFAULT_ZOOM_SPEED 40 +#define DEFAULT_ZOOM_SPEED 100 #define MIN_ZOOM -100.0f #define MAX_ZOOM -4000.0f @@ -56,10 +56,9 @@ float y_pos = DEFAULT_Y_POS; float z_pos = DEFAULT_ZOOM; static int renderer_render_grid = FALSE; - static int renderer_zoomspeed = DEFAULT_ZOOM_SPEED; - static GLuint texture; +static int grid_cell_size = 50; @@ -194,33 +193,45 @@ static void render_legend(void) glEnable(GL_DEPTH_TEST); } +int renderer_get_grid_cell_size(void) +{ + return grid_cell_size; +} + +void renderer_set_grid_cell_size(int cell_size) +{ + grid_cell_size = cell_size; +} + static void render_grid(void) { int i, DIM; - - DIM = fluids_get_dim(); + DIM = renderer_get_grid_cell_size(); glColor4f(0.0f, 0.0f, 0.5f, 0.8f); glLineWidth(1.0f); - for (i = 0; i < winWidth; i += DIM) { - if (i) { - glBegin(GL_LINES); - glVertex2i(i, 0); - glVertex2i(i, winWidth); - glEnd(); + glBegin(GL_LINES); + for (i = 0; i < winWidth; i += DIM) + { + if (i) + { + glVertex3i(i, 0, 0); + glVertex3i(i, winWidth, 0); } } - for (i = 0; i < winHeight; i += DIM) { - if (i) { - glBegin(GL_LINES); - glVertex2i(0, i); - glVertex2i(winHeight, i); - glEnd(); + for (i = 0; i < winHeight; i += DIM) + { + if (i) + { + glVertex3i(0, i, 0); + glVertex3i(winHeight, i, 0); } } + + glEnd(); } static void render_normal(void) @@ -310,7 +321,14 @@ void render_smoke(void) DIM = fluids_get_dim(); - glDisable(GL_BLEND); + if (colormap_get_alpha() < 1.0f) + { + glEnable(GL_BLEND); + } + else + { + glDisable(GL_BLEND); + } wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height @@ -367,7 +385,75 @@ void render_smoke(void) glEnd(); } - glEnable(GL_BLEND); + glDisable(GL_BLEND); +} + + +void render_grid_smoke(void) +{ + int i, j, idx, DIM; + double px, py, pz; + fftw_real wn, hn; + struct color4f color; + fftw_real *frame, *height; + + DIM = fluids_get_dim(); + + glDisable(GL_BLEND); + + wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width + hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height + + frame = smoke_get_frame(); + height = heightplots_get_frame(); + + for (j = 0; j < DIM - 1; j++) + { + glBegin(GL_LINE_STRIP); + + // horizontal lines + for (i = 0; i < DIM - 1; i++) + { + // vertex 2 + idx = ((j + 1) * DIM) + i; + + px = wn + (fftw_real)i * wn; + py = hn + (fftw_real)(j + 1) * hn; + pz = height[idx] * heightplots_get_height(); + + color = colormap_get_color(frame[idx]); + glColor4f(color.r, color.g, color.b, color.a); + + glVertex3f(px, py, pz); + + // vertex 1 + idx = (j * DIM) + i; + + px = wn + (fftw_real)i * wn; + py = hn + (fftw_real)j * hn; + pz = height[idx] * heightplots_get_height(); + + color = colormap_get_color(frame[idx]); + glColor4f(color.r, color.g, color.b, color.a); + + glVertex3f(px, py, pz); + + // vertex 3 + idx = (j * DIM) + (i + 1); + + px = wn + (fftw_real)(i + 1) * wn; + py = hn + (fftw_real)j * hn; + pz = height[idx] * heightplots_get_height(); + + color = colormap_get_color(frame[idx]); + glColor4f(color.r, color.g, color.b, color.a); + + glVertex3f(px, py, pz); + + } + + glEnd(); + } } @@ -911,6 +997,9 @@ void visualize(struct vis_data_arrays *vis_data) if (smoke_get_render()) { render_smoke(); } + else if (smoke_grid_get_render()) { + render_grid_smoke(); + } if (glyphs_get_render()) { render_glyphs(); diff --git a/Smoke/renderer_gl.h b/Smoke/renderer_gl.h index ecaa741..7238037 100644 --- a/Smoke/renderer_gl.h +++ b/Smoke/renderer_gl.h @@ -21,6 +21,9 @@ void renderer_reset_yaw(void); void renderer_reset_pitch(void); void renderer_reset_roll(void); +int renderer_get_grid_cell_size(void); +void renderer_set_grid_cell_size(int cell_size); + void renderer_load_texture(char *filename); extern float x_rot; diff --git a/Smoke/report/2IV35-Report.log b/Smoke/report/2IV35-Report.log index 6a65803..26a2a31 100644 --- a/Smoke/report/2IV35-Report.log +++ b/Smoke/report/2IV35-Report.log @@ -1,4 +1,4 @@ -This is pdfeTeX, Version 3.141592-1.21a-2.2 (MiKTeX 2.4) (preloaded format=latex 2007.9.5) 10 JAN 2008 10:33 +This is pdfeTeX, Version 3.141592-1.21a-2.2 (MiKTeX 2.4) (preloaded format=latex 2007.9.5) 10 JAN 2008 10:48 entering extended mode **2IV35-Report.tex (2IV35-Report.tex @@ -184,11 +184,11 @@ loading : Context Support Macros / PDF (2004.03.26) \MPnumerator=\count113 \everyMPtoPDFconversion=\toks25 ) -LaTeX Font Info: Try loading font information for U+msa on input line 14. +LaTeX Font Info: Try loading font information for U+msa on input line 13. (C:\MiKTeX\texmf\tex\latex\amsfonts\umsa.fd File: umsa.fd 2002/01/19 v2.2g AMS font definitions ) -LaTeX Font Info: Try loading font information for U+msb on input line 14. +LaTeX Font Info: Try loading font information for U+msb on input line 13. (C:\MiKTeX\texmf\tex\latex\amsfonts\umsb.fd File: umsb.fd 2002/01/19 v2.2g AMS font definitions @@ -229,7 +229,7 @@ Underfull \hbox (badness 10000) in paragraph at lines 17--19 [] ) -Underfull \hbox (badness 10000) in paragraph at lines 20--20 +Underfull \hbox (badness 10000) in paragraph at lines 20--19 [] @@ -267,7 +267,7 @@ Underfull \hbox (badness 10000) in paragraph at lines 25--28 [] ) -Underfull \hbox (badness 10000) in paragraph at lines 29--21 +Underfull \hbox (badness 10000) in paragraph at lines 29--20 [] @@ -315,7 +315,7 @@ Underfull \hbox (badness 10000) in paragraph at lines 49--52 [] [8 ]) -Underfull \hbox (badness 10000) in paragraph at lines 53--22 +Underfull \hbox (badness 10000) in paragraph at lines 53--21 [] @@ -417,7 +417,7 @@ Underfull \hbox (badness 10000) in paragraph at lines 21--23 ]) -Underfull \hbox (badness 10000) in paragraph at lines 26--24 +Underfull \hbox (badness 10000) in paragraph at lines 26--23 [] @@ -474,7 +474,7 @@ Underfull \hbox (badness 10000) in paragraph at lines 50--51 File: ambiguous.png Graphic file (type png) ) -Underfull \hbox (badness 10000) in paragraph at lines 59--25 +Underfull \hbox (badness 10000) in paragraph at lines 59--24 [] @@ -570,7 +570,7 @@ Underfull \hbox (badness 10000) in paragraph at lines 72--75 [] ) -Underfull \hbox (badness 10000) in paragraph at lines 76--26 +Underfull \hbox (badness 10000) in paragraph at lines 76--25 [] @@ -611,7 +611,7 @@ Underfull \hbox (badness 10000) in paragraph at lines 23--24 [] ) -Underfull \hbox (badness 10000) in paragraph at lines 27--27 +Underfull \hbox (badness 10000) in paragraph at lines 27--26 [] @@ -657,7 +657,7 @@ Underfull \hbox (badness 10000) in paragraph at lines 25--27 [] ) -Underfull \hbox (badness 10000) in paragraph at lines 28--28 +Underfull \hbox (badness 10000) in paragraph at lines 28--27 [] @@ -718,7 +718,7 @@ Underfull \hbox (badness 10000) in paragraph at lines 31--33 [] ) -Underfull \hbox (badness 10000) in paragraph at lines 36--29 +Underfull \hbox (badness 10000) in paragraph at lines 36--28 [] @@ -745,4 +745,4 @@ esky\cm\cmtt12.pfb> -Output written on 2IV35-Report.pdf (30 pages, 855412 bytes). +Output written on 2IV35-Report.pdf (30 pages, 855419 bytes). diff --git a/Smoke/report/2IV35-Report.pdf b/Smoke/report/2IV35-Report.pdf index b088a94..67a504b 100644 Binary files a/Smoke/report/2IV35-Report.pdf and b/Smoke/report/2IV35-Report.pdf differ diff --git a/Smoke/report/2IV35-Report.tex b/Smoke/report/2IV35-Report.tex index 0a92f36..32b5ece 100644 --- a/Smoke/report/2IV35-Report.tex +++ b/Smoke/report/2IV35-Report.tex @@ -9,8 +9,7 @@ % Title page \title{Visualization 2IV35} - \author{Oliver Schinagl (...)\\Wilrik De Loose (0601583)} - %\date{29th of August 2007} + \author{Oliver Schinagl (0580852)\\Wilrik De Loose (0601583)} \maketitle %no paragraph indentation diff --git a/Smoke/smoke.c b/Smoke/smoke.c index 70696a4..cc21479 100644 --- a/Smoke/smoke.c +++ b/Smoke/smoke.c @@ -10,14 +10,19 @@ static int smoke_render_smoke = TRUE; +static int smoke_render_smoke_grid = FALSE; static int smoke_dataset = DATASET_RHO; static fftw_real *smoke_frame; - void smoke_set_render(int render_smoke) { smoke_render_smoke = render_smoke; + + if (smoke_render_smoke) + { + smoke_render_smoke_grid = FALSE; + } } int smoke_get_render(void) @@ -25,6 +30,19 @@ int smoke_get_render(void) return smoke_render_smoke; } +int smoke_grid_get_render(void) +{ + return smoke_render_smoke_grid; +} + +void smoke_grid_set_render(int render_grid) +{ + if (!smoke_render_smoke) + { + smoke_render_smoke_grid = render_grid; + } +} + void smoke_set_dataset(int dataset) { smoke_dataset = dataset; diff --git a/Smoke/smoke.h b/Smoke/smoke.h index 8c163ff..7d7fa3c 100644 --- a/Smoke/smoke.h +++ b/Smoke/smoke.h @@ -4,6 +4,9 @@ void smoke_set_render(int render_smoke); int smoke_get_render(void); +void smoke_grid_set_render(int render_grid); +int smoke_grid_get_render(void); + void smoke_set_dataset(int dataset); int smoke_get_dataset(void); -- cgit v0.12