Exemple #1
0
    def __init__(self, dataManager=None, dataModel=None, module=None):
        Qt.QMainWindow.__init__(self)
        self.dm = dataManager
        self.dataModel = dataModel
        self.mod = None
        self.dockArea = dockarea.DockArea()
        self.setCentralWidget(self.dockArea)
        
        #self.logBtn = LogButton('Log')
        #self.statusBar().addPermanentWidget(self.logBtn)
        self.setStatusBar(StatusBar())
        
        if module is not None:
            self.loadModule(module)

        self.show()
Exemple #2
0
    def __init__(self, camera, module):
        CameraModuleInterface.__init__(self, camera, module)

        self.module = module
        self.view = module.getView()
        self.hasQuit = False
        self.boundaryItems = {}

        ## setup UI
        self.ui = CameraInterfaceTemplate()
        self.widget = dockarea.DockArea()
        w = QtGui.QWidget()
        self.ui.setupUi(w)

        # takes care of displaying image data,
        # contrast & background subtraction user interfaces
        self.imagingCtrl = ImagingCtrl()
        self.frameDisplay = self.imagingCtrl.frameDisplay

        ## Move control panels into docks
        recDock = dockarea.Dock(name="Recording",
                                widget=self.imagingCtrl,
                                size=(100, 10),
                                autoOrientation=False)
        devDock = dockarea.Dock(name="Device Control",
                                widget=self.ui.devCtrlWidget,
                                size=(100, 10),
                                autoOrientation=False)
        dispDock = dockarea.Dock(name="Display Control",
                                 widget=self.frameDisplay.contrastWidget(),
                                 size=(100, 600),
                                 autoOrientation=False)
        bgDock = dockarea.Dock(name="Background Subtraction",
                               widget=self.frameDisplay.backgroundWidget(),
                               size=(100, 10),
                               autoOrientation=False)
        self.widget.addDock(recDock)
        self.widget.addDock(devDock, 'bottom', recDock)
        self.widget.addDock(dispDock, 'bottom', devDock)
        self.widget.addDock(bgDock, 'bottom', dispDock)

        ## Camera state variables
        self.cam = camera
        self.roi = None
        self.exposure = 0.001
        self.binning = 1
        self.region = None

        ## set up item groups
        self.cameraItemGroup = pg.ItemGroup(
        )  ## translated with scope, scaled with camera objective
        self.imageItemGroup = pg.ItemGroup(
        )  ## translated and scaled as each frame arrives
        self.view.addItem(self.imageItemGroup)
        self.view.addItem(self.cameraItemGroup)
        self.cameraItemGroup.setZValue(0)
        self.imageItemGroup.setZValue(-2)

        ## video image item
        self.imageItem = self.frameDisplay.imageItem()
        self.view.addItem(self.imageItem)
        self.imageItem.setParentItem(self.imageItemGroup)
        self.imageItem.setZValue(-10)

        ## open camera, determine bit depth and sensor area
        self.openCamera()

        ## Initialize values
        self.lastCameraPosition = Point(self.camSize[0] * 0.5,
                                        self.camSize[1] * 0.5)
        self.lastCameraScale = Point(1.0, 1.0)
        self.scopeCenter = [self.camSize[0] * 0.5, self.camSize[1] * 0.5]
        self.cameraScale = [1, 1]

        ## Camera region-of-interest control
        self.roi = CamROI(self.camSize, parent=self.cameraItemGroup)
        self.roi.sigRegionChangeFinished.connect(self.regionWidgetChanged)
        self.roi.setZValue(-1)
        self.setRegion()

        ## Set up microscope objective borders
        self.borders = CameraItemGroup(self.cam)
        self.module.addItem(self.borders)
        self.borders.setZValue(-1)

        self.cam.sigGlobalTransformChanged.connect(self.globalTransformChanged)

        self.globalTransformChanged()

        # initially set binning and exposure from camera state
        self.exposure = self.cam.getParam('exposure')
        self.binning = self.cam.getParam('binning')[0]
        ## Initialize values/connections in Camera Dock
        self.setUiBinning(self.binning)
        self.ui.spinExposure.setValue(self.exposure)
        self.ui.spinExposure.setOpts(dec=True,
                                     step=1,
                                     minStep=100e-6,
                                     siPrefix=True,
                                     suffix='s',
                                     bounds=[0, 10])

        #Signals from self.ui.btnSnap and self.ui.recordStackBtn are caught by the RecordThread
        self.ui.btnFullFrame.clicked.connect(lambda: self.setRegion())
        self.proxy1 = SignalProxy(self.ui.binningCombo.currentIndexChanged,
                                  slot=self.binningComboChanged)
        self.ui.spinExposure.valueChanged.connect(
            self.setExposure
        )  ## note that this signal (from acq4.util.SpinBox) is delayed.

        ## Signals from Camera device
        self.cam.sigNewFrame.connect(self.newFrame)
        self.cam.sigCameraStopped.connect(self.cameraStopped)
        self.cam.sigCameraStarted.connect(self.cameraStarted)
        self.cam.sigShowMessage.connect(self.showMessage)

        self.frameDisplay.imageUpdated.connect(self.imageUpdated)
        self.imagingCtrl.sigStartVideoClicked.connect(self.startAcquireClicked)
        self.imagingCtrl.sigStopVideoClicked.connect(self.stopAcquireClicked)
        self.imagingCtrl.ui.acquireFrameBtn.setEnabled(False)
Exemple #3
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)