本文整理汇总了Python中navigation.Navigation.slide方法的典型用法代码示例。如果您正苦于以下问题:Python Navigation.slide方法的具体用法?Python Navigation.slide怎么用?Python Navigation.slide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类navigation.Navigation
的用法示例。
在下文中一共展示了Navigation.slide方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GLWidget
# 需要导入模块: from navigation import Navigation [as 别名]
# 或者: from navigation.Navigation import slide [as 别名]
#.........这里部分代码省略.........
def paintGL(self):
tx, ty = self.nav.get_translation()
sx, sy = self.nav.get_scale()
self.dataDisplay.transform(tx, ty, sx, sy)
self.dataDisplay.paint()
# handle window resizing
def resizeGL(self, w, h):
self.w, self.h = w, h
self.dataDisplay.resize(w, h)
def focusInEvent(self):
pass
def focusOutEvent(self):
self.keyReleaseEvent(None)
def navigateEvent(self):
self.updateGL()
def mousePressEvent(self, event):
x, y = self.ncoord(event.pos())
self.navInterface.mousePress(x, y, event.button())
def mouseReleaseEvent(self, event):
self.navInterface.mouseRelease()
def mouseMoveEvent(self, event):
x, y = self.ncoord(event.pos())
self.navInterface.mouseMove(x, y)
self.parent.statusbar.showMessage("%g, %g" % self.getMousePosition(x, y))
if self.navInterface.mouseButton:
SIGNALS.navigateSignal.emit()
def getMousePosition(self, x, y):
"""
convert mouse coordinates => data coordinates
"""
tx, ty = self.nav.get_translation(False)
sx, sy = self.nav.get_scale()
# x = .5 * (1. - 1./sx) - tx + x/sx# + self.nav.offsetx
# y = .5 * (1. - 1./sy) - ty + y/sy
x, y = self.nav.get_data_coordinates(x, y)
# inverse data normalization
xmin, xmax, ymin, ymax = self.dataDisplay.get_bounds()
x = xmin + x * (xmax - xmin)
y = ymin + y * (ymax - ymin)
y = -y
return x, y
def wheelEvent(self, event):
self.navInterface.mouseWheel(event.delta())
SIGNALS.navigateSignal.emit()
def keyPressEvent(self, e):
key = ""
if e.key() == QtCore.Qt.Key_Control:
key = KEY_CTRL
if e.key() == QtCore.Qt.Key_Shift:
key = KEY_SHIFT
if e.key() == QtCore.Qt.Key_Alt:
key = KEY_ALT
if e.key() == QtCore.Qt.Key_Up:
key = KEY_UP
if e.key() == QtCore.Qt.Key_Down:
key = KEY_DOWN
if e.key() == QtCore.Qt.Key_Left:
key = KEY_LEFT
if e.key() == QtCore.Qt.Key_Right:
key = KEY_RIGHT
self.navInterface.keyPress(key)
SIGNALS.navigateSignal.emit()
def keyReleaseEvent(self, e):
self.navInterface.keyRelease()
# PUBLIC METHODS
def slide(self, x, max):
# slide, and update only if the transform is not null
if (self.nav.slide(x, max)):
self.updateGL()
def reset(self):
self.nav.reset()
SIGNALS.navigateSignal.emit()
def load_data(self, data, databounds=None, options=None):
self.dataDisplay.load(data, databounds, options=options)
# reload if already initialized
if self.isInitialized:
self.dataDisplay.bind_data_buffer()
self.updateGL()
def capture(self):
glReadBuffer(GL_FRONT)
image = self.grabFrameBuffer()
return image