E5Graphics/E5ArrowItem.py

Sat, 05 Jul 2014 15:02:45 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 05 Jul 2014 15:02:45 +0200
changeset 3682
2543741b47b7
parent 3656
441956d8fce5
child 4021
195a471c327b
permissions
-rw-r--r--

Changed a few files to reference eric6.

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
3160
209a07d7e401 Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2990
diff changeset
3 # Copyright (c) 2007 - 2014 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
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3057
diff changeset
10 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
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 import math
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
14 from PyQt5.QtCore import QPointF, QRectF, QSizeF, QLineF, Qt
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
15 from PyQt5.QtGui import QPen, QPolygonF
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
16 from PyQt5.QtWidgets import QAbstractGraphicsShapeItem, QGraphicsItem, QStyle
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 NormalArrow = 1
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 WideArrow = 2
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
21 ArrowheadAngleFactor = 0.26179938779914941
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
22 # 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
23
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
24
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 class E5ArrowItem(QAbstractGraphicsShapeItem):
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Class implementing an arrow graphics item subclass.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
29 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
30 filled=False, type=NormalArrow, parent=None):
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Constructor
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param origin origin of the arrow (QPointF)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @param end end point of the arrow (QPointF)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @param filled flag indicating a filled arrow head (boolean)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 @param type arrow type (NormalArrow, WideArrow)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 @keyparam parent reference to the parent object (QGraphicsItem)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
40 super(E5ArrowItem, self).__init__(parent)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self._origin = origin
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self._end = end
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self._filled = filled
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self._type = type
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self._halfLength = 13.0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.setFlag(QGraphicsItem.ItemIsMovable, True)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.setFlag(QGraphicsItem.ItemIsSelectable, True)
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 def setPoints(self, xa, ya, xb, yb):
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 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
55
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 <b>Note:</b> This method does not redraw the item.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @param xa x-coordinate of the start point (float)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 @param ya y-coordinate of the start point (float)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 @param xb x-coordinate of the end point (float)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 @param yb y-coordinate of the end point (float)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self._origin = QPointF(xa, ya)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self._end = QPointF(xb, yb)
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 def setStartPoint(self, x, y):
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 Public method to set the start point.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 <b>Note:</b> This method does not redraw the item.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 @param x x-coordinate of the start point (float)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 @param y y-coordinate of the start point (float)
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 self._origin = QPointF(x, y)
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 def setEndPoint(self, x, y):
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 Public method to set the end point.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 <b>Note:</b> This method does not redraw the item.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @param x x-coordinate of the end point (float)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 @param y y-coordinate of the end point (float)
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 self._end = QPointF(x, y)
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 def boundingRect(self):
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 Public method to return the bounding rectangle.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 @return bounding rectangle (QRectF)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 extra = self._halfLength / 2.0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 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
96 self._end.y() - self._origin.y()))\
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 .normalized()\
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 .adjusted(-extra, -extra, extra, extra)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
100 def paint(self, painter, option, widget=None):
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 Public method to paint the item in local coordinates.
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 @param painter reference to the painter object (QPainter)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 @param option style options (QStyleOptionGraphicsItem)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 @param widget optional reference to the widget painted on (QWidget)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
108 if (option.state & QStyle.State_Selected) == \
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
109 QStyle.State(QStyle.State_Selected):
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 width = 2
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 else:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 width = 1
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 line first
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 line = QLineF(self._origin, self._end)
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
116 painter.setPen(
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
117 QPen(Qt.black, width, Qt.SolidLine, Qt.FlatCap, Qt.MiterJoin))
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 painter.drawLine(line)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 # draw the arrow head
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 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
122 slope = math.atan2(line.dy(), line.dx())
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 # Calculate left arrow point
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 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
126 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
127 self._end.y() - self._halfLength * math.sin(arrowSlope))
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 # Calculate right arrow point
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 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
131 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
132 self._end.y() - self._halfLength * math.sin(arrowSlope))
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 if self._filled:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 painter.setBrush(Qt.black)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 else:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 painter.setBrush(Qt.white)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 polygon = QPolygonF()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 polygon.append(line.p2())
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 polygon.append(a1)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 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
142 painter.drawPolygon(polygon)

eric ide

mercurial