From 58af85f1d3a3dd40de4905746be61164fa77c65d Mon Sep 17 00:00:00 2001 From: tfmoraes Date: Wed, 24 Feb 2010 14:54:24 +0000 Subject: [PATCH] ADD: Angular measures --- invesalius/constants.py | 3 ++- invesalius/data/measures.py | 9 +++++++-- invesalius/data/viewer_volume.py | 19 ++++++++++++++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/invesalius/constants.py b/invesalius/constants.py index 4f69104..152aef2 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -451,7 +451,8 @@ SLICE_STYLES = TOOL_STATES + TOOL_SLICE_STATES SLICE_STYLES.append(STATE_DEFAULT) SLICE_STYLES.append(SLICE_STATE_EDITOR) -VOLUME_STYLES = TOOL_STATES + [VOLUME_STATE_SEED, STATE_MEASURE_DISTANCE] +VOLUME_STYLES = TOOL_STATES + [VOLUME_STATE_SEED, STATE_MEASURE_DISTANCE, + STATE_MEASURE_ANGLE] VOLUME_STYLES.append(STATE_DEFAULT) diff --git a/invesalius/data/measures.py b/invesalius/data/measures.py index 8637aff..ad4d51f 100644 --- a/invesalius/data/measures.py +++ b/invesalius/data/measures.py @@ -230,6 +230,11 @@ class AngularMeasure(object): self.points[2] = (x, y, z) self.point_actor3 = self.representation.GetRepresentation(x, y, z) self.render.AddActor(self.point_actor3) + self.CreateMeasure() + + def CreateMeasure(self): + self._draw_line() + self._draw_text() def _draw_line(self): line1 = vtk.vtkLineSource() @@ -258,7 +263,7 @@ class AngularMeasure(object): a.SetMapper(m) a.GetProperty().SetColor(self.colour) self.line_actor = a - return a + self.render.AddActor(self.line_actor) def DrawArc(self): @@ -307,7 +312,7 @@ class AngularMeasure(object): a.GetPositionCoordinate().SetCoordinateSystemToWorld() a.GetPositionCoordinate().SetValue(x,y,z) self.text_actor = a - return a + self.render.AddActor(self.text_actor) def GetNumberOfPoints(self): return self.number_of_points diff --git a/invesalius/data/viewer_volume.py b/invesalius/data/viewer_volume.py index 06be475..0165034 100755 --- a/invesalius/data/viewer_volume.py +++ b/invesalius/data/viewer_volume.py @@ -300,7 +300,7 @@ class Viewer(wx.Panel): { "LeftButtonPressEvent": self.OnInsertLinearMeasurePoint }, - const.STATE_ANGULAR_MEASURE: + const.STATE_MEASURE_ANGLE: { "LeftButtonPressEvent": self.OnInsertAngularMeasurePoint } @@ -629,6 +629,23 @@ class Viewer(wx.Panel): def OnInsertAngularMeasurePoint(self, obj, evt): print "Hey, you inserted a angular point" + x,y = self.interactor.GetEventPosition() + self.measure_picker.Pick(x, y, 0, self.ren) + x, y, z = self.measure_picker.GetPickPosition() +# if self.measure_picker.GetPointId() != -1: + if not self.measures or self.measures[-1].point_actor3: + m = measures.AngularMeasure(self.ren) + m.SetPoint1(x, y, z) + self.measures.append(m) + elif not self.measures[-1].point_actor2: + m = self.measures[-1] + m.SetPoint2(x, y, z) + else: + m = self.measures[-1] + m.SetPoint3(x, y, z) + ps.Publisher().sendMessage("Add measure to list", + ("3D", _("%.3f" % m.GetValue()))) + self.interactor.Render() class SlicePlane: -- libgit2 0.21.2