def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)

        self.lastTime = current_milli_time()
        self.currentTime = current_milli_time()
        self.lastInspiration = current_milli_time()
        self.currentInspiration = current_milli_time()

        self.respRate = 10
        self.lastPressure = 0

        self.lastExpiration = current_milli_time()
        self.lastExpTime = current_milli_time()
        self.lastExpCurrentTime = current_milli_time()
        self.tidalVol = 0.0
        self.lastTidalVol = 0.0
        self.lastFlow = 0.0
        self.tidalVolHistory = [0] * 10
        self.tidalVolHistoryCounter = 0
        self.meantidalVol = 0.0


        ### widgets ###################################################################3
        # create graph widgets
        # alarm row at top
        self.labelAlarm = QLabel("Alarms:")
        self.graphWidgetPressure = pg.PlotWidget()
        self.graphWidgetVol = pg.PlotWidget()
        self.graphWidgetFlow = pg.PlotWidget()
        
        # pressure labels
        self.labelPMax = QLabel()
        self.labelPMaxVal = QLabel()
        self.labelPAv = QLabel()
        self.labelPAvVal = QLabel()
        self.labelPMin = QLabel()
        self.labelPMinVal = QLabel()

        # resp rate labels
        self.labelRespRate = QLabel("Resp. Rate:")
        self.labelRespRateVal = QLabel("10 bpm")

        # tidal volume labels
        self.labelTidalVol = QLabel("Tidal Vol:")
        self.labelTidalVolVal = QLabel("500 ml")

        # minute volume labels
        self.labelMinuteVol = QLabel("Minute Vol:")
        self.labelMinuteVolVal = QLabel("5 L/min")
        
        self.labelAlarmPMax = QLabel("40")
        self.btnUpPMax = QPushButton("+")
        self.btnDownPMax = QPushButton("-")
        
        
        self.labelAlarmPMin = QLabel("10")
        self.btnUpPMin = QPushButton("+")
        self.btnDownPMin = QPushButton("-")
        
        self.labelFMax = QLabel("Flow_max:")
        self.labelFMin = QLabel("Flow_min:")
        self.labelFMaxVal = QLabel()
        self.labelFMinVal = QLabel()

        
        layout = QGridLayout()
        
        layout.addWidget(self.labelAlarm, 1,1)
        layout.addWidget(self.graphWidgetPressure, 2,1, 3, 3)
        layout.addWidget(self.graphWidgetVol, 5,1, 3, 3)
        layout.addWidget(self.labelPMax,2,4)
        layout.addWidget(self.labelPMaxVal, 2,5)
        layout.addWidget(self.labelPAv,3,4)
        layout.addWidget(self.labelPAvVal, 3,5)
        layout.addWidget(self.labelPMin,4,4)
        layout.addWidget(self.labelPMinVal, 4,5)
        layout.addWidget(self.labelRespRate, 5,4)
        layout.addWidget(self.labelRespRateVal, 5,5)
        layout.addWidget(self.labelTidalVol, 6,4)
        layout.addWidget(self.labelTidalVolVal, 6,5)
        layout.addWidget(self.labelMinuteVol, 7,4)
        layout.addWidget(self.labelMinuteVolVal, 7,5)
        #layout.addWidget(self.btnUpPMax, 1,2)
        #layout.addWidget(self.labelAlarmPMax, 2,2)
        #layout.addWidget(self.btnDownPMax, 3,2)
        #layout.addWidget(self.btnUpPMin, 4,2)
        #layout.addWidget(self.labelAlarmPMin, 5,2)
        #layout.addWidget(self.btnDownPMin, 6,2)
        # layout.addWidget(self.labelFMax,4,4)
        # layout.addWidget(self.labelFMaxVal, 4,5)
        # layout.addWidget(self.labelFMin,5,4)
        # layout.addWidget(self.labelFMinVal, 5,5)
        

        self.labelPMax.setText("P_peak:")
        self.labelPMaxVal.setText("20")
        self.labelPMaxVal.setFont(QtGui.QFont("Arial", 48, QtGui.QFont.Bold))
        self.labelPAv.setText("P_mean:")
        self.labelPAvVal.setText("20")
        self.labelPAvVal.setFont(QtGui.QFont("Arial", 48, QtGui.QFont.Bold))
        self.labelPMin.setText("P_min:")
        self.labelPMinVal.setText("20")
        self.labelPMinVal.setFont(QtGui.QFont("Arial", 48, QtGui.QFont.Bold))
        self.labelAlarmPMax.setFont(QtGui.QFont("Arial", 24, QtGui.QFont.Bold))
        self.labelAlarmPMin.setFont(QtGui.QFont("Arial", 24, QtGui.QFont.Bold))

        self.labelRespRateVal.setFont(QtGui.QFont("Arial", 48, QtGui.QFont.Bold))
        self.labelTidalVolVal.setFont(QtGui.QFont("Arial", 48, QtGui.QFont.Bold))
        self.labelTidalVolVal.setAlignment(QtCore.Qt.AlignRight)
        self.labelMinuteVolVal.setFont(QtGui.QFont("Arial", 48, QtGui.QFont.Bold))

        self.maxX = 100
        self.x = list(range(self.maxX))
        self.y = [randint(0,100) for _ in range(100)]
        self.yRealPressure = [randint(0,100) for _ in range(100)]
        self.counter = 0
        self.fcounter = 0
        self.vcounter = 0
        self.maxPressure = 0.0
        self.minPressure = 100.0
        self.avPressure = 0.0
        
        self.alarmMaxPressure = 40.0
        self.alarmMinPressure = -5.0
        
        self.graphWidgetPressure.setBackground('w')
        #self.graphWidget.setYRange(-10 , 45, padding=0)
        styles = {'color':'b', 'font-size':'20px'}
        self.graphWidgetPressure.setLabel("left","Pressure (cmH2O)", **styles)

        pen = pg.mkPen(color=(255,0,0))
        self.data_line = self.graphWidgetPressure.plot(self.x, self.y, pen=pen, fillLevel=0.0, brush=(255,0,0,255))

        self.x2 = list(range(100))
        self.y2 = [randint(0,100) for _ in range(100)]
        
        self.graphWidgetFlow.setBackground('w')
        self.graphWidgetVol.setBackground('w')

        #self.graphWidgetFlow.setYRange(-300 , 300, padding=0)
        self.graphWidgetFlow.setLabel("left","Flow (ml/s)", **styles)
        self.graphWidgetVol.setLabel("left","Volume (ml)", **styles)

        #pen = pg.mkPen(color=(255,0,0))
        pen2 = pg.mkPen(color=(0,0,255))
        self.data_line_flow = self.graphWidgetFlow.plot(self.x2, self.y2, pen=pen2, fillLevel=0.0, brush=(0,0,255,255))
        self.data_line_vol = self.graphWidgetVol.plot(self.x2, self.y2, pen=pen2, fillLevel=0.0, brush=(0,0,255,255))

        widget = QWidget()
        widget.setLayout(layout)
        self.setCentralWidget(widget)
        self.resize(800,480)
        # self.showFullScreen()

        self.timer = QtCore.QTimer()
        self.timer.setInterval(50)
        self.timer.timeout.connect(self.update_plot_data)
        self.timer.timeout.connect(self.update_flow_plot_data)
        self.timer.timeout.connect(self.update_vol_plot_data)
        self.timer.start()
예제 #2
0
    def _init_ui(self):
        namesBox = gui.vBox(self.controlArea, "Names")

        hbox = gui.hBox(namesBox, margin=0, spacing=0)
        gui.lineEdit(hbox,
                     self,
                     "attr1",
                     "Variable X: ",
                     controlWidth=80,
                     orientation=Qt.Horizontal,
                     callback=self._attr_name_changed)
        gui.separator(hbox, 21)
        hbox = gui.hBox(namesBox, margin=0, spacing=0)
        attr2 = gui.lineEdit(hbox,
                             self,
                             "attr2",
                             "Variable Y: ",
                             controlWidth=80,
                             orientation=Qt.Horizontal,
                             callback=self._attr_name_changed)
        gui.separator(hbox)
        gui.checkBox(hbox,
                     self,
                     "hasAttr2",
                     '',
                     disables=attr2,
                     labelWidth=0,
                     callback=self.set_dimensions)
        gui.separator(namesBox)

        gui.widgetLabel(namesBox, "Labels")
        self.classValuesView = listView = QListView(
            selectionMode=QListView.SingleSelection,
            sizePolicy=QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Maximum))
        listView.setModel(self.class_model)
        itemmodels.select_row(listView, 0)
        namesBox.layout().addWidget(listView)

        self.addClassLabel = QAction("+",
                                     self,
                                     toolTip="Add new class label",
                                     triggered=self.add_new_class_label)

        self.removeClassLabel = QAction(
            unicodedata.lookup("MINUS SIGN"),
            self,
            toolTip="Remove selected class label",
            triggered=self.remove_selected_class_label)

        actionsWidget = itemmodels.ModelActionsWidget(
            [self.addClassLabel, self.removeClassLabel], self)
        actionsWidget.layout().addStretch(10)
        actionsWidget.layout().setSpacing(1)
        namesBox.layout().addWidget(actionsWidget)

        tBox = gui.vBox(self.controlArea, "Tools", addSpace=True)
        buttonBox = gui.hBox(tBox)
        toolsBox = gui.widgetBox(buttonBox, orientation=QGridLayout())

        self.toolActions = QActionGroup(self)
        self.toolActions.setExclusive(True)
        self.toolButtons = []

        for i, (name, tooltip, tool, icon) in enumerate(self.TOOLS):
            action = QAction(
                name,
                self,
                toolTip=tooltip,
                checkable=tool.checkable,
                icon=QIcon(icon),
            )
            action.triggered.connect(partial(self.set_current_tool, tool))

            button = QToolButton(iconSize=QSize(24, 24),
                                 toolButtonStyle=Qt.ToolButtonTextUnderIcon,
                                 sizePolicy=QSizePolicy(
                                     QSizePolicy.MinimumExpanding,
                                     QSizePolicy.Fixed))
            button.setDefaultAction(action)
            self.toolButtons.append((button, tool))

            toolsBox.layout().addWidget(button, i / 3, i % 3)
            self.toolActions.addAction(action)

        for column in range(3):
            toolsBox.layout().setColumnMinimumWidth(column, 10)
            toolsBox.layout().setColumnStretch(column, 1)

        undo = self.undo_stack.createUndoAction(self)
        redo = self.undo_stack.createRedoAction(self)

        undo.setShortcut(QKeySequence.Undo)
        redo.setShortcut(QKeySequence.Redo)

        self.addActions([undo, redo])
        self.undo_stack.indexChanged.connect(lambda _: self.invalidate())

        gui.separator(tBox)
        indBox = gui.indentedBox(tBox, sep=8)
        form = QFormLayout(formAlignment=Qt.AlignLeft,
                           labelAlignment=Qt.AlignLeft,
                           fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow)
        indBox.layout().addLayout(form)
        slider = gui.hSlider(indBox,
                             self,
                             "brushRadius",
                             minValue=1,
                             maxValue=100,
                             createLabel=False)
        form.addRow("Radius:", slider)

        slider = gui.hSlider(indBox,
                             self,
                             "density",
                             None,
                             minValue=1,
                             maxValue=100,
                             createLabel=False)

        form.addRow("Intensity:", slider)
        self.btResetToInput = gui.button(tBox, self, "Reset to Input Data",
                                         self.reset_to_input)
        self.btResetToInput.setDisabled(True)

        gui.rubber(self.controlArea)
        gui.auto_commit(self.left_side, self, "autocommit", "Send")

        # main area GUI
        viewbox = PaintViewBox(enableMouse=False)
        self.plotview = pg.PlotWidget(background="w", viewBox=viewbox)
        self.plotview.sizeHint = lambda: QSize(
            200, 100)  # Minimum size for 1-d painting
        self.plot = self.plotview.getPlotItem()

        axis_color = self.palette().color(QPalette.Text)
        axis_pen = QPen(axis_color)

        tickfont = QFont(self.font())
        tickfont.setPixelSize(max(int(tickfont.pixelSize() * 2 // 3), 11))

        axis = self.plot.getAxis("bottom")
        axis.setLabel(self.attr1)
        axis.setPen(axis_pen)
        axis.setTickFont(tickfont)

        axis = self.plot.getAxis("left")
        axis.setLabel(self.attr2)
        axis.setPen(axis_pen)
        axis.setTickFont(tickfont)
        if not self.hasAttr2:
            self.plot.hideAxis('left')

        self.plot.hideButtons()
        self.plot.setXRange(0, 1, padding=0.01)

        self.mainArea.layout().addWidget(self.plotview)

        # enable brush tool
        self.toolActions.actions()[0].setChecked(True)
        self.set_current_tool(self.TOOLS[0][2])

        self.set_dimensions()
예제 #3
0
    def show(self, filename, name, refresh=False):
        """
        plots:
            (N,)      float, int          --> line plot
            (N, M<4)  float, int          --> line plots
            (N, M>4)  float, complex, int --> 2d image
            (N, M>4)  complex             --> 2d images (abs, angle, real, imag)
            (N, M, L) float, complex, int --> 2d images (real) with slider

        scatter:
            (N, M, 2) float, int          --> N overlayed scatter plots
        """
        if len(name.split(' ')) == 2:
            name, im_type = name.split(' ')
        else:
            im_type = None

        # make plot
        f = h5py.File(filename, 'r')
        shape = f[name].shape
        title = name + ' ' + str(shape) + ' ' + str(f[name].dtype)

        if self.name == name:
            refresh = True
        elif (self.name is not None) and (self.name != name):
            self.close()

        #if not refresh :
        #    self.close()

        if shape == ():
            if refresh:
                self.plotW.setText('<b>' + name + '</b>: ' + str(f[name][()]))
            else:
                self.plotW = self.text_label = QLabel(self)
                self.plotW.setText('<b>' + title + '</b>: ' + str(f[name][()]))

        elif len(shape) == 1:
            if refresh:
                self.plotW.clear()
            else:
                self.plotW = pg.PlotWidget(title=title)

            self.plotW.plot(f[name][()], pen=(255, 150, 150))

        elif (len(shape) == 1) or (len(shape) == 2 and shape[0] < 5):
            if len(shape) == 1:
                I = [()]
            else:
                I = range(shape[0])
                np.random.seed(3)

            pen = (255, 150, 150)

            if refresh:
                self.plotW.clear()
            else:
                self.plotW = pg.PlotWidget(title=title)

            for i, ii in enumerate(I):
                if ii > 0:
                    pen = tuple(np.random.randint(0, 255, 3))

                self.plotW.plot(f[name][i], pen=pen)
                print('pen', pen)

        elif (len(shape) == 2 or len(shape) == 3) and im_type == 'scatter':
            if refresh:
                self.plotW.clear()
            else:
                self.plotW = pg.PlotWidget(title=title)

            self.ss = []
            # scatter plot
            ##############
            if len(shape) == 2:
                X = f[name][:, 0]
                Y = f[name][:, 1]
                pen = pg.mkPen((255, 150, 150))
                brush = pg.mkBrush(255, 255, 255, 120)

                self.s1 = pg.ScatterPlotItem(size=5, pen=pen, brush=brush)
                spots = [{
                    'pos': [X[n], Y[n]],
                    'data': n
                } for n in range(len(X))]
                self.s1.addPoints(spots)
                self.ss.append(self.s1)
            else:
                np.random.seed(3)
                for n in range(f[name].shape[0]):
                    X = f[name][n, :, 0]
                    Y = f[name][n, :, 1]

                    if n == 0:
                        pen = pg.mkPen((255, 150, 150))
                        brush = pg.mkBrush(255, 255, 255, 120)
                    else:
                        pen = pg.mkPen(tuple(np.random.randint(0, 255, 3)))
                        brush = pg.mkBrush(tuple(np.random.randint(0, 255, 4)))

                    self.ss.append(
                        pg.ScatterPlotItem(size=5, pen=pen, brush=brush))
                    spots = [{
                        'pos': [X[n], Y[n]],
                        'data': n
                    } for n in range(len(X))]
                    self.ss[-1].addPoints(spots)

            for s1 in self.ss:
                self.plotW.addItem(s1)

        elif len(shape) == 2 and shape[1] < 4:
            pens = [(255, 150, 150), (150, 255, 150), (150, 150, 255)]
            if refresh:
                self.plotW.clear()
                for i in range(shape[1]):
                    self.plotW.setData(i, f[name][:, i])
            else:
                self.plotW = pg.PlotWidget(title=name +
                                           ' [0, 1, 2] are [r, g, b]')
                for i in range(shape[1]):
                    self.plotW.plot(f[name][:, i], pen=pens[i])

        elif len(shape) == 2:
            if refresh:
                self.plotW.setImage(f[name][()].astype(np.float).real.T,
                                    autoRange=False,
                                    autoLevels=False,
                                    autoHistogramRange=False)
            else:
                if 'complex' in f[name].dtype.name:
                    title = title + ' (abs, angle, real, imag)'
                else:
                    title = title

                frame_plt = pg.PlotItem(title=title)
                self.plotW = pg.ImageView(view=frame_plt)
                self.plotW.ui.menuBtn.hide()
                self.plotW.ui.roiBtn.hide()
                if 'complex' in f[name].dtype.name:
                    im = f[name][()].T.astype(np.float)
                    self.plotW.setImage(
                        np.array([np.abs(im),
                                  np.angle(im), im.real, im.imag]))
                else:
                    self.plotW.setImage(f[name][()].astype(np.float).T)

        elif len(shape) == 3:
            if refresh:
                self.replot_frame()
            else:
                # show the middle frame
                frame_plt = pg.PlotItem(title=title)
                self.plotW = pg.ImageView(view=frame_plt)
                self.plotW.ui.menuBtn.hide()
                self.plotW.ui.roiBtn.hide()

                i = f[name].shape[0] // 2

                # set min / max to the 10 and 90'th percentile
                im = f[name][i]
                minl = np.percentile(im, 10.)
                maxl = np.percentile(im, 90.)

                self.plotW.setImage(im.astype(np.float).real.T,
                                    levels=(minl, maxl))

                # set min max of histogram widget to minl and maxl
                hw = self.plotW.getHistogramWidget()
                hw.item.setHistogramRange(minl, maxl)

                # add a little 1d plot with a vline
                self.plotW2 = pg.PlotWidget(title='index')
                self.plotW2.plot(np.arange(f[name].shape[0]),
                                 pen=(255, 150, 150))
                self.vline = self.plotW2.addLine(
                    x=i, movable=True, bounds=[0, f[name].shape[0] - 1])
                self.plotW2.setMaximumSize(10000000, 100)

                self.vline.sigPositionChanged.connect(self.replot_frame)

        f.close()

        # add to layout
        if refresh is False:
            self.layout.addWidget(self.plotW, stretch=1)

        if self.plotW2 is not None:
            self.layout.addWidget(self.plotW2, stretch=0)

        # remember the last file and dataset for updating
        self.name = name
        self.filename = filename
예제 #4
0
    def __init__(self, device=None):
        QWidget.__init__(self)
        self.p = device  # connection to the device hardware
        self.traceCols = utils.makeTraceColors()
        try:
            self.p.configure_trigger(0, 'A1', 0)
            self.p.select_range('A1', 4.0)
            self.p.set_sine(0)
        except:
            pass

        self.pwin = pg.PlotWidget()  # pyqtgraph window
        self.pwin.showGrid(x=True, y=True)  # with grid
        ax = self.pwin.getAxis('bottom')
        ax.setLabel(self.tr('Time (mS)'))
        ax = self.pwin.getAxis('left')
        ax.setLabel(self.tr('Voltage'))
        self.pwin.disableAutoRange()
        self.pwin.setXRange(0, self.TMAX)
        self.pwin.setYRange(self.VMIN, self.VMAX)
        self.pwin.hideButtons()  # Do not show the 'A' button of pg

        for ch in range(self.MAXCHAN):  # initialize the pg trace widgets
            self.traceWidget[ch] = self.pwin.plot([0, 0], [0, 0],
                                                  pen=self.traceCols[ch])

        right = QVBoxLayout()  # right side vertical layout
        right.setAlignment(Qt.AlignTop)
        right.setSpacing(self.RPGAP)

        H = QHBoxLayout()
        l = QLabel(text=self.tr('WG'))
        l.setMaximumWidth(25)
        H.addWidget(l)
        self.AWGslider = utils.slider(self.AWGmin, self.AWGmax, self.AWGval,
                                      100, self.awg_slider)
        H.addWidget(self.AWGslider)
        self.AWGtext = utils.lineEdit(100, self.AWGval, 6, self.awg_text)
        H.addWidget(self.AWGtext)
        l = QLabel(text=self.tr('Hz'))
        l.setMaximumWidth(20)
        H.addWidget(l)
        right.addLayout(H)

        H = QHBoxLayout()
        l = QLabel(text=self.tr('Timebase'))
        l.setMaximumWidth(60)
        H.addWidget(l)
        self.TBslider = utils.slider(0,
                                     len(self.tbvals) - 1, self.TBval, 150,
                                     self.set_timebase)
        H.addWidget(self.TBslider)
        l = QLabel(text=self.tr('mS/div'))
        l.setMaximumWidth(60)
        H.addWidget(l)
        right.addLayout(H)

        self.enable = QCheckBox(self.tr('Enable Measurements'))
        right.addWidget(self.enable)
        self.enable.stateChanged.connect(self.control)

        self.SaveButton = QPushButton(self.tr("Save Data"))
        self.SaveButton.clicked.connect(self.save_data)
        right.addWidget(self.SaveButton)

        H = QHBoxLayout()
        self.Res = QLabel(text='')
        #Res.setMaximumWidth(60)
        H.addWidget(self.Res)
        right.addLayout(H)

        #------------------------end of right panel ----------------

        top = QHBoxLayout()
        top.addWidget(self.pwin)
        top.addLayout(right)

        full = QVBoxLayout()
        full.addLayout(top)
        self.msgwin = QLabel(text=self.tr('messages'))
        full.addWidget(self.msgwin)

        self.setLayout(full)

        self.timer = QTimer()
        self.timer.timeout.connect(self.update)
        self.timer.start(self.TIMER)
    def init_ui(self):
        '''
            Create a list of currencies directly from the URL
        :return: String representation of the CSV file
        '''
        self.csvFile = Unzip().download_unzip()
        '''
            Convert CSV file into an Array
        '''
        self.csvFile = self.csvFile.split("\n")
        '''
            Select the first element of the CSV file. Split the currency for combobox
        '''
        self.currencies = self.csvFile[0][5:-1].split(",")
        '''
            Remove the first Element of the CSV file.
            i.e. All the currencies header. We no longer need those
        '''
        self.csvFile.pop(0)

        # print(self.csvFile[0].split(","))
        '''
            Set default date to current date.
        '''
        self.defaultDate = self.csvFile[0].split(",")[0]

        # print("Default Date: " + self.defaultDate)

        self.lineChart = []
        '''
            Create the empty dictionary for all the content in CSV file except currencies.
        '''
        self.dict = {}
        '''
            Populate the dictionary.
            Key: Date
            Value: List of all the exchange rate to that date 
        '''
        for arrays in self.csvFile:
            '''
                Get array of the whole CSV file and Split in chunks of array
                Each Element contains different: (date and exchange rate to that date) 
            '''
            arrays = arrays.split(",")
            '''
                Removes the empty last element.
            '''
            arrays.pop()
            '''
                Removes and return the date and store it as the key in the dictionary
                Rest of the list is store as the value to that key
            '''
            self.dict[arrays.pop(0)] = arrays

        # Add it to the Combo Box

        # Create Calender Widgets

        # Set the grid layout properly

        # -----------------------------------------------#
        ''' Grid Layout for the Application '''
        layout = QGridLayout()

        # Horizontal layout for Label and comboboxes
        hBox1 = QHBoxLayout()  # From Currency layout
        hBox2 = QHBoxLayout()  # To Currency layout
        hBox3 = QHBoxLayout()  # Amount to Convert (SpinBox) layout
        hBox4 = QHBoxLayout()  # Result layout

        # Add Calender to the Horizontal Layouts
        hBox5 = QHBoxLayout()  # Calender 1 layout
        hBox6 = QHBoxLayout()  # Calender 2 layout

        # Label for the ComboBox 1
        self.fromCurrencyLabel = QLabel("From Currency")
        self.fromCurrency = QComboBox()  # First ComboBox
        self.fromCurrency.setFixedWidth(150)  # Set the width to 150

        self.toCurrencyLabel = QLabel("To Currency")
        self.toCurrency = QComboBox()
        self.toCurrency.setFixedWidth(150)
        '''
            Add the stretch to the Horizontal layout, So that the Label and the ComboBox doesn't separate
            from each other
        '''
        hBox1.addStretch()
        hBox1.addWidget(self.fromCurrencyLabel)
        hBox1.addWidget(self.fromCurrency)

        hBox2.addStretch()
        hBox2.addWidget(self.toCurrencyLabel)
        hBox2.addWidget(self.toCurrency)
        '''
            Add the list of currency to the combobox
        '''
        self.fromCurrency.addItems(self.currencies)
        self.toCurrency.addItems(self.currencies)
        '''
            Set default currency to AUD
        '''
        self.fromCurrency.setCurrentText("AUD")
        self.toCurrency.setCurrentText("AUD")

        self.amtToConvertLabel = QLabel("Amount to Convert: ")
        self.amtToConvert = QDoubleSpinBox()
        self.amtToConvert.setFixedWidth(180)
        self.amtToConvert.setValue(1)
        self.amtToConvert.setMaximum(10000)

        hBox3.addStretch()
        hBox3.addWidget(self.amtToConvertLabel)
        hBox3.addWidget(self.amtToConvert)

        self.resultLabel = QLabel(
            "Result of conversion based on most recent rates: ")
        self.result = QLabel("")

        hBox4.addWidget(self.resultLabel)
        hBox4.addWidget(self.result)
        '''
            Create the instance of the Calender
        '''
        self.from_date = QCalendarWidget()
        '''
            Set Default date of the first calender to 3 weeks behind
        '''
        self.from_date.setSelectedDate(
            self.from_date.selectedDate().toPyDate() + timedelta(-21))
        '''
            Set Maximum Date to current date
        '''
        self.from_date.setMaximumDate(date.today())
        hBox5.addWidget(self.from_date)

        self.to_date = QCalendarWidget()
        self.to_date.setMaximumDate(date.today())
        hBox6.addWidget(self.to_date)

        self.plots = pg.PlotWidget()
        self.plots.plotItem.setLabel("left", "Rates")
        self.plots.plotItem.setLabel("bottom", "Days")
        self.plots.plotItem.showGrid(True, True)

        self.p1 = None
        self.p2 = None

        self.legend = self.plots.plotItem.addLegend()
        '''
            Add all the widgets to the layouts
        '''
        layout.addLayout(hBox1, 0, 0)
        layout.addLayout(hBox2, 0, 1)
        layout.addLayout(hBox3, 1, 0)
        layout.addLayout(hBox4, 1, 1)
        layout.addLayout(hBox5, 2, 0)
        layout.addLayout(hBox6, 2, 1)
        layout.addWidget(self.plots, 3, 0, 3, 0)
        '''
            Add the eventHandler to the Calender, ComboBox and SpinBox
        '''
        self.from_date.clicked.connect(self.dateChanged)
        self.to_date.clicked.connect(self.dateChanged)
        self.fromCurrency.currentTextChanged.connect(self.comboBoxChange)
        self.toCurrency.currentTextChanged.connect(self.comboBoxChange)
        self.amtToConvert.valueChanged.connect(self.comboBoxChange)
        '''
            Add the layout to the window
        '''
        self.setLayout(layout)
        '''
            Set the Window Title
        '''
        self.setWindowTitle(
            "Currency Converter - Assignment 1 - Manik Shakya - 2869290")
        self.show()
예제 #6
0
        temp_item.setBackground(QtGui.QColor(150, 250, 150))
        ground_table.setItem(item_clicked.row(), item_clicked.column(),
                             temp_item)
        ground_active_plots[item_clicked.row()] = True
        ground_curves[item_clicked.row()] = (ground_plot_1.plot(ground_x[n],
                                                                ground_y[n],
                                                                pen=(0, 0,
                                                                     255)))


clear_plot = QtGui.QPushButton("Clear plot")
ground_layout.addWidget(clear_plot, 8, 20)
clear_plot.clicked.connect(lambda: reset_plot())

pg.setConfigOption('background', 'w')
ground_plot_1 = pg.PlotWidget(title='Dynamic Plotting with PyQtGraph')
# ground_plot_1.enableAutoRange(axis='x')
ground_layout.addWidget(ground_plot_1, zr + 0, zc + 11, 20, 7)


def reset_plot():
    global ground_x, ground_y, BUFFER_SIZE, ground_curves
    #ground_plot_1.clear()
    ground_y = [[]] * parser.num_items
    ground_x = [[]] * parser.num_items
    #ground_y = [[0]*BUFFER_SIZE]*parser.num_items
    #ground_x = [[0]*BUFFER_SIZE]*parser.num_items


BUFFER_SIZE = 100
#ground_y = [[0]*BUFFER_SIZE]*parser.num_items
예제 #7
0
win = QtGui.QMainWindow()
win.setWindowTitle('Operation Room #2')

#controles
pause_btn = QtGui.QPushButton()
pause_btn.setText("Pause")
time_lbl = QtGui.QLabel()
time_lbl.setText("Time scale: ")
time_lbl.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignRight)
cb = QtGui.QComboBox()
cb.addItems(timeScaleOptions.keys())
load_btn = QtGui.QPushButton()
load_btn.setText("Load CSV")

#graficas
pl1 = pg.PlotWidget(title = "Heart Rate (BPM)", axisItems={'bottom': TimeAxisItem(orientation='bottom')})
pl1.showGrid(x=True, y=True)
pl1.setMouseEnabled(y=False)
pl2 = pg.PlotWidget(title = "O2 Saturation (%)", axisItems={'bottom': TimeAxisItem(orientation='bottom')})
pl2.showGrid(x=True, y=True)
pl2.setMouseEnabled(y=False)
pl3 = pg.PlotWidget(title = "Blood Pressure (mmHg)", colspan = 2, axisItems={'bottom': TimeAxisItem(orientation='bottom')})
pl3.showGrid(x=True, y=True)
pl3.setMouseEnabled(y=False)
legend = pl3.addLegend()
pl3.plot(name="Systolic Arterial BP", pen = "m")
pl3.plot(name="Mean Aterial BP", pen = "r")
pl3.plot(name="Diasolic Arterial BP", pen = "g")

#grafica scrolleo
plScroll = pg.PlotWidget(title = "Time Selection", axisItems={'bottom': TimeAxisItem(orientation='bottom')})
    def handleEvent(self, evt_src, evt_type, evt_val):
        try:
            data = evt_val.rvalue
            self.setImage(data)
        except Exception as e:
            self.warning('Exception in handleEvent: %s', e)



if __name__ == "__main__":
    import pyqtgraph as pg

    app = TaurusApplication()

    plot_widget = pg.PlotWidget()
    plot_item = plot_widget.getPlotItem()

    image_item = TaurusImageItem()

    #Add taurus 2D image data
    image_item.setModel('eval:randint(0,256,(16,16))')

    #add TarusImageItem to a PlotItem
    plot_item.addItem(image_item)

    #show or hide axis from the plot
    plot_item.showAxis('left', show=True)
    plot_item.showAxis('bottom', show=True)

    plot_widget.show()
예제 #9
0
    def set_window(self, parent=None):
        super(TraceAnalyzer, self).__init__(parent=parent)
        self.win = pg.GraphicsWindow(title="TraceAnalyzer")
        layout = pg.QtGui.QGridLayout()
        layout.setSpacing(10)
        self.win.setLayout(layout)
        self.win.resize(1280, 800)

        self.buttons = pg.QtGui.QGridLayout()
        self.b3 = pg.QtGui.QPushButton("Get Protocol Directory")
        self.buttons.addWidget(self.b3)
        self.b3.clicked.connect(self.getProtocolDir)

        self.notch_button = pg.QtGui.QDoubleSpinBox()
        self.notch_button.setValue(60.)
        self.notch_button.setMinimum(10.)
        self.notch_button.setMaximum(5000.)
        self.buttons.addWidget(self.notch_button)
        self.notch_button.valueChanged.connect(self.update_traces)
        self.notch_check = pg.QtGui.QCheckBox("Notch")
        self.notch_check.stateChanged.connect(self.update_traces)
        self.buttons.addWidget(self.notch_check)

        self.lpf_button = pg.QtGui.QDoubleSpinBox()
        self.lpf_button.setMinimum(200.)
        self.lpf_button.setMaximum(10000.)
        self.lpf_button.setValue(3000.)
        self.buttons.addWidget(self.lpf_button)
        self.lpf_button.valueChanged.connect(self.update_traces)
        self.buttons.addWidget(self.lpf_button)
        self.lpf_check = pg.QtGui.QCheckBox("LPF")
        self.lpf_check.setChecked(True)
        self.lpf_check.stateChanged.connect(self.update_traces)
        self.buttons.addWidget(self.lpf_check)

        self.cb_button = pg.QtGui.QPushButton("Clements-Bekkers")
        self.buttons.addWidget(self.cb_button)
        self.cb_button.clicked.connect(self.CB)

        self.aj_button = pg.QtGui.QPushButton("AJ")
        self.buttons.addWidget(self.aj_button)
        self.aj_button.clicked.connect(self.AJ)

        self.minis_risetau = pg.QtGui.QDoubleSpinBox()
        self.minis_risetau.setRange(0.1, 10.)
        self.minis_risetau.setValue(0.2)
        self.minis_risetau.setDecimals(2)
        self.minis_risetau.setSingleStep(0.1)
        self.minis_risetau.setSuffix(' ms')
        self.buttons.addWidget(self.minis_risetau)
        self.minis_risetau.valueChanged.connect(self.update_traces)

        self.minis_falltau = pg.QtGui.QDoubleSpinBox()
        self.minis_falltau.setRange(0.2, 20.)
        self.minis_falltau.setSingleStep(0.1)
        self.minis_falltau.setSuffix(' ms')
        self.minis_falltau.setValue(1.0)
        self.minis_falltau.setDecimals(2)
        self.buttons.addWidget(self.minis_falltau)
        self.minis_falltau.valueChanged.connect(self.update_traces)

        self.minis_thresh = pg.QtGui.QDoubleSpinBox()
        self.minis_thresh.setRange(1.0, 12.)
        self.minis_thresh.setValue(3.5)
        self.minis_thresh.setDecimals(2)
        self.minis_thresh.setSingleStep(0.1)
        self.minis_thresh.setSuffix(' n SD')
        self.buttons.addWidget(self.minis_thresh)
        self.minis_thresh.valueChanged.connect(self.update_traces)

        self.minis_sign = pg.QtGui.QComboBox()
        self.minis_sign.addItems(['-', '+'])
        self.buttons.addWidget(self.minis_sign)
        self.minis_sign.currentIndexChanged.connect(self.update_traces)

        spacerItem1 = pg.QtGui.QSpacerItem(0, 100,
                                           pg.QtGui.QSizePolicy.Expanding,
                                           pg.QtGui.QSizePolicy.Minimum)
        self.buttons.addItem(spacerItem1)

        self.b2 = pg.QtGui.QPushButton("Quit")
        self.buttons.addWidget(self.b2)
        self.b2.clicked.connect(self.quit)

        self.w1 = Slider(0, 250, scalar=1., parent=parent)
        self.w1.slider.valueChanged.connect(self.update_traces)

        # spacerItem = pg.QtGui.QSpacerItem(0, 10, pg.QtGui.QSizePolicy.Expanding, pg.QtGui.QSizePolicy.Minimum)
        # self.buttons.addItem(spacerItem)

        self.dataplot = pg.PlotWidget()
        self.dataplot2 = pg.PlotWidget()
        layout.addLayout(self.buttons, 0, 0, 7, 1)
        layout.addWidget(self.dataplot, 0, 1, 1, 6)
        layout.addWidget(self.dataplot2, 6, 1, 4, 6)
        layout.addWidget(self.w1, 11, 1, 1, 6)
        layout.setColumnStretch(0, 1)  # reduce width of LHS column of buttons
        layout.setColumnStretch(1, 7)  # and stretch out the data dispaly
예제 #10
0
data_raw = in_fid.read()
# Преобразуем к установленному формату
if len(data_raw) % 2 == 0:
    data_temp = np.fromstring(data_raw, dtype=np.int16)
else:
    data_temp = np.fromstring(data_raw[0:-1], dtype=np.int16)
data = []
for ind in range(0, len(data_temp), step_accel):
    data.append(data_temp[ind])
del data_temp
# Медианная фильтрация для устранения сбоев
data = sp_sig.medfilt(data, 5)

x_axis = np.linspace(0, len(data) / freq_d, len(data))
# Строим график
graph_accel = pg.PlotWidget(title='График ускорения')
pen = pg.mkPen(color='b')
graph_accel.plot(y=data, x=x_axis, pen=pen)
graph_accel.showGrid(x=False, y=True)
region = pg.LinearRegionItem()
region.setZValue(10)
region.setRegion([len(data) / 400, len(data) * 2 / 400])
graph_accel.addItem(region, ignoreBounds=True)

for i in range(len(modes)):
    a = pg.ArrowItem()
    a.setPos(modes[i][0] / freq_d, data[modes[i][0]])
    text = pg.TextItem(html='<div style="text-align: center">' +
                       str(modes[i][1]) + '</div>',
                       border='w',
                       fill=(0, 0, 255, 100))
예제 #11
0
    def setupUi(self, nmonAnalysis_Form):
        nmonAnalysis_Form.setObjectName("nmonAnalysis_Form")
        nmonAnalysis_Form.resize(969, 516)
        self.verticalLayout = QtWidgets.QVBoxLayout(nmonAnalysis_Form)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label = QtWidgets.QLabel(nmonAnalysis_Form)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.horizontalLayout.addWidget(self.label)
        self.ip_lineEdit = QtWidgets.QLineEdit(nmonAnalysis_Form)
        self.ip_lineEdit.setReadOnly(True)
        self.ip_lineEdit.setObjectName("ip_lineEdit")
        self.horizontalLayout.addWidget(self.ip_lineEdit)
        self.label_2 = QtWidgets.QLabel(nmonAnalysis_Form)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.horizontalLayout.addWidget(self.label_2)
        self.fileName_lineEdit = QtWidgets.QLineEdit(nmonAnalysis_Form)
        self.fileName_lineEdit.setReadOnly(True)
        self.fileName_lineEdit.setObjectName("fileName_lineEdit")
        self.horizontalLayout.addWidget(self.fileName_lineEdit)
        self.label_3 = QtWidgets.QLabel(nmonAnalysis_Form)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.horizontalLayout.addWidget(self.label_3)
        self.simpleNum_label = QtWidgets.QLabel(nmonAnalysis_Form)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.simpleNum_label.setFont(font)
        self.simpleNum_label.setText("")
        self.simpleNum_label.setObjectName("simpleNum_label")
        self.horizontalLayout.addWidget(self.simpleNum_label)
        self.analysis_pushButton = QtWidgets.QPushButton(nmonAnalysis_Form)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.analysis_pushButton.setFont(font)
        self.analysis_pushButton.setObjectName("analysis_pushButton")
        self.horizontalLayout.addWidget(self.analysis_pushButton)
        self.horizontalLayout.setStretch(0, 1)
        self.horizontalLayout.setStretch(1, 3)
        self.horizontalLayout.setStretch(2, 1)
        self.horizontalLayout.setStretch(3, 3)
        self.horizontalLayout.setStretch(5, 3)
        self.horizontalLayout.setStretch(6, 1)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout()
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.groupBox = QtWidgets.QGroupBox(nmonAnalysis_Form)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.groupBox.setFont(font)
        self.groupBox.setObjectName("groupBox")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.groupBox)
        self.verticalLayout_3.setContentsMargins(5, 5, 5, 5)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.textBrowser = QtWidgets.QTextBrowser(self.groupBox)
        self.textBrowser.setObjectName("textBrowser")
        self.verticalLayout_3.addWidget(self.textBrowser)
        self.gridLayout_3 = QtWidgets.QGridLayout()
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.star_spinBox = QtWidgets.QSpinBox(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.star_spinBox.setFont(font)
        self.star_spinBox.setObjectName("star_spinBox")
        self.gridLayout_3.addWidget(self.star_spinBox, 0, 1, 1, 1)
        self.disk_label = QtWidgets.QLabel(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.disk_label.setFont(font)
        self.disk_label.setText("")
        self.disk_label.setObjectName("disk_label")
        self.gridLayout_3.addWidget(self.disk_label, 6, 1, 1, 1)
        self.label_6 = QtWidgets.QLabel(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.label_6.setFont(font)
        self.label_6.setObjectName("label_6")
        self.gridLayout_3.addWidget(self.label_6, 1, 0, 1, 1)
        self.label_13 = QtWidgets.QLabel(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.label_13.setFont(font)
        self.label_13.setObjectName("label_13")
        self.gridLayout_3.addWidget(self.label_13, 6, 0, 1, 1)
        self.label_16 = QtWidgets.QLabel(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.label_16.setFont(font)
        self.label_16.setObjectName("label_16")
        self.gridLayout_3.addWidget(self.label_16, 7, 0, 1, 1)
        self.cpu_label = QtWidgets.QLabel(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.cpu_label.setFont(font)
        self.cpu_label.setText("")
        self.cpu_label.setObjectName("cpu_label")
        self.gridLayout_3.addWidget(self.cpu_label, 3, 1, 1, 1)
        self.label_5 = QtWidgets.QLabel(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.gridLayout_3.addWidget(self.label_5, 0, 0, 1, 1)
        self.IOPS_label = QtWidgets.QLabel(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.IOPS_label.setFont(font)
        self.IOPS_label.setText("")
        self.IOPS_label.setObjectName("IOPS_label")
        self.gridLayout_3.addWidget(self.IOPS_label, 7, 1, 1, 1)
        self.men_label = QtWidgets.QLabel(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.men_label.setFont(font)
        self.men_label.setText("")
        self.men_label.setObjectName("men_label")
        self.gridLayout_3.addWidget(self.men_label, 4, 1, 1, 1)
        self.label_11 = QtWidgets.QLabel(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.label_11.setFont(font)
        self.label_11.setObjectName("label_11")
        self.gridLayout_3.addWidget(self.label_11, 5, 0, 1, 1)
        self.net_label = QtWidgets.QLabel(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.net_label.setFont(font)
        self.net_label.setText("")
        self.net_label.setObjectName("net_label")
        self.gridLayout_3.addWidget(self.net_label, 5, 1, 1, 1)
        self.label_7 = QtWidgets.QLabel(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.label_7.setFont(font)
        self.label_7.setObjectName("label_7")
        self.gridLayout_3.addWidget(self.label_7, 3, 0, 1, 1)
        self.end_spinBox = QtWidgets.QSpinBox(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.end_spinBox.setFont(font)
        self.end_spinBox.setObjectName("end_spinBox")
        self.gridLayout_3.addWidget(self.end_spinBox, 1, 1, 1, 1)
        self.label_9 = QtWidgets.QLabel(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.label_9.setFont(font)
        self.label_9.setObjectName("label_9")
        self.gridLayout_3.addWidget(self.label_9, 4, 0, 1, 1)
        self.moveStart_pushButton = QtWidgets.QPushButton(self.groupBox)
        self.moveStart_pushButton.setObjectName("moveStart_pushButton")
        self.gridLayout_3.addWidget(self.moveStart_pushButton, 0, 2, 1, 1)
        self.moveEnd_pushButton = QtWidgets.QPushButton(self.groupBox)
        self.moveEnd_pushButton.setObjectName("moveEnd_pushButton")
        self.gridLayout_3.addWidget(self.moveEnd_pushButton, 1, 2, 1, 1)
        self.reset_pushButton = QtWidgets.QPushButton(self.groupBox)
        self.reset_pushButton.setObjectName("reset_pushButton")
        self.gridLayout_3.addWidget(self.reset_pushButton, 2, 2, 1, 1)
        self.pushButton_2 = QtWidgets.QPushButton(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.pushButton_2.setFont(font)
        self.pushButton_2.setObjectName("pushButton_2")
        self.gridLayout_3.addWidget(self.pushButton_2, 3, 2, 1, 1)
        self.pushButton_4 = QtWidgets.QPushButton(self.groupBox)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(9)
        self.pushButton_4.setFont(font)
        self.pushButton_4.setObjectName("pushButton_4")
        self.gridLayout_3.addWidget(self.pushButton_4, 4, 2, 1, 1)
        self.label_4 = QtWidgets.QLabel(self.groupBox)
        self.label_4.setAlignment(QtCore.Qt.AlignCenter)
        self.label_4.setObjectName("label_4")
        self.gridLayout_3.addWidget(self.label_4, 2, 0, 1, 1)
        self.verticalLayout_3.addLayout(self.gridLayout_3)
        self.verticalLayout_2.addWidget(self.groupBox)
        self.horizontalLayout_2.addLayout(self.verticalLayout_2)
        self.tabWidget = QtWidgets.QTabWidget(nmonAnalysis_Form)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.tabWidget.setFont(font)
        self.tabWidget.setObjectName("tabWidget")
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")
        self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.tab)
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        self.cpu_widget = pg.PlotWidget(self.tab)
        self.cpu_widget.setMinimumSize(QtCore.QSize(300, 200))
        self.cpu_widget.setObjectName("graph_widget")
        self.cpu_widget.showGrid(x=True, y=True, alpha=0.5)  # 显示图形网格
        self.cpu_widget.setLabel(axis='left', text='百分比(%)')  # 设置Y轴标签
        self.cpu_widget.setYRange(0, 150)  # 初始化Y轴显示范围
        self.cpu_widget.setXRange(0, 25, padding=0)  # 初始化X轴显示范围
        self.cpu_widget.setLimits(xMin=-1,
                                  yMin=-2,
                                  xMax=6000,
                                  yMax=150,
                                  minXRange=25,
                                  minYRange=20,
                                  maxXRange=1000)
        self.cpu_widget.setLabel(axis='bottom', text='采样点(个)')  # 设置X轴标签
        self.cpu_widget.addLegend(size=(20, 10), offset=(12, 12))  # 添加图示x
        self.cpu_point_label = pg.TextItem()  # 创建一个文本项
        self.cpu_widget.addItem(self.cpu_point_label)  # 在图形部件中添加文本项
        self.cpu_user_line = self.cpu_widget.plot(pen="g",
                                                  name="CPU使用率",
                                                  symbolBrush="g")
        self.cpu_idle_line = self.cpu_widget.plot(pen=(0, 249, 255),
                                                  name="CPU空闲率",
                                                  symbolBrush=(0, 249, 255))
        self.cpu_vLine = pg.InfiniteLine(angle=90, movable=False, pen="w")
        self.cpu_widget.addItem(self.cpu_vLine, ignoreBounds=True)
        self.verticalLayout_4.addWidget(self.cpu_widget)
        self.tabWidget.addTab(self.tab, "")
        self.tab_2 = QtWidgets.QWidget()
        self.tab_2.setObjectName("tab_2")
        self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.tab_2)
        self.verticalLayout_5.setObjectName("verticalLayout_5")
        self.mem_widget = pg.PlotWidget(self.tab_2)
        self.mem_widget.setMinimumSize(QtCore.QSize(300, 200))
        self.mem_widget.setObjectName("graph_widget")
        self.mem_widget.showGrid(x=True, y=True, alpha=0.5)  # 显示图形网格
        self.mem_widget.setLabel(axis='left', text='百分比(%)')  # 设置Y轴标签
        self.mem_widget.setYRange(0, 150)  # 初始化Y轴显示范围
        self.mem_widget.setXRange(0, 25, padding=0)  # 初始化X轴显示范围
        self.mem_widget.setLimits(xMin=-1,
                                  yMin=-2,
                                  xMax=6000,
                                  yMax=150,
                                  minXRange=25,
                                  minYRange=20,
                                  maxXRange=1000)
        self.mem_widget.setLabel(axis='bottom', text='采样点(个)')  # 设置X轴标签
        self.mem_widget.addLegend(size=(20, 10), offset=(12, 12))  # 添加图示x
        self.mem_point_label = pg.TextItem()  # 创建一个文本项
        self.mem_widget.addItem(self.mem_point_label)  # 在图形部件中添加文本项
        self.mem_line = self.mem_widget.plot(pen="g",
                                             name="内存使用率",
                                             symbolBrush="g")
        self.mem_vLine = pg.InfiniteLine(angle=90, movable=False, pen="w")
        self.mem_widget.addItem(self.mem_vLine, ignoreBounds=True)
        self.verticalLayout_5.addWidget(self.mem_widget)
        self.tabWidget.addTab(self.tab_2, "")
        self.tab_3 = QtWidgets.QWidget()
        self.tab_3.setObjectName("tab_3")
        self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.tab_3)
        self.verticalLayout_6.setObjectName("verticalLayout_6")
        self.disk_widget = pg.PlotWidget(self.tab_3)
        self.disk_widget.setMinimumSize(QtCore.QSize(300, 200))
        self.disk_widget.setObjectName("graph_widget")
        self.disk_widget.showGrid(x=True, y=True, alpha=0.5)  # 显示图形网格
        self.disk_widget.setLabel(axis='left', text='使用率(%)')  # 设置Y轴标签
        self.disk_widget.setYRange(0, 200)  # 初始化Y轴显示范围
        self.disk_widget.setXRange(0, 25, padding=0)  # 初始化X轴显示范围
        self.disk_widget.setLimits(xMin=-5,
                                   yMin=-2,
                                   xMax=6000,
                                   yMax=200,
                                   minXRange=25,
                                   minYRange=30,
                                   maxXRange=1000)
        self.disk_widget.setLabel(axis='bottom', text='采样点(个)')  # 设置X轴标签
        self.disk_widget.addLegend(size=(20, 10), offset=(12, 12))  # 添加图示
        self.disk_point_label = pg.TextItem()  # 创建一个文本项
        self.disk_widget.addItem(self.disk_point_label)  # 在图形部件中添加文本项
        self.disk_vLine = pg.InfiniteLine(angle=90, movable=False, pen="w")
        self.disk_widget.addItem(self.disk_vLine, ignoreBounds=True)
        self.verticalLayout_6.addWidget(self.disk_widget)
        self.tabWidget.addTab(self.tab_3, "")
        self.tab_4 = QtWidgets.QWidget()
        self.tab_4.setObjectName("tab_4")
        self.verticalLayout_7 = QtWidgets.QVBoxLayout(self.tab_4)
        self.verticalLayout_7.setObjectName("verticalLayout_7")
        self.iops_widget = pg.PlotWidget(self.tab_4)
        self.iops_widget.setMinimumSize(QtCore.QSize(300, 200))
        self.iops_widget.setObjectName("graph_widget")
        self.iops_widget.showGrid(x=True, y=True, alpha=0.5)  # 显示图形网格
        self.iops_widget.setLabel(axis='left', text='IO/sec')  # 设置Y轴标签
        self.iops_widget.setYRange(0, 600)  # 初始化Y轴显示范围
        self.iops_widget.setXRange(0, 25, padding=0)  # 初始化X轴显示范围
        self.iops_widget.setLimits(xMin=-5,
                                   yMin=-2,
                                   xMax=6000,
                                   yMax=600,
                                   minXRange=25,
                                   minYRange=20,
                                   maxXRange=1000)
        self.iops_widget.setLabel(axis='bottom', text='采样点(个)')  # 设置X轴标签
        self.iops_widget.addLegend(size=(20, 10), offset=(12, 12))  # 添加图示x
        self.iops_point_label = pg.TextItem()  # 创建一个文本项
        self.iops_widget.addItem(self.iops_point_label)  # 在图形部件中添加文本项
        self.iops_line = self.iops_widget.plot(pen=(228, 164, 255),
                                               name="磁盘IO/sec",
                                               symbolBrush=(228, 164, 255))
        self.iops_vLine = pg.InfiniteLine(angle=90, movable=False, pen="w")
        self.iops_widget.addItem(self.iops_vLine, ignoreBounds=True)
        self.verticalLayout_7.addWidget(self.iops_widget)
        self.tabWidget.addTab(self.tab_4, "")
        self.tab_5 = QtWidgets.QWidget()
        self.tab_5.setObjectName("tab_5")
        self.verticalLayout_8 = QtWidgets.QVBoxLayout(self.tab_5)
        self.verticalLayout_8.setObjectName("verticalLayout_8")
        self.net_widget = pg.PlotWidget(self.tab_5)
        self.net_widget.setMinimumSize(QtCore.QSize(300, 200))
        self.net_widget.setObjectName("graph_widget")
        self.net_widget.showGrid(x=True, y=True, alpha=0.5)  # 显示图形网格
        self.net_widget.setLabel(axis='left', text='Mbps')  # 设置Y轴标签
        self.net_widget.setYRange(0, 50)  # 初始化Y轴显示范围
        self.net_widget.setXRange(0, 25, padding=0)  # 初始化X轴显示范围
        self.net_widget.setLimits(xMin=-5,
                                  yMin=-2,
                                  xMax=6000,
                                  yMax=150,
                                  minXRange=25,
                                  minYRange=20,
                                  maxXRange=1000)
        self.net_widget.setLabel(axis='bottom', text='采样点(个)')  # 设置X轴标签
        self.net_widget.addLegend(size=(20, 10), offset=(12, 12))  # 添加图示
        self.net_point_label = pg.TextItem()  # 创建一个文本项
        self.net_widget.addItem(self.net_point_label)  # 在图形部件中添加文本项
        self.net_read_line = self.net_widget.plot(pen="r",
                                                  name="网络-读",
                                                  symbolBrush=(255, 0, 0))
        self.net_write_line = self.net_widget.plot(pen="g",
                                                   name="网络-写",
                                                   symbolBrush=(0, 255, 0))
        self.net_vLine = pg.InfiniteLine(angle=90, movable=False, pen="w")
        self.net_widget.addItem(self.net_vLine, ignoreBounds=True)
        self.verticalLayout_8.addWidget(self.net_widget)
        self.tabWidget.addTab(self.tab_5, "")
        self.horizontalLayout_2.addWidget(self.tabWidget)
        self.horizontalLayout_2.setStretch(0, 3)
        self.horizontalLayout_2.setStretch(1, 7)
        self.verticalLayout.addLayout(self.horizontalLayout_2)

        self.retranslateUi(nmonAnalysis_Form)
        self.tabWidget.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(nmonAnalysis_Form)
예제 #12
0
    def createLayout(self):
        print 'Creating layout...'
        self.setWindowTitle('Interferometry Acquisition GUI')
        #self.widget = QtGui.QWidget()
        #self.setCentralWidget(self.widget)
        self.layout = pg.LayoutWidget()
        #self.widget.setLayout(self.layout)
        self.setCentralWidget(self.layout)

        #Create GUI
        sizePolicyBt = QtGui.QSizePolicy(1, 1)
        sizePolicyBt.setHorizontalStretch(0)
        sizePolicyBt.setVerticalStretch(0)

        self.btOpen = QtGui.QPushButton("Open\nprevious results")
        sizePolicyBt.setHeightForWidth(
            self.btOpen.sizePolicy().hasHeightForWidth())
        self.btOpen.setSizePolicy(sizePolicyBt)
        self.btOpen.setStyleSheet(
            "background-color: yellow; font-size: 16px; font: bold")

        self.btStart = QtGui.QPushButton("Start\nacquisition")
        sizePolicyBt.setHeightForWidth(
            self.btStart.sizePolicy().hasHeightForWidth())
        self.btStart.setSizePolicy(sizePolicyBt)
        self.btStart.setStyleSheet(
            "background-color: green; font-size: 16px; font: bold")
        self.btStart.clicked.connect(self.startAcquisition)

        self.btStop = QtGui.QPushButton("Stop\nacquisition")
        sizePolicyBt.setHeightForWidth(
            self.btStop.sizePolicy().hasHeightForWidth())
        self.btStop.setSizePolicy(sizePolicyBt)
        self.btStop.setStyleSheet(
            "background-color: red; font-size: 16px; font: bold")
        self.btStop.clicked.connect(self.stopAcquisition)
        self.btStop.setEnabled(False)

        self.paramTree = ParameterTree()
        self.paramTree.setParameters(Parameters.paramObject, showTop=False)
        self.paramTree.setWindowTitle('pyqtgraph example: Parameter Tree')
        self.paramTree.setMinimumWidth(350)
        self.paramTree.setMaximumWidth(350)
        sizePolicyPt = QtGui.QSizePolicy(1, 1)
        sizePolicyPt.setHorizontalStretch(QtGui.QSizePolicy.Fixed)
        sizePolicyPt.setVerticalStretch(1)
        self.paramTree.setSizePolicy(sizePolicyPt)

        ## Create random 2D data
        data = np.random.normal(size=(
            512, 512)) + pg.gaussianFilter(np.random.normal(size=(512, 512)),
                                           (5, 5)) * 20 + 100
        data = data[:, :, np.newaxis]
        data = data.repeat(3, 2)

        self.plotTl = pg.GraphicsView()
        self.plotTlImage = pg.ImageItem(data[:, :, :])  #parent=self.plotTl
        self.plotTlViewBox = pg.ViewBox()
        self.plotTl.setCentralWidget(self.plotTlViewBox)
        self.plotTlViewBox.addItem(self.plotTlImage)

        self.plotTr = pg.PlotWidget(title="Interferometry",
                                    labels={
                                        'left': 'Signal amplitude (A.U.)',
                                        'bottom': 'Distance (mm)'
                                    })
        #self.plotTlViewBox2.addItem(self.plotTr)
        self.plotTrCurve = self.plotTr.plot(pen=(255, 0, 0), name='C1')  #Red
        self.plotTrCurve2 = self.plotTr.plot(pen=(0, 255, 0),
                                             name='C2')  #Green
        #self.plotTlViewBox2.enableAutoRange('xy', True)  ## stop auto-scaling after the first data set is plotted
        #self.plotTr.addLegend('Test')
        self.plotTr.setYRange(-1000, 1000)

        self.plotBl = pg.PlotWidget(title="Distance",
                                    labels={
                                        'left': 'Distance (mm)',
                                        'bottom': 'Number of acquisitions'
                                    })

        self.plotBlCurve = self.plotBl.plot(pen=(255, 0, 0), name='C1')
        self.plotBl.enableAutoRange(
            'xy',
            True)  ## stop auto-scaling after the first data set is plotted
        self.plotBl.setMaximumWidth(3500)

        self.tbInfo = QtGui.QTextEdit()
        self.tbInfo.setEnabled(False)
        palette = self.tbInfo.palette()
        palette.setColor(QtGui.QPalette.Base,
                         QtGui.QColor("white"))  #White background
        self.tbInfo.setPalette(palette)
        self.tbInfo.setTextColor(QtGui.QColor("black"))
        self.tbInfo.insertPlainText("Useful information will appear here.")

        #Create list view of multiple items
        self.tbStatus = QtGui.QListView()
        self.tbStatus.setEnabled(False)
        palette = self.tbStatus.palette()
        palette.setColor(QtGui.QPalette.Base,
                         QtGui.QColor("white"))  #White background
        self.tbStatus.setPalette(palette)
        itemModelStatus = QtGui.QStandardItemModel(self.tbStatus)
        self.tbStatus.setModel(itemModelStatus)
        #Add system status
        self.itemStatus = QtGui.QStandardItem()
        self.setStatus(False)
        itemModelStatus.appendRow(self.itemStatus)
        #Add camera status
        self.itemCameraStatus = QtGui.QStandardItem()
        self.setCameraStatus(False)
        itemModelStatus.appendRow(self.itemCameraStatus)
        #Add memory usage
        self.itemMemory = QtGui.QStandardItem(
            "Acquisition board memory usage: N/A")
        self.itemMemory.setForeground(QtGui.QColor("black"))
        itemModelStatus.appendRow(self.itemMemory)
        #Add max value position
        self.itemMaxValPos = QtGui.QStandardItem(
            "Maximum RF value position: N/A")
        self.itemMaxValPos.setForeground(QtGui.QColor("black"))
        itemModelStatus.appendRow(self.itemMaxValPos)

        #layout.addWidget(QtGui.QLabel("These are two views of the same data. They should always display the same values."), 0, 0, 1, 2)
        self.layout.addWidget(self.btOpen, 9, 6, 1, 1)
        self.layout.addWidget(self.btStart, 9, 7, 1, 1)
        self.layout.addWidget(self.btStop, 9, 8, 1, 1)
        self.layout.addWidget(self.paramTree, 0, 0, 10, 3)
        self.layout.addWidget(self.plotTl, 0, 3, 5, 3)
        self.layout.addWidget(self.plotTr, 0, 6, 5, 3)
        self.layout.addWidget(self.plotBl, 5, 3, 5, 3)
        self.layout.addWidget(self.tbInfo, 5, 6, 2, 3)
        self.layout.addWidget(self.tbStatus, 7, 6, 2, 3)

        self.layout.layout.setColumnStretch(3, 1)
        self.layout.layout.setColumnStretch(4, 1)
        self.layout.layout.setColumnStretch(5, 1)
        self.layout.layout.setColumnStretch(6, 1)
        self.layout.layout.setColumnStretch(7, 1)
        self.layout.layout.setColumnStretch(8, 1)

        self.show()
        self.resize(1500, 800)
        self.move(100, 100)

        Parameters.paramObject.param('Save/Restore functionality',
                                     'Save State').sigActivated.connect(
                                         self.saveParam)
        Parameters.paramObject.param('Save/Restore functionality',
                                     'Restore State').sigActivated.connect(
                                         self.restoreParam)

        Parameters.paramObject.child(
            "Acquisition Parameters",
            "Rotation speed (%)").sigValueChanged.connect(
                self.motorSpeedChanged)
        Parameters.paramObject.child(
            "Trigger Options",
            "Acquisition mode").sigValueChanged.connect(self.triggerChanged)
        Parameters.paramObject.child(
            "Trigger Options",
            "Trigger amplitude").sigValueChanged.connect(self.triggerChanged)
        Parameters.paramObject.child(
            "Trigger Options",
            "Trigger switch 1/2").sigActivated.connect(self.triggerHalfSwitch)

        # adding by emitting signal in different thread
        self.workThread = AcquisitionWorker()
        self.workThread.updateDataCamera.connect(self.setDataCurveTl)
        self.workThread.updateDataInterf.connect(self.setDataCurveTr)
        self.workThread.updateDataDistance.connect(self.setDataCurveBl)
        self.workThread.updateDataDistance2.connect(self.setDataCurveBl2)
        self.workThread.updateWire.connect(self.setWire)
        self.workThread.setStatus.connect(self.setStatus)
        self.workThread.setInfo.connect(self.setInfo)
        self.testCount = 0

        #Fill the plots with dummy data
        self.data = np.random.normal(size=(10, 1000))
        self.plotTrXAxis = np.arange(1000) * (0.01)
        self.plotBlXAxis = np.arange(1000) * (1)
        self.plotTrCurve.setData(x=self.plotTrXAxis,
                                 y=self.data[2 % 10],
                                 name='C1')
        self.plotTrCurve2.setData(x=self.plotTrXAxis,
                                  y=self.data[3 % 10],
                                  name='C2')
        self.plotBlCurve.setData(x=self.plotBlXAxis,
                                 y=self.data[4 % 10],
                                 name='C1')

        self.valueTest = 1
예제 #13
0
    def __init__(self, index, parent=None):
        QtGui.QWidget.__init__(self)

        self.window = parent

        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)
        
        hbox = QtGui.QHBoxLayout()
        vbox.addLayout(hbox)

        label1 = QtGui.QLabel("基础股票池", self)
        label1.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignVCenter)
        hbox.addWidget(label1)
        self.baseindexcombo = QtGui.QComboBox()
        self.baseindexcombo.addItems(["沪深300","中证500","中证全指","全体A股"])
        self.baseindexcombo.currentIndexChanged.connect(self.baseindexclicked)
        hbox.addWidget(self.baseindexcombo)

        label2 = QtGui.QLabel("最大选股数量", self)
        label2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignVCenter)
        hbox.addWidget(label2)

        self.intvalidator = QtGui.QIntValidator()
        self.maxcnt = QtGui.QLineEdit(self)
        self.maxcnt.setValidator(self.intvalidator)
        self.maxcnt.editingFinished.connect(self.topcntfinished)
        hbox.addWidget(self.maxcnt)

        label3 = QtGui.QLabel("最大个股权重", self)
        label3.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignVCenter)
        hbox.addWidget(label3)

        self.maxweight = QtGui.QLineEdit(self)
        self.maxweight.setValidator(self.intvalidator)
        self.maxweight.editingFinished.connect(self.topweightfinished)
        hbox.addWidget(self.maxweight)

        label4 = QtGui.QLabel("%", self)
        label4.setAlignment(QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
        hbox.addWidget(label4)

        vbox.addWidget(QtGui.QLabel("自定义选股", self))
               
        self.stkpool = QtGui.QPlainTextEdit(self)
        vbox.addWidget(self.stkpool)

        bapplypool = QtGui.QPushButton("自定义选股生效", self)
        bapplypool.clicked.connect(self.applyclicked)
        vbox.addWidget(bapplypool)

        self.chart = pg.PlotWidget()
        vbox.addWidget(self.chart)
        self.statusbar = QtGui.QStatusBar()
        self.window.setStatusBar(self.statusbar)
        self.updatestatusbar = False
        self.newstatusbarmsg = None

        self.index = index
        self.index.simulate()
        l = index.getDayCount()
        self.r = np.empty(l, dtype = np.float64)
        index.getCumReturn(self.r)
        self.dates = np.empty(l, dtype = np.int32)
        index.getDates(self.dates)

        self.curve = self.chart.plot(self.r)
        ticks = [list(zip(range(l), [str(x) for x in self.dates.tolist()]))[::250]]
        self.chart.getAxis("bottom").setTicks(ticks)
        
        self.redraw_event = threading.Event()
        self.redraw_event.set()
        self.datathread = threading.Thread(target = self.redrawPlot, args=())
        self.datathread.setDaemon(True)
        self.datathread.start()


        self.timer = QtCore.QTimer()
        self.timer.setInterval(50)
        self.timer.timeout.connect(self.updateData)
        self.timer.start(50)
예제 #14
0
    def setupUi(self, MainWindow, centralwidget, mainTabLayout):
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)

        self.declareInit()

        self.tab_5 = QtWidgets.QWidget()
        self.tab_5.setObjectName("tab_5")

        self.verticalLayout_ComparationTab = QtWidgets.QVBoxLayout(self.tab_5)
        self.verticalLayout_ComparationTab.setObjectName(
            "verticalLayout_ComparationTab")

        self.labelGraph_ComparationTab = QtWidgets.QLabel(self.tab_5)
        self.labelGraph_ComparationTab.setFont(font)
        self.labelGraph_ComparationTab.setObjectName(
            "labelGraph_ComparationTab")

        self.graph_ComparationTab = pg.PlotWidget(self.tab_5)
        self.graph_ComparationTab.setObjectName("graph_ComparationTab")
        self.graph_ComparationTab.setBackground('w')
        self.graph_ComparationTab.setLabel('left', 'Rainfall (mm)')
        self.graph_ComparationTab.setLabel('bottom', 'Month')
        self.legendComparation = self.graph_ComparationTab.addLegend()

        self.labelTable_ComparationTab = QtWidgets.QLabel()
        self.labelTable_ComparationTab.setFont(font)
        self.labelTable_ComparationTab.setObjectName(
            "labelTable_ComparationTab")

        self.table_ComparationTab = QtWidgets.QTableWidget()
        self.table_ComparationTab.setObjectName("table_ComparationTab")
        self.table_ComparationTab.setColumnCount(100)
        self.table_ComparationTab.setRowCount(100)
        self.table_ComparationTab.installEventFilter(self)

        self.label_bulanan = QtWidgets.QLabel()
        self.label_bulanan.setFont(font)
        self.label_bulanan.setObjectName("label_bulanan")

        self.label_28 = QtWidgets.QLabel()
        self.label_28.setObjectName("label_28")

        self.label_time_bulanan = QtWidgets.QLabel()
        self.label_time_bulanan.setObjectName("label_time_bulanan")

        self.annTime_bulanan = QtWidgets.QLabel()
        self.annTime_bulanan.setObjectName("annTime_bulanan")

        self.tfTime_bulanan = QtWidgets.QLabel()
        self.tfTime_bulanan.setObjectName("tfTime_bulanan")

        self.annMSE_bulanan = QtWidgets.QLabel()
        self.annMSE_bulanan.setObjectName("annMSE_bulanan")

        self.annRsqr_bulanan = QtWidgets.QLabel()
        self.annRsqr_bulanan.setObjectName("annRsqr_bulanan")

        self.label_29 = QtWidgets.QLabel()
        self.label_29.setObjectName("label_29")

        self.tfMSE = QtWidgets.QLabel()
        self.tfMSE.setObjectName("tfMSE")

        self.tfRsqr = QtWidgets.QLabel()
        self.tfRsqr.setObjectName("tfRsqr")

        self.model_bulanan = QtWidgets.QLabel()
        self.model_bulanan.setObjectName("model_bulanan")

        self.mse_bulanan = QtWidgets.QLabel()
        self.mse_bulanan.setObjectName("mse_bulanan")

        self.rsqr_bulanan = QtWidgets.QLabel()
        self.rsqr_bulanan.setObjectName("rsqr_bulanan")

        self.label_bulanan_no = QtWidgets.QLabel()
        self.label_bulanan_no.setObjectName("label_bulanan_no")

        self.label_bulanan_1 = QtWidgets.QLabel()
        self.label_bulanan_1.setObjectName("label_bulanan_1")

        self.label_bulanan_2 = QtWidgets.QLabel()
        self.label_bulanan_2.setObjectName("label_bulanan_label_bulanan_2")

        self.gridLayout_bulanan = QtWidgets.QGridLayout()

        self.gridLayout_bulanan.addWidget(self.label_bulanan_no, 0, 0, 1, 1)
        self.gridLayout_bulanan.addWidget(self.model_bulanan, 0, 1, 1, 1)
        self.gridLayout_bulanan.addWidget(self.label_time_bulanan, 0, 2, 1, 1)
        self.gridLayout_bulanan.addWidget(self.mse_bulanan, 0, 3, 1, 1)
        self.gridLayout_bulanan.addWidget(self.rsqr_bulanan, 0, 4, 1, 1)

        self.gridLayout_bulanan.addWidget(self.label_bulanan_1, 1, 0, 1, 1)
        self.gridLayout_bulanan.addWidget(self.label_28, 1, 1, 1, 1)
        self.gridLayout_bulanan.addWidget(self.annTime_bulanan, 1, 2, 1, 1)
        self.gridLayout_bulanan.addWidget(self.annMSE_bulanan, 1, 3, 1, 1)
        self.gridLayout_bulanan.addWidget(self.annRsqr_bulanan, 1, 4, 1, 1)

        self.gridLayout_bulanan.addWidget(self.label_bulanan_2, 2, 0, 1, 1)
        self.gridLayout_bulanan.addWidget(self.label_29, 2, 1, 1, 1)
        self.gridLayout_bulanan.addWidget(self.tfTime_bulanan, 2, 2, 1, 1)
        self.gridLayout_bulanan.addWidget(self.tfMSE, 2, 3, 1, 1)
        self.gridLayout_bulanan.addWidget(self.tfRsqr, 2, 4, 1, 1)

        self.label_harian_no = QtWidgets.QLabel()
        self.label_harian_no.setObjectName("label_harian_no")

        self.label_harian_1 = QtWidgets.QLabel()
        self.label_harian_1.setObjectName("label_harian_1")

        self.label_harian_2 = QtWidgets.QLabel()
        self.label_harian_2.setObjectName("label_harian_2")

        self.label_time_harian = QtWidgets.QLabel()
        self.label_time_harian.setObjectName("label_time_harian")

        self.annTime_harian = QtWidgets.QLabel()
        self.annTime_harian.setObjectName("annTime_harian")

        self.wwoTime_harian = QtWidgets.QLabel()
        self.wwoTime_harian.setObjectName("wwoTime_harian")

        self.label_harian = QtWidgets.QLabel()
        self.label_harian.setFont(font)
        self.label_harian.setObjectName("label_harian")

        self.label_ann_harian = QtWidgets.QLabel()
        self.label_ann_harian.setObjectName("label_ann_harian")

        self.annMSE_harian = QtWidgets.QLabel()
        self.annMSE_harian.setObjectName("annMSE_harian")

        self.annRsqr_harian = QtWidgets.QLabel()
        self.annRsqr_harian.setObjectName("annRsqr_harianharian")

        self.label_wwo = QtWidgets.QLabel()
        self.label_wwo.setObjectName("label_wwo")

        self.wwoMSE = QtWidgets.QLabel()
        self.wwoMSE.setObjectName("wwoMSE")

        self.wwoRsqr = QtWidgets.QLabel()
        self.wwoRsqr.setObjectName("wwoRsqr")

        self.model_harian = QtWidgets.QLabel()
        self.model_harian.setObjectName("model_harian")

        self.mse_harian = QtWidgets.QLabel()
        self.mse_harian.setObjectName("mse_harian")

        self.rsqr_harian = QtWidgets.QLabel()
        self.rsqr_harian.setObjectName("rsqr_harian")

        self.gridLayout_harian = QtWidgets.QGridLayout()

        self.gridLayout_harian.addWidget(self.label_harian_no, 0, 0, 1, 1)
        self.gridLayout_harian.addWidget(self.model_harian, 0, 1, 1, 1)
        self.gridLayout_harian.addWidget(self.label_time_harian, 0, 2, 1, 1)
        self.gridLayout_harian.addWidget(self.mse_harian, 0, 3, 1, 1)
        self.gridLayout_harian.addWidget(self.rsqr_harian, 0, 4, 1, 1)

        self.gridLayout_harian.addWidget(self.label_harian_1, 1, 0, 1, 1)
        self.gridLayout_harian.addWidget(self.label_ann_harian, 1, 1, 1, 1)
        self.gridLayout_harian.addWidget(self.annTime_harian, 1, 2, 1, 1)
        self.gridLayout_harian.addWidget(self.annMSE_harian, 1, 3, 1, 1)
        self.gridLayout_harian.addWidget(self.annRsqr_harian, 1, 4, 1, 1)

        self.gridLayout_harian.addWidget(self.label_harian_2, 2, 0, 1, 1)
        self.gridLayout_harian.addWidget(self.label_wwo, 2, 1, 1, 1)
        self.gridLayout_harian.addWidget(self.wwoTime_harian, 2, 2, 1, 1)
        self.gridLayout_harian.addWidget(self.wwoMSE, 2, 3, 1, 1)
        self.gridLayout_harian.addWidget(self.wwoRsqr, 2, 4, 1, 1)

        # garis horizontal
        self.line_1 = QtWidgets.QFrame()
        self.line_1.setFrameShadow(QtWidgets.QFrame.Raised)
        self.line_1.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_1.setObjectName("line_1")

        self.ConclusionVerticalLayout_ComparationTab = QtWidgets.QVBoxLayout()
        self.ConclusionVerticalLayout_ComparationTab.setAlignment(
            QtCore.Qt.AlignTop)
        self.ConclusionVerticalLayout_ComparationTab.setObjectName(
            "ConclusionVerticalLayout_ComparationTab")
        self.ConclusionVerticalLayout_ComparationTab.addWidget(
            self.label_bulanan)
        self.ConclusionVerticalLayout_ComparationTab.addLayout(
            self.gridLayout_bulanan)
        self.ConclusionVerticalLayout_ComparationTab.addWidget(self.line_1)
        self.ConclusionVerticalLayout_ComparationTab.addWidget(
            self.label_harian)
        self.ConclusionVerticalLayout_ComparationTab.addLayout(
            self.gridLayout_harian)

        self.graphComparationTabGroupLayout = QtWidgets.QVBoxLayout()
        self.graphComparationTabGroupLayout.setObjectName(
            "graphComparationTabGroupLayout")
        self.graphComparationTabGroupLayout.addWidget(
            self.labelGraph_ComparationTab)
        self.graphComparationTabGroupLayout.addWidget(
            self.graph_ComparationTab)

        self.packageForGraphComparationTabGroupLayout = QtWidgets.QWidget()
        self.packageForGraphComparationTabGroupLayout.setObjectName(
            "packageForGraphComparationTabGroupLayout")
        self.packageForGraphComparationTabGroupLayout.setLayout(
            self.graphComparationTabGroupLayout)

        self.tableComparationTabGroupLayout = QtWidgets.QVBoxLayout()
        self.tableComparationTabGroupLayout.setObjectName(
            "tableComparationTabGroupLayout")
        self.tableComparationTabGroupLayout.addWidget(
            self.labelTable_ComparationTab)
        self.tableComparationTabGroupLayout.addWidget(
            self.table_ComparationTab)

        self.packageForTableComparationTabGroupLayout = QtWidgets.QWidget()
        self.packageForTableComparationTabGroupLayout.setObjectName(
            "packageForTableComparationTabGroupLayout")
        self.packageForTableComparationTabGroupLayout.setLayout(
            self.tableComparationTabGroupLayout)

        self.splitterGraphAndTable_ComparationTab = QtWidgets.QSplitter(
            QtCore.Qt.Vertical)
        self.splitterGraphAndTable_ComparationTab.setObjectName(
            "splitterGraphAndTable_ComparationTab")
        self.splitterGraphAndTable_ComparationTab.addWidget(
            self.packageForGraphComparationTabGroupLayout)
        self.splitterGraphAndTable_ComparationTab.addWidget(
            self.packageForTableComparationTabGroupLayout)

        self.packageConclution_ComparationTab = QtWidgets.QWidget()
        self.packageConclution_ComparationTab.setObjectName(
            'packageConclution_ComparationTab')
        self.packageConclution_ComparationTab.setLayout(
            self.ConclusionVerticalLayout_ComparationTab)

        self.splitterHorizontal_ComparationTab = QtWidgets.QSplitter(
            QtCore.Qt.Horizontal)
        self.splitterHorizontal_ComparationTab.setObjectName(
            "splitterHorizontal_ComparationTab")
        self.splitterHorizontal_ComparationTab.addWidget(
            self.packageConclution_ComparationTab)
        self.splitterHorizontal_ComparationTab.addWidget(
            self.splitterGraphAndTable_ComparationTab)

        self.verticalLayout_ComparationTab.addWidget(
            self.splitterHorizontal_ComparationTab)

        mainTabLayout.addTab(self.tab_5, "")
        self.retranslateUi(mainTabLayout)
예제 #15
0
    def __init__(self, device=None):
        QWidget.__init__(self)
        self.p = device  # connection to the device hardware

        self.traceCols = utils.makeTraceColors()
        self.resultCols = utils.makeResultColors()

        self.tabs = QTabWidget()

        self.pwin = pg.PlotWidget()  # pyqtgraph window
        self.pwin.showGrid(x=True, y=True)  # with grid
        ax = self.pwin.getAxis('bottom')
        ax.setLabel(self.tr('Voltage (V)'))
        ax = self.pwin.getAxis('left')
        ax.setLabel(self.tr('Current(uA)'))
        self.pwin.disableAutoRange()
        self.pwin.setXRange(self.inputVMIN, self.inputVMAX)
        self.pwin.setYRange(self.inputIMIN, self.inputIMAX)
        self.pwin.hideButtons()  # Do not show the 'A' button of pg

        self.tab1 = QWidget()
        self.tab1.setAutoFillBackground(True)
        self.tab2 = QWidget()
        self.tab2.setAutoFillBackground(True)
        self.tabs.resize(300, 200)

        # Add tabs
        self.tabs.addTab(self.tab1, "INPUT")
        self.tabs.addTab(self.tab2, "OUTPUT")

        rW = QWidget()
        right = QVBoxLayout()  # right side vertical layout
        right.setAlignment(Qt.AlignTop)
        right.setSpacing(self.RPGAP)
        right.addWidget(self.tabs)
        rW.setLayout(right)

        rW.setFixedWidth(260)

        #------------------------------------------
        # INPUT TAB START
        #------------------------------------------
        T1 = QVBoxLayout()
        T1.setAlignment(Qt.AlignTop)
        T1.setSpacing(self.RPGAP)
        #T1.setAlignment(right)

        H = QHBoxLayout()
        self.defaultInputChkBox = QCheckBox("Use Defaults")
        self.defaultInputChkBox.setChecked(True)
        self.defaultInputChkBox.stateChanged.connect(
            self.defaultInputChkBoxChanged)
        H.addWidget(self.defaultInputChkBox)
        T1.addLayout(H)

        H = QHBoxLayout()

        l = QLabel(text=self.tr('Enter V_CE Value'))
        l.setMaximumWidth(140)
        H.addWidget(l)
        self.V_C_USER = utils.lineEdit(40, 1.0, 6, None)
        H.addWidget(self.V_C_USER)
        l = QLabel(text=self.tr('V'))
        l.setMaximumWidth(10)
        H.addWidget(l)

        T1.addLayout(H)

        H = QHBoxLayout()

        l = QLabel(text=self.tr('Steps'))
        l.setMaximumWidth(140)
        H.addWidget(l)
        self.UserStep = QLineEdit()
        self.UserStep = utils.lineEdit(40, 0.005, 6, None)
        self.UserStep.setText("0.05")
        #self.UserStep.setDisabled(True)

        H.addWidget(self.UserStep)
        l = QLabel(text=self.tr('V'))
        l.setMaximumWidth(10)
        H.addWidget(l)
        T1.addLayout(H)

        H = QHBoxLayout()

        right.addLayout(H)

        self.startInputButton = QPushButton(self.tr("Start"))
        T1.addWidget(self.startInputButton)
        self.startInputButton.clicked.connect(self.startInput)

        b = QPushButton(self.tr("Stop"))
        T1.addWidget(b)
        b.clicked.connect(self.stop)

        b = QPushButton(self.tr("Clear Traces"))
        T1.addWidget(b)
        b.clicked.connect(self.clear)

        if (self.trial >= 0):
            b = QPushButton(self.tr("Show Results"))
            T1.addWidget(b)
            b.clicked.connect(self.showdialogInput)

        self.SaveButton = QPushButton(self.tr("Save Data"))
        self.SaveButton.clicked.connect(self.save_data)
        T1.addWidget(self.SaveButton)

        H = QHBoxLayout()
        self.ResultsInput = QTextEdit()
        self.ResultsInput.setMaximumWidth(self.RPWIDTH / 2 - 5)
        H.addWidget(self.ResultsInput)
        T1.addLayout(H)
        self.tab1.layout = T1

        self.V_C_USER.setDisabled(True)
        self.UserStep.setDisabled(True)
        self.V_C_USER.setText("2")
        self.UserStep.setText("0.05")

        self.tab1.setLayout(self.tab1.layout)

        #----------------INPUT TAB ENDS---------------------------------

        #------------------------------------------
        # OUTPUT TAB START
        #------------------------------------------

        T2 = QVBoxLayout()
        T2.setAlignment(Qt.AlignTop)
        T2.setSpacing(self.RPGAP)
        #T2.setAlignment(right)

        H = QHBoxLayout()

        H = QHBoxLayout()
        l = QLabel(text=self.tr('Vbase (via 100kOhm)'))
        l.setMaximumWidth(140)
        H.addWidget(l)
        self.VBtext = utils.lineEdit(40, 1.0, 6, None)
        H.addWidget(self.VBtext)
        l = QLabel(text=self.tr('V'))
        l.setMaximumWidth(10)
        H.addWidget(l)

        T2.addLayout(H)

        H = QHBoxLayout()

        self.startOutputButton = QPushButton(self.tr("Start"))
        T2.addWidget(self.startOutputButton)
        self.startOutputButton.clicked.connect(self.startOutput)

        b = QPushButton(self.tr("Stop"))
        T2.addWidget(b)
        b.clicked.connect(self.stop)

        b = QPushButton(self.tr("Clear Traces"))
        T2.addWidget(b)
        b.clicked.connect(self.clear)

        if (self.trial >= 0):
            b = QPushButton(self.tr("Show Results"))
            T2.addWidget(b)
            b.clicked.connect(self.showdialogOutput)

        self.SaveButton = QPushButton(self.tr("Save Data"))
        self.SaveButton.clicked.connect(self.save_data)
        T2.addWidget(self.SaveButton)

        H = QHBoxLayout()
        self.Results = QTextEdit()
        self.Results.setMaximumWidth(self.RPWIDTH / 2 - 5)
        H.addWidget(self.Results)
        T2.addLayout(H)
        self.tab2.layout = T2

        self.tab2.setLayout(self.tab2.layout)

        #------------------------end of right panel ----------------

        top = QHBoxLayout()
        top.addWidget(self.pwin)
        top.addWidget(rW)

        full = QVBoxLayout()
        full.addLayout(top)
        self.msgwin = QLabel(text='')
        full.addWidget(self.msgwin)

        self.setLayout(full)

        self.timer = QTimer()
        self.timer.timeout.connect(self.update)
        self.timer.start(self.TIMER)

        self.tabs.currentChanged.connect(self.onChange)
예제 #16
0
    def __init__(self, adj, hop, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle('Check Clock Adjustments')
        self.setWindowIcon(QIcon('img/Avianz.ico'))
        self.setWindowFlags((self.windowFlags() ^ Qt.WindowContextHelpButtonHint) | Qt.WindowMaximizeButtonHint | Qt.WindowCloseButtonHint)

        self.parent = parent

        # list of dicts for each pair: {overlaps for each t, best overlap, best shift, (rec pair names)}
        self.shifts = adj
        self.xs = np.arange(-300*hop, 301*hop, hop)

        # top section
        self.labelCurrPage = QLabel("Page %s of %s" %(1, len(self.shifts)))
        self.labelRecs = QLabel()

        # middle section
        # The buttons to move through the overview
        self.leftBtn = QToolButton()
        self.leftBtn.setArrowType(Qt.LeftArrow)
        self.leftBtn.clicked.connect(self.moveLeft)
        self.leftBtn.setToolTip("View previous pair")
        self.rightBtn = QToolButton()
        self.rightBtn.setArrowType(Qt.RightArrow)
        self.rightBtn.clicked.connect(self.moveRight)
        self.rightBtn.setToolTip("View next pair")
        self.leftBtn.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)
        self.rightBtn.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)

        self.connectCheckbox = QCheckBox("Recorders are connected")
        self.connectCheckbox.setChecked(bool(self.parent.recConnections[0,1]==1))
        self.connectCheckbox.toggled.connect(self.connectToggled)

        # main graphic
        mainpl = pg.PlotWidget()
        self.p1 = mainpl.plot()
        self.p1.setPen(pg.mkPen('k', width=1))
        col = pg.mkColor(20, 255, 20, 150)
        self.bestLineO = pg.InfiniteLine(angle=0, movable=False, pen={'color': col, 'width': 2})
        self.bestLineSh = pg.InfiniteLine(angle=90, movable=False, pen={'color': col, 'width': 2})
        mainpl.addItem(self.bestLineO)
        mainpl.addItem(self.bestLineSh)

        # init plot with page 1 data
        self.currpage = 1
        self.leftBtn.setEnabled(False)
        if len(self.shifts)==1:
            self.rightBtn.setEnabled(False)
        self.setData()

        # accept / close
        closeBtn = QPushButton("Close")
        closeBtn.clicked.connect(self.accept)
        # cancelBtn = QPushButton("Cancel")
        # cancelBtn.clicked.connect(self.reject)

        # Layouts
        box = QVBoxLayout()
        topHBox = QHBoxLayout()
        topHBox.addWidget(self.labelCurrPage, stretch=1)
        topHBox.addWidget(self.labelRecs, stretch=3)
        box.addLayout(topHBox)

        midHBox = QHBoxLayout()
        midHBox.addWidget(self.leftBtn)
        midHBox.addWidget(mainpl, stretch=10)
        midHBox.addWidget(self.rightBtn)
        box.addLayout(midHBox)
        box.addWidget(self.connectCheckbox)

        bottomHBox = QHBoxLayout()
        bottomHBox.addWidget(closeBtn)
        # bottomHBox.addWidget(cancelBtn)
        box.addLayout(bottomHBox)
        self.setLayout(box)
        dlg.setLayout(layout)
        dlg.exec_()


if __name__ == '__main__':
    import sys
    import numpy
    import pyqtgraph as pg
    from taurus.qt.qtgui.tpg import TaurusPlotDataItem
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.qt.qtgui.tpg import CurvesPropertiesTool

    app = TaurusApplication()

    # a standard pyqtgraph plot_item
    w = pg.PlotWidget()

    #add legend to the plot, for that we have to give a name to plot items
    w.addLegend()

    # add a Y2 axis
    from taurus.qt.qtgui.tpg import Y2ViewBox
    y2ViewBox = Y2ViewBox()
    y2ViewBox.attachToPlotItem(w.getPlotItem())

    # adding a regular data item (non-taurus)
    c1 = pg.PlotDataItem(name='st plot',
                         pen=dict(color='y', width=3,
                                  style=QtCore.Qt.DashLine),
                         fillLevel=0.3,
                         fillBrush='g')
예제 #18
0
    def __init__(self):
        super().__init__()

        self.dataset = None
        self.z_values = []

        self._root = None
        self._displayed_root = None
        self._item = None
        self._cache = {}

        self.colors = colorpalette.ColorPaletteGenerator(10)

        box = gui.vBox(self.controlArea, "Axes")
        self.x_var_model = itemmodels.VariableListModel()
        self.comboBoxAttributesX = gui.comboBox(
            box, self, value='x_var_index', callback=self.replot,
            contentsLength=12)
        self.comboBoxAttributesX.setModel(self.x_var_model)

        self.y_var_model = itemmodels.VariableListModel()
        self.comboBoxAttributesY = gui.comboBox(
            box, self, value='y_var_index', callback=self.replot,
            contentsLength=12)
        self.comboBoxAttributesY.setModel(self.y_var_model)

        box = gui.vBox(self.controlArea, "Color")
        self.z_var_model = itemmodels.VariableListModel()
        self.comboBoxClassvars = gui.comboBox(
            box, self, value='z_var_index',
            callback=self._on_z_var_changed,
            contentsLength=12)
        self.comboBoxClassvars.setModel(self.z_var_model)

        self.z_values_view = gui.listBox(
            box, self, "selected_z_values", "z_values",
            callback=self._on_z_values_selection_changed,
            selectionMode=QListView.MultiSelection,
            addSpace=False
        )
        gui.comboBox(box, self, "color_scale", label="Scale: ",
                     orientation=Qt.Horizontal,
                     items=["Linear", "Square root", "Logarithmic"],
                     callback=self._on_color_scale_changed)

        self.sampling_box = gui.vBox(self.controlArea, "Sampling")
        sampling_options = (self.sample_times_captions +
                            self.sample_percentages_captions)
        self.sample_combo = gui.comboBox(
            self.sampling_box, self, 'sample_level', items=sampling_options,
            callback=self.update_sample)
        gui.button(self.sampling_box, self, "Sharpen", self.sharpen)

        gui.rubber(self.controlArea)

        self.plot = pg.PlotWidget(background="w")
        self.plot.setMenuEnabled(False)
        self.plot.setFrameStyle(QFrame.StyledPanel)
        self.plot.setMinimumSize(500, 500)

        def font_resize(font, factor, minsize=None, maxsize=None):
            font = QFont(font)
            fontinfo = QFontInfo(font)
            size = fontinfo.pointSizeF() * factor

            if minsize is not None:
                size = max(size, minsize)
            if maxsize is not None:
                size = min(size, maxsize)

            font.setPointSizeF(size)
            return font

        axisfont = font_resize(self.font(), 0.8, minsize=11)
        axispen = QPen(self.palette().color(QPalette.Text))
        axis = self.plot.getAxis("bottom")
        axis.setTickFont(axisfont)
        axis.setPen(axispen)
        axis = self.plot.getAxis("left")
        axis.setTickFont(axisfont)
        axis.setPen(axispen)

        self.plot.getViewBox().sigTransformChanged.connect(
            self._on_transform_changed)
        self.mainArea.layout().addWidget(self.plot)
예제 #19
0
    def __init__(
        self,
        time_past=5,
        bounds_update=0.1,
        compact=False,
        n_points_max=500,
        accumulators=None,
        precision=None,
        experiment=None,
        *args,
        **kwargs
    ):
        super().__init__(*args, **kwargs)

        self.experiment = experiment
        self.time_past = time_past
        self.compact = compact
        self.n_points_max = n_points_max

        self.setLayout(QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)

        self.precision = precision or 3
        self.penwidth = 2

        if not compact:
            self.control_layout = QHBoxLayout()
            self.control_layout.setContentsMargins(0, 0, 0, 0)

            self.btn_select = QPushButton("Choose variables")
            self.btn_select.clicked.connect(self.show_select)
            self.control_layout.addWidget(self.btn_select)
            self.wnd_config = None

            self.btn_freeze = QPushButton()
            self.btn_freeze.setMinimumSize(80, 16)
            self.btn_freeze.clicked.connect(self.toggle_freeze)
            self.control_layout.addWidget(self.btn_freeze)

            try:
                tm = self.experiment.tracking_method_name
                if tm == "tail" or tm == "fish":
                    self.btn_extra = QPushButton(
                        "Show tail curvature" if tm == "tail" else "Show last bouts"
                    )

                    self.btn_extra.clicked.connect(self.show_extra_plot)
                    self.control_layout.addWidget(self.btn_extra)
            except AttributeError:
                pass

            self.lbl_zoom = QLabel("Plot past ")
            self.spn_zoom = QDoubleSpinBox()
            self.spn_zoom.setValue(time_past)
            self.spn_zoom.setSuffix("s")
            self.spn_zoom.setMinimum(0.1)
            self.spn_zoom.setMaximum(30)
            self.spn_zoom.valueChanged.connect(self.update_zoom)

            self.control_layout.addItem(
                QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)
            )
            self.control_layout.addWidget(self.lbl_zoom)
            self.control_layout.addWidget(self.spn_zoom)

            self.layout().addLayout(self.control_layout)

        self.plotContainer = pg.PlotWidget()
        self.plotContainer.showAxis("left", False)
        self.plotContainer.plotItem.hideButtons()

        self.replay_left = pg.InfiniteLine(
            -1, pen=(220, 220, 220), movable=True, hoverPen=(230, 30, 0)
        )
        self.replay_right = pg.InfiniteLine(
            -1, pen=(220, 220, 220), movable=True, hoverPen=(230, 30, 0)
        )

        for rep_line in [self.replay_left, self.replay_right]:
            rep_line.sigDragged.connect(self.update_replay_limits)

        self.layout().addWidget(self.plotContainer)

        self.active_plots = []

        self.accumulators = accumulators or []
        self.selected_columns = []

        self.stream_items = []
        self.stream_scales = []

        self.bounds = []
        self.bounds_update = bounds_update

        self.colors = []

        self.frozen = True
        self.bounds_visible = None

        # trick to set color on update
        self.color_set = False

        self.toggle_freeze()
        self.update_zoom(time_past)
        self.update_buflen(time_past)
예제 #20
0
    def __init__(self, raw_signal, dt):
        super().__init__()

        self._logs = []
        self.l = QGridLayout(self)

        ####################
        ### Create Signal
        ####################
        self.signal = Signal(raw_signal=raw_signal, dt=dt)
        self.signalPlot = pg.PlotWidget()
        self.signalCurve1 = self.signalPlot.plot(self.signal.t,
                                                 self.signal.raw_signal)

        ####################
        ### Filter Signal
        ####################
        self.signal.filterSignal()
        self.signalCurve2 = self.signalPlot.plot(self.signal.t,
                                                 self.signal.filtered_signal,
                                                 pen=pg.mkPen('m'))

        ####################
        ### Detect cycles
        ####################
        self.signal.detectCycles()
        self.signalPlot.plot(
            self.signal.t[self.signal.raw_peaks[0]],
            self.signal.filtered_signal[self.signal.raw_peaks[0]],
            pen=pg.mkPen('y'))

        ####################
        ### Detect opening and closing phases
        ####################
        self.signal.detectPhases(use_filtered_signal=False)

        i = 0
        cs = [(241, 196, 15), (231, 76, 60)]

        for o, c in zip(self.signal.opening, self.signal.closing):
            print(o, c)
            i1 = pg.PlotCurveItem(self.signal.t[o:c],
                                  np.zeros_like(self.signal.t[o:c]))
            i2 = pg.PlotCurveItem(self.signal.t[o:c],
                                  self.signal.raw_signal[o:c])
            between = pg.FillBetweenItem(i1, i2, brush=cs[i % len(cs)])
            self.signalPlot.addItem(between)
            i += 1

        ####################
        ### FFT, Cepstrum
        ####################
        self.l.addWidget(QLabel("Signal"))
        self.l.addWidget(self.signalPlot)

        self.signal.computeFFT(use_hanning=True, use_filtered_signal=True)

        self.l.addWidget(QLabel("Power Spectrum"))
        self.powerSpectrum = pg.PlotWidget()
        self.l.addWidget(self.powerSpectrum)
        self.powerSpectrum.plot(*self.signal.getPowerSpectrum())

        self.signal.computeCepstrum()

        self.l.addWidget(QLabel("Cepstrum"))
        self.Cepstrum = pg.PlotWidget()
        self.l.addWidget(self.Cepstrum)
        self.Cepstrum.plot(*self.signal.getCepsturm())

        #######################
        ### Compute some parameters
        #######################
        print(F0fromCycles(self.signal.T))
        print(jitterPercent(self.signal.T))
        print(shimmerPercent(self.signal.A))
        print(
            cepstralPeakProminence(self.signal.raw_signal, 1 / self.signal.dt))

        self.setWindowTitle("Analysis Platform")
예제 #21
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(243, 306)

        self.centralwidget = PyQt5.QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.frame = PyQt5.QtWidgets.QFrame(self.centralwidget)
        self.frame.setGeometry(PyQt5.QtCore.QRect(0, 0, 700, 500))

        self.layoutWidget = PyQt5.QtWidgets.QWidget(self.frame)
        self.layoutWidget.setGeometry(PyQt5.QtCore.QRect(10, 10, 690, 490))
        self.layoutWidget.setObjectName("layoutWidget")

        self.h_layout = PyQt5.QtWidgets.QHBoxLayout(self.layoutWidget)
        self.v_layout_1 = PyQt5.QtWidgets.QVBoxLayout()

        """ add plot to the layout """
        self.plot_T = pg.PlotWidget(self.layoutWidget)
        self.plot_T.setObjectName("plot_T")
        self.v_layout_1.addWidget(self.plot_T)

        self.v_layout_3 = PyQt5.QtWidgets.QVBoxLayout()

        """ Fill up with elements """
        self.v_layout_3.addStretch()

        self.sizePolicy = PyQt5.QtWidgets.QSizePolicy(PyQt5.QtWidgets.QSizePolicy.Preferred, PyQt5.QtWidgets.QSizePolicy.Fixed)
        self.sizePolicy.setHorizontalStretch(0)
        self.sizePolicy.setVerticalStretch(0)

        """Create buttons according to List_Of_Servers.py and pack them into a dictionary"""
        self.buttons_dict = {}
        for i in LoS.server_list.keys():
            self.button = PyQt5.QtWidgets.QPushButton(self.layoutWidget)
            self.button.setText(str(i))
            self.sizePolicy.setHeightForWidth(self.button.sizePolicy().hasHeightForWidth())
            self.button.setSizePolicy(self.sizePolicy)
            self.button.setStyleSheet(f"background-color: gray;color: {LoS.server_list[i][5]}")
            self.buttons_dict[i] = self.button
            self.v_layout_3.addWidget(self.button)
            self.button.setObjectName("button_"+i)
            self.v_layout_3.addStretch()

        """ LOAD button """
        self.load_button = PyQt5.QtWidgets.QPushButton(self.layoutWidget)
        self.load_button.setGeometry(PyQt5.QtCore.QRect(500, 300, 50, 50))
        self.v_layout_3.addWidget(self.load_button)
        self.load_button.setText("Load LOG")
        self.v_layout_3.addStretch()

        self.label_1 = PyQt5.QtWidgets.QLabel(self.layoutWidget)
        self.label_1.setText("Number of points")
        self.label_1.setGeometry(PyQt5.QtCore.QRect(500, 20, 50, 50))
        self.label_1.setFixedWidth
        self.sizePolicy.setHeightForWidth(self.label_1.sizePolicy().hasHeightForWidth())
        self.label_1.setSizePolicy(self.sizePolicy)
        self.label_1.setAlignment(PyQt5.QtCore.Qt.AlignCenter)
        self.v_layout_3.addWidget(self.label_1)

        self.lineEdit_1 = PyQt5.QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_1.setText("10")
        self.lineEdit_1.setGeometry(PyQt5.QtCore.QRect(500, 20, 50, 50))
        self.lineEdit_1.setFixedWidth
        self.sizePolicy.setHeightForWidth(self.lineEdit_1.sizePolicy().hasHeightForWidth())
        self.lineEdit_1.setSizePolicy(self.sizePolicy)
        self.lineEdit_1.setAlignment(PyQt5.QtCore.Qt.AlignCenter)
        self.v_layout_3.addWidget(self.lineEdit_1)
        self.v_layout_3.addStretch()

        self.label_2 = PyQt5.QtWidgets.QLabel(self.layoutWidget)
        self.label_2.setText("Channel to monitor")
        self.label_2.setGeometry(PyQt5.QtCore.QRect(500, 20, 50, 50))
        self.label_2.setFixedWidth
        self.sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())
        self.label_2.setSizePolicy(self.sizePolicy)
        self.label_2.setAlignment(PyQt5.QtCore.Qt.AlignCenter)
        self.v_layout_3.addWidget(self.label_2)

        self.lineEdit_2 = PyQt5.QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_2.setText("1")
        self.lineEdit_2.setGeometry(PyQt5.QtCore.QRect(500, 100, 50, 50))
        self.lineEdit_2.setFixedWidth
        self.sizePolicy.setHeightForWidth(self.lineEdit_2.sizePolicy().hasHeightForWidth())
        self.lineEdit_2.setSizePolicy(self.sizePolicy)
        self.lineEdit_2.setAlignment(PyQt5.QtCore.Qt.AlignCenter)
        self.v_layout_3.addWidget(self.lineEdit_2)

        self.label_3 = PyQt5.QtWidgets.QLabel(self.layoutWidget)
        self.label_3.setText("Channel name")
        self.label_3.setGeometry(PyQt5.QtCore.QRect(500, 20, 50, 50))
        self.label_3.setFixedWidth
        self.sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
        self.label_3.setSizePolicy(self.sizePolicy)
        self.label_3.setAlignment(PyQt5.QtCore.Qt.AlignCenter)
        self.v_layout_3.addWidget(self.label_3)

        self.h_layout.addLayout(self.v_layout_1)
        self.h_layout.addLayout(self.v_layout_3)

        self.setLayout(self.h_layout)

        gc.collect()
예제 #22
0
 def init_ui(self):
     self._pw = pg.PlotWidget(title='平安银行')
     hLayout = QHBoxLayout()
     hLayout.addWidget(self._pw)
     self.setLayout(hLayout)
예제 #23
0
    def __init__(self,
                 scatter_widget,
                 parent=None,
                 _="None",
                 view_box=InteractiveViewBox):
        gui.OWComponent.__init__(self, scatter_widget)
        self.view_box = view_box(self)
        self.plot_widget = pg.PlotWidget(viewBox=self.view_box,
                                         parent=parent,
                                         background="w")
        self.plot_widget.getPlotItem().buttonsHidden = True
        self.plot_widget.setAntialiasing(True)
        self.plot_widget.sizeHint = lambda: QSize(500, 500)
        scene = self.plot_widget.scene()
        self._create_drag_tooltip(scene)
        self._data = (
            None
        )  # Original Table as passed from widget to new_data before transformations

        self.replot = self.plot_widget.replot
        ScaleScatterPlotData.__init__(self)
        self.density_img = None
        self.scatterplot_item = None
        self.scatterplot_item_sel = None
        self.reg_line_item = None

        self.labels = []

        self.master = scatter_widget
        self.master.Warning.add_message(
            "missing_coords",
            "Plot cannot be displayed because '{}' or '{}' is missing for "
            "all data points",
        )
        self.master.Information.add_message(
            "missing_coords",
            "Points with missing '{}' or '{}' are not displayed")
        self.master.Information.add_message(
            "missing_size",
            "Points with undefined '{}' are shown in smaller size")
        self.master.Information.add_message(
            "missing_shape",
            "Points with undefined '{}' are shown as crossed circles")
        self.shown_attribute_indices = []
        self.shown_x = self.shown_y = None
        self.pen_colors = self.brush_colors = None

        self.valid_data = None  # np.ndarray
        self.selection = None  # np.ndarray
        self.n_points = 0

        self.gui = OWPlotGUI(self)
        self.continuous_palette = ContinuousPaletteGenerator(
            QColor(255, 255, 0), QColor(0, 0, 255), True)
        self.discrete_palette = ColorPaletteGenerator()

        self.selection_behavior = 0

        self.legend = self.color_legend = None
        self.__legend_anchor = (1, 0), (1, 0)
        self.__color_legend_anchor = (1, 1), (1, 1)

        self.scale = None  # DiscretizedScale

        self.subset_indices = None

        # self.setMouseTracking(True)
        # self.grabGesture(QPinchGesture)
        # self.grabGesture(QPanGesture)

        self.update_grid()

        self._tooltip_delegate = HelpEventDelegate(self.help_event)
        self.plot_widget.scene().installEventFilter(self._tooltip_delegate)
예제 #24
0
# Grapichs Layout
#############################
app = QtGui.QApplication([])
win = QtGui.QMainWindow()
#app.setStyleSheet(qdarkstyle.load_stylesheet_pyside())
win.setWindowTitle('Electrooculograma')
win.resize(1000, 600)
pg.setConfigOptions(antialias=True)

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

fig2 = pg.PlotWidget(
    title=
    '<div style="text-align: center;"><span style="color: #FF0; font-size: 14pt;">Electrooculograma</span></div>'
)
fig2.setLabel(axis="bottom", text="Tiempo", units="s")
fig2.setLabel(axis="left", text="Amplitud", units="V")
fig2.setLabel(
    axis="top",
    text='<span style="color: #FF0; font-size: 12pt;">Señales Eléctricas</span>'
)
fig2.setYRange(0, 3.3)
fig2.showGrid(x=True, y=True)
fig2.addLegend()

lineR = pg.InfiniteLine(movable=True, label="T1")
lineG = pg.InfiniteLine(movable=True, label="T2")
fig2.addItem(lineG)
fig2.addItem(lineR)
예제 #25
0
    def __init__(self, device=None):
        QWidget.__init__(self)
        self.p = device  # connection to the device hardware
        self.p.set_pv1(0)
        self.traceCols = utils.makeTraceColors()

        self.pwin = pg.PlotWidget()  #pyqtgraph window
        self.pwin.showGrid(x=True, y=True)  # with grid
        ax = self.pwin.getAxis('bottom')
        ax.setLabel(self.tr('Voltage (V) -> Current -> Magnetic Field(B)'))
        ax = self.pwin.getAxis('left')
        ax.setLabel(self.tr('Magnetic Field (H)'))
        self.pwin.disableAutoRange()
        self.pwin.setXRange(self.VMIN, self.VMAX)
        self.pwin.setYRange(self.ZMIN, self.ZMAX)
        self.pwin.hideButtons()  # Do not show the 'A' button of pg

        right = QVBoxLayout()  # right side vertical layout
        right.setAlignment(Qt.AlignTop)
        right.setSpacing(self.RPGAP)

        b = QPushButton(self.tr("Start"))
        right.addWidget(b)
        b.clicked.connect(self.start)

        b = QPushButton(self.tr("Stop"))
        right.addWidget(b)
        b.clicked.connect(self.stop)

        b = QPushButton(self.tr("Set Zero"))
        right.addWidget(b)
        b.clicked.connect(self.zero)

        b = QPushButton(self.tr("Clear Traces"))
        right.addWidget(b)
        b.clicked.connect(self.clear)

        self.SaveButton = QPushButton(self.tr("Save Data"))
        self.SaveButton.clicked.connect(self.save_data)
        right.addWidget(self.SaveButton)

        #------------------------end of right panel ----------------

        top = QHBoxLayout()
        top.addWidget(self.pwin)
        top.addLayout(right)

        full = QVBoxLayout()
        full.addLayout(top)
        self.msgwin = QLabel(text='')
        full.addWidget(self.msgwin)

        self.setLayout(full)

        self.timer = QTimer()
        self.timer.timeout.connect(self.update)
        self.timer.start(self.TIMER)

        self.t = MPU925x.connect(self.p.I2C)
        self.t.initMagnetometer()
        self.zero = 0
        if MPU925x.MPU925x.ADDRESS not in self.p.I2C.scan():
            self.msg(self.tr('MPU925x Sensor Not Found'))
예제 #26
0
파일: view.py 프로젝트: fuhsy/isysozen
    def __init__(self, *args):
        self.app = QApplication(sys.argv)
        super(QMainWindow, self).__init__()
        # self.theme = audio_theme.AudioTheme('water')
        # rgba(126,177,119,255)
        super(QMainWindow, self).setStyleSheet(
            "QMainWindow {background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(156,207,149), stop:1 rgb(158,216,245));border: 1px solid black;}"
            # "QPushButton {background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(152,206,185), stop:1 rgb(172,226,205));color: rgba(192,246,225);border-radius:5px;}"
            # "QPushButton {background-color: rgb(152,206,185);color: rgb(255,255,255);border-radius:5px;}"
            "QPushButton {background-color: rgb(237,185,119);border-radius:5px;}"
            "QPushButton:disabled{ color: 'gray' ;}"
            "QPushButton:enabled{ color: 'white' ;}"
            "QListWidget {background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(152,206,185), stop:1 rgb(172,226,205));color: rgba(255,255,255,255);}"
            "QCheckBox {background-color: rgba(101,156,151,255);border: solid;border-radius:5px;}"
            "QLabel {color: rgba(255,255,255,255);}"
            "QAbstractItemView{background: rgba(101,156,151,255);}"
            "QComboBox {background-color: rgba(152,206,185,255);editable: rgba(152,206,185,255);color: rgba(255,255,255,255);}"
            "QSpinBox {background-color: rgba(152,206,185,255);color: rgba(255,255,255,255);}"
        )
        #self.setWindowFlags(QtCore.Qt.CustomizeWindowHint)
        #super(QMainWindow, self).setStyleSheet("QPushButton {background-color: 'green';border-color: beige;}")
        self.fps = 50
        # print pa_get_output_max_channels(4)
        #Lowest snapshot threshold for starting detection

        self.brightness_value_min = 1.2
        self.brightness_value_max = 1.45
        self.smooth_mean_dif = []
        self.brightness = 0
        self.brightness_plt = []
        self.sampleinterval = 0.1
        self.brightness_v = 0
        self.timewindow = 10
        self.size = (1920, 1080)
        self.layout = QGridLayout()
        # self.w = QWidget()
        self.pic = QLabel()
        self.video_frame = QLabel()
        self.select_audio_output = QComboBox()
        self.select_camera = QComboBox()
        self.audio_submit = QPushButton('Audio Device Connect')
        self.audio_submit.setToolTip(
            'Select an audio Source: \n 2-Chanel or 4-Channel speakers are supported'
        )
        self.detector_amount = QSpinBox()
        self.min_detectors = 1
        self.max_detectors = 5
        self.detector_amount.setMinimum(self.min_detectors)
        self.detector_amount.setMaximum(self.max_detectors)
        self.detector_amount.setAlignment(QtCore.Qt.AlignRight)
        self.button_start = QPushButton('Camera Connect')
        self.button_start.setToolTip('Connect to selected Camera')
        self.button_start_default = QPushButton('Start Computer GUI')
        self.button_listen_task = QPushButton('Listening Task')
        self.button_listen_task_2 = QPushButton('Listening Task 2')
        self.button_load_cal = QPushButton('Load Calibration')
        self.button_load_cal.setToolTip('Load latest saved Calibration')
        self.button_stop = QPushButton('Pause/Play')
        self.save_btn = QPushButton('Save Dataset')
        self.save_text = QLineEdit('User ID')
        self.button_play = QPushButton('Start')
        self.button_play.setToolTip('Stop/Play the current soundscape.')
        self.button_play.setToolTip('Starts Playing the Soundscape')
        self.button_reset = QPushButton('Reset Scene')
        self.button_reset.setToolTip(
            'If you want to rearrange the Zen Garden press here and the Scene will automatically rerendered'
        )
        self.button_new_cal = QPushButton('New Calibration')
        self.button_new_cal.setToolTip(
            'Please Click on the Corners of the Zen Garden to crop the image.\n 1.Left-Top Corner 2.Right-Top-Corner 3. Right-Bottom-Corner 4. Left-Bottom Corner '
        )
        self.auto_checkbox = QCheckBox('Auto Slider')
        self.slider1 = QSlider(QtCore.Qt.Horizontal)
        self.slider2 = QSlider(QtCore.Qt.Horizontal)
        self.slider3 = QSlider(QtCore.Qt.Horizontal)
        self.contour_slider = QSlider(QtCore.Qt.Horizontal)
        self.maxVolume_slider = QSlider(QtCore.Qt.Horizontal)
        self.txtslider1 = QLabel('Radius of Circle')
        self.txtslider1.setToolTip(
            'Set the radius of contour detection for sonic anchor')
        self.txtslider2 = QLabel('Speed ' + str(self.fps) + ' fps')
        self.txtslider2.setToolTip('Set the speed of the Sonic Anchor')
        self.txtslider3 = QLabel('Detecting Angle')
        self.txtslider3.setToolTip(
            'Set the detection angle in dircetion of movement')
        self.contour_slider_txt = QLabel('Contour Detection')
        self.contour_slider_txt.setToolTip(
            'Setup the Contour Detection from canny to rough')
        self.maxVolume_slider_txt = QLabel('Max Volume: 80%')
        self.detector_amount_txt = QLabel(
            '                                             Amount of Detectors')

        self.plt = pg.PlotWidget(title='Lightning Conditions')
        self.plt.setFixedWidth(300)
        self.plt.setRange(yRange=[0.9, 1.8])
        self.plt.resize(*self.size)
        self.plt.showGrid(x=True, y=True)
        self.plt.setLabel('left', 'Brightness')

        self.slider1.setFixedWidth(300)
        self.slider1.setRange(5, 45)
        self.slider2.setFixedWidth(300)
        self.slider2.setRange(1, 100)
        self.slider3.setFixedWidth(300)
        self.slider3.setRange(2, 120)
        self.contour_slider.setFixedWidth(300)
        self.contour_slider.setRange(0, 40)
        self.txtslider1.setFixedWidth(300)
        self.txtslider2.setFixedWidth(300)
        self.txtslider3.setFixedWidth(300)
        self.contour_slider_txt.setFixedWidth(300)
        self.maxVolume_slider_txt.setFixedWidth(300)
        self.maxVolume_slider.setFixedWidth(300)
        self.detector_amount_txt.setFixedWidth(300)
        self.save_btn.setFixedWidth(300)
        self.save_text.setFixedWidth(300)
        self.button_start_default.setFixedWidth(300)
        self.button_stop.setFixedWidth(300)
        self.button_play.setFixedWidth(300)
        self.button_reset.setFixedWidth(300)
        self.button_listen_task.setFixedWidth(300)
        self.button_listen_task_2.setFixedWidth(300)
        self.select_audio_output.setFixedWidth(300)
        self.select_camera.setFixedWidth(300)
        self.audio_submit.setFixedWidth(300)
        self.audio_submit.setFixedHeight(70)
        self.audio_submit.setStyleSheet("QPushButton {border-radius: 30px;}")
        self.detector_amount.setFixedWidth(150)
        # self.select_theme.setFixedWidth(300)
        self.button_start.setFixedWidth(300)
        self.button_start.setFixedHeight(70)
        self.button_start.setStyleSheet("QPushButton {border-radius: 30px;}")
        self.button_load_cal.setFixedWidth(300)
        self.button_new_cal.setFixedWidth(300)
        self.listw = QListWidget()
        self.listw.setFixedWidth(300)
        self.separatorLine = QFrame()
        self.separatorLine.setFrameShape(QFrame.HLine)
        self.separatorLine.setFrameShadow(QFrame.Raised)
        self.separatorLine2 = QFrame()
        self.separatorLine2.setFrameShape(QFrame.HLine)
        self.separatorLine2.setFrameShadow(QFrame.Raised)
        #self.plot = pg.PlotWidget()
        self.layout.setMargin(10)
        self.widget_pos = 0
        self.layout.addWidget(self.audio_submit, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.select_audio_output, self.widget_pos, 0)
        self.widget_pos += 2
        self.layout.addWidget(self.maxVolume_slider_txt, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.maxVolume_slider, self.widget_pos, 0)
        self.widget_pos += 3
        self.layout.addWidget(self.separatorLine, self.widget_pos, 0)
        self.widget_pos += 1

        self.layout.addWidget(self.button_start, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.select_camera, self.widget_pos, 0)
        self.widget_pos += 3
        self.layout.addWidget(self.separatorLine2, self.widget_pos, 0)
        self.widget_pos += 3
        # self.layout.addWidget(self.button_start_default,self.widget_pos,0)
        # self.widget_pos+=1
        # self.layout.addWidget(self.button_listen_task,self.widget_pos,0)
        # self.widget_pos+=1
        # self.layout.addWidget(self.button_listen_task_2,self.widget_pos,0)
        # self.widget_pos+=1

        # self.layout.addWidget(self.select_theme,self.widget_pos,0)
        # self.widget_pos+=1
        self.layout.addWidget(self.detector_amount_txt, self.widget_pos, 0)
        self.layout.addWidget(self.detector_amount, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.button_new_cal, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.button_load_cal, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.button_stop, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.button_play, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.button_reset, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.contour_slider_txt, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.contour_slider, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.txtslider1, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.slider1, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.txtslider2, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.slider2, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.txtslider3, self.widget_pos, 0)
        self.widget_pos += 1
        self.layout.addWidget(self.slider3, self.widget_pos, 0)
        self.widget_pos += 1
        # self.layout.addWidget(self.save_btn, self.widget_pos, 0)
        # self.widget_pos+=1
        # self.layout.addWidget(self.save_text, self.widget_pos, 0)
        # self.widget_pos+=1
        self.layout.addWidget(self.listw, self.widget_pos, 0)
        self.widget_pos += 1
        # self.connect(self, QtCore.SIGNAL('triggered()'), self.closeEvent)
        self.layout.addWidget(self.pic, 0, 1, self.widget_pos, 1)
        self.layout.addWidget(self.video_frame, 0, 1, self.widget_pos, 1)
        self.im = cv2.imread("../images/default/export.jpg")
        self.im_show = None
        self.button_start.setEnabled(False)
        self.button_start_default.setEnabled(False)
        self.button_load_cal.setEnabled(False)
        self.button_new_cal.setEnabled(False)
        self.button_listen_task.setEnabled(False)
        self.button_listen_task_2.setEnabled(False)
        # self.button_start_default.setEnabled(False)
        self.button_stop.setEnabled(False)
        self.button_play.setEnabled(False)
        self.button_reset.setEnabled(False)
        self.detector_amount.setEnabled(False)
        self.contour_slider.setEnabled(False)
        self.audio_controller = None
        self.select_audio_output.setEnabled(False)
        self.save_btn.setEnabled(False)
        # self.select_theme.setEnabled(False)
        self.slider1.setEnabled(False)
        self.slider2.setEnabled(False)
        self.slider3.setEnabled(False)
        self.button_reset.setEnabled(False)
        self.controller = None

        self.setCentralWidget(QWidget(self))
        self.centralWidget().setLayout(self.layout)
        self.show()
예제 #27
0
w1_other.addWidget(widgets["horusUploadSelector"], 1, 1, 1, 1)
w1_other.addWidget(widgets["horusUDPLabel"], 2, 0, 1, 1)
w1_other.addWidget(widgets["horusUDPEntry"], 2, 1, 1, 1)
w1_other.addWidget(widgets["ozimuxUploadLabel"], 3, 0, 1, 1)
w1_other.addWidget(widgets["ozimuxUploadSelector"], 3, 1, 1, 1)
w1_other.addWidget(widgets["ozimuxUDPLabel"], 4, 0, 1, 1)
w1_other.addWidget(widgets["ozimuxUDPEntry"], 4, 1, 1, 1)
w1_other.addWidget(widgets["otherHeaderLabel"], 5, 0, 1, 2)
w1_other.addWidget(widgets["inhibitCRCLabel"], 6, 0, 1, 1)
w1_other.addWidget(widgets["inhibitCRCSelector"], 6, 1, 1, 1)
w1_other.layout.setRowStretch(7, 1)

d0_other.addWidget(w1_other)

# Spectrum Display
widgets["spectrumPlot"] = pg.PlotWidget(title="Spectra")
widgets["spectrumPlot"].setLabel("left", "Power (dB)")
widgets["spectrumPlot"].setLabel("bottom", "Frequency (Hz)")
widgets["spectrumPlotData"] = widgets["spectrumPlot"].plot([0])

# Frequency Estiator Outputs
widgets["estimatorLines"] = [
    pg.InfiniteLine(
        pos=-1000,
        pen=pg.mkPen(color="w", width=2, style=QtCore.Qt.DashLine),
        label="F1",
        labelOpts={'position':0.9}
    ),
    pg.InfiniteLine(
        pos=-1000,
        pen=pg.mkPen(color="w", width=2, style=QtCore.Qt.DashLine),
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(1480, 884)
        self.runContButton = QtWidgets.QPushButton(Dialog)
        self.runContButton.setGeometry(QtCore.QRect(1320, 770, 131, 31))
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.runContButton.setFont(font)
        self.runContButton.setCheckable(False)
        self.runContButton.setDefault(False)
        self.runContButton.setFlat(False)
        self.runContButton.setObjectName("runContButton")
        self.stopRunButton = QtWidgets.QPushButton(Dialog)
        self.stopRunButton.setGeometry(QtCore.QRect(1320, 810, 131, 31))
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.stopRunButton.setFont(font)
        self.stopRunButton.setObjectName("stopRunButton")
        self.startFreqEdit = QtWidgets.QTextEdit(Dialog)
        self.startFreqEdit.setGeometry(QtCore.QRect(920, 800, 111, 31))
        self.startFreqEdit.setObjectName("startFreqEdit")
        self.label = QtWidgets.QLabel(Dialog)
        self.label.setGeometry(QtCore.QRect(920, 780, 111, 20))
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.line = QtWidgets.QFrame(Dialog)
        self.line.setGeometry(QtCore.QRect(0, 720, 1481, 21))
        self.line.setFrameShape(QtWidgets.QFrame.HLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line.setObjectName("line")
        self.label_2 = QtWidgets.QLabel(Dialog)
        self.label_2.setGeometry(QtCore.QRect(1050, 780, 111, 16))
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.label_3 = QtWidgets.QLabel(Dialog)
        self.label_3.setGeometry(QtCore.QRect(1180, 780, 111, 16))
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.stepFreqEdit = QtWidgets.QTextEdit(Dialog)
        self.stepFreqEdit.setGeometry(QtCore.QRect(1050, 800, 111, 31))
        self.stepFreqEdit.setObjectName("stepFreqEdit")
        self.stopFreqEdit = QtWidgets.QTextEdit(Dialog)
        self.stopFreqEdit.setGeometry(QtCore.QRect(1180, 800, 111, 31))
        self.stopFreqEdit.setObjectName("stopFreqEdit")
        self.checkBox = QtWidgets.QCheckBox(Dialog)
        self.checkBox.setGeometry(QtCore.QRect(1340, 840, 101, 41))
        font = QtGui.QFont()
        font.setPointSize(10)
        self.checkBox.setFont(font)
        self.checkBox.setObjectName("checkBox")
        self.connectButton = QtWidgets.QPushButton(Dialog)
        self.connectButton.setGeometry(QtCore.QRect(30, 840, 131, 31))
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.connectButton.setFont(font)
        self.connectButton.setCheckable(False)
        self.connectButton.setDefault(True)
        self.connectButton.setFlat(False)
        self.connectButton.setObjectName("connectButton")
        self.refreshButton = QtWidgets.QPushButton(Dialog)
        self.refreshButton.setGeometry(QtCore.QRect(30, 800, 131, 31))
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.refreshButton.setFont(font)
        self.refreshButton.setCheckable(False)
        self.refreshButton.setFlat(False)
        self.refreshButton.setObjectName("refreshButton")
        self.label_4 = QtWidgets.QLabel(Dialog)
        self.label_4.setGeometry(QtCore.QRect(30, 770, 131, 20))
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_4.setFont(font)
        self.label_4.setAlignment(QtCore.Qt.AlignCenter)
        self.label_4.setObjectName("label_4")
        self.comPortEdit = QtWidgets.QComboBox(
            Dialog)  #QtWidgets.QTextEdit(Dialog)
        self.comPortEdit.setGeometry(QtCore.QRect(30, 760, 131, 31))
        self.comPortEdit.setObjectName("comPortEdit")
        self.plot_tabWidget = QtWidgets.QTabWidget(Dialog)
        self.plot_tabWidget.setGeometry(QtCore.QRect(40, 50, 1401, 641))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.plot_tabWidget.setFont(font)
        self.plot_tabWidget.setObjectName("plot_tabWidget")
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")
        self.plot_tabWidget.addTab(self.tab, "")
        self.tab_2 = QtWidgets.QWidget()
        self.tab_2.setObjectName("tab_2")
        self.tab_3 = QtWidgets.QWidget()
        self.tab_3.setObjectName("tab_3")
        self.tab_4 = QtWidgets.QWidget()
        self.tab_4.setObjectName("tab_4")
        self.freqIndexSpinbox = QtWidgets.QSpinBox(self.tab_2)
        self.freqIndexSpinbox.setGeometry(QtCore.QRect(640, 40, 141, 51))
        font = QtGui.QFont()
        font.setPointSize(14)
        self.freqIndexSpinbox.setFont(font)
        self.freqIndexSpinbox.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.freqIndexSpinbox.setObjectName("freqIndexSpinbox")
        self.ringBox = QtWidgets.QComboBox(self.tab_2)
        self.ringBox.setGeometry(QtCore.QRect(230, 40, 211, 51))
        font = QtGui.QFont()
        font.setPointSize(14)
        self.ringBox.setFont(font)
        self.ringBox.setObjectName("ringBox")
        self.avgCountSpinbox = QtWidgets.QSpinBox(self.tab_2)
        self.avgCountSpinbox.setGeometry(QtCore.QRect(470, 40, 141, 51))
        font = QtGui.QFont()
        font.setPointSize(14)
        self.avgCountSpinbox.setFont(font)
        self.avgCountSpinbox.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.avgCountSpinbox.setObjectName("avgCountSpinbox")
        self.label_12 = QtWidgets.QLabel(self.tab_2)
        self.label_12.setGeometry(QtCore.QRect(430, 10, 211, 31))
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.label_12.setFont(font)
        self.label_12.setAlignment(QtCore.Qt.AlignCenter)
        self.label_12.setObjectName("label_12")
        #self.ringBox.addItem("")
        #self.ringBox.addItem("")
        #self.ringBox.addItem("")
        #self.ringBox.addItem("")
        #self.ringBox.addItem("")
        #self.ringBox.addItem("")
        #self.ringBox.addItem("")
        #self.ringBox.addItem("")
        #self.ringBox.addItem("")
        self.label_7 = QtWidgets.QLabel(self.tab_2)
        self.label_7.setGeometry(QtCore.QRect(230, 10, 211, 31))
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.label_7.setFont(font)
        self.label_7.setAlignment(QtCore.Qt.AlignCenter)
        self.label_7.setObjectName("label_7")
        self.label_8 = QtWidgets.QLabel(self.tab_2)
        self.label_8.setGeometry(QtCore.QRect(600, 10, 211, 31))
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.label_8.setFont(font)
        self.label_8.setAlignment(QtCore.Qt.AlignCenter)
        self.label_8.setObjectName("label_8")
        self.label_9 = QtWidgets.QLabel(self.tab_2)
        self.label_9.setGeometry(QtCore.QRect(790, 10, 221, 31))
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.label_9.setFont(font)
        self.label_9.setAlignment(QtCore.Qt.AlignCenter)
        self.label_9.setObjectName("label_9")
        self.freqValueText = QtWidgets.QTextEdit(self.tab_2)
        self.freqValueText.setGeometry(QtCore.QRect(810, 40, 171, 51))
        font = QtGui.QFont()
        font.setPointSize(14)
        self.freqValueText.setFont(font)
        self.freqValueText.setReadOnly(True)
        self.freqValueText.setAcceptRichText(True)
        self.freqValueText.setObjectName("freqValueText")
        self.plot_tabWidget.addTab(self.tab_2, "")
        self.plot_tabWidget.addTab(self.tab_3, "")
        self.plot_tabWidget.addTab(self.tab_4, "")
        self.label_5 = QtWidgets.QLabel(Dialog)
        self.label_5.setGeometry(QtCore.QRect(440, 740, 211, 20))
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_5.setFont(font)
        self.label_5.setAlignment(QtCore.Qt.AlignCenter)
        self.label_5.setObjectName("label_5")
        self.label_6 = QtWidgets.QLabel(Dialog)
        self.label_6.setGeometry(QtCore.QRect(10, 10, 1441, 31))
        font = QtGui.QFont()
        font.setPointSize(18)
        font.setBold(True)
        font.setWeight(75)
        self.label_6.setFont(font)
        self.label_6.setAlignment(QtCore.Qt.AlignCenter)
        self.label_6.setObjectName("label_6")

        # plot widgets
        pg.setConfigOption('background', 'w')
        pg.setConfigOption('foreground', 'k')
        self.plot1_tab1 = pg.PlotWidget(self.tab,
                                        title='Magnitude',
                                        labels={
                                            'left': 'Real',
                                            'bottom': 'Frequency [Hz]'
                                        })
        self.plot1_tab1.setGeometry(QtCore.QRect(50, 75, 630, 516))
        self.plot1_tab1.setObjectName("plot1_tab1")
        self.plot2_tab1 = pg.PlotWidget(self.tab,
                                        title='Phase',
                                        labels={
                                            'left': 'Imag',
                                            'bottom': 'Frequency [Hz]'
                                        })
        self.plot2_tab1.setGeometry(QtCore.QRect(715, 75, 630, 516))
        self.plot2_tab1.setObjectName("plot2_tab1")

        self.plot1_tab2 = pg.PlotWidget(self.tab_2, title='Impedance')
        self.plot1_tab2.setGeometry(QtCore.QRect(50, 107, 1300, 466))
        self.plot1_tab2.setObjectName("plot1_tab2")

        # Tab 3 stuff
        self.smithchart_tab3 = pp.figure(figsize=(5, 3))
        pp.ion()
        self.smithcanvas = FigureCanvas(self.smithchart_tab3)
        layout = QtGui.QGridLayout()  #QHBoxLayout()
        layout.addWidget(self.smithcanvas, 0, 0, 1, 1)
        sp.SmithAxes.scDefaultParams['axes.impedance'] = 100
        self.smith_ax = self.smithchart_tab3.add_subplot(111,
                                                         projection='smith')
        self.z0_Label = QLabel("Z0 [Ohms] =  ")
        self.z0_Label.setObjectName("z0_Label")
        self.z0_Edit = QtWidgets.QLineEdit("100")
        self.z0_Edit.setObjectName("z0_Edit")
        layout.addWidget(self.z0_Label, 1, 0, 1, 1, Qt.AlignRight)
        layout.addWidget(self.z0_Edit, 1, 1, 1, 1, Qt.AlignLeft)
        layout.setHorizontalSpacing(1)
        self.smithchart_tab3.tight_layout()
        layout.setColumnStretch(0, 2)
        self.plot2_tab3 = pg.PlotWidget(title='S11',
                                        labels={
                                            'left': 'S11 [dB]',
                                            'bottom': 'Frequency [Hz]'
                                        })
        self.plot2_tab3.setGeometry(QtCore.QRect(715, 75, 630, 516))
        self.plot2_tab3.setObjectName("plot2_tab3")
        layout.addWidget(self.plot2_tab3, 0, 1, 1, 1)
        self.smithPlotButton = QtWidgets.QPushButton("Update Smith Chart")
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        self.smithPlotButton.setCheckable(False)
        self.smithPlotButton.setFlat(False)
        self.smithPlotButton.setObjectName("smithPlotButton")
        layout.addWidget(self.smithPlotButton, 1, 0, 1, 1, Qt.AlignCenter)
        self.smithPlotWebButton = QtWidgets.QPushButton("Save Plot")
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.smithPlotWebButton.setFont(font)
        self.smithPlotWebButton.setCheckable(False)
        self.smithPlotWebButton.setFlat(False)
        self.smithPlotWebButton.setObjectName("smithPlotButton")
        layout.addWidget(self.smithPlotWebButton, 1, 0, 1, 1, Qt.AlignLeft)
        self.toggleS11PlotButton = QtWidgets.QPushButton("Toggle Z'' vs Z' On")
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.toggleS11PlotButton.setFont(font)
        self.toggleS11PlotButton.setCheckable(False)
        self.toggleS11PlotButton.setFlat(False)
        self.toggleS11PlotButton.setObjectName("toggleS11PlotButton")
        layout.addWidget(self.toggleS11PlotButton, 1, 1, 1, 1, Qt.AlignRight)
        self.tab_3.setLayout(layout)

        # Tab 4 stuff
        self.plot1_tab4 = pg.PlotWidget(title="",
                                        labels={
                                            'left': "Z' [Ohm]",
                                            'bottom': 'Time [sec]'
                                        })
        self.plot1_tab4.setGeometry(QtCore.QRect(715, 75, 630, 516))
        self.plot1_tab4.setObjectName("plot1_tab4")
        self.plot2_tab4 = pg.PlotWidget(title="",
                                        labels={
                                            'left': "Z' [Ohm]",
                                            'bottom': 'Time [sec]'
                                        })
        self.plot2_tab4.setGeometry(QtCore.QRect(715, 75, 630, 516))
        self.plot2_tab4.setObjectName("plot2_tab4")
        self.plot3_tab4 = pg.PlotWidget(title="",
                                        labels={
                                            'left': "Z' [Ohm]",
                                            'bottom': 'Time [sec]'
                                        })
        self.plot3_tab4.setGeometry(QtCore.QRect(715, 75, 630, 516))
        self.plot3_tab4.setObjectName("plot3_tab4")
        self.plot4_tab4 = pg.PlotWidget(title="",
                                        labels={
                                            'left': "Z' [Ohm]",
                                            'bottom': 'Time [sec]'
                                        })
        self.plot4_tab4.setGeometry(QtCore.QRect(715, 75, 630, 516))
        self.plot4_tab4.setObjectName("plot4_tab4")

        self.avgCountSpinbox_tab4 = QtWidgets.QSpinBox(self.tab_4)
        font = QtGui.QFont()
        font.setPointSize(16)
        self.avgCountSpinbox_tab4.setFont(font)
        self.avgCountSpinbox_tab4.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.avgCountSpinbox_tab4.setObjectName("avgCountSpinbox_tab4")
        self.label_20 = QtWidgets.QLabel("Avg. Count:")
        font = QtGui.QFont()
        font.setPointSize(16)
        self.label_20.setFont(font)
        self.label_20.setAlignment(QtCore.Qt.AlignCenter)
        self.label_20.setObjectName("label_20")

        self.avgTimeSpinbox_tab4 = QtWidgets.QSpinBox(self.tab_4)
        self.avgTimeSpinbox_tab4.setObjectName("avgTimeSpinbox_tab4")
        self.avgTimeSpinbox_tab4.setFont(font)
        self.label_21 = QtWidgets.QLabel("Time [sec]:")
        font = QtGui.QFont()
        font.setPointSize(16)
        self.label_21.setFont(font)
        self.label_21.setAlignment(QtCore.Qt.AlignCenter)
        self.label_21.setObjectName("label_21")

        self.passLabel = QtWidgets.QLabel("PASS")
        font = QtGui.QFont()
        font.setPointSize(16)
        self.passLabel.setStyleSheet("color: rgb(0,255,0)")
        self.passLabel.setFont(font)
        self.passLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.passLabel.setObjectName("passLabel")

        self.label_30 = QtWidgets.QLabel("--")
        self.label_31 = QtWidgets.QLabel("--")
        self.label_32 = QtWidgets.QLabel("--")
        self.label_33 = QtWidgets.QLabel("--")
        font = QtGui.QFont()
        font.setPointSize(16)

        font = QtGui.QFont()
        font.setPointSize(16)
        self.freq_tab4_plot1_Spinbox_tab4 = QtWidgets.QSpinBox(self.tab_4)
        self.freq_tab4_plot1_Spinbox_tab4.setObjectName(
            "freq_tab4_plot1_Spinbox_tab4")
        self.freq_tab4_plot1_Spinbox_tab4.setFont(font)
        self.freq_tab4_plot2_Spinbox_tab4 = QtWidgets.QSpinBox(self.tab_4)
        self.freq_tab4_plot2_Spinbox_tab4.setObjectName(
            "freq_tab4_plot2_Spinbox_tab4")
        self.freq_tab4_plot2_Spinbox_tab4.setFont(font)
        self.freq_tab4_plot3_Spinbox_tab4 = QtWidgets.QSpinBox(self.tab_4)
        self.freq_tab4_plot3_Spinbox_tab4.setObjectName(
            "freq_tab4_plot3_Spinbox_tab4")
        self.freq_tab4_plot3_Spinbox_tab4.setFont(font)
        self.freq_tab4_plot4_Spinbox_tab4 = QtWidgets.QSpinBox(self.tab_4)
        self.freq_tab4_plot4_Spinbox_tab4.setObjectName(
            "freq_tab4_plot4_Spinbox_tab4")
        self.freq_tab4_plot4_Spinbox_tab4.setFont(font)

        self.zRecordButton = QtWidgets.QPushButton("Turn On Record")
        self.zRecordButton.setCheckable(False)
        self.zRecordButton.setFlat(False)
        self.zRecordButton.setObjectName("zRecordButton")

        self.clearDataButton = QtWidgets.QPushButton("Clear Data")
        self.clearDataButton.setCheckable(False)
        self.clearDataButton.setFlat(False)
        self.clearDataButton.setObjectName("clearDataButton")

        self.toggle_tab4_plotsButton = QtWidgets.QPushButton('Plot Z"')
        self.toggle_tab4_plotsButton.setCheckable(False)
        self.toggle_tab4_plotsButton.setFlat(False)
        self.toggle_tab4_plotsButton.setObjectName("toggle_tab4_plotsButton")

        layout = QtGui.QGridLayout()
        layout.addWidget(self.plot1_tab4, 1, 1, 1, 1)
        layout.addWidget(self.plot2_tab4, 1, 2, 1, 1)
        layout.addWidget(self.plot3_tab4, 1, 3, 1, 1)
        layout.addWidget(self.plot4_tab4, 1, 4, 1, 1)
        layout.addWidget(self.avgCountSpinbox_tab4, 0, 2, 1, 1, Qt.AlignRight)
        layout.addWidget(self.label_20, 0, 2, 1, 1, Qt.AlignCenter)
        layout.addWidget(self.avgTimeSpinbox_tab4, 0, 3, 1, 1, Qt.AlignRight)
        layout.addWidget(self.label_21, 0, 3, 1, 1, Qt.AlignCenter)
        layout.addWidget(self.passLabel, 0, 1, 1, 1, Qt.AlignCenter)
        layout.addWidget(self.freq_tab4_plot1_Spinbox_tab4, 2, 1, 1, 1,
                         Qt.AlignCenter)
        layout.addWidget(self.freq_tab4_plot2_Spinbox_tab4, 2, 2, 1, 1,
                         Qt.AlignCenter)
        layout.addWidget(self.freq_tab4_plot3_Spinbox_tab4, 2, 3, 1, 1,
                         Qt.AlignCenter)
        layout.addWidget(self.freq_tab4_plot4_Spinbox_tab4, 2, 4, 1, 1,
                         Qt.AlignCenter)
        layout.addWidget(self.label_30, 2, 1, 1, 1, Qt.AlignRight)
        layout.addWidget(self.label_31, 2, 2, 1, 1, Qt.AlignRight)
        layout.addWidget(self.label_32, 2, 3, 1, 1, Qt.AlignRight)
        layout.addWidget(self.label_33, 2, 4, 1, 1, Qt.AlignRight)
        layout.addWidget(self.zRecordButton, 0, 4, 1, 1, Qt.AlignRight)
        layout.addWidget(self.clearDataButton, 0, 1, 1, 1, Qt.AlignLeft)
        layout.addWidget(self.toggle_tab4_plotsButton, 2, 1, 1, 1,
                         Qt.AlignLeft)
        self.tab_4.setLayout(layout)

        self.togglePlotButton = QtWidgets.QPushButton(self.tab)
        self.togglePlotButton.setGeometry(QtCore.QRect(585, 10, 220, 51))
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.togglePlotButton.setFont(font)
        self.togglePlotButton.setCheckable(False)
        self.togglePlotButton.setDefault(True)
        self.togglePlotButton.setFlat(False)
        self.togglePlotButton.setObjectName("connectButton")

        self.retranslateUi(Dialog)
        self.plot_tabWidget.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
예제 #29
0
    def functionsTab(self):
        qwidget = QtWidgets.QWidget()
        layout = QtWidgets.QGridLayout()
        qwidget.setLayout(layout)

        # READ SETTINGS
        data = pickle.load(open('settings/lsa_values.pkl', 'rb'), encoding='latin1')
        # with open() as fh:
        print(data.keys())

        # ASSEMBLE ELEMENTS
        row = -1

        x = np.linspace(0, 20 * np.pi, 1000)
        y = np.sin(x)

        row += 1
        pw1 = pg.PlotWidget(title="Momentum [GeV/c]")
        ax1 = pg.PlotDataItem(
            data['t_mom'], data['val_mom'],
            pen=pg.mkPen(color='r', width=2))  # , symbolPen=None, symbolBrush=pg.mkBrush(color='r'), symbolSize=6)
        pw1.addItem(ax1)
        layout.addWidget(pw1, row, 0, 1, 1)

        row += 1
        pw1 = pg.PlotWidget(title="Frequency program - 200 MHz")
        ax1 = pg.PlotDataItem(
            data['t_freq'], data['val_freq'], pen=pg.mkPen(color='y', width=2))
        pw1.addItem(ax1)
        layout.addWidget(pw1, row, 0, 1, 1)

        row += 1
        ww = QtWidgets.QTextEdit()
        layout.addWidget(ww, row, 0, 1, 1)
        # ww.setHtml("""
        # <style> {font-size: 200pt;} </style>
        # <ul>
        # <li> Eta </li>
        # <li> Radial steering as correction </li>
        # <li> Synchrotron frequency </li>
        # </ul>
        # """)
        # ww.setText("""
        # * Eta\n
        # * Radial steering correction\n
        # * Synchrotron frequency""")
        # font = QtGui.QFont('helvetica', 30, QtGui.QFont.Bold)
        # ww.setFont(font)
        # ww.setFontPointSize(80)
        # ww.setMinimumHeight(200)

        # qwidget = pg.PlotWidget(title="Functions")
        # ax1 = pg.PlotDataItem(
        #     x, y, pen=pg.mkPen(color='r', width=2),
        #     symbol='s', symbolPen=None, symbolBrush=pg.mkBrush(color='r'), symbolSize=6)
        # qwidget.addItem(ax1)

        # row += 1
        # layout.addWidget(QtWidgets.QLabel("Cavity 1"), row, 1)
        # layout.addWidget(QtWidgets.QLabel("Cavity 2"), row, 3)
        #
        # row += 1
        # self.c1_enable = JapcToggleButton(self.lsa)
        # self.c2_enable = JapcToggleButton(self.lsa)
        # layout.addWidget(QtWidgets.QLabel("Cavity active", alignment=QtCore.Qt.AlignRight), row, 0)
        # layout.addWidget(self.c1_enable, row, 1)
        # layout.addWidget(self.c2_enable, row, 3)
        #
        # row += 1
        # self.c1_vmin = JapcLineEdit(self.lsa)
        # self.c2_vmin = JapcLineEdit(self.lsa)
        # layout.addWidget(QtWidgets.QLabel("Vmin", alignment=QtCore.Qt.AlignRight), row, 0)
        # layout.addWidget(self.c1_vmin, row, 1)
        # layout.addWidget(self.c2_vmin, row, 3)
        #
        # row += 1
        # self.c1_vmax = JapcLineEdit(self.lsa)
        # self.c2_vmax = JapcLineEdit(self.lsa)
        # layout.addWidget(QtWidgets.QLabel("Vmax", alignment=QtCore.Qt.AlignRight), row, 0)
        # layout.addWidget(self.c1_vmax, row, 1)
        # layout.addWidget(self.c2_vmax, row, 3)
        #
        # row += 1
        # self.c1_polarloop = JapcToggleButton(self.lsa, "SPS800.CavityLoop.c1/PolarLoopPPM#Enable")
        # self.c2_polarloop = JapcToggleButton(self.lsa, "SPS800.CavityLoop.c2/PolarLoopPPM#Enable")
        # layout.addWidget(QtWidgets.QLabel("Polar Loop", alignment=QtCore.Qt.AlignRight), row, 0)
        # layout.addWidget(self.c1_polarloop, row, 1)
        # layout.addWidget(self.c2_polarloop, row, 3)
        #
        # row += 1
        # self.c1_cavityloop = JapcToggleButton(self.lsa, "SPS800.CavityLoop.c1/Operation#Enable")
        # self.c2_cavityloop = JapcToggleButton(self.lsa, "SPS800.CavityLoop.c2/Operation#Enable")
        # layout.addWidget(QtWidgets.QLabel("Cavity Loop", alignment=QtCore.Qt.AlignRight), row, 0)
        # layout.addWidget(self.c1_cavityloop, row, 1)
        # layout.addWidget(self.c2_cavityloop, row, 3)
        #
        # row += 1
        # self.c1_otf = JapcToggleButton(self.lsa, "SPS800.CavityLoop.c1/OneTurnFeedbackPPM#Enable")
        # self.c2_otf = JapcToggleButton(self.lsa, "SPS800.CavityLoop.c2/OneTurnFeedbackPPM#Enable")
        # layout.addWidget(QtWidgets.QLabel("One turn feedback", alignment=QtCore.Qt.AlignRight), row, 0)
        # layout.addWidget(self.c1_otf, row, 1)
        # layout.addWidget(self.c2_otf, row, 3)
        #
        # row += 1
        # self.c1_feedforward = JapcToggleButton(self.lsa, "SPS800.CavityLoop.c1/FeedforwardPPM#Enable")
        # self.c2_feedforward = JapcToggleButton(self.lsa, "SPS800.CavityLoop.c2/FeedforwardPPM#Enable")
        # layout.addWidget(QtWidgets.QLabel("Feedforward", alignment=QtCore.Qt.AlignRight), row, 0)
        # layout.addWidget(self.c1_feedforward, row, 1)
        # layout.addWidget(self.c2_feedforward, row, 3)
        #
        # # FINALIZE LAYOUT
        # layout.setHorizontalSpacing(40)
        # layout.setVerticalSpacing(10)
        # layout.setColumnStretch(0, 1)
        # layout.setColumnStretch(1, 1)
        # layout.setColumnStretch(2, 1)
        # layout.setColumnStretch(3, 1)

        return qwidget
예제 #30
0
    def __init__(self, device=None):
        QWidget.__init__(self)
        self.p = device  # connection to the device hardware
        self.traceCols = utils.makeTraceColors()

        self.pwin = pg.PlotWidget()  # pyqtgraph window
        self.pwin.showGrid(x=True, y=True)  # with grid
        ax = self.pwin.getAxis('bottom')
        ax.setLabel(self.tr('Time (Sec)'))
        ax = self.pwin.getAxis('left')
        ax.setLabel(self.tr('Distance(cm)'))
        self.pwin.disableAutoRange()
        self.pwin.setXRange(self.TMIN, self.TMAX)
        self.pwin.setYRange(self.DMIN, self.DMAX)
        self.pwin.hideButtons()  # Do not show the 'A' button of pg

        right = QVBoxLayout()  # right side vertical layout
        right.setAlignment(Qt.AlignTop)
        right.setSpacing(self.RPGAP)

        H = QHBoxLayout()
        l = QLabel(text=self.tr('Y-axis from 0 to'))
        l.setMaximumWidth(100)
        H.addWidget(l)
        self.DMAXtext = utils.lineEdit(40, self.DMAX, 6, None)
        H.addWidget(self.DMAXtext)
        l = QLabel(text=self.tr('cm'))
        l.setMaximumWidth(50)
        H.addWidget(l)
        right.addLayout(H)

        H = QHBoxLayout()
        l = QLabel(text=self.tr('Measure during'))
        l.setMaximumWidth(100)
        H.addWidget(l)
        self.TMAXtext = utils.lineEdit(40, self.TMAX, 6, None)
        H.addWidget(self.TMAXtext)
        l = QLabel(text=self.tr('Secs'))
        l.setMaximumWidth(50)
        H.addWidget(l)
        right.addLayout(H)

        b = QPushButton(self.tr("Start"))
        right.addWidget(b)
        b.clicked.connect(self.start)

        b = QPushButton(self.tr("Stop"))
        right.addWidget(b)
        b.clicked.connect(self.stop)

        b = QPushButton(self.tr("Fit Curve using Sine"))
        b.clicked.connect(self.fit_curve)
        right.addWidget(b)

        b = QPushButton(self.tr("Clear Traces"))
        right.addWidget(b)
        b.clicked.connect(self.clear)

        self.SaveButton = QPushButton(self.tr("Save Data"))
        self.SaveButton.clicked.connect(self.save_data)
        right.addWidget(self.SaveButton)

        #------------------------end of right panel ----------------

        top = QHBoxLayout()
        top.addWidget(self.pwin)
        top.addLayout(right)

        full = QVBoxLayout()
        full.addLayout(top)
        self.msgwin = QLabel(text='')
        full.addWidget(self.msgwin)

        self.setLayout(full)

        self.timer = QTimer()
        self.timer.timeout.connect(self.update)
        self.timer.start(self.TIMER)