예제 #1
0
    def makeObject(self, host):

        typ = self.type()
        args = self.args()
        if typ == 'plot':
            obj = pg.PlotWidget(name=self.name(), **args)
        elif typ == 'imageView':
            obj = pg.ImageView(**args)
        elif typ == 'canvas':
            obj = Canvas.Canvas(**args)
        elif typ == 'fileInput':
            obj = FileLoader.FileLoader(host.dataManager(), **args)
        #elif typ == 'database':
        #obj = DatabaseGui.DatabaseGui(host.dataManager(), **args)
        elif typ == 'table':
            obj = pg.TableWidget(**args)
        elif typ == 'dataTree':
            obj = pg.DataTreeWidget(**args)
        elif typ == 'parameterTree':
            obj = pg.parametertree.ParameterTree(**args)
        elif typ == 'graphicsView':
            obj = pg.GraphicsView(**args)
        elif typ == 'graphicsLayout':
            obj = pg.GraphicsLayoutWidget(**args)
        elif typ == 'viewBox':
            obj = pg.GraphicsView()
            obj.setCentralItem(pg.ViewBox(**args))
        else:
            raise Exception(
                "Cannot automatically create element '%s' (type=%s)" %
                (self.name, typ))
        #self.setObject(obj)  ## handled indirectly..
        return obj
예제 #2
0
    def __init__(self, module):
        self.hasQuit = False
        self.module = module # handle to the rest of the application
        
        self.interfaces = OrderedDict()  # owner: widget
        self.docks = OrderedDict()       # owner: dock
        
        # Start building UI
        Qt.QMainWindow.__init__(self)
        self.setWindowTitle('Camera')
        self.cw = dockarea.DockArea()
        self.setCentralWidget(self.cw)
        self.gv = pg.GraphicsView()
        self.gvDock = dockarea.Dock(name="View", widget=self.gv, hideTitle=True, size=(600,600))
        self.cw.addDock(self.gvDock)
        
        # set up ViewBox
        self.view = pg.ViewBox()
        self.view.enableAutoRange(x=False, y=False)
        self.view.setAspectLocked(True)
        self.gv.setCentralItem(self.view)
        
        # And a plot area for displaying depth-related information
        self.depthPlot = pg.PlotWidget(labels={'left': ('Depth', 'm')})
        self.depthPlot.setYRange(0, 1e-3)
        self.depthPlot.setXRange(-1, 1)
        self.depthPlot.hideAxis('bottom')
        self.depthPlot.setMouseEnabled(x=False)
        self.depthDock = pg.dockarea.Dock(name='Depth', widget=self.depthPlot)
        self.cw.addDock(self.depthDock, 'right')
        self.depthDock.hide()

        # Add a group that will track to the center of the view
        # self.trackedGroup = pg.GroupItem()
        # self.view.addItem(self.trackedGroup)

        # search for all devices that provide a cameraModuleInterface() method
        man = Manager.getManager()
        devices = [man.getDevice(dev) for dev in man.listDevices()]
        ifaces = OrderedDict([(dev.name(), dev.cameraModuleInterface(self)) for dev in devices if hasattr(dev, 'cameraModuleInterface')])
        
        # add each device's control panel in ots own dock
        haveDevs = False
        for dev, iface in ifaces.items():
            if iface is not None:
                haveDevs = True
                self.addInterface(dev, iface)
        
        # Add explanatory label if no devices were found
        if not haveDevs:
            label = Qt.QLabel("No imaging devices available")
            label.setAlignment(Qt.Qt.AlignHCenter | Qt.Qt.AlignVCenter)
            dock = dockarea.Dock(name="nocamera", widget=label, size=(100, 500), hideTitle=True)
            self.cw.addDock(dock, 'left', self.gvDock)

        # Add a dock with ROI buttons and plot
        self.roiWidget = ROIPlotter(self)
        self.roiDock = dockarea.Dock(name='ROI Plot', widget=self.roiWidget, size=(400, 10))
        self.cw.addDock(self.roiDock, 'bottom', self.gvDock)

        # Add timelapse / z stack / mosaic controls
        self.sequencerWidget = ImageSequencer(self)
        self.sequencerDock = dockarea.Dock(name='Image Sequencer', widget=self.sequencerWidget, size=(200, 10))
        self.cw.addDock(self.sequencerDock, 'right', self.roiDock)
        
        #grid = pg.GridItem()
        #self.view.addItem(grid)
        
        #Scale bar
        self.scaleBar = pg.ScaleBar(100e-6, offset=(-20,-20))
        self.scaleBar.setParentItem(self.view)
        
        ## Set up status bar labels
        self.recLabel = Qt.QLabel()
        self.rgnLabel = Qt.QLabel()
        self.xyLabel = Qt.QLabel()
        self.tLabel = Qt.QLabel()
        self.vLabel = Qt.QLabel()
        self.vLabel.setFixedWidth(50)
        self.setStatusBar(StatusBar())
        font = self.xyLabel.font()
        font.setPointSize(8)
        labels = [self.recLabel, self.xyLabel, self.rgnLabel, self.tLabel, self.vLabel]
        for label in labels:
            label.setFont(font)
            self.statusBar().insertPermanentWidget(0, label)

        # Load previous window state
        self.stateFile = os.path.join('modules', self.module.name + '_ui.cfg')
        uiState = module.manager.readConfigFile(self.stateFile)
        if 'geometry' in uiState:
            geom = Qt.QRect(*uiState['geometry'])
            self.setGeometry(geom)
        if 'window' in uiState:
            ws = Qt.QByteArray.fromPercentEncoding(uiState['window'])
            self.restoreState(ws)
        if 'docks' in uiState:
            self.cw.restoreState(uiState['docks'], missing='ignore')
        
        # done with UI
        self.show()
        self.centerView()
        
        self.gv.scene().sigMouseMoved.connect(self.updateMouse)
예제 #3
0
     if last is None:
         l2 = step
     else:
         pass
 bTimes = [x[1] for x in l2]
 print key, "  \tcompute time:\t%0.1f  \ttotal cost:\t%0.1f  \tmax interval:\t%0.1f\t" % (
     time.time()-start,
     sum(bTimes),
     max(bTimes)
 )
 #print "  total cost:\t%0.1f" % sum(bTimes)
 #print "  max interval:\t%0.1f" % max(bTimes)
 
 check(locs, l2)
 
 vb = pg.ViewBox()
 view.addItem(vb)
 data = [{'pos': l2[i][0], 'brush': (i * 255/ len(l2),)*3} for i in range(len(l2))]
 
 sp = pg.ScatterPlotItem(data, pen=0.3, pxMode=False, size=1e-4)
 vb.addItem(sp)
 
 ## number spots
 #for i in range(len(data)):
     #t = QtGui.QGraphicsTextItem()
     #t.setHtml('<span style="color: #f00">%d</span>'%i)
     #t.setFlag(t.ItemIgnoresTransformations, True)
     #t.setPos(*l2[i][0])
     #vb.addItem(t)
 
 vb.setRange(sp.boundingRect())