aboutsummaryrefslogtreecommitdiff
path: root/boltzgas/visualizer.py
diff options
context:
space:
mode:
Diffstat (limited to 'boltzgas/visualizer.py')
-rw-r--r--boltzgas/visualizer.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/boltzgas/visualizer.py b/boltzgas/visualizer.py
index 44cec7a..373a181 100644
--- a/boltzgas/visualizer.py
+++ b/boltzgas/visualizer.py
@@ -57,12 +57,15 @@ def make_timer():
return on_timer
-def make_keyboard_handler(controller):
+def make_keyboard_handler(controller, view):
def on_keyboard(key, x, y):
- if controller.isRunning():
- controller.pause()
- else:
- controller.run()
+ if key == b' ':
+ if controller.isRunning():
+ controller.pause()
+ else:
+ controller.run()
+ if key == b'h':
+ view.show_histogram = not view.show_histogram
return on_keyboard
@@ -88,7 +91,9 @@ def simulate(config, gas, instruments, decorations, windows, updates_per_frame =
glutDisplayFunc(make_display_handler(controller, view))
glutReshapeFunc(make_reshape_handler(view))
glutTimerFunc(20, make_timer(), 20)
- glutKeyboardFunc(make_keyboard_handler(controller))
+ glutKeyboardFunc(make_keyboard_handler(controller, view))
glutCloseFunc(make_close_handler(controller))
+ glutMouseFunc(lambda *args: list(map(lambda m: m.on_mouse(*args), view.mouse_monitors)))
+ glutMotionFunc(lambda *args: list(map(lambda m: m.on_mouse_move(*args), view.mouse_monitors)))
glutMainLoop()