def __init__(self, *args, **kwargs): super(OutputKnob, self).__init__(*args, **kwargs) self.name = kwargs.get("name", "output") self.displayName = kwargs.get("displayName", self.name) self.fillColor = kwargs.get("fillColor", QtGui.QColor(230, 130, 130)) self.fillColor = kwargs.get("fillColor", QtGui.QColor(50, 100, 80)) self.flow = kwargs.get("flow", FLOW_RIGHT_TO_LEFT)
def __init__(self, *args, **kwargs): super(GraphicsView, self).__init__(*args, **kwargs) self.fillColor = QtGui.QColor(38, 38, 38) self.lineColor = QtGui.QColor(55, 55, 55) self.xStep = 20 self.yStep = 20 self.current_zoom = 1.0 self.panningMult = 2.0 * self.current_zoom self.panning = False self.zoomStep = 1.1 # Since we implement custom panning, we don't need the scrollbars. self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) # self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) # self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.setDragMode(QtWidgets.QGraphicsView.RubberBandDrag) self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse) self.setViewportUpdateMode(self.SmartViewportUpdate) # self.glWidget = QtOpenGL.QGLWidget(QtOpenGL.QGLFormat(QtOpenGL.QGL.SampleBuffers)) # self.glWidget.updateGL() # self.setViewport(self.glWidget) self.colorTable = ColorTable(self)
def __init__(self, **kwargs): kwargs.pop("name") super(Knob, self).__init__(**kwargs) self.x = 0 self.y = 0 self.w = 10 self.h = 10 self.margin = 5 self.flow = FLOW_LEFT_TO_RIGHT self.maxConnections = -1 # A negative value means 'unlimited'. self.name = "value" self.displayName = self.name self.labelColor = QtGui.QColor(10, 10, 10) self.fillColor = QtGui.QColor(230, 230, 0) self.highlightColor = QtGui.QColor(255, 255, 0) # Temp store for Edge currently being created. self.newEdge = None self.edges = [] self.setAcceptHoverEvents(True)
def set_color(self, step): if self.basset_name == 'cc_bundle': self.normal_color = QtGui.QLinearGradient( QtCore.QPointF(0, 0), QtCore.QPointF(self.w, 0)) color1 = SPECIAL_COLOR['cc_bundle'][0] color2 = SPECIAL_COLOR['cc_bundle'][1] self.normal_color.setColorAt( 0, QtGui.QColor(color1[0], color1[1], color1[2])) self.normal_color.setColorAt( 1, QtGui.QColor(color2[0], color2[1], color2[2])) self.fill_color = self.normal_color else: super(PlaVersionItem, self).set_color(step)
def paintEvent(self, event): painter = QtGui.QPainter(self) painter.setPen(QtCore.Qt.NoPen) painter.setBrush( QtGui.QBrush( QtGui.QColor(self.text_color.red(), self.text_color.green(), self.text_color.blue(), 20))) painter.drawRoundedRect(0, 0, self.width(), self.height(), 5, 5) super(_BaseNoteWidget, self).paintEvent(event)
def __init__(self, shape=None, text=None, color=None, **kwargs): super(Tag, self).__init__(**kwargs) self.shape = shape self.text = text self.color = color self.x = 0 self.y = 0 self.w = TAG_W self.h = TAG_H self.margin = 5 self.name = "value" self.displayName = self.name self.auto_hide = True self.textColor = QtGui.QColor(10, 10, 10) self.fillColor = self.color if self.color is not None else QtGui.QColor( 170, 170, 170) self.highlightColor = QtGui.QColor(255, 255, 0) self.setAcceptHoverEvents(True)
def paint(self, painter, option, widget): """Draw the Knob's shape and label.""" bbox = self.boundingRect() # Draw a filled rectangle. # painter.setPen(QtGui.QPen(QtCore.Qt.NoPen)) pen = QtGui.QPen(QtGui.QColor(200, 200, 250)) pen.setWidth(1) painter.setPen(pen) painter.setBrush(QtGui.QBrush(self.fillColor)) # painter.drawRect(bbox) painter.drawEllipse(bbox) # Draw a text label next to it. Position depends on the flow. if self.flow == FLOW_LEFT_TO_RIGHT: x = bbox.right() + self.margin elif self.flow == FLOW_RIGHT_TO_LEFT: x = bbox.left() - self.margin else: raise Exception("Flow not recognized: {0}".format(self.flow)) y = bbox.bottom() self.setZValue(10)
def drawBackground(self, painter, rect): painter.setBrush(QtGui.QBrush(self.fillColor)) painter.setPen(QtGui.QPen(self.lineColor)) painter.drawRect(rect) lines = [] scale = max(int(1 / self.current_zoom / 2), 1) line_w = 200 * scale line_h = 80 * scale point1 = self.mapToScene(QtCore.QPoint(0, 0)) point2 = self.mapToScene( QtCore.QPoint(self.viewport().width(), self.viewport().height())) # for i in range(int(point1.y() / line_h), int(self.scene().height() / line_h)): for i in range(int(point1.y() / line_h), int(point2.y() / line_h)): lines.append( QtCore.QLineF( QtCore.QPoint(rect.x(), i * line_h), QtCore.QPoint(rect.x() + rect.width(), i * line_h))) # for i in range(int(self.scene().sceneRect().x()), int(self.scene().width() / line_w)): for i in range(int(point1.x() / line_w), int(point2.x() / line_w)): lines.append( QtCore.QLineF( QtCore.QPoint(i * line_w, rect.y()), QtCore.QPoint(i * line_w, rect.y() + rect.height()))) painter.drawLines(lines) painter.setPen(QtGui.QPen(QtGui.QColor(80, 80, 60, 50))) painter.drawLine( QtCore.QLineF(QtCore.QPoint(rect.x(), 0), QtCore.QPoint(rect.x() + rect.width(), 0))) painter.drawLine( QtCore.QLineF(QtCore.QPoint(0, rect.y()), QtCore.QPoint(0, rect.y() + rect.height())))
def __init__(self, version, entity, asset, *args, **kwargs): super(VersionItem, self).__init__(*args, **kwargs) self.x = 0 self.y = 0 self.w = 220 self.h = 80 self._parent = None self._children = [] self.version = version self.entity = entity self.asset = asset self.id = version.id self.edges = [] self.orientation = 0 self.margin = 6 self.roundness = 10 self.base_color = QtGui.QColor(210, 210, 210) self.base_color = QtGui.QColor(50, 60, 70) self.normal_color = self.base_color self.highlight_color = QtGui.QColor(250, 250, 150) self.highlight_color = QtGui.QColor(230, 230, 100) self.fill_color = self.normal_color self.border_color = QtGui.QColor(150, 150, 210) self.border_color = QtGui.QColor(180, 180, 250) self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, True) self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, True) self.dependent_versions = self.version.sources self.dependent_versions_count = self.dependent_versions.count() self.destination_versions = self.version.destinations self.destination_versions_count = self.destination_versions.count() self.connected_sources = dict() self.connected_destinations = dict() self.children_populated = False self.parent_populated = False
def set_color(self, step): color = get_pipeline_color(step) self.normal_color = QtGui.QColor(color[0], color[1], color[2], 200) self.fill_color = self.normal_color
def __init__(self, *args, **kwargs): super(InputKnob, self).__init__(*args, **kwargs) self.name = kwargs.get("name", "input") self.displayName = kwargs.get("displayName", self.name) self.fillColor = kwargs.get("fillColor", QtGui.QColor(130, 230, 130)) self.fillColor = kwargs.get("fillColor", QtGui.QColor(40, 60, 100))