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 | 320 | if self.current is None: |
321 | 321 | return |
322 | 322 | |
323 | - mr = self.current[1] | |
324 | - print "RM INC M", self.current, mr.IsComplete() | |
323 | + m, mr = self.current | |
325 | 324 | if not mr.IsComplete(): |
326 | 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 | 329 | actors = mr.GetActors() |
329 | 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 | 334 | if self.current[0].location == const.SURFACE: |
333 | 335 | Publisher.sendMessage('Render volume viewer') |
334 | 336 | else: |
335 | 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 | 341 | self.current = None |
340 | 342 | |
341 | 343 | ... | ... |
invesalius/data/styles.py
... | ... | @@ -381,6 +381,7 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): |
381 | 381 | self.AddObserver("LeftButtonPressEvent", self.OnInsertMeasurePoint) |
382 | 382 | self.AddObserver("LeftButtonReleaseEvent", self.OnReleaseMeasurePoint) |
383 | 383 | self.AddObserver("MouseMoveEvent", self.OnMoveMeasurePoint) |
384 | + self.AddObserver("LeaveEvent", self.OnLeaveMeasureInteractor) | |
384 | 385 | |
385 | 386 | def OnInsertMeasurePoint(self, obj, evt): |
386 | 387 | slice_number = self.slice_data.number |
... | ... | @@ -457,6 +458,15 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): |
457 | 458 | else: |
458 | 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 | 470 | def CleanUp(self): |
461 | 471 | self.picker.PickFromListOff() |
462 | 472 | Publisher.sendMessage("Remove incomplete measurements") | ... | ... |
invesalius/gui/data_notebook.py
... | ... | @@ -943,6 +943,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
943 | 943 | Publisher.subscribe(self.OnShowSingle, 'Show single measurement') |
944 | 944 | Publisher.subscribe(self.OnShowMultiple, 'Show multiple measurements') |
945 | 945 | Publisher.subscribe(self.OnLoadData, 'Load measurement dict') |
946 | + Publisher.subscribe(self.OnRemoveGUIMeasure, 'Remove GUI measurement') | |
946 | 947 | |
947 | 948 | def __bind_events_wx(self): |
948 | 949 | self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) |
... | ... | @@ -959,6 +960,19 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
959 | 960 | elif (keycode == wx.WXK_DELETE): |
960 | 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 | 976 | def RemoveMeasurements(self): |
963 | 977 | """ |
964 | 978 | Remove items selected. | ... | ... |