Exemple #1
0
    def storeSceneView(self, name, description=""):
        """  

        NOTE: Taken from here:
        https://github.com/Slicer/Slicer/blob/master/Applications/SlicerApp/
            Testing/Python/SlicerMRBTest.py#L273


        Store a scene view into the current scene.
        TODO: this might move to slicer.util


        @param name: TheSceneViewName
        @return: vtkImageData
        """
        viewport = slicer.app.layoutManager().viewport()
        qImage = qt.QPixmap().grabWidget(viewport).toImage()
        imageData = vtk.vtkImageData()

        slicer.qMRMLUtils().qImageToVtkImageData(qImage, imageData)

        sceneViewNode = slicer.vtkMRMLSceneViewNode()
        sceneViewNode.SetScreenShotType(4)
        sceneViewNode.SetScreenShot(imageData)

        return sceneViewNode.GetScreenShot()
    def storeSceneView(self, name, description=""):
        """  

        NOTE: Taken from here:
        https://github.com/Slicer/Slicer/blob/master/Applications/SlicerApp/
            Testing/Python/SlicerMRBTest.py#L273


        Store a scene view into the current scene.
        TODO: this might move to slicer.util


        @param name: TheSceneViewName
        @return: vtkImageData
        """
        viewport = slicer.app.layoutManager().viewport()
        qImage = qt.QPixmap().grabWidget(viewport).toImage()
        imageData = vtk.vtkImageData()

        slicer.qMRMLUtils().qImageToVtkImageData(qImage,imageData)

        sceneViewNode = slicer.vtkMRMLSceneViewNode()
        sceneViewNode.SetScreenShotType(4)
        sceneViewNode.SetScreenShot(imageData)
 
        return sceneViewNode.GetScreenShot()
Exemple #3
0
    def test_AddStorableDataAfterSceneViewTest1(self):

        self.delayDisplay("Starting the test")

        #
        # add a fiducial
        #
        slicer.modules.markups.logic().AddFiducial()

        #
        # save a scene view
        #
        sv = slicer.mrmlScene.AddNode(slicer.vtkMRMLSceneViewNode())
        sv.StoreScene()

        #
        # add another storable node, a volume
        #
        self.delayDisplay(
            "Adding a new storable node, after creating a scene view")
        import SampleData
        sampleDataLogic = SampleData.SampleDataLogic()
        mrHeadVolume = sampleDataLogic.downloadMRHead()
        mrHeadID = mrHeadVolume.GetID()

        #
        # restore the scene view
        #
        self.delayDisplay("Restoring the scene view")
        sv.RestoreScene()

        #
        # Is the new storable data still present?
        #
        restoredData = slicer.mrmlScene.GetNodeByID(mrHeadID)

        # for now, the non scene view storable data is removed
        self.assertTrue(restoredData == None)
        self.delayDisplay(
            'Success: extra storable node removed with scene view restore')

        self.delayDisplay('Test passed!')
  def test_AddStorableDataAfterSceneViewTest1(self):

    self.delayDisplay("Starting the test")

    #
    # add a fiducial
    #
    slicer.modules.markups.logic().AddFiducial()

    #
    # save a scene view
    #
    sv = slicer.mrmlScene.AddNode(slicer.vtkMRMLSceneViewNode())
    sv.StoreScene()

    #
    # add another storable node, a volume
    #
    self.delayDisplay("Adding a new storable node, after creating a scene view")
    import SampleData
    sampleDataLogic = SampleData.SampleDataLogic()
    mrHeadVolume = sampleDataLogic.downloadMRHead()
    mrHeadID = mrHeadVolume.GetID()

    #
    # restore the scene view
    #
    self.delayDisplay("Restoring the scene view")
    sv.RestoreScene()

    #
    # Is the new storable data still present?
    #
    restoredData = slicer.mrmlScene.GetNodeByID(mrHeadID)

    # for now, the non scene view storable data is removed
    self.assertTrue( restoredData == None )
    self.delayDisplay('Success: extra storable node removed with scene view restore')

    self.delayDisplay('Test passed!')
  def test_AddStorableDataAfterSceneViewTest1(self):

    slicer.util.delayDisplay("Starting the test")

    #
    # add a fiducial
    #
    slicer.modules.markups.logic().AddFiducial()

    #
    # save a scene view
    #
    sv = slicer.mrmlScene.AddNode(slicer.vtkMRMLSceneViewNode())
    sv.StoreScene()

    #
    # add another storable node, a volume
    #
    slicer.util.delayDisplay("Adding a new storable node, after creating a scene view")
    import SampleData
    sampleDataLogic = SampleData.SampleDataLogic()
    mrHeadVolume = sampleDataLogic.downloadMRHead()
    mrHeadID = mrHeadVolume.GetID()

    #
    # restore the scene view
    #
    slicer.util.delayDisplay("Restoring the scene view")
    sv.RestoreScene()

    #
    # Is the new storable data still present?
    #
    restoredData = slicer.mrmlScene.GetNodeByID(mrHeadID)

    # for now, the non scene view storable data is removed
    self.assertTrue( restoredData == None )
    slicer.util.delayDisplay('Success: extra storable node removed with scene view restore')


    #
    # add new storable again
    mrHeadVolume = sampleDataLogic.downloadMRHead()
    mrHeadID = mrHeadVolume.GetID()

    #
    # restore the scene view, but error on removing nodes
    #
    slicer.util.delayDisplay("Restoring the scene view with check for removed nodes")
    sv.RestoreScene(0)

    #
    # Is the new storable data still present?
    #
    restoredData = slicer.mrmlScene.GetNodeByID(mrHeadID)

    # in this case the non scene view storable data is kept' scene is not changed
    self.assertTrue( restoredData != None )
    slicer.util.delayDisplay('Success: extra storable node NOT removed with scene view restore')

    print 'Scene error code = ' + str(slicer.mrmlScene.GetErrorCode())
    print '\t' + slicer.mrmlScene.GetErrorMessage()

    slicer.util.delayDisplay('Test passed!')