summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2008-01-03 17:04:42 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2008-01-03 17:04:42 (GMT)
commit909340f9a5299194c582f9224f21f4f4daf56e51 (patch)
tree987fdc136590a23ad59ad984a2c47798bade24a0
parent8edd0c2ad477886571fe1d75219d5ca17255fdf0 (diff)
download2iv35-909340f9a5299194c582f9224f21f4f4daf56e51.zip
2iv35-909340f9a5299194c582f9224f21f4f4daf56e51.tar.gz
2iv35-909340f9a5299194c582f9224f21f4f4daf56e51.tar.bz2
cleanup and fixes
-rw-r--r--Smoke/colormap.c55
-rw-r--r--Smoke/colormap.h3
-rw-r--r--Smoke/fluids.c2
-rw-r--r--Smoke/gtk_colormap.c49
-rw-r--r--Smoke/interact.c1
-rw-r--r--Smoke/renderer_gl.c2
-rwxr-xr-xSmoke/smoke.binbin623769 -> 626039 bytes
7 files changed, 83 insertions, 29 deletions
diff --git a/Smoke/colormap.c b/Smoke/colormap.c
index 12b6f4b..392bbac 100644
--- a/Smoke/colormap.c
+++ b/Smoke/colormap.c
@@ -7,6 +7,7 @@
#include <rfftw.h>
+#include "fluids.h"
#include "funcs.h"
#include "palette.h"
@@ -32,6 +33,8 @@ static float colormap_clamp_min = 0.0f;
static float colormap_clamp_max = 0.9999f;
+static int colormap_autoscaling = FALSE;
+
static fftw_real *colormap_frame;
@@ -138,21 +141,14 @@ float colormap_get_clamp_max(void)
return colormap_clamp_max;
}
-
-static float remap(float value)
+void colormap_set_autoscaling(int autoscaling)
{
- value -= colormap_scale_min;
- value /= (colormap_scale_max - colormap_scale_min);
-
- return value;
+ colormap_autoscaling = autoscaling;
}
-static float clamp(float value)
+int colormap_get_autoscaling(void)
{
- if (value < colormap_clamp_min) value = colormap_clamp_min;
- if (value > colormap_clamp_max) value = colormap_clamp_max;
-
- return value;
+ return colormap_autoscaling;
}
void colormap_set_frame(fftw_real *frame)
@@ -166,6 +162,43 @@ fftw_real *colormap_get_frame(void)
}
+
+void colormap_autoscale(void)
+{
+ if (colormap_autoscaling) {
+ int k;
+ float value, scale_min, scale_max;
+
+ scale_min = scale_max = get_dataset(0);
+ colormap_scale_min = scale_min;
+ colormap_scale_max = scale_max;
+
+ for (k = 1; k < DIM * DIM; k++)
+ {
+ value = get_dataset(k);
+
+ if (scale_min > value) { colormap_scale_min = value; }
+ if (scale_max < value) { colormap_scale_max = value; }
+ }
+ }
+}
+
+static float remap(float value)
+{
+ value -= colormap_scale_min;
+ value /= (colormap_scale_max - colormap_scale_min);
+
+ return value;
+}
+
+static float clamp(float value)
+{
+ if (value < colormap_clamp_min) value = colormap_clamp_min;
+ if (value > colormap_clamp_max) value = colormap_clamp_max;
+
+ return value;
+}
+
struct color4f colormap_get_color(float value)
{
struct color4f return_value;
diff --git a/Smoke/colormap.h b/Smoke/colormap.h
index fdcfee6..70f7a72 100644
--- a/Smoke/colormap.h
+++ b/Smoke/colormap.h
@@ -30,6 +30,9 @@ float colormap_get_clamp_min(void);
void colormap_set_clamp_max(float max_clamp);
float colormap_get_clamp_max(void);
+void colormap_set_autoscaling(int autoscaling);
+int colormap_get_autoscaling(void);
+
void colormap_set_frame(fftw_real *frame);
fftw_real *colormap_get_frame(void);
diff --git a/Smoke/fluids.c b/Smoke/fluids.c
index 46c7a2b..6ea63d8 100644
--- a/Smoke/fluids.c
+++ b/Smoke/fluids.c
@@ -17,6 +17,7 @@
#include "funcs.h"
#include "fluids.h"
+#include "colormap.h"
//--- SIMULATION PARAMETERS ------------------------------------------------------------------------
const int DIM = 50; //size of simulation grid
@@ -321,6 +322,7 @@ void calculate_one_simulation_step(fftw_real *field)
calculate_height_plot();
calculate_normal_vectors();
copy_frame(field, rho);
+ colormap_autoscale();
}
}
diff --git a/Smoke/gtk_colormap.c b/Smoke/gtk_colormap.c
index 24639b4..878d81f 100644
--- a/Smoke/gtk_colormap.c
+++ b/Smoke/gtk_colormap.c
@@ -23,14 +23,14 @@ static gboolean select_num_colors(GtkRange *adjustment, gpointer data)
return TRUE;
}
-static gboolean set_scaling(GtkWidget *button, gpointer data) {
- colormap_set_scaling(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
+static gboolean set_scaling(GtkToggleButton *button, gpointer data) {
+ colormap_set_scaling(gtk_toggle_button_get_active(button));
return TRUE;
}
-static gboolean set_clamping(GtkWidget *button, gpointer data) {
- colormap_set_clamping(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
+static gboolean set_clamping(GtkToggleButton *button, gpointer data) {
+ colormap_set_clamping(gtk_toggle_button_get_active(button));
return TRUE;
}
@@ -42,6 +42,12 @@ static gboolean select_alpha(GtkRange *adjustment, gpointer data)
return TRUE;
}
+static gboolean set_autoscaling(GtkToggleButton *button, gpointer data) {
+ colormap_set_autoscaling(gtk_toggle_button_get_active(button));
+
+ return TRUE;
+}
+
GtkWidget *create_colormap_page(void)
{
@@ -49,7 +55,7 @@ GtkWidget *create_colormap_page(void)
*/
GtkWidget *page;
GtkWidget *frame;
- GtkWidget *box;
+ GtkWidget *box, *box2;
GtkWidget *label;
GtkWidget *button;
GtkWidget *combo;
@@ -62,17 +68,28 @@ GtkWidget *create_colormap_page(void)
box = gtk_vbox_new(FALSE, 0);
- button = gtk_check_button_new_with_label("Scaling");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), colormap_get_scaling());
- g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_scaling), NULL);
- gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);
- gtk_widget_show(button);
-
- button = gtk_check_button_new_with_label("Clamping");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), colormap_get_clamping());
- g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_clamping), NULL);
- gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);
- gtk_widget_show(button);
+ box2 = gtk_hbox_new(FALSE, 0);
+
+ button = gtk_check_button_new_with_label("Scaling");
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), colormap_get_scaling());
+ g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_scaling), NULL);
+ gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
+
+ button = gtk_check_button_new_with_label("Clamping");
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), colormap_get_clamping());
+ g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_clamping), NULL);
+ 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);
+
+ 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);
+ gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
gtk_container_add(GTK_CONTAINER(frame), box);
gtk_widget_show(box);
diff --git a/Smoke/interact.c b/Smoke/interact.c
index 3e450a0..64f6f36 100644
--- a/Smoke/interact.c
+++ b/Smoke/interact.c
@@ -110,6 +110,5 @@ void drag(int mx, int my)
default:
break;
}
- printf("mouse: %f\n", (float)mx /winWidth);
}
}
diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c
index 41f8f22..bafc0e3 100644
--- a/Smoke/renderer_gl.c
+++ b/Smoke/renderer_gl.c
@@ -41,7 +41,7 @@
#define LEGEND_X_POS -298.0f
#define LEGEND_Y_POS -295.0f
-#define LEGEND_Z_POS -720.0f
+#define LEGEND_Z_POS -735.0f
float x_pos = DEFAULT_X_POS;
float y_pos = DEFAULT_Y_POS;
diff --git a/Smoke/smoke.bin b/Smoke/smoke.bin
index c4fe03f..90abf7d 100755
--- a/Smoke/smoke.bin
+++ b/Smoke/smoke.bin
Binary files differ