Example #1
0
    def initializePlot(self):
        self.first_run = True
        self.win = qtgqt.QtGui.QMainWindow()
        area = darea.DockArea()
        white = (200, 200, 200)
        red = (200, 66, 66); redB = pg.mkBrush(200, 66, 66, 200)
        blue = (6, 106, 166); blueB = pg.mkBrush(6, 106, 166, 200)
        green = (16, 200, 166); greenB = pg.mkBrush(16, 200, 166, 200)
        yellow = (244, 244, 160); yellowB = pg.mkBrush(244, 244, 160, 200)
        darkyellow = (224, 166, 58); darkyellowB = pg.mkBrush(224, 166, 58, 200);
        self.win.setWindowTitle("Leaf control 1")
        self.win.setWindowIcon(qtgqt.QtGui.QIcon(self.rospack.get_path("ros_guis") + "/img/icon01.png"))
        self.win.resize(700, 600)
        self.win.setCentralWidget(area)
        dock1def = darea.Dock("Default", size = (1,1))  # give this dock minimum possible size
        dock2oth = darea.Dock("Others", size = (1,1))  # give this dock minimum possible size
        dock3ctr = darea.Dock("Control", size = (1,1))  # give this dock minimum possible size
        dock4gps = darea.Dock("2 Gps visualization", size = (500,400)) # size is only a suggestion
        area.addDock(dock1def, "left")
        area.addDock(dock2oth, "bottom", dock1def)
        area.addDock(dock3ctr, "above", dock2oth)
        area.addDock(dock4gps, "bottom", dock3ctr)
        dhLabel = qtgqt.QtGui.QLabel("Duro:"); dhLabel.setStyleSheet("background-color: rgb(4, 4, 4);"); dhLabel.setAlignment(pg.QtCore.Qt.AlignRight); dhLabel.setFixedSize(50, 25)
        dsLabel = qtgqt.QtGui.QLabel("Duro:"); dsLabel.setStyleSheet("background-color: rgb(4, 4, 4);"); dsLabel.setAlignment(pg.QtCore.Qt.AlignRight); dsLabel.setFixedSize(50, 25)
        nhLabel = qtgqt.QtGui.QLabel("Nova:"); nhLabel.setStyleSheet("background-color: rgb(4, 4, 4);"); nhLabel.setAlignment(pg.QtCore.Qt.AlignRight)
        nsLabel = qtgqt.QtGui.QLabel("Nova:"); nsLabel.setStyleSheet("background-color: rgb(4, 4, 4);"); nsLabel.setAlignment(pg.QtCore.Qt.AlignRight)     
        self.duroRtkLabel = qtgqt.QtGui.QLabel("+++")
        self.novaRtkLabel = qtgqt.QtGui.QLabel("+++")
        self.pauseSensorReadClickedBtn = qtgqt.QtGui.QPushButton("Pause")
        self.savePoseBtn = qtgqt.QtGui.QPushButton("Save")
        self.allSensorLaunchBtn = qtgqt.QtGui.QPushButton("Start AllSensor")
        self.tfSensorLaunchBtn = qtgqt.QtGui.QPushButton("Start TF")
        self.tfDuroLaunchBtn = qtgqt.QtGui.QPushButton("Start TF Duro")
        self.tfNovaLaunchBtn = qtgqt.QtGui.QPushButton("Start TF Nova")
        self.duroSensorLaunchBtn = qtgqt.QtGui.QPushButton("Start Duro GPS")
        self.novaSensorLaunchBtn = qtgqt.QtGui.QPushButton("Start Nova GPS")
        self.zedSensorLaunchBtn = qtgqt.QtGui.QPushButton("Start ZED camera")
        self.sickSensorLaunchBtn = qtgqt.QtGui.QPushButton("Start SICK")
        self.ousterLeftSensorLaunchBtn = qtgqt.QtGui.QPushButton("Start left Ouster")
        self.ousterRightSensorLaunchBtn = qtgqt.QtGui.QPushButton("Start right Ouster")
        self.veloLeftSensorLaunchBtn = qtgqt.QtGui.QPushButton("Start left Velodyne")
        self.veloRightSensorLaunchBtn = qtgqt.QtGui.QPushButton("Start right Velodyne")
        self.canSensorLaunchBtn = qtgqt.QtGui.QPushButton("Start CAN")
        self.radarSensorLaunchBtn = qtgqt.QtGui.QPushButton("Start Radar")
        self.mpcOnOffBtn = qtgqt.QtGui.QPushButton("Disable MPC")
        self.temporaryLaunchBtn = qtgqt.QtGui.QPushButton("Start temporary")
        self.loadWaypointBtn = qtgqt.QtGui.QPushButton("Load waypoints")
        self.saveWaypointBtn = qtgqt.QtGui.QPushButton("Save waypoints")
        self.selectFileBtn = qtgqt.QtGui.QPushButton("...")
        self.selectFileBtn.setMaximumWidth(22)
        self.speedLabel = qtgqt.QtGui.QLabel(" **.* Km/h")
        self.angleLabel = qtgqt.QtGui.QLabel(" **.* rad")
        self.csvLabel = qtgqt.QtGui.QLabel("none"); self.csvLabel.setAlignment(pg.QtCore.Qt.AlignRight)
        self.csvTextbox = qtgqt.QtGui.QLineEdit()
        self.allSensorLaunched = False
        self.waypointLoaded = False
        self.waypointSaving = False
        self.tfLaunched = False
        self.tfSensorLaunched = False
        self.tfDuroLaunched = False
        self.tfNovaLaunched = False
        self.duroSensorLaunched = False
        self.novaSensorLaunched = False
        self.zedSensorLaunched = False
        self.sickSensorLaunched = False
        self.ousterLeftSensorLaunched = False
        self.ousterRightSensorLaunched = False
        self.veloLeftSensorLaunched = False
        self.veloRightSensorLaunched = False
        self.canSensorLaunched = False
        self.radarSensorLaunched = False
        self.temporaryLaunched = False
        self.mpcFollow = True
        widg1def = pg.LayoutWidget()
        widg1def.setStyleSheet("background-color: rgb(40, 44, 52); color: rgb(171, 178, 191);")
        dock1def.setStyleSheet("background-color: rgb(18, 20, 23);")
        dock1def.addWidget(widg1def)
        self.novaRtkLabel.setStyleSheet("font-family: Monospace; font: 20pt; color: rgb(6, 106, 166)")
        self.duroRtkLabel.setStyleSheet("font-family: Monospace; font: 20pt; color: rgb(244, 166, 58)")
        self.angleLabel.setStyleSheet("font-family: Monospace; font: 20pt; color: rgb(200, 200, 200)")
        self.speedLabel.setStyleSheet("font-family: Monospace; font: 20pt; color: rgb(200, 200, 200)")
        self.csvLabel.setStyleSheet("font: 10pt; color: rgb(244, 166, 58)")
        sickLabel = qtgqt.QtGui.QLabel("Sick:"); sickLabel.setStyleSheet("background-color: rgb(4, 4, 4);"); sickLabel.setAlignment(pg.QtCore.Qt.AlignRight); sickLabel.setFixedSize(50, 25)
        olhLabel = qtgqt.QtGui.QLabel("OusterLeft:"); olhLabel.setStyleSheet("background-color: rgb(4, 4, 4);"); olhLabel.setAlignment(pg.QtCore.Qt.AlignRight); olhLabel.setFixedSize(80, 25)
        orhLabel = qtgqt.QtGui.QLabel("OusterRight:"); orhLabel.setStyleSheet("background-color: rgb(4, 4, 4);"); orhLabel.setAlignment(pg.QtCore.Qt.AlignRight); orhLabel.setFixedSize(95, 25)
        vlhLabel = qtgqt.QtGui.QLabel("VeloLeft:"); vlhLabel.setStyleSheet("background-color: rgb(4, 4, 4);"); vlhLabel.setAlignment(pg.QtCore.Qt.AlignRight)
        vrhLabel = qtgqt.QtGui.QLabel("VeloRight:"); vrhLabel.setStyleSheet("background-color: rgb(4, 4, 4);"); vrhLabel.setAlignment(pg.QtCore.Qt.AlignRight)
        self.sickOkLabel = qtgqt.QtGui.QLabel("**")
        self.sickOkLabel.setStyleSheet("font-family: Monospace; font: 20pt; color: rgb(224, 166, 58)")
        self.ousterLefLabel = qtgqt.QtGui.QLabel(" **")
        self.ousterLefLabel.setStyleSheet("font-family: Monospace; font: 20pt; color: rgb(16, 200, 166)")
        self.ousterRigLabel = qtgqt.QtGui.QLabel(" **")
        self.ousterRigLabel.setStyleSheet("font-family: Monospace; font: 20pt; color: rgb(16, 200, 166)")
        self.veloLef = qtgqt.QtGui.QLabel(" **")
        self.veloLef.setStyleSheet("font-family: Monospace; font: 20pt; color: rgb(200, 66, 66)")
        self.veloRig = qtgqt.QtGui.QLabel(" **")
        self.veloRig.setStyleSheet("font-family: Monospace; font: 20pt; color: rgb(200, 66, 66)")      
        # default
        widg1def.addWidget(dsLabel, row=1, col=6)
        widg1def.addWidget(nsLabel, row=2, col=6)
        widg1def.addWidget(self.duroRtkLabel, row=1, col=7)
        widg1def.addWidget(self.novaRtkLabel, row=2, col=7)
        widg1def.addWidget(self.speedLabel, row=3, col=2)
        widg1def.addWidget(self.angleLabel, row=3, col=4)
        widg1def.addWidget(self.pauseSensorReadClickedBtn, row=4, col=7)
        widg1def.addWidget(olhLabel, row=1, col=1)
        widg1def.addWidget(orhLabel, row=1, col=3)
        widg1def.addWidget(vlhLabel, row=2, col=1)
        widg1def.addWidget(vrhLabel, row=2, col=3)
        widg1def.addWidget(sickLabel, row=4, col=1)
        widg1def.addWidget(self.sickOkLabel, row=4, col=2)
        widg1def.addWidget(self.ousterLefLabel, row=1, col=2)
        widg1def.addWidget(self.ousterRigLabel, row=1, col=4)
        widg1def.addWidget(self.veloLef, row=2, col=2)
        widg1def.addWidget(self.veloRig, row=2, col=4)
        self.zedOkLabel = qtgqt.QtGui.QLabel("**")
        self.zedOkLabel.setStyleSheet("font-family: Monospace; font: 20pt; color: rgb(123, 64, 133)")
        zhLabel = qtgqt.QtGui.QLabel("Zed:"); zhLabel.setStyleSheet("background-color: rgb(4, 4, 4);"); zhLabel.setAlignment(pg.QtCore.Qt.AlignRight); zhLabel.setFixedSize(50, 25)
        widg1def.addWidget(zhLabel, row=3, col=6)
        widg1def.addWidget(self.zedOkLabel, row=3, col=7)

        self.state = None
        self.widgGps = pg.PlotWidget(title="Gps difference")
        self.widgGps.setAspectLocked(True)
        self.pltGpsOdom = pg.ScatterPlotItem(size = 10, pen = pg.mkPen(None), brush = blueB)
        self.pltDuroOrientation = pg.PlotCurveItem(pen=pg.mkPen(qtgqt.QtGui.QColor(244, 166, 58), width=6))
        self.pltNovaOrientation = pg.PlotCurveItem(pen=pg.mkPen(qtgqt.QtGui.QColor(200, 66, 66), width=8))
        self.pltLeafOdom = pg.ScatterPlotItem(size = 10, pen = pg.mkPen(None), brush = redB)
        self.widgGps.showGrid(x=True, y=True)
        self.widgGps.addItem(self.pltGpsOdom)
        self.widgGps.addItem(self.pltNovaOrientation)
        self.widgGps.addItem(self.pltDuroOrientation)
        self.widgGps.addItem(self.pltLeafOdom)
        dock4gps.addWidget(self.widgGps)
        self.pauseSensorReadClickedBtn.clicked.connect(self.pauseSensorReadClicked)
        self.savePoseBtn.clicked.connect(self.saveToCsvClicked)
        self.allSensorLaunchBtn.clicked.connect(self.startAllSensorClicked)
        self.tfSensorLaunchBtn.clicked.connect(self.startTFClicked)
        self.tfDuroLaunchBtn.clicked.connect(self.tfDuroClicked)
        self.tfNovaLaunchBtn.clicked.connect(self.tfNovaClicked)
        self.zedSensorLaunchBtn.clicked.connect(self.zedSensorClicked)
        self.duroSensorLaunchBtn.clicked.connect(self.duroSensorClicked)
        self.novaSensorLaunchBtn.clicked.connect(self.novaSensorClicked)
        self.sickSensorLaunchBtn.clicked.connect(self.sickSensorClicked)
        self.ousterLeftSensorLaunchBtn.clicked.connect(self.ousterLeftSensorClicked)
        self.ousterRightSensorLaunchBtn.clicked.connect(self.ousterRightSensorClicked)
        self.veloLeftSensorLaunchBtn.clicked.connect(self.veloLeftSensorClicked)
        self.veloRightSensorLaunchBtn.clicked.connect(self.veloRightSensorClicked)        
        self.canSensorLaunchBtn.clicked.connect(self.canSensorClicked)
        self.radarSensorLaunchBtn.clicked.connect(self.radarSensorClicked)
        self.mpcOnOffBtn.clicked.connect(self.mpcOnOffBtnClicked)
        self.temporaryLaunchBtn.clicked.connect(self.temporaryClicked)
        self.loadWaypointBtn.clicked.connect(self.loadCsvClicked)
        self.saveWaypointBtn.clicked.connect(self.saveCsvClicked)
        self.selectFileBtn.clicked.connect(self.selectCsvClicked)
        
        self.tGps = pg.TextItem(text = "Gps", color = blue)
        self.tLeaf = pg.TextItem(text = "Leaf odom", color = red)
        self.tstart = pg.TextItem(text = "Start", color = white)

        
        dock2oth.setStyleSheet("background-color: rgb(18, 20, 23);")
        self.drawCircle(self.widgGps)
        # other controls
        widg2oth = pg.LayoutWidget()
        dock2oth.setStyleSheet("background-color: rgb(18, 20, 23);")
        widg2oth.setStyleSheet("background-color: rgb(40, 44, 52); color: rgb(171, 178, 191);")
        widg2oth.addWidget(self.tfSensorLaunchBtn, row=1, col=1)
        widg2oth.addWidget(self.tfDuroLaunchBtn, row = 1, col = 2)
        widg2oth.addWidget(self.tfNovaLaunchBtn, row = 1, col = 3)
        widg2oth.addWidget(self.zedSensorLaunchBtn, row = 2, col = 1)
        widg2oth.addWidget(self.duroSensorLaunchBtn, row = 2, col = 2)
        widg2oth.addWidget(self.novaSensorLaunchBtn, row = 2, col = 3)
        widg2oth.addWidget(self.sickSensorLaunchBtn, row = 3, col = 1)
        widg2oth.addWidget(self.ousterLeftSensorLaunchBtn, row = 3, col = 2)
        widg2oth.addWidget(self.ousterRightSensorLaunchBtn, row = 3, col = 3)
        widg2oth.addWidget(self.canSensorLaunchBtn, row = 4, col = 1)
        widg2oth.addWidget(self.radarSensorLaunchBtn, row = 5, col = 1)
        widg2oth.addWidget(self.mpcOnOffBtn, row = 5, col = 3)
        widg2oth.addWidget(self.veloLeftSensorLaunchBtn, row = 4, col = 2)
        widg2oth.addWidget(self.veloRightSensorLaunchBtn, row = 4, col = 3)
        widg2oth.addWidget(self.temporaryLaunchBtn, row = 5, col = 2)

        dock2oth.addWidget(widg2oth)

        # control
        widg3ctr = pg.LayoutWidget()
        dock3ctr.setStyleSheet("background-color: rgb(18, 20, 23);")
        widg3ctr.setStyleSheet("background-color: rgb(40, 44, 52); color: rgb(171, 178, 191);")
        widg3ctr.addWidget(self.allSensorLaunchBtn, row=1, col=1)
        widg3ctr.addWidget(self.loadWaypointBtn, row=2, col=1)
        widg3ctr.addWidget(self.saveWaypointBtn, row=3, col=1)
        widg3ctr.addWidget(self.csvLabel, row=2, col=2)
        widg3ctr.addWidget(self.selectFileBtn, row=2, col=3)
        widg3ctr.addWidget(self.csvTextbox, row=3, col=2)
        dock3ctr.addWidget(widg3ctr)
        widg3ctr.addWidget(self.allSensorLaunchBtn, row=1, col=1)
        try:
            current_file = rospy.get_param("waypoint_file_name")
            self.csvLabel.setText(os.path.basename(str(current_file)))
        except:
            self.csvLabel.setText("No waypoint_file_name param")
        self.pauseSensorReadClicked() # start paused - the same effect as pushed the pause button
        self.win.show()
    def __init__(self, parent = None):
        self.parent = parent

        ## Dock: Indexing
        self.dock = Dock("Indexing", size=(1, 1))
        self.win = ParameterTree()
        #self.win.setWindowTitle('Indexing')
        self.dock.addWidget(self.win)
        self.winL = pg.LayoutWidget()
        self.launchIndexBtn = QtGui.QPushButton('Launch indexing')
        self.winL.addWidget(self.launchIndexBtn, row=0, col=0)
        self.synchBtn = QtGui.QPushButton('Deploy CrystFEL geometry')
        self.winL.addWidget(self.synchBtn, row=1, col=0)
        self.dock.addWidget(self.winL)

        self.index_grp = 'Crystal indexing'
        self.index_on_str = 'Indexing on'
        self.index_geom_str = 'CrystFEL geometry'
        self.index_peakMethod_str = 'Peak method'
        self.index_intRadius_str = 'Integration radii'
        self.index_pdb_str = 'Unitcell'
        self.index_method_str = 'Indexing method'
        self.index_tolerance_str = 'Tolerance'
        self.index_extra_str = 'Extra CrystFEL parameters'
        self.index_condition_str = 'Index condition'

        self.launch_grp = 'Batch'
        self.outDir_str = 'Output directory'
        self.runs_str = 'Runs(s)'
        self.sample_str = 'Sample name'
        self.tag_str = '.stream tag'
        self.queue_str = 'Queue'
        self.chunkSize_str = 'Chunk size'
        self.cpu_str = 'CPUs'
        self.keepData_str = 'Keep CXI images'
        self.noe_str = 'Number of events to process'
        (self.psanaq_str,self.psnehq_str,self.psfehq_str,self.psnehprioq_str,self.psfehprioq_str,self.psnehhiprioq_str,self.psfehhiprioq_str,self.psdebugq_str,self.psanagpuq_str,self.psanaidleq_str) = \
            ('psanaq','psnehq','psfehq','psnehprioq','psfehprioq','psnehhiprioq','psfehhiprioq','psdebugq','psanagpuq','psanaidleq')
        self.noQueue_str = 'N/A'

        self.outDir = self.parent.psocakeDir
        self.outDir_overridden = False
        self.runs = ''
        self.sample = 'crystal'
        self.tag = ''
        self.queue = self.psanaq_str
        self.chunkSize = 500
        self.cpu = 12
        self.noe = -1

        # Indexing
        self.showIndexedPeaks = False
        self.indexedPeaks = None
        self.hiddenCXI = '.temp.cxi'
        self.hiddenCrystfelStream = '.temp.stream'
        self.hiddenCrystfelList = '.temp.lst'
        self.indexingOn = False
        self.numIndexedPeaksFound = 0
        self.geom = '.temp.geom'
        self.peakMethod = 'cxi'
        self.intRadius = '4,5,6'
        self.pdb = ''
        self.indexingMethod = 'mosflm'
        self.tolerance = '5,5,5,1.5'
        self.extra = ''
        self.condition = ''
        self.keepData = True
        self.indexCounter = 0
        self.threadpool = []
        self.workerpool = []

        #######################
        # Mandatory parameter #
        #######################
        self.params = [
            {'name': self.index_grp, 'type': 'group', 'children': [
                {'name': self.index_on_str, 'type': 'bool', 'value': self.indexingOn, 'tip': "Turn on indexing"},
                {'name': self.index_geom_str, 'type': 'str', 'value': self.geom, 'tip': "CrystFEL geometry file"},
                #{'name': self.index_peakMethod_str, 'type': 'str', 'value': self.peakMethod, 'tip': "Turn on indexing"},
                {'name': self.index_intRadius_str, 'type': 'str', 'value': self.intRadius, 'tip': "Integration radii"},
                {'name': self.index_pdb_str, 'type': 'str', 'value': self.pdb, 'tip': "(Optional) CrystFEL unitcell file"},
                {'name': self.index_method_str, 'type': 'str', 'value': self.indexingMethod, 'tip': "comma separated indexing methods"},
                {'name': self.index_tolerance_str, 'type': 'str', 'value': self.tolerance,
                 'tip': "Indexing tolerance, default: 5,5,5,1.5"},
                {'name': self.index_extra_str, 'type': 'str', 'value': self.extra,
                 'tip': "Other indexing parameters, comma separated (e.g. --multi,--no-check-peaks)"},
                {'name': self.index_condition_str, 'type': 'str', 'value': self.condition,
                 'tip': "indexing condition e.g. 41 in #evr1# and #eventNumber# > 3"},
            ]},
            {'name': self.launch_grp, 'type': 'group', 'children': [
                {'name': self.outDir_str, 'type': 'str', 'value': self.outDir},
                {'name': self.runs_str, 'type': 'str', 'value': self.runs, 'tip': "comma separated or use colon for a range, e.g. 1,3,5:7 = runs 1,3,5,6,7"},
                {'name': self.sample_str, 'type': 'str', 'value': self.sample, 'tip': "name of the sample saved in the cxidb file, e.g. lysozyme"},
                {'name': self.tag_str, 'type': 'str', 'value': self.tag, 'tip': "attach tag to stream, e.g. cxitut13_0010_tag.stream"},
                {'name': self.queue_str, 'type': 'list', 'values': {self.psfehhiprioq_str: self.psfehhiprioq_str,
                                                               self.psnehhiprioq_str: self.psnehhiprioq_str,
                                                               self.psfehprioq_str: self.psfehprioq_str,
                                                               self.psnehprioq_str: self.psnehprioq_str,
                                                               self.psfehq_str: self.psfehq_str,
                                                               self.psnehq_str: self.psnehq_str,
                                                               self.psanaq_str: self.psanaq_str,
                                                               self.psdebugq_str: self.psdebugq_str,
                                                               self.psanagpuq_str: self.psanagpuq_str,
                                                               self.psanaidleq_str: self.psanaidleq_str},
                 'value': self.queue, 'tip': "Choose queue"},
                {'name': self.chunkSize_str, 'type': 'int', 'value': self.chunkSize, 'tip': "number of patterns to process per worker"},
                {'name': self.keepData_str, 'type': 'bool', 'value': self.keepData, 'tip': "Do not delete cxidb images in cxi file"},
            ]},
        ]

        self.p9 = Parameter.create(name='paramsCrystalIndexing', type='group', \
                                   children=self.params, expanded=True)
        self.win.setParameters(self.p9, showTop=False)
        self.p9.sigTreeStateChanged.connect(self.change)

        if using_pyqt4:
            self.parent.connect(self.launchIndexBtn, QtCore.SIGNAL("clicked()"), self.indexPeaks)
            self.parent.connect(self.synchBtn, QtCore.SIGNAL("clicked()"), self.syncGeom)
        else:
            self.launchIndexBtn.clicked.connect(self.indexPeaks)
            self.synchBtn.clicked.connect(self.syncGeom)
Example #3
0
    def __init__(self, parent=None):
        self.parent = parent

        #############################
        ## Dock 3: Diffraction geometry
        #############################
        self.d3 = Dock("Diffraction Geometry", size=(1, 1))
        self.w3 = ParameterTree()
        self.w3.setWindowTitle('Diffraction geometry')
        self.d3.addWidget(self.w3)
        self.w3a = pg.LayoutWidget()
        self.deployGeomBtn = QtGui.QPushButton(
            'Deploy manually centred geometry')
        self.w3a.addWidget(self.deployGeomBtn, row=0, col=0)
        self.deployAutoGeomBtn = QtGui.QPushButton(
            'Deploy automatically centred geometry')
        self.w3a.addWidget(self.deployAutoGeomBtn, row=1, col=0)
        self.d3.addWidget(self.w3a)

        self.resolutionRingList = np.array(
            [100., 300., 500., 700., 900., 1100.])
        self.resolutionText = []
        self.hasUserDefinedResolution = False

        self.geom_grp = 'Diffraction geometry'
        self.geom_detectorDistance_str = 'Detector distance'
        self.geom_clen_str = 'Home to Detector (clen)'
        self.geom_coffset_str = 'Sample to Home (coffset)'
        self.geom_photonEnergy_str = 'Photon energy'
        self.geom_wavelength_str = "Wavelength"
        self.geom_pixelSize_str = 'Pixel size'
        self.geom_resolutionRings_str = 'Resolution rings'
        self.geom_resolution_str = 'Resolution (pixels)'
        self.geom_resolutionUnits_str = 'Units'
        self.geom_unitA_crystal_str = 'Crystallography (Angstrom)'
        self.geom_unitNm_crystal_str = 'Crystallography (Nanometre)'
        self.geom_unitQ_crystal_str = 'Crystallography Reciprocal Space (q)'
        self.geom_unitA_physics_str = 'Physics (Angstrom)'
        self.geom_unitNm_physics_str = 'Physics (Nanometre)'
        self.geom_unitQ_physics_str = 'Physics Reciprocal Space (q)'
        self.geom_unitTwoTheta_str = 'Scattering Angle 2Theta'
        (self.unitA_c, self.unitNm_c, self.unitQ_c, self.unitA_p,
         self.unitNm_p, self.unitQ_p, self.unitTwoTheta) = (0, 1, 2, 3, 4, 5,
                                                            6)

        #######################
        # Mandatory parameter #
        #######################
        self.params = [
            {
                'name':
                self.geom_grp,
                'type':
                'group',
                'children': [
                    {
                        'name': self.geom_detectorDistance_str,
                        'type': 'float',
                        'value': 0.0,
                        'precision': 6,
                        'minVal': 0.0001,
                        'siFormat': (6, 6),
                        'siPrefix': True,
                        'suffix': 'mm'
                    },
                    {
                        'name': self.geom_clen_str,
                        'type': 'float',
                        'value': 0.0,
                        'step': 1e-6,
                        'siPrefix': True,
                        'suffix': 'm',
                        'readonly': True
                    },
                    {
                        'name': self.geom_coffset_str,
                        'type': 'float',
                        'value': 0.0,
                        'step': 1e-6,
                        'siPrefix': True,
                        'suffix': 'm',
                        'readonly': True
                    },
                    {
                        'name': self.geom_photonEnergy_str,
                        'type': 'float',
                        'value': 0.0,
                        'step': 1e-6,
                        'siPrefix': True,
                        'suffix': 'eV'
                    },
                    {
                        'name': self.geom_wavelength_str,
                        'type': 'float',
                        'value': 0.0,
                        'step': 1e-6,
                        'siPrefix': True,
                        'suffix': 'm',
                        'readonly': True
                    },
                    {
                        'name': self.geom_pixelSize_str,
                        'type': 'float',
                        'value': 0.0,
                        'precision': 12,
                        'minVal': 1e-6,
                        'siPrefix': True,
                        'suffix': 'm'
                    },
                    {
                        'name':
                        self.geom_resolutionRings_str,
                        'type':
                        'bool',
                        'value':
                        False,
                        'tip':
                        "Display resolution rings",
                        'children': [
                            {
                                'name': self.geom_resolution_str,
                                'type': 'str',
                                'value': None
                            },
                            {
                                'name': self.geom_resolutionUnits_str,
                                'type': 'list',
                                'values': {
                                    self.geom_unitA_crystal_str: self.unitA_c,
                                    self.geom_unitNm_crystal_str:
                                    self.unitNm_c,
                                    self.geom_unitQ_crystal_str: self.unitQ_c,
                                    self.geom_unitA_physics_str: self.unitA_p,
                                    self.geom_unitNm_physics_str:
                                    self.unitNm_p,
                                    self.geom_unitQ_physics_str: self.unitQ_p,
                                    self.geom_unitTwoTheta_str:
                                    self.unitTwoTheta
                                },
                                'value': self.unitA_c
                            },
                        ]
                    },
                ]
            },
        ]

        self.p1 = Parameter.create(name='paramsDiffractionGeometry', type='group', \
                                   children=self.params, expanded=True)
        self.p1.sigTreeStateChanged.connect(self.change)
        self.w3.setParameters(self.p1, showTop=False)

        self.deployGeomBtn.clicked.connect(self.deploy)
        self.deployAutoGeomBtn.clicked.connect(self.autoDeploy)
Example #4
0
    def initGui(self):
        area = DockArea()
        self.setCentralWidget(area)
        ##Dock
        d2 = Dock("Graph", size=(1000, 50))

        area.addDock(d2, 'top')

        ##Widget
        w2 = pg.LayoutWidget()
        #set font
        font = QtGui.QFont()
        font.setBold(True)

        ##continuous sample mode
        self.continuousModeLable = QtGui.QLabel("Continuous sample data:")
        self.continuousModeLable.setFont(font)
        w2.addWidget(self.continuousModeLable, row=2, col=0)

        ##continuouse data sample start pb
        self.continuouseDataStartPb = QtGui.QPushButton("Start")
        self.continuouseDataStartPb.setFixedWidth(90)
        self.continuouseDataStartPb.setFixedHeight(30)
        self.continuouseDataStartPb.clicked.connect(
            self.startContinuouseDownload)
        w2.addWidget(self.continuouseDataStartPb, row=3, col=0)

        ##continuouse data sample stop pb
        self.continuouseDataStopPb = QtGui.QPushButton("Stop")
        self.continuouseDataStopPb.setFixedWidth(90)
        self.continuouseDataStopPb.setFixedHeight(30)
        self.continuouseDataStopPb.clicked.connect(self.stopRuningContinuouse)
        self.continuouseDataStopPb.setEnabled(False)
        w2.addWidget(self.continuouseDataStopPb, row=3, col=1)
        d2.addWidget(w2)

        ##Graph preasure
        pwPreas = pg.PlotWidget(name='ADC Value')
        pwPreas.setTitle(title="ADC Value")
        pwPreas.setLabel('left', 'Value', units='bits')
        pwPreas.setLabel('bottom', 'Samples')
        self.p1 = pwPreas.plot(title="ADC_value")
        self.p1.setPen((200, 200, 100))
        d2.addWidget(pwPreas)

        ##Sensor 1 fft
        #		pwFFTS1 = pg.PlotWidget(name='Plot2')
        #		pwFFTS1.setTitle(title = "Sensor1 FFT")
        #		pwFFTS1.setLabel('left', 'Y', units='X')
        #		pwFFTS1.setLabel('bottom', 'X')
        #		self.p3 = pwFFTS1.plot(title="TEMPERATURE")
        #		self.p3.setPen((200,200,100))
        #		d2.addWidget(pwFFTS1)

        ##Graph temperature
        #		pwTemp = pg.PlotWidget(name='Plot2')
        #		pwTemp.setTitle(title = "Sensor2")
        #		pwTemp.setLabel('left', 'Value', units='bits')
        #		pwTemp.setLabel('bottom', 'Samples')
        #		self.p2 = pwTemp.plot(title="TEMPERATURE")
        #		self.p2.setPen((200,200,100))
        #		d2.addWidget(pwTemp)

        ##Sensor 2 fft
        #		pwFFTS2 = pg.PlotWidget(name='Plot2')
        #		pwFFTS2.setTitle(title = "Sensor2 FFT")
        #		pwFFTS2.setLabel('left', 'Y', units='X')
        #		pwFFTS2.setLabel('bottom', 'X')
        #		self.p4 = pwFFTS2.plot(title="TEMPERATURE")
        #		self.p4.setPen((200,200,100))
        #		d2.addWidget(pwFFTS2)

        #Setup main window
        self.setGeometry(300, 300, 600, 600)
        self.setWindowTitle('READ ADC DATA FROM STM32')
        self.show()
        if (TCP_conn.OpenTCP()):
            if DEBUG:
                print("Connected")
        else:
            self.continuouseDataStopPb.setEnabled(False)
            self.continuouseDataStartPb.setEnabled(False)

        #Connections between threads
        #Good example on treading signals
        #https://gitlab.com/aleksandaratanasov/pyqt_threaded_ui/blob/master/threaded_ui.py
        self.workerContinuouse.finished.connect(self.terminateWorkerContin)
        self.workerContinuouse.updating.connect(self.updateGraph)
        self.workerContinuouse.dataContin.connect(self.dataContinuouse)
Example #5
0
    def __init__(self, parent=None):

        self._DEBUGUER = 0
        QtGui.QMainWindow.__init__(self, parent)
        # set the main window
        self.resize(1000, 800)
        self.setWindowTitle('VIEWLER ARISTARKO')

        #CONTROL VARIABLES
        self.len = 100
        self.focus = False
        self.events = []  # list for store events
        self.plots = []  # list of plots
        self.ini = False
        self.fin = False

        #set dock area as central widget
        self.area = DockArea()
        self.setCentralWidget(
            self.area)  # inserto el pg como una widget central.

        #create docks and add them into dock area
        self.d1 = Dock("Controls", size=(200, 50), closable=True)
        self.d2 = Dock("Plots", size=(600, 480))
        #self.d3 = Dock("FOCUS", size=(400, 400), closable=True)
        self.area.addDock(self.d1, 'left')
        self.area.addDock(self.d2)

        #create a layout for dock 1. I am going to introduce more widgets
        self.w1 = pg.LayoutWidget()
        self.w2 = pg.LayoutWidget()
        self.w3 = pg.LayoutWidget()

        #create widgets and move into each dock

        #checkboxes
        edacb = QtGui.QCheckBox('EDA', self)
        emgcb = QtGui.QCheckBox('EMG', self)
        ecgcb = QtGui.QCheckBox('ECG', self)
        sktcb = QtGui.QCheckBox('SKT', self)
        edacb.toggle()
        emgcb.toggle()
        ecgcb.toggle()
        sktcb.toggle()

        #slider
        self.label1 = QtGui.QLabel("Zoom", )
        self.slider1 = QtGui.QSlider()
        self.slider1.setOrientation(QtCore.Qt.Horizontal)
        self.slider1.setRange(0, 99)
        self.slider1.setValue(1)

        #pyqtgraph
        self.win = pg.GraphicsWindow()
        self.win.resize(600, 600)
        self.win.setWindowTitle('VIEWLER ARISTARKO')
        #self.win2 = pg.GraphicsWindow()
        #self.win2.setWindowTitle('eventos')

        #locate widgets into layout
        #self.w1.addWidget(self.button, row=0, col=0)
        self.w1.addWidget(self.label1, row=1, col=0)
        self.w1.addWidget(self.slider1, row=1, col=1, colspan=2)
        self.w1.addWidget(edacb, row=2, col=0)
        self.w1.addWidget(emgcb, row=2, col=1)
        self.w1.addWidget(ecgcb, row=2, col=2)
        self.w1.addWidget(sktcb, row=2, col=3)

        #self.w2.addWidget(self.win, row=0, col=0)

        #move gidgets into docks
        self.d1.addWidget(self.w1)
        self.d2.addWidget(self.win)
        #self.d3.addWidget(self.win2)

        ######################################################
        ####################### PLOTS ########################
        ######################################################

        #PLOTS DEL EDA
        self.p1 = self.win.addPlot(name="EDA", title="Electro-Dermal Activity")
        #set the range of Xdata
        self.p1.setRange(xRange=[-self.len, 0])
        self.p1.setLimits(xMax=0)
        self.plots.append(self.p1)

        #creating curve for EDA
        self.curve1 = self.p1.plot(pen=(255, 0, 0), clickable=True)
        #self.curve1.sigPointsClicked.connect(self.plotClicked)
        #creating data vector
        self.eda = np.zeros(self.len)

        #PLOTS DEL EMG
        self.win.nextRow()
        self.p2 = self.win.addPlot(title="Electromyogram")
        #set the range of Xdata
        self.p2.setRange(xRange=[-self.len, 0])
        self.p2.setLimits(xMax=0)
        self.plots.append(self.p2)
        #creating curve for EDA
        self.curve2 = self.p2.plot(pen=(0, 0, 255))
        #creating data vector
        self.emg = np.zeros(self.len)

        #PLOTS DEL HRV
        self.win.nextRow()
        self.p3 = self.win.addPlot(title="Electrocardiogram")
        #set the range
        self.p3.setRange(xRange=[-self.len, 0])
        self.p3.setLimits(xMax=0)
        self.plots.append(self.p3)
        #creating curve for HRV
        self.curve3 = self.p3.plot(pen=(0, 255, 0))
        #creating data vector
        self.ecg = np.zeros(self.len)

        #PLOTS DEL SKT
        self.win.nextRow()
        self.p4 = self.win.addPlot(title="Skin Temperature")
        #set the range
        self.p4.setRange(xRange=[-self.len, 0])
        self.p4.setLimits(xMax=0)
        self.plots.append(self.p4)
        #creating curve for SKT
        self.curve4 = self.p4.plot(pen=(0, 255, 255))
        # #creating data vector
        self.skt = np.zeros(self.len)

        ##########################################################
        ####   EVENTS
        ##########################################################

        #SIGNALS
        self.slider1.valueChanged.connect(self.scale)
        self.win.scene().sigMouseClicked.connect(self.onClick)
        edacb.stateChanged.connect(self.toggleEda)
        emgcb.stateChanged.connect(self.toggleEmg)
        ecgcb.stateChanged.connect(self.toggleEcg)
        sktcb.stateChanged.connect(self.toggleSkt)
        self.p = [self.p1, self.p2, self.p3, self.p4]

        #TEST
        #self.lay = pg.GraphicsWindow()
        #self.lay.addItem(self.p1)
        #self.area = pg.LinearRegionItem(values=[0,1], orientation=pg.LinearRegionItem.Vertical, movable=False)
        #self.area2 = pg.LinearRegionItem(values=[0,1], orientation=pg.LinearRegionItem.Vertical, movable=False)

        #self.p5.addItem(self.area)
        #self.p5.addItem(self.area2)

        #self.area.setRegion((-50, -25))
        #self.area2.setRegion((-50, -30))

        #solo para debuguear
        if self._DEBUGUER:
            self.timer = pg.QtCore.QTimer()
            self.timer.timeout.connect(self.update_all)
            self.timer.start(50)
Example #6
0
 def create_ui(self):
     self.vblayout=QVBoxLayout(self)
     
     self.parSplitter=QSplitter(Qt.Vertical)
     
     self.funcLayoutWidget=pg.LayoutWidget()
     row=0
     col=0
     funcNameLabel=QLabel('Function name')
     self.funcLayoutWidget.addWidget(funcNameLabel,row=row,col=col)
     col+=1
     self.funcNameLineEdit=QLineEdit()
     self.funcNameLineEdit.returnPressed.connect(self.funcNameChanged)
     self.funcLayoutWidget.addWidget(self.funcNameLineEdit,row=row,col=col,colspan=2)
     col+=2
     self.replaceTabButton=QPushButton('Replace tabs')
     self.replaceTabButton.clicked.connect(self.replaceTabWithSpaces)
     self.funcLayoutWidget.addWidget(self.replaceTabButton,row=row,col=col)
             
     row+=1
     col=0
     self.funcTextEdit=QPlainTextEdit()
     self.funcTextEdit.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
     self.funcLayoutWidget.addWidget(self.funcTextEdit,row=row,col=col,colspan=4)
     self.highlighter=Highlighter(self.funcTextEdit.document())
     self.funcTextEdit.setTabStopWidth(16)
     
     row+=1
     col=0
     self.cursorPositionLabel=QLabel()
     self.cursorPositionLabel.setAlignment(Qt.AlignCenter)
     self.funcLayoutWidget.addWidget(self.cursorPositionLabel,row=row,col=col,colspan=4)
     
     self.parSplitter.addWidget(self.funcLayoutWidget)
     
     self.debugLayoutWidget=pg.LayoutWidget()
     row+=1
     col=0
     checkRunLabel=QLabel('Check/Run results')
     self.debugLayoutWidget.addWidget(checkRunLabel,row=row,col=col)
     
     row+=1
     col=0
     self.debugTextEdit=QPlainTextEdit()
     self.debugTextEdit.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
     self.debugLayoutWidget.addWidget(self.debugTextEdit,row=row,col=col,colspan=4)
     
     row+=1
     col=0
     self.testPushButton=QPushButton('Test function')
     self.testPushButton.clicked.connect(self.testFunction)
     self.debugLayoutWidget.addWidget(self.testPushButton,row=row,col=col)
     col+=1
     self.runPushButton=QPushButton('Run function')
     self.runPushButton.clicked.connect(self.runFunction)
     self.debugLayoutWidget.addWidget(self.runPushButton,row=row,col=col)
     col+=1
     self.savePushButton=QPushButton('Save function')
     self.savePushButton.clicked.connect(self.saveFunction)
     self.debugLayoutWidget.addWidget(self.savePushButton,row=row,col=col)
     col+=1
     self.closeEditorButton=QPushButton('Close Editor')
     self.closeEditorButton.clicked.connect(self.closeEditor)
     self.debugLayoutWidget.addWidget(self.closeEditorButton,row=row,col=col)
     
     self.parSplitter.addWidget(self.debugLayoutWidget)
     
     self.vblayout.addWidget(self.parSplitter)
    def __init__(self):

        self.w = QtGui.QWidget()
        self.w.setFixedSize(1640, 800)
        self.w.move(300, 300)
        self.w.setWindowTitle('Aries Project')

        # Counter
        self.data_points_limit = 10
        self.count = 0

        # Arrays fr plotting
        self.Mission_time = []
        self.Pressurant_temp = []
        self.Pressurant_pressure = []

        self.Oxidizer_temp = []
        self.Oxidizer_pressure = []

        self.Combustion_pressure = []

        # placing plots
        pg.setConfigOption('background', 'w')
        self.plot_layout = pg.LayoutWidget(self.w)

        self.my_plot_One = pg.PlotWidget()
        self.my_plot_One.showGrid(x=True, y=True)
        self.my_plot_One.setTitle("Pressurant Tank")
        self.my_plot_One.setFixedSize(533, 400)
        self.plot_layout.addWidget(self.my_plot_One)
        self.my_plot_One.setLabel('left', 'Temperature (C) & Pressure (psi)')
        self.my_plot_One.setLabel('bottom', 'Time', units='s')

        self.my_plot_Two = pg.PlotWidget()
        self.my_plot_Two.showGrid(x=True, y=True)
        self.my_plot_Two.setTitle("Oxidizer Tank")
        self.my_plot_Two.setFixedSize(533, 400)
        self.plot_layout.addWidget(self.my_plot_Two)
        self.my_plot_Two.setLabel('left', 'Temperature (C) & Pressure (psi)')
        self.my_plot_Two.setLabel('bottom', 'Time', units='s')

        self.my_plot_Three = pg.PlotWidget()
        self.my_plot_Three.showGrid(x=True, y=True)
        self.my_plot_Three.setTitle("Combustion Tank")
        self.my_plot_Three.setFixedSize(533, 400)
        self.plot_layout.addWidget(self.my_plot_Three)
        self.my_plot_Three.setLabel('left', 'Pressure (psi)')
        self.my_plot_Three.setLabel('bottom', 'Time', units='s')

        #The lines below create the buttons and QLabels you see on the windoself.
        #Creating Widgets
        self.QLabelOne = QtGui.QLabel(
            self.w)  #,text= "Tanks:",font = "Times 14 bold")
        self.QLabelOne.setText("Tanks:")
        self.QLabelTwo = QtGui.QLabel(
            self.w)  #(root,text= "Pressurant:",font = "Times 14 bold")
        self.QLabelTwo.setText("Pressurant:")
        self.QLabelThree = QtGui.QLabel(
            self.w)  #(root,text= "Oxidizer:",font = "Times 14 bold")
        self.QLabelThree.setText("Oxidizer:")
        self.QLabelFour = QtGui.QLabel(
            self.w)  #(root,text = "Combustion:",font = "Times 14 bold")
        self.QLabelFour.setText("Combustion:")
        self.QLabelFive = QtGui.QLabel(
            self.w)  #(root,text= "Temperature  (C):")
        self.QLabelFive.setText("Temperature  (C):")
        self.QLabelSix = QtGui.QLabel(
            self.w)  #(root,text= "Temperature  (C):")
        self.QLabelSix.setText("Temperature  (C):")
        self.QLabelSeven = QtGui.QLabel(self.w)
        self.QLabelSeven.setText("Pressure        (psi):")
        self.QLabelEight = QtGui.QLabel(self.w)
        self.QLabelEight.setText("Pressure        (psi):")
        self.QLabelNine = QtGui.QLabel(self.w)
        self.QLabelNine.setText("Baud Rate:")
        self.QLabelTen = QtGui.QLabel(self.w)
        self.QLabelTen.setText("Port:")
        self.QLabelTwelve = QtGui.QLabel(self.w)
        self.QLabelTwelve.setText("Valves: ")
        self.QLabelThirteen = QtGui.QLabel(self.w)
        self.QLabelThirteen.setText("High/Low (1/0):")
        self.QLabel_14 = QtGui.QLabel(self.w)
        self.QLabel_14.setText("Pressurant_Fill:")
        self.QLabel_16 = QtGui.QLabel(self.w)
        self.QLabel_16.setText("Pressurant_Oxidizer:")
        self.QLabel_17 = QtGui.QLabel(self.w)
        self.QLabel_17.setText("Oxidizer_fill:")
        self.QLabel_19 = QtGui.QLabel(self.w)
        self.QLabel_19.setText("Oxi_Combustion:")

        #Placing Widgets
        self.QLabelOne.move(40, 602)
        self.QLabelTwo.move(175, 602)
        self.QLabelThree.move(275, 602)
        self.QLabelFour.move(370, 602)
        self.QLabelFive.move(40, 640)
        self.QLabelSix.move(40, 660)
        self.QLabelSeven.move(40, 680)
        self.QLabelEight.move(40, 700)
        self.QLabelNine.move(1100, 500)
        self.QLabelTen.move(1100, 540)

        self.QLabelTwelve.move(600, 602)
        self.QLabelThirteen.move(800, 602)
        self.QLabel_14.move(600, 640)
        self.QLabel_16.move(600, 660)
        self.QLabel_17.move(600, 680)
        self.QLabel_19.move(600, 700)

        #Data QLabels
        self.QLabel_data1 = QtGui.QLabel(self.w)
        self.QLabel_data1.setText("X")
        self.QLabel_data2 = QtGui.QLabel(self.w)
        self.QLabel_data2.setText("X")
        self.QLabel_data3 = QtGui.QLabel(self.w)
        self.QLabel_data3.setText("X")
        self.QLabel_data4 = QtGui.QLabel(self.w)
        self.QLabel_data4.setText("X")
        self.QLabel_data5 = QtGui.QLabel(self.w)
        self.QLabel_data5.setText("X")
        self.QLabel_data6 = QtGui.QLabel(self.w)
        self.QLabel_data6.setText("X")
        self.QLabel_data7 = QtGui.QLabel(self.w)
        self.QLabel_data7.setText("X")
        self.QLabel_data8 = QtGui.QLabel(self.w)
        self.QLabel_data8.setText("X")
        self.QLabel_data9 = QtGui.QLabel(self.w)
        self.QLabel_data9.setText("X")
        self.QLabel_data10 = QtGui.QLabel(self.w)
        self.QLabel_data10.setText("X")
        self.QLabel_data11 = QtGui.QLabel(self.w)
        self.QLabel_data11.setText("X")
        self.QLabel_data12 = QtGui.QLabel(self.w)
        self.QLabel_data12.setText("X")

        self.QLabel_Pressurant_Fill = QtGui.QLabel(self.w)
        self.QLabel_Pressurant_Fill.setText("X")
        self.QLabel_Pressurant_Oxidizer = QtGui.QLabel(self.w)
        self.QLabel_Pressurant_Oxidizer.setText("X")
        self.QLabel_Oxidizer_fill = QtGui.QLabel(self.w)
        self.QLabel_Oxidizer_fill.setText("X")
        self.QLabel_Oxi_Combustion = QtGui.QLabel(self.w)
        self.QLabel_Oxi_Combustion.setText("X")

        #move Data QLabels
        self.QLabel_data1.move(175, 640)  #  Temp of Pressurant
        self.QLabel_data2.move(175, 660)  #  Temp Redundant of Pressurant
        self.QLabel_data3.move(175, 680)  #  Pressure of Pressurant
        self.QLabel_data4.move(175, 700)  #  Pressure Redundant of Pressurant
        self.QLabel_data5.move(275, 640)  #  Temp of Oxidizer
        self.QLabel_data6.move(275, 660)  #  Temp Redundant of Oxidizer
        self.QLabel_data7.move(275, 680)  #  Pressure of Oxidizer
        self.QLabel_data8.move(275, 700)  #  Pressure Redundant of Oxidizer
        self.QLabel_data9.move(375, 640)  #  Temp of Combustion Chamber
        self.QLabel_data10.move(375,
                                660)  #  Temp Redundant of Combustion Chamber
        self.QLabel_data11.move(375, 680)  #  Pressure of Combustion Chamber
        self.QLabel_data12.move(
            375, 700)  #  Pressure Redundant of Combustion Chamber

        self.QLabel_Pressurant_Fill.move(815, 640)
        self.QLabel_Pressurant_Oxidizer.move(815, 660)
        self.QLabel_Oxidizer_fill.move(815, 680)
        self.QLabel_Oxi_Combustion.move(815, 700)

        # Entry Box
        self.baud_rate = QtGui.QLineEdit(self.w)
        self.baud_rate.move(1180, 500)
        self.port_entry = QtGui.QLineEdit(self.w)
        self.port_entry.move(1180, 540)
        self.port = str(self.port_entry.text())
        self.baud = str(self.baud_rate.text())

        # Buttons
        self.CONNECT = QtGui.QPushButton("CONNECT", self.w)
        self.CONNECT.move(1020, 500)
        self.DISCONNECT = QtGui.QPushButton("Disconnect", self.w)
        self.DISCONNECT.move(1020, 540)
        self.button1 = QtGui.QPushButton('Open P-Fill', self.w)
        self.button1.move(1020, 600)
        self.button2 = QtGui.QPushButton('Close P-Fill', self.w)
        self.button2.move(1020, 640)
        self.button3 = QtGui.QPushButton('Open POIV', self.w)
        self.button3.move(1020, 680)
        self.button4 = QtGui.QPushButton('Close POIV', self.w)
        self.button4.move(1020, 720)
        self.button5 = QtGui.QPushButton('Open Oxi-Fill', self.w)
        self.button5.move(1180, 600)
        self.button6 = QtGui.QPushButton('Close Oxi-Fill', self.w)
        self.button6.move(1180, 640)
        self.button7 = QtGui.QPushButton('Launch', self.w)
        self.button7.move(1180, 680)
        self.button8 = QtGui.QPushButton('Abort', self.w)
        self.button8.move(1180, 720)

        QtCore.QObject.connect(self.CONNECT, QtCore.SIGNAL("clicked()"),
                               self.my_connect)
        QtCore.QObject.connect(self.DISCONNECT, QtCore.SIGNAL("clicked()"),
                               self.Disconnect)
        QtCore.QObject.connect(self.button1, QtCore.SIGNAL("clicked()"),
                               self.open_Pressurant_fill)
        QtCore.QObject.connect(self.button2, QtCore.SIGNAL("clicked()"),
                               self.close_Pressurant_fill)
        QtCore.QObject.connect(self.button3, QtCore.SIGNAL("clicked()"),
                               self.open_POIV)
        QtCore.QObject.connect(self.button4, QtCore.SIGNAL("clicked()"),
                               self.close_POIV)
        QtCore.QObject.connect(self.button5, QtCore.SIGNAL("clicked()"),
                               self.open_Oxidizer_fill)
        QtCore.QObject.connect(self.button6, QtCore.SIGNAL("clicked()"),
                               self.close_Oxidizer_fill)
        QtCore.QObject.connect(self.button7, QtCore.SIGNAL("clicked()"),
                               self.launch)
        QtCore.QObject.connect(self.button8, QtCore.SIGNAL("clicked()"),
                               self.Abort)
Example #8
0
    def _init_dock_image_view(self):
        self._dock_image_view = pyqtgraph.dockarea.Dock("Image View",
                                                        size=(500, 500))
        self.dock_area.addDock(self._dock_image_view, 'top')
        self.imv = pyqtgraph.ImageView()
        self._dock_image_view.addWidget(self.imv)
        self._dock_image_view.label = DockLabel("Shotnumber = ",
                                                self._dock_image_view)
        self._dock_image_view.updateStyle()
        self.imv.setImage(self.imgstack,
                          xvals=numpy.arange(
                              self.imgstack.shape[0]))  #.linspace(1., 3., ))

        # attempt to add to context menu (right mouse button) for cursor drop
        self.imv.view.menu.cursorDrop = QtGui.QAction("Drop Cursor",
                                                      self.imv.view.menu)
        self.imv.view.menu.dropCursor = self.dropCursor
        self.imv.view.menu.cursorDrop.triggered.connect(
            self.imv.view.menu.dropCursor)
        self.imv.view.menu.addAction(self.imv.view.menu.cursorDrop)
        acs = self.imv.view.menu.subMenus()

        def newSubMenus():
            return [self.imv.view.menu.cursorDrop] + acs

        self.imv.view.menu.subMenus = newSubMenus
        self.imv.view.menu.valid = False
        self.imv.view.menu.view().sigStateChanged.connect(
            self.imv.view.menu.viewStateChanged)
        self.imv.view.menu.updateState()

        #cross hair
        self.imv.vLine = pyqtgraph.InfiniteLine(angle=90, movable=False)
        self.imv.hLine = pyqtgraph.InfiniteLine(angle=0, movable=False)
        self.imv.addItem(self.imv.vLine, ignoreBounds=True)
        self.imv.addItem(self.imv.hLine, ignoreBounds=True)

        self.imv.vb = self.imv.view

        def animate(evt):
            if self.imv.playTimer.isActive():
                self.imv.playTimer.stop()
                return
            fpsin = self._imv_fps_in
            fps = float(str(fpsin.text()).split("FPS")[0])
            self.imv.play(fps)

        #animation controls
        self._imv_fps_in = QtGui.QLineEdit('10 FPS')
        self._imv_anim_b = QtGui.QPushButton('Animate')
        self._imv_anim_b.clicked.connect(animate)

        self._imv_layout_widg = pyqtgraph.LayoutWidget()
        self._imv_layout_widg.addWidget(QtGui.QLabel("Animation:"),
                                        row=0,
                                        col=0)
        self._imv_layout_widg.addWidget(self._imv_fps_in, row=0, col=1)
        self._imv_layout_widg.addWidget(self._imv_anim_b, row=0, col=2)

        self._dock_image_view.addWidget(self._imv_layout_widg)

        def jumpFrames(n):
            """Move video frame ahead n frames (may be negative)"""
            if self.imv.axes['t'] is not None:
                self.imv.setCurrentIndex(self.imv.currentIndex + n)
                try:
                    self._dock_image_view.label = DockLabel(
                        "Shotnumber = " +
                        str(self.imgstack_shotnumbers[self.imv.currentIndex]),
                        self._dock_image_view)
                    self._dock_image_view.updateStyle()
                except IndexError:
                    pass

        self.imv.jumpFrames = jumpFrames

        def mouseMoved(evt):
            pos = evt[
                0]  ## using signal proxy turns original arguments into a tuple
            if self.imv.scene.sceneRect().contains(pos):
                mousePoint = self.imv.vb.mapSceneToView(pos)
                self.imv.vLine.setPos(mousePoint.x())
                self.imv.hLine.setPos(mousePoint.y())
                index = (int(mousePoint.x()), int(mousePoint.y()))
                x = "<span style='font-size: 12pt;color: blue'>x=%0.1f,   " % mousePoint.x(
                )
                y = "<span style='color: red'>y=%0.1f</span>,   " % mousePoint.y(
                )
                if index[0] > 0 and index[0] < len(self.imgstack[1][0]):
                    if index[1] > 0 and index[1] < len(self.imgstack[2][0]):
                        #Fix the next line so that the z axis is for the image that is displayed
                        try:
                            z = "<span style='color: green'>z=%0.1f</span>" % self.imgstack[
                                self.imv.currentIndex, index[0], index[1]]
                        except:
                            z = "<span style='color: green'>z=Error</span>"
                            print "index:", index
                            print "len(self.imgstack[1][0]:", len(
                                self.imgstack[1][0])
                            print "self.imv.currentIndex:", self.imv.currentIndex
                        self.curs_pos_label.setText(x + y + z)

        self.proxy = pyqtgraph.SignalProxy(self.imv.scene.sigMouseMoved,
                                           rateLimit=60,
                                           slot=mouseMoved)
Example #9
0
    def __init__(self):
        BAUDE_RATE = 9600
        COM = 'COM5'
        self.WINDOW_SIZE = 4
        self.MAX_DATA_SIZE = 1024
        self.FS = 190
        self.MODEL = load('Eyes_Op_Cl_MLP_89.1%.joblib')
        self.app = pg.mkQApp()

        # view 1
        self.view = pg.widgets.RemoteGraphicsView.RemoteGraphicsView()
        self.view.setWindowTitle('Classe: RemoteSpeedTest')
        pg.setConfigOptions(antialias=True)
        self.view.pg.setConfigOptions(
            antialias=True)  ## prettier plots at no cost to the main process!
        self.view.setWindowTitle('pyqtgraph example: RemoteSpeedTest')

        # view 2
        self.view2 = pg.widgets.RemoteGraphicsView.RemoteGraphicsView()
        self.view2.setWindowTitle('Classe: RemoteSpeedTest')
        pg.setConfigOptions(antialias=True)
        self.view2.pg.setConfigOptions(
            antialias=True)  ## prettier plots at no cost to the main process!
        self.view2.setWindowTitle('FFT')

        self.label = QtGui.QLabel()
        # Check Boxes
        self.check_clf = QtGui.QCheckBox('Classificar')
        self.check_rcd = QtGui.QCheckBox('Gravar')
        self.check_HPF = QtGui.QCheckBox('High Pass Filter')
        self.check_LPF = QtGui.QCheckBox('Low Pass Filter')
        self.check_BPF = QtGui.QCheckBox('Band Pass Filter')

        # Adding layout and wodgets
        self.layout = pg.LayoutWidget()
        self.layout.addWidget(self.check_rcd)
        self.layout.addWidget(self.check_clf)
        self.layout.addWidget(self.label)
        self.layout.addWidget(self.view, row=1, col=0, colspan=3)
        self.layout.addWidget(self.view2, row=2, col=0, colspan=3)
        self.layout.addWidget(self.check_HPF, row=3, col=0)
        self.layout.addWidget(self.check_LPF, row=3, col=1)
        self.layout.addWidget(self.check_BPF, row=3, col=2)

        # Adding Plots

        self.layout.resize(800, 800)
        self.layout.show()

        # Setup plot wave
        self.wave_plot = self.view.pg.PlotItem()
        self.wave_plot._setProxyOptions(deferGetattr=True)
        self.view.setCentralItem(self.wave_plot)

        # Setup plot fft
        self.spectro_plot = self.view2.pg.PlotItem()
        self.spectro_plot._setProxyOptions(deferGetattr=True)
        self.view2.setCentralItem(self.spectro_plot)

        # Computting FPS
        self.lastUpdate = pg.ptime.time()
        self.avgFps = 0.0

        # Plot lines
        self.buffer = np.zeros(1024)
        self.wave_plot.plot(self.buffer, clear=True)
        self.label.setText(
            "<span style='font-size: 20pt'><span style='color: green'>Classe: ___ fps</span>"
        )

        # Serial config
        self.ser = serial.Serial(COM, BAUDE_RATE)
        self.lstUpClf = 0

        # Gravar
        self.file = []
Example #10
0
    def __init__(self):
        self.width = 1000
        self.high = 1000
        self.console_high = 150
        self.plot_high = self.high - self.console_high
        self.console_size = (self.width, self.console_high)
        self.plot_size = (self.width, self.plot_high)
        self.app = QtGui.QApplication([])
        self.win = QtGui.QMainWindow()
        self.area = DockArea()
        self.win.setCentralWidget(self.area)
        self.win.resize(self.width, self.high)
        self.win.setWindowTitle('Gimbal Monitor')
        self.timer_dt = 50

        pg.setConfigOptions(antialias=True)
        pg.setConfigOption('background', [0, 0, 0])
        pg.setConfigOption('foreground', [255, 255, 255, 100])

        # Dock
        self.d_console = self.dock4console('Console')
        self.d_controller_state = self.dock4plot('Controller State')
        self.d_motors_state = self.dock4plot('Motors State')
        self.d_controller_config = self.dock4plot('Controller Config')
        self.d_motors_config = self.dock4plot('Motor Config')
        self.d_imu_attitude = Dock('IMU Attitude',
                                   size=(1000, self.plot_high),
                                   closable=True)
        #self.d_imu_attitude.show()
        self.area.addDock(self.d_console, 'bottom')
        self.area.addDock(self.d_controller_state, 'top')
        self.area.addDock(self.d_motors_state, 'top')
        self.area.addDock(self.d_controller_config, 'top')
        self.area.addDock(self.d_motors_config, 'top')
        self.area.addDock(self.d_imu_attitude, 'top')

        self.area.moveDock(self.d_motors_state, 'above',
                           self.d_controller_state)
        self.area.moveDock(self.d_controller_config, 'above',
                           self.d_motors_state)
        self.area.moveDock(self.d_motors_config, 'above',
                           self.d_controller_config)
        self.area.moveDock(self.d_imu_attitude, 'right',
                           self.d_controller_state)

        # Controller State Layout
        self.pen_width = 2
        self.fill_beta = 70
        self.pen_red = pg.mkPen('F00', width=self.pen_width)
        self.pen_green = pg.mkPen('0F0', width=self.pen_width)
        self.pen_blue = pg.mkPen('0AF', width=self.pen_width)
        self.fill_red = [255, 0, 0, self.fill_beta]
        self.fill_green = [0, 255, 0, self.fill_beta]
        self.fill_blue = [0, 200, 255, self.fill_beta]

        self.imu_angle_time_len = 200
        self.imu_angle_data = np.zeros((3, self.imu_angle_time_len))
        self.imu_angle_v_data = np.zeros((3, self.imu_angle_time_len))
        self.w_controller_state = pg.LayoutWidget()
        self.p_attitude = pg.PlotWidget(title="Camera Attitude")
        self.p_angle_v = pg.PlotWidget(title="Angle Velocity")
        self.p_attitude.showGrid(x=True, y=True)
        self.p_angle_v.showGrid(x=True, y=True)
        self.curve_roll = self.p_attitude.plot(self.imu_angle_data[0],
                                               pen=self.pen_red,
                                               fillLevel=0,
                                               brush=self.fill_red)
        self.curve_pitch = self.p_attitude.plot(self.imu_angle_data[1],
                                                pen=self.pen_green,
                                                fillLevel=0,
                                                brush=self.fill_green)
        self.curve_yaw = self.p_attitude.plot(self.imu_angle_data[2],
                                              pen=self.pen_blue,
                                              fillLevel=0,
                                              brush=self.fill_blue)
        self.curve_roll_v = self.p_angle_v.plot(self.imu_angle_v_data[0],
                                                pen=self.pen_red,
                                                fillLevel=0,
                                                brush=self.fill_red)
        self.curve_pitch_v = self.p_angle_v.plot(self.imu_angle_v_data[1],
                                                 pen=self.pen_green,
                                                 fillLevel=0,
                                                 brush=self.fill_green)
        self.curve_yaw_v = self.p_angle_v.plot(self.imu_angle_v_data[2],
                                               pen=self.pen_blue,
                                               fillLevel=0,
                                               brush=self.fill_blue)
        self.time_remain = 6
        self.angle_max = 100
        self.angle_v_max = 1000
        self.text_interval = self.angle_max * 0.12
        self.text_interval_v = self.angle_v_max * 0.12
        self.angle_text_max_y = self.angle_max * 1.12
        self.angle_v_text_max_y = self.angle_v_max * 1.12
        self.p_attitude.setXRange(0 - self.time_remain,
                                  self.imu_angle_time_len + self.time_remain)
        self.p_attitude.setYRange(-100, 100)
        self.p_angle_v.setXRange(0 - self.time_remain,
                                 self.imu_angle_time_len + self.time_remain)
        self.p_angle_v.setYRange(-1000, 1000)

        self.t_roll_angle = pg.TextItem()
        self.t_roll_angle.setText('roll: %0.1f' % (0), [255, 0, 0, 200])
        self.t_roll_angle.setPos(0, self.angle_text_max_y)
        self.p_attitude.addItem(self.t_roll_angle)

        self.t_pitch_angle = pg.TextItem()
        self.t_pitch_angle.setText('pitch: %0.1f' % (0), [0, 255, 0, 200])
        self.t_pitch_angle.setPos(0,
                                  self.angle_text_max_y - self.text_interval)
        self.p_attitude.addItem(self.t_pitch_angle)

        self.t_yaw_angle = pg.TextItem()
        self.t_yaw_angle.setText('yaw: %0.1f' % (0), [0, 200, 255, 230])
        self.t_yaw_angle.setPos(0,
                                self.angle_text_max_y - 2 * self.text_interval)
        self.p_attitude.addItem(self.t_yaw_angle)

        self.t_roll_angle_v = pg.TextItem()
        self.t_roll_angle_v.setText('roll: %0.1f' % (0), [255, 0, 0, 200])
        self.t_roll_angle_v.setPos(0, self.angle_v_text_max_y)
        self.p_angle_v.addItem(self.t_roll_angle_v)

        self.t_pitch_angle_v = pg.TextItem()
        self.t_pitch_angle_v.setText('pitch: %0.1f' % (0), [0, 255, 0, 200])
        self.t_pitch_angle_v.setPos(
            0, self.angle_v_text_max_y - self.text_interval_v)
        self.p_angle_v.addItem(self.t_pitch_angle_v)

        self.t_yaw_angle_v = pg.TextItem()
        self.t_yaw_angle_v.setText('yaw: %0.1f' % (0), [0, 200, 255, 230])
        self.t_yaw_angle_v.setPos(
            0, self.angle_v_text_max_y - 2 * self.text_interval_v)
        self.p_angle_v.addItem(self.t_yaw_angle_v)

        self.w_controller_state.addWidget(self.p_attitude, row=0, col=0)
        self.w_controller_state.addWidget(self.p_angle_v, row=1, col=0)
        self.d_controller_state.addWidget(self.w_controller_state,
                                          row=0,
                                          col=1)

        self.timer_controller_state = QtCore.QTimer()
        self.timer_controller_state.timeout.connect(
            self.controller_state_update)

        # Motors State Layout
        self.motors_state_time_len = 200
        self.ntc_tempre_data = np.zeros((3, self.motors_state_time_len))
        self.input_current_data = np.zeros((3, self.motors_state_time_len))
        self.motor_current_data = np.zeros((3, self.motors_state_time_len))
        self.input_v_data = np.zeros((3, self.motors_state_time_len))
        self.duty_cycle_now_data = np.zeros((3, self.motors_state_time_len))
        self.rpm_data = np.zeros((3, self.motors_state_time_len))
        self.tacho_data = np.zeros((3, self.motors_state_time_len))
        self.tacho_abs_data = np.zeros((3, self.motors_state_time_len))

        self.w_motors_state = pg.LayoutWidget()
        self.p_ntc_tempre = pg.PlotWidget()
        self.p_current = pg.PlotWidget()
        self.p_input_v = pg.PlotWidget()
        self.p_duty_cycle_now = pg.PlotWidget()
        self.p_rpm = pg.PlotWidget()
        self.p_tacho = pg.PlotWidget()
        self.p_tach_abs = pg.PlotWidget()
        self.p_ntc_tempre.showGrid(True)
        self.p_current.showGrid(True)
        self.p_input_v.showGrid(True)
        self.p_duty_cycle_now.showGrid(True)
        self.p_rpm.showGrid(True)
        self.p_tacho.showGrid(True)
        self.p_tach_abs.showGrid(True)
        self.curve_ntc_tempre = self.p_ntc_tempre.plot(self.ntc_tempre_data[0],
                                                       pen=self.pen_blue,
                                                       fillLevel=0,
                                                       brush=self.fill_blue)
        self.curve_input_current = self.p_current.plot(
            self.input_current_data[0], pen=self.pen_)

        # IMU Attitude OpenGL Layout

        self.vr_layout = pg.LayoutWidget()

        self.w_vr = gl.GLViewWidget()
        glEnable(GL_LINE_SMOOTH)
        glShadeModel(GL_SMOOTH)
        glEnable(GL_DEPTH_TEST)
        glEnable(GL_CULL_FACE)
        glCullFace(GL_BACK)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC1_ALPHA)
        self.light()
        glMatrixMode(GL_PROJECTION)
        glMatrixMode(GL_MODELVIEW)
        gluPerspective(40., 1., 1., 40.)
        self.w_vr.opts['distance'] = 40
        self.w_vr.opts['azimuth'] = -10
        print(self.w_vr.opts)
        self.w_vr.setWindowTitle('IMU Attitude')
        #self.w_vr.setCameraPosition(pos=[0, 0, 50],)

        self.w_vr.show()
        self.vr_ground = gl.GLGridItem()
        self.vr_ground.scale(10, 10, 1)
        self.w_vr.addItem(self.vr_ground)

        self.cube_width = 20
        self.cube_high = self.cube_width * (1 - 0.618)
        self.verts = np.array([
            [self.cube_width / 2, self.cube_width / 2, self.cube_high / 2],
            [-self.cube_width / 2, self.cube_width / 2, self.cube_high / 2],
            [-self.cube_width / 2, -self.cube_width / 2, self.cube_high / 2],
            [self.cube_width / 2, -self.cube_width / 2, self.cube_high / 2],
            [self.cube_width / 2, self.cube_width / 2, -self.cube_high / 2],
            [-self.cube_width / 2, self.cube_width / 2, -self.cube_high / 2],
            [-self.cube_width / 2, -self.cube_width / 2, -self.cube_high / 2],
            [self.cube_width / 2, -self.cube_width / 2, -self.cube_high / 2],
        ])
        self.face = np.array([
            [0, 1, 2],  # up
            [0, 2, 3],
            [4, 6, 5],  # down
            [4, 7, 6],
            [0, 3, 7],  # front
            [0, 7, 4],
            [1, 6, 2],  # back
            [1, 5, 6],
            [0, 4, 5],  # left
            [0, 5, 1],
            [2, 6, 7],  # right
            [2, 7, 3],
        ])
        self.alpha = 1
        self.c_red = [1, 0, 0, self.alpha]
        self.c_greed = [0, 1, 0, self.alpha]
        self.c_blue = [0, 0, 1, self.alpha]
        self.gray_scale = 0.8
        self.c_gray = [
            self.gray_scale, self.gray_scale, self.gray_scale, self.alpha
        ]
        self.colors = np.array([
            self.c_gray,
            self.c_gray,
            self.c_gray,
            self.c_gray,
            self.c_gray,
            self.c_gray,
            self.c_gray,
            self.c_gray,
            self.c_gray,
            self.c_gray,
            self.c_gray,
            self.c_gray,
        ])
        self.cube = gl.GLMeshItem(vertexes=self.verts,
                                  faces=self.face,
                                  faceColors=self.colors,
                                  shader='shaded',
                                  drawEdges=True,
                                  edgeColor=(1, 1, 1, 1),
                                  smooth=False)
        self.cube.translate(0, 0, 3)
        self.cube_quat = QQuaternion(1.0, 0.0, 0.0, 0.0)
        self.cube_mat = self.cube_quat.toRotationMatrix()
        self.cube_mat_data = self.cube_mat.data()
        self.cube_transform = pg.Transform3D(
            self.cube_mat_data[0], self.cube_mat_data[1],
            self.cube_mat_data[2], 0, self.cube_mat_data[3],
            self.cube_mat_data[4], self.cube_mat_data[5], 0,
            self.cube_mat_data[6], self.cube_mat_data[7],
            self.cube_mat_data[8], 0, 0, 0, 0, 1)

        self.cube.setTransform(self.cube_transform)
        self.w_vr.addItem(self.cube)
        self.d_imu_attitude.addWidget(self.w_vr)
    def initUI(self):

        # Initialize tab screen
        self.tabs = QTabWidget()
        self.tab1 = pg.LayoutWidget()
        self.tab2 = pg.LayoutWidget()
        self.tabs.resize(300, 200)

        exitAct = QAction(QIcon('exit.png'), '&Exit', self)
        exitAct.setShortcut('Ctrl+Q')
        exitAct.setStatusTip('Exit application')
        exitAct.triggered.connect(qApp.quit)

        self.statusBar()

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&File')
        fileMenu.addAction(exitAct)

        self.setGeometry(200, 200, 450, 500)

        self.setWindowTitle('Phone Book')
        self.setCentralWidget(self.tabs)

        # Table Tab 1
        self.tableWidgetContactTab1 = QTableWidget()
        # self.tableWidgetContactTab1.setRowCount(2)
        self.tableWidgetContactTab1.setColumnCount(6)
        self.tableWidgetContactTab1.setHorizontalHeaderLabels(['Name', 'Age', 'Mobile', 'Gender', 'Address', 'Group'])
        self.tableWidgetContactTab1.setEditTriggers(QTableWidget.NoEditTriggers)
        self.tableWidgetContactTab1.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)

        self.ContactListDefault = []
        self.ContactListDefault.append("Avisha")
        self.ContactListDefault.append("25")
        self.ContactListDefault.append("1234567890")
        self.ContactListDefault.append("Female")
        self.ContactListDefault.append("Jodhpur")
        self.ContactListDefault.append("Default")

        self.ContactListDefault2 = []
        self.ContactListDefault2.append("XYZ")
        self.ContactListDefault2.append("25")
        self.ContactListDefault2.append("1234247890")
        self.ContactListDefault2.append("Female")
        self.ContactListDefault2.append("Jodhpur")
        self.ContactListDefault2.append("Business")

        self.RowCount=0

        self.tableWidgetContactTab1.insertRow(self.RowCount)

        # chkBoxItem = QtGui.QTableWidgetItem()
        # chkBoxItem.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
        # chkBoxItem.setCheckState(QtCore.Qt.Unchecked)
        # self.tableWidgetContactTab1.setItem(self.RowCount, 0, chkBoxItem)
        for col in range(0, 6):

            itemstr=str(self.ContactListDefault[col])
            item = QtGui.QTableWidgetItem(itemstr)

            # item.setFlags(QtCore.Qt.ItemIsUserCheckable |
            #               QtCore.Qt.ItemIsEnabled)


            self.tableWidgetContactTab1.setItem(self.RowCount, col, item)
            self.tableWidgetContactTab1.item(self.RowCount, col).setBackground(QtGui.QColor(255, 255, 153))
            # self.tableWidgetContactTab1.setItem(self.RowCount, col + 1, item)
            # item_1.setCheckState(QtCore.Qt.Unchecked)

        self.RowCount +=1



        self.tableWidgetContactTab1.insertRow(self.RowCount)

        # chkBoxItem = QtGui.QTableWidgetItem()
        # chkBoxItem.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
        # chkBoxItem.setCheckState(QtCore.Qt.Unchecked)
        # self.tableWidgetContactTab1.setItem(self.RowCount, 0, chkBoxItem)

        for col in range(0, 6):
            item=str(self.ContactListDefault2[col])
            # self.tableWidgetContactTab1.setItem(self.RowCount,col+1,QTableWidgetItem( item))
            self.tableWidgetContactTab1.setItem(self.RowCount, col, QTableWidgetItem(item))
            self.tableWidgetContactTab1.item(self.RowCount, col).setBackground(QtGui.QColor(255, 255, 153))
        self.RowCount += 1


        # self.tableWidgetContactTab1.horizontalHeader().setResizeMode(QHeaderView.Stretch)
        self.tableWidgetContactTab1.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents)
        # Layout Tab 1
        self.ButtonlayoutContactTab1 = pg.LayoutWidget()

        # Create Button Tab 1
        self.CreateButton = QPushButton()
        self.CreateButton.setText("Create")
        self.CreateButton.clicked.connect(self.CreateDetails)

        # Update Button Tab 1
        self.EditButton = QPushButton()
        self.EditButton.setText("Edit")
        self.EditButton.clicked.connect(self.EditDetails)

        # Update Button Tab 1
        self.UpdateButton = QPushButton()
        self.UpdateButton.setText("Update")
        self.UpdateButton.clicked.connect(self.UpdateDetails)
        self.UpdateButton.setEnabled(False)

        # Delete Button Tab 1
        self.DeleteButton = QPushButton()
        self.DeleteButton.setText("Delete")
        self.DeleteButton.clicked.connect(self.DeleteDetails)
        # self.DeleteButton.setEnabled(False)

        # Tab 1
        self.ButtonlayoutContactTab1.addWidget(self.CreateButton)
        self.ButtonlayoutContactTab1.addWidget(self.EditButton)
        self.ButtonlayoutContactTab1.addWidget(self.UpdateButton)
        self.ButtonlayoutContactTab1.addWidget(self.DeleteButton)



        # Businss Group-----------------------------------------------------------------------------------
        self.RowCount_Group=0
        # Table Tab 2
        self.tableWidgetGroupTab2 = QTableWidget()
        # self.tableWidgetGroupTab2.setRowCount(1)
        self.tableWidgetGroupTab2.setColumnCount(5)
        self.tableWidgetGroupTab2.setHorizontalHeaderLabels(['Name', 'Age', 'Mobile', 'Gender', 'Address'])
        self.tableWidgetGroupTab2.setEditTriggers(QTableWidget.NoEditTriggers)

        self.tableWidgetGroupTab2.insertRow(self.RowCount_Group)

        for col in range(0, 6):
            item = str(self.ContactListDefault2[col])
            self.tableWidgetGroupTab2.setItem(self.RowCount_Group, col, QTableWidgetItem(item))
        self.RowCount_Group += 1


        # self.tableWidgetGroupTab2.horizontalHeader().setResizeMode(QHeaderView.Stretch)
        self.tableWidgetGroupTab2.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents)

        # Tab 1
        self.tab1.addWidget(self.tableWidgetContactTab1,0,0)
        self.tab1.addWidget(self.ButtonlayoutContactTab1, 1,0)

        # Tab 2
        self.tab2.addWidget(self.tableWidgetGroupTab2, 0, 0)



        # Add tabs
        self.tabs.addTab(self.tab1, "Contact List")
        self.tabs.addTab(self.tab2, "Business Group")

        self.show()
Example #12
0
win = QtGui.QMainWindow()
area = DockArea()
win.setCentralWidget(area)
win.resize(1000,500)
win.setWindowTitle('DNV GL FuelFighters: read data')

d1 = Dock("Dock1", size=(1, 1)) 
d2 = Dock("Dock2 - Data Table", size=(500,300), closable=True)
d3 = Dock("Dock3", size=(500,400))


area.addDock(d1, 'left')      ## place d1 at left edge of dock area
area.addDock(d2,'right')
area.addDock(d3,'top',d2)

w1 = pg.LayoutWidget()
w2 = pg.LayoutWidget()
w3 = pg.PlotWidget(title="reading")



label = QtGui.QLabel(""" -- DNV GL FuelFighters -- 
						Why you should join FF???
						because of our princess Magnus
						""")
label2 = QtGui.QLabel("test")
hour = [1,2,3,4,5,6,7,8,9,10]
temperature = [30,32,34,32,33,31,29,32,35,45]

pic = QtGui.QLabel()
pic.setPixmap(QtGui.QPixmap("/home/motaz/Pictures/images.png"))
Example #13
0
	def initiate(self, dcontrols, lamb_po, phas,rh,jalph,jbet):
		self.dcontrols = dcontrols


		self.layout = pg.LayoutWidget()

		self.ws=[]
		self.ws += [Slider(0, 1,"\u03b1")]
		self.ws += [Slider(0, 1,"\u03b2")]

		self.ws += [Slider(1, 10, "\u2113")]
		print(self.ws[2].x)
		for i in range(3) :
			self.layout.addWidget(self.ws[i],row=0,col=i)
		self.dcontrols.addWidget(self.layout)

# =========================================================================
		self.ws[0].slider.setMaximum(glo_var.slid_precision)
		self.ws[0].x = glo_var.alpha
		self.ws[0].setLabelValue(self.ws[0].x*glo_var.slid_precision)
		self.ws[0].slider.setValue(glo_var.alpha*glo_var.slid_precision)
		self.ws[0].slider.valueChanged.connect(self.ws[0].setLabelValue)
  
		self.ws[1].slider.setMaximum(glo_var.slid_precision)
		self.ws[1].x = glo_var.beta
		self.ws[1].setLabelValue(self.ws[1].x*glo_var.slid_precision)
		self.ws[1].slider.setValue(glo_var.beta*glo_var.slid_precision)
		self.ws[1].slider.valueChanged.connect(self.ws[1].setLabelValue)
  

		self.ws[2].x = glo_var.l
		self.ws[2].slider.setPageStep(1)
		self.ws[2].intsetLabelValue(self.ws[2].x)
		self.ws[2].slider.setValue(glo_var.l)
		self.ws[2].slider.valueChanged.connect(self.ws[2].intsetLabelValue)       
		
		self.ws[2].slider.setMaximum(20)
		self.ws[2].slider.setMinimum(1)
# =====================================================================================================================================
		self.update_alpha_slid(self.ws[0])
		self.update_beta_slid(self.ws[1])
		self.update_l_slid(self.ws[2])



		[self.ws[i].slider.valueChanged.connect(self.update_ab_rh) for i in range(2)]
		self.ws[2].slider.valueChanged.connect(self.update_lamb_l)




		# self.layout.addWidget(self.ws[0],1,2)

		self.phas=phas


		self.rh=rh
		self.jalph = jalph
		self.jbet = jbet
		self.lamb_po = lamb_po
		self.phas.receive(self)
		# self.update_lamb_rh()
		self.update_ab_rh()
    def initializePlot(self):
        self.first_run = True
        white = (200, 200, 200)
        lightgray = (171, 178, 191)
        darkgray = (30, 40, 50)
        dark1 = (40, 44, 52)
        dark2 = (44, 48, 56)
        red = (200, 66, 66)
        red1b = pg.mkBrush(200, 66, 66, 200)
        blue = (6, 106, 166)
        blue1b = pg.mkBrush(6, 106, 166, 200)
        green = (16, 200, 166)
        green1b = pg.mkBrush(16, 200, 166, 200)
        yellow = (244, 244, 160)
        yellow1b = pg.mkBrush(244, 244, 160, 200)

        self.win.setWindowTitle("Teleop plotter")
        self.win.setWindowIcon(
            qtgqt.QtGui.QIcon(
                self.rospack.get_path("ros_guis") + "/img/icon02.png"))
        self.win.resize(1500, 2160)
        self.win.move(0, 0)
        self.win.setCentralWidget(self.area)

        self.dlefttop = darea.Dock(
            "left top", size=(1, 1))  # give this dock minimum possible size
        self.dleftbottom = darea.Dock("left bottom",
                                      size=(500,
                                            400))  # size is only a suggestion
        self.dlefttop.hideTitleBar()  # TODO 1
        self.dleftbottom.hideTitleBar()  # TODO 1
        #self.dright1 = darea.Dock("right 1", size=(500,200))
        #self.dright2 = darea.Dock("right 2", size=(500,200))
        self.area.addDock(self.dlefttop, "left")
        self.area.addDock(self.dleftbottom, "bottom", self.dlefttop)
        #self.area.addDock(self.dright1, "right")
        #self.area.addDock(self.dright2, "below", self.dright1)   ## place dright2 at top edge of dright1
        #self.area.moveDock(self.dright2, "below", self.dright1)
        self.wleft1 = pg.LayoutWidget()
        self.speedLabel = qtgqt.QtGui.QLabel("No data\n\n")
        self.isAutonomLabel = qtgqt.QtGui.QLabel("No data\n\n")
        self.saveBtn = qtgqt.QtGui.QPushButton("Save dock state")
        self.restoreBtn = qtgqt.QtGui.QPushButton("Restore dock state")
        self.clrBtn = qtgqt.QtGui.QPushButton("Clear")
        self.restoreBtn.setEnabled(False)
        self.wleft1.addWidget(self.isAutonomLabel, row=0, col=0)
        self.wleft1.addWidget(self.speedLabel, row=1, col=0)
        #self.wleft1.addWidget(self.clrBtn, row=2, col=0) # TODO 1
        self.wleft1.setStyleSheet(
            "background-color: rgb(40, 44, 52); color: rgb(171, 178, 191);")
        self.dlefttop.setStyleSheet("background-color: rgb(18, 20, 23);")
        self.speedLabel.setStyleSheet(
            "font-family: Monospace; font: 120pt; background-color: rgb(0, 0, 0)"
        )
        self.isAutonomLabel.setStyleSheet(
            "font: 120pt; background-color: rgb(200, 66, 66); color: rgb(44, 48, 56)"
        )
        self.isAutonomLabel.setAlignment(pg.QtCore.Qt.AlignCenter)
        self.dlefttop.addWidget(self.wleft1)
        self.state = None
        #self.wleftbottom = pg.PlotWidget(title="Plot left 2 (bottom)") # TODO 1
        self.wleftbottom = pg.PlotWidget()  # TODO 1
        self.wleftbottom.setAspectLocked(True)
        self.plot_left2 = pg.ScatterPlotItem(size=10,
                                             pen=pg.mkPen(None),
                                             brush=pg.mkBrush(
                                                 6, 106, 166, 255))
        self.wleftbottom.showGrid(x=True, y=True)
        self.wleftbottom.addItem(self.plot_left2)
        self.dleftbottom.addWidget(self.wleftbottom)
        self.wleftbottom.hideAxis('bottom')  # TODO 1
        self.wleftbottom.hideAxis('left')  # TODO 1
        self.clrBtn.clicked.connect(self.clear)
        self.tcurr = pg.TextItem(text="Teleop", color=white)
        self.tstart = pg.TextItem(text="Start", color=red)
        """
        self.wright1 = pg.PlotWidget(title="Plot right 1, random adat")
        self.wright1.plot(np.random.normal(size=20))
        self.wright1.showGrid(x=True, y=True)
        self.dright1.addWidget(self.wright1)
        self.wright2 = pg.PlotWidget(title="Plot right")
        self.plot_right2 = pg.ScatterPlotItem(size=10, pen=pg.mkPen(None), brush=pg.mkBrush(200,66,66,255))
        self.wright2.showGrid(x=True, y=True)
        self.wright2.addItem(self.plot_right2)
        self.dright2.addWidget(self.wright2)
        """

        self.blueWheelHoriz = pg.PlotCurveItem(
            pen=pg.mkPen(qtgqt.QtGui.QColor(6, 106, 166), width=40))
        self.wleftbottom.addItem(self.blueWheelHoriz)
        self.blueWheelVertic = pg.PlotCurveItem(
            pen=pg.mkPen(qtgqt.QtGui.QColor(6, 106, 166), width=40))
        self.wleftbottom.addItem(self.blueWheelVertic)
        self.blueWheelText1 = pg.TextItem(text="-", color=blue)
        self.wleftbottom.addItem(self.blueWheelText1)
        self.drawBlueCircle(self.wleftbottom)

        self.drawRedCircle(self.wleftbottom)
        self.redWheelHoriz = pg.PlotCurveItem(
            pen=pg.mkPen(qtgqt.QtGui.QColor(200, 66, 66), width=40))
        self.redWheelText1 = pg.TextItem(text="-", color=red)
        self.wleftbottom.addItem(self.redWheelHoriz)
        self.wleftbottom.addItem(self.redWheelText1)

        self.redWheelVertic = pg.PlotCurveItem(
            pen=pg.mkPen(qtgqt.QtGui.QColor(200, 66, 66), width=40))
        self.wleftbottom.addItem(self.redWheelVertic)

        self.wleftbottom.setAspectLocked(True)
        self.win.show()
Example #15
0
area = DockArea()
win.setCentralWidget(area)
win.setWindowTitle("HF SSDV")

# Create multiple dock areas, for displaying our data.
d0 = Dock("Controls", size=(300, 800))
d1 = Dock("Image List", size=(300, 800))
d2 = Dock("RX Image", size=(800, 800))
d3 = Dock("Image Metadata", size=(800, 50))
area.addDock(d0, "left")
area.addDock(d1, "right", d0)
area.addDock(d2, "right", d1)
area.addDock(d3, "bottom", d2)

# Controls
w1 = pg.LayoutWidget()
# TNC Connection
tncHostLabel = QtGui.QLabel("<b>TNC Host:</b>")
tncHostEntry = QtGui.QLineEdit(DEFAULT_TNC_HOST)
tncPortLabel = QtGui.QLabel("<b>TNC Port:</b>")
tncPortEntry = QtGui.QLineEdit(str(DEFAULT_TNC_PORT))
tncConnectButton = QtGui.QPushButton("Connect")
tncStatusLabel = QtGui.QLabel("Not Connected")

# User Information & Image TX Settings

userCallLabel = QtGui.QLabel("<b>Callsign:</b>")
userCallEntry = QtGui.QLineEdit(DEFAULT_CALLSIGN)
userCallEntry.setMaxLength(6)  # Maximum SSDV callsign length.

imageQualityLabel = QtGui.QLabel("<b>Img Quality:</b>")
Example #16
0
    def __init__(self):
        #TemplateBaseClass.__init__(self)

        #self.win =QtGui.QGridLayout()
        self.win = pg.LayoutWidget()  # Main layout
        self.win.setWindowTitle('TOF Scan Viewer')

        #Loadfile button
        self.loadbutton = QtGui.QPushButton('Load Data')
        self.loadbutton.clicked.connect(self.OpenFile)
        #Take reference button
        self.refbutton = QtGui.QPushButton('Save Reference')
        self.refbutton.clicked.connect(self.SaveReference)
        #Checkboxes

        self.checkbox0 = QtGui.QCheckBox(
            'Reference')  #View the data feeded by the digitizer
        self.checkbox0.clicked.connect(self.updatePlot)

        self.checkboxStream1 = QtGui.QCheckBox(
            'Stream from scanfile')  #View the data feeded by the digitizer
        self.checkboxStream1.clicked.connect(self.StreamOnOff)

        self.checkbox2 = QtGui.QCheckBox('Norm Dscan')
        self.checkbox2.clicked.connect(self.NormalizeDscan)
        self.checkbox3 = QtGui.QCheckBox('Norm TOF')
        self.checkbox3.clicked.connect(self.NormalizeTOF)

        self.realtimegraph = pg.GraphicsLayoutWidget()
        self.scangraph = pg.GraphicsLayoutWidget()

        # GUI layout
        #self.win.addWidget(QtGui.QLabel('Real time single shot data '),row=0,col=0)
        #self.win.addWidget(QtGui.QLabel('Real time accumulated data'),row=0,col=2)
        #self.win.addWidget(self.realtimegraph,row=1,col=0,colspan=4)
        #self.win.addWidget(QtGui.QLabel('Time of Flight scan'),row=2,col=0)

        self.win.addWidget(self.loadbutton, row=3, col=0)
        self.win.addWidget(self.refbutton, row=4, col=0)
        self.win.addWidget(self.checkbox0, row=5, col=0)
        self.win.addWidget(self.checkboxStream1, row=6, col=0)
        self.win.addWidget(self.checkbox2, row=7, col=0)
        self.win.addWidget(self.checkbox3, row=8, col=0)

        self.win.addWidget(self.scangraph, row=2, col=1, rowspan=25, colspan=3)
        self.realtimegraph.setMaximumHeight(200)
        self.win.resize(1250, 1250)
        self.win.show()

        # Graph layout

        self.prealtime1 = self.realtimegraph.addPlot(row=0, col=0)
        self.prealtime1.setLabel(axis='left', text='Signal (mV) ')
        self.prealtime1.setLabel(axis='bottom', text='Tof (ns)')
        self.prealtime2 = self.realtimegraph.addPlot(row=0, col=2)
        self.prealtime2.setLabel(axis='left', text='Signal (mV) ')
        self.prealtime2.setLabel(axis='bottom', text='Tof (ns)')

        self.p1 = self.scangraph.addPlot(row=0, col=0, colspan=2)
        self.p1.setLabel(axis='left', text='Delay (fs)')
        self.p1.setLabel(axis='bottom', text='Tof (ns)')

        # Item for displaying image data
        self.img = pg.ImageItem()
        self.p1.addItem(self.img)

        # Custom ROI for selecting an image region
        self.roi = pg.ROI(
            [-8, 14],
            [1000, 100])  # first vector =[x0,y0], second vector =[lx,ly]
        self.roi.addScaleHandle([0.5, 1], [0.5, 0.5])
        self.roi.addScaleHandle([0, 0.5], [0.5, 0.5])
        self.p1.addItem(self.roi)
        self.roi.setZValue(10)  # make sure ROI is drawn above image
        self.roi.sigRegionChanged.connect(self.updatePlot)

        # Isocurve drawing
        self.iso = pg.IsocurveItem(level=0.8, pen='g')
        self.iso.setParentItem(self.img)
        self.iso.setZValue(5)

        # Contrast/color control
        self.hist = pg.HistogramLUTItem()
        self.hist.setImageItem(self.img)
        self.scangraph.addItem(self.hist)

        # Draggable line for setting isocurve level
        self.isoLine = pg.InfiniteLine(angle=0, movable=True, pen='g')
        self.hist.vb.addItem(self.isoLine)
        self.hist.vb.setMouseEnabled(
            y=False)  # makes user interaction a little easier
        self.isoLine.setValue(0.8)
        self.isoLine.setZValue(1000)  # bring iso line above contrast controls
        self.isoLine.sigDragged.connect(self.updateIsocurve)

        # Another plot area for displaying ROI data
        self.scangraph.nextRow()
        self.p0 = self.scangraph.addPlot(row=1, col=0)
        self.p0.setLabel(axis='left', text='Signal (arb. u)')
        self.p0.setLabel(axis='bottom', text='Delay (fs)')
        #self.p0.setMaximumWidth(250)
        #self.p0.setMaximumHeight(250)
        #self.p0.rotate(90)
        #self.p0.translate(0,-250)
        self.p0.invertX(True)
        self.isoLine0 = pg.InfiniteLine(angle=90, movable=True, pen='g')
        self.p0.vb.addItem(self.isoLine0)
        self.isoLine0.setValue(2.0)
        self.isoLine0.setZValue(1000)

        self.scangraph.nextCol()
        self.p2 = self.scangraph.addPlot(row=1, col=1, colspan=1)
        self.p2.setLabel(axis='left', text='Signal (arb. u)')
        self.p2.setLabel(axis='bottom', text='Tof (ns)')
        #self.p2.setMaximumHeight(250)

        #Initialize the image
        self.scan = np.random.normal(size=(100, 200))
        self.scan[20:80, 20:80] += 2.
        self.scan = pg.gaussianFilter(self.scan, (3, 3))
        self.scan += np.random.normal(size=(100, 200)) * 0.1
        self.activeimg = self.scan

        self.img.setImage(self.activeimg)
        self.img.scale(1, 1)
        self.img.translate(0, 0)
        self.hist.setLevels(self.activeimg.min(), self.activeimg.max())
        self.p1.autoRange()

        # Infos from filedata
        self.pname = ''
        self.fname = ''

        # Initialise useful variables
        self.normDscan = []
        self.normTOF = []
        self.refDscan = []
        self.refTOF = []
        self.refx0 = []
        self.refy0 = []

        #Timer object for realtime data

        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.updatePlot)
 def initializePlot(self):
     self.first_run = True
     self.paused = False
     self.launched = False
     self.win = qtgqt.QtGui.QMainWindow()
     area = darea.DockArea()
     red = (200, 66, 66)
     redB = pg.mkBrush(200, 66, 66, 200)
     blue = (6, 106, 166)
     blueB = pg.mkBrush(6, 106, 166, 200)
     green = (16, 200, 166)
     greenB = pg.mkBrush(16, 200, 166, 200)
     yellow = (244, 244, 160)
     yellowB = pg.mkBrush(244, 244, 160, 200)
     self.win.setWindowTitle("Waypoint and map editor")
     self.win.resize(1000, 800)
     self.win.setCentralWidget(area)
     dock1 = darea.Dock("dock 1",
                        size=(1, 1))  # give this dock minimum possible size
     dock2 = darea.Dock("dock 2",
                        size=(500, 400))  # size is only a suggestion
     area.addDock(dock1, "left")
     area.addDock(dock2, "bottom", dock1)
     widg1 = pg.LayoutWidget()
     self.csv1Label = qtgqt.QtGui.QLabel("none")
     self.csv1Label.setAlignment(pg.QtCore.Qt.AlignRight)
     self.csv2Label = qtgqt.QtGui.QLabel("none")
     self.csv2Label.setAlignment(pg.QtCore.Qt.AlignRight)
     self.selectFile1Btn = qtgqt.QtGui.QPushButton("Select file")
     self.selectFile2Btn = qtgqt.QtGui.QPushButton("Select file")
     self.selectFile1Btn.setMaximumWidth(100)
     self.selectFile2Btn.setMaximumWidth(100)
     widg1.setStyleSheet(
         "background-color: rgb(40, 44, 52); color: rgb(171, 178, 191);")
     dock1.setStyleSheet("background-color: rgb(18, 20, 23);")
     self.csv1Label.setStyleSheet(
         "font: 10pt; color: rgb(6, 106, 166)")  # blue
     self.csv2Label.setStyleSheet(
         "font: 10pt; color: rgb(200, 66, 66)")  # red
     widg1.addWidget(self.selectFile1Btn, row=1, col=2)
     widg1.addWidget(self.selectFile2Btn, row=2, col=2)
     widg1.addWidget(self.csv1Label, row=1, col=1)
     widg1.addWidget(self.csv2Label, row=2, col=1)
     dock1.addWidget(widg1)
     self.state = None
     self.widg2 = pg.PlotWidget(title="widg2 (bottom)")
     self.widg2.setAspectLocked(True)
     self.pltBlue = ScatterPlotItem(
         size=10, pen=pg.mkPen(None), brush=blueB
     )  # instead of pg.ScatterPlotItem use the override ScatterPlotItem
     self.pltRed = pg.ScatterPlotItem(size=10,
                                      pen=pg.mkPen(None),
                                      brush=redB)
     self.widg2.showGrid(x=True, y=True)
     self.widg2.addItem(self.pltBlue)
     self.widg2.addItem(self.pltRed)
     dock2.addWidget(self.widg2)
     self.selectFile1Btn.clicked.connect(self.selectCsv1Clicked)
     self.selectFile2Btn.clicked.connect(self.selectCsv2Clicked)
     self.textSpeedArray = np.empty(1, dtype=object)
     self.win.show()
Example #18
0
import pyqtgraph.widgets.RemoteGraphicsView
import numpy as np

app = pg.mkQApp()

view = pg.widgets.RemoteGraphicsView.RemoteGraphicsView()
pg.setConfigOptions(antialias=False)  ## this will be expensive for the local plot
view.pg.setConfigOptions(antialias=False)  ## prettier plots at no cost to the main process! 
view.setWindowTitle('pyqtgraph example: RemoteSpeedTest')

label = QtGui.QLabel()
#rcheck = QtGui.QCheckBox('plot remote')
#rcheck.setChecked(True)
#lcheck = QtGui.QCheckBox('plot local')
#lplt = pg.PlotWidget()
layout = pg.LayoutWidget()
#layout.addWidget(rcheck)
#layout.addWidget(lcheck)
layout.addWidget(label)
layout.addWidget(view, row=1, col=0, colspan=3)
#layout.addWidget(lplt, row=2, col=0, colspan=3)
layout.resize(800,800)
layout.show()

## Create a PlotItem in the remote process that will be displayed locally
rplt = view.pg.PlotItem()
rplt._setProxyOptions(deferGetattr=True)  ## speeds up access to rplt.plot
view.setCentralItem(rplt)

lastUpdate = pg.ptime.time()
avgFps = 0.0
Example #19
0
d3 = Dock("wave-forms", size=(300,400))
d4 = Dock("Response", size=(500,400))
d5 = Dock("Impedance Graph", size=(500,400))
area.addDock(paramsDock, 'left')      ## place paramsDock at left edge of dock area (it will fill the whole space since there are no other docks yet)
area.addDock(paramsDockA, 'above', paramsDock)
area.addDock(d2, 'right')     ## place d2 at right edge of dock area
area.addDock(d3, 'bottom', paramsDock)## place d3 at bottom edge of paramsDock
area.addDock(d4, 'top', d2)   
area.addDock(d5, 'above', d4)   

#area.moveDock(d4, 'top', d2)     ## move d4 to top edge of d2

## Add widgets into each dock

## first dock gets save/restore buttons
paramsWidget = pg.LayoutWidget()
label = QtGui.QLabel("""Some buttons""")
getParamsBtn = QtGui.QPushButton('Get params')
sendParamsBtn = QtGui.QPushButton('Send params')
#sendParamsBtn.setEnabled(False)

paramsWidget.addWidget(label, row=0, col=0)
paramsWidget.addWidget(getParamsBtn, row=1, col=0)
paramsWidget.addWidget(sendParamsBtn, row=2, col=0)
paramsDock.addWidget(paramsWidget)

scrollWidget = QtGui.QPlainTextEdit()
d2.addWidget(scrollWidget)

#d3.hideTitleBar()
wavePlotWidget = pg.PlotWidget(title="Waveform")
Example #20
0
    def __init__(self, parent=None):
        self.parent = parent

        ## Dock: Hit finder
        self.dock = Dock("Hit Finder", size=(1, 1))
        self.win = ParameterTree()
        self.dock.addWidget(self.win)
        self.winL = pg.LayoutWidget()
        self.dock.addWidget(self.winL)

        # Hit finding
        self.spiParam_grp = 'Hit finder'
        self.spiParam_algorithm_str = 'Algorithm'
        # algorithm 0
        self.spiParam_algorithm0_str = 'None'
        # algorithm 1
        self.spiParam_algorithm1_str = 'chiSquared'
        self.spiParam_alg1_pruneInterval_str = 'prune interval'
        # algorithm 2
        self.spiParam_algorithm2_str = 'photonFinder'
        self.spiParam_alg2_threshold_str = 'ADUs per photon'
        self.spiParam_alg2_hitThreshold_str = 'Number of pixels for a hit'

        self.spiParam_outDir_str = 'Output directory'
        self.spiParam_runs_str = 'Run(s)'
        self.spiParam_queue_str = 'queue'
        self.spiParam_cpu_str = 'CPUs'
        self.spiParam_psanaq_str = 'psanaq'
        self.spiParam_psnehq_str = 'psnehq'
        self.spiParam_psfehq_str = 'psfehq'
        self.spiParam_psnehprioq_str = 'psnehprioq'
        self.spiParam_psfehprioq_str = 'psfehprioq'
        self.spiParam_psnehhiprioq_str = 'psnehhiprioq'
        self.spiParam_psfehhiprioq_str = 'psfehhiprioq'
        self.spiParam_psdebugq_str = 'psdebugq'
        self.spiParam_psanagpuq_str = 'psanagpuq'
        self.spiParam_psanaidleq_str = 'psanaidleq'
        self.spiParam_noe_str = 'Number of events to process'
        self.spiParam_launch_str = 'Launch hit finder'

        self.hitParam_grp = 'Find hits'
        self.hitParam_hitThresh_str = 'Hit threshold'
        self.hitParam_backgroundThresh_str = 'Background threshold'
        self.hitParam_sample_str = 'Sample name'
        self.hitParam_save_str = 'Save hits'
        self.tag_str = '.cxi tag'

        # Init hit finding
        self.nPixels = 0
        self.spiAlgorithm = 2
        self.spiParam_alg1_pruneInterval = -1
        self.spiParam_alg2_threshold = 30
        self.spiParam_outDir = self.parent.psocakeDir
        self.spiParam_outDir_overridden = False
        self.spiParam_runs = ''
        self.spiParam_queue = self.spiParam_psanaq_str
        self.spiParam_cpus = 24
        self.spiParam_noe = -1
        self.hitParam_hitThresh = '-1'
        self.hitParam_backgroundThresh = '-1'
        self.hitParam_sample = "sample"
        self.tag = ''

        self.params = [
            {
                'name':
                self.spiParam_grp,
                'type':
                'group',
                'children': [
                    {
                        'name': self.spiParam_algorithm_str,
                        'type': 'list',
                        'values': {
                            self.spiParam_algorithm2_str: 2,
                            self.spiParam_algorithm0_str: 0
                        },
                        'value': self.spiAlgorithm
                    },
                    #{'name': self.spiParam_algorithm1_str, 'visible': True, 'expanded': False, 'type': 'str', 'value': "",
                    # 'readonly': True, 'children': [
                    #    {'name': self.spiParam_alg1_pruneInterval_str, 'type': 'float', 'value': self.spiParam_alg1_pruneInterval,
                    #     'tip': "update running background"},
                    #]},
                    {
                        'name':
                        self.spiParam_algorithm2_str,
                        'visible':
                        True,
                        'expanded':
                        False,
                        'type':
                        'str',
                        'value':
                        "",
                        'readonly':
                        True,
                        'children': [
                            {
                                'name': self.spiParam_alg2_threshold_str,
                                'type': 'float',
                                'value': self.spiParam_alg2_threshold,
                                'tip': "search for pixels above ADU per photon"
                            },
                        ]
                    },
                    {
                        'name': self.spiParam_outDir_str,
                        'type': 'str',
                        'value': self.spiParam_outDir
                    },
                    {
                        'name':
                        self.spiParam_runs_str,
                        'type':
                        'str',
                        'value':
                        self.spiParam_runs,
                        'tip':
                        "comma separated or use colon for a range, e.g. 1,3,5:7 = runs 1,3,5,6,7"
                    },
                    {
                        'name': self.spiParam_queue_str,
                        'type': 'list',
                        'values': {
                            self.spiParam_psfehhiprioq_str: 'psfehhiprioq',
                            self.spiParam_psnehhiprioq_str: 'psnehhiprioq',
                            self.spiParam_psfehprioq_str: 'psfehprioq',
                            self.spiParam_psnehprioq_str: 'psnehprioq',
                            self.spiParam_psfehq_str: 'psfehq',
                            self.spiParam_psnehq_str: 'psnehq',
                            self.spiParam_psanaq_str: 'psanaq',
                            self.spiParam_psdebugq_str: 'psdebugq',
                            self.spiParam_psanagpuq_str: 'psanagpuq',
                            self.spiParam_psanaidleq_str: 'psanaidleq'
                        },
                        'value': self.spiParam_queue,
                        'tip': "Choose queue"
                    },
                    {
                        'name': self.spiParam_cpu_str,
                        'type': 'int',
                        'value': self.spiParam_cpus
                    },
                    {
                        'name':
                        self.spiParam_noe_str,
                        'type':
                        'int',
                        'value':
                        self.spiParam_noe,
                        'tip':
                        "number of events to process, default=0 means process all events"
                    },
                    {
                        'name': self.tag_str,
                        'type': 'str',
                        'value': self.tag
                    },
                    {
                        'name': self.spiParam_launch_str,
                        'type': 'action'
                    },
                ]
            },
            {
                'name':
                self.hitParam_grp,
                'type':
                'group',
                'children': [
                    {
                        'name':
                        self.hitParam_hitThresh_str,
                        'type':
                        'str',
                        'value':
                        self.hitParam_hitThresh,
                        'tip':
                        "Set as hit if number of pixels with photons above this value. Or specify a range using a colon, e.g. 100:10000."
                    },
                    {
                        'name':
                        self.hitParam_backgroundThresh_str,
                        'type':
                        'str',
                        'value':
                        self.hitParam_backgroundThresh,
                        'tip':
                        "Use as background if number of pixels with photons below this value. Or specify a range using a colon, e.g. 100:10000."
                    },
                    {
                        'name': self.hitParam_sample_str,
                        'type': 'str',
                        'value': self.hitParam_sample
                    },
                    {
                        'name': self.hitParam_save_str,
                        'type': 'action'
                    },
                ]
            },
        ]
        self.p8 = Parameter.create(name='paramsHitFinder', type='group', \
                                   children=self.params, expanded=True)
        self.win.setParameters(self.p8, showTop=False)
        self.p8.sigTreeStateChanged.connect(self.change)
Example #21
0
    def __init__(self, parent=None):
        self.parent = parent

        self.d12 = Dock("Mask Panel", size=(1, 1))
        ## Dock 12: Mask Panel
        self.w17 = ParameterTree()
        self.d12.addWidget(self.w17)
        self.w18 = pg.LayoutWidget()
        self.maskRectBtn = QtGui.QPushButton('Stamp rectangular mask')
        self.w18.addWidget(self.maskRectBtn, row=0, col=0)  #, colspan=2)
        self.maskCircleBtn = QtGui.QPushButton('Stamp circular mask')
        self.w18.addWidget(self.maskCircleBtn, row=0, col=1)  #, colspan=2)
        self.maskThreshBtn = QtGui.QPushButton('Mask outside histogram')
        self.w18.addWidget(self.maskThreshBtn, row=1, col=1)  #, colspan=2)
        self.maskPolyBtn = QtGui.QPushButton('Stamp polygon mask')
        self.w18.addWidget(self.maskPolyBtn, row=1, col=0)  #, colspan=2)
        self.deployMaskBtn = QtGui.QPushButton()
        self.deployMaskBtn.setStyleSheet(
            'QPushButton {background-color: #A3C1DA; color: red;}')
        self.deployMaskBtn.setText('Save static mask')
        self.w18.addWidget(self.deployMaskBtn, row=2, col=0)
        self.loadMaskBtn = QtGui.QPushButton()
        self.loadMaskBtn.setStyleSheet(
            'QPushButton {background-color: #A3C1DA; color: red;}')
        self.loadMaskBtn.setText('Load mask')
        self.w18.addWidget(self.loadMaskBtn, row=2, col=1)
        self.generatePowderBtn = QtGui.QPushButton('Generate Average Image')
        self.w18.addWidget(self.generatePowderBtn, row=3, col=0, colspan=2)
        # Connect listeners to functions
        self.d12.addWidget(self.w18)

        self.mask_grp = 'Mask'
        self.mask_mode_str = 'Masking mode'
        self.do_nothing_str = 'Off'
        self.do_toggle_str = 'Toggle'
        self.do_mask_str = 'Mask'
        self.do_unmask_str = 'Unmask'
        self.streak_mask_str = 'Use jet streak mask'
        self.streak_width_str = 'maximum streak length'
        self.streak_sigma_str = 'sigma'
        self.psana_mask_str = 'Use psana mask'
        self.user_mask_str = 'Use user-defined mask'
        self.mask_calib_str = 'calib pixels'
        self.mask_status_str = 'status pixels'
        self.mask_edges_str = 'edge pixels'
        self.mask_central_str = 'central pixels'
        self.mask_unbond_str = 'unbonded pixels'
        self.mask_unbondnrs_str = 'unbonded pixel neighbors'
        self.powder_grp = 'Generate Average Image'
        self.powder_outDir_str = 'Output directory'
        self.powder_runs_str = 'Run(s)'
        self.powder_queue_str = 'Queue'
        self.powder_cpu_str = 'CPUs'
        self.powder_noe_str = 'Number of events to process'
        self.powder_threshold_str = 'Threshold'
        self.masking_mode_message = "<span style='color: " + color.black_hex + "; font-size: 24pt;'>Masking mode <br> </span>"

        ######################
        # Mask
        ######################
        self.maskingMode = 0
        self.userMaskOn = False
        self.streakMaskOn = False
        self.streak_sigma = 1
        self.streak_width = 250
        self.psanaMaskOn = False
        self.mask_calibOn = True
        self.mask_statusOn = True
        self.mask_edgesOn = True
        self.mask_centralOn = True
        self.mask_unbondOn = True
        self.mask_unbondnrsOn = True
        self.display_data = None
        self.mask_rect = None
        self.mask_circle = None
        self.mask_poly = None
        self.powder_outDir = self.parent.psocakeDir
        self.powder_runs = ''
        self.powder_queue = self.parent.pk.hitParam_psanaq_str
        self.powder_cpus = 24
        self.powder_noe = -1
        self.powder_threshold = -1

        ###########################
        # Mask variables
        ###########################
        self.psanaMask = None  # psana mask
        self.psanaMaskAssem = None
        self.userMask = None  # user-defined mask
        self.userMaskAssem = None
        self.streakMask = None  # jet streak mask
        self.StreakMask = None  # streak mask class
        self.streakMaskAssem = None
        self.combinedMask = None  # combined mask

        self.params = [
            {
                'name':
                self.mask_grp,
                'type':
                'group',
                'children': [
                    {
                        'name':
                        self.user_mask_str,
                        'type':
                        'bool',
                        'value':
                        self.userMaskOn,
                        'tip':
                        "Mask areas defined by user",
                        'children': [
                            {
                                'name': self.mask_mode_str,
                                'type': 'list',
                                'values': {
                                    self.do_toggle_str: 3,
                                    self.do_unmask_str: 2,
                                    self.do_mask_str: 1,
                                    self.do_nothing_str: 0
                                },
                                'value': self.maskingMode,
                                'tip': "Choose masking mode"
                            },
                        ]
                    },
                    {
                        'name':
                        self.streak_mask_str,
                        'type':
                        'bool',
                        'value':
                        self.streakMaskOn,
                        'tip':
                        "Mask jet streaks shot-to-shot",
                        'children': [
                            {
                                'name': self.streak_width_str,
                                'type': 'float',
                                'value': self.streak_width,
                                'tip': "set maximum length of streak"
                            },
                            {
                                'name': self.streak_sigma_str,
                                'type': 'float',
                                'value': self.streak_sigma,
                                'tip': "set number of sigma to threshold"
                            },
                        ]
                    },
                    {
                        'name':
                        self.psana_mask_str,
                        'type':
                        'bool',
                        'value':
                        self.psanaMaskOn,
                        'tip':
                        "Mask edges and unbonded pixels etc",
                        'children': [
                            {
                                'name': self.mask_calib_str,
                                'type': 'bool',
                                'value': self.mask_calibOn,
                                'tip': "use custom mask deployed in calibdir"
                            },
                            {
                                'name': self.mask_status_str,
                                'type': 'bool',
                                'value': self.mask_statusOn,
                                'tip': "mask bad pixel status"
                            },
                            {
                                'name': self.mask_edges_str,
                                'type': 'bool',
                                'value': self.mask_edgesOn,
                                'tip': "mask edge pixels"
                            },
                            {
                                'name': self.mask_central_str,
                                'type': 'bool',
                                'value': self.mask_centralOn,
                                'tip':
                                "mask central edge pixels inside asic2x1"
                            },
                            {
                                'name': self.mask_unbond_str,
                                'type': 'bool',
                                'value': self.mask_unbondOn,
                                'tip': "mask unbonded pixels (cspad only)"
                            },
                            {
                                'name': self.mask_unbondnrs_str,
                                'type': 'bool',
                                'value': self.mask_unbondnrsOn,
                                'tip':
                                "mask unbonded pixel neighbors (cspad only)"
                            },
                        ]
                    },
                ]
            },
            {
                'name':
                self.powder_grp,
                'type':
                'group',
                'children': [
                    {
                        'name': self.powder_outDir_str,
                        'type': 'str',
                        'value': self.powder_outDir
                    },
                    {
                        'name':
                        self.powder_runs_str,
                        'type':
                        'str',
                        'value':
                        self.powder_runs,
                        'tip':
                        "comma separated or use colon for a range, e.g. 1,3,5:7 = runs 1,3,5,6,7"
                    },
                    {
                        'name': self.powder_queue_str,
                        'type': 'list',
                        'values': {
                            self.parent.pk.hitParam_psfehhiprioq_str:
                            'psfehhiprioq',
                            self.parent.pk.hitParam_psnehhiprioq_str:
                            'psnehhiprioq',
                            self.parent.pk.hitParam_psfehprioq_str:
                            'psfehprioq',
                            self.parent.pk.hitParam_psnehprioq_str:
                            'psnehprioq',
                            self.parent.pk.hitParam_psfehq_str: 'psfehq',
                            self.parent.pk.hitParam_psnehq_str: 'psnehq',
                            self.parent.pk.hitParam_psanaq_str: 'psanaq',
                            self.parent.pk.hitParam_psdebugq_str: 'psdebugq'
                        },
                        'value': self.powder_queue,
                        'tip': "Choose queue"
                    },
                    {
                        'name': self.powder_cpu_str,
                        'type': 'int',
                        'value': self.powder_cpus,
                        'tip': "number of cpus to use per run"
                    },
                    {
                        'name':
                        self.powder_threshold_str,
                        'type':
                        'float',
                        'value':
                        self.powder_threshold,
                        'tip':
                        "ignore pixels below ADU threshold, default=-1 means no threshold"
                    },
                    {
                        'name':
                        self.powder_noe_str,
                        'type':
                        'int',
                        'value':
                        self.powder_noe,
                        'tip':
                        "number of events to process, default=-1 means process all events"
                    },
                ]
            },
        ]

        self.p6 = Parameter.create(name='paramsMask', type='group', \
                                   children=self.params, expanded=True)
        self.w17.setParameters(self.p6, showTop=False)
        self.p6.sigTreeStateChanged.connect(self.change)

        self.parent.connect(self.maskRectBtn, QtCore.SIGNAL("clicked()"),
                            self.makeMaskRect)
        self.parent.connect(self.maskCircleBtn, QtCore.SIGNAL("clicked()"),
                            self.makeMaskCircle)
        self.parent.connect(self.maskThreshBtn, QtCore.SIGNAL("clicked()"),
                            self.makeMaskThresh)
        self.parent.connect(self.maskPolyBtn, QtCore.SIGNAL("clicked()"),
                            self.makeMaskPoly)
        self.parent.connect(self.deployMaskBtn, QtCore.SIGNAL("clicked()"),
                            self.deployMask)
        self.parent.connect(self.loadMaskBtn, QtCore.SIGNAL("clicked()"),
                            self.loadMask)

        self.parent.connect(self.generatePowderBtn, QtCore.SIGNAL("clicked()"),
                            self.makePowder)
Example #22
0
    def __init__(self,
                 current_protocol,
                 protocols,
                 signals,
                 n_signals=1,
                 parent=None,
                 n_channels=32,
                 max_protocol_n_samples=None,
                 experiment=None,
                 freq=500,
                 plot_raw_flag=True,
                 plot_signals_flag=True,
                 plot_source_space_flag=False,
                 show_subject_window=True,
                 channels_labels=None,
                 photo_rect=False):
        super(MainWindow, self).__init__(parent)

        # Which windows to draw:
        self.plot_source_space_flag = plot_source_space_flag
        self.show_subject_window = show_subject_window

        # status info
        self.status = PlayerLineInfo([p.name for p in protocols],
                                     [[p.duration for p in protocols]])

        self.source_freq = freq
        self.experiment = experiment
        self.signals = signals

        # player panel
        self.player_panel = PlayerButtonsWidget(parent=self)
        self.player_panel.restart.clicked.connect(self.restart_experiment)
        self.player_panel.start.clicked.connect(self.update_first_status)
        self._first_time_start_press = True

        # timer label
        self.timer_label = QtWidgets.QLabel('tf')

        # signals viewer
        self.signals_viewer = DerivedSignalViewer(
            freq, [signal.name for signal in signals])

        # raw data viewer
        self.raw_viewer = RawSignalViewer(freq,
                                          channels_labels,
                                          notch_filter=True)
        self.n_channels = n_channels
        self.n_samples = 2000

        self.plot_raw_checkbox = QtWidgets.QCheckBox('plot raw')
        self.plot_raw_checkbox.setChecked(plot_raw_flag)
        self.plot_signals_checkbox = QtWidgets.QCheckBox('plot signals')
        self.plot_signals_checkbox.setChecked(plot_signals_flag)
        self.autoscale_raw_chekbox = QtWidgets.QCheckBox('autoscale')
        self.autoscale_raw_chekbox.setChecked(True)

        # topomaper
        # pos = ch_names_to_2d_pos(channels_labels)
        # self.topomaper = TopomapWidget(pos)

        # dc_blocker
        self.dc_blocker = DCBlocker()

        # main window layout
        layout = pg.LayoutWidget(self)
        layout.addWidget(self.signals_viewer, 0, 0, 1, 3)
        layout.addWidget(self.plot_raw_checkbox, 1, 0, 1, 1)
        layout.addWidget(self.plot_signals_checkbox, 1, 2, 1, 1)
        layout.addWidget(self.autoscale_raw_chekbox, 1, 1, 1, 1)
        layout.addWidget(self.raw_viewer, 2, 0, 1, 3)
        layout.addWidget(self.player_panel, 3, 0, 1, 1)
        layout.addWidget(self.timer_label, 3, 1, 1, 1)
        #layout.addWidget(self.topomaper, 3, 2, 1, 1)
        layout.addWidget(self.status, 4, 0, 1, 3)
        layout.layout.setRowStretch(0, 2)
        layout.layout.setRowStretch(2, 2)
        self.setCentralWidget(layout)

        # main window settings
        self.resize(800, 600)
        self.show()

        # subject window
        if show_subject_window:
            self.subject_window = SubjectWindow(self,
                                                current_protocol,
                                                photo_rect=photo_rect)
            self.subject_window.show()
            self._subject_window_want_to_close = False
        else:
            self.subject_window = None
            self._subject_window_want_to_close = None

        # Source space window
        if plot_source_space_flag:
            source_space_protocol = SourceSpaceRecontructor(signals)
            self.source_space_window = SourceSpaceWindow(
                self, source_space_protocol)
            self.source_space_window.show()

        # time counter
        self.time_counter = 0
        self.time_counter1 = 0
        self.t0 = time.time()
        self.t = self.t0
matrixInit()

#############################
# Grapichs Layout
#############################
app = QtGui.QApplication([])
win = QtGui.QMainWindow()
app.setStyleSheet(qdarkstyle.load_stylesheet_pyside())

win.setWindowTitle('Corte directo para suelos friccionantes')
pg.setConfigOptions(antialias=True)

#############################
# Layout
win1 = pg.LayoutWidget()
win.setCentralWidget(win1)

fig2 = pg.PlotWidget(
    title=
    '<div style="text-align: center;"><span style="color: #CCC; font-size: 11pt;">Grafico</span></div>'
)
fig2.setLabel(axis="left", text="Deformaciones", units="mm")
fig2.setLabel(axis="bottom", text="Tiempo", units="s")
fig2.setLabel(
    axis="top",
    text=
    '<span style="color: #CCC; font-size: 12pt;">Esfuezo de corte vs Deformacion Horizontal</span>'
)
fig2.setLabel(axis="right", text='-')
fig2.setYRange(0, 10.0)
Example #24
0
    def __init__(self):
        """Missing docstring."""
        super().__init__()

        # %% plot parameters
        self.z_min = -10e-2  # m
        self.z_max = 10e-2  # m
        self.n_points = 100  # number of points to evaluate field within z_min and z_max
        if self.z_max > self.z_min:
            self.z_array = np.linspace(self.z_min, self.z_max, self.n_points)
        else:
            raise ValueError('z_max must be bigger than z_min')
        # pre-allocate Bz
        self.Bz = np.ones(self.n_points)

        # %% ########### variables parameters ########################
        # parameter table 1
        self.variables = dict(T=150, R=2.5e-2, D=4.9e-2 / 2, I=1)
        self.variables_min = dict(T=1, R=0.5e-2, D=0, I=0)
        self.variables_max = dict(T=500, R=10e-2, D=10e-2, I=10)
        self.variables_step = dict(T=1, R=.1e-2, D=.1e-2 / 2, I=.5)
        self.variables_txt = dict(T='(turns)', R='(m)', D='(m)', I='(A)')
        self.table1 = list(self.variables.keys())

        # %% ########## window parameters ############
        self.resize(1000, 800)
        self.setWindowTitle('FI226 - Coil Simulation (exact)')

        # %% ########## Init dockable area ###############
        self.area = DockArea()
        self.setCentralWidget(self.area)

        # %% ################ Create and place docks ##################
        self.d1 = Dock("Magnetic field in the z direction Bz for x=0 and y=0",
                       size=(1, 1),
                       closable=True)
        self.d2 = Dock("Derivative of Bz with respect to z",
                       size=(1, 1),
                       closable=True)
        self.d3 = Dock("parameter table", size=(1, 1))

        self.area.addDock(self.d1, 'left')
        # self.area.addDock(self.d1, 'above', self.d6)
        self.area.addDock(self.d2, 'right')

        self.area.addDock(self.d3, 'bottom')

        # Move docks programatically after they have been placed
        # self.area.moveDock(self.d4, 'top', self.d2)  # move d4 to top edge of d2

        # %% #################### dock 1 ########################
        self.w1 = pg.LayoutWidget()
        # self.d1.hideTitleBar()
        # Add (and set) a plot into this dock
        self.w1 = pg.PlotWidget(title=None)
        self.w1.setLabel('bottom', text='z position', units='m')
        self.w1.setLabel('left', text='Bz', units='G')
        self.curve_plot1_1 = self.w1.plot([], pen='g')
        self.curve_plot1_2 = self.w1.plot([], pen='r')
        self.d1.addWidget(self.w1)

        # %% #################### dock 2 ########################
        self.w2 = pg.LayoutWidget()
        # self.d1.hideTitleBar()
        # Add (and set) a plot into this dock
        self.w2 = pg.PlotWidget(title=None)
        self.w2.setLabel('bottom', text='z position', units='m')
        self.w2.setLabel('left', text='dBz/dz', units='G/cm')
        self.curve_plot2_1 = self.w2.plot([], symbolBrush=None, pen='y')
        self.curve_plot2_2 = self.w2.plot([], pen='g')
        self.d2.addWidget(self.w2)

        # %% #################### dock 3 ########################
        # This is a parameter dock.
        self.sliders = dict()
        for idx, variable in enumerate(self.table1):
            value = self.variables[variable]
            min = self.variables_min[variable]
            max = self.variables_max[variable]
            step = self.variables_step[variable]
            txt = self.variables_txt[variable]
            self.sliders[variable] = self.createSlider(variable, min, max,
                                                       step, value, txt)

            self.d3.addWidget(self.sliders[variable]['btn'], row=idx, col=1)
            self.d3.addWidget(self.sliders[variable]['slider'], row=idx, col=2)
            self.d3.addWidget(self.sliders[variable]['txt'], row=idx, col=3)
            self.d3.addWidget(self.sliders[variable]['lineEdit'],
                              row=idx,
                              col=4)

        # %% ################### act ############################
        self.update()
        self.show()
Example #25
0
    def __init__(self, parent=None):
        self.parent = parent

        ## Dock 8: Quantifier
        self.dSmall = Dock("Small Data", size=(100, 100))
        self.w8 = ParameterTree()
        self.dSmall.addWidget(self.w8)
        self.w11a = pg.LayoutWidget()
        self.refreshBtn = QtGui.QPushButton('Refresh')
        self.w11a.addWidget(self.refreshBtn, row=0, col=0)
        self.dSmall.addWidget(self.w11a)
        # Add plot
        self.w9 = pg.PlotWidget(title="Metric")
        self.dSmall.addWidget(self.w9)

        # Quantifier parameter tree
        self.quantifier_grp = 'Small data'
        self.quantifier_filename_str = 'filename'
        self.quantifier_dataset_str = 'dataset'
        self.quantifier_sort_str = 'sort'

        # Quantifier
        self.quantifier_filename = ''
        self.quantifier_dataset = '/entry_1/result_1/'
        self.quantifier_sort = False
        self.quantifierFileOpen = False
        self.quantifierHasData = False

        self.params = [
            {
                'name':
                self.quantifier_grp,
                'type':
                'group',
                'children': [
                    {
                        'name': self.quantifier_filename_str,
                        'type': 'str',
                        'value': self.quantifier_filename,
                        'tip': "Full path Hdf5 filename"
                    },
                    {
                        'name': self.quantifier_dataset_str,
                        'type': 'str',
                        'value': self.quantifier_dataset,
                        'tip': "Hdf5 dataset metric, nPeaksAll or nHitsAll"
                    },
                    {
                        'name': self.quantifier_sort_str,
                        'type': 'bool',
                        'value': self.quantifier_sort,
                        'tip': "Ascending sort metric"
                    },
                ]
            },
        ]

        self.pSmall = Parameter.create(name='paramsQuantifier', type='group', \
                                       children=self.params, expanded=True)
        self.w8.setParameters(self.pSmall, showTop=False)
        self.pSmall.sigTreeStateChanged.connect(self.change)
        self.refreshBtn.clicked.connect(self.reloadQuantifier)
Example #26
0
    logging = True
    log_file_name = textbox.text() + datetime.datetime.now().strftime(
        '_%Y-%m-%d_%H-%M-%S') + '.txt'
    logging_toggler.setText('Now logging')
    timer.singleShot(5000, stop_logging)


please_center = False


def median_centering():
    global please_center
    please_center = True


setwidget = pg.LayoutWidget()
logging_toggler = QtGui.QPushButton('Log for 5 seconds')
logging_toggler.clicked.connect(log_and_print)
zero_button = QtGui.QPushButton('Center Traces')
zero_button.clicked.connect(median_centering)

setwidget.addWidget(logging_toggler)
setwidget.addWidget(zero_button)
d2.addWidget(setwidget)

textbox = QtGui.QLineEdit()
setwidget.addWidget(textbox)

centering = None
current_data_view = None
d1 = Dock("Altitude Orientation Indicator", size=(window_block[0] * 24, window_block[1] * 13), hideTitle=True)
d2 = Dock("Console", size=(window_block[0] * 24, window_block[1] * 5), hideTitle=True)
d3 = Dock("Data Stream", size=(24 * window_block[0], 24 * window_block[1]), hideTitle=True)
d4 = Dock("Menu", size=(8 * window_block[0], 27 * window_block[1]), hideTitle=True)
d6 = Dock("Stream Options", size=(8 * window_block[0], 13 * window_block[1]), hideTitle=True)
area.addDock(d1, 'left')
area.addDock(d6, 'right', d1)
area.addDock(d3, 'bottom', d1)
area.addDock(d2, 'bottom', d3)
area.addDock(d4, 'bottom', d6)


# Add widgets into each dock

# first dock gets save/restore buttons
w4 = pg.LayoutWidget()
label = QtGui.QLabel("""Will contain either 3D plot or 3 cross-sectional plots for orientation viewing""")
saveBtn = QtGui.QPushButton('Save dock state')
restoreBtn = QtGui.QPushButton('Restore dock state')
restoreBtn.setEnabled(False)
w4.addWidget(label, row=0, col=0)
w4.addWidget(saveBtn, row=1, col=0)
w4.addWidget(restoreBtn, row=2, col=0)
d1.addWidget(w4)
state = None


def save():
    global state
    state = area.saveState()
    restoreBtn.setEnabled(True)
Example #28
0
    def __init__(self, parent=None):

        DEBUGUER = 0
        QtGui.QMainWindow.__init__(self, parent)
        self.resize(1000, 800)
        self.setWindowTitle('POST-PROCESSING ARISTARKO')

        #CONTROL VARIABLES
        #TODO: mejor meter en un dictionary
        self.data = np.array([])

        #set dock area as central widget
        self.area = DockArea()
        self.setCentralWidget(self.area)

        #create docks and add them into dock area
        self.d1 = Dock("Controls", size=(200, 50), closable=True)
        self.d2 = Dock("Plots", size=(600, 480))
        #self.d3 = Dock("FOCUS", size=(400, 400), closable=True)
        self.area.addDock(self.d1, 'left')
        self.area.addDock(self.d2)

        #create a layout for dock 1. I am going to introduce more widgets
        self.w1 = pg.LayoutWidget()

        ###########################################
        #create widgets and move into each dock
        ###########################################

        #open file action
        openfile = QtGui.QAction(QtGui.QIcon('open.png'), 'Open Log', self)
        openfile.setShortcut('Ctrl+O')
        openfile.setStatusTip('Open new File')
        openfile.triggered.connect(self.showDialog)

        # menu bar
        menubar = self.menuBar()  # activo la barra de menu
        fileMenu = menubar.addMenu('&File')  # adding the menu
        fileMenu.addAction(openfile)  #le pongo la action

        ##########################################
        #graphics
        ##########################################

        self.win = pg.GraphicsWindow()
        self.win.resize(600, 600)
        self.win.setWindowTitle('ARISTARKO MONITOR')
        self.d2.addWidget(self.win)  #adding a dock2
        self.p1 = self.win.addPlot()
        self.win.nextRow()
        self.p2 = self.win.addPlot()

        #regions
        self.region = pg.LinearRegionItem()
        self.region.setZValue(10)
        self.p2.addItem(self.region, ignoreBounds=True)
        self.p1.setAutoVisible(y=True)
        self.region.setRegion([1000, 2000])

        #controls
        self.button = QtGui.QPushButton('PLOT')
        self.w1.addWidget(self.button, row=0, col=0)
        self.d1.addWidget(self.w1)

        #SIGNALS
        self.button.clicked.connect(self.plotSignals)
        self.region.sigRegionChanged.connect(self.updateRange)
        self.p1.sigRangeChanged.connect(self.updateRegion)
    def __init__(self, parent=None):
        self.parent = parent

        ## Dock 14: Indexing
        self.d14 = Dock("Indexing", size=(1, 1))
        self.w21 = ParameterTree()
        self.w21.setWindowTitle('Indexing')
        self.d14.addWidget(self.w21)
        self.w22 = pg.LayoutWidget()
        self.launchIndexBtn = QtGui.QPushButton('Launch indexing')
        self.w22.addWidget(self.launchIndexBtn, row=0, col=0)
        self.synchBtn = QtGui.QPushButton('Deploy CrystFEL geometry')
        self.w22.addWidget(self.synchBtn, row=1, col=0)
        self.d14.addWidget(self.w22)

        self.index_grp = 'Crystal indexing'
        self.index_on_str = 'Indexing on'
        self.index_geom_str = 'CrystFEL geometry'
        self.index_peakMethod_str = 'Peak method'
        self.index_intRadius_str = 'Integration radii'
        self.index_pdb_str = 'PDB'
        self.index_method_str = 'Indexing method'
        #self.index_minPeaks_str = 'Minimum number of peaks'
        #self.index_maxPeaks_str = 'Maximum number of peaks'
        #self.index_minRes_str = 'Minimum resolution (pixels)'
        self.index_tolerance_str = 'Tolerance'
        self.index_extra_str = 'Extra CrystFEL parameters'

        self.launch_grp = 'Batch'
        self.outDir_str = 'Output directory'
        self.runs_str = 'Runs(s)'
        self.sample_str = 'Sample name'
        self.tag_str = 'Tag'
        self.queue_str = 'Queue'
        self.chunkSize_str = 'Chunk size'
        self.keepData_str = 'Keep CXI images'
        self.noe_str = 'Number of events to process'
        (self.psanaq_str,self.psnehq_str,self.psfehq_str,self.psnehprioq_str,self.psfehprioq_str,self.psnehhiprioq_str,self.psfehhiprioq_str,self.psdebugq_str) = \
            ('psanaq','psnehq','psfehq','psnehprioq','psfehprioq','psnehhiprioq','psfehhiprioq','psdebugq')

        self.outDir = self.parent.psocakeDir
        self.outDir_overridden = False
        self.runs = ''
        self.sample = 'crystal'
        self.tag = ''
        self.queue = self.psanaq_str
        self.chunkSize = 500
        self.noe = -1

        # Indexing
        self.showIndexedPeaks = False
        self.indexedPeaks = None
        self.hiddenCXI = '.temp.cxi'
        self.hiddenCrystfelStream = '.temp.stream'
        self.hiddenCrystfelList = '.temp.lst'

        self.indexingOn = False
        self.numIndexedPeaksFound = 0
        self.geom = '.temp.geom'
        self.peakMethod = 'cxi'
        self.intRadius = '2,3,4'
        self.pdb = ''
        self.indexingMethod = 'mosflm-noretry,dirax'
        #self.minPeaks = 15
        #self.maxPeaks = 2048
        #self.minRes = 0
        self.tolerance = '5,5,5,1.5'
        self.extra = ''
        self.keepData = True

        #######################
        # Mandatory parameter #
        #######################
        self.params = [
            {
                'name':
                self.index_grp,
                'type':
                'group',
                'children': [
                    {
                        'name': self.index_on_str,
                        'type': 'bool',
                        'value': self.indexingOn,
                        'tip': "Turn on indexing"
                    },
                    {
                        'name': self.index_geom_str,
                        'type': 'str',
                        'value': self.geom,
                        'tip': "CrystFEL geometry file"
                    },
                    #{'name': self.index_peakMethod_str, 'type': 'str', 'value': self.peakMethod, 'tip': "Turn on indexing"},
                    {
                        'name': self.index_intRadius_str,
                        'type': 'str',
                        'value': self.intRadius,
                        'tip': "Integration radii"
                    },
                    {
                        'name': self.index_pdb_str,
                        'type': 'str',
                        'value': self.pdb,
                        'tip': "(Optional) CrystFEL unitcell file"
                    },
                    {
                        'name': self.index_method_str,
                        'type': 'str',
                        'value': self.indexingMethod,
                        'tip': "comma separated indexing methods"
                    },
                    {
                        'name': self.index_tolerance_str,
                        'type': 'str',
                        'value': self.tolerance,
                        'tip': "Indexing tolerance, default: 5,5,5,1.5"
                    },
                    {
                        'name': self.index_extra_str,
                        'type': 'str',
                        'value': self.extra,
                        'tip': "Other indexing parameters"
                    },
                    #{'name': self.index_minPeaks_str, 'type': 'int', 'value': self.minPeaks,
                    # 'tip': "Index only if there are more Bragg peaks found"},
                    #{'name': self.index_maxPeaks_str, 'type': 'int', 'value': self.maxPeaks,
                    # 'tip': "Index only if there are less Bragg peaks found"},
                    #{'name': self.index_minRes_str, 'type': 'int', 'value': self.minRes,
                    # 'tip': "Index only if Bragg peak resolution is at least this"},
                ]
            },
            {
                'name':
                self.launch_grp,
                'type':
                'group',
                'children': [
                    {
                        'name': self.outDir_str,
                        'type': 'str',
                        'value': self.outDir
                    },
                    {
                        'name':
                        self.runs_str,
                        'type':
                        'str',
                        'value':
                        self.runs,
                        'tip':
                        "comma separated or use colon for a range, e.g. 1,3,5:7 = runs 1,3,5,6,7"
                    },
                    {
                        'name':
                        self.sample_str,
                        'type':
                        'str',
                        'value':
                        self.sample,
                        'tip':
                        "name of the sample saved in the cxidb file, e.g. lysozyme"
                    },
                    {
                        'name':
                        self.tag_str,
                        'type':
                        'str',
                        'value':
                        self.tag,
                        'tip':
                        "attach tag to stream, e.g. cxitut13_0010_tag.stream"
                    },
                    {
                        'name': self.queue_str,
                        'type': 'list',
                        'values': {
                            self.psfehhiprioq_str: self.psfehhiprioq_str,
                            self.psnehhiprioq_str: self.psnehhiprioq_str,
                            self.psfehprioq_str: self.psfehprioq_str,
                            self.psnehprioq_str: self.psnehprioq_str,
                            self.psfehq_str: self.psfehq_str,
                            self.psnehq_str: self.psnehq_str,
                            self.psanaq_str: self.psanaq_str,
                            self.psdebugq_str: self.psdebugq_str
                        },
                        'value': self.queue,
                        'tip': "Choose queue"
                    },
                    {
                        'name': self.chunkSize_str,
                        'type': 'int',
                        'value': self.chunkSize,
                        'tip': "number of patterns to process per worker"
                    },
                    {
                        'name': self.keepData_str,
                        'type': 'bool',
                        'value': self.keepData,
                        'tip': "Do not delete cxidb images in cxi file"
                    },
                ]
            },
        ]

        self.p9 = Parameter.create(name='paramsCrystalIndexing', type='group', \
                                   children=self.params, expanded=True)
        self.w21.setParameters(self.p9, showTop=False)
        self.p9.sigTreeStateChanged.connect(self.change)

        self.launchIndexBtn.clicked.connect(self.indexPeaks)
        self.synchBtn.clicked.connect(self.syncGeom)
Example #30
0
    def __init__(self):
        """Temp docstring."""
        super().__init__()

        # %% ########### variables parameters ########################
        # parameter table 1
        self.variables = dict(x=5, y=2, z=2)
        self.variables_min = dict(x=0, y=0, z=0)
        self.variables_max = dict(x=10, y=10, z=10)
        self.variables_step = dict(x=1, y=.1, z=.3)
        self.variables_txt = dict(x='(m)', y='(cm)', z='(some comment)')
        self.table1 = list(self.variables.keys())

        # parameter table 2
        self.variables.update(dict(x2=0, y2=11.8))
        self.variables_min.update(dict(x2=-10, y2=-5))
        self.variables_max.update(dict(x2=10, y2=20))
        self.variables_step.update(dict(x2=1, y2=.2))
        self.variables_txt.update(dict(x2=None, y=None, z=None))
        self.table2 = [
            x for x in list(self.variables.keys()) if x not in self.table1
        ]

        # parameter table 3
        self.variables.update(dict(x3=2))
        self.variables_min.update(dict(x3=0))
        self.variables_max.update(dict(x3=3))
        self.variables_step.update(dict(x3=1))
        self.variables_txt.update(dict(x3=None))
        self.table3 = [
            x for x in list(self.variables.keys())
            if x not in self.table1 and x not in self.table2
        ]

        # %% ########## window parameters ############
        self.resize(1000, 800)
        self.setWindowTitle('pyqtgraph_fastApp')

        # %% ########## Init dockable area ###############
        self.area = DockArea()
        self.setCentralWidget(self.area)

        # %% ################ Create and place docks ##################
        self.d1 = Dock("plot 1 (d1)", size=(1, 1), closable=True)
        self.d2 = Dock("plot 2 (d2)", size=(1, 1), closable=True)
        self.d3 = Dock("parameter table 1 (d3)", size=(1, 1))
        self.d4 = Dock("parameter table 2 (d4)", size=(1, 1))
        self.d5 = Dock("parameter table 3 (d5)", size=(1, 1))
        self.d6 = Dock("plot 3 (d6)", size=(1, 1), closable=True)

        self.area.addDock(self.d6, 'left')
        self.area.addDock(self.d1, 'above', self.d6)
        self.area.addDock(self.d2, 'right')

        self.area.addDock(self.d5, 'bottom')
        self.area.addDock(self.d4, 'above', self.d5)
        self.area.addDock(self.d3, 'above', self.d4)

        # Move docks programatically after they have been placed
        # self.area.moveDock(self.d4, 'top', self.d2)  # move d4 to top edge of d2

        # %% #################### dock 1 ########################
        self.w1 = pg.LayoutWidget()
        # self.d1.hideTitleBar()
        # Add (and set) a plot into this dock
        self.w1 = pg.PlotWidget(title=None)
        self.w1.setLabel('bottom', text='x axis', unitPrefix=None)
        self.w1.setLabel('left', text='y axis', unitPrefix=None)
        self.curve_plot1_1 = self.w1.plot([], pen='g')
        self.curve_plot1_2 = self.w1.plot([], pen='r')
        self.d1.addWidget(self.w1)

        # %% #################### dock 2 ########################
        self.w2 = pg.LayoutWidget()
        # self.d1.hideTitleBar()
        # Add (and set) a plot into this dock
        self.w2 = pg.PlotWidget(title=None)
        self.w2.setLabel('bottom', text='x axis', unitPrefix=None)
        self.w2.setLabel('left', text='y axis', unitPrefix=None)
        self.curve_plot2_1 = self.w2.plot([], symbolBrush=None, pen='y')
        self.curve_plot2_2 = self.w2.plot([], pen='g')
        self.d2.addWidget(self.w2)

        # %% #################### dock 6 ########################
        self.w6 = pg.LayoutWidget()
        # self.d1.hideTitleBar()
        # Add (and set) a plot into this dock
        self.w6 = pg.PlotWidget(title=None)
        self.w6.setLabel('bottom', text='x axis', unitPrefix=None)
        self.w6.setLabel('left', text='y axis (cm)', unitPrefix=None)
        self.curve_plot3_1 = self.w6.plot([], symbolBrush=None, pen='r')
        self.curve_plot3_2 = self.w6.plot([])
        self.curve_plot3_3 = self.w6.plot([], pen='g')
        self.d6.addWidget(self.w6)

        # %% #################### dock 3 ########################
        # This is a parameter dock.
        self.sliders = dict()
        for idx, variable in enumerate(self.table1):
            value = self.variables[variable]
            min = self.variables_min[variable]
            max = self.variables_max[variable]
            step = self.variables_step[variable]
            txt = self.variables_txt[variable]
            self.sliders[variable] = self.createSlider(variable, min, max,
                                                       step, value, txt)

            self.d3.addWidget(self.sliders[variable]['btn'], row=idx, col=1)
            self.d3.addWidget(self.sliders[variable]['slider'], row=idx, col=2)
            self.d3.addWidget(self.sliders[variable]['txt'], row=idx, col=3)
            self.d3.addWidget(self.sliders[variable]['lineEdit'],
                              row=idx,
                              col=4)

        # %% #################### dock 4 ########################
        # This is a parameter dock.
        self.sliders = dict()
        for idx, variable in enumerate(self.table2):
            value = self.variables[variable]
            min = self.variables_min[variable]
            max = self.variables_max[variable]
            step = self.variables_step[variable]
            txt = self.variables_txt[variable]
            self.sliders[variable] = self.createSlider(variable, min, max,
                                                       step, value, txt)

            self.d4.addWidget(self.sliders[variable]['btn'], row=idx, col=1)
            self.d4.addWidget(self.sliders[variable]['slider'], row=idx, col=2)
            self.d4.addWidget(self.sliders[variable]['txt'], row=idx, col=3)
            self.d4.addWidget(self.sliders[variable]['lineEdit'],
                              row=idx,
                              col=4)

        # %% #################### dock 5 ########################
        # This is a parameter dock.
        self.sliders = dict()
        for idx, variable in enumerate(self.table3):
            value = self.variables[variable]
            min = self.variables_min[variable]
            max = self.variables_max[variable]
            step = self.variables_step[variable]
            txt = self.variables_txt[variable]
            self.sliders[variable] = self.createSlider(variable, min, max,
                                                       step, value, txt)

            self.d5.addWidget(self.sliders[variable]['btn'], row=idx, col=1)
            self.d5.addWidget(self.sliders[variable]['slider'], row=idx, col=2)
            self.d5.addWidget(self.sliders[variable]['txt'], row=idx, col=3)
            self.d5.addWidget(self.sliders[variable]['lineEdit'],
                              row=idx,
                              col=4)

        # %% ################### act ############################
        self.update()
        self.show()