Exemplo n.º 1
0
    def test_plot_clear(self):
        # tests to make sure that when the clear flag is passed
        # to plots, that clear works as expected
        plot_item = MyPlotItem()
        x = [1]
        y = [1]
        plot = PlotCurveItem(x, y)
        plot_item.addItem(plot)

        plot2 = PlotCurveItem(y, x)
        plot_item.add_event_item(plot2)

        plot5 = PlotCurveItem(y, x)
        plot_item.addItem(plot5)

        x = y = np.zeros(2)
        plot3 = PathItem(x, y)
        plot_item.add_event_item(plot3)

        plot4 = plot_item.plot(clear=True)

        # Test that all of the plots have been cleared,
        # and that plot4 was added successfully
        self.assertEqual(len(plot_item.listDataItems()), 1)
        self.assertEqual(len(plot_item._myEventItemList), 0)
        self.assertEqual(len(plot_item._myItemList), 1)
        self.assertEqual(plot_item.listDataItems()[0], plot4)
        self.assertEqual(plot_item._myItemList[0], plot4)
Exemplo n.º 2
0
    def test_my_plot_item_add_item(self):
        plot_item = MyPlotItem()
        x = [1]
        y = [1]
        plot = PlotCurveItem(x, y)
        plot_item.addItem(plot)

        self.assertEqual(len(plot_item._myItemList), 1)

        x = y = np.zeros(2)
        plot2 = PathItem(x, y)
        plot_item.addItem(plot2)
        self.assertEqual(len(plot_item._myItemList), 2)
Exemplo n.º 3
0
    def test_clear_event_items(self):
        plot_item = MyPlotItem()
        x = [1]
        y = [1]
        plot = PlotCurveItem(x, y)
        plot_item.addItem(plot)

        plot2 = PlotCurveItem(y, x)
        plot_item.add_event_item(plot2)

        self.assertEqual(len(plot_item._myEventItemList), 1)
        self.assertEqual(len(plot_item.listDataItems()), 2)

        plot_item.clear_event_items()
        self.assertEqual(len(plot_item._myEventItemList), 0)

        self.assertEqual(len(plot_item.listDataItems()), 1)
Exemplo n.º 4
0
    def test_clear(self):
        plot_item = MyPlotItem()
        x = [1]
        y = [1]
        plot = PlotCurveItem(x, y)
        plot_item.addItem(plot)

        plot2 = PlotCurveItem(y, x)
        plot_item.add_event_item(plot2)

        x = y = np.zeros(2)
        plot3 = PathItem(x, y)
        plot_item.add_event_item(plot3)

        plot_item.clear()
        self.assertEqual(len(plot_item.listDataItems()), 0)
        self.assertEqual(len(plot_item._myEventItemList), 0)
        self.assertEqual(len(plot_item._myItemList), 0)
Exemplo n.º 5
0
    def _create_right_widget(self, parent=None):
        wig = pg.GraphicsLayoutWidget(parent)

        # Main plot
        self.plot_widget = MyPlotItem(title='Current Trace', name='Plot')
        wig.addItem(self.plot_widget)
        self.plot_widget.enableAutoRange('xy', False)
        self.p1 = self.plot_widget.plot(
        )  # create an empty plot curve to be filled later

        # Tool bar for main plot.  Contains zoom button and different checkboxes
        self.plot_tool_bar = PlotToolBar(self)
        if not parent is None:
            parent.addToolBar(self.plot_tool_bar)

        event_finder_plots_layout = LayoutWidget()
        event_finder_plots_layout.addWidget(self.plot_tool_bar,
                                            row=1,
                                            col=0,
                                            colspan=3)
        event_finder_plots_layout.addWidget(wig, row=2, col=0, colspan=3)

        return event_finder_plots_layout
Exemplo n.º 6
0
    def _create_event_viewer_plot_widget(self):
        wig = pg.GraphicsLayoutWidget()
        wig2 = pg.GraphicsLayoutWidget()

        # Main plot
        self.eventview_plotwid = MyPlotItem(title='Current Trace', name='Plot')
        wig.addItem(self.eventview_plotwid)
        self.eventview_plotwid.enableAutoRange('xy', False)

        wig.nextRow()
        # Create Qwt plot for concatenated events
        self.plot_concatevents = wig.addPlot(title='Concatenated Events',
                                             name='Concat')

        self.eventviewer_plots = []

        # Now add 9 plots to view events in
        for i in xrange(3):
            wig2.nextRow()
            for j in xrange(3):
                plot = wig2.addPlot(title='Event ' + str(i * 3 + j),
                                    name='Single' + str(i * 3 + j))
                self.eventviewer_plots.append(plot)

                # Tool bar for main plot.  Contains zoom button and different checkboxes
                #         self.plotToolBar = PlotToolBar(self)
                #         self.addToolBar(self.plotToolBar)

        event_select_toolbar = QtGui.QToolBar(self)
        if self._parent is not None:
            self._parent.addToolBar(event_select_toolbar)

        button_previous = QtGui.QPushButton(event_select_toolbar)
        button_previous.setText("Previous")
        button_previous.clicked.connect(self.previous_clicked)
        event_select_toolbar.addWidget(button_previous)

        self.event_display_edit = QtGui.QLineEdit()
        self.event_display_edit.setText('0')
        self.event_display_edit.setMaxLength(1)
        self.event_display_edit.setValidator(
            QtGui.QIntValidator(0, 0, self.event_display_edit))
        self.event_display_edit.textChanged.connect(
            self._event_display_edit_on_change)
        event_select_toolbar.addWidget(self.event_display_edit)

        self.event_count_text = QtGui.QLabel()
        self.event_count_text.setText('/' + str(0))
        event_select_toolbar.addWidget(self.event_count_text)

        button_previous = QtGui.QPushButton(event_select_toolbar)
        button_previous.setText("Next")
        button_previous.clicked.connect(self.next_clicked)
        event_select_toolbar.addWidget(button_previous)

        frame = QtGui.QSplitter()
        frame.setOrientation(QtCore.Qt.Vertical)
        frame.addWidget(wig)
        frame.addWidget(wig2)

        event_finder_plots_layout = LayoutWidget()
        # event_finder_plots_layout.addWidget(self.plotToolBar, row=1, col=0, colspan=3)
        event_finder_plots_layout.addWidget(frame, row=2, col=0, colspan=3)
        event_finder_plots_layout.addWidget(event_select_toolbar,
                                            row=5,
                                            col=0,
                                            colspan=3)

        return event_finder_plots_layout