-
Notifications
You must be signed in to change notification settings - Fork 0
/
mp_MenuCallbacks.py
executable file
·110 lines (77 loc) · 4.18 KB
/
mp_MenuCallbacks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/python
'''
Drop menu callback handlers for mrMeshPy
Andre' Gouws 2017
#TODO - workaround that doesn't require the parent UI to be global - needed for drawing routines
'''
import vtk
from mp_VTKDrawing import *
debug = True
global the_parent_UI
def Ui_setupMenuBarCallbacks(parent_UI):
global the_parent_UI
the_parent_UI = parent_UI;
if debug: print('setting up menu bar callbacks')
parent_UI.actionEnableDraw.triggered.connect(cb_MenuEnableDraw)
parent_UI.actionDisableDraw.triggered.connect(cb_MenuDisableDraw)
parent_UI.actionCloseAndFill.triggered.connect(cb_MenuCloseAndFill)
parent_UI.actionStart_New_ROI.triggered.connect(startNewROI)
parent_UI.actionSend_10_bytes_TCP.triggered.connect(send10Bytes)
def testMenuMessage():
print('test message from mrMeshPy menu! - wait for it!')
global the_parent_UI
def cb_MenuEnableDraw():
global the_parent_UI
#enable draw mode
currentIndex = the_parent_UI.tabWidget.currentIndex()
the_parent_UI.vtkInstances[currentIndex]._Iren.inDrawMode = 1 #TODO
the_parent_UI.vtkInstances[currentIndex].inDrawMode = the_parent_UI.vtkInstances[currentIndex]._Iren.inDrawMode
style = vtk.vtkInteractorStyleUser()
the_parent_UI.vtkInstances[currentIndex].SetInteractorStyle(style)
the_parent_UI.statusbar.showMessage("In DRAW ROI Mode! - rotation/zoom disabled - (Menu-ROIs-Disable Draw to continue) ..")
# it has become apparent that users may start drawing a new ROI before an old one is removed.
# this can cause problems if the old temporary overlay surface is still present
# what we'll do is detect if a closed roi surface is present, and - if so - remove it.
try:
#remove the overlaid roi actor
the_parent_UI.vtkInstances[currentIndex]._Iren.ren.RemoveActor(the_parent_UI.vtkInstances[currentIndex]._Iren.roiActor)
print "Removed an exiting temporary ROI surface to start a new one."
except:
pass
def cb_MenuDisableDraw():
global the_parent_UI
#disable draw mode
currentIndex = the_parent_UI.tabWidget.currentIndex()
the_parent_UI.vtkInstances[currentIndex]._Iren.inDrawMode = 0 #TODO
the_parent_UI.vtkInstances[currentIndex].inDrawMode = the_parent_UI.vtkInstances[currentIndex]._Iren.inDrawMode
style = vtk.vtkInteractorStyleTrackballCamera()
the_parent_UI.vtkInstances[currentIndex].SetInteractorStyle(style)
the_parent_UI.statusbar.showMessage("Draw mode disabled - normal rotation/zoom resumed ..")
def cb_MenuCloseAndFill():
global the_parent_UI
currentIndex = the_parent_UI.tabWidget.currentIndex()
obj = the_parent_UI.vtkInstances[currentIndex]._Iren
obj.inDrawMode = 1 #tmp reset
drawingMakeROI(obj, None)
style = vtk.vtkInteractorStyleTrackballCamera()
the_parent_UI.vtkInstances[currentIndex].SetInteractorStyle(style)
the_parent_UI.statusbar.showMessage("Closed and filled ROI ..")
def startNewROI():
global the_parent_UI
currentIndex = the_parent_UI.tabWidget.currentIndex()
try:
#remove the overlaid roi actor
the_parent_UI.vtkInstances[currentIndex]._Iren.ren.RemoveActor(the_parent_UI.vtkInstances[currentIndex]._Iren.roiActor)
# reset all pointers to ROI data
the_parent_UI.vtkInstances[currentIndex]._Iren.inDrawMode = 0 #TODO
the_parent_UI.vtkInstances[currentIndex]._Iren.pickedPointIds = [] #place holder for picked vtk point IDs so we can track
the_parent_UI.vtkInstances[currentIndex]._Iren.pickedPointOrigValues = [] #place holder for picked vtk point IDs so we can track
the_parent_UI.vtkInstances[currentIndex]._Iren.pickedPoints = vtk.vtkPoints() #place holder for picked vtk point IDs so we can track
style = vtk.vtkInteractorStyleTrackballCamera()
the_parent_UI.vtkInstances[currentIndex].SetInteractorStyle(style)
the_parent_UI.statusbar.showMessage("Old ROI drawing removed. New ROI started - enable drawing mode to continue ...")
except:
print "Error while trying to remove an exisiting ROI actor - does one actually exist yet?"
def send10Bytes():
global the_parent_UI
the_parent_UI.TCP_server.socket.write('Ready,uint8,%i' %129860*1000)