class FirstWindow(QtGui.QWidget):
    """Creates the opening window"""
    def __init__(self, parent, context, reactor):
        QtGui.QWidget.__init__(self)
        self.parent = parent
        self.context = context
        self.reactor = reactor
        self.parameterWindows = {}
        self.manuallyLoaded = True
        self.setWindowTitle("Live Grapher!")
        hbl = QtGui.QHBoxLayout()
        self.setLayout(hbl)
        self.datavaultwidget = DataVaultWidget(self, context)
        self.datavaultwidget.populateList()
        #self.datavaultwidget.show()
        hbl.addWidget(self.datavaultwidget)
        
    def newParameterWindow(self, dataset, directory):
        win = ParameterWindow(self, dataset, directory)
        win.show()
        self.parameterWindows[dataset, directory] = win

    def getParameters(self, dataset, directory):
        parameters = self.parent.getParameters(dataset, directory)
        return parameters
    
    def closeEvent(self, event):
        self.reactor.stop()                   
Пример #2
0
    def setupViewingTools(self):
        context = yield self.parent.cxn.context()
        self.datavaultwidget = DataVaultWidget(self, context)
        self.datavaultwidget.populateList()
        self.bottomPanel4 = QtGui.QHBoxLayout()
        self.bottomPanel4.addWidget(self.datavaultwidget)
        self.layout.addLayout(self.bottomPanel4)

        cameraCanvasLayout = QtGui.QVBoxLayout()

        self.bottomPanel4.addLayout(cameraCanvasLayout)

        self.cameraCanvas = CameraCanvas(self)
        self.cameraCanvas.show()
        ntbCamera = NavigationToolbar(self.cameraCanvas, self)

        cameraCanvasLayout.addWidget(self.cameraCanvas)
        cameraCanvasLayout.addWidget(ntbCamera)

        analysisCanvasLayout = QtGui.QVBoxLayout()

        self.bottomPanel4.addLayout(analysisCanvasLayout)

        self.analysisCanvas = AnalysisCanvas(self)
        self.analysisCanvas.show()
        ntbAnalysis = NavigationToolbar(self.analysisCanvas, self)

        analysisCanvasLayout.addWidget(self.analysisCanvas)
        self.parametersEdit = QtGui.QLineEdit(readOnly=True)
        analysisCanvasLayout.addWidget(self.parametersEdit)
        analysisCanvasLayout.addWidget(ntbAnalysis)
Пример #3
0
class FirstWindow(QtGui.QMainWindow):
    """Creates the opening window"""
    def __init__(self, parent, context):
        QtGui.QMainWindow.__init__(self)
        self.parent = parent
        self.context = context
        self.parameterWindows = {}
        self.manuallyLoaded = True
        self.setWindowTitle("Live Grapher!")
        self.main_widget = QtGui.QWidget(self)
        self.setCentralWidget(self.main_widget)
        hbl = QtGui.QHBoxLayout(self.main_widget)
        self.datavaultwidget = DataVaultWidget(self, context)
        self.datavaultwidget.populateList()
        #self.datavaultwidget.show()
        hbl.addWidget(self.datavaultwidget)

    def newParameterWindow(self, dataset, directory):
        win = ParameterWindow(self, dataset, directory)
        win.show()
        self.parameterWindows[dataset, directory] = win

    def getParameters(self, dataset, directory):
        parameters = self.parent.getParameters(dataset, directory)
        return parameters
Пример #4
0
 def __init__(self, parent, context):
     QtGui.QMainWindow.__init__(self)
     self.parent = parent
     self.context = context
     self.parameterWindows = {}
     self.manuallyLoaded = True
     self.setWindowTitle("Live Grapher!")
     self.main_widget = QtGui.QWidget(self)
     self.setCentralWidget(self.main_widget)
     hbl = QtGui.QHBoxLayout(self.main_widget)
     self.datavaultwidget = DataVaultWidget(self, context)
     self.datavaultwidget.populateList()
     #self.datavaultwidget.show()
     hbl.addWidget(self.datavaultwidget)
Пример #5
0
 def __init__(self, parent, context, reactor):
     QtGui.QWidget.__init__(self)
     self.parent = parent
     self.context = context
     self.reactor = reactor
     self.parameterWindows = {}
     self.manuallyLoaded = True
     self.setWindowTitle("Live Grapher!")
     hbl = QtGui.QHBoxLayout()
     self.setLayout(hbl)
     self.datavaultwidget = DataVaultWidget(self, context)
     self.datavaultwidget.populateList()
     #self.datavaultwidget.show()
     hbl.addWidget(self.datavaultwidget)
Пример #6
0
    def setupViewingTools(self):    
        context = yield self.parent.cxn.context()
        self.datavaultwidget = DataVaultWidget(self, context)
        self.datavaultwidget.populateList()     
        self.bottomPanel4 = QtGui.QHBoxLayout()
        self.bottomPanel4.addWidget(self.datavaultwidget)
        self.layout.addLayout(self.bottomPanel4)
              
        cameraCanvasLayout = QtGui.QVBoxLayout()
        
        self.bottomPanel4.addLayout(cameraCanvasLayout)
        
        self.cameraCanvas = CameraCanvas(self)
        self.cameraCanvas.show()
        ntbCamera = NavigationToolbar(self.cameraCanvas, self)

        cameraCanvasLayout.addWidget(self.cameraCanvas)
        cameraCanvasLayout.addWidget(ntbCamera)
        
        analysisCanvasLayout = QtGui.QVBoxLayout()
        
        self.bottomPanel4.addLayout(analysisCanvasLayout)
        
        self.analysisCanvas = AnalysisCanvas(self)
        self.analysisCanvas.show()
        ntbAnalysis = NavigationToolbar(self.analysisCanvas, self)

        analysisCanvasLayout.addWidget(self.analysisCanvas)
        self.parametersEdit = QtGui.QLineEdit(readOnly=True)
        analysisCanvasLayout.addWidget(self.parametersEdit)
        analysisCanvasLayout.addWidget(ntbAnalysis)
 def __init__(self, parent, context, reactor):
     QtGui.QWidget.__init__(self)
     self.parent = parent
     self.context = context
     self.reactor = reactor
     self.parameterWindows = {}
     self.manuallyLoaded = True
     self.setWindowTitle("Live Grapher!")
     hbl = QtGui.QHBoxLayout()
     self.setLayout(hbl)
     self.datavaultwidget = DataVaultWidget(self, context)
     self.datavaultwidget.populateList()
     #self.datavaultwidget.show()
     hbl.addWidget(self.datavaultwidget)
Пример #8
0
 def __init__(self, parent, context):
     QtGui.QMainWindow.__init__(self)
     self.parent = parent
     self.context = context
     self.parameterWindows = {}
     self.manuallyLoaded = True
     self.setWindowTitle("Live Grapher!")
     self.main_widget = QtGui.QWidget(self)     
     self.setCentralWidget(self.main_widget)        
     hbl = QtGui.QHBoxLayout(self.main_widget)
     self.datavaultwidget = DataVaultWidget(self, context)
     self.datavaultwidget.populateList()
     #self.datavaultwidget.show()
     hbl.addWidget(self.datavaultwidget)
Пример #9
0
    def initGui( self ):

        dvWidget = self.dvWidget = DataVaultWidget( self )
        self.setCentralWidget( dvWidget )
        
        #### menu bar doesn't seem to work
        connectMenu = menuBar.addMenu( '&Grapher' )
        connectAction = self.connectAction = connectMenu.addAction( '&Connect' )
        connectAction.triggered.connect( lambda _: connect() )

        lrSigs.connecting.connect( lambda: connectAction.setEnabled( False ) )
        lrSigs.failed.connect( lambda: connectAction.setEnabled( True ) )
        lrSigs.disconnected.connect( lambda: connectAction.setEnabled( True ) )

        selectDVAction = self.selectDVAction = connectMenu.addAction( 'Select &Data Vault' )
        selectDVAction.triggered.connect( dvWidget.browser.selectDataVault )
        selectDVAction.setEnabled( False )

        lrSigs.connected.connect( lambda: selectDVAction.setEnabled( True ) )
        lrSigs.failed.connect( lambda: selectDVAction.setEnabled( False ) )
        lrSigs.disconnected.connect( lambda: selectDVAction.setEnabled( False ) )
Пример #10
0
class AppWindow(QtGui.QWidget):
    """Creates the window for the new plot"""
    def __init__(self, parent):
        QtGui.QWidget.__init__(self)

        self.parent = parent

        self.histList = []

        self.layout = QtGui.QVBoxLayout()

        temperatureButton = QtGui.QPushButton("Temp", self)
        temperatureButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
        temperatureButton.clicked.connect(self.printTemperature)

        #        openKineticButton = QtGui.QPushButton("Open Kinetic", self)
        #        openKineticButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
        #        openKineticButton.clicked.connect(self.openKinetic)

        #        openKineticDataVaultButton = QtGui.QPushButton("Open Kinetic Data Vault", self)
        #        openKineticDataVaultButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
        #        openKineticDataVaultButton.clicked.connect(self.openKineticDataVault)
        #
        #        saveKineticDataVaultButton = QtGui.QPushButton("Temp Save DV", self)
        #        saveKineticDataVaultButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
        #        saveKineticDataVaultButton.clicked.connect(self.saveKineticDataVault)

        abortAcquisitionButton = QtGui.QPushButton("Abort Acquisition", self)
        abortAcquisitionButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
        abortAcquisitionButton.clicked.connect(self.abortAcquisition)

        getIonNumberHistogramButton = QtGui.QPushButton(
            "Ion Swap - Ion Number", self)
        getIonNumberHistogramButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
        getIonNumberHistogramButton.clicked.connect(self.getIonNumberHistogram)

        loadDatasetsButton = QtGui.QPushButton("Load Datasets", self)
        loadDatasetsButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
        loadDatasetsButton.clicked.connect(self.loadDatasets)

        #        pathLabel = QtGui.QLabel()
        #        pathLabel.setText('Path: ')

        pathDataVaultLabel = QtGui.QLabel()
        pathDataVaultLabel.setText('Path: ')

        #        self.pathEdit = QtGui.QLineEdit()
        #        self.pathEdit.setText(r'C:\Users\lattice\Documents\Andor\jun12\062812\1\image')

        self.pathDataVaultEdit = QtGui.QLineEdit()
        self.pathDataVaultEdit.setText(
            str(['', 'Experiments', 'IonSwap', '2012Jul10']))

        self.loadDatasetsEdit = QtGui.QLineEdit()
        self.loadDatasetsEdit.setText(str([175618, 175622]))

        #        exposureLabel = QtGui.QLabel()
        #        exposureLabel.setText('Exposure (ms): ')

        iterationsLabel = QtGui.QLabel()
        iterationsLabel.setText('Iterations: ')

        ionThresholdLabel = QtGui.QLabel()
        ionThresholdLabel.setText('Ion Threshold: ')

        darkIonThresholdLabel = QtGui.QLabel()
        darkIonThresholdLabel.setText('Dark Ion Threshold: ')

        imageNumberLabel = QtGui.QLabel()
        imageNumberLabel.setText('Image Number: ')

        kineticSetsLabel = QtGui.QLabel()
        kineticSetsLabel.setText('Kinetic Sets: ')

        expectedNumberOfIonsLabel = QtGui.QLabel()
        expectedNumberOfIonsLabel.setText('Expected Number Of Ions: ')

        alphaLabel = QtGui.QLabel()
        alphaLabel.setText('Alpha: ')

        axialOffsetLabel = QtGui.QLabel()
        axialOffsetLabel.setText('Axial Offset: ')

        sigmaLabel = QtGui.QLabel()
        sigmaLabel.setText('Sigma: ')

        loadDatasetsLabel = QtGui.QLabel()
        loadDatasetsLabel.setText('Datasets: ')

        #        self.exposureSpinBox = QtGui.QSpinBox()
        #        self.exposureSpinBox.setMinimum(100)
        #        self.exposureSpinBox.setMaximum(1000)
        #        self.exposureSpinBox.setSingleStep(1)
        #        self.exposureSpinBox.setValue(EXPOSURE*1000)
        #        self.exposureSpinBox.setKeyboardTracking(False)
        #        self.connect(self.exposureSpinBox, QtCore.SIGNAL('valueChanged(int)'), self.changeExposure)

        self.iterationsSpinBox = QtGui.QSpinBox()
        self.iterationsSpinBox.setMinimum(0)
        self.iterationsSpinBox.setMaximum(1000)
        self.iterationsSpinBox.setSingleStep(1)
        self.iterationsSpinBox.setValue(2)
        self.iterationsSpinBox.setKeyboardTracking(False)

        self.kineticSetsSpinBox = QtGui.QSpinBox()
        self.kineticSetsSpinBox.setMinimum(0)
        self.kineticSetsSpinBox.setMaximum(100)
        self.kineticSetsSpinBox.setSingleStep(1)
        self.kineticSetsSpinBox.setValue(2)
        self.kineticSetsSpinBox.setKeyboardTracking(False)

        self.ionThresholdSpinBox = QtGui.QSpinBox()
        self.ionThresholdSpinBox.setMinimum(0)
        self.ionThresholdSpinBox.setMaximum(1000)
        self.ionThresholdSpinBox.setSingleStep(1)
        self.ionThresholdSpinBox.setValue(700)
        self.ionThresholdSpinBox.setKeyboardTracking(False)

        self.darkIonThresholdSpinBox = QtGui.QSpinBox()
        self.darkIonThresholdSpinBox.setMinimum(-1000)
        self.darkIonThresholdSpinBox.setMaximum(0)
        self.darkIonThresholdSpinBox.setSingleStep(1)
        self.darkIonThresholdSpinBox.setValue(-350)
        self.darkIonThresholdSpinBox.setKeyboardTracking(False)

        self.alphaSpinBox = QtGui.QSpinBox()
        self.alphaSpinBox.setMinimum(1)
        self.alphaSpinBox.setMaximum(50)
        self.alphaSpinBox.setSingleStep(1)
        self.alphaSpinBox.setValue(15)
        self.alphaSpinBox.setKeyboardTracking(False)

        self.axialOffsetSpinBox = QtGui.QSpinBox()
        self.axialOffsetSpinBox.setMinimum(1)
        self.axialOffsetSpinBox.setMaximum(100)
        self.axialOffsetSpinBox.setSingleStep(1)
        self.axialOffsetSpinBox.setValue(33)
        self.axialOffsetSpinBox.setKeyboardTracking(False)

        self.sigmaSpinBox = QtGui.QSpinBox()
        self.sigmaSpinBox.setMinimum(1)
        self.sigmaSpinBox.setMaximum(50)
        self.sigmaSpinBox.setSingleStep(1)
        self.sigmaSpinBox.setValue(5)
        self.sigmaSpinBox.setKeyboardTracking(False)

        self.expectedNumberOfIonsSpinBox = QtGui.QSpinBox()
        self.expectedNumberOfIonsSpinBox.setMinimum(1)
        self.expectedNumberOfIonsSpinBox.setMaximum(10)
        self.expectedNumberOfIonsSpinBox.setSingleStep(1)
        self.expectedNumberOfIonsSpinBox.setValue(5)
        self.expectedNumberOfIonsSpinBox.setKeyboardTracking(False)

        imageAnalyzedLabel = QtGui.QLabel()
        imageAnalyzedLabel.setText('Images to analyze: ')

        typIonDiameterLabel = QtGui.QLabel()
        typIonDiameterLabel.setText('Typical Ion Diameter: ')

        #        peakVicinityLabel = QtGui.QLabel()
        #        peakVicinityLabel.setText('Peak Vicinity: ')

        self.imageAnalyzedSpinBox = QtGui.QSpinBox()
        self.imageAnalyzedSpinBox.setMinimum(1)
        self.imageAnalyzedSpinBox.setMaximum(20)
        self.imageAnalyzedSpinBox.setSingleStep(1)
        self.imageAnalyzedSpinBox.setValue(2)
        self.imageAnalyzedSpinBox.setKeyboardTracking(False)

        self.typIonDiameterSpinBox = QtGui.QSpinBox()
        self.typIonDiameterSpinBox.setMinimum(1)
        self.typIonDiameterSpinBox.setMaximum(20)
        self.typIonDiameterSpinBox.setSingleStep(1)
        self.typIonDiameterSpinBox.setValue(5)
        self.typIonDiameterSpinBox.setKeyboardTracking(False)

        # Layout
        self.bottomPanel1 = QtGui.QHBoxLayout()

        self.bottomPanel1.addWidget(temperatureButton)
        self.bottomPanel1.addWidget(getIonNumberHistogramButton)
        self.bottomPanel1.addWidget(kineticSetsLabel)
        self.bottomPanel1.addWidget(self.kineticSetsSpinBox)

        self.bottomPanel1.addStretch(0)
        self.bottomPanel1.setSizeConstraint(QtGui.QLayout.SetFixedSize)
        self.bottomPanel1.addWidget(iterationsLabel)
        self.bottomPanel1.addWidget(self.iterationsSpinBox)
        self.bottomPanel1.addWidget(alphaLabel)
        self.bottomPanel1.addWidget(self.alphaSpinBox)
        self.bottomPanel1.addWidget(axialOffsetLabel)
        self.bottomPanel1.addWidget(self.axialOffsetSpinBox)
        self.bottomPanel1.addWidget(sigmaLabel)
        self.bottomPanel1.addWidget(self.sigmaSpinBox)

        self.bottomPanel2 = QtGui.QHBoxLayout()

        #        self.bottomPanel2.addStretch(0)

        self.bottomPanel2.addWidget(abortAcquisitionButton)
        self.bottomPanel2.addWidget(imageAnalyzedLabel)
        self.bottomPanel2.addWidget(self.imageAnalyzedSpinBox)
        self.bottomPanel2.addWidget(expectedNumberOfIonsLabel)
        self.bottomPanel2.addWidget(self.expectedNumberOfIonsSpinBox)
        self.bottomPanel2.addWidget(typIonDiameterLabel)
        self.bottomPanel2.addWidget(self.typIonDiameterSpinBox)

        #        self.bottomPanel3 = QtGui.QHBoxLayout()
        #
        #
        #        self.bottomPanel3.addWidget(openKineticButton)
        #        self.bottomPanel3.addWidget(pathLabel)
        #        self.bottomPanel3.addWidget(self.pathEdit)

        #        self.bottomPanel4 = QtGui.QHBoxLayout()

        #        self.bottomPanel4.addWidget(saveKineticDataVaultButton)
        #        self.bottomPanel4.addWidget(openKineticDataVaultButton)
        #        self.bottomPanel4.addWidget(pathDataVaultLabel)
        #        self.bottomPanel4.addWidget(self.pathDataVaultEdit)

        self.bottomPanel3 = QtGui.QHBoxLayout()

        self.bottomPanel3.addWidget(loadDatasetsButton)
        self.bottomPanel3.addWidget(loadDatasetsLabel)
        self.bottomPanel3.addWidget(self.loadDatasetsEdit)
        self.bottomPanel3.addWidget(pathDataVaultLabel)
        self.bottomPanel3.addWidget(self.pathDataVaultEdit)

        self.layout.addLayout(self.bottomPanel1)
        self.layout.addLayout(self.bottomPanel2)
        self.layout.addLayout(self.bottomPanel3)

        self.setWindowTitle('Dark Ion Analysis')
        self.setLayout(self.layout)

        self.setupViewingTools()

    @inlineCallbacks
    def setupViewingTools(self):
        context = yield self.parent.cxn.context()
        self.datavaultwidget = DataVaultWidget(self, context)
        self.datavaultwidget.populateList()
        self.bottomPanel4 = QtGui.QHBoxLayout()
        self.bottomPanel4.addWidget(self.datavaultwidget)
        self.layout.addLayout(self.bottomPanel4)

        cameraCanvasLayout = QtGui.QVBoxLayout()

        self.bottomPanel4.addLayout(cameraCanvasLayout)

        self.cameraCanvas = CameraCanvas(self)
        self.cameraCanvas.show()
        ntbCamera = NavigationToolbar(self.cameraCanvas, self)

        cameraCanvasLayout.addWidget(self.cameraCanvas)
        cameraCanvasLayout.addWidget(ntbCamera)

        analysisCanvasLayout = QtGui.QVBoxLayout()

        self.bottomPanel4.addLayout(analysisCanvasLayout)

        self.analysisCanvas = AnalysisCanvas(self)
        self.analysisCanvas.show()
        ntbAnalysis = NavigationToolbar(self.analysisCanvas, self)

        analysisCanvasLayout.addWidget(self.analysisCanvas)
        self.parametersEdit = QtGui.QLineEdit(readOnly=True)
        analysisCanvasLayout.addWidget(self.parametersEdit)
        analysisCanvasLayout.addWidget(ntbAnalysis)

    def setParametersText(self, parametersArray):
        self.parametersEdit.setText('Height: ' + str(parametersArray[0]) +
                                    ' ' + 'Alpha: ' + str(parametersArray[1]) +
                                    ' ' + 'AxialOffset: ' +
                                    str(parametersArray[2]) + ' ' + 'Sigma: ' +
                                    str(parametersArray[3]) + ' ' +
                                    'Offset: ' + str(parametersArray[4]))

    def printTemperature(self, evt):
        self.parent.printTemperature()

    def getDarkIonCatalog(self, evt):
        self.parent.getDarkIonCatalog(self.imageAnalyzedSpinBox.value(),
                                      self.typIonDiameterSpinBox.value(),
                                      self.ionThresholdSpinBox.value(),
                                      self.darkIonThresholdSpinBox.value(),
                                      self.iterationsSpinBox.value())

    def getIonPositionCatalog(self, evt):
        self.parent.getIonPositionCatalog(self.imageAnalyzedSpinBox.value(),
                                          self.typIonDiameterSpinBox.value(),
                                          self.ionThresholdSpinBox.value(),
                                          self.darkIonThresholdSpinBox.value(),
                                          self.iterationsSpinBox.value(),
                                          self.peakVicinitySpinBox.value())

    def collectData(self, evt):
        self.parent.collectData(self.iterationsSpinBox.value(),
                                self.imageAnalyzedSpinBox.value())


#    def changeExposure(self, value):
#        self.parent.changeExposure(float(self.exposureSpinBox.value())/1000) #convert ms to s
#
#    def countDarkIons(self, evt):
#        histWindow = HistWindow(self, self.parent.darkIonCatalog)
#        self.histList.append(histWindow)
#        histWindow.show()
#        print np.mean(self.parent.darkIonCatalog)

    @inlineCallbacks
    def getIonNumberHistogram(self, evt):
        ionNumberCatalogArray = []
        yield self.parent.buildDarkIonPositionCatalog(
            self.kineticSetsSpinBox.value(), self.imageAnalyzedSpinBox.value(),
            self.typIonDiameterSpinBox.value(),
            self.expectedNumberOfIonsSpinBox.value(),
            self.iterationsSpinBox.value(), [
                self.alphaSpinBox.value(),
                self.axialOffsetSpinBox.value(),
                self.sigmaSpinBox.value()
            ])
        for i in range(3):
            ionNumberCatalog = yield self.parent.getIonNumberHistogram(
                i + 1, self.imageAnalyzedSpinBox.value(),
                self.iterationsSpinBox.value(),
                self.kineticSetsSpinBox.value())
            ionNumberCatalogArray.append(ionNumberCatalog)
        ionSwapCatalog = yield self.parent.getIonSwapHistogram(
            self.imageAnalyzedSpinBox.value(), self.iterationsSpinBox.value(),
            self.expectedNumberOfIonsSpinBox.value(),
            self.kineticSetsSpinBox.value())
        histWindow = HistWindow(self, ionNumberCatalogArray, ionSwapCatalog)
        self.histList.append(histWindow)
        histWindow.show()
        yield self.parent.appendParametersToDatasets(
            self.imageAnalyzedSpinBox.value(), self.iterationsSpinBox.value(),
            self.kineticSetsSpinBox.value())

    def openKinetic(self, evt):
        self.parent.openKinetic(str(self.pathEdit.text()),
                                self.kineticSetsSpinBox.value(),
                                ((self.imageAnalyzedSpinBox.value() + 1) *
                                 self.iterationsSpinBox.value()))

    def openKineticDataVault(self, evt):
        self.parent.openKineticDataVault(
            str(self.pathDataVaultEdit.text()),
            ((self.imageAnalyzedSpinBox.value() + 1) *
             self.iterationsSpinBox.value()))

    def loadDatasets(self, evt):
        self.parent.loadDatasets(str(self.pathDataVaultEdit.text()),
                                 str(self.loadDatasetsEdit.text()),
                                 ((self.imageAnalyzedSpinBox.value() + 1) *
                                  self.iterationsSpinBox.value()))

    def saveKineticDataVault(self, evt):
        self.parent.saveKineticDataVault(
            str(self.pathDataVaultEdit.text()), 'image',
            ((self.imageAnalyzedSpinBox.value() + 1) *
             self.iterationsSpinBox.value()))

    def abortAcquisition(self, evt):
        self.parent.abortAcquisition()

    def getData(self, evt):
        self.parent.getData(((self.imageAnalyzedSpinBox.value() + 1) *
                             self.iterationsSpinBox.value()))

    def closeEvent(self, evt):
        self.parent.reactor.stop()
Пример #11
0
    def __init__(self, parent, context):
        self.parent = parent
        self.context = context
        self.parameterWindows = {}
        self.datasetCheckboxes = {}
        self.datasetCheckboxCounter = 0
        self.manuallyLoaded = True
        QtGui.QMainWindow.__init__(self)
        self.setWindowTitle("Live Grapher")
        self.main_widget = QtGui.QWidget(self)
        self.setCentralWidget(self.main_widget)
        # create a vertical box layout widget
        grapherLayout = QtGui.QVBoxLayout()
        #vbl.addStretch(1)
        # instantiate our Matplotlib canvas widget
        self.qmc = Qt4MplCanvas(self.main_widget, self)
        # instantiate the navigation toolbar
        ntb = NavigationToolbar(self.qmc, self.main_widget)

        # Layout that involves the canvas, toolbar, graph options...etc.
        grapherLayout.addWidget(ntb)
        grapherLayout.addWidget(self.qmc)

        # Main horizontal layout
        mainLayout = QtGui.QHBoxLayout(self.main_widget)
        self.datavaultwidget = DataVaultWidget(self, self.context)
        self.datavaultwidget.setMaximumWidth(180)
        self.datavaultwidget.populateList()
        # Add the datavault widget
        # Layout that controls datasets
        datasetLayout = QtGui.QVBoxLayout()
        datasetLayout.addWidget(self.datavaultwidget)

        mainLayout.addLayout(datasetLayout)
        mainLayout.addLayout(grapherLayout)

        # Layout for keeping track of datasets on a graph
        self.datasetCheckboxListWidget = QtGui.QListWidget()
        self.datasetCheckboxListWidget.setMaximumWidth(180)
        datasetLayout.addWidget(self.datasetCheckboxListWidget)

        # set the focus on the main widget
        self.main_widget.setFocus()
        # add menu
        self.create_menu()
        # checkbox to change boundaries
        self.cb1 = QtGui.QCheckBox('AutoScroll', self)
        #self.cb1.move(290, 23)
        self.cb1.clicked.connect(self.autoscrollSignal)
        # checkbox to overlay new dataset
        self.cb2 = QtGui.QCheckBox('Overlay', self)
        #self.cb2.move(500, 35)
        # checkbox to toggle AutoFit
        self.cb3 = QtGui.QCheckBox('AutoFit', self)
        #self.cb3.move(290, 39)
        self.cb3.toggle()
        self.cb3.clicked.connect(self.autofitSignal)
        # button to fit data on screen
        fitButton = QtGui.QPushButton("Fit", self)
        fitButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
        #fitButton.move(390, 32)
        fitButton.clicked.connect(self.fitDataSignal)

        # Layout that controls graph options
        buttonBox = QtGui.QHBoxLayout()
        buttonBox.addWidget(self.cb1)
        buttonBox.addWidget(self.cb3)
        buttonBox.addWidget(self.cb2)
        buttonBox.addWidget(fitButton)

        grapherLayout.addLayout(buttonBox)
Пример #12
0
class GrapherWindow(QtGui.QMainWindow):
    """Creates the window for the new plot"""
    def __init__(self, parent, context):
        self.parent = parent
        self.context = context
        self.parameterWindows = {}
        self.datasetCheckboxes = {}
        self.datasetCheckboxCounter = 0
        self.manuallyLoaded = True
        QtGui.QMainWindow.__init__(self)
        self.setWindowTitle("Live Grapher")
        self.main_widget = QtGui.QWidget(self)
        self.setCentralWidget(self.main_widget)
        # create a vertical box layout widget
        grapherLayout = QtGui.QVBoxLayout()
        #vbl.addStretch(1)
        # instantiate our Matplotlib canvas widget
        self.qmc = Qt4MplCanvas(self.main_widget, self)
        # instantiate the navigation toolbar
        ntb = NavigationToolbar(self.qmc, self.main_widget)

        # Layout that involves the canvas, toolbar, graph options...etc.
        grapherLayout.addWidget(ntb)
        grapherLayout.addWidget(self.qmc)

        # Main horizontal layout
        mainLayout = QtGui.QHBoxLayout(self.main_widget)
        self.datavaultwidget = DataVaultWidget(self, self.context)
        self.datavaultwidget.setMaximumWidth(180)
        self.datavaultwidget.populateList()
        # Add the datavault widget
        # Layout that controls datasets
        datasetLayout = QtGui.QVBoxLayout()
        datasetLayout.addWidget(self.datavaultwidget)

        mainLayout.addLayout(datasetLayout)
        mainLayout.addLayout(grapherLayout)

        # Layout for keeping track of datasets on a graph
        self.datasetCheckboxListWidget = QtGui.QListWidget()
        self.datasetCheckboxListWidget.setMaximumWidth(180)
        datasetLayout.addWidget(self.datasetCheckboxListWidget)

        # set the focus on the main widget
        self.main_widget.setFocus()
        # add menu
        self.create_menu()
        # checkbox to change boundaries
        self.cb1 = QtGui.QCheckBox('AutoScroll', self)
        #self.cb1.move(290, 23)
        self.cb1.clicked.connect(self.autoscrollSignal)
        # checkbox to overlay new dataset
        self.cb2 = QtGui.QCheckBox('Overlay', self)
        #self.cb2.move(500, 35)
        # checkbox to toggle AutoFit
        self.cb3 = QtGui.QCheckBox('AutoFit', self)
        #self.cb3.move(290, 39)
        self.cb3.toggle()
        self.cb3.clicked.connect(self.autofitSignal)
        # button to fit data on screen
        fitButton = QtGui.QPushButton("Fit", self)
        fitButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
        #fitButton.move(390, 32)
        fitButton.clicked.connect(self.fitDataSignal)

        # Layout that controls graph options
        buttonBox = QtGui.QHBoxLayout()
        buttonBox.addWidget(self.cb1)
        buttonBox.addWidget(self.cb3)
        buttonBox.addWidget(self.cb2)
        buttonBox.addWidget(fitButton)

        grapherLayout.addLayout(buttonBox)

    # adds a checkbox when a new dataset is overlaid on the graph
    def createDatasetCheckbox(self, dataset, directory):
        datasetCheckbox = QtGui.QCheckBox(
            str(dataset) + ' ' + str(directory[-1]), self)
        datasetCheckbox.toggle()
        datasetCheckbox.clicked.connect(self.datasetCheckboxSignal)
        self.datasetCheckboxes[dataset, directory] = datasetCheckbox
        self.datasetCheckboxListWidget.addItem('')
        self.datasetCheckboxListWidget.setItemWidget(
            self.datasetCheckboxListWidget.item(self.datasetCheckboxCounter),
            datasetCheckbox)
        self.datasetCheckboxCounter = self.datasetCheckboxCounter + 1


#        self.datasetCheckboxes
#        self.datasetCheckboxModel.appendRow(datasetCheckbox)

    def datasetCheckboxSignal(self):
        #self.qmc.ax.legend()
        self.qmc.drawLegend()
        self.qmc.draw()

    # when the autoFit button is checked, it will uncheck the autoscroll button
    def autofitSignal(self):
        if (self.cb1.isChecked()):
            self.cb1.toggle()

    # when the autoscroll button is checked, it will uncheck the autoFit button
    def autoscrollSignal(self):
        if (self.cb3.isChecked()):
            self.cb3.toggle()

    # instructs the graph to update the boundaries to fit all the data
    def fitDataSignal(self):
        if (
                self.cb1.isChecked()
        ):  # makes sure autoscroll is off otherwise it will undo this operation
            self.cb1.toggle()
        elif (
                self.cb3.isChecked()
        ):  # makes sure autoFit is off otherwise it will undo this operation
            self.cb3.toggle()
        self.qmc.fitData()

    def newParameterWindow(self, dataset, directory):
        win = ParameterWindow(self, dataset, directory)
        win.show()
        self.parameterWindows[dataset, directory] = win

    def getParameters(self, dataset, directory):
        parameters = self.parent.getParameters(dataset, directory)
        return parameters

    # handles loading a new plot
    def load_plot(self):
        text, ok = QtGui.QInputDialog.getText(self, 'Open Dataset',
                                              'Enter a dataset:')
        if ok:
            #MR some type checking that is must be an integer. This won't be necessary when we switch to the browser.
            dataset = int(text)
        text2, ok = QtGui.QInputDialog.getText(
            self, 'Open Dataset', 'Enter a directory in labrad format:')
        if ok:
            directory = tuple(eval(str(text2)))
            #MR some type checking that is must be an integer. This won't be necessary when we switch to the browser.
            self.parent.newDataset(dataset, directory, self.manuallyLoaded)

    # about menu
    def on_about(self):
        msg = """ Live Grapher for LabRad! """
        QtGui.QMessageBox.about(self, "About the demo", msg.strip())

    # creates the menu
    def create_menu(self):
        self.file_menu = self.menuBar().addMenu("&File")

        load_file_action = self.create_action("&Load plot",
                                              shortcut="Ctrl+L",
                                              slot=self.load_plot,
                                              tip="Save the plot")
        quit_action = self.create_action("&Close Window",
                                         slot=self.close,
                                         shortcut="Ctrl+Q",
                                         tip="Close the application")

        self.add_actions(self.file_menu, (load_file_action, None, quit_action))

        self.help_menu = self.menuBar().addMenu("&Help")
        about_action = self.create_action("&About",
                                          shortcut='F1',
                                          slot=self.on_about,
                                          tip='About the demo')

        self.add_actions(self.help_menu, (about_action, ))

    # menu - related
    def add_actions(self, target, actions):
        for action in actions:
            if action is None:
                target.addSeparator()
            else:
                target.addAction(action)

    # menu - related
    def create_action(self,
                      text,
                      slot=None,
                      shortcut=None,
                      icon=None,
                      tip=None,
                      checkable=False,
                      signal="triggered()"):
        action = QtGui.QAction(text, self)
        if icon is not None:
            action.setIcon(QtGui.QIcon(":/%s.png" % icon))
        if shortcut is not None:
            action.setShortcut(shortcut)
        if tip is not None:
            action.setToolTip(tip)
            action.setStatusTip(tip)
        if slot is not None:
            self.connect(action, QtCore.SIGNAL(signal), slot)
        if checkable:
            action.setCheckable(True)
        return action

    def fileQuit(self):
        self.close()

    def closeEvent(self, event):
        self.qmc.endTimer()
        if (self.cb2.isChecked()):
            # "uncheck" the overlay checkbox
            self.cb2.toggle()
        print 'delering datadict'
        del self.qmc.dataDict
        # Remove this window from the dictionary so that no datasets...
        # ... are drawn to this window
        self.parent.removeWindowFromDictionary(self)
        self.parent.removeWindowFromWinList(self)
        self.fileQuit()
Пример #13
0
class AppWindow(QtGui.QWidget):
    """Creates the window for the new plot"""
    def __init__(self, parent):
        QtGui.QWidget.__init__(self)
        
        self.parent = parent
        
        self.histList = []
        
       
        self.layout = QtGui.QVBoxLayout()
       
        
#        temperatureButton = QtGui.QPushButton("Temp", self)
#        temperatureButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
#        temperatureButton.clicked.connect(self.printTemperature)     
        
                     
        
#        openKineticButton = QtGui.QPushButton("Open Kinetic", self)
#        openKineticButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
#        openKineticButton.clicked.connect(self.openKinetic)

#        openKineticDataVaultButton = QtGui.QPushButton("Open Kinetic Data Vault", self)
#        openKineticDataVaultButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
#        openKineticDataVaultButton.clicked.connect(self.openKineticDataVault)
#        
#        saveKineticDataVaultButton = QtGui.QPushButton("Temp Save DV", self)
#        saveKineticDataVaultButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
#        saveKineticDataVaultButton.clicked.connect(self.saveKineticDataVault)        
        
#        abortAcquisitionButton = QtGui.QPushButton("Abort Acquisition", self)
#        abortAcquisitionButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
#        abortAcquisitionButton.clicked.connect(self.abortAcquisition)

        
        getIonNumberHistogramButton = QtGui.QPushButton("Ion Swap - Ion Number", self)
        getIonNumberHistogramButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
        getIonNumberHistogramButton.clicked.connect(self.getIonNumberHistogram)
        
        loadDatasetsButton = QtGui.QPushButton("Load Datasets", self)
        loadDatasetsButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
        loadDatasetsButton.clicked.connect(self.loadDatasets)      
        
        
#        pathLabel = QtGui.QLabel()
#        pathLabel.setText('Path: ')
        
        pathDataVaultLabel = QtGui.QLabel()
        pathDataVaultLabel.setText('Path: ')        
        
#        self.pathEdit = QtGui.QLineEdit()
#        self.pathEdit.setText(r'C:\Users\lattice\Documents\Andor\jun12\062812\1\image') 
        
        self.pathDataVaultEdit = QtGui.QLineEdit()
        self.pathDataVaultEdit.setText(str(['','Experiments', 'IonSwap', '2012Jun28']))        

        self.loadDatasetsEdit = QtGui.QLineEdit()
        self.loadDatasetsEdit.setText(str([111111]))              
                        
#        exposureLabel = QtGui.QLabel()
#        exposureLabel.setText('Exposure (ms): ')

        iterationsLabel = QtGui.QLabel()
        iterationsLabel.setText('Iterations: ')
        
        ionThresholdLabel = QtGui.QLabel()
        ionThresholdLabel.setText('Ion Threshold: ')

        darkIonThresholdLabel = QtGui.QLabel()
        darkIonThresholdLabel.setText('Dark Ion Threshold: ')
        
        imageNumberLabel = QtGui.QLabel()
        imageNumberLabel.setText('Image Number: ')
        
        kineticSetsLabel = QtGui.QLabel()
        kineticSetsLabel.setText('Kinetic Sets: ')
        
        expectedNumberOfIonsLabel = QtGui.QLabel()
        expectedNumberOfIonsLabel.setText('Expected Number Of Ions: ') 
        
        alphaLabel = QtGui.QLabel()
        alphaLabel.setText('Alpha: ')
        
        axialOffsetLabel = QtGui.QLabel()
        axialOffsetLabel.setText('Axial Offset: ')

        sigmaLabel = QtGui.QLabel()
        sigmaLabel.setText('Sigma: ')
        
        loadDatasetsLabel = QtGui.QLabel()
        loadDatasetsLabel.setText('Datasets: ')                       
        
             
        
#        self.exposureSpinBox = QtGui.QSpinBox()
#        self.exposureSpinBox.setMinimum(100)
#        self.exposureSpinBox.setMaximum(1000)
#        self.exposureSpinBox.setSingleStep(1)  
#        self.exposureSpinBox.setValue(EXPOSURE*1000)     
#        self.exposureSpinBox.setKeyboardTracking(False)
#        self.connect(self.exposureSpinBox, QtCore.SIGNAL('valueChanged(int)'), self.changeExposure)

        self.iterationsSpinBox = QtGui.QSpinBox()
        self.iterationsSpinBox.setMinimum(0)
        self.iterationsSpinBox.setMaximum(1000)
        self.iterationsSpinBox.setSingleStep(1)  
        self.iterationsSpinBox.setValue(50)     
        self.iterationsSpinBox.setKeyboardTracking(False)

        self.kineticSetsSpinBox = QtGui.QSpinBox()
        self.kineticSetsSpinBox.setMinimum(0)
        self.kineticSetsSpinBox.setMaximum(100)
        self.kineticSetsSpinBox.setSingleStep(1)  
        self.kineticSetsSpinBox.setValue(1)     
        self.kineticSetsSpinBox.setKeyboardTracking(False)


        self.ionThresholdSpinBox = QtGui.QSpinBox()
        self.ionThresholdSpinBox.setMinimum(0)
        self.ionThresholdSpinBox.setMaximum(1000)
        self.ionThresholdSpinBox.setSingleStep(1)  
        self.ionThresholdSpinBox.setValue(700)     
        self.ionThresholdSpinBox.setKeyboardTracking(False)

        self.darkIonThresholdSpinBox = QtGui.QSpinBox()
        self.darkIonThresholdSpinBox.setMinimum(-1000)
        self.darkIonThresholdSpinBox.setMaximum(0)
        self.darkIonThresholdSpinBox.setSingleStep(1)  
        self.darkIonThresholdSpinBox.setValue(-350)     
        self.darkIonThresholdSpinBox.setKeyboardTracking(False)
        
        self.alphaSpinBox = QtGui.QSpinBox()
        self.alphaSpinBox.setMinimum(1)
        self.alphaSpinBox.setMaximum(50)
        self.alphaSpinBox.setSingleStep(1)  
        self.alphaSpinBox.setValue(15)     
        self.alphaSpinBox.setKeyboardTracking(False)

        self.axialOffsetSpinBox = QtGui.QSpinBox()
        self.axialOffsetSpinBox.setMinimum(1)
        self.axialOffsetSpinBox.setMaximum(100)
        self.axialOffsetSpinBox.setSingleStep(1)  
        self.axialOffsetSpinBox.setValue(33)     
        self.axialOffsetSpinBox.setKeyboardTracking(False)

        self.sigmaSpinBox = QtGui.QSpinBox()
        self.sigmaSpinBox.setMinimum(1)
        self.sigmaSpinBox.setMaximum(50)
        self.sigmaSpinBox.setSingleStep(1)  
        self.sigmaSpinBox.setValue(5)     
        self.sigmaSpinBox.setKeyboardTracking(False)        
        
        self.expectedNumberOfIonsSpinBox = QtGui.QSpinBox()
        self.expectedNumberOfIonsSpinBox.setMinimum(1)
        self.expectedNumberOfIonsSpinBox.setMaximum(10)
        self.expectedNumberOfIonsSpinBox.setSingleStep(1)  
        self.expectedNumberOfIonsSpinBox.setValue(5)     
        self.expectedNumberOfIonsSpinBox.setKeyboardTracking(False)               
        
        imageAnalyzedLabel = QtGui.QLabel()
        imageAnalyzedLabel.setText('Images to analyze: ')

        typIonDiameterLabel = QtGui.QLabel()
        typIonDiameterLabel.setText('Typical Ion Diameter: ')
        
#        peakVicinityLabel = QtGui.QLabel()
#        peakVicinityLabel.setText('Peak Vicinity: ')
        
        
        self.imageAnalyzedSpinBox = QtGui.QSpinBox()
        self.imageAnalyzedSpinBox.setMinimum(1)
        self.imageAnalyzedSpinBox.setMaximum(20)
        self.imageAnalyzedSpinBox.setSingleStep(1)  
        self.imageAnalyzedSpinBox.setValue(2)     
        self.imageAnalyzedSpinBox.setKeyboardTracking(False)        

        self.typIonDiameterSpinBox = QtGui.QSpinBox()
        self.typIonDiameterSpinBox.setMinimum(1)
        self.typIonDiameterSpinBox.setMaximum(20)
        self.typIonDiameterSpinBox.setSingleStep(1)  
        self.typIonDiameterSpinBox.setValue(5)     
        self.typIonDiameterSpinBox.setKeyboardTracking(False) 
          
          
         # Layout
        self.bottomPanel1 = QtGui.QHBoxLayout()
        
#        self.bottomPanel1.addWidget(temperatureButton)
        self.bottomPanel1.addWidget(getIonNumberHistogramButton)
        self.bottomPanel1.addWidget(kineticSetsLabel)
        self.bottomPanel1.addWidget(self.kineticSetsSpinBox)
    
        self.bottomPanel1.addStretch(0)
        self.bottomPanel1.setSizeConstraint(QtGui.QLayout.SetFixedSize)        
        self.bottomPanel1.addWidget(iterationsLabel)
        self.bottomPanel1.addWidget(self.iterationsSpinBox)
        self.bottomPanel1.addWidget(alphaLabel)
        self.bottomPanel1.addWidget(self.alphaSpinBox)
        self.bottomPanel1.addWidget(axialOffsetLabel)
        self.bottomPanel1.addWidget(self.axialOffsetSpinBox)
        self.bottomPanel1.addWidget(sigmaLabel)
        self.bottomPanel1.addWidget(self.sigmaSpinBox)
        
        self.bottomPanel2 = QtGui.QHBoxLayout()

#        self.bottomPanel2.addStretch(0)

#        self.bottomPanel2.addWidget(abortAcquisitionButton)
        self.bottomPanel2.addWidget(imageAnalyzedLabel)
        self.bottomPanel2.addWidget(self.imageAnalyzedSpinBox)
        self.bottomPanel2.addWidget(expectedNumberOfIonsLabel)
        self.bottomPanel2.addWidget(self.expectedNumberOfIonsSpinBox)
        self.bottomPanel2.addWidget(typIonDiameterLabel)
        self.bottomPanel2.addWidget(self.typIonDiameterSpinBox)

        
#        self.bottomPanel3 = QtGui.QHBoxLayout()
#
#
#        self.bottomPanel3.addWidget(openKineticButton)
#        self.bottomPanel3.addWidget(pathLabel)
#        self.bottomPanel3.addWidget(self.pathEdit)
        
#        self.bottomPanel4 = QtGui.QHBoxLayout()

#        self.bottomPanel4.addWidget(saveKineticDataVaultButton)
#        self.bottomPanel4.addWidget(openKineticDataVaultButton)
#        self.bottomPanel4.addWidget(pathDataVaultLabel)
#        self.bottomPanel4.addWidget(self.pathDataVaultEdit)        
        
        self.bottomPanel3 = QtGui.QHBoxLayout()

        self.bottomPanel3.addWidget(loadDatasetsButton)
        self.bottomPanel3.addWidget(loadDatasetsLabel)
        self.bottomPanel3.addWidget(self.loadDatasetsEdit)
        self.bottomPanel3.addWidget(pathDataVaultLabel)
        self.bottomPanel3.addWidget(self.pathDataVaultEdit)    
        
        
        self.layout.addLayout(self.bottomPanel1)
        self.layout.addLayout(self.bottomPanel2)
        self.layout.addLayout(self.bottomPanel3)

        self.setWindowTitle('Dark Ion Analysis')  
        self.setLayout(self.layout)
        
        self.setupViewingTools()       


    @inlineCallbacks
    def setupViewingTools(self):    
        context = yield self.parent.cxn.context()
        self.datavaultwidget = DataVaultWidget(self, context)
        self.datavaultwidget.populateList()     
        self.bottomPanel4 = QtGui.QHBoxLayout()
        self.bottomPanel4.addWidget(self.datavaultwidget)
        self.layout.addLayout(self.bottomPanel4)
              
        cameraCanvasLayout = QtGui.QVBoxLayout()
        
        self.bottomPanel4.addLayout(cameraCanvasLayout)
        
        self.cameraCanvas = CameraCanvas(self)
        self.cameraCanvas.show()
        ntbCamera = NavigationToolbar(self.cameraCanvas, self)

        cameraCanvasLayout.addWidget(self.cameraCanvas)
        cameraCanvasLayout.addWidget(ntbCamera)
        
        analysisCanvasLayout = QtGui.QVBoxLayout()
        
        self.bottomPanel4.addLayout(analysisCanvasLayout)
        
        self.analysisCanvas = AnalysisCanvas(self)
        self.analysisCanvas.show()
        ntbAnalysis = NavigationToolbar(self.analysisCanvas, self)

        analysisCanvasLayout.addWidget(self.analysisCanvas)
        self.parametersEdit = QtGui.QLineEdit(readOnly=True)
        analysisCanvasLayout.addWidget(self.parametersEdit)
        analysisCanvasLayout.addWidget(ntbAnalysis)
        
    def setParametersText(self, parametersArray):
        self.parametersEdit.setText('Height: ' + str(parametersArray[0]) + ' ' + 'Alpha: ' + str(parametersArray[1]) + ' ' + 'AxialOffset: ' + str(parametersArray[2]) + ' ' + 'Sigma: ' + str(parametersArray[3]) + ' ' + 'Offset: ' + str(parametersArray[4]))       
        
    def printTemperature(self, evt):
        self.parent.printTemperature()
    
    def getDarkIonCatalog(self, evt):
        self.parent.getDarkIonCatalog(self.imageAnalyzedSpinBox.value(), self.typIonDiameterSpinBox.value(), self.ionThresholdSpinBox.value(), self.darkIonThresholdSpinBox.value(), self.iterationsSpinBox.value())
        
    def getIonPositionCatalog(self, evt):
        self.parent.getIonPositionCatalog(self.imageAnalyzedSpinBox.value(), self.typIonDiameterSpinBox.value(), self.ionThresholdSpinBox.value(), self.darkIonThresholdSpinBox.value(), self.iterationsSpinBox.value(), self.peakVicinitySpinBox.value())
    
    def collectData(self, evt):
        self.parent.collectData(self.iterationsSpinBox.value(), self.imageAnalyzedSpinBox.value())
    
#    def changeExposure(self, value):
#        self.parent.changeExposure(float(self.exposureSpinBox.value())/1000) #convert ms to s     
#        
#    def countDarkIons(self, evt):
#        histWindow = HistWindow(self, self.parent.darkIonCatalog)
#        self.histList.append(histWindow)
#        histWindow.show()
#        print np.mean(self.parent.darkIonCatalog)
        
    def getIonNumberHistogram(self, evt):
        ionNumberCatalogArray = []
        self.parent.buildDarkIonPositionCatalog(self.kineticSetsSpinBox.value(), self.imageAnalyzedSpinBox.value(), self.typIonDiameterSpinBox.value(), self.expectedNumberOfIonsSpinBox.value(), self.iterationsSpinBox.value(), [self.alphaSpinBox.value(), self.axialOffsetSpinBox.value(), self.sigmaSpinBox.value()])
        for i in range(3): 
            ionNumberCatalog = self.parent.getIonNumberHistogram(i + 1, self.imageAnalyzedSpinBox.value(), self.iterationsSpinBox.value(), self.kineticSetsSpinBox.value())
            ionNumberCatalogArray.append(ionNumberCatalog)
        ionSwapCatalog = self.parent.getIonSwapHistogram(self.imageAnalyzedSpinBox.value(), self.iterationsSpinBox.value(), self.expectedNumberOfIonsSpinBox.value(), self.kineticSetsSpinBox.value())
        histWindow = HistWindow(self, ionNumberCatalogArray, ionSwapCatalog)
        self.histList.append(histWindow)
        histWindow.show()
        self.parent.appendParametersToDatasets(self.imageAnalyzedSpinBox.value(), self.iterationsSpinBox.value(), self.kineticSetsSpinBox.value())
    
    def openKinetic(self, evt):
        self.parent.openKinetic(str(self.pathEdit.text()), self.kineticSetsSpinBox.value(), ((self.imageAnalyzedSpinBox.value() + 1)*self.iterationsSpinBox.value()))
        
    def openKineticDataVault(self, evt):
        self.parent.openKineticDataVault(str(self.pathDataVaultEdit.text()), ((self.imageAnalyzedSpinBox.value() + 1)*self.iterationsSpinBox.value()))

    def loadDatasets(self, evt):
        self.parent.loadDatasets(str(self.pathDataVaultEdit.text()), str(self.loadDatasetsEdit.text()), ((self.imageAnalyzedSpinBox.value() + 1)*self.iterationsSpinBox.value()))
    
    def saveKineticDataVault(self, evt):
        self.parent.saveKineticDataVault(str(self.pathDataVaultEdit.text()), 'image', ((self.imageAnalyzedSpinBox.value() + 1)*self.iterationsSpinBox.value()))

    def abortAcquisition(self, evt):
        self.parent.abortAcquisition()
    
    def getData(self, evt):
        self.parent.getData(((self.imageAnalyzedSpinBox.value() + 1)*self.iterationsSpinBox.value()))

    def closeEvent(self, evt):
        self.parent.reactor.stop()           
Пример #14
0
    def __init__(self, parent, context):
        self.parent = parent
        self.context = context
        self.parameterWindows = {}
        self.datasetCheckboxes = {}
        self.datasetCheckboxCounter = 0
        self.manuallyLoaded = True
        QtGui.QMainWindow.__init__(self)
        self.setWindowTitle("Live Grapher")
        self.main_widget = QtGui.QWidget(self)     
        self.setCentralWidget(self.main_widget)
        # create a vertical box layout widget
        grapherLayout = QtGui.QVBoxLayout()
        #vbl.addStretch(1)
        # instantiate our Matplotlib canvas widget
        self.qmc = Qt4MplCanvas(self.main_widget, self)
        # instantiate the navigation toolbar
        ntb = NavigationToolbar(self.qmc, self.main_widget)

        # Layout that involves the canvas, toolbar, graph options...etc.
        grapherLayout.addWidget(ntb)
        grapherLayout.addWidget(self.qmc)

        # Main horizontal layout
        mainLayout = QtGui.QHBoxLayout(self.main_widget)
        self.datavaultwidget = DataVaultWidget(self, self.context)
        self.datavaultwidget.setMaximumWidth(180)
        self.datavaultwidget.populateList()
        # Add the datavault widget
        # Layout that controls datasets
        datasetLayout = QtGui.QVBoxLayout() 
        datasetLayout.addWidget(self.datavaultwidget)

        mainLayout.addLayout(datasetLayout)
        mainLayout.addLayout(grapherLayout)
        
        # Layout for keeping track of datasets on a graph
        self.datasetCheckboxListWidget = QtGui.QListWidget()
        self.datasetCheckboxListWidget.setMaximumWidth(180)
        datasetLayout.addWidget(self.datasetCheckboxListWidget)


        # set the focus on the main widget
        self.main_widget.setFocus()
        # add menu
        self.create_menu()
        # checkbox to change boundaries
        self.cb1 = QtGui.QCheckBox('AutoScroll', self)
        #self.cb1.move(290, 23)
        self.cb1.clicked.connect(self.autoscrollSignal) 
        # checkbox to overlay new dataset
        self.cb2 = QtGui.QCheckBox('Overlay', self)
        #self.cb2.move(500, 35)
        # checkbox to toggle AutoFit
        self.cb3 = QtGui.QCheckBox('AutoFit', self)
        #self.cb3.move(290, 39)
        self.cb3.toggle()
        self.cb3.clicked.connect(self.autofitSignal) 
        # button to fit data on screen
        fitButton = QtGui.QPushButton("Fit", self)
        fitButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
        #fitButton.move(390, 32)
        fitButton.clicked.connect(self.fitDataSignal)
        
        # Layout that controls graph options
        buttonBox = QtGui.QHBoxLayout()
        buttonBox.addWidget(self.cb1) 
        buttonBox.addWidget(self.cb3)
        buttonBox.addWidget(self.cb2)  
        buttonBox.addWidget(fitButton) 
        
        grapherLayout.addLayout(buttonBox)
Пример #15
0
class GrapherWindow(QtGui.QMainWindow):
    """Creates the window for the new plot"""
    def __init__(self, parent, context):
        self.parent = parent
        self.context = context
        self.parameterWindows = {}
        self.datasetCheckboxes = {}
        self.datasetCheckboxCounter = 0
        self.manuallyLoaded = True
        QtGui.QMainWindow.__init__(self)
        self.setWindowTitle("Live Grapher")
        self.main_widget = QtGui.QWidget(self)     
        self.setCentralWidget(self.main_widget)
        # create a vertical box layout widget
        grapherLayout = QtGui.QVBoxLayout()
        #vbl.addStretch(1)
        # instantiate our Matplotlib canvas widget
        self.qmc = Qt4MplCanvas(self.main_widget, self)
        # instantiate the navigation toolbar
        ntb = NavigationToolbar(self.qmc, self.main_widget)

        # Layout that involves the canvas, toolbar, graph options...etc.
        grapherLayout.addWidget(ntb)
        grapherLayout.addWidget(self.qmc)

        # Main horizontal layout
        mainLayout = QtGui.QHBoxLayout(self.main_widget)
        self.datavaultwidget = DataVaultWidget(self, self.context)
        self.datavaultwidget.setMaximumWidth(180)
        self.datavaultwidget.populateList()
        # Add the datavault widget
        # Layout that controls datasets
        datasetLayout = QtGui.QVBoxLayout() 
        datasetLayout.addWidget(self.datavaultwidget)

        mainLayout.addLayout(datasetLayout)
        mainLayout.addLayout(grapherLayout)
        
        # Layout for keeping track of datasets on a graph
        self.datasetCheckboxListWidget = QtGui.QListWidget()
        self.datasetCheckboxListWidget.setMaximumWidth(180)
        datasetLayout.addWidget(self.datasetCheckboxListWidget)


        # set the focus on the main widget
        self.main_widget.setFocus()
        # add menu
        self.create_menu()
        # checkbox to change boundaries
        self.cb1 = QtGui.QCheckBox('AutoScroll', self)
        #self.cb1.move(290, 23)
        self.cb1.clicked.connect(self.autoscrollSignal) 
        # checkbox to overlay new dataset
        self.cb2 = QtGui.QCheckBox('Overlay', self)
        #self.cb2.move(500, 35)
        # checkbox to toggle AutoFit
        self.cb3 = QtGui.QCheckBox('AutoFit', self)
        #self.cb3.move(290, 39)
        self.cb3.toggle()
        self.cb3.clicked.connect(self.autofitSignal) 
        # button to fit data on screen
        fitButton = QtGui.QPushButton("Fit", self)
        fitButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
        #fitButton.move(390, 32)
        fitButton.clicked.connect(self.fitDataSignal)
        
        # Layout that controls graph options
        buttonBox = QtGui.QHBoxLayout()
        buttonBox.addWidget(self.cb1) 
        buttonBox.addWidget(self.cb3)
        buttonBox.addWidget(self.cb2)  
        buttonBox.addWidget(fitButton) 
        
        grapherLayout.addLayout(buttonBox)

    # adds a checkbox when a new dataset is overlaid on the graph
    def createDatasetCheckbox(self, dataset, directory):
        datasetCheckbox = QtGui.QCheckBox(str(dataset) + ' ' + str(directory[-1]), self)
        datasetCheckbox.toggle()
        datasetCheckbox.clicked.connect(self.datasetCheckboxSignal)
        self.datasetCheckboxes[dataset, directory] = datasetCheckbox
        self.datasetCheckboxListWidget.addItem('')
        self.datasetCheckboxListWidget.setItemWidget(self.datasetCheckboxListWidget.item(self.datasetCheckboxCounter), datasetCheckbox)
        self.datasetCheckboxCounter = self.datasetCheckboxCounter + 1

#        self.datasetCheckboxes
#        self.datasetCheckboxModel.appendRow(datasetCheckbox)

    def datasetCheckboxSignal(self):
        #self.qmc.ax.legend()
        self.qmc.drawLegend()
        self.qmc.draw()

    # when the autoFit button is checked, it will uncheck the autoscroll button
    def autofitSignal(self):
        if (self.cb1.isChecked()):
            self.cb1.toggle()
    
    # when the autoscroll button is checked, it will uncheck the autoFit button        
    def autoscrollSignal(self):
        if (self.cb3.isChecked()):
            self.cb3.toggle()

    # instructs the graph to update the boundaries to fit all the data
    def fitDataSignal(self):
        if (self.cb1.isChecked()): # makes sure autoscroll is off otherwise it will undo this operation
            self.cb1.toggle()
        elif (self.cb3.isChecked()): # makes sure autoFit is off otherwise it will undo this operation
            self.cb3.toggle()
        self.qmc.fitData()
    
    def newParameterWindow(self, dataset, directory):
        win = ParameterWindow(self, dataset, directory)
        win.show()
        self.parameterWindows[dataset, directory] = win

    def getParameters(self, dataset, directory):
        parameters = self.parent.getParameters(dataset, directory)
        return parameters                   

    # handles loading a new plot
    def load_plot(self): 
        text, ok = QtGui.QInputDialog.getText(self, 'Open Dataset', 'Enter a dataset:')        
        if ok:
            #MR some type checking that is must be an integer. This won't be necessary when we switch to the browser.
            dataset = int(text)
        text2, ok = QtGui.QInputDialog.getText(self, 'Open Dataset', 'Enter a directory in labrad format:')        
        if ok:
            directory = tuple(eval(str(text2)))
            #MR some type checking that is must be an integer. This won't be necessary when we switch to the browser.
            self.parent.newDataset(dataset, directory, self.manuallyLoaded)
     
    # about menu        
    def on_about(self):
        msg = """ Live Grapher for LabRad! """
        QtGui.QMessageBox.about(self, "About the demo", msg.strip())

    # creates the menu
    def create_menu(self):        
        self.file_menu = self.menuBar().addMenu("&File")
        
        load_file_action = self.create_action("&Load plot",
            shortcut="Ctrl+L", slot=self.load_plot, 
            tip="Save the plot")
        quit_action = self.create_action("&Close Window", slot=self.close, 
            shortcut="Ctrl+Q", tip="Close the application")
        
        self.add_actions(self.file_menu, 
            (load_file_action, None, quit_action))
        
        self.help_menu = self.menuBar().addMenu("&Help")
        about_action = self.create_action("&About", 
            shortcut='F1', slot=self.on_about, 
            tip='About the demo')
        
        self.add_actions(self.help_menu, (about_action,))

    # menu - related
    def add_actions(self, target, actions):
        for action in actions:
            if action is None:
                target.addSeparator()
            else:
                target.addAction(action)

    # menu - related
    def create_action( self, text, slot=None, shortcut=None, 
                        icon=None, tip=None, checkable=False, 
                        signal="triggered()"):
        action = QtGui.QAction(text, self)
        if icon is not None:
            action.setIcon(QtGui.QIcon(":/%s.png" % icon))
        if shortcut is not None:
            action.setShortcut(shortcut)
        if tip is not None:
            action.setToolTip(tip)
            action.setStatusTip(tip)
        if slot is not None:
            self.connect(action, QtCore.SIGNAL(signal), slot)
        if checkable:
            action.setCheckable(True)
        return action
    
    def closeEvent(self, event):
        if (self.cb2.isChecked()):
            # "uncheck" the overlay checkbox
            self.cb2.toggle()
        # Remove this window from the dictionary so that no datasets...
        # ... are drawn to this window
        self.parent.removeWindowFromDictionary(self)
        self.parent.removeWindowFromWinList(self)