diff --git a/invesalius/data/measures.py b/invesalius/data/measures.py index 5c0b410..8637aff 100644 --- a/invesalius/data/measures.py +++ b/invesalius/data/measures.py @@ -38,14 +38,14 @@ class CirclePointRepresentation(object): sphere.SetCenter(x, y, z) sphere.SetRadius(self.radius) - c = vtk.vtkCoordinate() - c.SetCoordinateSystemToWorld() +# c = vtk.vtkCoordinate() +# c.SetCoordinateSystemToWorld() - m = vtk.vtkPolyDataMapper2D() + m = vtk.vtkPolyDataMapper() m.SetInputConnection(sphere.GetOutputPort()) - m.SetTransformCoordinate(c) +# m.SetTransformCoordinate(c) - a = vtk.vtkActor2D() + a = vtk.vtkActor() a.SetMapper(m) a.GetProperty().SetColor(self.colour) diff --git a/invesalius/data/viewer_volume.py b/invesalius/data/viewer_volume.py index dcf2b28..06be475 100755 --- a/invesalius/data/viewer_volume.py +++ b/invesalius/data/viewer_volume.py @@ -91,8 +91,8 @@ class Viewer(wx.Panel): self.points_reference = [] - self.measure_picker = vtk.vtkPointPicker() - self.measure_picker.SetTolerance(0.005) + self.measure_picker = vtk.vtkPropPicker() + #self.measure_picker.SetTolerance(0.005) self.measures = [] @@ -299,6 +299,10 @@ class Viewer(wx.Panel): const.STATE_MEASURE_DISTANCE: { "LeftButtonPressEvent": self.OnInsertLinearMeasurePoint + }, + const.STATE_ANGULAR_MEASURE: + { + "LeftButtonPressEvent": self.OnInsertAngularMeasurePoint } } @@ -312,7 +316,8 @@ class Viewer(wx.Panel): self.text.Hide() self.interactor.Render() - if state == const.STATE_MEASURE_DISTANCE: + if state in (const.STATE_MEASURE_DISTANCE, + const.STATE_MEASURE_ANGLE): self.interactor.SetPicker(self.measure_picker) if (state == const.STATE_ZOOM_SL): @@ -610,17 +615,20 @@ class Viewer(wx.Panel): 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_actor2: - m = measures.LinearMeasure(self.ren) - m.SetPoint1(x, y, z) - self.measures.append(m) - else: - m = self.measures[-1] - m.SetPoint2(x, y, z) - ps.Publisher().sendMessage("Add measure to list", - ("3D", _("%.3f mm3" % m.GetValue()))) - self.interactor.Render() +# if self.measure_picker.GetPointId() != -1: + if not self.measures or self.measures[-1].point_actor2: + m = measures.LinearMeasure(self.ren) + m.SetPoint1(x, y, z) + self.measures.append(m) + else: + m = self.measures[-1] + m.SetPoint2(x, y, z) + ps.Publisher().sendMessage("Add measure to list", + ("3D", _("%.3f mm3" % m.GetValue()))) + self.interactor.Render() + + def OnInsertAngularMeasurePoint(self, obj, evt): + print "Hey, you inserted a angular point" class SlicePlane: diff --git a/invesalius/gui/task_tools.py b/invesalius/gui/task_tools.py index 573fd8f..b596790 100644 --- a/invesalius/gui/task_tools.py +++ b/invesalius/gui/task_tools.py @@ -121,12 +121,12 @@ class InnerTaskPanel(wx.Panel): print "TODO: Send Signal - Add text annotation (both 2d and 3d)" def OnLinkLinearMeasure(self): - #print "TODO: Send Signal - Add linear measure (both 2d and 3d)" ps.Publisher().sendMessage('Enable style', - constants.STATE_LINEAR_MEASURE) + constants.STATE_MEASURE_DISTANCE) def OnLinkAngularMeasure(self): - print "TODO: Send Signal - Add angular measure (both 2d and 3d)" + ps.Publisher().sendMessage('Enable style', + constants.STATE_MEASURE_ANGLE) def OnButton(self, evt): id = evt.GetId() -- libgit2 0.21.2