def addNew(self): rgn = ptree.Parameter.create(name='region', autoIncrementName=True, renamable=True, removable=True, type='bool', value=True, children=[ dict(name='DB Column', type='str', value='Region'), dict(name='Color', type='color'), ]) self.addChild(rgn) ## find the center of the view view = self.canvas.view center = view.viewRect().center() size = [x * 50 for x in view.viewPixelSize()] pts = [ center, center + pg.Point(size[0], 0), center + pg.Point(0, size[1]) ] roi = pg.PolyLineROI(pts, closed=True) roi.setZValue(1000) view.addItem(roi) rgn.roi = roi roi.rgn = rgn roi.sigRegionChangeFinished.connect(self.regionChanged)
def addROI(self, roiType): pen = pg.mkPen(pg.intColor(len(self.ROIs))) center = self.view.viewRect().center() #print 'camerawindow.py: addROI:: ', self.view.viewPixelSize() size = [x * 50 for x in self.view.viewPixelSize()] if roiType == 'rect': roi = PlotROI(center, size) elif roiType == 'ellipse': roi = pg.EllipseROI(center, size, removable=True) elif roiType == 'polygon': pts = [ center, center + pg.Point(0, size[1]), center + pg.Point(size[0], 0) ] roi = pg.PolyLineROI(pts, closed=True, removable=True) elif roiType == 'ruler': pts = [center, center + pg.Point(size[0], size[1])] roi = RulerROI(pts, removable=True) else: raise ValueError("Invalid ROI type %s" % roiType) roi.setZValue(40000) roi.setPen(pen) self.view.addItem(roi) plot = self.roiPlot.plot(pen=pen) self.ROIs.append({'roi': roi, 'plot': plot, 'vals': [], 'times': []}) roi.sigRemoveRequested.connect(self.removeROI)
def addActiveRegion(self, rgnType): rgn = pTypes.SimpleParameter(name=rgnType, autoIncrementName=True, type='bool', value=True, removable=True, renamable=True) self.params.param('Active Regions').addChild(rgn) pos = self.getViewBox().viewRect().center() size = self.params.param('spacing').value()*4 if rgnType == 'Rectangle': roi = pg.ROI(pos=pos, size=size, angle=self.angle()) roi.addScaleHandle([0, 0], [1, 1]) roi.addScaleHandle([1, 1], [0, 0]) roi.addRotateHandle([0, 1], [0.5, 0.5]) roi.addRotateHandle([1, 0], [0.5, 0.5]) elif rgnType == 'Polygon': roi = pg.PolyLineROI((pos, pos+pg.Point(0,1)*size, pos+pg.Point(1,0)*size), closed=True) else: raise Exception('Not sure how to add region of type:%s' % rgnType) rgn.item = roi self.rgns.append(rgn) self.getViewBox().addItem(roi) roi.sigRegionChanged.connect(self.invalidatePoints) roi.sigRegionChangeFinished.connect(self.stateChangeFinished) rgn.sigValueChanged.connect(self.rgnToggled) self.invalidatePoints() self.stateChangeFinished()