Commit e74c70282a18335c69654c2195791a1bbcc40649
1 parent
c281f9ee
Exists in
master
and in
6 other branches
FIX: Measurements removal
Showing
2 changed files
with
14 additions
and
23 deletions
Show diff stats
invesalius/gui/data_notebook.py
@@ -385,16 +385,17 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -385,16 +385,17 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
385 | # it is necessary to update internal dictionary | 385 | # it is necessary to update internal dictionary |
386 | # that maps bitmap given item index | 386 | # that maps bitmap given item index |
387 | old_dict = self.mask_list_index | 387 | old_dict = self.mask_list_index |
388 | - new_dict = {} | ||
389 | - for index in selected_items: | ||
390 | - self.DeleteItem(index) | ||
391 | - for i in old_dict: | ||
392 | - if i < index: | ||
393 | - new_dict[i] = old_dict[i] | ||
394 | - if i > index: | ||
395 | - new_dict[i-1] = old_dict[i] | ||
396 | - old_dict = new_dict | ||
397 | - self.mask_list_index = new_dict | 388 | + if selected_items: |
389 | + for index in selected_items: | ||
390 | + new_dict = {} | ||
391 | + self.DeleteItem(index) | ||
392 | + for i in old_dict: | ||
393 | + if i < index: | ||
394 | + new_dict[i] = old_dict[i] | ||
395 | + if i > index: | ||
396 | + new_dict[i-1] = old_dict[i] | ||
397 | + old_dict = new_dict | ||
398 | + self.mask_list_index = new_dict | ||
398 | 399 | ||
399 | if new_dict: | 400 | if new_dict: |
400 | if index == self.current_index: | 401 | if index == self.current_index: |
@@ -713,9 +714,9 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -713,9 +714,9 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
713 | # that maps bitmap given item index | 714 | # that maps bitmap given item index |
714 | selected_items = self.GetSelected() | 715 | selected_items = self.GetSelected() |
715 | old_dict = self.surface_list_index | 716 | old_dict = self.surface_list_index |
716 | - new_dict = {} | ||
717 | if selected_items: | 717 | if selected_items: |
718 | for index in selected_items: | 718 | for index in selected_items: |
719 | + new_dict = {} | ||
719 | self.DeleteItem(index) | 720 | self.DeleteItem(index) |
720 | for i in old_dict: | 721 | for i in old_dict: |
721 | if i < index: | 722 | if i < index: |
@@ -959,27 +960,22 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -959,27 +960,22 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
959 | # that maps bitmap given item index | 960 | # that maps bitmap given item index |
960 | selected_items = self.GetSelected() | 961 | selected_items = self.GetSelected() |
961 | selected_items.sort(reverse=True) | 962 | selected_items.sort(reverse=True) |
962 | - print "selected_items", selected_items | 963 | + |
963 | old_dict = self._list_index | 964 | old_dict = self._list_index |
964 | - new_dict = {} | ||
965 | - print " self._list_index before", self._list_index | ||
966 | if selected_items: | 965 | if selected_items: |
967 | for index in selected_items: | 966 | for index in selected_items: |
968 | - print "----- index", index | 967 | + new_dict = {} |
969 | self.DeleteItem(index) | 968 | self.DeleteItem(index) |
970 | - print "----- old_dict before", old_dict | ||
971 | for i in old_dict: | 969 | for i in old_dict: |
972 | if i < index: | 970 | if i < index: |
973 | new_dict[i] = old_dict[i] | 971 | new_dict[i] = old_dict[i] |
974 | if i > index: | 972 | if i > index: |
975 | new_dict[i-1] = old_dict[i] | 973 | new_dict[i-1] = old_dict[i] |
976 | old_dict = new_dict | 974 | old_dict = new_dict |
977 | - print "----- old_dict after", old_dict | ||
978 | self._list_index = new_dict | 975 | self._list_index = new_dict |
979 | ps.Publisher().sendMessage('Remove measurements', selected_items) | 976 | ps.Publisher().sendMessage('Remove measurements', selected_items) |
980 | else: | 977 | else: |
981 | dlg.MeasureSelectionRequiredForRemoval() | 978 | dlg.MeasureSelectionRequiredForRemoval() |
982 | - print " self._list_index after", self._list_index | ||
983 | 979 | ||
984 | 980 | ||
985 | def OnCloseProject(self, pubsub_evt): | 981 | def OnCloseProject(self, pubsub_evt): |
invesalius/project.py
@@ -149,13 +149,9 @@ class Project(object): | @@ -149,13 +149,9 @@ class Project(object): | ||
149 | 149 | ||
150 | 150 | ||
151 | def AddMeasurement(self, measurement): | 151 | def AddMeasurement(self, measurement): |
152 | - print "--- proj: AddMeasurement", measurement.index | ||
153 | index = len(self.measurement_dict) | 152 | index = len(self.measurement_dict) |
154 | measurement.index = index | 153 | measurement.index = index |
155 | - print " index:", index | ||
156 | - print " dict before:", self.measurement_dict | ||
157 | self.measurement_dict[index] = measurement | 154 | self.measurement_dict[index] = measurement |
158 | - print " dict after:", self.measurement_dict | ||
159 | return index | 155 | return index |
160 | 156 | ||
161 | def ChangeMeasurement(self, measurement): | 157 | def ChangeMeasurement(self, measurement): |
@@ -163,7 +159,6 @@ class Project(object): | @@ -163,7 +159,6 @@ class Project(object): | ||
163 | self.measurement_dict[index] = measurement | 159 | self.measurement_dict[index] = measurement |
164 | 160 | ||
165 | def RemoveMeasurement(self, index): | 161 | def RemoveMeasurement(self, index): |
166 | - print "--- proj: RemoveMeasurement", index | ||
167 | new_dict = {} | 162 | new_dict = {} |
168 | for i in self.measurement_dict: | 163 | for i in self.measurement_dict: |
169 | if i < index: | 164 | if i < index: |