Python pyqtgraph.EllipseROI() Examples

The following are 6 code examples of pyqtgraph.EllipseROI(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pyqtgraph , or try the search function .
Example #1
Source File: test_ROI.py    From tf-pose with Apache License 2.0 7 votes vote down vote up
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) 
Example #2
Source File: __init__.py    From finplot with MIT License 6 votes vote down vote up
def remove_last_roi(self):
        if self.rois:
            if isinstance(self.rois[-1], pg.EllipseROI):
                self.removeItem(self.rois[-1])
                self.rois = self.rois[:-1]
                self.draw_ellipse = None
            else:
                h = self.rois[-1].handles[-1]['item']
                self.rois[-1].removeHandle(h)
                if not self.rois[-1].segments:
                    self.removeItem(self.rois[-1])
                    self.rois = self.rois[:-1]
                    self.draw_line = None
            if self.rois:
                if isinstance(self.rois[-1], pg.EllipseROI):
                    self.draw_ellipse = self.rois[-1]
                else:
                    self.draw_line = self.rois[-1]
                    self.set_draw_line_color(draw_line_color)
            return True 
Example #3
Source File: test_ROI.py    From soapy with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #4
Source File: custom_tracking_exp.py    From stytra with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, **kwargs):
        """ """
        super().__init__(**kwargs)

        # We need to initialise the ellipse, add it to the area, and remove
        # the handles from the ellipseROI:
        self.fly_ell = pg.EllipseROI(pos=(0, 0), size=(10, 10), movable=False, pen=None)

        self.display_area.addItem(self.fly_ell)
        [self.fly_ell.removeHandle(h) for h in self.fly_ell.getHandles()]
        self.pre_th = 0 
Example #5
Source File: camera_display.py    From stytra with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, **kwargs):
        """ """
        super().__init__(**kwargs)

        # Draw ROI for eyes region selection:
        self.pre_th = [0, 0]

        self.eye_params = self.experiment.pipeline.eyetrack._params
        self.roi_eyes = pg.ROI(
            pos=self.eye_params.wnd_pos,
            size=self.eye_params.wnd_dim,
            pen=dict(color=(5, 40, 200), width=3),
        )

        self.roi_eyes.addScaleHandle([0, 0], [1, 1])
        self.roi_eyes.addScaleHandle([1, 1], [0, 0])

        self.curves_eyes = [
            pg.EllipseROI(
                pos=(0, 0), size=(10, 10), movable=False, pen=dict(color=k, width=3)
            )
            for k in [(5, 40, 230), (40, 230, 5)]
        ]

        for c in self.curves_eyes:
            self.display_area.addItem(c)
            [c.removeHandle(h) for h in c.getHandles()]

        self.initialise_roi(self.roi_eyes)

        self.setting_param_val = False 
Example #6
Source File: drawroi.py    From suite2p with GNU General Public License v3.0 5 votes vote down vote up
def draw(self, parent, imy, imx, dy, dx):
        roipen = pg.mkPen(self.color, width=3,
                          style=QtCore.Qt.SolidLine)
        self.ROI = pg.EllipseROI([imx, imy], [dx, dy], pen=roipen, removable=True)
        self.ROI.handleSize = 8
        self.ROI.handlePen = roipen
        self.ROI.addScaleHandle([1, 0.5], [0., 0.5])
        self.ROI.addScaleHandle([0.5, 0], [0.5, 1])
        self.ROI.setAcceptedMouseButtons(QtCore.Qt.LeftButton)
        parent.p0.addItem(self.ROI)