3 from PyQt5
import QtCore
6 from ost
import gfx, gui
11 QtCore.QObject.__init__(self, parent)
12 QtCore.QObject.connect(spnav,QtCore.SIGNAL(
"deviceTransformed(int,int,int,int,int,int)"), self.
ChangedChanged)
13 QtCore.QObject.connect(spnav,QtCore.SIGNAL(
"deviceButtonPressed(int)"), self.
ToggleToggle)
25 rr=r/abs(r)*max(0.0,abs(r)-0.9)
27 return rr/abs(rr)*(math.pow(1.01,abs(rr))-1.0)*40.0/self.
speedspeed
30 tf.ApplyXAxisTranslation(d(tx))
31 tf.ApplyYAxisTranslation(d(ty))
34 delta=currz*math.pow(1.01,d(tz))-currz;
35 tf.ApplyZAxisTranslation(delta);
37 scene.SetNearFar(scene.near-delta,scene.far-delta);
39 tf.ApplyXAxisRotation(d(rx))
40 tf.ApplyYAxisRotation(d(ry))
41 tf.ApplyZAxisRotation(d(rz))
49 ost.LogVerbose(
"SpaceNav: translation %s" % (self.strans
and "enabled" or "disabled"))
51 self.
rotrot =
not self.
rotrot
53 ost.LogVerbose(
"SpaceNav: rotation %s"%(self.
rotrot
and "enabled" or "disabled"))
55 if self.
speedspeed > 20:
56 self.
speedspeed *= 0.8
57 ost.LogVerbose(
"SpaceNav: speed increased to "+str(self.
speedspeed))
59 self.
speedspeed /= 0.8
60 ost.LogVerbose(
"SpaceNav: speed reduced to "+str(self.
speedspeed))
62 ost.LogVerbose(
"SpaceNav: unmapped button press ["+str(button)+
"]")
65 def _InitSpaceNav(app):
67 spnav = gui.SpnavInput.GetQThread()
70 parent = app.gl_win.qobject
72 ost.LogInfo(
"SpaceNav: device found and connected")
74 ost.LogInfo(
"SpaceNav: no device found, or could not connect to device socket")
76 ost.LogInfo(
"SpaceNav: caught exception during initialization: %s"%(traceback.format_exc()))
main class for organization and root for the graphical display
def Changed(self, tx, ty, tz, rx, ry, rz)
def __init__(self, spnav, parent=None)