diff options
author | Oliver Schinagl <oliver@schinagl.nl> | 2007-12-13 13:27:13 (GMT) |
---|---|---|
committer | Oliver Schinagl <oliver@schinagl.nl> | 2007-12-13 13:27:13 (GMT) |
commit | 24b088df4b8fec9e3ba988e72f8bf2c27dbed347 (patch) | |
tree | 50642145b22589af38c9954b15ae693977a9648f | |
parent | f0135d0ef75cb8172e5d77b5918f0cc60884bd59 (diff) | |
download | 2iv35-24b088df4b8fec9e3ba988e72f8bf2c27dbed347.zip 2iv35-24b088df4b8fec9e3ba988e72f8bf2c27dbed347.tar.gz 2iv35-24b088df4b8fec9e3ba988e72f8bf2c27dbed347.tar.bz2 |
mouse fix
-rw-r--r-- | Smoke/fluids.c | 56 | ||||
-rw-r--r-- | Smoke/fluids.h | 16 | ||||
-rw-r--r-- | Smoke/glut.c | 6 | ||||
-rw-r--r-- | Smoke/gtk.c | 43 | ||||
-rwxr-xr-x | Smoke/smoke.bin | bin | 591182 -> 579139 bytes |
5 files changed, 73 insertions, 48 deletions
diff --git a/Smoke/fluids.c b/Smoke/fluids.c index 332924a..bcd9684 100644 --- a/Smoke/fluids.c +++ b/Smoke/fluids.c @@ -45,11 +45,6 @@ int color_dir = 0; //use direction color-coding or not float vec_scale = 1000; //scaling of hedgehogs
int draw_smoke = 0; //draw the smoke or not
int draw_vecs = 1; //draw the vector field or not
-const int COLOR_BLACKWHITE=0; //different types of color mapping: black-and-white, rainbow, banded
-const int COLOR_RAINBOW=1;
-const int COLOR_BANDS=2;
-const int COLOR_WILRIK=3;
-const int COLOR_OLIVER=4;
int scalar_col = 0; //method for scalar coloring
int frozen = 0; //toggles on/off the animation
int olivers_color = 256;
@@ -82,6 +77,13 @@ float x_pos = 0.0f; float y_pos = 0.0f;
float z_pos = -1000.0f;
+struct color4f {
+ float r;
+ float g;
+ float b;
+ float a;
+};
+
//------ SIMULATION CODE STARTS HERE -----------------------------------------------------------------
//init_simulation: Initialize simulation data structures as a function of the grid size 'n'.
@@ -346,26 +348,46 @@ float remap(float value) }
//set_colormap: Sets three different types of colormaps
-void set_colormap(float vy, int draw_bar, float alpha)
+struct color4f set_colormap(float vy, int draw_bar, float alpha)
{
- float R,G,B;
+ float R, G, B;
+ struct color4f return_value;
if (autoscale)
{
vy = remap(vy);
}
- if (!(draw_bar))
- {
- if (vy < clamp_min) vy = clamp_min;
- if (vy > clamp_max) vy = clamp_max;
- }
+ if (!(draw_bar))
+ {
+ if (vy < clamp_min) vy = clamp_min;
+ if (vy > clamp_max) vy = clamp_max;
+ } else {
+
+ }
vy *= olivers_color;
vy = (float)(int)(vy);
vy /= olivers_color;
- if (scalar_col==COLOR_BLACKWHITE) {
+ if (scalar_col==COLOR_BLUE_GREEN_RED) {
+ if (vy < -0.1) {
+ R = G = 0;
+ vy -= -0.1;
+ vy /= 0.9;
+ B = -vy;
+ } else if (vy < 0.1) {
+ R = B = 0;
+ vy += 0.1;
+ vy /= 0.2;
+ G = vy;
+ } else {
+ vy -= 0.1;
+ vy /= 0.9;
+ R = vy;
+ G = B = 0;
+ }
+ } else if (scalar_col==COLOR_BLACKWHITE) {
R = G = B = vy;
}
else if (scalar_col==COLOR_WILRIK) {
@@ -384,6 +406,12 @@ void set_colormap(float vy, int draw_bar, float alpha) }
glColor4f(R,G,B,alpha);
+
+ return_value.r = R;
+ return_value.g = G;
+ return_value.b = B;
+ return_value.a = alpha;
+ return return_value;
}
@@ -931,7 +959,7 @@ void keyboard(unsigned char key, int x, int y) case 'a': frozen = 1-frozen; break;
case 'q': exit(0); break;
case 'r': toggle_mouse_rotate(); break;
- break;
+ default: break;
}
}
diff --git a/Smoke/fluids.h b/Smoke/fluids.h index 4c33cc1..7464e73 100644 --- a/Smoke/fluids.h +++ b/Smoke/fluids.h @@ -16,6 +16,13 @@ extern rfftwnd_plan plan_rc, plan_cr; //simulation domain discretization #define DATASET_DIVV 3 #define DATASET_DIVF 4 +#define COLOR_BLACKWHITE 0 +#define COLOR_RAINBOW 1 +#define COLOR_BANDS 2 +#define COLOR_BLUE_GREEN_RED 3 +#define COLOR_WILRIK 4 +#define COLOR_OLIVER 5 + #define MOUSE_SMOKE 0 #define MOUSE_SCALE_MIN 1 #define MOUSE_SCALE_MAX 2 @@ -42,11 +49,6 @@ extern int color_dir; //use direction color-coding or not extern float vec_scale; //scaling of hedgehogs extern int draw_smoke; //draw the smoke or not extern int draw_vecs; //draw the vector field or not -extern const int COLOR_BLACKWHITE; //different types of color mapping: black-and-white, rainbow, banded -extern const int COLOR_RAINBOW; -extern const int COLOR_BANDS; -extern const int COLOR_WILRIK; -extern const int COLOR_OLIVER; extern int scalar_col; //method for scalar coloring extern int frozen; //toggles on/off the animation extern int olivers_color; @@ -64,10 +66,6 @@ extern int glyph_scalar; extern int glyph_vector; extern int draw_options; -extern float x_rot;
-extern float y_rot;
-extern float z_rot; - void init_simulation(int n); void visualize(void); diff --git a/Smoke/glut.c b/Smoke/glut.c index 3c431f5..3aebabd 100644 --- a/Smoke/glut.c +++ b/Smoke/glut.c @@ -21,9 +21,9 @@ void do_one_simulation_step(void) //reshape: Handle window resizing (reshaping) events void reshape(int w, int h) { - glViewport(0.0f, 0.0f, (GLfloat)w, (GLfloat)h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
+ glViewport(0.0f, 0.0f, (GLfloat)w, (GLfloat)h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); gluPerspective(45.0f, (GLfloat)w / (GLfloat)h, 0.1, 5000.0f); //glOrtho(0.0, (GLdouble)w, 0.0, (GLdouble)h, -100, 100); //glFrustum(-1.0, 1.0, -1.0, 1.0, 0.1, 1000.0); diff --git a/Smoke/gtk.c b/Smoke/gtk.c index 3fd0274..681b6c8 100644 --- a/Smoke/gtk.c +++ b/Smoke/gtk.c @@ -307,14 +307,15 @@ button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer data) { - g_print ("%s: \"button_press_event\": ", gtk_widget_get_name (widget)); + +// g_print ("%s: \"button_press_event\": ", gtk_widget_get_name (widget)); if (event->button == 1) { /*** Fill in the details here. ***/ g_print ("button 1\n"); // fluids - click(1, 1, (int)event->x, (int)event->y); + click(1, (event->type == GDK_BUTTON_PRESS) ? 0 : 1, (int)event->x, (int)event->y); // endf return TRUE; @@ -701,14 +702,13 @@ GtkWidget *create_colormap_page(void) box = gtk_hbox_new(FALSE, 0); combo = gtk_combo_new(); -// gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(combo)->entry), "Aap"); - glist = g_list_append(glist, "String 1"); - glist = g_list_append(glist, "String 2"); - glist = g_list_append(glist, "String 3"); - glist = g_list_append(glist, "String 4"); + glist = g_list_append(glist, "Black & White"); + glist = g_list_append(glist, "Rainbow"); + glist = g_list_append(glist, "Bands"); + glist = g_list_append(glist, "Wilrik"); + glist = g_list_append(glist, "Oliver"); -// free(glist); gtk_combo_set_popdown_strings (GTK_COMBO (combo), glist); gtk_box_pack_start(GTK_BOX(box), combo, FALSE, TRUE, 0); @@ -948,20 +948,6 @@ create_window (GdkGLConfig *glconfig) #endif /* - * Settings button. - */ - - button = gtk_button_new_with_label("<<"); - - g_signal_connect(G_OBJECT(button), "clicked", - G_CALLBACK (show_settings), settings_notebook); - - gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); - - gtk_widget_show(button); - - - /* * Draw the options notebook */ @@ -1029,6 +1015,19 @@ create_window (GdkGLConfig *glconfig) gtk_notebook_append_page(settings_notebook, notebook_page, notebook_page_label); + /* + * Settings button. + */ + + button = gtk_button_new_with_label("<<"); + + g_signal_connect(G_OBJECT(button), "clicked", + G_CALLBACK (show_settings), settings_notebook); + + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + + gtk_widget_show(button); + return window; } diff --git a/Smoke/smoke.bin b/Smoke/smoke.bin Binary files differindex 22a3447..f8021c1 100755 --- a/Smoke/smoke.bin +++ b/Smoke/smoke.bin |