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.
Changed)
13 QtCore.QObject.connect(spnav,QtCore.SIGNAL(
"deviceButtonPressed(int)"), self.
Toggle)
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.
speed
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"))
53 ost.LogVerbose(
"SpaceNav: rotation %s"%(self.
rot and "enabled" or "disabled"))
57 ost.LogVerbose(
"SpaceNav: speed increased to "+str(self.
speed))
60 ost.LogVerbose(
"SpaceNav: speed reduced to "+str(self.
speed))
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