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


Python gui.ThunkEventHandler类代码示例

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


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

示例1: __init__

    def __init__(self, parentApplet, labelingSlots, topLevelOperatorView, drawerUiPath=None, rawInputSlot=None,
                 crosshair=True, is_3d_widget_visible=False):
        """
        Constructor.

        :param labelingSlots: Provides the slots needed for sourcing/sinking label data.  See LabelingGui.LabelingSlots
                              class source for details.
        :param topLevelOperatorView: is provided to the LayerViewerGui (the base class)
        :param drawerUiPath: can be given if you provide an extended drawer UI file.  Otherwise a default one is used.
        :param rawInputSlot: Data from the rawInputSlot parameter will be displayed directly underneath the elements
                             (if provided).
        """

        self._colorTable16 = list(colortables.default16_new)

        # Do have have all the slots we need?
        assert isinstance(labelingSlots, LabelingGui.LabelingSlots)
        assert labelingSlots.labelInput is not None, "Missing a required slot."
        assert labelingSlots.labelOutput is not None, "Missing a required slot."
        assert labelingSlots.labelEraserValue is not None, "Missing a required slot."
        assert labelingSlots.labelDelete is not None, "Missing a required slot."
        assert labelingSlots.labelNames is not None, "Missing a required slot."

        self.__cleanup_fns = []

        self._labelingSlots = labelingSlots
        self._minLabelNumber = 0
        self._maxLabelNumber = 99 #100 or 255 is reserved for eraser

        self._rawInputSlot = rawInputSlot

        self._labelingSlots.labelNames.notifyDirty(bind(self._updateLabelList))
        self.__cleanup_fns.append(partial(self._labelingSlots.labelNames.unregisterDirty, bind(self._updateLabelList)))
        self._colorTable16 = colortables.default16_new
        self._programmaticallyRemovingLabels = False

        if drawerUiPath is None:
            # Default ui file
            drawerUiPath = os.path.split(__file__)[0] + '/labelingDrawer.ui'
        self._initLabelUic(drawerUiPath)

        # Init base class
        super(LabelingGui, self).__init__(parentApplet,
                                          topLevelOperatorView,
                                          [labelingSlots.labelInput, labelingSlots.labelOutput],
                                          crosshair=crosshair,
                                          is_3d_widget_visible=is_3d_widget_visible)

        self.__initShortcuts()
        self._labelingSlots.labelEraserValue.setValue(self.editor.brushingModel.erasingNumber)
        self._allowDeleteLastLabelOnly = False
        self._forceAtLeastTwoLabels = False

        # Register for thunk events (easy UI calls from non-GUI threads)
        self.thunkEventHandler = ThunkEventHandler(self)
        self._changeInteractionMode(Tool.Navigation)
开发者ID:ilastik,项目名称:ilastik,代码行数:56,代码来源:labelingGui.py

示例2: __init__

    def __init__(self, parentApplet, topLevelOperatorView):
        """
        """
        super(VigraWatershedViewerGui, self).__init__(parentApplet, topLevelOperatorView)
        self.topLevelOperatorView = topLevelOperatorView
        op = self.topLevelOperatorView

        op.FreezeCache.setValue(True)
        op.OverrideLabels.setValue({0: (0, 0, 0, 0)})

        # Default settings (will be overwritten by serializer)
        op.InputChannelIndexes.setValue([])
        op.SeedThresholdValue.setValue(0.0)
        op.MinSeedSize.setValue(0)

        # Init padding gui updates
        blockPadding = PreferencesManager().get("vigra watershed viewer", "block padding", 10)
        op.WatershedPadding.notifyDirty(self.updatePaddingGui)
        op.WatershedPadding.setValue(blockPadding)
        self.updatePaddingGui()

        # Init block shape gui updates
        cacheBlockShape = PreferencesManager().get("vigra watershed viewer", "cache block shape", (256, 10))
        op.CacheBlockShape.notifyDirty(self.updateCacheBlockGui)
        op.CacheBlockShape.setValue(tuple(cacheBlockShape))
        self.updateCacheBlockGui()

        # Init seeds gui updates
        op.SeedThresholdValue.notifyDirty(self.updateSeedGui)
        op.SeedThresholdValue.notifyReady(self.updateSeedGui)
        op.SeedThresholdValue.notifyUnready(self.updateSeedGui)
        op.MinSeedSize.notifyDirty(self.updateSeedGui)
        self.updateSeedGui()

        # Init input channel gui updates
        op.InputChannelIndexes.notifyDirty(self.updateInputChannelGui)
        op.InputChannelIndexes.setValue([0])
        op.InputImage.notifyMetaChanged(bind(self.updateInputChannelGui))
        self.updateInputChannelGui()

        self.thunkEventHandler = ThunkEventHandler(self)

        # Remember to unsubscribe during shutdown
        self.__cleanup_fns = []
        self.__cleanup_fns.append(partial(op.WatershedPadding.unregisterDirty, self.updatePaddingGui))
        self.__cleanup_fns.append(partial(op.CacheBlockShape.unregisterDirty, self.updateCacheBlockGui))
        self.__cleanup_fns.append(partial(op.SeedThresholdValue.unregisterDirty, self.updateSeedGui))
        self.__cleanup_fns.append(partial(op.SeedThresholdValue.unregisterReady, self.updateSeedGui))
        self.__cleanup_fns.append(partial(op.SeedThresholdValue.unregisterUnready, self.updateSeedGui))
        self.__cleanup_fns.append(partial(op.MinSeedSize.unregisterDirty, self.updateSeedGui))
        self.__cleanup_fns.append(partial(op.InputChannelIndexes.unregisterDirty, self.updateInputChannelGui))
        self.__cleanup_fns.append(partial(op.InputImage.unregisterDirty, self.updateInputChannelGui))
开发者ID:jenspetersen,项目名称:ilastik,代码行数:52,代码来源:vigraWatershedViewerGui.py

示例3: __init__

    def __init__( self, workflow = [], parent = None, flags = QtCore.Qt.WindowFlags(0), sideSplitterSizePolicy=SideSplitterSizePolicy.Manual ):
        QMainWindow.__init__(self, parent = parent, flags = flags )
        # Register for thunk events (easy UI calls from non-GUI threads)
        self.thunkEventHandler = ThunkEventHandler(self)

        self._sideSplitterSizePolicy = sideSplitterSizePolicy

        self.projectManager = ProjectManager()
        
        import inspect, os
        ilastikShellFilePath = os.path.dirname(inspect.getfile(inspect.currentframe()))
        uic.loadUi( ilastikShellFilePath + "/ui/ilastikShell.ui", self )
        self._applets = []
        self.appletBarMapping = {}

        self.setAttribute(Qt.WA_AlwaysShowToolTips)
        
        if 'Ubuntu' in platform.platform():
            # Native menus are prettier, but aren't working on Ubuntu at this time (Qt 4.7, Ubuntu 11)
            self.menuBar().setNativeMenuBar(False)

        (self._projectMenu, self._shellActions) = self._createProjectMenu()
        self._settingsMenu = self._createSettingsMenu()
        self.menuBar().addMenu( self._projectMenu )
        self.menuBar().addMenu( self._settingsMenu )

        self.updateShellProjectDisplay()
        
        self.progressDisplayManager = ProgressDisplayManager(self.statusBar)

        self.appletBar.expanded.connect(self.handleAppleBarItemExpanded)
        self.appletBar.clicked.connect(self.handleAppletBarClick)
        self.appletBar.setVerticalScrollMode( QAbstractItemView.ScrollPerPixel )
        
        # By default, make the splitter control expose a reasonable width of the applet bar
        self.mainSplitter.setSizes([300,1])
        
        self.currentAppletIndex = 0

        self.currentImageIndex = -1
        self.populatingImageSelectionCombo = False
        self.imageSelectionCombo.currentIndexChanged.connect( self.changeCurrentInputImageIndex )
        
        self.enableWorkflow = False # Global mask applied to all applets
        self._controlCmds = []      # Track the control commands that have been issued by each applet so they can be popped.
        self._disableCounts = []    # Controls for each applet can be disabled by his peers.
                                    # No applet can be enabled unless his disableCount == 0

        # Add all the applets from the workflow
        for app in workflow.applets:
            self.addApplet(app)
        self.workflow = workflow
开发者ID:kemaleren,项目名称:ilastik,代码行数:52,代码来源:ilastikShell.py

示例4: __init__

    def __init__(self, parentApplet, croppingSlots, topLevelOperatorView, drawerUiPath=None, rawInputSlot=None, crosshair=True):
        """
        Constructor.

        :param croppingSlots: Provides the slots needed for sourcing/sinking crop data.  See CroppingGui.CroppingSlots
                              class source for details.
        :param topLevelOperatorView: is provided to the LayerViewerGui (the base class)
        :param drawerUiPath: can be given if you provide an extended drawer UI file.  Otherwise a default one is used.
        :param rawInputSlot: Data from the rawInputSlot parameter will be displayed directly underneath the elements
                             (if provided).
        """

        # Do we have all the slots we need?
        assert isinstance(croppingSlots, CroppingGui.CroppingSlots)
        assert croppingSlots.cropInput is not None, "Missing a required slot."
        assert croppingSlots.cropOutput is not None, "Missing a required slot."
        assert croppingSlots.cropEraserValue is not None, "Missing a required slot."
        assert croppingSlots.cropDelete is not None, "Missing a required slot."
        assert croppingSlots.cropNames is not None, "Missing a required slot."
        assert croppingSlots.cropsAllowed is not None, "Missing a required slot."

        self.__cleanup_fns = []
        self._croppingSlots = croppingSlots
        self._minCropNumber = 0
        self._maxCropNumber = 99 #100 or 255 is reserved for eraser

        self._rawInputSlot = rawInputSlot

        self.topLevelOperatorView.Crops.notifyDirty( bind(self._updateCropList) )
        self.topLevelOperatorView.Crops.notifyDirty( bind(self._updateCropList) )
        self.__cleanup_fns.append( partial( self.topLevelOperatorView.Crops.unregisterDirty, bind(self._updateCropList) ) )
        
        self._colorTable16 = colortables.default16_new
        self._programmaticallyRemovingCrops = False

        self._initCropUic(drawerUiPath)

        self._maxCropNumUsed = 0

        self._allowDeleteLastCropOnly = False
        self.__initShortcuts()
        # Init base class
        super(CroppingGui, self).__init__(parentApplet,
                                          topLevelOperatorView,
                                          [croppingSlots.cropInput, croppingSlots.cropOutput],
                                          crosshair=crosshair)
        self._croppingSlots.cropEraserValue.setValue(self.editor.brushingModel.erasingNumber)

        # Register for thunk events (easy UI calls from non-GUI threads)
        self.thunkEventHandler = ThunkEventHandler(self)
开发者ID:ilastik,项目名称:ilastik,代码行数:50,代码来源:croppingGui.py

示例5: __init__

    def __init__(self, topLevelOperatorView):
        drawerUiPath = os.path.join( os.path.split(__file__)[0], 'splitBodyCarvingDrawer.ui' )
        super( SplitBodyCarvingGui, self ).__init__(topLevelOperatorView, drawerUiPath=drawerUiPath)
        self._splitInfoWidget = BodySplitInfoWidget(self, self.topLevelOperatorView)
        self._splitInfoWidget.navigationRequested.connect( self._handleNavigationRequest )
        self._labelControlUi.annotationWindowButton.pressed.connect( self._splitInfoWidget.show )
        
        # Hide all controls related to uncertainty; they aren't used in this applet
        self._labelControlUi.uncertaintyLabel.hide()
        self._labelControlUi.uncertaintyCombo.hide()
        self._labelControlUi.pushButtonUncertaintyFG.hide()
        self._labelControlUi.pushButtonUncertaintyBG.hide()
        
        # Hide manual save buttons; user must use the annotation window to save/load objects
        self._labelControlUi.saveControlLabel.hide()
        self._labelControlUi.save.hide()
        self._labelControlUi.saveAs.hide()
        self._labelControlUi.namesButton.hide()

        self.thunkEventHandler = ThunkEventHandler(self)

        fragmentColors = [ QColor(0,0,0,0), # transparent (background)
                           QColor(0, 255, 255),   # cyan
                           QColor(255, 0, 255),   # magenta
                           QColor(0, 0, 128),     # navy
                           QColor(165,  42,  42), # brown        
                           QColor(255, 105, 180), # hot pink
                           QColor(255, 165, 0),   # orange
                           QColor(173, 255,  47), # green-yellow
                           QColor(102, 205, 170), # dark aquamarine
                           QColor(128,0, 128),    # purple
                           QColor(240, 230, 140), # khaki
                           QColor(192, 192, 192), # silver
                           QColor(69, 69, 69) ]   # dark grey

        self._fragmentColors = fragmentColors

        # In this workflow, you aren't allowed to make brushstrokes unless there is a "current fragment"
        def handleEditingFragmentChange(slot, *args):
            if slot.value == "":
                self._changeInteractionMode(Tool.Navigation)
            else:
                self._changeInteractionMode(Tool.Paint)
            self._labelControlUi.paintToolButton.setEnabled( slot.value != "" )
            self._labelControlUi.eraserToolButton.setEnabled( slot.value != "" )
            self._labelControlUi.labelListView.setEnabled( slot.value != "" )
        topLevelOperatorView.CurrentEditingFragment.notifyDirty( handleEditingFragmentChange )
        handleEditingFragmentChange(topLevelOperatorView.CurrentEditingFragment)
开发者ID:JensNRAD,项目名称:ilastik_public,代码行数:48,代码来源:splitBodyCarvingGui.py

示例6: __init__

    def __init__(self, labelingSlots, topLevelOperatorView, drawerUiPath=None, rawInputSlot=None, crosshair=True):
        """
        Constructor.

        :param labelingSlots: Provides the slots needed for sourcing/sinking label data.  See LabelingGui.LabelingSlots
                              class source for details.
        :param topLevelOperatorView: is provided to the LayerViewerGui (the base class)
        :param drawerUiPath: can be given if you provide an extended drawer UI file.  Otherwise a default one is used.
        :param rawInputSlot: Data from the rawInputSlot parameter will be displayed directly underneath the elements
                             (if provided).
        """

        # Do have have all the slots we need?
        assert isinstance(labelingSlots, LabelingGui.LabelingSlots)
        assert all([v is not None for v in labelingSlots.__dict__.values()])

        self._labelingSlots = labelingSlots
        self._minLabelNumber = 0
        self._maxLabelNumber = 99  # 100 or 255 is reserved for eraser

        self._rawInputSlot = rawInputSlot

        self._labelingSlots.maxLabelValue.notifyDirty(bind(self._updateLabelList))

        self._colorTable16 = self._createDefault16ColorColorTable()
        self._programmaticallyRemovingLabels = False

        if drawerUiPath is None:
            # Default ui file
            drawerUiPath = os.path.split(__file__)[0] + "/labelingDrawer.ui"
        self._initLabelUic(drawerUiPath)

        # Init base class
        super(LabelingGui, self).__init__(
            topLevelOperatorView, [labelingSlots.labelInput, labelingSlots.labelOutput], crosshair=crosshair
        )

        self.__initShortcuts()
        self._labelingSlots.labelEraserValue.setValue(self.editor.brushingModel.erasingNumber)

        # Register for thunk events (easy UI calls from non-GUI threads)
        self.thunkEventHandler = ThunkEventHandler(self)
        self._changeInteractionMode(Tool.Navigation)
开发者ID:jennyhong,项目名称:ilastik,代码行数:43,代码来源:labelingGui.py

示例7: __init__

    def __init__(self, parentApplet, topLevelOperatorView):
        """
        """
        super(VigraWatershedViewerGui, self).__init__( parentApplet, topLevelOperatorView )
        self.topLevelOperatorView = topLevelOperatorView
        op = self.topLevelOperatorView
        
        # Init padding gui updates
        blockPadding = PreferencesManager().get( 'vigra watershed viewer', 'block padding', 10)
        op.WatershedPadding.notifyDirty( self.updatePaddingGui )
        op.WatershedPadding.setValue( blockPadding )
        self.updatePaddingGui()
        
        # Init block shape gui updates
        cacheBlockShape = PreferencesManager().get( 'vigra watershed viewer', 'cache block shape', (256, 10))
        op.CacheBlockShape.notifyDirty( self.updateCacheBlockGui )
        op.CacheBlockShape.setValue( tuple(cacheBlockShape) )
        self.updateCacheBlockGui()

        # Init seeds gui updates
        op.SeedThresholdValue.notifyDirty( self.updateSeedGui )
        op.SeedThresholdValue.notifyReady( self.updateSeedGui )
        op.SeedThresholdValue.notifyUnready( self.updateSeedGui )
        op.MinSeedSize.notifyDirty( self.updateSeedGui )
        self.updateSeedGui()
        
        # Init input channel gui updates
        op.InputChannelIndexes.notifyDirty( self.updateInputChannelGui )
        op.InputImage.notifyMetaChanged( bind(self.updateInputChannelGui) )
        self.updateInputChannelGui()

        self.thunkEventHandler = ThunkEventHandler(self)
        
        # Remember to unsubscribe during shutdown
        self.__cleanup_fns = []
        self.__cleanup_fns.append( partial( op.WatershedPadding.unregisterDirty, self.updatePaddingGui ) )
        self.__cleanup_fns.append( partial( op.CacheBlockShape.unregisterDirty, self.updateCacheBlockGui ) )
        self.__cleanup_fns.append( partial( op.SeedThresholdValue.unregisterDirty, self.updateSeedGui ) )
        self.__cleanup_fns.append( partial( op.SeedThresholdValue.unregisterReady, self.updateSeedGui ) )
        self.__cleanup_fns.append( partial( op.SeedThresholdValue.unregisterUnready, self.updateSeedGui ) )
        self.__cleanup_fns.append( partial( op.MinSeedSize.unregisterDirty, self.updateSeedGui ) )
        self.__cleanup_fns.append( partial( op.InputChannelIndexes.unregisterDirty, self.updateInputChannelGui ) )
        self.__cleanup_fns.append( partial( op.InputImage.unregisterDirty, self.updateInputChannelGui ) )
开发者ID:CVML,项目名称:ilastik,代码行数:43,代码来源:vigraWatershedViewerGui.py

示例8: __init__

    def __init__(self, parentApplet, topLevelOperatorView):
        """
        """
        super(VigraWatershedViewerGui, self).__init__( parentApplet, topLevelOperatorView )
        self.topLevelOperatorView = topLevelOperatorView
        
        self.topLevelOperatorView.FreezeCache.setValue(True)
        self.topLevelOperatorView.OverrideLabels.setValue( { 0: (0,0,0,0) } )

        # Default settings (will be overwritten by serializer)
        self.topLevelOperatorView.InputChannelIndexes.setValue( [] )
        self.topLevelOperatorView.SeedThresholdValue.setValue( 0.0 )
        self.topLevelOperatorView.MinSeedSize.setValue( 0 )

        # Init padding gui updates
        blockPadding = PreferencesManager().get( 'vigra watershed viewer', 'block padding', 10)
        self.topLevelOperatorView.WatershedPadding.notifyDirty( self.updatePaddingGui )
        self.topLevelOperatorView.WatershedPadding.setValue( blockPadding )
        self.updatePaddingGui()
        
        # Init block shape gui updates
        cacheBlockShape = PreferencesManager().get( 'vigra watershed viewer', 'cache block shape', (256, 10))
        self.topLevelOperatorView.CacheBlockShape.notifyDirty( self.updateCacheBlockGui )
        self.topLevelOperatorView.CacheBlockShape.setValue( tuple(cacheBlockShape) )
        self.updateCacheBlockGui()

        # Init seeds gui updates
        self.topLevelOperatorView.SeedThresholdValue.notifyDirty( self.updateSeedGui )
        self.topLevelOperatorView.SeedThresholdValue.notifyReady( self.updateSeedGui )
        self.topLevelOperatorView.SeedThresholdValue.notifyUnready( self.updateSeedGui )
        self.topLevelOperatorView.MinSeedSize.notifyDirty( self.updateSeedGui )
        self.updateSeedGui()
        
        # Init input channel gui updates
        self.topLevelOperatorView.InputChannelIndexes.notifyDirty( self.updateInputChannelGui )
        self.topLevelOperatorView.InputChannelIndexes.setValue( [0] )
        self.topLevelOperatorView.InputImage.notifyMetaChanged( bind(self.updateInputChannelGui) )
        self.updateInputChannelGui()

        self.thunkEventHandler = ThunkEventHandler(self)
开发者ID:kumartr,项目名称:ilastik,代码行数:40,代码来源:vigraWatershedViewerGui.py

示例9: __init__

    def __init__(self, labelingSlots, topLevelOperator, drawerUiPath=None, rawInputSlot=None ):
        """
        See LabelingSlots class (above) for expected type of labelingSlots parameter.
        
        observedSlots is the same as in the LayerViewer constructor.
        drawerUiPath can be given if you provide an extended drawer UI file.  Otherwise a default one is used.
        Data from the rawInputSlot parameter will be displayed directly underneatch the labels (if provided).
        """
        # Do have have all the slots we need?
        assert isinstance(labelingSlots, LabelingGui.LabelingSlots)
        assert all( [v is not None for v in labelingSlots.__dict__.values()] )
       
        self._minLabelNumber = 0
        self._maxLabelNumber = 99 #100 or 255 is reserved for eraser

        self._rawInputSlot = rawInputSlot
        
        # Init base class
        super(LabelingGui, self).__init__( topLevelOperator )

        self._labelingSlots = labelingSlots
        self._labelingSlots.labelEraserValue.setValue(self.editor.brushingModel.erasingNumber)
        self._labelingSlots.maxLabelValue.notifyDirty( bind(self.updateLabelList) )

        # Register for thunk events (easy UI calls from non-GUI threads)
        self.thunkEventHandler = ThunkEventHandler(self)

        self._colorTable16 = self._createDefault16ColorColorTable()
        self._programmaticallyRemovingLabels = False
        
        if drawerUiPath is None:
            # Default ui file
            drawerUiPath = os.path.split(__file__)[0] + '/labelingDrawer.ui'
        self.initLabelUic(drawerUiPath)
        
        self.changeInteractionMode(Tool.Navigation)
        
        self.__initShortcuts()
开发者ID:LimpingTwerp,项目名称:applet-workflows,代码行数:38,代码来源:labelingGui.py

示例10: IlastikShell

class IlastikShell( QMainWindow ):
    """
    The GUI's main window.  Simply a standard 'container' GUI for one or more applets.
    """


    def __init__( self, workflow = [], parent = None, flags = QtCore.Qt.WindowFlags(0), sideSplitterSizePolicy=SideSplitterSizePolicy.Manual ):
        QMainWindow.__init__(self, parent = parent, flags = flags )
        # Register for thunk events (easy UI calls from non-GUI threads)
        self.thunkEventHandler = ThunkEventHandler(self)

        self._sideSplitterSizePolicy = sideSplitterSizePolicy

        self.projectManager = ProjectManager()
        
        import inspect, os
        ilastikShellFilePath = os.path.dirname(inspect.getfile(inspect.currentframe()))
        uic.loadUi( ilastikShellFilePath + "/ui/ilastikShell.ui", self )
        self._applets = []
        self.appletBarMapping = {}

        self.setAttribute(Qt.WA_AlwaysShowToolTips)
        
        if 'Ubuntu' in platform.platform():
            # Native menus are prettier, but aren't working on Ubuntu at this time (Qt 4.7, Ubuntu 11)
            self.menuBar().setNativeMenuBar(False)

        (self._projectMenu, self._shellActions) = self._createProjectMenu()
        self._settingsMenu = self._createSettingsMenu()
        self.menuBar().addMenu( self._projectMenu )
        self.menuBar().addMenu( self._settingsMenu )

        self.updateShellProjectDisplay()
        
        self.progressDisplayManager = ProgressDisplayManager(self.statusBar)

        for applet in workflow:
            self.addApplet(applet)

        self.appletBar.expanded.connect(self.handleAppleBarItemExpanded)
        self.appletBar.clicked.connect(self.handleAppletBarClick)
        self.appletBar.setVerticalScrollMode( QAbstractItemView.ScrollPerPixel )
        
        # By default, make the splitter control expose a reasonable width of the applet bar
        self.mainSplitter.setSizes([300,1])
        
        self.currentAppletIndex = 0

        self.currentImageIndex = -1
        self.populatingImageSelectionCombo = False
        self.imageSelectionCombo.currentIndexChanged.connect( self.changeCurrentInputImageIndex )
        
        self.enableWorkflow = False # Global mask applied to all applets
        self._controlCmds = []      # Track the control commands that have been issued by each applet so they can be popped.
        self._disableCounts = []    # Controls for each applet can be disabled by his peers.
                                    # No applet can be enabled unless his disableCount == 0

        
    def _createProjectMenu(self):
        # Create a menu for "General" (non-applet) actions
        menu = QMenu("&Project", self)

        shellActions = ShellActions()

        # Menu item: New Project
        shellActions.newProjectAction = menu.addAction("&New Project...")
        shellActions.newProjectAction.setShortcuts( QKeySequence.New )
        shellActions.newProjectAction.triggered.connect(self.onNewProjectActionTriggered)

        # Menu item: Open Project 
        shellActions.openProjectAction = menu.addAction("&Open Project...")
        shellActions.openProjectAction.setShortcuts( QKeySequence.Open )
        shellActions.openProjectAction.triggered.connect(self.onOpenProjectActionTriggered)

        # Menu item: Save Project
        shellActions.saveProjectAction = menu.addAction("&Save Project")
        shellActions.saveProjectAction.setShortcuts( QKeySequence.Save )
        shellActions.saveProjectAction.triggered.connect(self.onSaveProjectActionTriggered)

        # Menu item: Save Project As
        shellActions.saveProjectAsAction = menu.addAction("&Save Project As...")
        shellActions.saveProjectAsAction.setShortcuts( QKeySequence.SaveAs )
        shellActions.saveProjectAsAction.triggered.connect(self.onSaveProjectAsActionTriggered)

        # Menu item: Save Project Snapshot
        shellActions.saveProjectSnapshotAction = menu.addAction("&Take Snapshot...")
        shellActions.saveProjectSnapshotAction.triggered.connect(self.onSaveProjectSnapshotActionTriggered)

        # Menu item: Import Project
        shellActions.importProjectAction = menu.addAction("&Import Project...")
        shellActions.importProjectAction.triggered.connect(self.onImportProjectActionTriggered)

        # Menu item: Quit
        shellActions.quitAction = menu.addAction("&Quit")
        shellActions.quitAction.setShortcuts( QKeySequence.Quit )
        shellActions.quitAction.triggered.connect(self.onQuitActionTriggered)
        shellActions.quitAction.setShortcut( QKeySequence.Quit )
        
        return (menu, shellActions)
    
#.........这里部分代码省略.........
开发者ID:LimpingTwerp,项目名称:applet-workflows,代码行数:101,代码来源:ilastikShell.py

示例11: LabelingGui


#.........这里部分代码省略.........
            self.labelDelete = None # labelDelete.setValue(xxx)
            # Slot that contains the maximum label value (for all images)
            self.maxLabelValue = None # maxLabelValue.value
            
            # Slot to specify which images the user is allowed to label.
            self.labelsAllowed = None # labelsAllowed[image_index].value == True

    @traceLogged(traceLogger)
    def __init__(self, labelingSlots, topLevelOperator, drawerUiPath=None, rawInputSlot=None ):
        """
        See LabelingSlots class (above) for expected type of labelingSlots parameter.
        
        observedSlots is the same as in the LayerViewer constructor.
        drawerUiPath can be given if you provide an extended drawer UI file.  Otherwise a default one is used.
        Data from the rawInputSlot parameter will be displayed directly underneatch the labels (if provided).
        """
        # Do have have all the slots we need?
        assert isinstance(labelingSlots, LabelingGui.LabelingSlots)
        assert all( [v is not None for v in labelingSlots.__dict__.values()] )
       
        self._minLabelNumber = 0
        self._maxLabelNumber = 99 #100 or 255 is reserved for eraser

        self._rawInputSlot = rawInputSlot
        
        # Init base class
        super(LabelingGui, self).__init__( topLevelOperator )

        self._labelingSlots = labelingSlots
        self._labelingSlots.labelEraserValue.setValue(self.editor.brushingModel.erasingNumber)
        self._labelingSlots.maxLabelValue.notifyDirty( bind(self.updateLabelList) )

        # Register for thunk events (easy UI calls from non-GUI threads)
        self.thunkEventHandler = ThunkEventHandler(self)

        self._colorTable16 = self._createDefault16ColorColorTable()
        self._programmaticallyRemovingLabels = False
        
        if drawerUiPath is None:
            # Default ui file
            drawerUiPath = os.path.split(__file__)[0] + '/labelingDrawer.ui'
        self.initLabelUic(drawerUiPath)
        
        self.changeInteractionMode(Tool.Navigation)
        
        self.__initShortcuts()

    @traceLogged(traceLogger)
    def initLabelUic(self, drawerUiPath):
        _labelControlUi = uic.loadUi(drawerUiPath)

        # We own the applet bar ui
        self._labelControlUi = _labelControlUi

        # Initialize the label list model
        model = LabelListModel()
        _labelControlUi.labelListView.setModel(model)
        _labelControlUi.labelListModel=model
        _labelControlUi.labelListModel.rowsRemoved.connect(self.onLabelRemoved)
        _labelControlUi.labelListModel.labelSelected.connect(self.onLabelSelected)
        
        @traceLogged(traceLogger)
        def onDataChanged(topLeft, bottomRight):
            """Handle changes to the label list selections."""
            firstRow = topLeft.row()
            lastRow  = bottomRight.row()
开发者ID:LimpingTwerp,项目名称:applet-workflows,代码行数:67,代码来源:labelingGui.py

示例12: LabelingGui


#.........这里部分代码省略.........
        assert labelingSlots.labelNames is not None, "Missing a required slot."

        self.__cleanup_fns = []

        self._labelingSlots = labelingSlots
        self._minLabelNumber = 0
        self._maxLabelNumber = 99 #100 or 255 is reserved for eraser

        self._rawInputSlot = rawInputSlot

        self._labelingSlots.labelNames.notifyDirty(bind(self._updateLabelList))
        self.__cleanup_fns.append(partial(self._labelingSlots.labelNames.unregisterDirty, bind(self._updateLabelList)))
        self._colorTable16 = colortables.default16_new
        self._programmaticallyRemovingLabels = False

        if drawerUiPath is None:
            # Default ui file
            drawerUiPath = os.path.split(__file__)[0] + '/labelingDrawer.ui'
        self._initLabelUic(drawerUiPath)

        # Init base class
        super(LabelingGui, self).__init__(parentApplet,
                                          topLevelOperatorView,
                                          [labelingSlots.labelInput, labelingSlots.labelOutput],
                                          crosshair=crosshair,
                                          is_3d_widget_visible=is_3d_widget_visible)

        self.__initShortcuts()
        self._labelingSlots.labelEraserValue.setValue(self.editor.brushingModel.erasingNumber)
        self._allowDeleteLastLabelOnly = False
        self._forceAtLeastTwoLabels = False

        # Register for thunk events (easy UI calls from non-GUI threads)
        self.thunkEventHandler = ThunkEventHandler(self)
        self._changeInteractionMode(Tool.Navigation)

    def _initLabelUic(self, drawerUiPath):
        _labelControlUi = uic.loadUi(drawerUiPath)

        # We own the applet bar ui
        self._labelControlUi = _labelControlUi

        # Initialize the label list model
        model = LabelListModel()
        _labelControlUi.labelListView.setModel(model)
        _labelControlUi.labelListModel=model
        _labelControlUi.labelListModel.rowsRemoved.connect(self._onLabelRemoved)
        _labelControlUi.labelListModel.elementSelected.connect(self._onLabelSelected)

        def handleClearRequested(row, name):
            selection = QMessageBox.warning(self, "Clear labels?",
                          "All '{}' brush strokes will be erased.  Are you sure?"
                          .format(name),
                          QMessageBox.Ok | QMessageBox.Cancel)
            if selection != QMessageBox.Ok:
                return

            # This only works if the top-level operator has a 'clearLabel' function.
            self.topLevelOperatorView.clearLabel(row+1)

        _labelControlUi.labelListView.clearRequested.connect(handleClearRequested)

        def handleLabelMergeRequested(from_row, from_name, into_row, into_name):
            from_label = from_row+1
            into_label = into_row+1
            selection = QMessageBox.warning(self, "Merge labels?",
开发者ID:ilastik,项目名称:ilastik,代码行数:67,代码来源:labelingGui.py

示例13: CroppingGui


#.........这里部分代码省略.........
        assert croppingSlots.cropEraserValue is not None, "Missing a required slot."
        assert croppingSlots.cropDelete is not None, "Missing a required slot."
        assert croppingSlots.cropNames is not None, "Missing a required slot."
        assert croppingSlots.cropsAllowed is not None, "Missing a required slot."

        self.__cleanup_fns = []
        self._croppingSlots = croppingSlots
        self._minCropNumber = 0
        self._maxCropNumber = 99 #100 or 255 is reserved for eraser

        self._rawInputSlot = rawInputSlot

        self.topLevelOperatorView.Crops.notifyDirty( bind(self._updateCropList) )
        self.topLevelOperatorView.Crops.notifyDirty( bind(self._updateCropList) )
        self.__cleanup_fns.append( partial( self.topLevelOperatorView.Crops.unregisterDirty, bind(self._updateCropList) ) )
        
        self._colorTable16 = colortables.default16_new
        self._programmaticallyRemovingCrops = False

        self._initCropUic(drawerUiPath)

        self._maxCropNumUsed = 0

        self._allowDeleteLastCropOnly = False
        self.__initShortcuts()
        # Init base class
        super(CroppingGui, self).__init__(parentApplet,
                                          topLevelOperatorView,
                                          [croppingSlots.cropInput, croppingSlots.cropOutput],
                                          crosshair=crosshair)
        self._croppingSlots.cropEraserValue.setValue(self.editor.brushingModel.erasingNumber)

        # Register for thunk events (easy UI calls from non-GUI threads)
        self.thunkEventHandler = ThunkEventHandler(self)

    def _initCropUic(self, drawerUiPath):

        self.cropSelectionWidget = CropSelectionWidget()

        self._cropControlUi = self.cropSelectionWidget

        # Initialize the crop list model
        model = CropListModel()
        self._cropControlUi.cropListView.setModel(model)
        self._cropControlUi.cropListModel=model
        self._cropControlUi.cropListModel.rowsRemoved.connect(self._onCropRemoved)
        self._cropControlUi.cropListModel.elementSelected.connect(self._onCropSelected)
        self._cropControlUi.cropListModel.dataChanged.connect(self.onCropListDataChanged)
        self.toolButtons = None

    def _initCropListView(self):
        if self.topLevelOperatorView.Crops.value != {}:
            self._cropControlUi.cropListModel=CropListModel()
            crops = self.topLevelOperatorView.Crops.value
            for key in sorted(crops):
                newRow = self._cropControlUi.cropListModel.rowCount()
                crop = Crop(
                        key,
                        [(crops[key]["time"][0],crops[key]["starts"][0],crops[key]["starts"][1],crops[key]["starts"][2]),(crops[key]["time"][1],crops[key]["stops"][0],crops[key]["stops"][1],crops[key]["stops"][2])],
                        QColor(crops[key]["cropColor"][0],crops[key]["cropColor"][1],crops[key]["cropColor"][2]),
                        pmapColor=QColor(crops[key]["pmapColor"][0],crops[key]["pmapColor"][1],crops[key]["pmapColor"][2])
                )
                self._cropControlUi.cropListModel.insertRow( newRow, crop )

            self._cropControlUi.cropListModel.elementSelected.connect(self._onCropSelected)
            self._cropControlUi.cropListView.setModel(self._cropControlUi.cropListModel)
开发者ID:ilastik,项目名称:ilastik,代码行数:67,代码来源:croppingGui.py

示例14: VigraWatershedViewerGui

class VigraWatershedViewerGui(LayerViewerGui):
    """
    """

    ###########################################
    ### AppletGuiInterface Concrete Methods ###
    ###########################################

    def appletDrawer(self):
        return self.getAppletDrawerUi()

    def stopAndCleanUp(self):
        # Unsubscribe to all signals
        for fn in self.__cleanup_fns:
            fn()

    # (Other methods already provided by our base class)

    ###########################################
    ###########################################

    def __init__(self, parentApplet, topLevelOperatorView):
        """
        """
        super(VigraWatershedViewerGui, self).__init__(parentApplet, topLevelOperatorView)
        self.topLevelOperatorView = topLevelOperatorView
        op = self.topLevelOperatorView

        op.FreezeCache.setValue(True)
        op.OverrideLabels.setValue({0: (0, 0, 0, 0)})

        # Default settings (will be overwritten by serializer)
        op.InputChannelIndexes.setValue([])
        op.SeedThresholdValue.setValue(0.0)
        op.MinSeedSize.setValue(0)

        # Init padding gui updates
        blockPadding = PreferencesManager().get("vigra watershed viewer", "block padding", 10)
        op.WatershedPadding.notifyDirty(self.updatePaddingGui)
        op.WatershedPadding.setValue(blockPadding)
        self.updatePaddingGui()

        # Init block shape gui updates
        cacheBlockShape = PreferencesManager().get("vigra watershed viewer", "cache block shape", (256, 10))
        op.CacheBlockShape.notifyDirty(self.updateCacheBlockGui)
        op.CacheBlockShape.setValue(tuple(cacheBlockShape))
        self.updateCacheBlockGui()

        # Init seeds gui updates
        op.SeedThresholdValue.notifyDirty(self.updateSeedGui)
        op.SeedThresholdValue.notifyReady(self.updateSeedGui)
        op.SeedThresholdValue.notifyUnready(self.updateSeedGui)
        op.MinSeedSize.notifyDirty(self.updateSeedGui)
        self.updateSeedGui()

        # Init input channel gui updates
        op.InputChannelIndexes.notifyDirty(self.updateInputChannelGui)
        op.InputChannelIndexes.setValue([0])
        op.InputImage.notifyMetaChanged(bind(self.updateInputChannelGui))
        self.updateInputChannelGui()

        self.thunkEventHandler = ThunkEventHandler(self)

        # Remember to unsubscribe during shutdown
        self.__cleanup_fns = []
        self.__cleanup_fns.append(partial(op.WatershedPadding.unregisterDirty, self.updatePaddingGui))
        self.__cleanup_fns.append(partial(op.CacheBlockShape.unregisterDirty, self.updateCacheBlockGui))
        self.__cleanup_fns.append(partial(op.SeedThresholdValue.unregisterDirty, self.updateSeedGui))
        self.__cleanup_fns.append(partial(op.SeedThresholdValue.unregisterReady, self.updateSeedGui))
        self.__cleanup_fns.append(partial(op.SeedThresholdValue.unregisterUnready, self.updateSeedGui))
        self.__cleanup_fns.append(partial(op.MinSeedSize.unregisterDirty, self.updateSeedGui))
        self.__cleanup_fns.append(partial(op.InputChannelIndexes.unregisterDirty, self.updateInputChannelGui))
        self.__cleanup_fns.append(partial(op.InputImage.unregisterDirty, self.updateInputChannelGui))

    def initAppletDrawerUi(self):
        # Load the ui file (find it in our own directory)
        localDir = os.path.split(__file__)[0]
        self._drawer = uic.loadUi(localDir + "/drawer.ui")

        # Input channels
        self._inputChannelCheckboxes = []
        self._inputChannelCheckboxes.append(self._drawer.input_ch0)
        self._inputChannelCheckboxes.append(self._drawer.input_ch1)
        self._inputChannelCheckboxes.append(self._drawer.input_ch2)
        self._inputChannelCheckboxes.append(self._drawer.input_ch3)
        self._inputChannelCheckboxes.append(self._drawer.input_ch4)
        self._inputChannelCheckboxes.append(self._drawer.input_ch5)
        self._inputChannelCheckboxes.append(self._drawer.input_ch6)
        self._inputChannelCheckboxes.append(self._drawer.input_ch7)
        self._inputChannelCheckboxes.append(self._drawer.input_ch8)
        self._inputChannelCheckboxes.append(self._drawer.input_ch9)
        for checkbox in self._inputChannelCheckboxes:
            checkbox.toggled.connect(self.onInputSelectionsChanged)

        # Seed thresholds
        self._drawer.useSeedsCheckbox.toggled.connect(self.onUseSeedsToggled)
        self._drawer.seedThresholdSpinBox.valueChanged.connect(self.onSeedThresholdChanged)

        # Seed size
        self._drawer.seedSizeSpinBox.valueChanged.connect(self.onSeedSizeChanged)
#.........这里部分代码省略.........
开发者ID:jenspetersen,项目名称:ilastik,代码行数:101,代码来源:vigraWatershedViewerGui.py

示例15: SplitBodyCarvingGui

class SplitBodyCarvingGui(CarvingGui):
    
    def __init__(self, topLevelOperatorView):
        drawerUiPath = os.path.join( os.path.split(__file__)[0], 'splitBodyCarvingDrawer.ui' )
        super( SplitBodyCarvingGui, self ).__init__(topLevelOperatorView, drawerUiPath=drawerUiPath)
        self._splitInfoWidget = BodySplitInfoWidget(self, self.topLevelOperatorView)
        self._splitInfoWidget.navigationRequested.connect( self._handleNavigationRequest )
        self._labelControlUi.annotationWindowButton.pressed.connect( self._splitInfoWidget.show )
        
        # Hide all controls related to uncertainty; they aren't used in this applet
        self._labelControlUi.uncertaintyLabel.hide()
        self._labelControlUi.uncertaintyCombo.hide()
        self._labelControlUi.pushButtonUncertaintyFG.hide()
        self._labelControlUi.pushButtonUncertaintyBG.hide()
        
        # Hide manual save buttons; user must use the annotation window to save/load objects
        self._labelControlUi.saveControlLabel.hide()
        self._labelControlUi.save.hide()
        self._labelControlUi.saveAs.hide()
        self._labelControlUi.namesButton.hide()

        self.thunkEventHandler = ThunkEventHandler(self)

        fragmentColors = [ QColor(0,0,0,0), # transparent (background)
                           QColor(0, 255, 255),   # cyan
                           QColor(255, 0, 255),   # magenta
                           QColor(0, 0, 128),     # navy
                           QColor(165,  42,  42), # brown        
                           QColor(255, 105, 180), # hot pink
                           QColor(255, 165, 0),   # orange
                           QColor(173, 255,  47), # green-yellow
                           QColor(102, 205, 170), # dark aquamarine
                           QColor(128,0, 128),    # purple
                           QColor(240, 230, 140), # khaki
                           QColor(192, 192, 192), # silver
                           QColor(69, 69, 69) ]   # dark grey

        self._fragmentColors = fragmentColors

        # In this workflow, you aren't allowed to make brushstrokes unless there is a "current fragment"
        def handleEditingFragmentChange(slot, *args):
            if slot.value == "":
                self._changeInteractionMode(Tool.Navigation)
            else:
                self._changeInteractionMode(Tool.Paint)
            self._labelControlUi.paintToolButton.setEnabled( slot.value != "" )
            self._labelControlUi.eraserToolButton.setEnabled( slot.value != "" )
            self._labelControlUi.labelListView.setEnabled( slot.value != "" )
        topLevelOperatorView.CurrentEditingFragment.notifyDirty( handleEditingFragmentChange )
        handleEditingFragmentChange(topLevelOperatorView.CurrentEditingFragment)

    def _handleNavigationRequest(self, coord3d):
        self.editor.posModel.cursorPos = list(coord3d)
        self.editor.posModel.slicingPos = list(coord3d)
        self.editor.navCtrl.panSlicingViews( list(coord3d), [0,1,2] )
        
        # Navigation change is passed to downstream applets via this special slot
        self.topLevelOperatorView.NavigationCoordinates.setValue( coord3d, check_changed=False )
        
    def labelingContextMenu(self, names, op, position5d):
        return None
#        pos = TinyVector(position5d)
#        sample_roi = (pos, pos+1)
#        ravelerLabelSample = self.topLevelOperatorView.RavelerLabels(*sample_roi).wait()
#        ravelerLabel = ravelerLabelSample[0,0,0,0,0]
#        
#        menu = super( SplitBodyCarvingGui, self ).labelingContextMenu(names, op, position5d)
#        menu.addSeparator()
#        highlightAction = menu.addAction( "Highlight Raveler Object {}".format( ravelerLabel ) )
#        highlightAction.triggered.connect( partial(self.topLevelOperatorView.CurrentRavelerLabel.setValue, ravelerLabel ) )
#
#        # Auto-seed also auto-highlights
#        autoSeedAction = menu.addAction( "Auto-seed background for Raveler Object {}".format( ravelerLabel ) )
#        autoSeedAction.triggered.connect( partial(OpSplitBodyCarving.autoSeedBackground, self.topLevelOperatorView, ravelerLabel ) )
#        autoSeedAction.triggered.connect( partial(self.topLevelOperatorView.CurrentRavelerLabel.setValue, ravelerLabel ) )
#        return menu

    def _update_rendering(self):
        """
        Override from the base class.
        """
        # This update has to be performed in a different thread to avoid a deadlock
        # (Because this function is running in the context of a dirty notification!)
        req = Request( self.__update_rendering )
        def handle_rendering_failure( exc, exc_info ):
            import traceback
            traceback.print_exception(*exc_info)
            sys.stderr.write("Exception raised during volume rendering update.  See traceack above.\n")
        req.notify_failed( handle_rendering_failure )
        req.submit()
    
    def __update_rendering(self):
        if not self.render:
            return

        if not self._labelControlUi.activate3DViewCheckbox.isChecked():
            return 

        rendered_volume_shape = (250, 250, 250)

#.........这里部分代码省略.........
开发者ID:JensNRAD,项目名称:ilastik_public,代码行数:101,代码来源:splitBodyCarvingGui.py


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