source: orange/Orange/OrangeCanvas/canvas/items/tests/test_controlpoints.py @ 11161:981b2bbe3262

Revision 11161:981b2bbe3262, 1.8 KB checked in by Ales Erjavec <ales.erjavec@…>, 18 months ago (diff)

Removed control points from the annotation graphics items.

Line 
1from PyQt4.QtGui import QGraphicsRectItem, QGraphicsLineItem
2from PyQt4.QtCore import QRectF, QMargins, QLineF
3
4from . import TestItems
5
6from ..controlpoints import ControlPoint, ControlPointRect, ControlPointLine
7
8
9class TestControlPoints(TestItems):
10    def test_controlpoint(self):
11        point = ControlPoint()
12
13        self.scene.addItem(point)
14
15        point.setAnchor(ControlPoint.Left)
16        self.assertEqual(point.anchor(), ControlPoint.Left)
17
18    def test_controlpointrect(self):
19        control = ControlPointRect()
20        rect = QGraphicsRectItem(QRectF(10, 10, 100, 200))
21        self.scene.addItem(rect)
22        self.scene.addItem(control)
23
24        control.setRect(rect.rect())
25        control.setFocus()
26        control.rectChanged.connect(rect.setRect)
27
28        control.setRect(QRectF(20, 20, 100, 200))
29        self.assertEqual(control.rect(), rect.rect())
30        self.assertEqual(control.rect(), QRectF(20, 20, 100, 200))
31
32        control.setControlMargins(5)
33        self.assertEqual(control.controlMargins(), QMargins(5, 5, 5, 5))
34        control.rectEdited.connect(rect.setRect)
35
36        self.view.show()
37        self.app.exec_()
38
39        self.assertEqual(rect.rect(), control.rect())
40
41    def test_controlpointline(self):
42        control = ControlPointLine()
43        line = QGraphicsLineItem(10, 10, 200, 200)
44
45        self.scene.addItem(line)
46        self.scene.addItem(control)
47
48        control.setLine(line.line())
49        control.setFocus()
50        control.lineChanged.connect(line.setLine)
51
52        control.setLine(QLineF(30, 30, 180, 180))
53        self.assertEqual(control.line(), line.line())
54        self.assertEqual(line.line(), QLineF(30, 30, 180, 180))
55
56        control.lineEdited.connect(line.setLine)
57
58        self.view.show()
59        self.app.exec_()
60
61        self.assertEqual(control.line(), line.line())
Note: See TracBrowser for help on using the repository browser.