示例#1
0
    def __init__(self, display, axes, data=None, names=None, **kwargs):
        for a in axes:
            a.setPen()  # update colour theme

        ImageView.__init__(
            self,
            view=pg.PlotItem(
                axisItems={
                    'bottom': axes[0],
                    'left': axes[1]}))
        PyqtgraphgDisplayBase.__init__(self)
        DisplayWidget.__init__(self, **kwargs)

        self.display = display
        self.moveLayerToNewImage = None
        self.cItems = OrderedDict()  # colorlayerItems

        self.sigTimeChanged.connect(self.display.highlightLayer)

        # for unified access within different widgets:
        self.item = self.imageItem
        self.setTitle = self.view.setTitle

        self._firstTime = True
        self._changed = False
        self._timeline_visible = True
        self._image_redefined = False
        self._moved_layer = None
        self._set_kwargs = {}

        self.opts['discreteTimeLine'] = True



        # TODO: better would be to init imageView with given histrogramAxis
        #      ... but this is easier:
        axes[2].sigLabelChanged.connect(self.setHistogramLabel)
        self.setHistogramLabel(axes[2].labelText)
        axes[2].sigRangeChanged.connect(self.ui.histogram.axis.setRange)
        axes[2].sigFontSizeChanged.connect(self._setHistogramFontSize)

        # hide buttons
        self.ui.roiBtn.hide()
        self.ui.menuBtn.hide()
        # fixed height for time axis:
        self.ui.splitter.setSizes([self.height() - 35, 35])
        self.ui.splitter.setStretchFactor(0, 1)
        # Remove ROI plot:
        self.ui.roiPlot.setMouseEnabled(False, False)
        self.ui.roiPlot.hide()

        #default color set
        #NO: only gray works also with color images
        #self.ui.histogram.item.gradient.loadPreset('flame')
        

        if data is not None:
            self.update(data)
            self.updateView()
示例#2
0
 def restoreState(self, state):
     self.view.vb.setState(state['view'])
     self.ui.histogram.vb.setState(state['histogram'])
     self.ui.histogram.setLevels(*state['histoRegion'])
     self.ui.histogram.gradient.restoreState(state['colorbar'])
     img = state['image']
     if img is not None:
         self.setImage(img, autoRange=False, autoLevels=False, 
                   autoHistogramRange=False)
     DisplayWidget.restoreState(self, state)
示例#3
0
    def __init__(self, display, axes, data=None, names=None, **kwargs):
        for a in axes:
            a.setPen()  # update colour theme

        ImageView.__init__(self,
                           view=pg.PlotItem(axisItems={
                               'bottom': axes[0],
                               'left': axes[1]
                           }))
        PyqtgraphgDisplayBase.__init__(self)
        DisplayWidget.__init__(self, **kwargs)

        self.display = display
        self.moveLayerToNewImage = None
        self.cItems = OrderedDict()  #colorlayerItems

        #for unified access within different widgets:
        self.item = self.imageItem
        self.setTitle = self.view.setTitle

        self._firstTime = True
        self._changed = False
        self._timeline_visible = True
        self._image_redefined = False
        self._moved_layer = None
        self._set_kwargs = {}

        self.setOpts(discreteTimeSteps=True)

        #make splitter an unchangeable small grey line:
        s = self.ui.splitter
        s.handle(1).setEnabled(False)
        s.setStyleSheet("QSplitter::handle{background-color: grey}")
        s.setHandleWidth(2)

        #TODO: better would be to init imageView with given histrogramAxis
        #      ... but this is easier:
        axes[2].sigLabelChanged.connect(self.setHistogramLabel)
        self.setHistogramLabel(axes[2].labelText)
        axes[2].sigRangeChanged.connect(self.ui.histogram.axis.setRange)
        axes[2].sigFontSizeChanged.connect(self._setHistogramFontSize)

        #hide buttons
        self.ui.roiBtn.hide()
        self.ui.normBtn.hide()
        #fixed height for time axis:
        self.ui.splitter.setSizes([self.height() - 35, 35])
        self.ui.splitter.setStretchFactor(0, 1)
        #Remove ROI plot:
        self.ui.roiPlot.setMouseEnabled(False, False)
        self.ui.roiPlot.hide()

        if data is not None:
            self.update(data)
            self.updateView()
示例#4
0
    def restoreState(self, state):
        self.clear()

        self.view.vb.setState(state['view'])
        names = state['layerNames']
        # DATA
        for n, name in enumerate(names):
            x, y = state['%i_x' % n], state['%i_y' % n]
            self.addLayer(name, data=(x, y))

        DisplayWidget.restoreState(self, state)
示例#5
0
 def restoreState(self, state):
     self.view.vb.setState(state['view'])
     self.ui.histogram.vb.setState(state['histogram'])
     self.ui.histogram.setLevels(*state['histoRegion'])
     self.ui.histogram.gradient.restoreState(state['colorbar'])
     img = state['image']
     if img is not None:
         self.setImage(img,
                       autoRange=False,
                       autoLevels=False,
                       autoHistogramRange=False)
     DisplayWidget.restoreState(self, state)
示例#6
0
    def __init__(self, display, axes, data=None, names=None, **kwargs):
        for a in axes:
            a.setPen() # update colour theme
        
        ImageView.__init__(self, view=pg.PlotItem(axisItems={'bottom':axes[0],'left':axes[1]}))
        PyqtgraphgDisplayBase.__init__(self)
        DisplayWidget.__init__(self, **kwargs)
        
        self.display = display
        self.moveLayerToNewImage = None
        self.cItems = OrderedDict() #colorlayerItems

        #for unified access within different widgets:
        self.item = self.imageItem
        self.setTitle = self.view.setTitle

        self._firstTime = True
        self._changed = False
        self._timeline_visible = True
        self._image_redefined = False
        self._moved_layer = None
        self._set_kwargs = {}

        self.setOpts(discreteTimeSteps=True)
        
        #make splitter an unchangeable small grey line:
        s = self.ui.splitter
        s.handle(1).setEnabled(False)
        s.setStyleSheet("QSplitter::handle{background-color: grey}")
        s.setHandleWidth(2)
        
        #TODO: better would be to init imageView with given histrogramAxis
        #      ... but this is easier:
        axes[2].sigLabelChanged.connect(self.setHistogramLabel)
        self.setHistogramLabel(axes[2].labelText)
        axes[2].sigRangeChanged.connect(self.ui.histogram.axis.setRange)
        axes[2].sigFontSizeChanged.connect(self._setHistogramFontSize)
 
        #hide buttons
        self.ui.roiBtn.hide()
        self.ui.normBtn.hide()
        #fixed height for time axis:
        self.ui.splitter.setSizes([self.height()-35, 35])
        self.ui.splitter.setStretchFactor (0, 1)
        #Remove ROI plot:
        self.ui.roiPlot.setMouseEnabled(False, False)
        self.ui.roiPlot.hide()

        if data is not None:
            self.update(data)
            self.updateView()
示例#7
0
 def restoreState(self, state):
     self.view.vb.setState(state['view'])
     self.ui.histogram.vb.setState(state['histogram'])
     self.ui.histogram.setLevels(*state['histoRegion'])
     self.ui.histogram.gradient.restoreState(state['colorbar'])
     img = state['image']
     if img is not None:
         self.setImage(img, autoRange=False, autoLevels=False,
                       autoHistogramRange=False)
     try:
         self.setCurrentIndex(state['currentIndex'])
     except AttributeError:
         # cannot set index, because has no layers
         pass
     DisplayWidget.restoreState(self, state)
示例#8
0
 def saveState(self):
     state = DisplayWidget.saveState(self)
     state['view'] = self.view.vb.getState()
     state['histogram'] = self.ui.histogram.vb.getState()
     state['histoRegion'] = self.ui.histogram.getLevels()
     state['colorbar'] = self.ui.histogram.gradient.saveState()
     state['image'] = self.image
     return state
示例#9
0
 def saveState(self):
     state = DisplayWidget.saveState(self)
     state['view'] = self.view.vb.getState()
     state['layerNames'] = [c.label.text for c in self.curves]
     for n, c in enumerate(self.curves):
         state['%i_x' % n] = c.xData
         state['%i_y' % n] = c.yData
     return state
示例#10
0
 def saveState(self):
     state = DisplayWidget.saveState(self)
     state['view'] = self.view.vb.getState()
     state['histogram'] = self.ui.histogram.vb.getState()
     state['histoRegion'] = self.ui.histogram.getLevels()
     state['colorbar'] = self.ui.histogram.gradient.saveState()
     state['image'] = self.image
     return state
示例#11
0
    def __init__(self, display, axes, data=None, names=None, **kwargs):
        self.display = display

        axisItems = {}
        o = self.axisOrientation
        for n, a in enumerate(axes[:2]):
            a.setOrientation(o[n])
            axisItems[o[n]] = a
            a.setPen()  # update colour theme
        pgPlotWidget.__init__(self, axisItems=axisItems)
        PyqtgraphgDisplayBase.__init__(self)
        DisplayWidget.__init__(self, **kwargs)

        self.view = self.getPlotItem()

        self.addLegend()
        self.curves = []
        # this is mostly used for fast and easy access to all curve values
        # within the Automatic-script:
        self.data = ProxyList()

        if names is not None and data is not None:
            #ADD MULTIPLE LAYERS
            if names is None:
                c = len(data)
                names = [None] * c
            else:
                c = len(names)
            if data is None:
                data = [None] * c
            for i, (d, n) in enumerate(zip(data, names)):

                self.addLayer(n, d, pen=(i, c))

        #UPDATE CURVE NAMES:
        display.stack.sigLayerNameChanged.connect(
            lambda index, txt, self=self: self.curves[index].label.setText(txt
                                                                           ))
示例#12
0
    def __init__(self, display, axes, data=None, names=None, **kwargs):
        self.display = display

        axisItems = {}
        o = self.axisOrientation
        for n, a in enumerate(axes[:2]):
            a.setOrientation(o[n])
            axisItems[o[n]] = a
            a.setPen()  # update colour theme
        pgPlotWidget.__init__(self, axisItems=axisItems)
        PyqtgraphgDisplayBase.__init__(self)
        DisplayWidget.__init__(self, **kwargs)

        self.view = self.getPlotItem()

        self.addLegend()
        self.curves = []
        # this is mostly used for fast and easy access to all curve values
        # within the Automatic-script:
        self.data = ProxyList()

        if names is not None and data is not None:
            # ADD MULTIPLE LAYERS
            if names is None:
                c = len(data)
                names = [None] * c
            else:
                c = len(names)
            if data is None:
                data = [None] * c
            for i, (d, n) in enumerate(zip(data, names)):

                self.addLayer(n, d, pen=(i, c))

        # UPDATE CURVE NAMES:
        display.stack.sigLayerNameChanged.connect(
            lambda index, txt, self=self: self.curves[index].label.setText(txt))
示例#13
0
    def __init__(self, display, axes, data=None, names=None, **kwargs):
        for a in axes:
            a.setPen()  # update colour theme

        ImageView.__init__(
            self, view=pg.PlotItem(
                axisItems={
                    'bottom': axes[0],
                    'left': axes[1]})
        )
        PyqtgraphgDisplayBase.__init__(self)
        DisplayWidget.__init__(self, **kwargs)

        self.display = display
        self.moveLayerToNewImage = None
        self.cItems = OrderedDict()  # colorlayerItems

        self.sigTimeChanged.connect(self.display.highlightLayer)

        # for unified access within different widgets:
        self.item = self.imageItem
        self.setTitle = self.view.setTitle

        self._firstTime = True
        self._changed = False
        self._timeline_visible = True
        self._image_redefined = False
        self._moved_layer = None
        self._set_kwargs = {}

        self.opts['discreteTimeLine'] = True

        # TODO: better would be to init imageView with given histrogramAxis
        #      ... but this is easier:
        axes[2].sigLabelChanged.connect(self.setHistogramLabel)
        self.setHistogramLabel(axes[2].labelText)
        axes[2].sigRangeChanged.connect(self.ui.histogram.axis.setRange)
        axes[2].sigFontSizeChanged.connect(self._setHistogramFontSize)

        # hide buttons
        self.ui.roiBtn.hide()
        self.ui.menuBtn.hide()
        # fixed height for time axis:
        self.ui.splitter.setSizes([self.height() - 35, 35])
        self.ui.splitter.setStretchFactor(0, 1)
        # Remove ROI plot:
        self.ui.roiPlot.setMouseEnabled(False, False)
        self.ui.roiPlot.hide()

        # -------------------
        # Context menu over colorbar histogram:
        vb = self.ui.histogram.vb
        menu = vb.menu
        # remove 'Export...' menu:
        vb.raiseContextMenu = self._cbar_raiseContextMenu
        # remove mouse mode
        menu.removeAction(menu.leftMenu.menuAction())
        # remove redundsant menus:
        menu.removeAction(
            next(a for a in menu.actions() if a.text() == 'X Axis'))
#         menu.removeAction(
#             next(a for a in menu.actions() if 'Export' in a.text()))
        # y-Axis menu
        yAxisAction = next(a for a in menu.actions() if a.text() == 'Y Axis')
        yAxisAction.setText('Scale')
        # connect min-max edit with cbar intensity range change:
        menu.ctrl[-1].minText.editingFinished.connect(self._cbar_updateRange)
        menu.ctrl[-1].maxText.editingFinished.connect(self._cbar_updateRange)
        # add cbar fit:
        menu.addAction('Fit').triggered.connect(self._cbar_fit)