Python pyqtgraph 模块,RectROI() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用pyqtgraph.RectROI()

项目:NeoAnalysis    作者:neoanalysis    | 项目源码 | 文件源码
def test_getArrayRegion(transpose=False):
    pr = pg.PolyLineROI([[0, 0], [27, 0], [0, 28]], closed=True)
    pr.setPos(1, 1)
    rois = [
        (pg.ROI([1, 1], [27, 28], pen='y'), 'baseroi'),
        (pg.RectROI([1, 1], [27, 28], pen='y'), 'rectroi'),
        (pg.EllipseROI([1, 1], [27, 28], pen='y'), 'ellipseroi'),
        (pr, 'polylineroi'),
    ]
    for roi, name in rois:
        # For some ROIs, resize should not be used.
        testResize = not isinstance(roi, pg.PolyLineROI)

        origMode = pg.getConfigOption('imageAxisOrder')
        try:
            if transpose:
                pg.setConfigOptions(imageAxisOrder='row-major')
                check_getArrayRegion(roi, 'roi/'+name, testResize, transpose=True)
            else:
                pg.setConfigOptions(imageAxisOrder='col-major')
                check_getArrayRegion(roi, 'roi/'+name, testResize)
        finally:
            pg.setConfigOptions(imageAxisOrder=origMode)
项目:NeoAnalysis    作者:neoanalysis    | 项目源码 | 文件源码
def test_getArrayRegion(transpose=False):
    pr = pg.PolyLineROI([[0, 0], [27, 0], [0, 28]], closed=True)
    pr.setPos(1, 1)
    rois = [
        (pg.ROI([1, 1], [27, 28], pen='y'), 'baseroi'),
        (pg.RectROI([1, 1], [27, 28], pen='y'), 'rectroi'),
        (pg.EllipseROI([1, 1], [27, 28], pen='y'), 'ellipseroi'),
        (pr, 'polylineroi'),
    ]
    for roi, name in rois:
        # For some ROIs, resize should not be used.
        testResize = not isinstance(roi, pg.PolyLineROI)

        origMode = pg.getConfigOption('imageAxisOrder')
        try:
            if transpose:
                pg.setConfigOptions(imageAxisOrder='row-major')
                check_getArrayRegion(roi, 'roi/'+name, testResize, transpose=True)
            else:
                pg.setConfigOptions(imageAxisOrder='col-major')
                check_getArrayRegion(roi, 'roi/'+name, testResize)
        finally:
            pg.setConfigOptions(imageAxisOrder=origMode)
项目:FoundryDataBrowser    作者:ScopeFoundry    | 项目源码 | 文件源码
def setup(self):

        self.ui = self.dockarea = pyqtgraph.dockarea.DockArea()
        self.imview = pg.ImageView()
        self.imview.getView().invertY(True) # uper left origin
        self.dockarea.addDock(name='Full Image', widget=self.imview)

        self.imview_roi = pg.ImageView()
        self.imview_roi.getView().invertY(True) # upper left origin
        self.dockarea.addDock(name='ROI Image', widget=self.imview_roi)

        self.imview_gauss = pg.ImageView()
        self.imview_gauss.getView().invertY(True) # upper left origin
        self.dockarea.addDock(name='Gauss Fit Image', widget=self.imview_gauss)


        self.rect_roi = pg.RectROI([20, 20], [100, 100], pen=(0,9))
        self.imview.getView().addItem(self.rect_roi)        
        self.rect_roi.sigRegionChanged[object].connect(self.on_change_rect_roi)

        self.info_label = QtWidgets.QLabel()
        self.dockarea.addDock(name='info', widget=self.info_label)
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def __init__(self, model):
            sp = model
            _, _, sizeE, sizeN = sp.covariance.noise_coord

            self.patch_size_roi = pg.RectROI(
                pos=(0., 0.),
                size=(sizeE, sizeN),
                sideScalers=True,
                movable=False,
                pen=pen_roi)
            self.patch_size_roi.sigRegionChangeFinished.connect(self.update)

            self._anisotropic = False
            self.components_available = {
                'synthetic_noise': [
                  'Noise',
                  lambda sp: sp.covariance.syntheticNoise(
                    self.sizePatchPx(), anisotropic=self.anisotropic)
                ]}

            self._component = 'synthetic_noise'
            KitePlot.__init__(self, model=model)

            self.addItem(self.patch_size_roi)
项目:picosdk-python-examples    作者:picotech    | 项目源码 | 文件源码
def triggerKnobEnabledChange(self, state):
        self.triggerKnobSource.setEnabled(state)
        self.triggerKnobDirection.setEnabled(state)
        if state:
            if self.triggX is None:
                self.triggX = 0.5
            if self.triggY is None:
                self.triggY = 0
            if self.triggerDiamond is None:
                self.triggerDiamond = pg.RectROI([self.triggX * self.samples / self.ratioBin, self.triggY],
                                                 [0, 0], invertible=True, pen=pg.mkPen(None))
                self.triggerDiamond.sigRegionChanged.connect(self.triggerDiamondUpdate)
                self.viewPlot.addItem(self.triggerDiamond)
        else:
            self.viewPlot.removeItem(self.triggerDiamond)
            self.triggerDiamond = None
        self.triggerReset = True
项目:ScopeFoundry    作者:ScopeFoundry    | 项目源码 | 文件源码
def setup(self):

        #self.ui = self.splitter = QtWidgets.QSplitter()
        #self.ui.setLayout(QtWidgets.QVBoxLayout())
        self.ui = self.dockarea = dockarea.DockArea()
        self.imview = pg.ImageView()
        self.imview.getView().invertY(False) # lower left origin
        #self.splitter.addWidget(self.imview)
        self.dockarea.addDock(name='Image', widget=self.imview)
        self.graph_layout = pg.GraphicsLayoutWidget()
        #self.splitter.addWidget(self.graph_layout)
        self.dockarea.addDock(name='Spec Plot', widget=self.graph_layout)

        self.spec_plot = self.graph_layout.addPlot()
        self.rect_plotdata = self.spec_plot.plot()
        self.point_plotdata = self.spec_plot.plot(pen=(0,9))


        # Rectangle ROI
        self.rect_roi = pg.RectROI([20, 20], [20, 20], pen=(0,9))
        self.rect_roi.addTranslateHandle((0.5,0.5))        
        self.imview.getView().addItem(self.rect_roi)        
        self.rect_roi.sigRegionChanged[object].connect(self.on_change_rect_roi)

        # Point ROI
        self.circ_roi = pg.CircleROI( (0,0), (2,2) , movable=True, pen=(0,9))
        #self.circ_roi.removeHandle(self.circ_roi.getHandles()[0])
        h = self.circ_roi.addTranslateHandle((0.5,.5))
        h.pen = pg.mkPen('r')
        h.update()
        self.imview.getView().addItem(self.circ_roi)
        self.circ_roi.removeHandle(0)
        self.circ_roi_plotline = pg.PlotCurveItem([0], pen=(0,9))
        self.imview.getView().addItem(self.circ_roi_plotline) 
        self.circ_roi.sigRegionChanged[object].connect(self.on_update_circ_roi)

        self.hyperspec_data = None
        self.display_image = None
        self.spec_x_array = None

        self.scan_specific_setup()