From 6f2555dece0b2bd677e30bff78b14f523f25f364 Mon Sep 17 00:00:00 2001 From: tatiana Date: Mon, 8 Mar 2010 11:37:29 +0000 Subject: [PATCH] FIX: Measure removal / viewer slice render problem --- invesalius/data/measures.py | 5 ++++- invesalius/data/viewer_slice.py | 17 +++++++++++------ invesalius/gui/data_notebook.py | 6 ++---- invesalius/gui/dialogs.py | 18 +++++++++--------- invesalius/project.py | 8 ++++++++ 5 files changed, 34 insertions(+), 20 deletions(-) diff --git a/invesalius/data/measures.py b/invesalius/data/measures.py index ceb3013..7acda97 100644 --- a/invesalius/data/measures.py +++ b/invesalius/data/measures.py @@ -104,13 +104,16 @@ class MeasurementManager(object): self.current = (m, mr) + mr = self.current[1] + m = self.current[0] + x, y, z = position actors = mr.AddPoint(x, y, z) m.points.append(position) ps.Publisher().sendMessage(("Add actors", location), (actors, m.slice_number)) - if self.mr.IsComplete(): + if mr.IsComplete(): index = prj.Project().AddMeasurement(m) #m.index = index # already done in proj self.measures.append(self.current) diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index 28b6481..a51ab67 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -1495,9 +1495,14 @@ class Viewer(wx.Panel): def RemoveActors(self, pubsub_evt): "Remove a list of actors" actors, n = pubsub_evt.data - renderer = self.renderers_by_slice_number[n] - for actor in actors: - # Remove the actor from the renderer - renderer.RemoveActor(actor) - # and remove the actor from the actor's list - self.actors_by_slice_number[n].remove(actor) + try: + renderer = self.renderers_by_slice_number[n] + except KeyError: + for actor in actors: + self.actors_by_slice_number[n].remove(actor) + else: + for actor in actors: + # Remove the actor from the renderer + renderer.RemoveActor(actor) + # and remove the actor from the actor's list + self.actors_by_slice_number[n].remove(actor) diff --git a/invesalius/gui/data_notebook.py b/invesalius/gui/data_notebook.py index 8ef39dc..85f7aff 100644 --- a/invesalius/gui/data_notebook.py +++ b/invesalius/gui/data_notebook.py @@ -501,7 +501,6 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): if key != index: self.SetItemImage(key, 0) self.current_index = index - def AddMask(self, pubsub_evt): index, mask_name, threshold_range, colour = pubsub_evt.data @@ -1088,9 +1087,9 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): type = TYPE[m.type] location = LOCATION[m.location] if m.type == const.LINEAR: - value = "%.2f mm" % m.value + value = (u"%.2f mm") % m.value else: - value = "%.2f˚" % m.value + value = (u"%.2f˚") % m.value self.InsertNewItem(m.index, m.name, colour, type, location, value) @@ -1103,7 +1102,6 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): type_ = pubsub_evt.data[4] value = pubsub_evt.data[5] - if index not in self._list_index: image = self.CreateColourBitmap(colour) image_index = self.imagelist.Add(image) diff --git a/invesalius/gui/dialogs.py b/invesalius/gui/dialogs.py index 7bc299f..af98734 100644 --- a/invesalius/gui/dialogs.py +++ b/invesalius/gui/dialogs.py @@ -613,15 +613,15 @@ def ShowAboutDialog(parent): "Paulo Henrique Junqueira Amorim", "Thiago Franco de Moraes"] - info.Translators = ["Alex P. Natsios (EL)", - "Andreas Loupasakis (EL)", - "Cheng-Chia Tseng (ZH)", - "Dimitris Glezos (EL)", - "Eugene Liscio (EN)", - u"Frédéric Lopez (FR)", - "J. Javier de Lima Moreno (ES)" - "Nikos Korkakakis (EL)", - "Sebastian Hilbert (DE)"] + info.Translators = ["Alex P. Natsios", + "Andreas Loupasakis", + "Cheng-Chia Tseng", + "Dimitris Glezos", + "Eugene Liscio", + u"Frédéric Lopez", + "Javier de Lima Moreno" + "Nikos Korkakakis", + "Sebastian Hilbert"] info.DocWriters = ["Fabio Francisco da Silva (PT)"] diff --git a/invesalius/project.py b/invesalius/project.py index bc565ac..d3e10eb 100755 --- a/invesalius/project.py +++ b/invesalius/project.py @@ -149,8 +149,13 @@ class Project(object): def AddMeasurement(self, measurement): + print "--- proj: AddMeasurement", measurement.index index = len(self.measurement_dict) + measurement.index = index + print " index:", index + print " dict before:", self.measurement_dict self.measurement_dict[index] = measurement + print " dict after:", self.measurement_dict return index def ChangeMeasurement(self, measurement): @@ -158,6 +163,7 @@ class Project(object): self.measurement_dict[index] = measurement def RemoveMeasurement(self, index): + print "--- proj: RemoveMeasurement", index new_dict = {} for i in self.measurement_dict: if i < index: @@ -165,7 +171,9 @@ class Project(object): if i > index: new_dict[i-1] = self.measurement_dict[i] new_dict[i-1].index = i-1 + print " dict before:", self.measurement_dict self.measurement_dict = new_dict + print " dict after:", self.measurement_dict def SetAcquisitionModality(self, type_=None): -- libgit2 0.21.2