Python pyqtgraph.PolyLineROI() Examples

The following are 4 code examples of pyqtgraph.PolyLineROI(). 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: 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 #3
Source File: tab_scene.py    From kite with GNU General Public License v3.0 5 votes vote down vote up
def addPolyLine(self):
        [[xmin, xmax], [ymin, ymax]] = self.plot.viewRange()
        self.poly_line = pg.PolyLineROI(
            positions=[(xmin+(xmax-xmin)*.4,
                        ymin+(ymax-ymin)*.4),
                       (xmin+(xmax-xmin)*.6,
                        ymin+(ymax-ymin)*.6)],
            pen=pg.mkPen('g', width=2))
        self.plot.addItem(self.poly_line)
        self.updateTransPlot()

        self.poly_line.sigRegionChangeFinished.connect(
            self.updateTransPlot) 
Example #4
Source File: AttributeCharts.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes vote down vote up
def drawScatterplot(self, xvalues, xmin, xmax, yvalues, ymin, ymax, slope, intercept, ids, symbols=None):
        # plot the chart
        if has_pyqtgraph:
            self.scatter = pg.ScatterPlotItem()
            self.plot.clear()
            # each point takes the colour of the map
            if symbols:
                points = []
                for i, id in enumerate(ids):
                    x = xvalues[i]
                    y = yvalues[i]
                    symb = symbols[i]
                    points.append({'pos': (x,y), 'data': id, 'size': 3, 'pen': pg.mkPen(None), 'brush': symb})
                self.scatter.addPoints(points)
            else:
                self.scatter.addPoints(x=xvalues, y=yvalues, data=ids, size=3, pen=pg.mkPen(None), brush=pg.mkBrush(235, 235, 235, 255))
            # selection by direct click
            self.scatter.sigClicked.connect(self.changedScatterplotSelection)
            self.plot.addItem(self.scatter)
            # add the regression line
            self.regress_line = pg.InfiniteLine()
            self.regress_line.setAngle(atan(slope/1) * 180 / 3.1459)
            self.regress_line.setValue((0,intercept))
            self.regress_line.setPen(color='b', width=1)
            if self.show_lines:
                self.plot.addItem(self.regress_line)
            # newfeature: add the selection tool
            #self.roi = pg.PolyLineROI([[xmin, ymin],[xmax, ymin],[xmax, ymax],[xmin, ymax]], closed=True)
            #self.roi.sigRegionChangeFinished.connect(self.changedScatterPlotSelection)
            #self.plot.addItem(self.roi)
            #self.plot.disableAutoRange('xy')

    # allow selection of items in chart and selecting them on the map