#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Aug 5 15:53:16 2019 @author: pavel """ """ Qt wrapper/container class that handles all the top level events and maintains the methods necessary to use the QT signals and slots API. """ from pyqtgraph.Qt import QtCore, QtGui, QtWidgets from TubeCanvas import TubeDraw class TubeWidget(QtGui.QWidget): sigUpdate = QtCore.pyqtSignal(float, float, float) #Initializes the QT wrapper class. def __init__(self): super(TubeWidget, self).__init__() box = QtGui.QVBoxLayout(self) self.resize(500,500) self.setLayout(box) self.canvas = TubeDraw() #self.canvas.create_native() box.addWidget(self.canvas.native) self.camera = [0,0,0] self.down = False self.canvas.events.mouse_press.connect(self.on_mouse_press) self.canvas.events.mouse_release.connect(self.on_mouse_release) self.canvas.events.mouse_move.connect(self.on_mouse_move) self.canvas.events.mouse_wheel.connect(self.on_mouse_wheel) #self.show() #Handles the mouse release event def on_mouse_release(self, event): self.down=False self.sendCameraInfo() #Handles the mouse move event def on_mouse_move(self, event): if self.down: self.sendCameraInfo() #Handles the mouse press event def on_mouse_press(self, event): self.down = True n = 3 #Handles the mouse wheel event def on_mouse_wheel(self, event): self.sendCameraInfo() #controls the emit function of the QT class to send a signal to the slot #located in the other window. def sendCameraInfo(self): #self.view = self.canvas.view self.camera = self.canvas.camera #print("stuff", self.view[3, 0], self.view[3, 1], self.view[3, 2]) print("stuff", self.camera[0], self.camera[1], self.camera[2]) self.sigUpdate.emit(self.camera[0], self.camera[1], self.camera[2])