summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2008-01-05 04:02:07 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2008-01-05 04:02:07 (GMT)
commit11e1578b67647a603e23fae44fe658fe2806e19a (patch)
treedacfbba0e25b4e86aaf8ab5e36c92099dc442a76
parentcf983359977dbea21b49747e3430725209a804ee (diff)
download2iv35-11e1578b67647a603e23fae44fe658fe2806e19a.zip
2iv35-11e1578b67647a603e23fae44fe658fe2806e19a.tar.gz
2iv35-11e1578b67647a603e23fae44fe658fe2806e19a.tar.bz2
heightplots added
-rw-r--r--Smoke/fluids.c2
-rw-r--r--Smoke/gtk_heightplots.c185
-rw-r--r--Smoke/heightplots.c45
-rw-r--r--Smoke/heightplots.h3
-rw-r--r--Smoke/renderer_gl.c36
-rwxr-xr-xSmoke/smoke.binbin631486 -> 636108 bytes
6 files changed, 250 insertions, 21 deletions
diff --git a/Smoke/fluids.c b/Smoke/fluids.c
index 0dc8469..dcf0a08 100644
--- a/Smoke/fluids.c
+++ b/Smoke/fluids.c
@@ -425,6 +425,8 @@ void calculate_one_simulation_step(struct vis_data_arrays *vis_data)
dataset = glyphs_get_dataset_color();
frame = get_frame(vis_data, dataset);
glyphs_set_frame(frame);
+
+ heightplots_set_frame(vis_data->height);
}
//------ VISUALIZATION CODE STARTS HERE -----------------------------------------------------------------
diff --git a/Smoke/gtk_heightplots.c b/Smoke/gtk_heightplots.c
index 9e3d52a..42ddf70 100644
--- a/Smoke/gtk_heightplots.c
+++ b/Smoke/gtk_heightplots.c
@@ -1,20 +1,94 @@
#include <gtk/gtk.h>
+#include <rfftw.h>
+#include "fluids.h"
+
+#include "heightplots.h"
#include "gtk_heightplots.h"
-static gboolean select_colormap(GtkComboBox *combo, gpointer data)
+
+static GtkWidget *height_scale;
+static GtkAdjustment *rho_adj, *vel_adj, *force_adj, *divv_adj, *divf_adj;
+
+
+static gboolean set_dataset(GtkToggleButton *button, gpointer data)
{
- heightplots_set_colormap(gtk_combo_box_get_active(combo));
-}
+ GtkAdjustment *temp;
+ gchar *s;
+ if (gtk_toggle_button_get_active(button)) {
+ switch ((int)data) {
+ default:
+ break;
+ case DATASET_RHO:
+ heightplots_set_dataset(DATASET_RHO);
+ gtk_range_set_adjustment(GTK_RANGE(height_scale), rho_adj);
+ gtk_adjustment_set_value(rho_adj, heightplots_get_height());
+ break;
+ case DATASET_VEL:
+ heightplots_set_dataset(DATASET_VEL);
+ gtk_range_set_adjustment(GTK_RANGE(height_scale), vel_adj);
+ gtk_adjustment_set_value(vel_adj, heightplots_get_height());
+ break;
+ case DATASET_FORCE:
+ heightplots_set_dataset(DATASET_FORCE);
+ gtk_range_set_adjustment(GTK_RANGE(height_scale), force_adj);
+ gtk_adjustment_set_value(force_adj, heightplots_get_height());
+ break;
+ case DATASET_DIVV:
+ heightplots_set_dataset(DATASET_DIVV);
+ gtk_range_set_adjustment(GTK_RANGE(height_scale), divv_adj);
+ gtk_adjustment_set_value(force_adj, heightplots_get_height());
+ break;
+ case DATASET_DIVF:
+ heightplots_set_dataset(DATASET_DIVF);
+ gtk_range_set_adjustment(GTK_RANGE(height_scale), divf_adj);
+ gtk_adjustment_set_value(force_adj, heightplots_get_height());
+ break;
+ }
+ }
-static gboolean select_num_colors(GtkRange *adjustment, gpointer data)
+ return TRUE;
+}
+
+static gboolean select_height(GtkRange *adjustment, gpointer data)
{
- heightplots_set_num_colors((int)gtk_range_get_value(adjustment));
+ heightplots_set_height((int)gtk_range_get_value(adjustment));
+
+ return TRUE;
}
+static void init_adjustments(void)
+{
+ int dataset;
+
+ dataset = heightplots_get_dataset();
+
+ heightplots_set_dataset(DATASET_RHO);
+ rho_adj = GTK_ADJUSTMENT(gtk_adjustment_new(
+ heightplots_get_height(), 1, 500, 5, 50, 0));
+ g_object_ref(rho_adj);
+ heightplots_set_dataset(DATASET_VEL);
+ vel_adj = GTK_ADJUSTMENT(gtk_adjustment_new(
+ heightplots_get_height(), 1, 1000, 5, 50, 0));
+ g_object_ref(vel_adj);
+ heightplots_set_dataset(DATASET_FORCE);
+ force_adj = GTK_ADJUSTMENT(gtk_adjustment_new(
+ heightplots_get_height(), 1, 2000, 5, 50, 0));
+ g_object_ref(force_adj);
+ heightplots_set_dataset(DATASET_DIVV);
+ divv_adj = GTK_ADJUSTMENT(gtk_adjustment_new(
+ heightplots_get_height(), 1, 3000, 5, 50, 0));
+ g_object_ref(divv_adj);
+ heightplots_set_dataset(DATASET_DIVF);
+ divf_adj = GTK_ADJUSTMENT(gtk_adjustment_new(
+ heightplots_get_height(), 1, 4000, 5, 50, 0));
+ g_object_ref(divf_adj);
+
+ heightplots_set_dataset(dataset);
+}
GtkWidget *create_heightplots_page(void)
@@ -22,8 +96,109 @@ GtkWidget *create_heightplots_page(void)
/* in reality a page is really just a vbox filled with other widgets
*/
GtkWidget *page;
+ GtkWidget *frame;
+ GtkWidget *box, *box2;
+ GtkWidget *button;
+ GSList *dataset_group;
+
+
+ init_adjustments();
page = gtk_vbox_new(FALSE, 0);
+ 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 (heightplots_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 (heightplots_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 (heightplots_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 (heightplots_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 (heightplots_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("Muliplier");
+
+ box = gtk_vbox_new(FALSE, 0);
+
+ height_scale = gtk_hscale_new(rho_adj);
+ gtk_scale_set_digits(GTK_SCALE(height_scale), 0);
+ g_signal_connect(GTK_RANGE(height_scale), "value-changed", G_CALLBACK(select_height), NULL);
+
+ gtk_box_pack_start(GTK_BOX(box), height_scale, FALSE, TRUE, 0);
+ gtk_widget_show(height_scale);
+
+ 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);
+
+
return page;
}
diff --git a/Smoke/heightplots.c b/Smoke/heightplots.c
index 4593455..2f166d6 100644
--- a/Smoke/heightplots.c
+++ b/Smoke/heightplots.c
@@ -23,6 +23,9 @@ static float heightplots_alpha = 1.0f;
static int heightplots_dataset = DATASET_RHO;
+static int heightplots_rho, heightplots_vel, heightplots_force = 100;
+static int heightplots_divv, heightplots_divf = 1000;
+
static fftw_real *heightplots_frame;
@@ -76,6 +79,48 @@ int heightplots_get_dataset(void)
return heightplots_dataset;
}
+void heightplots_set_height(int height)
+{
+ switch(heightplots_dataset) {
+ case DATASET_RHO:
+ heightplots_rho = height;
+ case DATASET_VEL:
+ heightplots_vel = height;
+ case DATASET_FORCE:
+ heightplots_force = height;
+ case DATASET_DIVV:
+ heightplots_divv = height;
+ case DATASET_DIVF:
+ heightplots_divf = height;
+ default:
+ break;
+ }
+}
+
+int heightplots_get_height(void)
+{
+ int return_value;
+
+ return_value = 0;
+
+ switch(heightplots_dataset) {
+ case DATASET_RHO:
+ return_value = heightplots_rho;
+ case DATASET_VEL:
+ return_value = heightplots_vel;
+ case DATASET_FORCE:
+ return_value = heightplots_force;
+ case DATASET_DIVV:
+ return_value = heightplots_divv;
+ case DATASET_DIVF:
+ return_value = heightplots_divf;
+ default:
+ break;
+ }
+
+ return return_value;
+}
+
void heightplots_set_frame(fftw_real *frame)
{
heightplots_frame = frame;
diff --git a/Smoke/heightplots.h b/Smoke/heightplots.h
index 49c5441..6c25c69 100644
--- a/Smoke/heightplots.h
+++ b/Smoke/heightplots.h
@@ -16,6 +16,9 @@ float heightplots_get_alpha(void);
void heightplots_set_dataset(int dataset);
int heightplots_get_dataset(void);
+void heightplots_set_height(int height);
+int heightplots_get_height(void);
+
void heightplots_set_frame(fftw_real *frame);
fftw_real *heightplots_get_frame(void);
diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c
index b21ef58..1d722ce 100644
--- a/Smoke/renderer_gl.c
+++ b/Smoke/renderer_gl.c
@@ -553,18 +553,18 @@ static void render_streamlines(void)
void render_flowvis(void)
{
int i, j, idx, DIM;
- double px,py;
+ double px, py, pz;
fftw_real wn, hn;
struct color4f color;
- fftw_real *field;
+ fftw_real *frame, *height;
DIM = fluids_get_dim();
wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width
hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height
- field = smoke_get_frame();
-
+ frame = smoke_get_frame();
+ height = heightplots_get_frame();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
@@ -573,35 +573,39 @@ void render_flowvis(void)
glBegin(GL_TRIANGLE_STRIP);
i = 0;
+ idx = (j * DIM) + i;
px = wn + (fftw_real)i * wn;
py = hn + (fftw_real)j * hn;
- idx = (j * DIM) + i;
+ pz = height[idx] *heightplots_get_height();
- glColor3f(field[idx],field[idx],field[idx]);
- glVertex2f(px,py);
+ glColor3f(frame[idx],frame[idx],frame[idx]);
+ glVertex3f(px, py, pz);
for (i = 0; i < DIM - 1; i++)
{
+ idx = ((j + 1) * DIM) + i;
px = wn + (fftw_real)i * wn;
py = hn + (fftw_real)(j + 1) * hn;
- idx = ((j + 1) * DIM) + i;
- color = flowvis_get_color(field[idx]);
+ pz = height[idx] *heightplots_get_height();
+ color = flowvis_get_color(frame[idx]);
glColor4f(color.r, color.g, color.b, color.a);
- glVertex2f(px, py);
+ glVertex3f(px, py, pz);
+ idx = (j * DIM) + (i + 1);
px = wn + (fftw_real)(i + 1) * wn;
py = hn + (fftw_real)j * hn;
- idx = (j * DIM) + (i + 1);
- color = flowvis_get_color(field[idx]);
+ pz = height[idx] *heightplots_get_height();
+ color = flowvis_get_color(frame[idx]);
glColor4f(color.r, color.g, color.b, color.a);
- glVertex2f(px, py);
+ glVertex3f(px, py, pz);
}
+ idx = ((j + 1) * DIM) + (DIM - 1);
px = wn + (fftw_real)(DIM - 1) * wn;
py = hn + (fftw_real)(j + 1) * hn;
- idx = ((j + 1) * DIM) + (DIM - 1);
- color = flowvis_get_color(field[idx]);
+ pz = height[idx] *heightplots_get_height();
+ color = flowvis_get_color(frame[idx]);
glColor4f(color.r, color.g, color.b, color.a);
- glVertex2f(px, py);
+ glVertex3f(px, py, pz);
glEnd();
}
}
diff --git a/Smoke/smoke.bin b/Smoke/smoke.bin
index bb10f34..f5578cc 100755
--- a/Smoke/smoke.bin
+++ b/Smoke/smoke.bin
Binary files differ