Compare View
Commits (3)
Showing
4 changed files
Show diff stats
invesalius/data/viewer_slice.py
... | ... | @@ -1049,7 +1049,6 @@ class Viewer(wx.Panel): |
1049 | 1049 | #self.scroll.Bind(wx.EVT_SCROLL_ENDSCROLL, self.OnScrollBarRelease) |
1050 | 1050 | self.interactor.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) |
1051 | 1051 | self.interactor.Bind(wx.EVT_RIGHT_UP, self.OnContextMenu) |
1052 | - self.interactor.Bind(wx.EVT_SIZE, self.OnSize) | |
1053 | 1052 | |
1054 | 1053 | def LoadImagedata(self, mask_dict): |
1055 | 1054 | self.SetInput(mask_dict) |
... | ... | @@ -1433,15 +1432,6 @@ class Viewer(wx.Panel): |
1433 | 1432 | self.scroll.SetThumbPosition(pos) |
1434 | 1433 | self.OnScrollBar() |
1435 | 1434 | |
1436 | - def OnSize(self, evt): | |
1437 | - print("OnSize") | |
1438 | - w, h = self.GetSize() | |
1439 | - rwin = self.interactor.GetRenderWindow() | |
1440 | - rwin.SetSize(w, h) | |
1441 | - # if self.slice_data: | |
1442 | - # self.slice_data.SetSize((w, h)) | |
1443 | - # evt.Skip() | |
1444 | - | |
1445 | 1435 | def OnSetMIPSize(self, number_slices): |
1446 | 1436 | self.number_slices = number_slices |
1447 | 1437 | self.ReloadActualSlice() | ... | ... |
invesalius/net/neuronavigation_api.py
... | ... | @@ -28,20 +28,26 @@ class NeuronavigationApi(metaclass=Singleton): |
28 | 28 | An API used internally in InVesalius to communicate with the |
29 | 29 | outside world. |
30 | 30 | |
31 | - When something noteworthy happens when running InVesalius, e.g., | |
32 | - the coil is moved during neuronavigation, an object created from | |
33 | - this class can be used to update that information. | |
31 | + When an event of one of several types happens while running InVesalius, e.g., | |
32 | + the coil is moved during neuronavigation, this class is used to update the | |
33 | + information conveyed by the event. | |
34 | 34 | |
35 | 35 | When created for the first time, takes a connection object obtained |
36 | 36 | from outside InVesalius (see the main entrypoint in app.py). |
37 | 37 | |
38 | - If connection object is not given or it is None, skip doing the updates. | |
38 | + The owner of the connection object can update the state of InVesalius by implementing | |
39 | + functions to set callbacks, used then to communicate the new state to InVesalius (see, | |
40 | + e.g., set_callback__set_markers below). | |
41 | + | |
42 | + If connection object is not given or it is None, do not do the updates. | |
39 | 43 | """ |
40 | 44 | N_VERTICES_IN_POLYGON = 3 |
41 | 45 | |
42 | 46 | def __init__(self, connection=None): |
43 | 47 | if connection is not None: |
44 | - assert self._hasmethod(connection, 'update_coil_pose') | |
48 | + self.assert_valid(connection) | |
49 | + | |
50 | + self.__set_callbacks(connection) | |
45 | 51 | self.__bind_events() |
46 | 52 | |
47 | 53 | self.connection = connection |
... | ... | @@ -49,9 +55,16 @@ class NeuronavigationApi(metaclass=Singleton): |
49 | 55 | def _hasmethod(self, obj, name): |
50 | 56 | return hasattr(obj, name) and callable(getattr(obj, name)) |
51 | 57 | |
58 | + def assert_valid(self, connection): | |
59 | + assert self._hasmethod(connection, 'update_coil_pose') | |
60 | + assert self._hasmethod(connection, 'update_focus') | |
61 | + assert self._hasmethod(connection, 'set_callback__set_markers') | |
62 | + | |
52 | 63 | def __bind_events(self): |
53 | 64 | Publisher.subscribe(self.update_focus, 'Set cross focal point') |
54 | 65 | |
66 | + # Functions for InVesalius to send updates. | |
67 | + | |
55 | 68 | # TODO: Not the cleanest API; for an example of a better API, see update_coil_pose |
56 | 69 | # below, for which position and orientation are sent separately. Changing this |
57 | 70 | # would require changing 'Set cross focal point' publishers and subscribers |
... | ... | @@ -96,3 +109,11 @@ class NeuronavigationApi(metaclass=Singleton): |
96 | 109 | points=points, |
97 | 110 | polygons=polygons, |
98 | 111 | ) |
112 | + | |
113 | + # Functions for InVesalius to receive updates via callbacks. | |
114 | + | |
115 | + def __set_callbacks(self, connection): | |
116 | + connection.set_callback__set_markers(self.set_markers) | |
117 | + | |
118 | + def set_markers(self, markers): | |
119 | + Publisher.sendMessage('Set markers', markers=markers) | ... | ... |
requirements.txt
1 | -Cython==0.29.24 | |
2 | -Pillow==9.0.1 | |
1 | +Cython==0.29.28 | |
2 | +Pillow==9.1.0 | |
3 | 3 | Pypubsub==4.0.3 |
4 | 4 | configparser==5.0.1 |
5 | 5 | h5py==2.10.0 |
6 | 6 | imageio==2.9.0 |
7 | 7 | nibabel==3.2.1 |
8 | -numpy==1.21.2 | |
8 | +numpy==1.22.1 | |
9 | 9 | plaidml-keras==0.7.0 |
10 | 10 | psutil==5.8.0 |
11 | 11 | pyserial==3.5 |
12 | -python-gdcm==3.0.9.1 | |
13 | -scikit-image==0.18.3 | |
14 | -scipy==1.7.1 | |
15 | -vtk==9.0.3 | |
12 | +python-gdcm==3.0.12 | |
13 | +scikit-image==0.19.1 | |
14 | +scipy==1.7.3 | |
15 | +vtk==9.1.0 | |
16 | 16 | wxPython==4.1.1 |
17 | 17 | Theano==1.0.5 |
18 | -torch==1.9.1 | |
18 | +torch==1.11.0 | |
19 | 19 | pyacvd==0.2.7 | ... | ... |
requirements_m1.txt
1 | -Cython==0.29.24 | |
2 | -Pillow==9.0.0 | |
1 | +Cython==0.29.28 | |
2 | +Pillow==9.1.0 | |
3 | 3 | Pypubsub==4.0.3 |
4 | 4 | configparser==5.0.1 |
5 | 5 | h5py==3.6.0 |
... | ... | @@ -8,10 +8,10 @@ nibabel==3.2.1 |
8 | 8 | numpy==1.22.1 |
9 | 9 | psutil==5.8.0 |
10 | 10 | pyserial==3.5 |
11 | -python-gdcm==3.0.9.1 | |
11 | +python-gdcm==3.0.12 | |
12 | 12 | scikit-image==0.19.1 |
13 | 13 | scipy==1.7.3 |
14 | -vtk==9.0.3 | |
14 | +vtk==9.1.0 | |
15 | 15 | wxPython==4.1.1 |
16 | -torch==1.10.0 | |
16 | +torch==1.11.0 | |
17 | 17 | pyacvd==0.2.7 | ... | ... |