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 | 385 | # it is necessary to update internal dictionary |
386 | 386 | # that maps bitmap given item index |
387 | 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 | 400 | if new_dict: |
400 | 401 | if index == self.current_index: |
... | ... | @@ -713,9 +714,9 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
713 | 714 | # that maps bitmap given item index |
714 | 715 | selected_items = self.GetSelected() |
715 | 716 | old_dict = self.surface_list_index |
716 | - new_dict = {} | |
717 | 717 | if selected_items: |
718 | 718 | for index in selected_items: |
719 | + new_dict = {} | |
719 | 720 | self.DeleteItem(index) |
720 | 721 | for i in old_dict: |
721 | 722 | if i < index: |
... | ... | @@ -959,27 +960,22 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
959 | 960 | # that maps bitmap given item index |
960 | 961 | selected_items = self.GetSelected() |
961 | 962 | selected_items.sort(reverse=True) |
962 | - print "selected_items", selected_items | |
963 | + | |
963 | 964 | old_dict = self._list_index |
964 | - new_dict = {} | |
965 | - print " self._list_index before", self._list_index | |
966 | 965 | if selected_items: |
967 | 966 | for index in selected_items: |
968 | - print "----- index", index | |
967 | + new_dict = {} | |
969 | 968 | self.DeleteItem(index) |
970 | - print "----- old_dict before", old_dict | |
971 | 969 | for i in old_dict: |
972 | 970 | if i < index: |
973 | 971 | new_dict[i] = old_dict[i] |
974 | 972 | if i > index: |
975 | 973 | new_dict[i-1] = old_dict[i] |
976 | 974 | old_dict = new_dict |
977 | - print "----- old_dict after", old_dict | |
978 | 975 | self._list_index = new_dict |
979 | 976 | ps.Publisher().sendMessage('Remove measurements', selected_items) |
980 | 977 | else: |
981 | 978 | dlg.MeasureSelectionRequiredForRemoval() |
982 | - print " self._list_index after", self._list_index | |
983 | 979 | |
984 | 980 | |
985 | 981 | def OnCloseProject(self, pubsub_evt): | ... | ... |
invesalius/project.py
... | ... | @@ -149,13 +149,9 @@ class Project(object): |
149 | 149 | |
150 | 150 | |
151 | 151 | def AddMeasurement(self, measurement): |
152 | - print "--- proj: AddMeasurement", measurement.index | |
153 | 152 | index = len(self.measurement_dict) |
154 | 153 | measurement.index = index |
155 | - print " index:", index | |
156 | - print " dict before:", self.measurement_dict | |
157 | 154 | self.measurement_dict[index] = measurement |
158 | - print " dict after:", self.measurement_dict | |
159 | 155 | return index |
160 | 156 | |
161 | 157 | def ChangeMeasurement(self, measurement): |
... | ... | @@ -163,7 +159,6 @@ class Project(object): |
163 | 159 | self.measurement_dict[index] = measurement |
164 | 160 | |
165 | 161 | def RemoveMeasurement(self, index): |
166 | - print "--- proj: RemoveMeasurement", index | |
167 | 162 | new_dict = {} |
168 | 163 | for i in self.measurement_dict: |
169 | 164 | if i < index: | ... | ... |