Ejemplo n.º 1
0
    def test_qfigure2(self):
        fig = vpl.QtFigure2("a qt widget figure")
        self.assertIs(fig, vpl.gcf())

        vpl.scatter(np.arange(9).reshape((3, 3)).T)
        vpl.quick_test_plot()

        fig.add_all()

        fig.show(block=False)
        fig.qapp.processEvents()

        for i in fig.view_buttons.buttons:
            i.released.emit()
            fig.qapp.processEvents()
            time.sleep(.1)

        fig.screenshot_button.released.emit()
        fig.show_plot_table_button.released.emit()

        fig.show()
Ejemplo n.º 2
0
def test_qfigure2():
    fig = vpl.QtFigure2("a QWidget figure")
    fig.setWindowTitle(fig.window_name)
    assert fig is vpl.gcf()

    plot = vpl.scatter(np.arange(9).reshape((3, 3)).T)[0]
    vpl.quick_test_plot()

    fig.add_all()

    fig.show(block=False)
    fig.qapp.processEvents()

    for i in fig.view_buttons.buttons:
        i.released.emit()
        fig.qapp.processEvents()
        time.sleep(.1)

    if not VTKPLOTLIB_WINDOWLESS_TEST:
        fig.screenshot_button.released.emit()
    fig.show_plot_table_button.released.emit()

    fig.show(block=False)

    for plot in fig.plot_table.rows:
        fig.plot_table.rows[plot].text.released.emit()
        fig.qapp.processEvents()
        assert not plot.visible

    assert np.allclose(vpl.screenshot_fig(fig=fig),
                       np.array(255) * fig.background_color,
                       atol=1.)

    for plot in fig.plot_table.rows:
        fig.plot_table.rows[plot].text.released.emit()
        fig.qapp.processEvents()
        assert plot.visible

    fig.plot_table.close()
Ejemplo n.º 3
0
    def _mouse_move_cb(self, invoker, name):
        if self._click_location:
            self.pick.update()
            if self._clicks_are_equal(self._click_location,
                                      self.pick.point_2D):
                return
            self._click_location = None
        # Only calling the super event with the mouse button down (which rotates
        # the model for left click) when we are sure that this click is not
        # meant to place a marker reduces the slight jolt when you click on with
        # a sensitive mouse. Move the lines below to the top of this method to
        # see what I mean.
        if self._super_on_mouse_move:
            call_super_callback()


if __name__ == "__main__":
    import vtkplotlib as vpl

    fig = vpl.QtFigure2()
    style = fig.style

    balls = vpl.quick_test_plot()
    rabbit = vpl.mesh_plot(vpl.data.get_rabbit_stl())
    rabbit.vertices -= [i.mean() for i in vpl.unzip_axes(rabbit.vertices)]
    rabbit.vertices /= 5
    text = vpl.text("text")

    vpl.show()
Ejemplo n.º 4
0

class QLabel_alterada(QtWidgets.QLabel):
    released = QtCore.pyqtSignal()

    def mouseReleaseEvent(self, ev):
        self.released.emit()


if __name__ == "__main__":
    import vtkplotlib as vpl

    app = None
    app = QtWidgets.QApplication(sys.argv)

    self = vpl.QtFigure2("Rabbits")

    plot = vpl.mesh_plot(vpl.data.get_rabbit_stl())
    # plot.name = "rabbit"
    # mesh_2 = Mesh.from_file(vpl.data.get_rabbit_stl())
    # mesh_2.translate(np.array([100, 0, 0]))
    # vpl.scatter(np.random.uniform(-100, 100, (3, 3)))

    self.add_all()
    fig, self = self, self.view_buttons

    #    M = np.roll(np.eye(3), 1, 0)
    #    self.rotate(M)

    fig.show()
#
Ejemplo n.º 5
0
                colors[i] = np.zeros(len(points[i]))
        new.point_colors = np.concatenate(colors)

        return new


if __name__ == "__main__":
    import vtkplotlib as vpl

    t = np.arange(0, 1, .01) * 2 * np.pi
    points = np.array([np.cos(t), np.sin(t), np.cos(t)
                       * np.sin(t)], dtype=np.float32).T

    path = Path(vpl.data.get_rabbit_stl())

    vpl.QtFigure2().add_screenshot_button()

#    other = vpl.plot(points, color="r").polydata
    self = PolyData()
##    self.points = points
###
###    n, m = 10, 50
###    itr_of_arrays = np.random.randint(0, len(points), (n, m))
####    lines = np.concatenate((np.ones((n, 1), int) * m, lines), axis=1)
###
#    lines = [np.random.randint(0, len(t), np.random.randint(3, 5)) for i in range(10)]
#    self = vpl.plots.polydata.PolyData()
#    self.points = points
#    self.lines = join_line_ends(lines)
#    self.to_plot()