Beispiel #1
0
    def __printSnapshots__(self):
        """ Generate snapshots of all the volumes to be displayed in the report
        """
        # Save a png file from different images.
        # We manipulate the widget to have the aspect that we want for the screenshot
        lm = slicer.app.layoutManager()

        # Take original image with Labelmap
        # Change to Red
        SlicerUtil.changeLayoutRedSingle()
        sliceWidget = lm.sliceWidget("Red")
        controller = sliceWidget.sliceController()
        controller.fitSliceToBackground()
        # Hide the slider bar (just show the picture)
        controller.hide()
        sliceView = sliceWidget.sliceView()
        sliceView.cornerAnnotation().ClearAllTexts()
        sliceView.scheduleRender()
        # Take the snapshot
        SlicerUtil.takeSnapshot(os.path.join(self.getCurrentDataFolder(),
                                             self.__getReportImagePath__(1)),
                                type=slicer.qMRMLScreenShotDialog.Red,
                                hideAnnotations=True)

        # Restore the regular controller
        controller.show()

        # Enhanced (with and without labelmap)
        SlicerUtil.changeLayoutYellowSingle()

        # If the user didn't open the enhanced volume yet, force it
        enhancedVol = self.getEnhancedVolume()
        yellowCompositeNode = slicer.mrmlScene.GetNodeByID(
            'vtkMRMLSliceCompositeNodeYellow')
        if yellowCompositeNode.GetBackgroundVolumeID() != enhancedVol.GetID():
            yellowCompositeNode.SetBackgroundVolumeID(enhancedVol.GetID())
            yellowSliceNode = slicer.mrmlScene.GetNodeByID(
                'vtkMRMLSliceNodeYellow')
            yellowSliceNode.SetOrientationToAxial()
            # Assign the labelmap
            yellowCompositeNode.SetLabelVolumeID(
                self.currentLabelmapVolume.GetID())

        controller = lm.sliceWidget("Yellow").sliceController()
        controller.fitSliceToBackground()
        # Hide the slider bar (just show the picture)
        controller.hide()
        # Take the snapshot
        SlicerUtil.takeSnapshot(os.path.join(self.getCurrentDataFolder(),
                                             self.__getReportImagePath__(3)),
                                type=slicer.qMRMLScreenShotDialog.Yellow,
                                hideAnnotations=True)

        # Remove the labelmap
        controller.setLabelMapHidden(True)
        # Take the snapshot
        SlicerUtil.takeSnapshot(os.path.join(self.getCurrentDataFolder(),
                                             self.__getReportImagePath__(2)),
                                type=slicer.qMRMLScreenShotDialog.Yellow,
                                hideAnnotations=True)

        # Restore the regular controller
        controller.show()
        controller.setLabelMapHidden(False)