Esempio n. 1
0
    def __init__(self,
                 topics=None,
                 terms=None,
                 addr=None,
                 parent=None,
                 **kwargs):
        super().__init__(parent)

        self.fetcher = None
        if addr:
            self.fetcher = AsyncFetcher(topics, terms, addr)

        handles = self.roi.getHandles()
        self.view.disableAutoRange()
        self.roi.removeHandle(handles[1])
        self.last_updated = pg.LabelItem(parent=self.getView())
        self.pixel_value = pg.LabelItem(parent=self.getView())
        self.proxy = pg.SignalProxy(self.scene.sigMouseMoved,
                                    rateLimit=30,
                                    slot=self.cursor_hover_evt)
Esempio n. 2
0
    def __init__(self, display_panel):
        super().__init__()
        self.display_panel = display_panel
        self.main_window = self.display_panel.main_window
        # Layout
        self.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                           QtWidgets.QSizePolicy.Expanding)
        self.layout = pg.GraphicsLayout()
        self.layout.layout.setColumnFixedWidth(0, self.main_window.axis_width)

        # Variables
        self.axes: Optional[Dict[View, pg.AxisItem]] = {}
        self.vbs: Optional[Dict[View, pg.ViewBox]] = {}

        self.main_plot = pg.PlotItem(enableMenu=False)
        self.main_plot.hideButtons()
        self.main_plot.hideAxis('left')
        self.main_plot.hideAxis('bottom')
        self.main_vb: pg.ViewBox = self.main_plot.getViewBox()
        self.main_vb.sigXRangeChanged.connect(self.zoomChanged)
        self.main_vb.setXRange(0, 1)
        self.main_vb.setYRange(0, 1)
        self.main_vb.setMouseEnabled(False, False)
        self.main_plot.setZValue(-sys.maxsize - 1)
        self.axis_bottom = pg.AxisItem('bottom', parent=self.main_vb)
        self.axis_bottom.setLabel('time (s)')
        self.axis_bottom.showLabel(
            self.main_window.application.config['show_x-axis_label'])
        # self.axis_bottom.setFixedHeight(self.axis_bottom.height())
        self.label = pg.LabelItem(justify='left', color=[255, 255, 255, 0])

        # Connections
        self.maxWidthChanged.connect(self.main_window.checkAxesWidths)
        self.main_vb.sigResized.connect(self.updateViews)
        self.main_window.cursorReadoutStatus.connect(self.setCursorReadout)

        self.proxy = pg.SignalProxy(self.scene().sigMouseMoved,
                                    rateLimit=60,
                                    slot=self.mouseMoved)
        self.buildLayout()
        self.setCursorReadout(self.main_window.cursor_readout)
Esempio n. 3
0
    def initalizePlot(self):
        #create window for plot
        self.plotWin = pg.GraphicsWindow(title="Linescan Plot")
        #add plot object to window
        self.linescanPlot = self.plotWin.addPlot()
        #add label to display xy data
        label = pg.LabelItem(justify='right')
        self.plotWin.addItem(label)
        #add plot
        #self.linescanPlot.plot(x, self.linescanData, pen=penType, symbol='o')
        self.linescanPlot.plot(self.x, self.y, pen=self.penType, clear=True)
        #add title to plot
        #self.linescanPlot.setTitle('ROI #1')

        #get mouse hover data from line

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

        def mouseMoved(evt):
            if self.linescanPlot.sceneBoundingRect().contains(evt):
                mousePoint = vb.mapSceneToView(evt)
                index = int(mousePoint.x())
                if index > 0 and index < len(self.y):
                    label.setText(
                        "<span style='font-size: 12pt'>x=%0.2f,   <span style='color: red'>y=%0.2f</span>"
                        % (mousePoint.x(), self.y[index]))
                    vLine.setPos(mousePoint.x())
                    #hLine.setPos(mousePoint.y())
                    hLine.setPos(self.y[index])

        ## use signal proxy to turn original arguments into a tuple
        proxy = pg.SignalProxy(self.linescanPlot.scene().sigMouseMoved,
                               rateLimit=60,
                               slot=mouseMoved)
        self.linescanPlot.scene().sigMouseMoved.connect(mouseMoved)
        return
Esempio n. 4
0
 def __init__(self):
     TemplateBaseClass.__init__(self)
     # Create the main window
     self.ui = WindowTemplate()
     self.ui.setupUi(self)
     self.setWindowTitle('GammaSpy')
     self.show()
     # Setup buttons/widgets
     self.setup_plot()
     self.setup_menu_items()
     self.setup_buttons()
     self.setup_inputs()
     # internal data
     self.last_clicked = []
     self.proxy = pg.SignalProxy(self.ui.plotSpectrum.scene().sigMouseMoved,
                                 rateLimit=60,
                                 slot=self.mouseMoved)
     self.ui.listWidget.currentItemChanged.connect(self.list_item_clicked)
     self.ui.textBrowser.setWordWrapMode(0)
     self.ui.textBrowser.setFontPointSize(8.)
     self.ui.textBrowser.setReadOnly(True)
Esempio n. 5
0
 def __init__(self, parent, row=0, col=0, title="noname", lock=True):
     self.parent = parent
     self.colorRotation = row + col
     self.lineList = []
     self.p = self.parent.addPlot(row=row, col=col)
     self.legend = self.p.addLegend(offset=(10, 10))
     self.legend.setBrush(self.parent.themeBack)
     self.legend.setLabelTextColor(self.parent.themeFore)
     #self.label = pg.LabelItem(justify='right')
     #p.addItem(self.label)
     if (parent.firstPlot):
         if lock:
             self.p.setXLink(parent.firstPlot.p)
     #p.addItem(self.curvePoint)
     self.vLine = pg.InfiniteLine(angle=90, movable=False)
     #self.hLine = pg.InfiniteLine(angle=0, movable=False)
     self.p.addItem(self.vLine, ignoreBounds=True)
     #p.addItem(self.hLine, ignoreBounds=True)
     self.proxy = pg.SignalProxy(self.p.scene().sigMouseMoved,
                                 rateLimit=60,
                                 slot=self.mouseMoved)
Esempio n. 6
0
    def init_ui(self):
        layout = QtWidgets.QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        value = self.item.getter()
        values = self.item.values
        if values is not None:
            self.value_display = ComboBoxFeatItemWidget(values)
        elif isinstance(value, bool):
            self.value_display = ComboBoxFeatItemWidget({True, False})
        # elif isinstance(value, Iterable):
        #     pass
        elif isinstance(value, (int, float, Q_)):
            opts = dict()
            if self.item.units is not None:
                opts['unit'] = self.item.units
            if self.item.limits is not None:
                opts['bounds'] = self.item.limits
            opts['dec'] = True
            opts['minStep'] = 1e-3
            opts['decimals'] = 5
            if isinstance(value, int):
                opts['int'] = True
                opts['minStep'] = 1
                opts['decimals'] = 10
            self.value_display = SpinBoxFeatItemWidget(opts)
        else:
            self.value_display = LineEditFeatItemWidget()

        self.value_display.activated.connect(self.feat_update)
        self.value_display.refreshed.connect(self.feat_reload)
        self.changed_proxy = pg.SignalProxy(self.item.changed,
                                            rateLimit=self.refresh_rate,
                                            slot=self.feat_changed)
        self.value_display.setter(value)

        self.value_display.set_readonly(self.item.readonly)

        layout.addWidget(self.value_display)
        self.setLayout(layout)
        return
Esempio n. 7
0
    def shortcut(self):
        # keyboard shortcut

        self.shortcutPu = QShortcut(QtGui.QKeySequence("+"), self)
        self.shortcutPu.activated.connect(self.paletteup)
        self.shortcutPu.setContext(Qt.ShortcutContext(3))
        #3: The shortcut is active when its parent widget, or any of its children has focus. default O The shortcut is active when its parent widget has focus.
        self.shortcutPd = QtGui.QShortcut(QtGui.QKeySequence("-"), self)
        self.shortcutPd.activated.connect(self.palettedown)
        self.shortcutPd.setContext(Qt.ShortcutContext(3))

        self.shortcutOpen = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+o"), self)
        self.shortcutOpen.activated.connect(self.OpenF)
        self.shortcutOpen.setContext(Qt.ShortcutContext(3))

        self.shortcutSave = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+s"), self)
        self.shortcutSave.activated.connect(self.SaveF)
        self.shortcutSave.setContext(Qt.ShortcutContext(3))

        if self.meas == 'on':
            self.shortcutMeas = QtGui.QShortcut(QtGui.QKeySequence('Ctrl+m'),
                                                self)
            self.shortcutMeas.activated.connect(self.Measurement)
            self.shortcutMeas.setContext(Qt.ShortcutContext(3))

        self.shortcutBloq = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+b"), self)
        self.shortcutBloq.activated.connect(self.bloquer)
        self.shortcutBloq.setContext(Qt.ShortcutContext(3))

        self.shortcutDebloq = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+d"),
                                              self)
        self.shortcutDebloq.activated.connect(self.debloquer)
        self.shortcutDebloq.setContext(Qt.ShortcutContext(3))

        # mousse action:
        self.proxy = pg.SignalProxy(self.p1.scene().sigMouseMoved,
                                    rateLimit=60,
                                    slot=self.mouseMoved)
        self.p1.scene().sigMouseClicked.connect(self.mouseClick)
        self.vb = self.p1.vb
Esempio n. 8
0
    def addDockWidgetsPlots(self):
        self.w1 = pg.PlotWidget(title="Plots of the slow-wave data")
        self.w2 = pg.PlotWidget(title="Plots of zoomed-in slow-wave data")
        self.w3 = pg.PlotWidget(title="Selected Data for Training")
        c = pg.PlotCurveItem(pen=pg.mkPen('r', width=2))
        c_event = pg.PlotCurveItem(pen=pg.mkPen('y', width=2))
        self.curve_bottom.append(c)
        self.curve_bottom.append(c_event)
        self.w3.addItem(c)
        self.w3.addItem(c_event)
        nPlots = 256
        for i in range(nPlots):
            c1 = pg.PlotCurveItem(pen=(i, nPlots * 1.3))
            c1.setPos(0, i * 20)
            self.curves_left.append(c1)
            self.w1.addItem(c1)
            self.w1.setYRange(0, 900)
            self.w1.setXRange(0, 3000)

            c2 = pg.PlotCurveItem(pen=(i, nPlots * 1.3))
            c2.setPos(0, i * 20)
            self.curves_right.append(c2)
            self.w2.addItem(c2)
        self.s1 = pg.ScatterPlotItem(size=10,
                                     pen=pg.mkPen(None),
                                     brush=pg.mkBrush(255, 255, 255, 120))
        self.s2 = pg.ScatterPlotItem(size=10,
                                     pen=pg.mkPen(None),
                                     brush=pg.mkBrush(255, 255, 255, 120))
        self.w1.addItem(self.s1)
        self.w2.addItem(self.s2)
        self.d_plot.addWidget(self.w1, row=0, col=0)
        self.d_plot.addWidget(self.w2, row=0, col=1)
        self.d_train.addWidget(self.w3, row=0, col=0)
        self.proxy = pg.SignalProxy(self.w2.scene().sigMouseMoved,
                                    rateLimit=60,
                                    slot=self.mouseMoved)
        self.w2.scene().sigMouseClicked.connect(self.onClick)
        self.w2.sigXRangeChanged.connect(self.updateRegion)
        self.w2.sigYRangeChanged.connect(self.updateRegion)
 def showImage(self, arr, min=None, max=None):
     arr = arr.astype("float64")
     if arr is None:
         self.img = None
         return
     if self.img==None:
         if min and max:
             self.img = pg.ImageItem(arr, levels=(min, max), autoLevels=False)
         else:
             self.img = pg.ImageItem(arr, autoRange=False, autoLevels=False)
         self.addItem(self.img)
     # Add/readd crosshair
     if self.crosshair_visible:
       self.addItem(self.vLine, ignoreBounds=True)
       self.addItem(self.hLine, ignoreBounds=True)
     proxy = pg.SignalProxy(self.scene().sigMouseMoved, rateLimit=60, slot=self.mouseMoved)
     self.scene().sigMouseMoved.connect(self.mouseMoved)
     if min and max:
         self.img.setImage(arr, levels=(min, max))
     else:
         self.img.setImage(arr)
     self.updateView()
Esempio n. 10
0
	def plot_liss(self):
		lissx = self.Liss_x.currentText()
		lissy = self.Liss_y.currentText()
		self.liss_x = self.Liss_x.currentIndex()
		self.liss_y = self.Liss_y.currentIndex()
		if not (self.channel_states[self.liss_x] and self.channel_states[self.liss_y]):
			QtGui.QMessageBox.about(self, 'Error : Insufficient Data',  'Please enable the selected channels in the oscilloscope')
			return

		self.liss_win = pg.GraphicsWindow(title="Basic plotting examples")
		self.liss_win.setWindowTitle('pyqtgraph example: Plotting')
		self.p1 = self.liss_win.addPlot(title="Lissajous: x : %s vs y : %s"%(lissx,lissy),x=self.I.achans[self.liss_x].get_yaxis(),y=self.I.achans[self.liss_y].get_yaxis())
		self.p1.setLabel('left',lissy);self.p1.setLabel('bottom',lissx)
		self.p1.getAxis('left').setGrid(170)
		self.p1.getAxis('bottom').setGrid(170)

		self.lissvLine = pg.InfiniteLine(angle=90, movable=False,pen=[100,100,200,200])
		self.p1.addItem(self.lissvLine, ignoreBounds=True)
		self.lisshLine = pg.InfiniteLine(angle=0, movable=False,pen=[100,100,200,200])
		self.p1.addItem(self.lisshLine, ignoreBounds=True)
		self.vb = self.p1.vb
		self.lissproxy = pg.SignalProxy(self.p1.scene().sigMouseClicked, rateLimit=60, slot=self.lissMouseClicked)
Esempio n. 11
0
    def plt_show(self, num):
        self.main_layout.removeWidget(self.plt)
        self.plt = pg.PlotWidget()
        self.plt.addLegend(size=(150, 80))
        self.plt.showGrid(x=True, y=True, alpha=0.5)
        xdict = dict(enumerate(self.data["aa"].astype(str)))
        axis_1 = [(i, self.data["aa"][i].tolist())
                  for i in range(0, len(self.data["aa"]), 500)]
        stringaxis = pg.AxisItem(orientation="bottom")
        stringaxis.setTicks([axis_1, xdict.items()])
        #self.plt.getAxis("bottom").setTicks([axis_1, xdict.items()])
        #x_max = self.data.iloc[:,0].max()
        #self.plt.setRange(xRange=[0, x_max], yRange=[0, 0.01], padding=0)
        #self.plt.setXRange(max=1000, min=0, padding=0)
        for i in num.split(","):
            i = int(i)
            print(i)
            self.plt.plot(x=self.data.index.tolist(),
                          y=list(self.data.iloc[:, i]),
                          pen=colour[i - 1],
                          name=yp_list[i - 1])

        self.label = pg.TextItem()  # 创建一个文本项
        self.plt.addItem(self.label)
        self.vLine = pg.InfiniteLine(
            angle=90,
            movable=False,
        )
        self.hLine = pg.InfiniteLine(
            angle=0,
            movable=False,
        )
        self.plt.addItem(self.vLine, ignoreBounds=True)  # 在图形部件中添加垂直线条
        self.plt.addItem(self.hLine, ignoreBounds=True)  # 在图形部件中添加水平线条

        self.move_slot = pg.SignalProxy(self.plt.sceneObj.sigMouseMoved,
                                        rateLimit=60,
                                        slot=self.mouse_moved)
        self.main_layout.addWidget(self.plt)
Esempio n. 12
0
 def __init__(self):
     super(TopView, self).__init__()
     self.ctrl = Controller(self)
     uic.loadUi(Path(__file__).parent.joinpath('topview.ui'), self)
     self.plotItem_topview.setAspectLocked(True)
     self.imageItem = pg.ImageItem()
     self.plotItem_topview.addItem(self.imageItem)
     # setup one horizontal and one vertical line that can be moved
     line_kwargs = {'movable': True, 'pen': pg.mkPen((0, 255, 0), width=3)}
     self.line_coronal = pg.InfiniteLine(angle=0, pos=0, **line_kwargs)
     self.line_sagittal = pg.InfiniteLine(angle=90, pos=0, **line_kwargs)
     self.line_coronal.sigDragged.connect(
         self.coronal_line_moved)  # sigPositionChangeFinished
     self.line_sagittal.sigDragged.connect(self.sagittal_line_moved)
     self.plotItem_topview.addItem(self.line_coronal)
     self.plotItem_topview.addItem(self.line_sagittal)
     # connect signals and slots
     s = self.plotItem_topview.getViewBox().scene()
     self.proxy = pg.SignalProxy(s.sigMouseMoved,
                                 rateLimit=60,
                                 slot=self.mouseMoveEvent)
     self.ctrl.set_top()
Esempio n. 13
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(u'K线工具')
        # 主图
        self.m_plotWidget = pg.PlotWidget()
        # 界面布局
        self.m_pgLayout = pg.GraphicsLayout(border=(100, 100, 100))
        self.m_pgLayout.setContentsMargins(10, 10, 10, 10)
        self.m_pgLayout.setSpacing(0)
        self.m_pgLayout.setBorder(color=(255, 255, 255, 255), width=0.8)
        self.m_pgLayout.setZValue(0)
        self.m_pgTitle = self.m_pgLayout.addLabel(u'量化分析工具', size='20pt')
        self.m_plotWidget.setCentralItem(self.m_pgLayout)
        # self.m_plotWidget.centralWidget.getItem(0, 0).setText(u'原来是你', size='20pt')

        # 初始化子图
        self.m_klPlotItem = KLPlotItem()
        self.m_pgLayout.nextRow()
        self.m_pgLayout.addItem(self.m_klPlotItem)

        self.m_volPlotItem = VolPlotItem()
        self.m_pgLayout.nextRow()
        self.m_pgLayout.addItem(self.m_volPlotItem)

        # self.m_oiPlotItem = OIPlotItem()
        # self.m_curveOI = self.m_oiPlotItem.plot()
        # self.m_pgLayout.nextRow()
        # self.m_pgLayout.addItem(self.m_oiPlotItem)

        # 注册鼠标事件
        self.m_proxy = pg.SignalProxy(self.m_plotWidget.scene().sigMouseMoved,
                                      rateLimit=360,
                                      slot=self.pwMouseMoved)
        # 设置界面
        self.m_vbLayout = QtGui.QVBoxLayout()
        self.m_vbLayout.addWidget(self.m_plotWidget)
        self.setLayout(self.m_vbLayout)
        # 初始化完成
        self.m_initCompleted = True
Esempio n. 14
0
    def plot_k(self):
        axis_date = pg.AxisItem(orientation='bottom')
        axis_date.setTicks([self._axis_date])
        self._pw.setAxisItems({'bottom': axis_date})

        self._k_item = CandlestickItem(self._data)
        self._pw.addItem(self._k_item)

        # 添加第二个图形
        self._pw.plot(x=list(self._xdict.keys()),
                      y=self._data['close'].values,
                      pen='r',
                      name='close')

        self._label_info = pg.TextItem()
        self._pw.addItem(self._label_info)
        self._pw.showGrid(x=True, y=True, alpha=0.5)

        self._v_line = pg.InfiniteLine(angle=90, movable=False)
        self._h_line = pg.InfiniteLine(angle=0, movable=False)
        self._pw.addItem(self._v_line, ignoreBounds=True)
        self._pw.addItem(self._h_line, ignoreBounds=True)

        self._view_box = self._pw.getPlotItem().getViewBox()

        # 显示部分数据
        _tmp_data = self._data.iloc[-120:]
        _x_left = _tmp_data.index[0]
        _x_right = _tmp_data.index[-1]
        _y_max = _tmp_data['high'].max()
        _y_min = _tmp_data['low'].min()
        top_left = QPointF(_x_left * 0.99, _y_max * 1.01)
        bottom_right = QPointF(_x_right * 1.01, _y_min * 0.99)
        self._view_box.setRange(rect=QRectF(top_left, bottom_right))

        # self._proxy 代理必须存在,不能用局部变量
        self._proxy = pg.SignalProxy(self._pw.scene().sigMouseMoved,
                                     rateLimit=30,
                                     slot=self.mouse_moved)
Esempio n. 15
0
    def __init__(self, loop):
        QtWidgets.QMainWindow.__init__(self)

        self.init_gui()

        [self.scope, self.rate] = setupScope(self.nSamples, self.voltageRange,
                                             self.channel)
        self.voltageRangeComboBox.setCurrentIndex(7)
        self.scopeRunning = False
        self.loop = loop

        self.prevSpec = 0
        self.lastData = None

        self.lastUpdate = None

        self.vb = self.specPlot.vb
        self._proxy = pg.SignalProxy(self.specPlot.scene().sigMouseMoved,
                                     rateLimit=60,
                                     slot=self.mouseMoved)

        self.loop.create_task(self.update())
Esempio n. 16
0
    def __init__(self, name, parent=None, properties=None):
        self.parent = parent
        self.name = name
        self.colors = Colors()
        self.hiddencurves = set()
        self.properties = properties if properties is not None else {}

        axisItems = {'bottom': TimeAxisItem(orientation='bottom')}
        super().__init__(parent=parent, axisItems=axisItems, background='w')

        self.legend = LegendItem()
        self.legend.setParentItem(self.getPlotItem())

        self.vb = self.getViewBox()
        self.vb.setMouseMode(self.vb.RectMode)

        self.setCursor(QtCore.Qt.CrossCursor)

        mouseMoved = partial(self.mouseMoved, self)
        self.sigproxy = pg.SignalProxy(self.scene().sigMouseMoved,
                                       rateLimit=60,
                                       slot=mouseMoved)
Esempio n. 17
0
    def plt_show(self, num):
        self.main_layout.removeWidget(self.plt)

        self.plt = pg.PlotWidget()
        self.plt.addLegend(size=(150, 80))
        self.plt.showGrid(x=True, y=True, alpha=0.5)

        for i in num.split(","):
            i = int(i)
            self.plt.plot(x=self.data.index.tolist(), y=list(self.data.iloc[:,i]), pen=colour[i-1],
                     name=yp_list[i-1])

        self.label = pg.TextItem()  # 创建一个文本项
        self.plt.addItem(self.label)
        self.vLine = pg.InfiniteLine(angle=90, movable=False, )
        self.hLine = pg.InfiniteLine(angle=0, movable=False, )
        self.plt.addItem(self.vLine, ignoreBounds=True)  # 在图形部件中添加垂直线条
        self.plt.addItem(self.hLine, ignoreBounds=True)  # 在图形部件中添加水平线条

        self.move_slot = pg.SignalProxy(self.plt.scene().sigMouseMoved,
                                        rateLimit=60, slot=self.mouse_moved)
        self.main_layout.addWidget(self.plt)
Esempio n. 18
0
 def __init__(self, data: DataType,
              layout: int = PGImageTool.LayoutSimple, parent=None):
     """Create an ImageTool QWidget.
     :param data: A RegularDataArray, numpy.array, or xarray.DataArray
     :param layout: An int that defines the layout. See PGImageTool for layout definitions
     :param parent: QWidget that will be this widget's parent
     """
     super().__init__(parent)
     # Warn user about nan
     if hasattr(data, 'values'):
         d = data.values
     else:
         d = data
     if np.any(np.isnan(d)):
         warnings.warn('Input data contains NaNs. All NaN will be set to 0.')
         d[np.isnan(d)] = 0
     # Create data
     self.data: RegularDataArray = RegularDataArray(data)
     self.it_layout: int = layout
     # Create info bar and ImageTool PyQt Widget
     self.info_bar = InfoBar(self.data, parent=self)
     self.pg_widget = QtWidgets.QWidget()  # widget to hold pyqtgraph graphicslayout
     self.pg_widget.setLayout(QtWidgets.QVBoxLayout())
     self.pg_win = PGImageTool(self.data, layout=layout)  # the pyqtgraph graphicslayout
     self.pg_widget.layout().addWidget(self.pg_win)
     # Build the layout
     self.setLayout(QtWidgets.QVBoxLayout())
     self.layout().addWidget(self.info_bar)
     self.layout().addWidget(self.pg_win)
     # Create status bar
     self.status_bar = QtWidgets.QStatusBar(self)
     self.status_bar.showMessage("Initialized")
     self.layout().addWidget(self.status_bar)
     # Connect signals and slots
     self.mouse_move_proxy = pg.SignalProxy(self.pg_win.mouse_hover, rateLimit=30, slot=self.update_status_bar)
     self.build_handlers()
     # TODO: update to QT 5.14 and use textActivated signal instead
     self.info_bar.cmap_combobox.currentTextChanged.connect(self.set_all_cmaps)
     self.info_bar.transpose_request.connect(self.transpose_data)
Esempio n. 19
0
    def plot(self, axis):
        ''' Plots a 1D cross-section through the minimum of the modeled surface. '''
        dim = self.best_point.shape[0]
        n_points = 100

        points = np.zeros((n_points, dim))
        for d in range(dim):
            points[:, d] = self.best_point[d]
        points[:, axis] = np.linspace(self.pipeline.bounds[axis][0],
                                      self.pipeline.bounds[axis][1], n_points)
        costs = self.predict(points)[0]
        win = pg.GraphicsWindow()
        win.setWindowTitle('Modeled surface')
        label = pg.LabelItem(justify="right")
        label.setText('goo!')
        win.addItem(label)
        p = win.addPlot(row=1,
                        col=0,
                        labels={
                            'bottom': 'Axis %i' % axis,
                            'left': 'Result'
                        })

        def mouseMoved(evt):
            mousePoint = p.vb.mapSceneToView(evt[0])
            label.setText("x = %0.2f, y = %0.2f</span>" %
                          (mousePoint.x(), mousePoint.y()))

        points = self.pipeline.unnormalize(points)
        x = points[:, axis]
        y = costs
        plot = p.plot(x=x, y=y, symbol='o', symbolSize=7, pen=None)

        proxy = pg.SignalProxy(p.scene().sigMouseMoved,
                               rateLimit=60,
                               slot=mouseMoved)

        return win, proxy
Esempio n. 20
0
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        winSize=self.size()
        self.view.resize(winSize.width(),winSize.height())
        x = numpy.linspace(-5., 5., 10000)
        y =gaussian(5.,0.2, x)
        self.p=self.view.plot(x,y)

        proxy = pg.SignalProxy(self.view.scene().sigMouseMoved, rateLimit=60, slot=self.mouseMoved)
        self.view.enableAutoRange("xy", True)

 



        Plotted = self.plot
        vLine = pg.InfiniteLine(angle=90, movable=False)
        hLine = pg.InfiniteLine(angle=0, movable=False)
        Plotted.addItem(vLine, ignoreBounds=True)
        Plotted.addItem(hLine, ignoreBounds=True)
        Plotted.setMouseTracking(True)
        Plotted.scene().sigMouseMoved.connect(self.mouseMoved)

        def mouseMoved(self,evt):
                pos = evt
                if self.plot.sceneBoundingRect().contains(pos):
                    mousePoint = self.plot.plotItem.vb.mapSceneToView(pos)
                    self.label.setText("<span style='font-size: 15pt'>X=%0.1f, <span style='color: black'>Y=%0.1f</span>" % (mousePoint.x(),mousePoint.y()))
                self.plot.plotItem.vLine.setPos(mousePoint.x())
                self.plot.plotItem.hLine.setPos(mousePoint.y()

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    window = MyApp()
    window.show()

    sys.exit(app.exec_())
Esempio n. 21
0
    def __init__(self):
        super(Graph, self).__init__()

        pg.setConfigOptions(antialias=True)

        self.setTitle('Acceleration - Distance Relationships')
        self.enableAutoRange('y', 1)
        self.enableAutoRange('x', 1)
        self.showGrid(x=True, y=True)

        # getting the position of the mouse pointer
        self.coords = QtWidgets.QLabel()
        self.proxy = pg.SignalProxy(self.scene().sigMouseMoved,
                                    rateLimit=60,
                                    slot=self.mouseMoved)

        self.l1 = self.getPlotItem().addLine(x=0,
                                             movable=False,
                                             pen={'color': "w"})
        self.l1 = self.getPlotItem().addLine(y=0,
                                             movable=False,
                                             pen={'color': "w"})
        self.l2 = self.plot()
        self.l3 = self.plot()
        self.l4 = self.plot()
        self.l5 = self.plot()

        # Let's initialize our variables
        self.distance = 0
        self.length = 0
        self.time_yellow = 0
        self.v_current = 0
        self.v_max = 0
        self.a_max = 0
        self.a_min = 0

        self.getPlotItem().setLabel('left', text='Distance (m)')
        self.getPlotItem().setLabel('bottom', text='Acceleration (m/s^2)')
Esempio n. 22
0
    def run_post(self, data):
        if self.hist.size == 0 or self.bin_edges.size == 0:
            log.error('data is empty')
            return

        title = f'{self._cfg["signal"]} : {self._name}'
        self._win = pg.GraphicsLayoutWidget(show=True, title=title)
        p = self._win.addPlot(row=1, col=0)
        p.getAxis('left').setGrid(128)
        p.getAxis('bottom').setGrid(128)

        self._label = pg.LabelItem(justify='right')
        self._bg = pg.PlotDataItem(x=self.bin_edges, y=self.hist, pen='r')
        p.addItem(self._bg)
        self._win.addItem(self._label, row=0, col=0)

        p.setLabels(left='Probability', bottom=self._cfg['signal'])
        p.setXRange(self.bin_edges[0], self.bin_edges[-1], padding=0.05)
        p.setYRange(np.nanmin(self.hist), np.nanmax(self.hist), padding=0.05)

        def mouseMoved(evt):
            pos = evt[0]
            if p.sceneBoundingRect().contains(pos):
                mousePoint = p.vb.mapSceneToView(pos)
                xval = mousePoint.x()
                index = np.searchsorted(self.bin_edges, xval) - 1
                if index >= 0 and index < len(self.bin_edges):
                    self._label.setText(
                        "<span style='font-size: 12pt'>{}={:.5f}</span>,   <span style='color: yellow; font-size:12pt'>probability: {:.5f}</span>"
                        .format(self._cfg['signal'], mousePoint.x(),
                                self.hist[index]))

        self.proxy = pg.SignalProxy(p.scene().sigMouseMoved,
                                    rateLimit=60,
                                    slot=mouseMoved)

        self._win.closeEvent = lambda evt: data.on_tool_finished()
        return True
Esempio n. 23
0
    def __init__(self, parent):
        """Constructor"""
        self.__view = parent

        super(Crosshair, self).__init__()
        self.__vLine = pg.InfiniteLine(angle=90, movable=False)
        self.__hLine = pg.InfiniteLine(angle=0, movable=False)
        self.__textPrice = pg.TextItem('price')
        self.__textDate = pg.TextItem('date')

        #mid 在y轴动态跟随最新价显示最新价和最新时间
        self.__textLastPrice = pg.TextItem('lastTickPrice')

        view = self.__view

        view.addItem(self.__textDate, ignoreBounds=True)
        view.addItem(self.__textPrice, ignoreBounds=True)
        view.addItem(self.__vLine, ignoreBounds=True)
        view.addItem(self.__hLine, ignoreBounds=True)
        view.addItem(self.__textLastPrice, ignoreBounds=True)
        self.proxy = pg.SignalProxy(view.scene().sigMouseMoved,
                                    rateLimit=60,
                                    slot=self.__mouseMoved)
Esempio n. 24
0
    def __init__(self, dataForCandle=None):
        """Constructor"""
        super(pgCandleWidgetCross, self).__init__()
        self.setWindowTitle('pyqtgraph example: crosshair')

        self.candleData = dataForCandle
        self.CandlePlot = pg.PlotItem()
        #cross hair
        self.vLine = pg.InfiniteLine(angle=90, movable=False)
        self.hLine = pg.InfiniteLine(angle=0, movable=False)

        self.label = pg.LabelItem(justify='right')

        self.addItem(self.label, 0, 0)
        self.addItem(self.CandlePlot, 1, 0)

        self.CandlePlot.addItem(CandlestickItem(self.candleData))
        self.CandlePlot.addItem(self.vLine, ignoreBounds=True)
        self.CandlePlot.addItem(self.hLine, ignoreBounds=True)

        self.proxy = pg.SignalProxy(self.CandlePlot.scene().sigMouseMoved,
                                    rateLimit=60,
                                    slot=self.mouseMoved)
Esempio n. 25
0
 def __init__(self, topview: TopView, waxis, haxis, daxis):
     super(SliceView, self).__init__()
     self.topview = topview
     self.ctrl = SliceController(self, waxis, haxis, daxis)
     uic.loadUi(Path(__file__).parent.joinpath('sliceview.ui'), self)
     self.add_image_layer(slice_kwargs={
         'volume': 'image',
         'mode': 'clip'
     },
                          pg_kwargs={'opacity': 0.8})
     self.add_image_layer(slice_kwargs={
         'volume': 'annotation',
         'mode': 'clip'
     },
                          pg_kwargs={'opacity': 0.2})
     # init the image display
     self.plotItem_slice.setAspectLocked(True)
     # connect signals and slots
     s = self.plotItem_slice.getViewBox().scene()
     self.proxy = pg.SignalProxy(s.sigMouseMoved,
                                 rateLimit=60,
                                 slot=self.mouseMoveEvent)
     s.sigMouseClicked.connect(self.mouseClick)
Esempio n. 26
0
    def plot_k(self):
        axis_date = pg.AxisItem(orientation='bottom')
        axis_date.setTicks([self._axis_date])
        self._pw.setAxisItems({'bottom': axis_date})

        self._k_item = VolItem(self._data)
        self._pw.addItem(self._k_item)

        self._label_info = pg.TextItem()
        self._pw.addItem(self._label_info)
        self._pw.showGrid(x=True, y=True, alpha=0.5)

        self._v_line = pg.InfiniteLine(angle=90, movable=False)
        self._h_line = pg.InfiniteLine(angle=0, movable=False)
        self._pw.addItem(self._v_line, ignoreBounds=True)
        self._pw.addItem(self._h_line, ignoreBounds=True)

        self._view_box = self._pw.getPlotItem().getViewBox()

        # 显示部分数据
        _tmp_data = self._data.iloc[-120:]
        _x_left = _tmp_data.index[0]
        _x_right = _tmp_data.index[-1]
        _y_max = self._data['vol'].max() / 10000
        top_left = QPointF(_x_left * 0.99, _y_max * 1.01)
        bottom_right = QPointF(_x_right * 1.01, 0)
        # 设置可视范围
        self._view_box.setRange(rect=QRectF(top_left, bottom_right))
        # 设置y轴可视范围,调整padding
        self._view_box.setYRange(0, _y_max * 1.01, padding=0)
        # 设置鼠标禁用状态
        self._view_box.setMouseEnabled(x=True, y=False)

        # self._proxy 代理必须存在,不能用局部变量
        self._proxy = pg.SignalProxy(self._pw.scene().sigMouseMoved,
                                     rateLimit=30,
                                     slot=self.mouse_moved)
Esempio n. 27
0
    def shortcut(self):

        self.shortcutPu = QShortcut(QtGui.QKeySequence("+"), self)
        self.shortcutPu.activated.connect(self.paletteup)
        self.shortcutPu.setContext(Qt.ShortcutContext(3))
        #3: The shortcut is active when its parent widget, or any of its children has focus. default O The shortcut is active when its parent widget has focus.
        self.shortcutPd = QtGui.QShortcut(QtGui.QKeySequence("-"), self)
        self.shortcutPd.activated.connect(self.palettedown)
        self.shortcutPd.setContext(Qt.ShortcutContext(3))

        self.shortcutOpen = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+o"), self)
        self.shortcutOpen.activated.connect(self.OpenF)
        self.shortcutOpen.setContext(Qt.ShortcutContext(3))

        #self.shortcutSave=QtGui.QShortcut(QtGui.QKeySequence("Ctrl+s"),self)
        #self.shortcutSave.activated.connect(self.SaveF)
        #self.shortcutSave.setContext(Qt.ShortcutContext(3))

        self.shortcutEnerg = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+e"),
                                             self)
        self.shortcutEnerg.activated.connect(self.Energ)
        self.shortcutEnerg.setContext(Qt.ShortcutContext(3))

        self.shortcutMeas = QtGui.QShortcut(QtGui.QKeySequence('Ctrl+m'), self)
        self.shortcutMeas.activated.connect(self.Measurement)
        self.shortcutMeas.setContext(Qt.ShortcutContext(3))

        self.shortcutMeas = QtGui.QShortcut(QtGui.QKeySequence('Ctrl+k'), self)
        self.shortcutMeas.activated.connect(self.CUT)
        self.shortcutMeas.setContext(Qt.ShortcutContext(3))

        # mousse mvt
        self.proxy = pg.SignalProxy(self.p1.scene().sigMouseMoved,
                                    rateLimit=60,
                                    slot=self.mouseMoved)
        self.p1.scene().sigMouseClicked.connect(self.mouseClick)
        self.vb = self.p1.vb
Esempio n. 28
0
 def __init__(self):
     self.cpu_list = []
     self.mem_list = []
     self.disk_list = []
     self.nmon_infos = {}
     self.name = ''
     self.fileName = ''
     self.moveable = True
     super(simpleForm, self).__init__()
     self.setupUi(self)
     self.timer = QTimer(self)
     self.setWarnLine()
     self.visableUploadChange()
     self.visabledownloadChange()
     self.start_record.setDisabled(True)
     self.download_record.setDisabled(True)
     self.analysis_record.setDisabled(True)
     self.move_slot = pg.SignalProxy(self.graph_widget.scene().sigMouseMoved, rateLimit=60, slot=self.print_slot)
     self.upload_nmon.clicked.connect(self.uploadfile)
     self.moveable_btn.clicked.connect(self.moveType)
     self.start_record.clicked.connect(self.record_command)
     self.timer.timeout.connect(self.nmon_finished)
     self.download_record.clicked.connect(self.nmon_download)
     self.analysis_record.clicked.connect(self.analysis_show)
Esempio n. 29
0
    def __init__(self, pw, xAxis, viwe, parent=None):
        self.__view = viwe
        self.pw = pw
        self.xData = xAxis['tradingday'].values.tolist()
        self.yData = xAxis['spread'].values.tolist()
        super(CrosshairTool, self).__init__()
        self.xAxis = 0
        self.yAxis = 0

        # 在y轴动态mid跟随最新价显示最新价和最新时间
        self.rects = [self.__view.vb.sceneBoundingRect()]
        self.__textDate = pg.TextItem()
        self.__textSig = pg.TextItem()
        self.__textDate.setZValue(2)
        self.__textSig.setZValue(2)
        #动态跟随
        self.__textInfo = pg.TextItem('lastBarInfo')
        self.__textInfo.setZValue(2)
        self.__textInfo.border = pg.mkPen(color=(230, 255, 0, 255), width=1.2)
        self.__textInfo.setText(U"日期")

        # 注册十字光标
        self.vLine = pg.InfiniteLine(angle=90, movable=False)
        self.hLine = pg.InfiniteLine(angle=0, movable=False)
        self.vLine.setPos(0)
        self.hLine.setPos(0)
        self.__view.vb.addItem(self.vLine, ignoreBounds=True)
        self.__view.vb.addItem(self.hLine, ignoreBounds=True)
        self.__view.vb.addItem(self.__textDate, ignoreBounds=True)
        self.__view.vb.addItem(self.__textSig, ignoreBounds=True)
        self.__view.vb.addItem(self.__textInfo, ignoreBounds=True)
        self.proxy = pg.SignalProxy(self.pw.scene().sigMouseMoved,
                                    rateLimit=60,
                                    slot=self.mouseMoved)
        # 跨线程刷新界面支持
        self.signal.connect(self.update)
    def __init__(self, parent=None):
        gui.OWComponent.__init__(self, widget=parent)
        pg.PlotWidget.__init__(self,
                               parent=parent,
                               viewBox=KaplanMeierViewBox(self))

        self.setLabels(left='Survival Probability', bottom='Time')

        self.highlighted_curve: Optional[int] = None
        self.curves: Dict[int, EstimatedFunctionCurve] = {}
        self.__selection_items: Dict[int, Optional[pg.PlotDataItem]] = {}

        self.view_box: KaplanMeierViewBox = self.getViewBox()

        self._mouse_moved_signal = pg.SignalProxy(
            self.plotItem.scene().sigMouseMoved,
            slot=self.mouseMovedEvent,
            delay=0.15,
            rateLimit=10)
        self.view_box.selection_changed.connect(self.on_selection_changed)

        self.legend = LegendItem()
        self.legend.setParentItem(self.getViewBox())
        self.legend.restoreAnchor(((1, 0), (1, 0)))