Пример #1
0
 def test_add_color(self, qtbot: QtBot):
     widget = ColormapCreator()
     colormap_edit = widget.show_colormap
     color1 = QColor(10, 40, 12)
     color2 = QColor(100, 4, 220)
     widget.color_picker.setCurrentColor(color1)
     with qtbot.waitSignal(colormap_edit.double_clicked):
         qtbot.mouseDClick(colormap_edit,
                           Qt.LeftButton,
                           pos=QPoint(30,
                                      widget.height() // 2))
     assert len(widget.current_colormap()) == 1
     assert widget.current_colormap()[0].color == Color(10, 40, 12)
     assert isclose(widget.current_colormap()[0].color_position,
                    20 / (colormap_edit.width() - 20))
     widget.color_picker.setCurrentColor(color2)
     with qtbot.waitSignal(colormap_edit.double_clicked):
         qtbot.mouseDClick(colormap_edit,
                           Qt.LeftButton,
                           pos=QPoint(80,
                                      widget.height() // 2))
     assert len(widget.current_colormap()) == 2
     assert widget.current_colormap()[0].color == Color(10, 40, 12)
     assert widget.current_colormap()[1].color == Color(100, 4, 220)
     assert isclose(widget.current_colormap()[0].color_position,
                    20 / (colormap_edit.width() - 20))
     assert isclose(widget.current_colormap()[1].color_position,
                    70 / (colormap_edit.width() - 20))
Пример #2
0
 def test_add_color(self, qtbot: QtBot):
     widget = ColormapCreator()
     colormap_edit = widget.show_colormap
     color1 = QColor(10, 40, 12)
     color2 = QColor(100, 4, 220)
     widget.color_picker.setCurrentColor(color1)
     with qtbot.waitSignal(colormap_edit.double_clicked):
         qtbot.mouseDClick(colormap_edit,
                           Qt.LeftButton,
                           pos=QPoint(30,
                                      widget.height() // 2))
     assert len(widget.current_colormap().colors) == 3
     assert np.allclose(widget.current_colormap().colors[0],
                        Color(10 / 255, 40 / 255, 12 / 255))
     assert isclose(widget.current_colormap().controls[1],
                    20 / (colormap_edit.width() - 20))
     widget.color_picker.setCurrentColor(color2)
     with qtbot.waitSignal(colormap_edit.double_clicked):
         qtbot.mouseDClick(colormap_edit,
                           Qt.LeftButton,
                           pos=QPoint(80,
                                      widget.height() // 2))
     assert len(widget.current_colormap().colors) == 4
     assert np.allclose(widget.current_colormap().colors[1],
                        Color(10 / 255, 40 / 255, 12 / 255))
     assert np.allclose(widget.current_colormap().colors[2],
                        Color(100 / 255, 4 / 255, 220 / 255))
     assert isclose(widget.current_colormap().controls[1],
                    20 / (colormap_edit.width() - 20))
     assert isclose(widget.current_colormap().controls[2],
                    70 / (colormap_edit.width() - 20))
Пример #3
0
    def test_click(self, qtbot: QtBot):
        widget = ColormapEdit()
        qtbot.addWidget(widget)
        width = widget.width() - 20
        with qtbot.waitSignal(widget.double_clicked):
            qtbot.mouseDClick(widget,
                              Qt.LeftButton,
                              pos=QPoint(30,
                                         widget.height() // 2))

        pos = 20 / width
        widget.add_color(ColorPosition(pos, Color(125, 231, 21)))
        assert len(widget.colormap) == 1
        with qtbot.assertNotEmitted(widget.double_clicked):
            qtbot.mouseDClick(widget,
                              Qt.LeftButton,
                              pos=QPoint(30,
                                         widget.height() // 2))
        assert len(widget.colormap) == 0
Пример #4
0
    def test_click(self, qtbot: QtBot):
        widget = ColormapEdit()
        qtbot.addWidget(widget)
        width = widget.width() - 20
        with qtbot.waitSignal(widget.double_clicked):
            qtbot.mouseDClick(widget,
                              Qt.LeftButton,
                              pos=QPoint(30,
                                         widget.height() // 2))

        pos = 20 / width
        widget.add_color(pos, Color(0.274, 0.02, 0.745))
        widget.add_color(pos / 2, Color(0.274, 0.2, 0.745))
        assert len(widget.colormap.colors) == 4
        with qtbot.assertNotEmitted(widget.double_clicked):
            qtbot.mouseDClick(widget,
                              Qt.LeftButton,
                              pos=QPoint(30,
                                         widget.height() // 2))
        assert len(widget.colormap.colors) == 3