From c5ec3483d1de85dd4cc581e7c8b61ab17186dc01 Mon Sep 17 00:00:00 2001
From: Tobias Schmidt <tobias.schmidt@unibas.ch>
Date: Wed, 13 Jun 2012 11:39:55 +0200
Subject: [PATCH] allow SpaceExplorer sensitivity to be changed by +/- buttons
 (fixes BZDNG-105)

---
 modules/gui/pymod/init_spacenav.py | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/modules/gui/pymod/init_spacenav.py b/modules/gui/pymod/init_spacenav.py
index df8bf383b..5346b4ca5 100644
--- a/modules/gui/pymod/init_spacenav.py
+++ b/modules/gui/pymod/init_spacenav.py
@@ -11,17 +11,18 @@ class SpacenavControl(QtCore.QObject):
     
     self.trans = True
     self.rot = True
+    self.speed = 480.0
     
   def Changed(self, tx,ty,tz,rx,ry,rz): 
     transf = gfx.Scene().GetTransform()
     if(self.trans):
-      transf.ApplyXAxisTranslation(tx/480.0)
-      transf.ApplyYAxisTranslation(ty/480.0)
-      transf.ApplyZAxisTranslation(-tz/480.0)
+      transf.ApplyXAxisTranslation(tx/self.speed)
+      transf.ApplyYAxisTranslation(ty/self.speed)
+      transf.ApplyZAxisTranslation(-tz/self.speed)
     if(self.rot):
-      transf.ApplyXAxisRotation(rx/480.0)
-      transf.ApplyYAxisRotation(ry/480.0)
-      transf.ApplyZAxisRotation(rz/480.0) 
+      transf.ApplyXAxisRotation(rx/self.speed)
+      transf.ApplyYAxisRotation(ry/self.speed)
+      transf.ApplyZAxisRotation(rz/self.speed)
     gfx.Scene().SetTransform(transf)
     gfx.Scene().RequestRedraw()
 
@@ -32,6 +33,16 @@ class SpacenavControl(QtCore.QObject):
     elif button == 1:
       self.rot = not self.rot
       print "Rotation Enabled:",self.rot
+    elif button == 12:
+      if self.speed > 20:
+        self.speed *= 0.8
+        print "Speed Increased:",self.speed
+    elif button == 13:
+      self.speed /= 0.8
+      print "Speed Reduced:",self.speed
+    else:
+      print "other:",button
+
       
 def _InitSpaceNav(app):
   try:
@@ -40,4 +51,4 @@ def _InitSpaceNav(app):
     parent = app.gl_win.qobject
     SpacenavControl(spnav,parent)
   except AttributeError:
-    pass
\ No newline at end of file
+    pass
-- 
GitLab