Skip to content
Snippets Groups Projects
Select Git revision
  • b9d945938d0585a387014e4769f431c9691dcce2
  • main default protected
  • Issue#3
  • issue14_PRC
  • Issue_4
  • master
  • issue_7
  • issue_19
  • deep-learning
  • dl-onehot
  • issue12
  • count_gene
  • feature
  • issue13
  • 6-terminal-fragment-selection
  • issue_13
  • gen_transc
  • suvi
  • wrapper
19 results

setup.py

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)