summaryrefslogtreecommitdiff
path: root/src/gpudataviz.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpudataviz.cpp')
-rw-r--r--src/gpudataviz.cpp43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/gpudataviz.cpp b/src/gpudataviz.cpp
index b22864e..91ef5fa 100644
--- a/src/gpudataviz.cpp
+++ b/src/gpudataviz.cpp
@@ -281,40 +281,41 @@ bool MyGTKGLSceneWidget::do_mouse_logic(GdkEventType type, guint state, guint x,
* GDK_MOD1_MASK, ... (normally MOD1 it is the Alt key)
* GDK_SUPER_MASK, GDK_HYPER_MASK, GDK_META_MASK (extra keybord modifier keys)
*/
- // Static variables to hold previous mouse button event
- static GdkEventType prev_type = GDK_NOTHING;
- /*static guint prev_state=0; UNUSED FOR NOW */
- static guint drag_x=0, drag_y=0;
-
+ static GdkEventType prev_type = GDK_NOTHING; // Static variable to hold previous mouse button event
+ static guint drag_x=0, drag_y=0; // Static for DRAGING displacement calculus
+ static float t=0.0f; // XXX Just for playing with time
bool redraw=false; // Setting it to true will queue a redraw to the widget (invalidate)
- std::cout << "event type " << type << " state " << state << " on (" << x << "," << y << ") " << std::endl;
+ // For event filter debug (display all events)
+ //std::cout << "event type " << type << " state " << state << " on (" << x << "," << y << ") " << std::endl;
/* *** BEGIN event filtering *** */
MOUSE_DRAG_START(GDK_BUTTON2_MASK) {
drag_x=x; drag_y=y;
- //std::cout << "this->camera == {" << this->camera.rx << ", " << this->camera.ry << ", " << this->camera.tz << "}" << std::endl;
}
+ // Carmera rotation
MOUSE_DRAGING(GDK_BUTTON2_MASK) {
float mouse_sensivity = 0.2f;
gint dx = drag_x - x; // Delta movement (since last event)
gint dy = drag_y - y; // Not unsigned !
- // Yes dy for camera.rx, and -= operator
- // GTK mouse coords and Opengl are not on the same coords system
- this->camera.rx -= mouse_sensivity * dy;
- this->camera.ry -= mouse_sensivity * dx;
+ this->camera.rx -= mouse_sensivity * dy; // Camera position update
+ this->camera.ry -= mouse_sensivity * dx; // Yes dy for camera.rx, and -= operator :
+ // GTK mouse coords and OpenGL ones are not on the same coords system
drag_x = x; drag_y = y;
redraw=true;
}
+ // Camera zoom-in
MOUSE_WHEEL(GDK_SCROLL_UP, 0, 0) {
+
if (this->camera.tz + 0.5f <= -0.5f) {
this->camera.tz += 0.5f;
redraw=true;
}
}
+ // Camera zoom-out
MOUSE_WHEEL(GDK_SCROLL_DOWN, 0, 0) {
if (this->camera.tz - 0.5f >= -9.0f) {
this->camera.tz -= 0.5f;
@@ -322,10 +323,19 @@ bool MyGTKGLSceneWidget::do_mouse_logic(GdkEventType type, guint state, guint x,
}
}
+ /*
MOUSE_CLIC(GDK_BUTTON1_MASK, 0, 0) {
//TODO
this->clKit.execKernel("water1", 0.0f);
redraw=true;
+ }*/
+
+ MOUSE_DRAGING(GDK_BUTTON1_MASK) {
+ t+=0.1f;
+ std::cout << "execKernel(\"water1\", " << t << ");" << std::endl;
+ int res = this->clKit.execKernel("water1", t);
+ std::cout << " -> " << res << std::endl;
+ redraw=true;
}
@@ -341,15 +351,8 @@ bool MyGTKGLSceneWidget::do_mouse_logic(GdkEventType type, guint state, guint x,
// Previous button event retention for double-clic filtering
- switch(type) {
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- case GDK_2BUTTON_PRESS:
- prev_type=type;
-// prev_state=state;
- break;
- default:
- break;
+ if ( type == GDK_BUTTON_PRESS || type == GDK_2BUTTON_PRESS || type == GDK_BUTTON_RELEASE ) {
+ prev_type=type;
}
if ( redraw ) queue_draw();