Blame view

TubeWidget.py 2.73 KB
9f9f1788   Pavel Govyadinov   clead up version ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  #!/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
  
6eb102f5   Pavel Govyadinov   Fixed issue cause...
17
18
  DEBUG = False
  
9f9f1788   Pavel Govyadinov   clead up version ...
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  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()
  
2282da38   Pavel Govyadinov   added path select...
50
      #Handles the mouse press events
9f9f1788   Pavel Govyadinov   clead up version ...
51
52
53
54
55
56
57
58
59
60
61
62
63
64
      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])
6eb102f5   Pavel Govyadinov   Fixed issue cause...
65
66
          if DEBUG:
              print("stuff", self.camera[0], self.camera[1], self.camera[2])
9f9f1788   Pavel Govyadinov   clead up version ...
67
          self.sigUpdate.emit(self.camera[0], self.camera[1], self.camera[2])
6aca1767   Pavel Govyadinov   Added a signal to...
68
69
70
71
72
73
74
          
      """
      Function to receive the signal with the information necessary to visualize
      specific fibers only. With the rest of them being minimized.
      """
      @QtCore.pyqtSlot(list)
      def select(self, x):
2282da38   Pavel Govyadinov   added path select...
75
76
77
78
79
80
          self.canvas.select_edges(x)
  #        for e in x:
  #            if e in self.canvas.edge_dict:    
  #                print(self.canvas.edge_dict[e])
  #            elif (e[1], e[0]) in self.canvas.edge_dict:
  #                print(self.canvas.edge_dict[(e[1], e[0])])
6aca1767   Pavel Govyadinov   Added a signal to...
81
          print("got signal", x)
9f9f1788   Pavel Govyadinov   clead up version ...
82
  
6aca1767   Pavel Govyadinov   Added a signal to...
83
84
85
86
87
88
      """
          Initialization method that connects the slot to the function that handles
          the information being sent.
      """
      def connect(self, signal_object):
          signal_object.select.connect(self.select)