Commit 6f2555dece0b2bd677e30bff78b14f523f25f364
1 parent
afd317a1
Exists in
master
and in
68 other branches
FIX: Measure removal / viewer slice render problem
Showing
5 changed files
with
34 additions
and
20 deletions
Show diff stats
invesalius/data/measures.py
| @@ -104,13 +104,16 @@ class MeasurementManager(object): | @@ -104,13 +104,16 @@ class MeasurementManager(object): | ||
| 104 | 104 | ||
| 105 | self.current = (m, mr) | 105 | self.current = (m, mr) |
| 106 | 106 | ||
| 107 | + mr = self.current[1] | ||
| 108 | + m = self.current[0] | ||
| 109 | + | ||
| 107 | x, y, z = position | 110 | x, y, z = position |
| 108 | actors = mr.AddPoint(x, y, z) | 111 | actors = mr.AddPoint(x, y, z) |
| 109 | m.points.append(position) | 112 | m.points.append(position) |
| 110 | ps.Publisher().sendMessage(("Add actors", location), | 113 | ps.Publisher().sendMessage(("Add actors", location), |
| 111 | (actors, m.slice_number)) | 114 | (actors, m.slice_number)) |
| 112 | 115 | ||
| 113 | - if self.mr.IsComplete(): | 116 | + if mr.IsComplete(): |
| 114 | index = prj.Project().AddMeasurement(m) | 117 | index = prj.Project().AddMeasurement(m) |
| 115 | #m.index = index # already done in proj | 118 | #m.index = index # already done in proj |
| 116 | self.measures.append(self.current) | 119 | self.measures.append(self.current) |
invesalius/data/viewer_slice.py
| @@ -1495,9 +1495,14 @@ class Viewer(wx.Panel): | @@ -1495,9 +1495,14 @@ class Viewer(wx.Panel): | ||
| 1495 | def RemoveActors(self, pubsub_evt): | 1495 | def RemoveActors(self, pubsub_evt): |
| 1496 | "Remove a list of actors" | 1496 | "Remove a list of actors" |
| 1497 | actors, n = pubsub_evt.data | 1497 | actors, n = pubsub_evt.data |
| 1498 | - renderer = self.renderers_by_slice_number[n] | ||
| 1499 | - for actor in actors: | ||
| 1500 | - # Remove the actor from the renderer | ||
| 1501 | - renderer.RemoveActor(actor) | ||
| 1502 | - # and remove the actor from the actor's list | ||
| 1503 | - self.actors_by_slice_number[n].remove(actor) | 1498 | + try: |
| 1499 | + renderer = self.renderers_by_slice_number[n] | ||
| 1500 | + except KeyError: | ||
| 1501 | + for actor in actors: | ||
| 1502 | + self.actors_by_slice_number[n].remove(actor) | ||
| 1503 | + else: | ||
| 1504 | + for actor in actors: | ||
| 1505 | + # Remove the actor from the renderer | ||
| 1506 | + renderer.RemoveActor(actor) | ||
| 1507 | + # and remove the actor from the actor's list | ||
| 1508 | + self.actors_by_slice_number[n].remove(actor) |
invesalius/gui/data_notebook.py
| @@ -501,7 +501,6 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -501,7 +501,6 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
| 501 | if key != index: | 501 | if key != index: |
| 502 | self.SetItemImage(key, 0) | 502 | self.SetItemImage(key, 0) |
| 503 | self.current_index = index | 503 | self.current_index = index |
| 504 | - | ||
| 505 | 504 | ||
| 506 | def AddMask(self, pubsub_evt): | 505 | def AddMask(self, pubsub_evt): |
| 507 | index, mask_name, threshold_range, colour = pubsub_evt.data | 506 | index, mask_name, threshold_range, colour = pubsub_evt.data |
| @@ -1088,9 +1087,9 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -1088,9 +1087,9 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
| 1088 | type = TYPE[m.type] | 1087 | type = TYPE[m.type] |
| 1089 | location = LOCATION[m.location] | 1088 | location = LOCATION[m.location] |
| 1090 | if m.type == const.LINEAR: | 1089 | if m.type == const.LINEAR: |
| 1091 | - value = "%.2f mm" % m.value | 1090 | + value = (u"%.2f mm") % m.value |
| 1092 | else: | 1091 | else: |
| 1093 | - value = "%.2f˚" % m.value | 1092 | + value = (u"%.2f˚") % m.value |
| 1094 | self.InsertNewItem(m.index, m.name, colour, type, location, value) | 1093 | self.InsertNewItem(m.index, m.name, colour, type, location, value) |
| 1095 | 1094 | ||
| 1096 | 1095 | ||
| @@ -1103,7 +1102,6 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -1103,7 +1102,6 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
| 1103 | type_ = pubsub_evt.data[4] | 1102 | type_ = pubsub_evt.data[4] |
| 1104 | value = pubsub_evt.data[5] | 1103 | value = pubsub_evt.data[5] |
| 1105 | 1104 | ||
| 1106 | - | ||
| 1107 | if index not in self._list_index: | 1105 | if index not in self._list_index: |
| 1108 | image = self.CreateColourBitmap(colour) | 1106 | image = self.CreateColourBitmap(colour) |
| 1109 | image_index = self.imagelist.Add(image) | 1107 | image_index = self.imagelist.Add(image) |
invesalius/gui/dialogs.py
| @@ -613,15 +613,15 @@ def ShowAboutDialog(parent): | @@ -613,15 +613,15 @@ def ShowAboutDialog(parent): | ||
| 613 | "Paulo Henrique Junqueira Amorim", | 613 | "Paulo Henrique Junqueira Amorim", |
| 614 | "Thiago Franco de Moraes"] | 614 | "Thiago Franco de Moraes"] |
| 615 | 615 | ||
| 616 | - info.Translators = ["Alex P. Natsios (EL)", | ||
| 617 | - "Andreas Loupasakis (EL)", | ||
| 618 | - "Cheng-Chia Tseng (ZH)", | ||
| 619 | - "Dimitris Glezos (EL)", | ||
| 620 | - "Eugene Liscio (EN)", | ||
| 621 | - u"Frédéric Lopez (FR)", | ||
| 622 | - "J. Javier de Lima Moreno (ES)" | ||
| 623 | - "Nikos Korkakakis (EL)", | ||
| 624 | - "Sebastian Hilbert (DE)"] | 616 | + info.Translators = ["Alex P. Natsios", |
| 617 | + "Andreas Loupasakis", | ||
| 618 | + "Cheng-Chia Tseng", | ||
| 619 | + "Dimitris Glezos", | ||
| 620 | + "Eugene Liscio", | ||
| 621 | + u"Frédéric Lopez", | ||
| 622 | + "Javier de Lima Moreno" | ||
| 623 | + "Nikos Korkakakis", | ||
| 624 | + "Sebastian Hilbert"] | ||
| 625 | 625 | ||
| 626 | info.DocWriters = ["Fabio Francisco da Silva (PT)"] | 626 | info.DocWriters = ["Fabio Francisco da Silva (PT)"] |
| 627 | 627 |
invesalius/project.py
| @@ -149,8 +149,13 @@ class Project(object): | @@ -149,8 +149,13 @@ class Project(object): | ||
| 149 | 149 | ||
| 150 | 150 | ||
| 151 | def AddMeasurement(self, measurement): | 151 | def AddMeasurement(self, measurement): |
| 152 | + print "--- proj: AddMeasurement", measurement.index | ||
| 152 | index = len(self.measurement_dict) | 153 | index = len(self.measurement_dict) |
| 154 | + measurement.index = index | ||
| 155 | + print " index:", index | ||
| 156 | + print " dict before:", self.measurement_dict | ||
| 153 | self.measurement_dict[index] = measurement | 157 | self.measurement_dict[index] = measurement |
| 158 | + print " dict after:", self.measurement_dict | ||
| 154 | return index | 159 | return index |
| 155 | 160 | ||
| 156 | def ChangeMeasurement(self, measurement): | 161 | def ChangeMeasurement(self, measurement): |
| @@ -158,6 +163,7 @@ class Project(object): | @@ -158,6 +163,7 @@ class Project(object): | ||
| 158 | self.measurement_dict[index] = measurement | 163 | self.measurement_dict[index] = measurement |
| 159 | 164 | ||
| 160 | def RemoveMeasurement(self, index): | 165 | def RemoveMeasurement(self, index): |
| 166 | + print "--- proj: RemoveMeasurement", index | ||
| 161 | new_dict = {} | 167 | new_dict = {} |
| 162 | for i in self.measurement_dict: | 168 | for i in self.measurement_dict: |
| 163 | if i < index: | 169 | if i < index: |
| @@ -165,7 +171,9 @@ class Project(object): | @@ -165,7 +171,9 @@ class Project(object): | ||
| 165 | if i > index: | 171 | if i > index: |
| 166 | new_dict[i-1] = self.measurement_dict[i] | 172 | new_dict[i-1] = self.measurement_dict[i] |
| 167 | new_dict[i-1].index = i-1 | 173 | new_dict[i-1].index = i-1 |
| 174 | + print " dict before:", self.measurement_dict | ||
| 168 | self.measurement_dict = new_dict | 175 | self.measurement_dict = new_dict |
| 176 | + print " dict after:", self.measurement_dict | ||
| 169 | 177 | ||
| 170 | 178 | ||
| 171 | def SetAcquisitionModality(self, type_=None): | 179 | def SetAcquisitionModality(self, type_=None): |