Operating system: Windows 10
Slicer version: 5.0.3
I’m trying to code a python extension that plots a line using points read from a csv file. After creating the script to add the required values to a vtkPoints and vtkPolyLine objects, I was able to render the line using the following:
# Create a polydata to store everything in
polyData = vtk.vtkPolyData()
# Add the points to the dataset
polyData.SetPoints(points)
# Add the lines to the dataset
polyData.SetLines(cells)
slicer.modules.models.logic().AddModel(polyData)
Output:
I now want to edit the line thickness.
When I use vtk outside of slicer, I would just use the following:
# Setup actor and mapper
mapper = vtkPolyDataMapper()
mapper.SetInputData(polyData)
actor = vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetLineWidth(5)
# Setup render window, renderer, and interactor
renderer = vtkRenderer()
renderWindow = vtkRenderWindow()
renderWindow.SetWindowName('PolyLine')
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderer.AddActor(actor)
renderWindow.Render()
renderWindowInteractor.Start()
However, I’m not sure how to use actor and renderer with Slicer. Is there a way of using actors in a Slicer scene?
I know the Models module’s UI has a line width slider, so I’m probably just missing something. I’ve tried looking in the logic file for the Models module, but haven’t found anything I can use. Any help at all would be appreciated.