def createScalingRuler(self, sliceViewName):
    #
    # Create the Scaling Ruler
    #
    self.points[sliceViewName] = vtk.vtkPoints()
    self.points[sliceViewName].SetNumberOfPoints(22)

    lines = []
    for i in xrange(0,21):
      line = vtk.vtkLine()
      lines.append(line)

    # setting the points to lines
    for i in xrange(0,21):
      if (i%2 == 0):
        lines[i].GetPointIds().SetId(0,i)
        lines[i].GetPointIds().SetId(1,i+1)
      else:
        lines[i].GetPointIds().SetId(0,i-1)
        lines[i].GetPointIds().SetId(1,i+1)

    # Create a cell array to store the lines in and add the lines to it
    linesArray = vtk.vtkCellArray()
    for i in xrange(0,21):
      linesArray.InsertNextCell(lines[i])

    # Create a polydata to store everything in
    linesPolyData = vtk.vtkPolyData()

    # Add the points to the dataset
    linesPolyData.SetPoints(self.points[sliceViewName])

    # Add the lines to the dataset
    linesPolyData.SetLines(linesArray)

    # mapper
    mapper = vtk.vtkPolyDataMapper2D()
    if vtk.VTK_MAJOR_VERSION <= 5:
      mapper.SetInput(linesPolyData)
    else:
      mapper.SetInputData(linesPolyData)
    # actor
    actor = self.scalingRulerActors[sliceViewName]
    actor.SetMapper(mapper)
    # color actor
    actor.GetProperty().SetColor(1,1,1)
    actor.GetProperty().SetLineWidth(1)
    textActor = self.scalingRulerTextActors[sliceViewName]
    textProperty = textActor.GetTextProperty()
Exemple #2
0
  def createScalingRuler(self, sliceViewName):
    #
    # Create the Scaling Ruler
    #
    self.points[sliceViewName] = vtk.vtkPoints()
    self.points[sliceViewName].SetNumberOfPoints(22)

    lines = []
    for i in xrange(0,21):
      line = vtk.vtkLine()
      lines.append(line)

    # setting the points to lines
    for i in xrange(0,21):
      if (i%2 == 0):
        lines[i].GetPointIds().SetId(0,i)
        lines[i].GetPointIds().SetId(1,i+1)
      else:
        lines[i].GetPointIds().SetId(0,i-1)
        lines[i].GetPointIds().SetId(1,i+1)

    # Create a cell array to store the lines in and add the lines to it
    linesArray = vtk.vtkCellArray()
    for i in xrange(0,21):
      linesArray.InsertNextCell(lines[i])

    # Create a polydata to store everything in
    linesPolyData = vtk.vtkPolyData()

    # Add the points to the dataset
    linesPolyData.SetPoints(self.points[sliceViewName])

    # Add the lines to the dataset
    linesPolyData.SetLines(linesArray)

    # mapper
    mapper = vtk.vtkPolyDataMapper2D()
    if vtk.VTK_MAJOR_VERSION <= 5:
      mapper.SetInput(linesPolyData)
    else:
      mapper.SetInputData(linesPolyData)
    # actor
    actor = self.scalingRulerActors[sliceViewName]
    actor.SetMapper(mapper)
    # color actor
    actor.GetProperty().SetColor(1,1,1)
    actor.GetProperty().SetLineWidth(1)
    textActor = self.scalingRulerTextActors[sliceViewName]
    textProperty = textActor.GetTextProperty()
  def drawLineBetweenPoints(self, lineModel, point1, point2):        
    # Create a vtkPoints object and store the points in it
    points = vtk.vtkPoints()
    points.InsertNextPoint(point1)
    points.InsertNextPoint(point2)

    # Create line
    line = vtk.vtkLine()
    line.GetPointIds().SetId(0,0) 
    line.GetPointIds().SetId(1,1)
    lineCellArray = vtk.vtkCellArray()
    lineCellArray.InsertNextCell(line)
    
    # Update model data
    lineModel.GetPolyData().SetPoints(points)
    lineModel.GetPolyData().SetLines(lineCellArray)