def addWebActor(self): self.webView = qt.QWebView() self.webView.setWindowFlags(0x800) self.webView.setStyleSheet('background:transparent;') w, h = self.sliceView.width,self.sliceView.height self.qImage = qt.QImage(w, h, qt.QImage.Format_ARGB32) self.vtkImage = vtk.vtkImageData() self.mapper = vtk.vtkImageMapper() self.mapper.SetColorLevel(128) self.mapper.SetColorWindow(255) self.mapper.SetInput(self.vtkImage) self.actor2D = vtk.vtkActor2D() self.actor2D.SetMapper(self.mapper) self.imageActor = vtk.vtkImageActor() #self.imageActor.SetPosition(0,-1000,0) self.renderWindow = self.sliceView.renderWindow() self.renderer = self.renderWindow.GetRenderers().GetItemAsObject(0) self.renderer.AddActor2D(self.actor2D) globals()['slicer'].ia = self.imageActor self.webView.connect('loadFinished(bool)', lambda worked : self.onLoadFinished(worked) ) #self.webView.page().connect('repaintRequested(QRect)', lambda rect : onLoadFinished(rect, self.webView, self.qImage) ) self.style = self.sliceView.interactor() events = ("ModifiedEvent", "MouseMoveEvent", "EnterEvent", "LeaveEvent",) for event in events: tag = self.style.AddObserver(event, self.processEvent) self.observerTags.append([self.style,tag])
def __init__(self, sliceWidget): super(ThresholdEffectTool,self).__init__(sliceWidget) # create a logic instance to do the non-gui work self.logic = ThresholdEffectLogic(self.sliceWidget.sliceLogic()) self.logic.undoRedo = self.undoRedo # interaction state variables self.min = 0 self.max = 0 # class instances self.lut = None self.thresh = None self.map = None # feedback actor self.cursorDummyImage = vtk.vtkImageData() self.cursorDummyImage.AllocateScalars() self.cursorMapper = vtk.vtkImageMapper() self.cursorMapper.SetInput( self.cursorDummyImage ) self.cursorActor = vtk.vtkActor2D() self.cursorActor.VisibilityOff() self.cursorActor.SetMapper( self.cursorMapper ) self.cursorMapper.SetColorWindow( 255 ) self.cursorMapper.SetColorLevel( 128 ) self.actors.append( self.cursorActor ) self.renderer.AddActor2D( self.cursorActor )
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()
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
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)
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()
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
def __init__(self, sliceWidget): super(ThresholdEffectTool, self).__init__(sliceWidget) # create a logic instance to do the non-gui work self.logic = ThresholdEffectLogic(self.sliceWidget.sliceLogic()) self.logic.undoRedo = self.undoRedo # interaction state variables self.min = 0 self.max = 0 # class instances self.lut = None self.thresh = None self.map = None # feedback actor self.cursorDummyImage = vtk.vtkImageData() self.cursorDummyImage.AllocateScalars() self.cursorMapper = vtk.vtkImageMapper() self.cursorMapper.SetInput(self.cursorDummyImage) self.cursorActor = vtk.vtkActor2D() self.cursorActor.VisibilityOff() self.cursorActor.SetMapper(self.cursorMapper) self.cursorMapper.SetColorWindow(255) self.cursorMapper.SetColorLevel(128) self.actors.append(self.cursorActor) self.renderer.AddActor2D(self.cursorActor)
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 )
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 )
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()
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)
def createActors(self, sliceViewName): sliceWidget = self.layoutManager.sliceWidget(sliceViewName) self.sliceWidgets[sliceViewName] = sliceWidget sliceView = sliceWidget.sliceView() self.scalingRulerTextActors[sliceViewName] = vtk.vtkTextActor() textActor = self.scalingRulerTextActors[sliceViewName] textProperty = textActor.GetTextProperty() textProperty.SetShadow(1) self.scalingRulerActors[sliceViewName] = vtk.vtkActor2D() # Create Scaling Ruler self.createScalingRuler(sliceViewName) # Create Color Scalar Bar self.colorScalarBars[sliceViewName] = self.createColorScalarBar(sliceViewName)
def __init__(self, parent=None, width=400, height=400, showWidget=False, scale=False): super(LayerReveal, self).__init__() self.width = width self.height = height self.showWidget = showWidget self.scale = scale self.renderer = None # 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)
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,parent=None,width=400,height=400,showWidget=False,scale=False): super(LayerReveal,self).__init__() self.width = width self.height = height self.showWidget = showWidget self.scale = scale self.renderer = None # 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)
def paintFeedback(self): """ add a feedback actor (copy of the paint radius actor) for any points that don't have one yet. If the list is empty, clear out the old actors """ if self.paintCoordinates == []: for a in self.feedbackActors: self.renderer.RemoveActor2D(a) self.feedbackActors = [] return for xy in self.paintCoordinates[len(self.feedbackActors):]: a = vtk.vtkActor2D() self.feedbackActors.append(a) a.SetMapper(self.mapper) a.SetPosition(xy[0], xy[1]) property = a.GetProperty() property.SetColor(.7, .7, 0) property.SetOpacity( .5 ) self.renderer.AddActor2D( a )
def paintFeedback(self): """ add a feedback actor (copy of the paint radius actor) for any points that don't have one yet. If the list is empty, clear out the old actors """ if self.paintCoordinates == []: for a in self.feedbackActors: self.renderer.RemoveActor2D(a) self.feedbackActors = [] return for xy in self.paintCoordinates[len(self.feedbackActors):]: a = vtk.vtkActor2D() self.feedbackActors.append(a) a.SetMapper(self.mapper) a.SetPosition(xy[0], xy[1]) property = a.GetProperty() property.SetColor(.7, .7, 0) property.SetOpacity(.5) self.renderer.AddActor2D(a)
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]
def __init__(self, sliceWidget): self.initialized = False super(IsobrushEffectTool, self).__init__(sliceWidget) # create a logic instance to do the non-gui work self.logic = IsobrushEffectLogic(self.sliceWidget.sliceLogic()) # interaction state variables - track if painting or not self.actionState = None self.mode = 'isograph' # TODO: could be a node setting controlled by gui # # cursor actor (paint preview) # self.cursorMapper = vtk.vtkImageMapper() self.cursorDummyImage = vtk.vtkImageData() self.cursorDummyImage.AllocateScalars(vtk.VTK_UNSIGNED_INT, 1) self.cursorMapper.SetInputData(self.cursorDummyImage) self.cursorActor = vtk.vtkActor2D() self.cursorActor.VisibilityOff() self.cursorActor.SetMapper(self.cursorMapper) self.cursorMapper.SetColorWindow(255) self.cursorMapper.SetColorLevel(128) self.actors.append(self.cursorActor) self.renderer.AddActor2D(self.cursorActor) # # Shader computation # - need to import class from module here since it may not be in sys.path # at startup time # - uses dummy render window for framebuffer object context # try: from vtkSlicerShadedActorModuleLogicPython import vtkOpenGLShaderComputation from vtkSlicerShadedActorModuleLogicPython import vtkOpenGLTextureImage except ImportError: import vtkAddon vtkOpenGLShaderComputation = vtkAddon.vtkOpenGLShaderComputation vtkOpenGLTextureImage = vtkAddon.vtkOpenGLTextureImage self.shaderComputation = vtkOpenGLShaderComputation() self.backgroundTextureImage = vtkOpenGLTextureImage() self.labelTextureImage = vtkOpenGLTextureImage() self.resultImageTexture = vtkOpenGLTextureImage() self.iterationImageTexture = vtkOpenGLTextureImage() self.backgroundTextureImage.SetShaderComputation( self.shaderComputation) self.labelTextureImage.SetShaderComputation(self.shaderComputation) self.resultImageTexture.SetShaderComputation(self.shaderComputation) self.iterationImageTexture.SetShaderComputation(self.shaderComputation) self.shaderComputation.SetVertexShaderSource(""" #version 120 attribute vec3 vertexAttribute; attribute vec2 textureCoordinateAttribute; varying vec3 interpolatedTextureCoordinate; void main() { interpolatedTextureCoordinate = vec3(textureCoordinateAttribute, .5); gl_Position = vec4(vertexAttribute, 1.); } """) self.initialized = True self.previewOn()
def __init__(self, sliceWidget): self.initialized = False super(IsobrushEffectTool,self).__init__(sliceWidget) # create a logic instance to do the non-gui work self.logic = IsobrushEffectLogic(self.sliceWidget.sliceLogic()) # interaction state variables - track if painting or not self.actionState = None # # cursor actor (paint preview) # self.cursorMapper = vtk.vtkImageMapper() self.cursorDummyImage = vtk.vtkImageData() self.cursorDummyImage.AllocateScalars(vtk.VTK_UNSIGNED_INT, 1) self.cursorMapper.SetInputData( self.cursorDummyImage ) self.cursorActor = vtk.vtkActor2D() self.cursorActor.VisibilityOff() self.cursorActor.SetMapper( self.cursorMapper ) self.cursorMapper.SetColorWindow( 255 ) self.cursorMapper.SetColorLevel( 128 ) self.actors.append( self.cursorActor ) self.renderer.AddActor2D( self.cursorActor ) # # Shader computation # - need to import class from module here since it may not be in sys.path # at startup time # - uses dummy render window for framebuffer object context # try: from vtkSlicerShadedActorModuleLogicPython import vtkOpenGLShaderComputation from vtkSlicerShadedActorModuleLogicPython import vtkOpenGLTextureImage except ImportError: import vtkAddon vtkOpenGLShaderComputation=vtkAddon.vtkOpenGLShaderComputation vtkOpenGLTextureImage=vtkAddon.vtkOpenGLTextureImage self.shaderComputation=vtkOpenGLShaderComputation() self.backgroundTextureImage=vtkOpenGLTextureImage() self.labelTextureImage=vtkOpenGLTextureImage() self.resultImageTexture=vtkOpenGLTextureImage() self.iterationImageTexture=vtkOpenGLTextureImage() self.backgroundTextureImage.SetShaderComputation(self.shaderComputation) self.labelTextureImage.SetShaderComputation(self.shaderComputation) self.resultImageTexture.SetShaderComputation(self.shaderComputation) self.iterationImageTexture.SetShaderComputation(self.shaderComputation) self.shaderComputation.SetVertexShaderSource(""" #version 120 attribute vec3 vertexAttribute; attribute vec2 textureCoordinateAttribute; varying vec3 interpolatedTextureCoordinate; void main() { interpolatedTextureCoordinate = vec3(textureCoordinateAttribute, .5); gl_Position = vec4(vertexAttribute, 1.); } """) self.initialized = True self.previewOn()
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)