Exemple #1
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setWindowTitle(self.__doc__)
        self.setWindowIcon(get_icon("guiqwt.svg"))

        self.manager = manager = PlotManager(None)
        manager.set_main(self)
        self.subplotwidget = spwidget = SubplotWidget(manager, parent=self)
        self.setLayout(QW.QVBoxLayout())
        toolbar = QW.QToolBar(_("Tools"))
        manager.add_toolbar(toolbar)
        self.layout().addWidget(toolbar)
        self.layout().addWidget(spwidget)

        plot1 = CurvePlot(title="TL")
        plot2 = CurvePlot(title="TR")
        plot3 = CurvePlot(title="BL")
        plot4 = CurvePlot(title="BR")
        spwidget.add_subplot(plot1, 0, 0, "1")
        spwidget.add_subplot(plot2, 0, 1, "2")
        spwidget.add_subplot(plot3, 1, 0, "3")
        spwidget.add_subplot(plot4, 1, 1, "4")
        spwidget.add_itemlist()
        manager.synchronize_axis(BasePlot.X_BOTTOM, ["1", "3"])
        manager.synchronize_axis(BasePlot.X_BOTTOM, ["2", "4"])
        manager.synchronize_axis(BasePlot.Y_LEFT, ["1", "2"])
        manager.synchronize_axis(BasePlot.Y_LEFT, ["3", "4"])

        self.manager.register_all_curve_tools()
Exemple #2
0
    def __init__(self,
                 parent=None,
                 title=None,
                 xlabel=None,
                 ylabel=None,
                 xunit=None,
                 yunit=None,
                 section="plot",
                 show_itemlist=False,
                 gridparam=None,
                 curve_antialiasing=None,
                 **kwargs):
        if PYQT5:
            super(BaseCurveWidget, self).__init__(parent, **kwargs)
            self.setOrientation(Qt.Horizontal)
        else:
            QSplitter.__init__(self, Qt.Horizontal, parent)

        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        self.plot = CurvePlot(parent=self,
                              title=title,
                              xlabel=xlabel,
                              ylabel=ylabel,
                              xunit=xunit,
                              yunit=yunit,
                              section=section,
                              gridparam=gridparam)
        if curve_antialiasing is not None:
            self.plot.set_antialiasing(curve_antialiasing)
        self.addWidget(self.plot)
        self.itemlist = PlotItemList(self)
        self.itemlist.setVisible(show_itemlist)
        self.addWidget(self.itemlist)
        configure_plot_splitter(self)
    def create_plot(self, options):
        manager = PlotManager(None)
        self.plotwidget = CurveWidget(self, manager=manager, **options)
        manager.set_main(self.plotwidget)
        plot1 = CurvePlot(title="TL")
        plot2 = CurvePlot(title="TR")
        plot3 = CurvePlot(title="BL")
        plot4 = CurvePlot(title="BR")
        self.plotwidget.add_plot(plot1, 0, 0, "1")
        self.plotwidget.add_plot(plot2, 0, 1, "2")
        self.plotwidget.add_plot(plot3, 1, 0, "3")
        self.plotwidget.add_plot(plot4, 1, 1, "4")
        self.plotwidget.finalize()
        manager.synchronize_axis(BasePlot.X_BOTTOM, ["1", "3"])
        manager.synchronize_axis(BasePlot.X_BOTTOM, ["2", "4"])
        manager.synchronize_axis(BasePlot.Y_LEFT, ["1", "2"])
        manager.synchronize_axis(BasePlot.Y_LEFT, ["3", "4"])

        self.layout.addWidget(self.plotwidget, 0, 0)
    def setup_widget(self):

        self.plot = CurvePlot(self)
        self.data_cut = make.curve(self.xdata, self.ydata)
        self.data_fit = make.curve(self.xfit, self.yfit)

        self.plot.add_item(self.data_cut)
        self.plot.add_item(self.data_fit)

        vlayout = QVBoxLayout()
        vlayout.addWidget(self.plot)
        self.setLayout(vlayout)
Exemple #5
0
 def plot_init(self):
     self.manager = PlotManager(self)
     self.plots = []
     self.plot = CurvePlot(xlabel="", ylabel="")
     # self.plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(10)
     self.manager.add_plot(self.plot)
     self.plots.append(self.plot)
     self.plot.plot_id = id(self.plot)
     self.curve = make.curve([0], [0], color="blue", title="gray value")
     self.plot.add_item(self.curve)
     self.plot.add_item(make.legend("TR"))
     self.ui_obj.line_info_display.addWidget(self.plot)
Exemple #6
0
 def setup_plot(self, i, j, win):
     p = CurvePlot(win, xlabel=self.xlabel, ylabel=self.ylabel)
     self.main_widget = p
     win.add_plot(i, j, p)
     for item in self.plots:
         p.add_item(item)
     p.enable_used_axes()
     active_item = p.get_active_item(force=True)
     p.set_scales(self.xscale, self.yscale)
     active_item.unselect()
     if self.legend_position is not None:
         p.add_item(make.legend(self.legend_position))
     return p
Exemple #7
0
 def test_adding_to_plot(self):
     s = ScanningParam()
     a = AxisParam()
     a.length = 9
     a.increment = 0.5
     a.start = -2.0
     a.unit = 'V'
     s.axis1 = a
     m = Measurement(np.arange(9), s)
     curve = ThothCurveItem(m)
     from guiqwt.curve import CurvePlot
     plot = CurvePlot(title="Test")
     plot.add_item(curve)
     plot.show()
Exemple #8
0
    def setup_widget(self, title):
        #---Create the plot widget:
        self.plot = CurvePlot(self)
        self.curve_item = make.curve([], [], color='b')
        self.plot.add_item(self.curve_item)
        self.plot.set_antialiasing(True)
        #---

        button = QPushButton("Test filter: %s" % title)
        button.clicked.connect(self.process_data)
        vlayout = QVBoxLayout()
        vlayout.addWidget(self.plot)
        vlayout.addWidget(button)
        self.setLayout(vlayout)

        self.update_curve()
Exemple #9
0
    def setup_widget(self, title):
        """Create the plot widget:
        """
        self.plot = CurvePlot(self)
        self.curve_item = (make.curve([], [], color='b'))
        self.second_curve_item = (make.curve([], [], color='g'))

        self.plot.add_item(self.curve_item)
        self.plot.add_item(self.second_curve_item)
        self.plot.set_antialiasing(True)

        self.databaseScroll = treeList(DBaseName = None)
        self.databaseScroll.setSortingEnabled(True)

        spacer = qg.QSpacerItem(30,40)
        
        preprocessData = qg.QGroupBox(u"preprocess data")
        
        # create buttons
        listButton = qg.QPushButton(u"Refresh list")
        processButton = qg.QPushButton(u"       run preprocessing       ")
        addwaveletButton = qg.QPushButton(u"  add wavelet spikes to DB  ")
        
        self.checkAddData = qg.QMessageBox()
        
        self.wavelet = qg.QCheckBox(u"wavelet filter      ")
        label1 = qg.QLabel("enter threshold value: ")
        self.waveletThreshold = qg.QLineEdit(u"10")

        

        # connect user actions with methods:
        self.connect(listButton, qc.SIGNAL('clicked()'), self.but_clicked)
        self.connect(processButton, qc.SIGNAL('clicked()'), 
                     self.run_preprocess)
        self.connect(self.databaseScroll, 
                     qc.SIGNAL("doubleClicked(QModelIndex)"), 
                     self.double_clicked)
        self.connect(addwaveletButton, qc.SIGNAL('clicked()'), 
                     self.add_data_to_DBase)
        
        vlayout = qg.QVBoxLayout()
        hlayout = qg.QHBoxLayout()

        
        vlayout.addWidget(self.databaseScroll)
        vlayout.addWidget(listButton)

        vlayout.addWidget(self.plot)
        vlayout.addSpacerItem(spacer)
        
        
        hlayout.addWidget(self.wavelet)
        hlayout.addWidget(label1)
        hlayout.addWidget(self.waveletThreshold)

        hlayout.addWidget(processButton)        
        hlayout.addWidget(addwaveletButton)
        preprocessData.setLayout(hlayout)
        vlayout.addWidget(preprocessData)
        
        self.setLayout(vlayout)
        
        self.update_curve()
Exemple #10
0
    def __init__(
        self,
        parent=None,
        view_duration=10.,
        t_start=0.,
        zoom_limit=(0.001, 100),
        analogsignals=None,
        spiketrains=None,
        vlimits=None,
        nplot=1,
    ):
        QWidget.__init__(self, parent)

        self.zoom_limit = zoom_limit

        self.mainlayout = QVBoxLayout()
        self.setLayout(self.mainlayout)

        self.analogsignals = analogsignals
        self.spiketrains = spiketrains
        self.vlimits = vlimits
        self.nplot = nplot

        self.selectedspikes = []

        self.plots = []
        for i in range(nplot):
            plot = CurvePlot()
            self.mainlayout.addWidget(plot)
            self.plots.append(plot)
            plot.del_all_items(except_grid=False)
            # TODO :
            # xaxis off fo i>0

        self.x_min, self.x_max = 0., 60.
        self.y_min, self.y_max = -1., 1.

        h = QHBoxLayout()
        self.mainlayout.addLayout(h)

        # position
        h.addWidget(QLabel('Pos'))
        self.hslider = QSlider(Qt.Horizontal)
        self.hslider.setMaximum(1000)
        h.addWidget(self.hslider, 6)
        #self.hspinbox = QDoubleSpinBox(decimals=3, minimum = -np.inf, maximum =np.inf, value = 0.)
        self.hspinbox = QDoubleSpinBox()
        self.hspinbox.setDecimals(3)
        self.hspinbox.setMinimum(-np.inf)
        self.hspinbox.setMaximum(np.inf)
        self.hspinbox.setValue(0.)
        h.addWidget(self.hspinbox, 3)
        #self.popupStep = QToolButton(popupMode = QToolButton.MenuButtonPopup, toolButtonStyle = Qt.ToolButtonTextBesideIcon)
        self.popupStep = QToolButton()
        self.popupStep.setPopupMode(QToolButton.MenuButtonPopup)
        self.popupStep.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        self.popupStep.setText('step')
        h.addWidget(self.popupStep)
        h.addSpacing(20)
        self.hslider.valueChanged.connect(self.hsliderChanged)
        self.hspinbox.valueChanged.connect(self.refresh)
        #~ self.actPopup = [ ]
        #ag = QActionGroup(self.popupStep, exclusive = True)
        ag = QActionGroup(self.popupStep)
        ag.setExclusive(True)

        for s in ['60s', '10s', '1s', '100ms', '5ms']:
            #act = QAction(s, self.popupStep, checkable = True)
            act = QAction(s, self.popupStep)
            act.setCheckable(True)
            ag.addAction(act)
            self.popupStep.addAction(act)
        ag.triggered.connect(self.changeHStep)

        #H zoom factor
        h.addWidget(QLabel('HZoom'))
        #self.hzslider= QSlider(Qt.Horizontal, minimum = 0, maximum = 100,)
        self.hzslider = QSlider(Qt.Horizontal)
        self.hzslider.setMinimum(0)
        self.hzslider.setMaximum(100)
        h.addWidget(self.hzslider, 1)
        self.hzslider.valueChanged.connect(self.hzsliderChanged)
        #self.hzspinbox = QDoubleSpinBox(decimals=5,value=1., singleStep = .1,
        #                                                minimum = self.zoom_limit[0], maximum = self.zoom_limit[1],)
        self.hzspinbox = QDoubleSpinBox()

        self.hzspinbox.setDecimals(5)
        self.hzspinbox.setValue(1.)
        self.hzspinbox.setSingleStep(.1)
        self.hzspinbox.setMinimum(self.zoom_limit[0])
        self.hzspinbox.setMaximum(self.zoom_limit[1])
        h.addWidget(self.hzspinbox)
        self.hzspinbox.valueChanged.connect(self.hzspinboxChanged)
        self.hzspinbox.setValue(view_duration)
        self.hzspinbox.valueChanged.connect(self.refresh)
        h.addSpacing(20)

        # V zoom
        v = QVBoxLayout()
        h.addLayout(v)
        #self.vz2spinbox = QDoubleSpinBox(decimals=5,value=1., singleStep = .1, minimum = -np.inf, maximum =np.inf,)
        self.vz2spinbox = QDoubleSpinBox()
        self.vz2spinbox.setDecimals(5)
        self.vz2spinbox.setValue(1.)
        self.vz2spinbox.setSingleStep(.1)
        self.vz2spinbox.setMinimum(-np.inf)
        self.vz2spinbox.setMaximum(np.inf)

        v.addWidget(self.vz2spinbox)
        #self.vz1spinbox = QDoubleSpinBox(decimals=5,value=-1., singleStep = .1, minimum = -np.inf, maximum =np.inf,)
        self.vz1spinbox = QDoubleSpinBox()
        self.vz1spinbox.setDecimals(5)
        self.vz1spinbox.setValue(-1.)
        self.vz1spinbox.setSingleStep(.1)
        self.vz1spinbox.setMinimum(-np.inf)
        self.vz1spinbox.setMaximum(np.inf)

        v.addWidget(self.vz1spinbox)
        self.vz2spinbox.valueChanged.connect(self.vzspinboxChanged)
        self.vz1spinbox.valueChanged.connect(self.vzspinboxChanged)
        #~ self.vz2spinbox.valueChanged.connect(self.refresh)
        #~ self.vz1spinbox.valueChanged.connect(self.refresh)

        #
        self.changeData(
            analogsignals=analogsignals,
            spiketrains=spiketrains,
            vlimits=vlimits,
        )