Commit 58af85f1d3a3dd40de4905746be61164fa77c65d

Authored by tfmoraes
1 parent 347582dc

ADD: Angular measures

invesalius/constants.py
... ... @@ -451,7 +451,8 @@ SLICE_STYLES = TOOL_STATES + TOOL_SLICE_STATES
451 451 SLICE_STYLES.append(STATE_DEFAULT)
452 452 SLICE_STYLES.append(SLICE_STATE_EDITOR)
453 453  
454   -VOLUME_STYLES = TOOL_STATES + [VOLUME_STATE_SEED, STATE_MEASURE_DISTANCE]
  454 +VOLUME_STYLES = TOOL_STATES + [VOLUME_STATE_SEED, STATE_MEASURE_DISTANCE,
  455 + STATE_MEASURE_ANGLE]
455 456 VOLUME_STYLES.append(STATE_DEFAULT)
456 457  
457 458  
... ...
invesalius/data/measures.py
... ... @@ -230,6 +230,11 @@ class AngularMeasure(object):
230 230 self.points[2] = (x, y, z)
231 231 self.point_actor3 = self.representation.GetRepresentation(x, y, z)
232 232 self.render.AddActor(self.point_actor3)
  233 + self.CreateMeasure()
  234 +
  235 + def CreateMeasure(self):
  236 + self._draw_line()
  237 + self._draw_text()
233 238  
234 239 def _draw_line(self):
235 240 line1 = vtk.vtkLineSource()
... ... @@ -258,7 +263,7 @@ class AngularMeasure(object):
258 263 a.SetMapper(m)
259 264 a.GetProperty().SetColor(self.colour)
260 265 self.line_actor = a
261   - return a
  266 + self.render.AddActor(self.line_actor)
262 267  
263 268 def DrawArc(self):
264 269  
... ... @@ -307,7 +312,7 @@ class AngularMeasure(object):
307 312 a.GetPositionCoordinate().SetCoordinateSystemToWorld()
308 313 a.GetPositionCoordinate().SetValue(x,y,z)
309 314 self.text_actor = a
310   - return a
  315 + self.render.AddActor(self.text_actor)
311 316  
312 317 def GetNumberOfPoints(self):
313 318 return self.number_of_points
... ...
invesalius/data/viewer_volume.py
... ... @@ -300,7 +300,7 @@ class Viewer(wx.Panel):
300 300 {
301 301 "LeftButtonPressEvent": self.OnInsertLinearMeasurePoint
302 302 },
303   - const.STATE_ANGULAR_MEASURE:
  303 + const.STATE_MEASURE_ANGLE:
304 304 {
305 305 "LeftButtonPressEvent": self.OnInsertAngularMeasurePoint
306 306 }
... ... @@ -629,6 +629,23 @@ class Viewer(wx.Panel):
629 629  
630 630 def OnInsertAngularMeasurePoint(self, obj, evt):
631 631 print "Hey, you inserted a angular point"
  632 + x,y = self.interactor.GetEventPosition()
  633 + self.measure_picker.Pick(x, y, 0, self.ren)
  634 + x, y, z = self.measure_picker.GetPickPosition()
  635 +# if self.measure_picker.GetPointId() != -1:
  636 + if not self.measures or self.measures[-1].point_actor3:
  637 + m = measures.AngularMeasure(self.ren)
  638 + m.SetPoint1(x, y, z)
  639 + self.measures.append(m)
  640 + elif not self.measures[-1].point_actor2:
  641 + m = self.measures[-1]
  642 + m.SetPoint2(x, y, z)
  643 + else:
  644 + m = self.measures[-1]
  645 + m.SetPoint3(x, y, z)
  646 + ps.Publisher().sendMessage("Add measure to list",
  647 + ("3D", _("%.3f" % m.GetValue())))
  648 + self.interactor.Render()
632 649  
633 650  
634 651 class SlicePlane:
... ...