当前位置: 首页>>代码示例>>Python>>正文


Python layerstack.LayerStackModel类代码示例

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


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

示例1: testNonEmptyLayerStackModel

    def testNonEmptyLayerStackModel( self ):
        lsm = LayerStackModel()
        
        lsm.append(self.layer1)
        lsm.append(self.layer2)
        lsm.append(self.layer3)
        
        ip = ImagePump( lsm, SliceProjection() )
        self.assertEqual( len(lsm), 3 )
        self.assertEqual( len(ip.stackedImageSources), 3 )
        self.assertEqual( len(ip.syncedSliceSources), 3 )
        
        self.assertEqual( len(ip.stackedImageSources.getRegisteredLayers()), 3 )
        for layer in lsm:
            self.assertTrue( ip.stackedImageSources.isRegistered(layer) )

        lsm.deleteSelected()
        self.assertEqual( len(lsm), 2 )
        self.assertEqual( len(ip.stackedImageSources), 2 )
        self.assertEqual( len(ip.syncedSliceSources), 2 )
        self.assertEqual( len(ip.stackedImageSources.getRegisteredLayers()), 2 )
        for layer in lsm:
            self.assertTrue( ip.stackedImageSources.isRegistered(layer) )

        lsm.clear()
        self.assertEqual( len(lsm), 0 )
        self.assertEqual( len(ip.stackedImageSources), 0 )
        self.assertEqual( len(ip.syncedSliceSources), 0 )
        self.assertEqual( len(ip.stackedImageSources.getRegisteredLayers()), 0 )
开发者ID:JensNRAD,项目名称:volumina,代码行数:29,代码来源:imagepump_tests.py

示例2: ImageScene2D_LazyTest

    class ImageScene2D_LazyTest(ut.TestCase):
        def setUp(self):
            self.layerstack = LayerStackModel()
            self.sims = StackedImageSources(self.layerstack)

            self.g = Graph()
            self.op = OpLazy(self.g)
            self.ds = LazyflowSource(self.op.Output)

            self.ss = SliceSource(self.ds, projectionAlongTZC)

            self.layer = GrayscaleLayer(self.ds, normalize=False)
            self.layerstack.append(self.layer)
            self.ims = imsfac.createImageSource(self.layer, [self.ss])
            self.sims.register(self.layer, self.ims)

            self.scene = ImageScene2D(PositionModel(), (0, 0, 0), preemptive_fetch_number=0)
            self.scene.setCacheSize(1)

            self.scene.stackedImageSources = self.sims
            self.scene.dataShape = (30, 30)

        def renderScene(self, s, exportFilename=None, joinRendering=True):
            img = QImage(30, 30, QImage.Format_ARGB32_Premultiplied)
            img.fill(Qt.white)
            p = QPainter(img)

            s.render(p)  # trigger a rendering of the whole scene
            if joinRendering:
                # wait for all the data to arrive
                s.joinRenderingAllTiles(viewport_only=False)  # There is no viewport!
                # finally, render everything
                s.render(p)
            p.end()

            if exportFilename is not None:
                img.save(exportFilename)
            return byte_view(img)

        def testLazy(self):
            for i in range(3):
                self.op.setConstant(i)
                aimg = self.renderScene(self.scene, "/tmp/a_%03d.png" % i)
                assert numpy.all(aimg[:, :, 0] == i), "!= %d, [0,0,0]=%d" % (i, aimg[0, 0, 0])

                self.op.setConstant(42)
                self.op.setDelay(1)
                aimg = self.renderScene(self.scene, joinRendering=False, exportFilename="/tmp/x_%03d.png" % i)
                # this should be "i", not 255 (the default background for the imagescene)
                assert numpy.all(aimg[:, :, 0] == i), "!= %d, [0,0,0]=%d" % (i, aimg[0, 0, 0])

                # Now give the scene time to update before we change it again...
                self.scene.joinRenderingAllTiles(viewport_only=False)
开发者ID:ilastik,项目名称:volumina,代码行数:53,代码来源:lazy_test.py

示例3: createWidget

    def createWidget(self, parent):
        a = (numpy.random.random((1,100,200,300,1))*255).astype(numpy.uint8)
        source = ArraySource(a)
        layerstack = LayerStackModel()
        layerstack.append( GrayscaleLayer( source ) )

        editor = VolumeEditor(layerstack, labelsink=None, parent=self)  
        widget = VolumeEditorWidget(parent=parent)
        if not _has_lazyflow:
            widget.setEnabled(False)
        widget.init(editor)
        editor.dataShape = a.shape
        return widget
开发者ID:JensNRAD,项目名称:volumina,代码行数:13,代码来源:volumeEditorWidget_plugin.py

示例4: ImageScene2DTest

class ImageScene2DTest( ut.TestCase ):
    def setUp( self ):
        self.app = QApplication([], False)

        self.layerstack = LayerStackModel()
        self.sims = StackedImageSources( self.layerstack )

        self.GRAY = 201
        self.ds = ConstantSource(self.GRAY)
        self.layer = GrayscaleLayer( self.ds )
        self.layerstack.append(self.layer)
        self.ims = imsfac.createImageSource( self.layer, [self.ds] )
        self.sims.register(self.layer, self.ims)
        
        self.scene = ImageScene2D(self.app) 
        self.scene.stackedImageSources = self.sims
        self.scene.sceneShape = (310,290)

    def renderScene( self, s):
        img = QImage(310,290,QImage.Format_ARGB32_Premultiplied)
        p = QPainter(img)
        s.render(p)
        s.joinRendering()
        s.render(p)
        p.end()
        return byte_view(img)

    def testBasicImageRenderingCapability( self ):
        import time
        aimg = self.renderScene(self.scene)
        self.assertTrue(np.all(aimg[:,:,0:3] == self.GRAY))
        self.assertTrue(np.all(aimg[:,:,3] == 255))

    @ut.skipIf(os.getenv('TRAVIS'), 'fails on TRAVIS CI due to unknown reasons')
    def testToggleVisibilityOfOneLayer( self ):
        aimg = self.renderScene(self.scene)
        self.assertTrue(np.all(aimg[:,:,0:3] == self.GRAY))
        self.assertTrue(np.all(aimg[:,:,3] == 255))

        self.layer.visible = False
        aimg = self.renderScene(self.scene)
        self.assertTrue(np.all(aimg[:,:,0:3] == 255)) # all white
        self.assertTrue(np.all(aimg[:,:,3] == 255))

        self.layer.visible = True
        aimg = self.renderScene(self.scene)
        self.assertTrue(np.all(aimg[:,:,0:3] == self.GRAY))
        self.assertTrue(np.all(aimg[:,:,3] == 255))
开发者ID:LimpingTwerp,项目名称:volumina,代码行数:48,代码来源:imageScene2D_tests.py

示例5: test_repaint_after_visible_change

    def test_repaint_after_visible_change(self):
        self.model = LayerStackModel()

        self.o1 = Layer([])
        self.o1.name = "Fancy Layer"
        self.o1.opacity = 0.5
        self.model.append(self.o1)
        
        self.o2 = Layer([])
        self.o2.name = "Some other Layer"
        self.o2.opacity = 0.25
        self.model.append(self.o2)
        
        self.view = LayerWidget(None, self.model)
        self.view.show()
        self.view.updateGeometry()
    
        self.w = QWidget()
        self.lh = QHBoxLayout(self.w)
        self.lh.addWidget(self.view)
        self.w.setGeometry(100, 100, 300, 300)
        self.w.show()

        # Run the test within the GUI event loop
        QTimer.singleShot(500, self.impl )
        self.app.exec_()
        
        # Were there errors?
        assert not TestLayerWidget.errors, "There were GUI errors/failures.  See above."        
开发者ID:JensNRAD,项目名称:volumina,代码行数:29,代码来源:layerwidget_test.py

示例6: testRegisterAndDeregister

    def testRegisterAndDeregister( self ):
        lsm = LayerStackModel()
        sims = StackedImageSources( lsm )
        self.assertEqual( len(lsm), 0 )
        self.assertEqual( len(sims), 0 )

        lsm.append(self.layer1)
        lsm.append(self.layer2)
        lsm.append(self.layer3)
        self.assertEqual( lsm.layerIndex(self.layer1), 2 )
        self.assertEqual( lsm.layerIndex(self.layer2), 1 )
        self.assertEqual( lsm.layerIndex(self.layer3), 0 )
        self.assertEqual( len(lsm), 3 )
        self.assertEqual( len(sims), 0 )

        self.assertFalse(sims.isRegistered(self.layer2))
        sims.register( self.layer2, self.ims2 )
        self.assertTrue(sims.isRegistered(self.layer2))
        self.assertEqual( len(sims), 1 )
        self.assertEqual( sims.getImageSource(0), self.ims2 )

        sims.register( self.layer1, self.ims1 )
        sims.register( self.layer3, self.ims3 )
        sims.deregister( self.layer2 )
        self.assertTrue( sims.isRegistered( self.layer1 ))
        self.assertFalse( sims.isRegistered( self.layer2 ))
        self.assertTrue( sims.isRegistered( self.layer3 ))
        self.assertEqual( len(lsm), 3 )
        self.assertEqual( len(sims), 2 )
        self.assertEqual( sims.getImageSource(0), self.ims3 )    
        self.assertEqual( sims.getImageSource(1), self.ims1 )

        for i,v in enumerate(sims):
            if i == 0:
                self.assertEqual(len(v), 3)
                self.assertEqual(v[0], self.layer3.visible) 
                self.assertEqual(v[1], self.layer3.opacity)
                self.assertEqual(v[2], self.ims3)  
            elif i == 1:
                self.assertEqual(len(v), 3)
                self.assertEqual(v[0], self.layer1.visible) 
                self.assertEqual(v[1], self.layer1.opacity)
                self.assertEqual(v[2], self.ims1)
            else:
                raise Exception("unexpected index")

        sims.deregister( self.layer1 )
        sims.deregister( self.layer3 )
        self.assertEqual( len(lsm), 3 )
        self.assertEqual( len(sims), 0 )

        lsm.clear()
开发者ID:JensNRAD,项目名称:volumina,代码行数:52,代码来源:imagepump_tests.py

示例7: Main

class Main(QMainWindow):
     def __init__(self, useGL, argv):
         QMainWindow.__init__(self)
         self.initUic()
         
     def initUic(self):
         
        self.g=g=Graph() 
         
        #get the absolute path of the 'ilastik' module
        uic.loadUi("designerElements/MainWindow.ui", self) 
        
        self.actionQuit.triggered.connect(qApp.quit)
        def toggleDebugPatches(show):
            self.editor.showDebugPatches = show
        self.actionShowDebugPatches.toggled.connect(toggleDebugPatches)
        
        self.layerstack = LayerStackModel()
        
        readerNew=op.OpH5ReaderBigDataset(g)
        readerNew.inputs["Filenames"].setValue(["scripts/CB_compressed_XY.h5","scripts/CB_compressed_XZ.h5","scripts/CB_compressed_YZ.h5"])
        readerNew.inputs["hdf5Path"].setValue("volume/data")
        
        datasrc = LazyflowSource(readerNew.outputs["Output"])
        
        layer1 = GrayscaleLayer( datasrc )
        layer1.name = "Big Data"
        
        
        self.layerstack.append(layer1)
        
        shape=readerNew.outputs["Output"].meta.shape
        print shape
        self.editor = VolumeEditor(shape, self.layerstack)  
        #self.editor.setDrawingEnabled(False)
        
        self.volumeEditorWidget.init(self.editor)
        model = self.editor.layerStack
        self.layerWidget.init(model)
        
        self.UpButton.clicked.connect(model.moveSelectedUp)
        model.canMoveSelectedUp.connect(self.UpButton.setEnabled)
        self.DownButton.clicked.connect(model.moveSelectedDown)
        model.canMoveSelectedDown.connect(self.DownButton.setEnabled)
        self.DeleteButton.clicked.connect(model.deleteSelected)
        model.canDeleteSelected.connect(self.DeleteButton.setEnabled)        
开发者ID:LimpingTwerp,项目名称:applet-workflows,代码行数:46,代码来源:bigDatasetLoader.py

示例8: initLayerstackModel

 def initLayerstackModel(self):
     self.layerstack = LayerStackModel()
     self.layerWidget.init(self.layerstack)
     model = self.layerstack
     self.UpButton.clicked.connect(model.moveSelectedUp)
     model.canMoveSelectedUp.connect(self.UpButton.setEnabled)
     self.DownButton.clicked.connect(model.moveSelectedDown)
     model.canMoveSelectedDown.connect(self.DownButton.setEnabled)
     self.DeleteButton.clicked.connect(model.deleteSelected)
     model.canDeleteSelected.connect(self.DeleteButton.setEnabled)
开发者ID:jakirkham,项目名称:volumina,代码行数:10,代码来源:viewer.py

示例9: setUp

    def setUp( self ):
        self.layerstack = LayerStackModel()
        self.sims = StackedImageSources( self.layerstack )

        self.GRAY = 201
        self.ds = ConstantSource(self.GRAY)
        self.layer = GrayscaleLayer( self.ds )
        self.layerstack.append(self.layer)
        self.ims = imsfac.createImageSource( self.layer, [self.ds] )
        self.sims.register(self.layer, self.ims)

        self.scene = ImageScene2D(PositionModel(), (0,3,4), preemptive_fetch_number=0)

        self.scene.stackedImageSources = self.sims
        self.scene.dataShape = (310,290)
开发者ID:DerThorsten,项目名称:volumina,代码行数:15,代码来源:imageScene2D_tests.py

示例10: setUp

    def setUp( self ):
        dataShape = (1, 900, 400, 10, 1) # t,x,y,z,c
        data = np.indices(dataShape)[3] # Data is labeled according to z-index
        self.ds1 = ArraySource( data )
        self.CONSTANT = 13
        self.ds2 = ConstantSource( self.CONSTANT )

        self.layer1 = GrayscaleLayer( self.ds1 )
        self.layer1.visible = True
        self.layer1.opacity = 1.0

        self.layer2 = GrayscaleLayer( self.ds2 )

        self.lsm = LayerStackModel()
        self.pump = ImagePump( self.lsm, SliceProjection() )
开发者ID:LimpingTwerp,项目名称:volumina,代码行数:15,代码来源:tiling_tests.py

示例11: setUp

    def setUp( self ):
        self.app = QApplication([], False)

        self.layerstack = LayerStackModel()
        self.sims = StackedImageSources( self.layerstack )

        self.GRAY = 201
        self.ds = ConstantSource(self.GRAY)
        self.layer = GrayscaleLayer( self.ds )
        self.layerstack.append(self.layer)
        self.ims = imsfac.createImageSource( self.layer, [self.ds] )
        self.sims.register(self.layer, self.ims)
        
        self.scene = ImageScene2D(self.app) 
        self.scene.stackedImageSources = self.sims
        self.scene.sceneShape = (310,290)
开发者ID:LimpingTwerp,项目名称:volumina,代码行数:16,代码来源:imageScene2D_tests.py

示例12: setUp

        def setUp( self ):
            self.layerstack = LayerStackModel()
            self.sims = StackedImageSources( self.layerstack )

            self.g = Graph()
            self.op = OpLazy(self.g)
            self.ds = LazyflowSource( self.op.Output )

            self.ss = SliceSource( self.ds, projectionAlongTZC )

            self.layer = GrayscaleLayer(self.ds, normalize = False)
            self.layerstack.append(self.layer)
            self.ims = imsfac.createImageSource( self.layer, [self.ss] )
            self.sims.register(self.layer, self.ims)

            self.scene = ImageScene2D(PositionModel(), (0,0,0), preemptive_fetch_number=0)
            self.scene.setCacheSize(1)

            self.scene.stackedImageSources = self.sims
            self.scene.dataShape = (30,30)
开发者ID:JensNRAD,项目名称:volumina,代码行数:20,代码来源:lazy_test.py

示例13: DirtyPropagationTest

class DirtyPropagationTest( ut.TestCase ):
    
    def setUp( self ):
        dataShape = (1, 900, 400, 10, 1) # t,x,y,z,c
        data = np.indices(dataShape)[3] # Data is labeled according to z-index
        self.ds1 = ArraySource( data )
        self.CONSTANT = 13
        self.ds2 = ConstantSource( self.CONSTANT )

        self.layer1 = GrayscaleLayer( self.ds1 )
        self.layer1.visible = True
        self.layer1.opacity = 1.0

        self.layer2 = GrayscaleLayer( self.ds2 )

        self.lsm = LayerStackModel()
        self.pump = ImagePump( self.lsm, SliceProjection() )

    def testEverythingDirtyPropagation( self ):
        self.lsm.append(self.layer2)        
        tiling = Tiling((900,400), blockSize=100)
        tp = TileProvider(tiling, self.pump.stackedImageSources)
        try:
            tp.requestRefresh(QRectF(100,100,200,200))
            tp.join()
            tiles = tp.getTiles(QRectF(100,100,200,200))
            for tile in tiles:
                aimg = byte_view(tile.qimg)
                self.assertTrue(np.all(aimg[:,:,0:3] == self.CONSTANT))
                self.assertTrue(np.all(aimg[:,:,3] == 255))

            NEW_CONSTANT = self.CONSTANT+1
            self.ds2.constant = NEW_CONSTANT
            tp.requestRefresh(QRectF(100,100,200,200))
            tp.join()
            tiles = tp.getTiles(QRectF(100,100,200,200))
            for tile in tiles:
                aimg = byte_view(tile.qimg)
                self.assertTrue(np.all(aimg[:,:,0:3] == NEW_CONSTANT))
                self.assertTrue(np.all(aimg[:,:,3] == 255))
            
        finally:
            tp.notifyThreadsToStop()
            tp.joinThreads()

    def testOutOfViewDirtyPropagation( self ):
        self.lsm.append(self.layer1)
        tiling = Tiling((900,400), blockSize=100)
        tp = TileProvider(tiling, self.pump.stackedImageSources)
        try:
            # Navigate down to the second z-slice
            self.pump.syncedSliceSources.through = [0,1,0]
            tp.requestRefresh(QRectF(100,100,200,200))
            tp.join()

            # Sanity check: Do we see the right data on the second slice? (should be all 1s)
            tiles = tp.getTiles(QRectF(100,100,200,200))
            for tile in tiles:
                aimg = byte_view(tile.qimg)
                self.assertTrue(np.all(aimg[:,:,0:3] == 1))
                self.assertTrue(np.all(aimg[:,:,3] == 255))

            # Navigate down to the third z-slice
            self.pump.syncedSliceSources.through = [0,2,0]
            tp.requestRefresh(QRectF(100,100,200,200))
            tp.join()

            # Sanity check: Do we see the right data on the third slice?(should be all 2s)
            tiles = tp.getTiles(QRectF(100,100,200,200))
            for tile in tiles:
                aimg = byte_view(tile.qimg)
                self.assertTrue(np.all(aimg[:,:,0:3] == 2))
                self.assertTrue(np.all(aimg[:,:,3] == 255))

            # Navigate back up to the second z-slice
            self.pump.syncedSliceSources.through = [0,1,0]
            tp.requestRefresh(QRectF(100,100,200,200))
            tp.join()
            for tile in tiles:
                aimg = byte_view(tile.qimg)
                self.assertTrue(np.all(aimg[:,:,0:3] == 1))
                self.assertTrue(np.all(aimg[:,:,3] == 255))

            # Change some of the data in the (out-of-view) third z-slice
            slicing = (slice(None), slice(100,300), slice(100,300), slice(2,3), slice(None))
            slicing = tuple(slicing)
            self.ds1._array[slicing] = 99
            self.ds1.setDirty( slicing )
            
            # Navigate back down to the third z-slice
            self.pump.syncedSliceSources.through = [0,2,0]
            tp.requestRefresh(QRectF(100,100,200,200))
            tp.join()

            # Even though the data was out-of-view when it was changed, it should still have new values.
            # If dirtiness wasn't propagated correctly, the cache's old values will be used.
            # (For example, this fails if you comment out the call to setDirty, above.)
            tiles = tp.getTiles(QRectF(100,100,200,200))
            for tile in tiles:
                aimg = byte_view(tile.qimg)
#.........这里部分代码省略.........
开发者ID:LimpingTwerp,项目名称:volumina,代码行数:101,代码来源:tiling_tests.py

示例14: testAddingAndRemovingLayers

    def testAddingAndRemovingLayers( self ):
        lsm = LayerStackModel()
        sims = StackedImageSources( lsm )
        ims_view = sims.viewImageSources()
        self.assertEqual(len(lsm), 0)
        self.assertEqual(len(sims), 0)
        self.assertEqual(len(ims_view), 0)

        lsm.append(self.layer1)
        lsm.append(self.layer2)
        sims.register(self.layer1, self.ims1)
        sims.register(self.layer2, self.ims2)
        self.assertEqual(sims.isRegistered(self.layer1), True)
        self.assertEqual(sims.isRegistered(self.layer2), True)
        self.assertEqual(len(lsm), 2)
        self.assertEqual(len(sims), 2)
        self.assertEqual(len(ims_view), 2)
        self.assertEqual(ims_view[0], self.ims2)
        self.assertEqual(ims_view[1], self.ims1)

        lsm.append(self.layer3)
        self.assertEqual(len(lsm), 3)
        self.assertEqual(len(sims), 2)
        self.assertEqual(len(ims_view), 2)
        self.assertEqual(ims_view[0], self.ims2)
        self.assertEqual(ims_view[1], self.ims1)
        self.assertEqual(sims.isRegistered(self.layer1), True)
        self.assertEqual(sims.isRegistered(self.layer2), True)

        lsm.selectRow(1) # layer2
        lsm.deleteSelected()
        self.assertEqual(len(lsm), 2)
        self.assertEqual(len(sims), 1)
        self.assertEqual(len(ims_view), 1)
        self.assertEqual(ims_view[0], self.ims1)
        self.assertEqual(sims.isRegistered(self.layer1), True)
        self.assertEqual(sims.isRegistered(self.layer2), False)

        lsm.selectRow(0) # layer3
        lsm.deleteSelected()
        self.assertEqual(len(lsm), 1)
        self.assertEqual(len(sims), 1)
        self.assertEqual(len(ims_view), 1)
        self.assertEqual(ims_view[0], self.ims1)
        self.assertEqual(sims.isRegistered(self.layer1), True)
        self.assertEqual(sims.isRegistered(self.layer2), False)

        sims.deregister(self.layer1)
        self.assertEqual(len(lsm), 1)
        self.assertEqual(len(sims), 0)
        self.assertEqual(len(ims_view), 0)
        self.assertEqual(sims.isRegistered(self.layer1), False)
        self.assertEqual(sims.isRegistered(self.layer2), False)
开发者ID:JensNRAD,项目名称:volumina,代码行数:53,代码来源:imagepump_tests.py

示例15: Viewer

class Viewer(QMainWindow):
    """High-level API to view multi-dimensional arrays.

    Properties:
        title -- window title

    """
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        uiDirectory = os.path.split(volumina.__file__)[0]
        if uiDirectory == '':
            uiDirectory = '.'
        loadUi(uiDirectory + '/viewer.ui', self)

        self._dataShape = None
        self.editor = None

        self.actionQuit.triggered.connect(qApp.quit)
        #when connecting in renderScreenshot to a partial(...) function,
        #we need to remember the created function to be able to disconnect
        #to it later
        self._renderScreenshotDisconnect = None

        self.initLayerstackModel()

        self.actionCurrentView = QAction(QIcon(), \
            "Only for selected view", self.menuView)
        f = self.actionCurrentView.font()
        f.setBold(True)
        self.actionCurrentView.setFont(f)

        #make sure the layer stack widget, which is the right widget
        #managed by the splitter self.splitter shows up correctly
        #TODO: find a proper way of doing this within the designer
        def adjustSplitter():
            s = self.splitter.sizes()
            s = [int(0.66*s[0]), s[0]-int(0.66*s[0])]
            self.splitter.setSizes(s)
        QTimer.singleShot(0, adjustSplitter)

    def initLayerstackModel(self):
        self.layerstack = LayerStackModel()
        self.layerWidget.init(self.layerstack)
        model = self.layerstack
        self.UpButton.clicked.connect(model.moveSelectedUp)
        model.canMoveSelectedUp.connect(self.UpButton.setEnabled)
        self.DownButton.clicked.connect(model.moveSelectedDown)
        model.canMoveSelectedDown.connect(self.DownButton.setEnabled)
        self.DeleteButton.clicked.connect(model.deleteSelected)
        model.canDeleteSelected.connect(self.DeleteButton.setEnabled)

    def renderScreenshot(self, axis, blowup=1, filename="/tmp/volumina_screenshot.png"):
        """Save the complete slice as shown by the slice view 'axis'
        in the GUI as an image
        
        axis -- 0, 1, 2 (x, y, or z slice view)
        blowup -- enlarge written image by this factor
        filename -- output file
        """

        print "Rendering screenshot for axis=%d to '%s'" % (axis, filename)
        s = self.editor.imageScenes[axis]
        self.editor.navCtrl.enableNavigation = False
        func = partial(self._renderScreenshot, s, blowup, filename)
        self._renderScreenshotDisconnect = func
        s._renderThread.patchAvailable.connect(func)
        nRequested = 0
        for patchNumber in range(len(s._tiling)):
            p = s.tileProgress(patchNumber)
            if p < 1.0:
                s.requestPatch(patchNumber)
                nRequested += 1
        print "  need to compute %d of %d patches" % (nRequested, len(s._tiling))
        if nRequested == 0:
            #If no tile needed to be requested, the 'patchAvailable' signal
            #of the render thread will never come.
            #In this case, we need to call the implementation ourselves:
            self._renderScreenshot(s, blowup, filename, patchNumber=0)

    def addLayer(self, a, display='grayscale', opacity=1.0, \
                 name='Unnamed Layer', visible=True, interpretChannelsAs=None):
        print "adding layer '%s', shape=%r, %r" % (name, a.shape, type(a))

        """Adds a new layer on top of the layer stack (such that it will be
        above all currently defined layers). The array 'a' may be a simple
        numpy.ndarray or implicitly defined via a LazyflowArraySource.

        Returns the created Layer object. The layer can either be removed
        by passing this object to self.removeLayer, or by giving a unique
        name.
        """

        aSlices = None #in case a needs to be split by a lazyflow operator


        if len(a.shape) not in [2,3,5]:
            raise RuntimeError("Cannot interpret array with: shape=%r" \
                               % a.shape)

        volumeImage = True
#.........这里部分代码省略.........
开发者ID:LimpingTwerp,项目名称:volumina,代码行数:101,代码来源:api.py


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