Commit 155529ac7c40cec2867d63ff31f12fa85ab80679
1 parent
2b56e41f
Exists in
master
and in
26 other branches
Removing incomplete measurements from the data_notebook
Showing
3 changed files
with
33 additions
and
7 deletions
Show diff stats
invesalius/data/measures.py
| @@ -320,22 +320,24 @@ class MeasurementManager(object): | @@ -320,22 +320,24 @@ class MeasurementManager(object): | ||
| 320 | if self.current is None: | 320 | if self.current is None: |
| 321 | return | 321 | return |
| 322 | 322 | ||
| 323 | - mr = self.current[1] | ||
| 324 | - print "RM INC M", self.current, mr.IsComplete() | 323 | + m, mr = self.current |
| 325 | if not mr.IsComplete(): | 324 | if not mr.IsComplete(): |
| 326 | print "---To REMOVE" | 325 | print "---To REMOVE" |
| 327 | - self.measures.pop() | 326 | + idx = self.measures._list_measures.index((m, mr)) |
| 327 | + self.measures.remove((m, mr)) | ||
| 328 | + Publisher.sendMessage("Remove GUI measurement", idx) | ||
| 328 | actors = mr.GetActors() | 329 | actors = mr.GetActors() |
| 329 | slice_number = self.current[0].slice_number | 330 | slice_number = self.current[0].slice_number |
| 330 | - Publisher.sendMessage(('Remove actors ' + str(self.current[0].location)), | ||
| 331 | - (actors, slice_number)) | 331 | + if m.location == const.SURFACE: |
| 332 | + Publisher.sendMessage(('Remove actors ' + str(self.current[0].location)), | ||
| 333 | + (actors, slice_number)) | ||
| 332 | if self.current[0].location == const.SURFACE: | 334 | if self.current[0].location == const.SURFACE: |
| 333 | Publisher.sendMessage('Render volume viewer') | 335 | Publisher.sendMessage('Render volume viewer') |
| 334 | else: | 336 | else: |
| 335 | Publisher.sendMessage('Update slice viewer') | 337 | Publisher.sendMessage('Update slice viewer') |
| 336 | 338 | ||
| 337 | - if self.measures: | ||
| 338 | - self.measures.pop() | 339 | + # if self.measures: |
| 340 | + # self.measures.pop() | ||
| 339 | self.current = None | 341 | self.current = None |
| 340 | 342 | ||
| 341 | 343 |
invesalius/data/styles.py
| @@ -381,6 +381,7 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | @@ -381,6 +381,7 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | ||
| 381 | self.AddObserver("LeftButtonPressEvent", self.OnInsertMeasurePoint) | 381 | self.AddObserver("LeftButtonPressEvent", self.OnInsertMeasurePoint) |
| 382 | self.AddObserver("LeftButtonReleaseEvent", self.OnReleaseMeasurePoint) | 382 | self.AddObserver("LeftButtonReleaseEvent", self.OnReleaseMeasurePoint) |
| 383 | self.AddObserver("MouseMoveEvent", self.OnMoveMeasurePoint) | 383 | self.AddObserver("MouseMoveEvent", self.OnMoveMeasurePoint) |
| 384 | + self.AddObserver("LeaveEvent", self.OnLeaveMeasureInteractor) | ||
| 384 | 385 | ||
| 385 | def OnInsertMeasurePoint(self, obj, evt): | 386 | def OnInsertMeasurePoint(self, obj, evt): |
| 386 | slice_number = self.slice_data.number | 387 | slice_number = self.slice_data.number |
| @@ -457,6 +458,15 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | @@ -457,6 +458,15 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | ||
| 457 | else: | 458 | else: |
| 458 | self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) | 459 | self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) |
| 459 | 460 | ||
| 461 | + def OnLeaveMeasureInteractor(self, obj, evt): | ||
| 462 | + if self.creating or self.selected: | ||
| 463 | + n, m, mr = self.creating | ||
| 464 | + if not mr.IsComplete(): | ||
| 465 | + Publisher.sendMessage("Remove incomplete measurements") | ||
| 466 | + self.creating = None | ||
| 467 | + self.selected = None | ||
| 468 | + Publisher.sendMessage('Update slice viewer') | ||
| 469 | + | ||
| 460 | def CleanUp(self): | 470 | def CleanUp(self): |
| 461 | self.picker.PickFromListOff() | 471 | self.picker.PickFromListOff() |
| 462 | Publisher.sendMessage("Remove incomplete measurements") | 472 | Publisher.sendMessage("Remove incomplete measurements") |
invesalius/gui/data_notebook.py
| @@ -943,6 +943,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -943,6 +943,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
| 943 | Publisher.subscribe(self.OnShowSingle, 'Show single measurement') | 943 | Publisher.subscribe(self.OnShowSingle, 'Show single measurement') |
| 944 | Publisher.subscribe(self.OnShowMultiple, 'Show multiple measurements') | 944 | Publisher.subscribe(self.OnShowMultiple, 'Show multiple measurements') |
| 945 | Publisher.subscribe(self.OnLoadData, 'Load measurement dict') | 945 | Publisher.subscribe(self.OnLoadData, 'Load measurement dict') |
| 946 | + Publisher.subscribe(self.OnRemoveGUIMeasure, 'Remove GUI measurement') | ||
| 946 | 947 | ||
| 947 | def __bind_events_wx(self): | 948 | def __bind_events_wx(self): |
| 948 | self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) | 949 | self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) |
| @@ -959,6 +960,19 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -959,6 +960,19 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
| 959 | elif (keycode == wx.WXK_DELETE): | 960 | elif (keycode == wx.WXK_DELETE): |
| 960 | self.RemoveMeasurements() | 961 | self.RemoveMeasurements() |
| 961 | 962 | ||
| 963 | + def OnRemoveGUIMeasure(self, pubsub_evt): | ||
| 964 | + idx = pubsub_evt.data | ||
| 965 | + self.DeleteItem(idx) | ||
| 966 | + | ||
| 967 | + old_dict = self._list_index | ||
| 968 | + new_dict = {} | ||
| 969 | + j = 0 | ||
| 970 | + for i in old_dict: | ||
| 971 | + if i != idx: | ||
| 972 | + new_dict[j] = old_dict[i] | ||
| 973 | + j+=1 | ||
| 974 | + self._list_index = new_dict | ||
| 975 | + | ||
| 962 | def RemoveMeasurements(self): | 976 | def RemoveMeasurements(self): |
| 963 | """ | 977 | """ |
| 964 | Remove items selected. | 978 | Remove items selected. |