Пример #1
0
 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()
Пример #2
0
    def __init__(self, name, ptSize, **args):
        pg.CrosshairROI.__init__(self, pos=(0,0), size=args.get('size', [ptSize*4]*2), angle=args.get('angle', 0), **args)

        self.name = name

        self.params = pTypes.SimpleParameter(name=self.name, type='bool', value=True, removable=True, renamable=True, children=[
            dict(name='layout', type='list', value=args.get('layout', 'Hexagonal'), values=['Square', 'Hexagonal']),
            dict(name='spacing', type='float', value=args.get('spacing', ptSize), suffix='m', siPrefix=True, bounds=[1e-9, None], step=10e-6),
            dict(name='Active Regions', type='group', addText="Add region...", addList=['Rectangle', 'Polygon'])
        ])
        
        self.params.item = self
        self.params.param('Active Regions').addNew = self.addActiveRegion
        self.rgns = []
        self.pointSize = ptSize
        self._points = np.empty((0,2), dtype=float)
        self._scene = None 
        self._scatter = pg.ScatterPlotItem(pxMode=False, brush=None, antialias=True)
        self._scatter.setParentItem(self)
        self._needScatterUpdate = False
        self.params.param('layout').sigStateChanged.connect(self.invalidatePoints)
        self.params.param('spacing').sigStateChanged.connect(self.invalidatePoints)
        self.params.param('Active Regions').sigChildRemoved.connect(self.rgnRemoved)
        
        self.sigRegionChanged.connect(self.invalidatePoints)
        self.params.sigValueChanged.connect(self.toggled)
        self.params.sigRemoved.connect(self.removed)
Пример #3
0
 def __init__(self, name, ptSize, **args):
     self.name = name
     points = args.get('points', ([0,0], [0,ptSize*3], [ptSize*3,0]))
     pos = (0,0)
     pg.PolygonROI.__init__(self, points, pos)
     self.setZValue(10000000)
     self.params = pTypes.SimpleParameter(name=self.name, type='bool', value=True, removable=True, renamable=True, children=[
     ])
     self.params.item = self
     self.sigRegionChanged.connect(self.rgnChanged)
Пример #4
0
 def __init__(self, name, ptSize, **args):
     self.name = name
     #if 'host' in args:
         #self.host = args.pop('host')
     
     pg.EllipseROI.__init__(self, (0,0), [ptSize] * 2, movable=args.get('movable', True))
     self.aspectLocked = True
     self.overPen = None
     self.underPen = self.pen
     self.setFlag(Qt.QGraphicsItem.ItemIgnoresParentOpacity, True)
     self.params = pTypes.SimpleParameter(name=self.name, type='bool', value=args.get('active', True), removable=True, renamable=True, children=[
     ])
     self.params.item = self
Пример #5
0
    def __init__(self, component):
        QtCore.QObject.__init__(self)
        ### These need to be initialized before the ROI is initialized because they are included in stateCopy(), which is called by ROI initialization.
        # self.name = component.name
        self.component = weakref.ref(component)

        params = [
            dict(name='startTime', type='float', value=0.0, suffix='s', bounds=[0, None], siPrefix=True, step=10e-3),
            dict(name='duration', type='float', value=0.002, suffix='s', bounds=[1e-6, None], siPrefix=True, step=1e-3),
            dict(name='radius', type='float', value=10e-6, suffix='m', siPrefix=True, bounds=[1e-6, None], step=1e-6),
            dict(name='thickness', type='float', value=2e-6, suffix='m', siPrefix=True, bounds=[1e-6, None], step=1e-6),
            dict(name='spacing', type='float', value=0.5e-6, suffix='m', siPrefix=True, step=0.1e-6, bounds=[1e-7, None]),
            dict(name='speed', type='float', readonly=True, value=0, suffix='m/ms', siPrefix=True),
        ]
        self.params = pTypes.SimpleParameter(name='spiral_scan', type='bool', value=True, 
                                             removable=True, renamable=True, children=params)
        self.params.component = self.component  # required by ScanProgram.paramRequestedRemove()

        self.roi = SpiralScanROI(pos=[0.0, 0.0], radius=self.params['radius'])

        self.params.sigTreeStateChanged.connect(self.paramsChanged)
        self.roi.sigRegionChanged.connect(self.roiChanged)
        self.paramsChanged()
Пример #6
0
    def __init__(self, component):
        Qt.QObject.__init__(self)
        self.name = component.name
        ### These need to be initialized before the ROI is initialized because they are included in stateCopy(), which is called by ROI initialization.

        self.params = pTypes.SimpleParameter(name=self.name,
                                             type='bool',
                                             value=True,
                                             removable=True,
                                             renamable=True,
                                             children=[
                                                 dict(name='Length',
                                                      type='float',
                                                      value=1e-5,
                                                      suffix='m',
                                                      siPrefix=True,
                                                      bounds=[1e-6, None],
                                                      step=1e-6),
                                                 dict(name='startTime',
                                                      type='float',
                                                      value=5e-2,
                                                      suffix='s',
                                                      siPrefix=True,
                                                      bounds=[0., None],
                                                      step=1e-2),
                                                 dict(name='sweepSpeed',
                                                      type='float',
                                                      value=1e-6,
                                                      suffix='m/ms',
                                                      siPrefix=True,
                                                      bounds=[1e-8, None],
                                                      minStep=5e-7,
                                                      step=0.5,
                                                      dec=True),
                                                 dict(name='interSweepSpeed',
                                                      type='float',
                                                      value=5e-6,
                                                      suffix='m/ms',
                                                      siPrefix=True,
                                                      bounds=[1e-8, None],
                                                      minStep=5e-7,
                                                      step=0.5,
                                                      dec=True),
                                                 dict(name='nScans',
                                                      type='int',
                                                      value=100,
                                                      bounds=[1, None]),
                                                 dict(name='endTime',
                                                      type='float',
                                                      value=5.5e-1,
                                                      suffix='s',
                                                      siPrefix=True,
                                                      bounds=[0., None],
                                                      step=1e-2,
                                                      readonly=True),
                                             ])
        self.params.component = weakref.ref(component)
        self.roi = MultiLineScanROI(
            [[0.0, 0.0], [self.params['Length'], self.params['Length']]])
        self.roi.sigRegionChangeFinished.connect(self.updateFromROI)
        self.params.sigTreeStateChanged.connect(self.update)