|
7 | 7 | PIPE_HIGHLIGHT_COLOR, PIPE_DISABLED_COLOR, |
8 | 8 | PIPE_STYLE_DASHED, PIPE_STYLE_DEFAULT, PIPE_STYLE_DOTTED, |
9 | 9 | PIPE_LAYOUT_STRAIGHT, PIPE_WIDTH, IN_PORT, OUT_PORT, Z_VAL_PIPE, |
10 | | - Z_VAL_NODE_WIDGET |
11 | | -) |
| 10 | + Z_VAL_NODE_WIDGET, |
| 11 | + PIPE_LAYOUT_ANGLE, PIPE_LAYOUT_CURVED) |
12 | 12 | from NodeGraphQt.qgraphics.port import PortItem |
13 | 13 |
|
14 | 14 | PIPE_STYLES = { |
@@ -163,25 +163,43 @@ def draw_path(self, start_port, end_port=None, cursor_pos=None): |
163 | 163 | path.lineTo(pos2) |
164 | 164 | self.setPath(path) |
165 | 165 | return |
| 166 | + elif self.viewer_pipe_layout() == PIPE_LAYOUT_CURVED: |
| 167 | + ctr_offset_x1, ctr_offset_x2 = pos1.x(), pos2.x() |
| 168 | + tangent = ctr_offset_x1 - ctr_offset_x2 |
| 169 | + tangent = (tangent * -1) if tangent < 0 else tangent |
| 170 | + |
| 171 | + max_width = start_port.node.boundingRect().width() / 2 |
| 172 | + tangent = max_width if tangent > max_width else tangent |
| 173 | + if start_port.port_type == IN_PORT: |
| 174 | + ctr_offset_x1 -= tangent |
| 175 | + ctr_offset_x2 += tangent |
| 176 | + else: |
| 177 | + ctr_offset_x1 += tangent |
| 178 | + ctr_offset_x2 -= tangent |
166 | 179 |
|
167 | | - ctr_offset_x1, ctr_offset_x2 = pos1.x(), pos2.x() |
168 | | - tangent = ctr_offset_x1 - ctr_offset_x2 |
169 | | - tangent = (tangent * -1) if tangent < 0 else tangent |
170 | | - |
171 | | - max_width = start_port.node.boundingRect().width() / 2 |
172 | | - tangent = max_width if tangent > max_width else tangent |
| 180 | + ctr_point1 = QtCore.QPointF(ctr_offset_x1, pos1.y()) |
| 181 | + ctr_point2 = QtCore.QPointF(ctr_offset_x2, pos2.y()) |
| 182 | + path.cubicTo(ctr_point1, ctr_point2, pos2) |
| 183 | + self.setPath(path) |
| 184 | + elif self.viewer_pipe_layout() == PIPE_LAYOUT_ANGLE: |
| 185 | + ctr_offset_x1, ctr_offset_x2 = pos1.x(), pos2.x() |
| 186 | + distance = ctr_offset_x1 - ctr_offset_x2 |
| 187 | + distance = (distance * -1) if distance < 0 else distance |
| 188 | + distance /= 2 |
| 189 | + if start_port.port_type == IN_PORT: |
| 190 | + ctr_offset_x1 -= distance |
| 191 | + ctr_offset_x2 += distance |
| 192 | + else: |
| 193 | + ctr_offset_x1 += distance |
| 194 | + ctr_offset_x2 -= distance |
173 | 195 |
|
174 | | - if start_port.port_type == IN_PORT: |
175 | | - ctr_offset_x1 -= tangent |
176 | | - ctr_offset_x2 += tangent |
177 | | - else: |
178 | | - ctr_offset_x1 += tangent |
179 | | - ctr_offset_x2 -= tangent |
| 196 | + ctr_point1 = QtCore.QPointF(ctr_offset_x1, pos1.y()) |
| 197 | + ctr_point2 = QtCore.QPointF(ctr_offset_x2, pos2.y()) |
| 198 | + path.lineTo(ctr_point1) |
| 199 | + path.lineTo(ctr_point2) |
| 200 | + path.lineTo(pos2) |
| 201 | + self.setPath(path) |
180 | 202 |
|
181 | | - ctr_point1 = QtCore.QPointF(ctr_offset_x1, pos1.y()) |
182 | | - ctr_point2 = QtCore.QPointF(ctr_offset_x2, pos2.y()) |
183 | | - path.cubicTo(ctr_point1, ctr_point2, pos2) |
184 | | - self.setPath(path) |
185 | 203 |
|
186 | 204 | def reset_path(self): |
187 | 205 | path = QtGui.QPainterPath(QtCore.QPointF(0.0, 0.0)) |
|
0 commit comments