Commit c281f9ee553c47f67b39f1531c89093b27289d44
1 parent
9005b9a8
Exists in
master
and in
68 other branches
FIX: Measurements removal
Showing
2 changed files
with
16 additions
and
6 deletions
Show diff stats
invesalius/gui/data_notebook.py
... | ... | @@ -954,25 +954,32 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
954 | 954 | """ |
955 | 955 | Remove items selected. |
956 | 956 | """ |
957 | + print "data_notebook: RemoveMeasurements" | |
957 | 958 | # it is necessary to update internal dictionary |
958 | 959 | # that maps bitmap given item index |
959 | 960 | selected_items = self.GetSelected() |
961 | + selected_items.sort(reverse=True) | |
962 | + print "selected_items", selected_items | |
960 | 963 | old_dict = self._list_index |
961 | 964 | new_dict = {} |
965 | + print " self._list_index before", self._list_index | |
962 | 966 | if selected_items: |
963 | 967 | for index in selected_items: |
968 | + print "----- index", index | |
964 | 969 | self.DeleteItem(index) |
970 | + print "----- old_dict before", old_dict | |
965 | 971 | for i in old_dict: |
966 | 972 | if i < index: |
967 | 973 | new_dict[i] = old_dict[i] |
968 | 974 | if i > index: |
969 | 975 | new_dict[i-1] = old_dict[i] |
970 | 976 | old_dict = new_dict |
977 | + print "----- old_dict after", old_dict | |
971 | 978 | self._list_index = new_dict |
972 | - | |
973 | 979 | ps.Publisher().sendMessage('Remove measurements', selected_items) |
974 | 980 | else: |
975 | - dlg.MeasureSelectionRequiredForRemoval() | |
981 | + dlg.MeasureSelectionRequiredForRemoval() | |
982 | + print " self._list_index after", self._list_index | |
976 | 983 | |
977 | 984 | |
978 | 985 | def OnCloseProject(self, pubsub_evt): |
... | ... | @@ -1095,14 +1102,16 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1095 | 1102 | |
1096 | 1103 | |
1097 | 1104 | def AddItem_(self, pubsub_evt): |
1105 | + print "notebook: AddItem_" | |
1106 | + print "self._list_index before:", self._list_index | |
1098 | 1107 | index = pubsub_evt.data[0] |
1108 | + print "index", index | |
1099 | 1109 | name = pubsub_evt.data[1] |
1100 | 1110 | colour = pubsub_evt.data[2] |
1101 | 1111 | location = pubsub_evt.data[3] |
1102 | 1112 | type_ = pubsub_evt.data[4] |
1103 | 1113 | value = pubsub_evt.data[5] |
1104 | 1114 | |
1105 | - | |
1106 | 1115 | if index not in self._list_index: |
1107 | 1116 | image = self.CreateColourBitmap(colour) |
1108 | 1117 | image_index = self.imagelist.Add(image) |
... | ... | @@ -1119,6 +1128,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1119 | 1128 | |
1120 | 1129 | def InsertNewItem(self, index=0, label="Measurement 1", colour=None, |
1121 | 1130 | type_="LINEAR", location="SURFACE", value="0 mm"): |
1131 | + print "InsertNewItem" | |
1122 | 1132 | self.InsertStringItem(index, "") |
1123 | 1133 | self.SetStringItem(index, 1, label, |
1124 | 1134 | imageId = self._list_index[index]) |
... | ... | @@ -1126,16 +1136,18 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1126 | 1136 | self.SetStringItem(index, 3, location) |
1127 | 1137 | self.SetStringItem(index, 4, value) |
1128 | 1138 | self.SetItemImage(index, 1) |
1139 | + self.Refresh() | |
1129 | 1140 | |
1130 | 1141 | def UpdateItemInfo(self, index=0, label="Measurement 1", colour=None, |
1131 | 1142 | type_="LINEAR", location="SURFACE", value="0 mm"): |
1143 | + print "UpdateItemInfo" | |
1132 | 1144 | self.SetStringItem(index, 1, label, |
1133 | 1145 | imageId = self._list_index[index]) |
1134 | 1146 | self.SetStringItem(index, 2, type_) |
1135 | 1147 | self.SetStringItem(index, 3, location) |
1136 | 1148 | self.SetStringItem(index, 4, value) |
1137 | 1149 | self.SetItemImage(index, 1) |
1138 | - | |
1150 | + self.Refresh() | |
1139 | 1151 | |
1140 | 1152 | def CreateColourBitmap(self, colour): |
1141 | 1153 | """ | ... | ... |
invesalius/project.py
... | ... | @@ -171,9 +171,7 @@ class Project(object): |
171 | 171 | if i > index: |
172 | 172 | new_dict[i-1] = self.measurement_dict[i] |
173 | 173 | new_dict[i-1].index = i-1 |
174 | - print " dict before:", self.measurement_dict | |
175 | 174 | self.measurement_dict = new_dict |
176 | - print " dict after:", self.measurement_dict | |
177 | 175 | |
178 | 176 | |
179 | 177 | def SetAcquisitionModality(self, type_=None): | ... | ... |