• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python slicer.qMRMLUtils函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中slicer.qMRMLUtils函数的典型用法代码示例。如果您正苦于以下问题:Python qMRMLUtils函数的具体用法?Python qMRMLUtils怎么用?Python qMRMLUtils使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了qMRMLUtils函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: takeScreenshot

  def takeScreenshot(self,name,description,type=-1):
    # show the message even if not taking a screen shot
    slicer.util.delayDisplay('Take screenshot: '+description+'.\nResult is available in the Annotations module.', 3000)

    lm = slicer.app.layoutManager()
    # switch on the type to get the requested window
    widget = 0
    if type == slicer.qMRMLScreenShotDialog.FullLayout:
      # full layout
      widget = lm.viewport()
    elif type == slicer.qMRMLScreenShotDialog.ThreeD:
      # just the 3D window
      widget = lm.threeDWidget(0).threeDView()
    elif type == slicer.qMRMLScreenShotDialog.Red:
      # red slice window
      widget = lm.sliceWidget("Red")
    elif type == slicer.qMRMLScreenShotDialog.Yellow:
      # yellow slice window
      widget = lm.sliceWidget("Yellow")
    elif type == slicer.qMRMLScreenShotDialog.Green:
      # green slice window
      widget = lm.sliceWidget("Green")
    else:
      # default to using the full window
      widget = slicer.util.mainWindow()
      # reset the type so that the node is set correctly
      type = slicer.qMRMLScreenShotDialog.FullLayout

    # grab and convert to vtk image data
    qimage = ctk.ctkWidgetsUtils.grabWidget(widget)
    imageData = vtk.vtkImageData()
    slicer.qMRMLUtils().qImageToVtkImageData(qimage,imageData)

    annotationLogic = slicer.modules.annotations.logic()
    annotationLogic.CreateSnapShot(name, description, type, 1, imageData)
开发者ID:andrewfzheng,项目名称:Slicer,代码行数:35,代码来源:AddStorableDataAfterSceneViewTest.py


示例2: takeScreenshot

  def takeScreenshot(self,name,description,type=-1):
    """ Take a screenshot of the selected viewport and store as and
    annotation snapshot node. Convenience method for automated testing.

    If self.enableScreenshots is False then only a message is displayed but screenshot
    is not stored. Screenshots are scaled by self.screenshotScaleFactor.

    :param name: snapshot node name
    :param description: description of the node
    :param type: which viewport to capture. If not specified then captures the entire window.
      Valid values: slicer.qMRMLScreenShotDialog.FullLayout,
      slicer.qMRMLScreenShotDialog.ThreeD, slicer.qMRMLScreenShotDialog.Red,
      slicer.qMRMLScreenShotDialog.Yellow, slicer.qMRMLScreenShotDialog.Green.
    """

    # show the message even if not taking a screen shot
    slicer.util.delayDisplay(description)

    if not self.enableScreenshots:
      return

    lm = slicer.app.layoutManager()
    # switch on the type to get the requested window
    widget = 0
    if type == slicer.qMRMLScreenShotDialog.FullLayout:
      # full layout
      widget = lm.viewport()
    elif type == slicer.qMRMLScreenShotDialog.ThreeD:
      # just the 3D window
      widget = lm.threeDWidget(0).threeDView()
    elif type == slicer.qMRMLScreenShotDialog.Red:
      # red slice window
      widget = lm.sliceWidget("Red")
    elif type == slicer.qMRMLScreenShotDialog.Yellow:
      # yellow slice window
      widget = lm.sliceWidget("Yellow")
    elif type == slicer.qMRMLScreenShotDialog.Green:
      # green slice window
      widget = lm.sliceWidget("Green")
    else:
      # default to using the full window
      widget = slicer.util.mainWindow()
      # reset the type so that the node is set correctly
      type = slicer.qMRMLScreenShotDialog.FullLayout

    # grab and convert to vtk image data
    qimage = ctk.ctkWidgetsUtils.grabWidget(widget)
    imageData = vtk.vtkImageData()
    slicer.qMRMLUtils().qImageToVtkImageData(qimage,imageData)

    annotationLogic = slicer.modules.annotations.logic()
    annotationLogic.CreateSnapShot(name, description, type, self.screenshotScaleFactor, imageData)
开发者ID:BRAINSia,项目名称:Slicer,代码行数:52,代码来源:ScriptedLoadableModule.py


示例3: _createMagnifiedPixmap

  def _createMagnifiedPixmap(self, xyz, inputImageDataConnection, outputSize, crosshairColor, imageZoom=10):

    # Use existing instance of objects to avoid instantiating one at each event.
    imageCrop = self.imageCrop
    painter = self.painter
    pen = self.pen

    def _roundInt(value):
      try:
        return int(round(value))
      except ValueError:
        return 0

    imageCrop.SetInputConnection(inputImageDataConnection)
    xyzInt = [0, 0, 0]
    xyzInt = [_roundInt(value) for value in xyz]
    producer = inputImageDataConnection.GetProducer()
    dims = producer.GetOutput().GetDimensions()
    minDim = min(dims[0],dims[1])
    imageSize = _roundInt(minDim/imageZoom/2.0)
    imin = max(0,xyzInt[0]-imageSize)
    imax = min(dims[0]-1,  xyzInt[0]+imageSize)
    jmin = max(0,xyzInt[1]-imageSize)
    jmax = min(dims[1]-1,  xyzInt[1]+imageSize)
    if (imin <= imax) and (jmin <= jmax):
      imageCrop.SetVOI(imin, imax, jmin, jmax, 0,0)
      imageCrop.Update()
      vtkImage = imageCrop.GetOutput()
      if vtkImage:
        qImage = qt.QImage()
        slicer.qMRMLUtils().vtkImageDataToQImage(vtkImage, qImage)
        imagePixmap = qt.QPixmap.fromImage(qImage)
        imagePixmap = imagePixmap.scaled(outputSize, qt.Qt.KeepAspectRatio, qt.Qt.FastTransformation)

        # draw crosshair
        painter.begin(imagePixmap)
        pen = qt.QPen()
        pen.setColor(crosshairColor)
        painter.setPen(pen)
        painter.drawLine(0, int(imagePixmap.height()/2), imagePixmap.width(), int(imagePixmap.height()/2))
        painter.drawLine(int(imagePixmap.width()/2), 0, int(imagePixmap.width()/2), imagePixmap.height())
        painter.end()
        return imagePixmap
    return None
开发者ID:cpinter,项目名称:Slicer,代码行数:44,代码来源:DataProbe.py


示例4: takeScreenshot

  def takeScreenshot(self,name,description,type=-1):
    # show the message even if not taking a screen shot
    self.delayDisplay(description)

    if self.enableScreenshots == 0:
      return

    lm = slicer.app.layoutManager()
    # switch on the type to get the requested window
    widget = 0
    if type == slicer.qMRMLScreenShotDialog.FullLayout:
      # full layout
      widget = lm.viewport()
    elif type == slicer.qMRMLScreenShotDialog.ThreeD:
      # just the 3D window
      widget = lm.threeDWidget(0).threeDView()
    elif type == slicer.qMRMLScreenShotDialog.Red:
      # red slice window
      widget = lm.sliceWidget("Red")
    elif type == slicer.qMRMLScreenShotDialog.Yellow:
      # yellow slice window
      widget = lm.sliceWidget("Yellow")
    elif type == slicer.qMRMLScreenShotDialog.Green:
      # green slice window
      widget = lm.sliceWidget("Green")
    else:
      # default to using the full window
      widget = slicer.util.mainWindow()
      # reset the type so that the node is set correctly
      type = slicer.qMRMLScreenShotDialog.FullLayout

    # grab and convert to vtk image data
    qpixMap = qt.QPixmap().grabWidget(widget)
    qimage = qpixMap.toImage()
    imageData = vtk.vtkImageData()
    slicer.qMRMLUtils().qImageToVtkImageData(qimage,imageData)

    annotationLogic = slicer.modules.annotations.logic()
    annotationLogic.CreateSnapShot(name, description, type, self.screenshotScaleFactor, imageData)
开发者ID:KitwareMedical,项目名称:Slicer,代码行数:39,代码来源:RSNAQuantTutorial.py


示例5: saveScreenshot

  def saveScreenshot(self, name, filePath, description):
    type = slicer.qMRMLScreenShotDialog.FullLayout
    lm = slicer.app.layoutManager()
    widget = lm.viewport()
    # grab and convert to vtk image data
    qpixMap = qt.QPixmap().grabWidget(widget)
    qimage = qpixMap.toImage()
    imageData = vtk.vtkImageData()
    slicer.qMRMLUtils().qImageToVtkImageData(qimage,imageData)

    annotationLogic = slicer.modules.annotations.logic()
    annotationLogic.CreateSnapShot(name, description, type, 1, imageData)
    
    snapshotNode = slicer.util.getNode(name)
    
    if not snapshotNode:
       print "Can't get snapshotNode"
       return
    
    if not slicer.util.saveNode(snapshotNode, filePath):
       print "Can't save " + filePath
       return
开发者ID:gsi-kanderle,项目名称:SliceTRiP,代码行数:22,代码来源:LoadCTXLight.py


示例6: takeScreenShot

  def takeScreenShot(name, description, widget=None, screenShotType=-1):
    lm = slicer.app.layoutManager()
    if not widget:
      if screenShotType == slicer.qMRMLScreenShotDialog.FullLayout:
        widget = lm.viewport()
      elif screenShotType == slicer.qMRMLScreenShotDialog.ThreeD:
        widget = lm.threeDWidget(0).threeDView()
      elif screenShotType == slicer.qMRMLScreenShotDialog.Red:
        widget = lm.sliceWidget("Red")
      elif screenShotType == slicer.qMRMLScreenShotDialog.Yellow:
        widget = lm.sliceWidget("Yellow")
      elif screenShotType == slicer.qMRMLScreenShotDialog.Green:
        widget = lm.sliceWidget("Green")
      else:
        widget = slicer.util.mainWindow()
        screenShotType = slicer.qMRMLScreenShotDialog.FullLayout

    qImage = ctk.ctkWidgetsUtils.grabWidget(widget)
    imageData = vtk.vtkImageData()
    slicer.qMRMLUtils().qImageToVtkImageData(qImage, imageData)

    annotationLogic = slicer.modules.annotations.logic()
    annotationLogic.CreateSnapShot(name, description, screenShotType, 1.0, imageData)
    return slicer.util.getNodesByClass('vtkMRMLAnnotationSnapshotNode')[-1]
开发者ID:QIICR,项目名称:Reporting,代码行数:24,代码来源:htmlReport.py


示例7: __init__

  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)
开发者ID:pieper,项目名称:CompareVolumes,代码行数:40,代码来源:CompareVolumes.py


示例8: revealPixmap

  def revealPixmap(self, xy):
    """fill a pixmap with an image that has a reveal pattern
    at xy with the fg drawn over the bg"""

    # Get QImages for the two layers
    bgVTKImage = self.layerLogics['B'].GetImageData()
    fgVTKImage = self.layerLogics['F'].GetImageData()
    bgQImage = qt.QImage()
    fgQImage = qt.QImage()
    slicer.qMRMLUtils().vtkImageDataToQImage(bgVTKImage, bgQImage)
    slicer.qMRMLUtils().vtkImageDataToQImage(fgVTKImage, fgQImage)

    # get the geometry of the focal point (xy) and images
    # noting that vtk has the origin at the bottom left and qt has
    # it at the top left.  yy is the flipped version of y
    imageWidth = bgQImage.width()
    imageHeight = bgQImage.height()
    x,y=xy
    yy = imageHeight-y

    #
    # make a generally transparent image,
    # then fill quadrants with the fg image
    #
    overlayImage = qt.QImage(imageWidth, imageHeight, qt.QImage().Format_ARGB32)
    overlayImage.fill(0)

    halfWidth = imageWidth//2
    halfHeight = imageHeight//2
    topLeft = qt.QRect(0,0, x, yy)
    bottomRight = qt.QRect(x, yy, imageWidth-x-1, imageHeight-yy-1)

    self.painter.begin(overlayImage)
    self.painter.drawImage(topLeft, fgQImage, topLeft)
    self.painter.drawImage(bottomRight, fgQImage, bottomRight)
    self.painter.end()

    # draw the bg and fg on top of gray background
    compositePixmap = qt.QPixmap(self.width,self.height)
    compositePixmap.fill(self.gray)
    self.painter.begin(compositePixmap)
    self.painter.drawImage(
        -1 * (x  -self.width//2),
        -1 * (yy -self.height//2),
        bgQImage)
    self.painter.drawImage(
        -1 * (x  -self.width//2),
        -1 * (yy -self.height//2),
        overlayImage)
    self.painter.end()

    if self.scale:
      compositePixmap = self.scalePixmap(compositePixmap)

    # draw a border around the pixmap
    self.painter.begin(compositePixmap)
    self.pen = qt.QPen()
    self.color = qt.QColor("#FF0")
    self.color.setAlphaF(0.3)
    self.pen.setColor(self.color)
    self.pen.setWidth(5)
    self.pen.setStyle(3) # dotted line (Qt::DotLine)
    self.painter.setPen(self.pen)
    rect = qt.QRect(1, 1, self.width-2, self.height-2)
    self.painter.drawRect(rect)
    self.painter.end()

    return compositePixmap
开发者ID:pieper,项目名称:CompareVolumes,代码行数:68,代码来源:CompareVolumes.py



注:本文中的slicer.qMRMLUtils函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python slicer.qMRMLWidget函数代码示例发布时间:2022-05-27
下一篇:
Python slicer.qMRMLNodeComboBox函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap