Skip to content
Snippets Groups Projects
Commit 1962bc59 authored by stefan's avatar stefan
Browse files

Added shooter controls to dokk

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@1819 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent d444f4fb
No related branches found
No related tags found
No related merge requests found
...@@ -4,11 +4,16 @@ from PyQt4.QtGui import * ...@@ -4,11 +4,16 @@ from PyQt4.QtGui import *
from PyQt4.QtCore import * from PyQt4.QtCore import *
from PyQt4.QtOpenGL import * from PyQt4.QtOpenGL import *
TRANS_VAL = 20
class DokkGLCanvas(QGLWidget): class DokkGLCanvas(QGLWidget):
def __init__(self, format, parent=None): def __init__(self, format, parent=None):
QGLWidget.__init__(self, format, parent) QGLWidget.__init__(self, format, parent)
self.last_pos_=QPoint() self.last_pos_=QPoint()
self.setAutoFillBackground(False) self.setAutoFillBackground(False)
self.setAttribute(Qt.WA_KeyCompression,True)
def initializeGL(self): def initializeGL(self):
gfx.Scene().InitGL() gfx.Scene().InitGL()
...@@ -45,6 +50,32 @@ class DokkGLCanvas(QGLWidget): ...@@ -45,6 +50,32 @@ class DokkGLCanvas(QGLWidget):
False) False)
self.update() self.update()
def wheelEvent(self, event):
self.OnTransform(gfx.INPUT_COMMAND_TRANSZ,0,gfx.TRANSFORM_VIEW,
0.1*(-event.delta()))
def OnTransform(self,com, indx, trg, val):
gfx.Scene().Apply(gfx.InputEvent(gfx.INPUT_DEVICE_MOUSE,
com, indx,trg,val*0.5),False)
self.update()
def keyReleaseEvent(self, event):
if event.key() == Qt.Key_Left or event.key() == Qt.Key_A:
self.OnTransform(gfx.INPUT_COMMAND_TRANSX,0, gfx.TRANSFORM_VIEW, -TRANS_VAL)
if event.key() == Qt.Key_Right or event.key() == Qt.Key_D:
self.OnTransform(gfx.INPUT_COMMAND_TRANSX,0, gfx.TRANSFORM_VIEW, TRANS_VAL)
if event.key() == Qt.Key_Down or event.key() == Qt.Key_S:
self.OnTransform(gfx.INPUT_COMMAND_TRANSZ,0, gfx.TRANSFORM_VIEW, TRANS_VAL)
if event.key() == Qt.Key_Up or event.key() == Qt.Key_W:
self.OnTransform(gfx.INPUT_COMMAND_TRANSZ,0, gfx.TRANSFORM_VIEW, -TRANS_VAL)
if event.key() == Qt.Key_Escape:
QApplication.exit()
class DokkGLWin(gfx.GLWinBase): class DokkGLWin(gfx.GLWinBase):
def _CreateFormat(self): def _CreateFormat(self):
fmt=QGLFormat() fmt=QGLFormat()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment