-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from jchanvfx/slice_pipes
pipe connection slicer tool
- Loading branch information
Showing
9 changed files
with
157 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/python | ||
from NodeGraphQt import QtCore, QtGui, QtWidgets | ||
from NodeGraphQt.constants import Z_VAL_NODE_WIDGET, PIPE_SLICER_COLOR | ||
|
||
|
||
class SlicerPipe(QtWidgets.QGraphicsPathItem): | ||
""" | ||
Base item used for drawing the pipe connection slicer. | ||
""" | ||
|
||
def __init__(self): | ||
super(SlicerPipe, self).__init__() | ||
self.setZValue(Z_VAL_NODE_WIDGET + 2) | ||
|
||
def paint(self, painter, option, widget): | ||
""" | ||
Draws the slicer pipe. | ||
Args: | ||
painter (QtGui.QPainter): painter used for drawing the item. | ||
option (QtGui.QStyleOptionGraphicsItem): | ||
used to describe the parameters needed to draw. | ||
widget (QtWidgets.QWidget): not used. | ||
""" | ||
color = QtGui.QColor(*PIPE_SLICER_COLOR) | ||
p1 = self.path().pointAtPercent(0) | ||
p2 = self.path().pointAtPercent(1) | ||
size = 6.0 | ||
offset = size / 2 | ||
|
||
painter.save() | ||
painter.setRenderHint(painter.Antialiasing, True) | ||
|
||
font = painter.font() | ||
font.setPointSize(12) | ||
painter.setFont(font) | ||
text = 'slice' | ||
text_x = painter.fontMetrics().width(text) / 2 | ||
text_y = painter.fontMetrics().height() / 1.5 | ||
text_pos = QtCore.QPointF(p1.x() - text_x, p1.y() - text_y) | ||
text_color = QtGui.QColor(*PIPE_SLICER_COLOR) | ||
text_color.setAlpha(80) | ||
painter.setPen(QtGui.QPen(text_color, 1.5, QtCore.Qt.SolidLine)) | ||
painter.drawText(text_pos, text) | ||
|
||
painter.setPen(QtGui.QPen(color, 1.5, QtCore.Qt.DashLine)) | ||
painter.drawPath(self.path()) | ||
|
||
painter.setPen(QtGui.QPen(color, 1.5, QtCore.Qt.SolidLine)) | ||
painter.setBrush(color) | ||
|
||
rect = QtCore.QRectF(p1.x() - offset, p1.y() - offset, size, size) | ||
painter.drawEllipse(rect) | ||
|
||
rect = QtCore.QRectF(p2.x() - offset, p2.y() - offset, size, size) | ||
painter.drawEllipse(rect) | ||
painter.restore() | ||
|
||
def draw_path(self, p1, p2): | ||
path = QtGui.QPainterPath() | ||
path.moveTo(p1) | ||
path.lineTo(p2) | ||
self.setPath(path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
PySide2>=5.12 | ||
Qt.py>=1.2.0.b2 | ||
python>=3.6 | ||
python>=3.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters