Skip to content
Snippets Groups Projects
Select Git revision
  • e9384a9fc95b88ede3de997a0fb03729bb864cc5
  • master default protected
  • develop protected
  • cmake_boost_refactor
  • ubuntu_ci
  • mmtf
  • non-orthogonal-maps
  • no_boost_filesystem
  • data_viewer
  • 2.11.1
  • 2.11.0
  • 2.10.0
  • 2.9.3
  • 2.9.2
  • 2.9.1
  • 2.9.0
  • 2.8.0
  • 2.7.0
  • 2.6.1
  • 2.6.0
  • 2.6.0-rc4
  • 2.6.0-rc3
  • 2.6.0-rc2
  • 2.6.0-rc
  • 2.5.0
  • 2.5.0-rc2
  • 2.5.0-rc
  • 2.4.0
  • 2.4.0-rc2
29 results

widget_pool.cc

Blame
  • spacenav_connect.py 1.38 KiB
    from PyQt4 import QtCore, QtGui
    
    from ost import geom, gfx, gui
    
    import sys, random
    import sip
    
    class SpnavWidget(QtCore.QObject):
      def __init__(self, spnav,
                   parent=None):
        QtCore.QObject.__init__(self, parent)
        QtCore.QObject.connect(spnav,QtCore.SIGNAL("deviceTransformed(int,int,int,int,int,int)"), self.Changed)
        QtCore.QObject.connect(spnav,QtCore.SIGNAL("deviceButtonPressed(int)"), self.Toggle)     
        
        self.e=io.LoadEntity("../entity/sdh.pdb")
        self.go=gfx.Entity("sdh",self.e)
        scene.Add(self.go)
        self.trans = True
        self.rot = True
      def Changed(self, tx,ty,tz,rx,ry,rz): 
        transf = self.go.GetTF()
        if(self.trans):
          transf.ApplyXAxisTranslation(tx/480.0)
          transf.ApplyYAxisTranslation(ty/480.0)
          transf.ApplyZAxisTranslation(-tz/480.0)
        if(self.rot):
          transf.ApplyXAxisRotation(rx/480.0)
          transf.ApplyYAxisRotation(ry/480.0)
          transf.ApplyZAxisRotation(rz/480.0) 
        self.go.SetTF(transf)
        gfx.Scene().RequestRedraw()
    
      def Toggle(self, button):
        if button == 0:
          self.trans = not self.trans
          print "Translation Enabled:",self.trans
        elif button == 1:
          self.rot = not self.rot
          print "Rotation Enabled:",self.rot
          
    app=gui.GostyApp.Instance()
    
    spnav = gui.SpnavInput.GetQThread()
    spnav.start()
    pts=SpnavWidget(spnav)
    gfx.Scene().AutoAutoslab(False)
    gfx.Scene().SetNearFar(1,10000)