Example #1
0
  def __init__(self, sliceWidget):
    super(LevelTracingEffectTool,self).__init__(sliceWidget)
    
    # create a logic instance to do the non-gui work
    self.logic = LevelTracingEffectLogic(self.sliceWidget.sliceLogic())

    # instance variables
    self.actionState = ''

    # initialization
    self.xyPoints = vtk.vtkPoints()
    self.rasPoints = vtk.vtkPoints()
    self.polyData = vtk.vtkPolyData()

    self.tracingFilter = vtkITK.vtkITKLevelTracingImageFilter()
    self.ijkToXY = vtk.vtkTransform()

    self.mapper = vtk.vtkPolyDataMapper2D()
    self.actor = vtk.vtkActor2D()
    property_ = self.actor.GetProperty()
    property_.SetColor( 107/255., 190/255., 99/255. )
    property_.SetLineWidth( 1 )
    self.mapper.SetInput(self.polyData)
    self.actor.SetMapper(self.mapper)
    property_ = self.actor.GetProperty()
    property_.SetColor(1,1,0)
    property_.SetLineWidth(1)
    self.renderer.AddActor2D( self.actor )
    self.actors.append( self.actor )
Example #2
0
    def __init__(self, sliceWidget):

        # keep a flag since events such as sliceNode modified
        # may come during superclass construction, which will
        # invoke our processEvents method
        self.initialized = False

        super(DrawEffectTool, self).__init__(sliceWidget)

        # create a logic instance to do the non-gui work
        self.logic = DrawEffectLogic(self.sliceWidget.sliceLogic())

        # interaction state variables
        self.activeSlice = None
        self.lastInsertSLiceNodeMTime = None
        self.actionState = None

        # initialization
        self.xyPoints = vtk.vtkPoints()
        self.rasPoints = vtk.vtkPoints()
        self.polyData = self.createPolyData()

        self.mapper = vtk.vtkPolyDataMapper2D()
        self.actor = vtk.vtkActor2D()
        self.mapper.SetInput(self.polyData)
        self.actor.SetMapper(self.mapper)
        property_ = self.actor.GetProperty()
        property_.SetColor(1, 1, 0)
        property_.SetLineWidth(1)
        self.renderer.AddActor2D(self.actor)
        self.actors.append(self.actor)

        self.initialized = True
Example #3
0
  def __init__(self, sliceWidget):
    super(PaintEffectTool,self).__init__(sliceWidget)
    # create a logic instance to do the non-gui work
    self.logic = PaintEffectLogic(self.sliceWidget.sliceLogic())

    # configuration variables
    self.delayedPaint = True
    self.parameterNode = self.editUtil.getParameterNode()
    self.sphere = not (0 == int(self.parameterNode.GetParameter("PaintEffect,sphere")))
    self.smudge = not (0 == int(self.parameterNode.GetParameter("PaintEffect,smudge")))
    self.pixelMode = not (0 == int(self.parameterNode.GetParameter("PaintEffect,pixelMode")))
    self.radius = float(self.parameterNode.GetParameter("PaintEffect,radius"))

    # interaction state variables
    self.position = [0, 0, 0]
    self.paintCoordinates = []
    self.feedbackActors = []
    self.lastRadius = 0

    # scratch variables
    self.rasToXY = vtk.vtkMatrix4x4()

    # initialization
    self.brush = vtk.vtkPolyData()
    self.createGlyph(self.brush)
    self.mapper = vtk.vtkPolyDataMapper2D()
    self.actor = vtk.vtkActor2D()
    self.mapper.SetInput(self.brush)
    self.actor.SetMapper(self.mapper)
    self.actor.VisibilityOff()

    self.renderer.AddActor2D(self.actor)
    self.actors.append(self.actor)

    self.processEvent()
Example #4
0
    def __init__(self, sliceWidget):
        super(PaintEffectTool, self).__init__(sliceWidget)

        # configuration variables
        self.radius = 5
        self.smudge = 0
        self.delayedPaint = 1

        # interaction state variables
        self.position = [0, 0, 0]
        self.paintCoordinates = []
        self.feedbackActors = []
        self.lastRadius = 0

        # scratch variables
        self.rasToXY = vtk.vtkMatrix4x4()

        # initialization
        self.brush = vtk.vtkPolyData()
        self.createGlyph(self.brush)
        self.mapper = vtk.vtkPolyDataMapper2D()
        self.actor = vtk.vtkActor2D()
        self.mapper.SetInput(self.brush)
        self.actor.SetMapper(self.mapper)
        self.actor.VisibilityOff()

        self.renderer.AddActor2D(self.actor)
        self.actors.append(self.actor)

        self.processEvent()
Example #5
0
    def __init__(self, sliceWidget):
        super(DrawEffectTool, self).__init__(sliceWidget)

        # create a logic instance to do the non-gui work
        self.logic = DrawEffectLogic(self.sliceWidget.sliceLogic())

        # interaction state variables
        self.activeSlice = None
        self.lastInsertSLiceNodeMTime = None
        self.actionState = None

        # initialization
        self.xyPoints = vtk.vtkPoints()
        self.rasPoints = vtk.vtkPoints()
        self.polyData = self.createPolyData()

        self.mapper = vtk.vtkPolyDataMapper2D()
        self.actor = vtk.vtkActor2D()
        self.mapper.SetInput(self.polyData)
        self.actor.SetMapper(self.mapper)
        property_ = self.actor.GetProperty()
        property_.SetColor(1, 1, 0)
        property_.SetLineWidth(1)
        self.renderer.AddActor2D(self.actor)
        self.actors.append(self.actor)
Example #6
0
    def __init__(self, sliceWidget):
        super(RectangleEffectTool, self).__init__(sliceWidget)

        # create a logic instance to do the non-gui work
        self.logic = RectangleEffectLogic(self.sliceWidget.sliceLogic())

        # interaction state variables
        self.actionState = None
        self.startXYPosition = None
        self.currentXYPosition = None

        # initialization
        self.createGlyph()

        self.mapper = vtk.vtkPolyDataMapper2D()
        self.actor = vtk.vtkActor2D()
        if vtk.VTK_MAJOR_VERSION <= 5:
            self.mapper.SetInput(self.polyData)
        else:
            self.mapper.SetInputData(self.polyData)
        self.actor.SetMapper(self.mapper)
        property_ = self.actor.GetProperty()
        property_.SetColor(1, 1, 0)
        property_.SetLineWidth(1)
        self.renderer.AddActor2D(self.actor)
        self.actors.append(self.actor)
Example #7
0
    def __init__(self, sliceWidget):
        super(DrawEffectTool, self).__init__(sliceWidget)

        # create a logic instance to do the non-gui work
        self.logic = DrawEffectLogic(self.sliceWidget.sliceLogic())

        # interaction state variables
        self.activeSlice = None
        self.lastInsertSLiceNodeMTime = None
        self.actionState = None

        # initialization
        self.xyPoints = vtk.vtkPoints()
        self.rasPoints = vtk.vtkPoints()
        self.polyData = self.createPolyData()

        self.mapper = vtk.vtkPolyDataMapper2D()
        self.actor = vtk.vtkActor2D()
        self.mapper.SetInput(self.polyData)
        self.actor.SetMapper(self.mapper)
        property_ = self.actor.GetProperty()
        property_.SetColor(1, 1, 0)
        property_.SetLineWidth(1)
        self.renderer.AddActor2D(self.actor)
        self.actors.append(self.actor)
Example #8
0
  def __init__(self, sliceWidget):

    # keep a flag since events such as sliceNode modified
    # may come during superclass construction, which will
    # invoke our processEvents method
    self.initialized = False

    super(DrawEffectTool,self).__init__(sliceWidget)
    
    # create a logic instance to do the non-gui work
    self.logic = DrawEffectLogic(self.sliceWidget.sliceLogic())

    # interaction state variables
    self.activeSlice = None
    self.lastInsertSLiceNodeMTime = None
    self.actionState = None

    # initialization
    self.xyPoints = vtk.vtkPoints()
    self.rasPoints = vtk.vtkPoints()
    self.polyData = self.createPolyData()

    self.mapper = vtk.vtkPolyDataMapper2D()
    self.actor = vtk.vtkActor2D()
    self.mapper.SetInput(self.polyData)
    self.actor.SetMapper(self.mapper)
    property_ = self.actor.GetProperty()
    property_.SetColor(1,1,0)
    property_.SetLineWidth(1)
    self.renderer.AddActor2D( self.actor )
    self.actors.append( self.actor )

    self.initialized = True
Example #9
0
  def __init__(self, sliceWidget):
    super(RectangleEffectTool,self).__init__(sliceWidget)

    # create a logic instance to do the non-gui work
    self.logic = RectangleEffectLogic(self.sliceWidget.sliceLogic())

    # interaction state variables
    self.actionState = None
    self.startXYPosition = None
    self.currentXYPosition = None

    # initialization
    self.createGlyph()

    self.mapper = vtk.vtkPolyDataMapper2D()
    self.actor = vtk.vtkActor2D()
    if vtk.VTK_MAJOR_VERSION <= 5:
      self.mapper.SetInput(self.polyData)
    else:
      self.mapper.SetInputData(self.polyData)
    self.actor.SetMapper(self.mapper)
    property_ = self.actor.GetProperty()
    property_.SetColor(1,1,0)
    property_.SetLineWidth(1)
    self.renderer.AddActor2D( self.actor )
    self.actors.append( self.actor )
Example #10
0
  def __init__(self, sliceWidget):
    super(PaintEffectTool,self).__init__(sliceWidget)

    # configuration variables
    self.radius = 5
    self.smudge = 0
    self.delayedPaint = 1

    # interaction state variables
    self.position = [0, 0, 0]
    self.paintCoordinates = []
    self.feedbackActors = []
    self.lastRadius = 0

    # scratch variables
    self.rasToXY = vtk.vtkMatrix4x4()

    # initialization
    self.brush = vtk.vtkPolyData()
    self.createGlyph(self.brush)
    self.mapper = vtk.vtkPolyDataMapper2D()
    self.actor = vtk.vtkActor2D()
    self.mapper.SetInput(self.brush)
    self.actor.SetMapper(self.mapper)
    self.actor.VisibilityOff()

    self.renderer.AddActor2D(self.actor)
    self.actors.append(self.actor)

    self.processEvent()
Example #11
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()
Example #12
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()
Example #13
0
    def __init__(self, sliceWidget):
        super(PaintEffectTool, self).__init__(sliceWidget)
        # create a logic instance to do the non-gui work
        self.logic = PaintEffectLogic(self.sliceWidget.sliceLogic())

        # configuration variables
        self.delayedPaint = True
        self.parameterNode = self.editUtil.getParameterNode()
        self.sphere = not (0 == int(
            self.parameterNode.GetParameter("PaintEffect,sphere")))
        self.smudge = not (0 == int(
            self.parameterNode.GetParameter("PaintEffect,smudge")))
        self.pixelMode = not (0 == int(
            self.parameterNode.GetParameter("PaintEffect,pixelMode")))
        self.radius = float(
            self.parameterNode.GetParameter("PaintEffect,radius"))

        # interaction state variables
        self.position = [0, 0, 0]
        self.paintCoordinates = []
        self.feedbackActors = []
        self.lastRadius = 0

        # scratch variables
        self.rasToXY = vtk.vtkMatrix4x4()

        # initialization
        self.brush = vtk.vtkPolyData()
        self.createGlyph(self.brush)
        self.mapper = vtk.vtkPolyDataMapper2D()
        self.actor = vtk.vtkActor2D()
        if vtk.VTK_MAJOR_VERSION <= 5:
            self.mapper.SetInput(self.brush)
        else:
            self.mapper.SetInputData(self.brush)
        self.actor.SetMapper(self.mapper)
        self.actor.VisibilityOff()

        self.renderer.AddActor2D(self.actor)
        self.actors.append(self.actor)

        self.processEvent()
  def __init__(self, sliceWidget):
    super(WindowLevelEffectTool,self).__init__(sliceWidget)

    # create a logic instance to do the non-gui work
    self.logic = WindowLevelEffectLogic(self.sliceWidget.sliceLogic())
    self.options = WindowLevelEffectOptions()

    # interaction state variables
    self.actionState = None
    self.startXYPosition = None
    self.currentXYPosition = None

    # configuration
    self.parameterNode = self.editUtil.getParameterNode()
    self.mode = self.parameterNode.GetParameter('WindowLevelEffect,wlmode')
    self.changeBg = not (0 == int(self.parameterNode.GetParameter('WindowLevelEffect,changeBg')))
    self.changeFg = not (0 == int(self.parameterNode.GetParameter('WindowLevelEffect,changeFg')))

    # initialization
    self.createGlyph()

    self.mapper = vtk.vtkPolyDataMapper2D()
    self.actor = vtk.vtkActor2D()
    if vtk.VTK_MAJOR_VERSION <= 5:
      self.mapper.SetInput(self.polyData)
    else:
      self.mapper.SetInputData(self.polyData)
    self.actor.SetMapper(self.mapper)
    property_ = self.actor.GetProperty()
    property_.SetColor(1,1,0)
    property_.SetLineWidth(1)
    self.renderer.AddActor2D( self.actor )
    self.actors.append( self.actor )

    # will keep w/l on left mouse button down
    self.bgStartWindowLevel = [0,0]
    self.fgStartWindowLevel = [0,0]
    def __init__(self, sliceWidget):
        super(WindowLevelEffectTool, self).__init__(sliceWidget)

        # create a logic instance to do the non-gui work
        self.logic = WindowLevelEffectLogic(self.sliceWidget.sliceLogic())
        self.options = WindowLevelEffectOptions()

        # interaction state variables
        self.actionState = None
        self.startXYPosition = None
        self.currentXYPosition = None

        # configuration
        self.parameterNode = self.editUtil.getParameterNode()
        self.mode = self.parameterNode.GetParameter("WindowLevelEffect,wlmode")
        self.changeBg = not (0 == int(self.parameterNode.GetParameter("WindowLevelEffect,changeBg")))
        self.changeFg = not (0 == int(self.parameterNode.GetParameter("WindowLevelEffect,changeFg")))

        # initialization
        self.createGlyph()

        self.mapper = vtk.vtkPolyDataMapper2D()
        self.actor = vtk.vtkActor2D()
        if vtk.VTK_MAJOR_VERSION <= 5:
            self.mapper.SetInput(self.polyData)
        else:
            self.mapper.SetInputData(self.polyData)
        self.actor.SetMapper(self.mapper)
        property_ = self.actor.GetProperty()
        property_.SetColor(1, 1, 0)
        property_.SetLineWidth(1)
        self.renderer.AddActor2D(self.actor)
        self.actors.append(self.actor)

        # will keep w/l on left mouse button down
        self.bgStartWindowLevel = [0, 0]
        self.fgStartWindowLevel = [0, 0]
Example #16
0
  def __init__(self,parent=None,width=400,height=400,showWidget=False,scale=False):
    super(ROIManager,self).__init__()
    self.width = width
    self.height = height
    self.showWidget = showWidget
    self.scale = scale
    self.renderer = None
    self.ROIRadius = 20.0
    self.minValueBG=0
    self.maxValueBG=0
    self.minValueFG=0
    self.maxValueFG=0
    self.probeWidget = None
    self.drawOverlay = 0

    # utility Qt instances for use in methods
    self.gray = qt.QColor()
    self.gray.setRedF(0.5)
    self.gray.setGreenF(0.5)
    self.gray.setBlueF(0.5)
    # a painter to use for various jobs
    self.painter = qt.QPainter()


    # make a qwidget display
    if self.showWidget:
      self.frame = qt.QFrame(parent)
      mw = slicer.util.mainWindow()
      self.frame.setGeometry(mw.x, mw.y, self.width, self.height)
      self.frameLayout = qt.QVBoxLayout(self.frame)
      self.label = qt.QLabel()
      self.frameLayout.addWidget(self.label)
      self.frame.show()

    # make an image actor in the slice view
    self.vtkImage = vtk.vtkImageData()

    self.mrmlUtils = slicer.qMRMLUtils()
    self.imageMapper = vtk.vtkImageMapper()
    self.imageMapper.SetColorLevel(128)
    self.imageMapper.SetColorWindow(255)
    if vtk.VTK_MAJOR_VERSION <= 5:
      self.imageMapper.SetInput(self.vtkImage)
    else:
      self.imageMapper.SetInputData(self.vtkImage)
    self.actor2D = vtk.vtkActor2D()
    self.actor2D.SetMapper(self.imageMapper)

    # make a circle actor
    self.circle = vtk.vtkRegularPolygonSource()
    self.circle.SetNumberOfSides(50)
    self.circle.SetRadius(5)
    self.circle.SetCenter(0,0,0)
    self.circle.GeneratePolylineOn()
    self.circle.GeneratePolygonOff()
    self.circle.Update()
    self.mapper = vtk.vtkPolyDataMapper2D()
    self.actor = vtk.vtkActor2D()
    if vtk.VTK_MAJOR_VERSION <= 5:
      self.mapper.SetInput(self.circle.GetOutput())
    else:
      self.mapper.SetInputConnection(self.circle.GetOutputPort())
    self.actor.SetMapper(self.mapper)
    property_ = self.actor.GetProperty()
    property_.SetColor(1,1,0)
    property_.SetLineWidth(1)