Commit 0087de43c87cc570a74b0c9f1a1dfb110cb5ca6b

Authored by tfmoraes
1 parent 3b2da4e1

ENH: Using PropPicker instead of PointPicker in measures

invesalius/data/measures.py
... ... @@ -38,14 +38,14 @@ class CirclePointRepresentation(object):
38 38 sphere.SetCenter(x, y, z)
39 39 sphere.SetRadius(self.radius)
40 40  
41   - c = vtk.vtkCoordinate()
42   - c.SetCoordinateSystemToWorld()
  41 +# c = vtk.vtkCoordinate()
  42 +# c.SetCoordinateSystemToWorld()
43 43  
44   - m = vtk.vtkPolyDataMapper2D()
  44 + m = vtk.vtkPolyDataMapper()
45 45 m.SetInputConnection(sphere.GetOutputPort())
46   - m.SetTransformCoordinate(c)
  46 +# m.SetTransformCoordinate(c)
47 47  
48   - a = vtk.vtkActor2D()
  48 + a = vtk.vtkActor()
49 49 a.SetMapper(m)
50 50 a.GetProperty().SetColor(self.colour)
51 51  
... ...
invesalius/data/viewer_volume.py
... ... @@ -91,8 +91,8 @@ class Viewer(wx.Panel):
91 91  
92 92 self.points_reference = []
93 93  
94   - self.measure_picker = vtk.vtkPointPicker()
95   - self.measure_picker.SetTolerance(0.005)
  94 + self.measure_picker = vtk.vtkPropPicker()
  95 + #self.measure_picker.SetTolerance(0.005)
96 96 self.measures = []
97 97  
98 98  
... ... @@ -299,6 +299,10 @@ class Viewer(wx.Panel):
299 299 const.STATE_MEASURE_DISTANCE:
300 300 {
301 301 "LeftButtonPressEvent": self.OnInsertLinearMeasurePoint
  302 + },
  303 + const.STATE_ANGULAR_MEASURE:
  304 + {
  305 + "LeftButtonPressEvent": self.OnInsertAngularMeasurePoint
302 306 }
303 307 }
304 308  
... ... @@ -312,7 +316,8 @@ class Viewer(wx.Panel):
312 316 self.text.Hide()
313 317 self.interactor.Render()
314 318  
315   - if state == const.STATE_MEASURE_DISTANCE:
  319 + if state in (const.STATE_MEASURE_DISTANCE,
  320 + const.STATE_MEASURE_ANGLE):
316 321 self.interactor.SetPicker(self.measure_picker)
317 322  
318 323 if (state == const.STATE_ZOOM_SL):
... ... @@ -610,17 +615,20 @@ class Viewer(wx.Panel):
610 615 x,y = self.interactor.GetEventPosition()
611 616 self.measure_picker.Pick(x, y, 0, self.ren)
612 617 x, y, z = self.measure_picker.GetPickPosition()
613   - if self.measure_picker.GetPointId() != -1:
614   - if not self.measures or self.measures[-1].point_actor2:
615   - m = measures.LinearMeasure(self.ren)
616   - m.SetPoint1(x, y, z)
617   - self.measures.append(m)
618   - else:
619   - m = self.measures[-1]
620   - m.SetPoint2(x, y, z)
621   - ps.Publisher().sendMessage("Add measure to list",
622   - ("3D", _("%.3f mm3" % m.GetValue())))
623   - self.interactor.Render()
  618 +# if self.measure_picker.GetPointId() != -1:
  619 + if not self.measures or self.measures[-1].point_actor2:
  620 + m = measures.LinearMeasure(self.ren)
  621 + m.SetPoint1(x, y, z)
  622 + self.measures.append(m)
  623 + else:
  624 + m = self.measures[-1]
  625 + m.SetPoint2(x, y, z)
  626 + ps.Publisher().sendMessage("Add measure to list",
  627 + ("3D", _("%.3f mm3" % m.GetValue())))
  628 + self.interactor.Render()
  629 +
  630 + def OnInsertAngularMeasurePoint(self, obj, evt):
  631 + print "Hey, you inserted a angular point"
624 632  
625 633  
626 634 class SlicePlane:
... ...
invesalius/gui/task_tools.py
... ... @@ -121,12 +121,12 @@ class InnerTaskPanel(wx.Panel):
121 121 print "TODO: Send Signal - Add text annotation (both 2d and 3d)"
122 122  
123 123 def OnLinkLinearMeasure(self):
124   - #print "TODO: Send Signal - Add linear measure (both 2d and 3d)"
125 124 ps.Publisher().sendMessage('Enable style',
126   - constants.STATE_LINEAR_MEASURE)
  125 + constants.STATE_MEASURE_DISTANCE)
127 126  
128 127 def OnLinkAngularMeasure(self):
129   - print "TODO: Send Signal - Add angular measure (both 2d and 3d)"
  128 + ps.Publisher().sendMessage('Enable style',
  129 + constants.STATE_MEASURE_ANGLE)
130 130  
131 131 def OnButton(self, evt):
132 132 id = evt.GetId()
... ...