47
47
"""
48
48
49
49
from PyQt4 .QtCore import Qt , QPointF
50
- from PyQt4 .QtGui import QGraphicsPathItem , QPen , QGraphicsItem , QPainterPath , QPolygonF
50
+ from PyQt4 .QtGui import QGraphicsPathItem , QPen , QGraphicsItem , QPainterPath , QPolygonF , QPainter
51
51
from processing .modeler .ModelerGraphicItem import ModelerGraphicItem
52
52
from processing .modeler .ModelerAlgorithm import Algorithm
53
53
@@ -61,56 +61,62 @@ def __init__(self, startItem, startIndex, endItem, endIndex,
61
61
self .startIndex = startIndex
62
62
self .startItem = startItem
63
63
self .endItem = endItem
64
+ self .endPoints = []
64
65
self .setFlag (QGraphicsItem .ItemIsSelectable , False )
65
66
self .myColor = Qt .gray
66
67
self .setPen (QPen (self .myColor , 1 , Qt .SolidLine ,
67
68
Qt .RoundCap , Qt .RoundJoin ))
68
69
self .setZValue (0 )
69
70
70
- def paint (self , painter , option , widget = None ):
71
- myPen = self .pen ()
72
- myPen .setColor (self .myColor )
73
- painter .setPen (myPen )
74
- painter .setBrush (self .myColor )
75
-
71
+ def updatePath (self ):
72
+ self .endPoints = []
76
73
controlPoints = []
77
74
endPt = self .endItem .getLinkPointForParameter (self .endIndex )
78
75
startPt = self .startItem .getLinkPointForOutput (self .startIndex )
79
76
if isinstance (self .startItem .element , Algorithm ):
80
77
if self .startIndex != - 1 :
81
78
controlPoints .append (self .startItem .pos () + startPt )
82
79
controlPoints .append (self .startItem .pos () + startPt
83
- + QPointF (ModelerGraphicItem .BOX_WIDTH / 2 , 0 ))
80
+ + QPointF (ModelerGraphicItem .BOX_WIDTH / 3 , 0 ))
84
81
controlPoints .append (self .endItem .pos () + endPt
85
- - QPointF (ModelerGraphicItem .BOX_WIDTH / 2 , 0 ))
82
+ - QPointF (ModelerGraphicItem .BOX_WIDTH / 3 , 0 ))
86
83
controlPoints .append (self .endItem .pos () + endPt )
87
84
pt = QPointF (self .startItem .pos () + startPt
88
85
+ QPointF (- 3 , - 3 ))
89
- painter . drawEllipse ( pt . x (), pt . y (), 6 , 6 )
86
+ self . endPoints . append ( pt )
90
87
pt = QPointF (self .endItem .pos () + endPt +
91
88
QPointF (- 3 , - 3 ))
92
- painter . drawEllipse ( pt . x (), pt . y (), 6 , 6 )
89
+ self . endPoints . append ( pt )
93
90
else :
94
91
# Case where there is a dependency on an algorithm not
95
92
# on an output
96
93
controlPoints .append (self .startItem .pos () + startPt )
97
94
controlPoints .append (self .startItem .pos () + startPt
98
- + QPointF (ModelerGraphicItem .BOX_WIDTH / 2 , 0 ))
95
+ + QPointF (ModelerGraphicItem .BOX_WIDTH / 3 , 0 ))
99
96
controlPoints .append (self .endItem .pos () + endPt
100
- - QPointF (ModelerGraphicItem .BOX_WIDTH / 2 , 0 ))
97
+ - QPointF (ModelerGraphicItem .BOX_WIDTH / 3 , 0 ))
101
98
controlPoints .append (self .endItem .pos () + endPt )
102
99
else :
103
100
controlPoints .append (self .startItem .pos ())
104
101
controlPoints .append (self .startItem .pos ()
105
- + QPointF (ModelerGraphicItem .BOX_WIDTH / 2 , 0 ))
102
+ + QPointF (ModelerGraphicItem .BOX_WIDTH / 3 , 0 ))
106
103
controlPoints .append (self .endItem .pos () + endPt
107
- - QPointF (ModelerGraphicItem .BOX_WIDTH / 2 , 0 ))
104
+ - QPointF (ModelerGraphicItem .BOX_WIDTH / 3 , 0 ))
108
105
controlPoints .append (self .endItem .pos () + endPt )
109
106
pt = QPointF (self .endItem .pos () + endPt + QPointF (- 3 , - 3 ))
110
- painter .drawEllipse (pt .x (), pt .y (), 6 , 6 )
111
-
107
+ self .endPoints .append (pt )
112
108
path = QPainterPath ()
113
109
path .moveTo (controlPoints [0 ])
114
110
path .cubicTo (* controlPoints [1 :])
115
- painter .strokePath (path , painter .pen ())
116
111
self .setPath (path )
112
+
113
+ def paint (self , painter , option , widget = None ):
114
+ myPen = self .pen ()
115
+ myPen .setColor (self .myColor )
116
+ painter .setPen (myPen )
117
+ painter .setBrush (self .myColor )
118
+ painter .setRenderHint (QPainter .Antialiasing )
119
+
120
+ for point in self .endPoints :
121
+ painter .drawEllipse (point .x (), point .y (), 6 , 6 )
122
+ painter .strokePath (self .shape (), painter .pen ())
0 commit comments