From dc3edb075e04adabec5f322ea57c2c61028bce8f Mon Sep 17 00:00:00 2001 From: Thiago Franco de Moraes Date: Fri, 8 Jul 2016 14:07:00 -0300 Subject: [PATCH] Improvements --- invesalius/data/measures.py | 35 +++++++++++++++++++++++++++++++++++ invesalius/data/styles.py | 36 ++++++++++-------------------------- invesalius/gui/data_notebook.py | 2 ++ 3 files changed, 47 insertions(+), 26 deletions(-) diff --git a/invesalius/data/measures.py b/invesalius/data/measures.py index 5a06f1f..0f052ed 100644 --- a/invesalius/data/measures.py +++ b/invesalius/data/measures.py @@ -98,6 +98,7 @@ class MeasurementManager(object): Publisher.subscribe(self._load_measurements, "Load measurement dict") Publisher.subscribe(self._rm_incomplete_measurements, "Remove incomplete measurements") + Publisher.subscribe(self._change_measure_point_pos, 'Change measurement point position') def _load_measurements(self, pubsub_evt): try: @@ -246,6 +247,40 @@ class MeasurementManager(object): value)) self.current = None + def _change_measure_point_pos(self, pubsub_evt): + index, npoint, pos = pubsub_evt.data + print index, npoint, pos + m, mr = self.measures[index] + x, y, z = pos + if npoint == 0: + mr.SetPoint1(x, y, z) + m.points[0] = x, y, z + elif npoint == 1: + mr.SetPoint2(x, y, z) + m.points[1] = x, y, z + elif npoint == 2: + mr.SetPoint3(x, y, z) + m.points[2] = x, y, z + + m.value = mr.GetValue() + + name = m.name + colour = m.colour + m.value = mr.GetValue() + type_ = TYPE[m.type] + location = LOCATION[m.location] + + if m.type == const.LINEAR: + value = u"%.2f mm"% m.value + else: + value = u"%.2f°"% m.value + + Publisher.sendMessage('Update measurement info in GUI', + (index, name, colour, + location, + type_, + value)) + def _change_name(self, pubsub_evt): index, new_name = pubsub_evt.data self.measures[index].name = new_name diff --git a/invesalius/data/styles.py b/invesalius/data/styles.py index f8d2967..ce3d54c 100644 --- a/invesalius/data/styles.py +++ b/invesalius/data/styles.py @@ -394,36 +394,19 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): def OnReleaseMeasurePoint(self, obj, evt): if self.selected: - print "Changing Position" n, m, mr = self.selected x, y, z = self._get_pos_clicked() - ren = self.slice_data.renderer - mr.renderer = ren - if n == 0: - mr.SetPoint1(x, y, z) - m.points[0] = x, y, z - elif n == 1: - mr.SetPoint2(x, y, z) - m.points[1] = x, y, z - - m.value = mr.GetValue() - + idx = self.measures._list_measures.index((m, mr)) + Publisher.sendMessage('Change measurement point position', (idx, n, (x, y, z))) Publisher.sendMessage('Reload actual slice %s' % self.orientation) self.selected = None def OnMoveMeasurePoint(self, obj, evt): if self.selected: - print "Changing Position" n, m, mr = self.selected x, y, z = self._get_pos_clicked() - ren = self.slice_data.renderer - mr.renderer = ren - if n == 0: - mr.SetPoint1(x, y, z) - m.points[0] = x, y, z - elif n == 1: - mr.SetPoint2(x, y, z) - m.points[1] = x, y, z + idx = self.measures._list_measures.index((m, mr)) + Publisher.sendMessage('Change measurement point position', (idx, n, (x, y, z))) Publisher.sendMessage('Reload actual slice %s' % self.orientation) @@ -452,11 +435,12 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): if slice_number in self.measures.measures[self._ori]: for m, mr in self.measures.measures[self._ori][slice_number]: - for n, p in enumerate(m.points): - px, py, pz = p - dist = ((px-x)**2 + (py-y)**2 + (pz-z)**2)**0.5 - if dist < max_dist: - return (n, m, mr) + if mr.IsComplete(): + for n, p in enumerate(m.points): + px, py, pz = p + dist = ((px-x)**2 + (py-y)**2 + (pz-z)**2)**0.5 + if dist < max_dist: + return (n, m, mr) return None class AngularMeasureInteractorStyle(DefaultInteractorStyle): diff --git a/invesalius/gui/data_notebook.py b/invesalius/gui/data_notebook.py index ba95e97..2c17910 100644 --- a/invesalius/gui/data_notebook.py +++ b/invesalius/gui/data_notebook.py @@ -1127,6 +1127,8 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): self.UpdateItemInfo(index, name, colour, location, type_, value) else: self.InsertNewItem(index, name, colour, location, type_, value) + else: + self.UpdateItemInfo(index, name, colour, location, type_, value) -- libgit2 0.21.2