當前位置: 首頁>>代碼示例>>Python>>正文


Python Line.orthogonal方法代碼示例

本文整理匯總了Python中gaphas.item.Line.orthogonal方法的典型用法代碼示例。如果您正苦於以下問題:Python Line.orthogonal方法的具體用法?Python Line.orthogonal怎麽用?Python Line.orthogonal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gaphas.item.Line的用法示例。


在下文中一共展示了Line.orthogonal方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_orthogonal_horizontal_undo

# 需要導入模塊: from gaphas.item import Line [as 別名]
# 或者: from gaphas.item.Line import orthogonal [as 別名]
def test_orthogonal_horizontal_undo(revert_undo, undo_fixture):
    """Test orthogonal line constraints bug (#107).

    """
    canvas = Canvas()
    line = Line()
    canvas.add(line)
    assert not line.horizontal
    assert len(canvas.solver._constraints) == 0

    segment = Segment(line, None)
    segment.split_segment(0)

    line.orthogonal = True

    assert 2 == len(canvas.solver._constraints)

    del undo_fixture[2][:]  # Clear undo_list
    line.horizontal = True

    assert 2 == len(canvas.solver._constraints)

    undo_fixture[0]()  # Call undo

    assert not line.horizontal
    assert 2 == len(canvas.solver._constraints)

    line.horizontal = True

    assert line.horizontal
    assert 2 == len(canvas.solver._constraints)
開發者ID:amolenaar,項目名稱:gaphas,代碼行數:33,代碼來源:test_line.py

示例2: test_orthogonal_line_undo

# 需要導入模塊: from gaphas.item import Line [as 別名]
# 或者: from gaphas.item.Line import orthogonal [as 別名]
def test_orthogonal_line_undo(revert_undo, undo_fixture):
    """Test orthogonal line undo.

    """
    canvas = Canvas()
    line = Line()
    canvas.add(line)

    segment = Segment(line, None)
    segment.split_segment(0)

    # Start with no orthogonal constraints
    assert len(canvas.solver._constraints) == 0

    line.orthogonal = True

    # Check orthogonal constraints
    assert 2 == len(canvas.solver._constraints)
    assert 3 == len(line.handles())

    undo_fixture[0]()  # Call undo

    assert not line.orthogonal
    assert 0 == len(canvas.solver._constraints)
    assert 2 == len(line.handles())
開發者ID:amolenaar,項目名稱:gaphas,代碼行數:27,代碼來源:test_line.py

示例3: test_orthogonal_horizontal_undo

# 需要導入模塊: from gaphas.item import Line [as 別名]
# 或者: from gaphas.item.Line import orthogonal [as 別名]
    def test_orthogonal_horizontal_undo(self):
        canvas = Canvas()
        line = Line()
        canvas.add(line)

        assert len(canvas.solver._constraints) == 0

        line.orthogonal = True

        assert len(canvas.solver._constraints) == 2
        after_ortho = set(canvas.solver._constraints)

        del undo_list[:]
        line.horizontal = True

        assert len(canvas.solver._constraints) == 2

        undo()

        assert not line.horizontal
        assert len(canvas.solver._constraints) == 2, canvas.solver._constraints

        line.horizontal = True

        assert line.horizontal
        assert len(canvas.solver._constraints) == 2, canvas.solver._constraints
開發者ID:hugoruscitti,項目名稱:examplelab,代碼行數:28,代碼來源:test_line.py

示例4: test_orthogonal_line_split_segment

# 需要導入模塊: from gaphas.item import Line [as 別名]
# 或者: from gaphas.item.Line import orthogonal [as 別名]
    def test_orthogonal_line_split_segment(self):
        canvas = Canvas()
        line = Line()
        canvas.add(line)

        assert len(canvas.solver._constraints) == 0

        line.orthogonal = True

        assert len(canvas.solver._constraints) == 2
        after_ortho = set(canvas.solver._constraints)
        assert len(line.handles()) == 3

        del undo_list[:]

        line.split_segment(0)

        assert len(canvas.solver._constraints) == 3
        assert len(line.handles()) == 4

        undo()

        assert len(canvas.solver._constraints) == 2
        assert len(line.handles()) == 3
        assert canvas.solver._constraints == after_ortho

        line.split_segment(0)

        assert len(canvas.solver._constraints) == 3
        assert len(line.handles()) == 4
        after_split = set(canvas.solver._constraints)

        del undo_list[:]

        line.merge_segment(0)

        assert len(canvas.solver._constraints) == 2
        assert len(line.handles()) == 3

        undo()

        assert len(canvas.solver._constraints) == 3
        assert len(line.handles()) == 4
        assert canvas.solver._constraints == after_split
開發者ID:hugoruscitti,項目名稱:examplelab,代碼行數:46,代碼來源:test_line.py

示例5: test_line_guide

# 需要導入模塊: from gaphas.item import Line [as 別名]
# 或者: from gaphas.item.Line import orthogonal [as 別名]
    def test_line_guide(self):
        c = Canvas()
        l = Line()
        c.add(l)
        l.handles().append(l._create_handle((20, 20)))
        l.handles().append(l._create_handle((30, 30)))
        l.handles().append(l._create_handle((40, 40)))
        l.orthogonal = True
        c.update_now()

        guides = list(Guide(l).horizontal())
        self.assertEquals(2, len(guides))
        self.assertEquals(10.0, guides[0])
        self.assertEquals(40.0, guides[1])

        guides = list(Guide(l).vertical())
        self.assertEquals(2, len(guides))
        self.assertEquals(00.0, guides[0])
        self.assertEquals(20.0, guides[1])
開發者ID:adrianboguszewski,項目名稱:gaphas,代碼行數:21,代碼來源:test_guide.py


注:本文中的gaphas.item.Line.orthogonal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。