E5Graphics/E5ArrowItem.py

Sun, 05 Jun 2011 18:25:36 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 05 Jun 2011 18:25:36 +0200
changeset 1112
8a7d1b9d18db
parent 945
8cd4d08fa9f6
child 1131
7781e396c903
permissions
-rw-r--r--

Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.

51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
791
9ec2ac20e54e Updated copyright notice.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 51
diff changeset
3 # Copyright (c) 2007 - 2011 Detlev Offenbach <detlev@die-offenbachs.de>
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a graphics item subclass for an arrow.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
1112
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
10 import math
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
1112
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
12 from PyQt4.QtCore import QPointF, QRectF, QSizeF, QLineF, Qt
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
13 from PyQt4.QtGui import QAbstractGraphicsShapeItem, QGraphicsItem, QStyle, QPen, QPolygonF
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 NormalArrow = 1
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 WideArrow = 2
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
1112
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
18 ArrowheadAngleFactor = 0.26179938779914941 # 0.5 * math.atan(math.sqrt(3.0) / 3.0)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
20
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 class E5ArrowItem(QAbstractGraphicsShapeItem):
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Class implementing an arrow graphics item subclass.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
25 def __init__(self, origin=QPointF(), end=QPointF(),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
26 filled=False, type=NormalArrow, parent=None):
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 Constructor
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param origin origin of the arrow (QPointF)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param end end point of the arrow (QPointF)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param filled flag indicating a filled arrow head (boolean)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param type arrow type (NormalArrow, WideArrow)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @keyparam parent reference to the parent object (QGraphicsItem)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 QAbstractGraphicsShapeItem.__init__(self, parent)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self._origin = origin
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self._end = end
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self._filled = filled
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self._type = type
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self._halfLength = 13.0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.setFlag(QGraphicsItem.ItemIsMovable, True)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.setFlag(QGraphicsItem.ItemIsSelectable, True)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 def setPoints(self, xa, ya, xb, yb):
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 Public method to set the start and end points of the line.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 <b>Note:</b> This method does not redraw the item.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 @param xa x-coordinate of the start point (float)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 @param ya y-coordinate of the start point (float)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 @param xb x-coordinate of the end point (float)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 @param yb y-coordinate of the end point (float)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self._origin = QPointF(xa, ya)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self._end = QPointF(xb, yb)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 def setStartPoint(self, x, y):
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 Public method to set the start point.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 <b>Note:</b> This method does not redraw the item.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 @param x x-coordinate of the start point (float)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 @param y y-coordinate of the start point (float)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self._origin = QPointF(x, y)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 def setEndPoint(self, x, y):
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 Public method to set the end point.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 <b>Note:</b> This method does not redraw the item.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 @param x x-coordinate of the end point (float)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 @param y y-coordinate of the end point (float)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self._end = QPointF(x, y)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 def boundingRect(self):
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 Public method to return the bounding rectangle.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 @return bounding rectangle (QRectF)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 extra = self._halfLength / 2.0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 return QRectF(self._origin, QSizeF(self._end.x() - self._origin.x(),
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self._end.y() - self._origin.y()))\
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 .normalized()\
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 .adjusted(-extra, -extra, extra, extra)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
96 def paint(self, painter, option, widget=None):
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 Public method to paint the item in local coordinates.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 @param painter reference to the painter object (QPainter)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 @param option style options (QStyleOptionGraphicsItem)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 @param widget optional reference to the widget painted on (QWidget)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 if (option.state & QStyle.State_Selected) == QStyle.State(QStyle.State_Selected):
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 width = 2
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 else:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 width = 1
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 # draw the line first
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 line = QLineF(self._origin, self._end)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 painter.setPen(QPen(Qt.black, width, Qt.SolidLine, Qt.FlatCap, Qt.MiterJoin))
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 painter.drawLine(line)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 # draw the arrow head
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 arrowAngle = self._type * ArrowheadAngleFactor
1112
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
116 slope = math.atan2(line.dy(), line.dx())
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 # Calculate left arrow point
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 arrowSlope = slope + arrowAngle
1112
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
120 a1 = QPointF(self._end.x() - self._halfLength * math.cos(arrowSlope),
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
121 self._end.y() - self._halfLength * math.sin(arrowSlope))
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 # Calculate right arrow point
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 arrowSlope = slope - arrowAngle
1112
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
125 a2 = QPointF(self._end.x() - self._halfLength * math.cos(arrowSlope),
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
126 self._end.y() - self._halfLength * math.sin(arrowSlope))
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 if self._filled:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 painter.setBrush(Qt.black)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 else:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 painter.setBrush(Qt.white)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 polygon = QPolygonF()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 polygon.append(line.p2())
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 polygon.append(a1)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 polygon.append(a2)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
136 painter.drawPolygon(polygon)

eric ide

mercurial