예제 #1
0
    def paint1(self, painter, option, widget=None):
        #Q_UNUSED(a_option);
        #Q_UNUSED(a_widget);
        rect = self.boundingRect()
        tiotype = self.ioType()

        pen = qtg.QPen(colors.C.SOCKETBORDER.qColor())
        pen.setWidth(2)
        brush =  qtg.QBrush()
        if (self._isHover):
            brush.setColor(colors.C.SOCKETHOVER.qColor())
        elif (self._isDrop):
            brush.setColor(colors.C.SOCKETDROP.qColor())
        elif (self.isSignalOn()):
            brush.setColor(self._colorSignalOn)
        elif (not self.isSignalOn()):
            brush.setColor(self._colorSignalOff)
        #//  else if (tiotype == Type::eInput)
        #//    brush.setColor(config.getColor(Config::Color::eSocketInput));
        #//  else if (tiotype == Type::eOutput)
        #//    brush.setColor(config.getColor(Config::Color::eSocketOutput));
        if (tiotype == NodeIoType.DYNAMIC):
            brush.setStyle(qtc.Qt.Dense5Pattern)
        else:
            brush.setStyle(qtc.Qt.SolidPattern)

        painter.setPen(pen)
        painter.setBrush(brush)
        if (tiotype == NodeIoType.OUTPUT):
            painter.drawEllipse(rect)
        elif (tiotype == NodeIoType.DYNAMIC):
            painter.drawRect(rect)
            painter.drawEllipse(rect)
        else:
            painter.drawRect(rect)
        
        if (not self._used):
            painter.save()
            painter.setPen(qtc.Qt.NoPen)
            painter.setBrush(pen.color())
            
            if (tiotype == NodeIoType.OUTPUT):
                painter.drawEllipse(rect.adjusted(4, 4, -4, -4))
            elif (tiotype == NodeIoType.DYNAMIC):
                painter.drawRect(rect.adjusted(4, 4, -4, -4))
                painter.drawEllipse(rect.adjusted(4, 4, -4, -4))
            else:
                painter.drawRect(rect.adjusted(4, 4, -4, -4))
            painter.restore()

        if ( not self._nameHidden):
            pen.setColor(colors.C.FONTNAME.qColor())
            painter.setPen(pen)
            painter.setFont(self._font)
            metrics = qtg.QFontMetrics(self._font)
            FONT_HEIGHT = metrics.height()
            if (direction.LEFT == self.dir()):
                painter.drawText((rect.width()) - 4, (FONT_HEIGHT / 2) - metrics.strikeOutPos(), self.name())
            else:
                painter.drawText(-metrics.width(self.name()) - IoNodeView.SIZE + IoNodeView.SIZE / 3, (FONT_HEIGHT / 2) - metrics.strikeOutPos(), self.name())
예제 #2
0
    def drawBackground(self, painter, rect):

        penNormal = qtg.QPen(colors.PEN_NORMAL)
        penAxis = qtg.QPen(colors.PEN_AXIS) 

        #qreal const LEFT{ a_rect.left() };
        LEFT = rect.left()
        #qreal const RIGHT{ a_rect.right() };
        RIGHT = rect.right()
        #qreal const TOP{ a_rect.top() };
        TOP = rect.top()
        #qreal const BOTTOM{ a_rect.bottom() };
        BOTTOM = rect.bottom()

        #qreal const GRID_DENSITY{ (m_gridDensity == GridDensity::eSmall ? 100.0 : 10.0) };
        GRID_DENSITY = 100.0 if self._gridDensity == GridDensity.SMALL else 10.0

        #qreal const START_X{ std::round(LEFT / GRID_DENSITY) * GRID_DENSITY };
        START_X = round(LEFT / GRID_DENSITY) * GRID_DENSITY
        #qreal const START_Y{ std::round(TOP / GRID_DENSITY) * GRID_DENSITY };
        START_Y = round(TOP / GRID_DENSITY) * GRID_DENSITY

        if self._gridDensity == GridDensity.SMALL:
            penAxis.setWidth(2)
            penNormal.setWidth(2)
        
        
        #for x in range(START_X,RIGHT,GRID_DENSITY):
        x = START_X
        while x<RIGHT:
            PEN = penAxis if (x >= -0.1 and x <= 0.1) else penNormal
            painter.setPen(PEN)
            painter.drawLine(qtc.QPointF(x, TOP), qtc.QPointF(x, BOTTOM))
            x+=GRID_DENSITY

        #for y in range(START_Y,BOTTOM,GRID_DENSITY):
        y=START_Y
        while y<BOTTOM:
            PEN = penAxis if (y >= -0.1 and y <= 0.1) else penNormal 
            painter.setPen(PEN)
            painter.drawLine(qtc.QPointF(LEFT, y), qtc.QPointF(RIGHT, y))
            y+=GRID_DENSITY
예제 #3
0
    def paint(self,
              painter,
              option,
              widget=None):  #QStyleOptionGraphicsItem, QWidget
        #(void)option;
        #(void)widget;

        signalColor = self._colorSignalOn if self.isSignalOn(
        ) else self._colorSignalOff
        #QColor const notActive{ (isSelected() ? get_color(Color::eSelected) : signalColor) };
        notActive = colors.C.SELECTED.qColor() if self.isSelected(
        ) else signalColor
        #QColor const hover{ get_color(Color::eSocketHover) };
        hover = colors.C.SOCKETHOVER.qColor()
        #QPen pen{ (m_isHover ? hover : notActive) };
        pen = qtg.QPen(hover) if self._isHover else qtg.QPen(notActive)
        pstyle = qtc.Qt.SolidLine if (self._to != None) else qtc.Qt.DashDotLine
        pen.setStyle(pstyle)
        pen.setWidth(2)

        if (self._valueType.size() > 1):
            pen.setStyle(qtc.Qt.DotLine)
            pen.setWidth(4)
            pen.setDashOffset(self._dashOffset)
            '''        
            dash = pen
            hover2 = signalColor
            #hover2.setAlpha(85)
            dash.setColor(hover2)
            dash.setStyle(qtc.Qt.DotLine)
            dash.setWidth(4)
            dash.setDashOffset(self._dashOffset)
            painter.setPen(dash)
            painter.drawPath(self._path)

        else
        '''

        painter.setPen(pen)
        painter.drawPath(self._path)
예제 #4
0
    def paint(self, painter, option, widget=None):

        #self.updRec();
        
        tcolor = qtg.QColor(203, 217, 81,255) if self.state() else qtg.QColor(244, 53, 64,255)
        tbrush = qtg.QBrush(tcolor)
        tbrush.setColor(tcolor)
        tbrush.setStyle(qtc.Qt.SolidPattern)

        tpen = qtg.QPen(qtc.Qt.black)

        painter.setPen(tpen)
        painter.setBrush(tbrush)

        painter.drawRect(self.boundingRect())
예제 #5
0
    def paint(self, painter, option, widget=None):
        #Q_UNUSED(a_option);
        #Q_UNUSED(a_widget);
        rect = self.boundingRect()
        tiotype = self.ioType()
        tdir = self.dir()
        #effectivedir do not apply here because of rotation is handled by scene
        isInvert = self._parent.isInvertH()
        isInvertN = isInvert 
        if (tiotype == NodeIoType.OUTPUT and tdir==direction.LEFT) or (tiotype == NodeIoType.INPUT and tdir==direction.RIGHT):
            isInvertN = not isInvert
        startAngle = 90*16 if isInvertN else -90 * 16
        startAngleOutside = 90*16 if isInvertN else -90 * 16
        startAngleInside = -90 * 16  if isInvertN else 90*16
        if self.module().mType() == ModuleType.IO:
            if self.dir() in [direction.TOP,direction.DOWN]:
                startAngle = 0*16 if isInvert else -180 * 16
                startAngleOutside = 0*16 if isInvert else -180 * 16
                startAngleInside = -180 * 16  if isInvert else 0*16                 
        spanAngle = 180 * 16

        pen = qtg.QPen(colors.C.SOCKETBORDER.qColor())
        pens = None
        pen.setWidth(2)
        brush =  qtg.QBrush()
        if (self._isHover or self._inHover):
            #self.module().impl().consoleWrite(f'hoverOn:{self.name()}\n')
            brush.setColor(colors.C.SOCKETHOVER.qColor())
        elif (self._isDrop):
            brush.setColor(colors.C.SOCKETDROP.qColor())
        elif (self.isSignalOn()):
            brush.setColor(self._colorSignalOn)
        elif (not self.isSignalOn()):
            brush.setColor(self._colorSignalOff)
        #pens = qtg.QPen(brush.color())
        pens = self._colorSignalOn if self.isSignalOn() else self._colorSignalOff
        if (self._outHover and tiotype == NodeIoType.OUTPUT):
            pens = colors.C.SOCKETHOVER.qColor()
        #//  else if (tiotype == Type::eInput)
        #//    brush.setColor(config.getColor(Config::Color::eSocketInput));
        #//  else if (tiotype == Type::eOutput)
        #//    brush.setColor(config.getColor(Config::Color::eSocketOutput));
        if (tiotype == NodeIoType.DYNAMIC):
            brush.setStyle(qtc.Qt.Dense5Pattern)
        else:
            brush.setStyle(qtc.Qt.SolidPattern)

        painter.setPen(pen)
        painter.setBrush(brush)
        if (tiotype == NodeIoType.OUTPUT):
            painter.drawEllipse(rect)
            #painter.drawArc(rect.adjusted(-4, -4, +4, +4), startAngle, spanAngle)
            #painter.setPen(brush)
            if (self._used or self._links.itemCount()>0):
                painter.setPen(pens)
            painter.drawArc(rect.adjusted(-2, -2, +2, +2), startAngle, spanAngle)
        elif (tiotype == NodeIoType.DYNAMIC):
            painter.drawEllipse(rect)
            painter.drawArc(rect.adjusted(-2, -2, +2, +2), startAngleInside, spanAngle)
            painter.drawArc(rect.adjusted(-2, -2, +2, +2), startAngleOutside, spanAngle)
        else:
            painter.drawEllipse(rect)
            #painter.drawArc(rect.adjusted(-4, -4, +4, +4), startAngle, spanAngle)
            #painter.setPen(brush)
            painter.setPen(pens)
            painter.drawArc(rect.adjusted(-2, -2, +2, +2), startAngle, spanAngle)
            if (not self._used):
                #painter.save()
                painter.setPen(qtc.Qt.NoPen)
                painter.setBrush(pen.color())
                painter.drawEllipse(rect.adjusted(4, 4, -4, -4))
                #painter.restore()
            

        if ( not self._nameHidden):
            pen.setColor(colors.C.FONTNAME.qColor())
            painter.setPen(pen)
            painter.setFont(self._font)
            metrics = qtg.QFontMetrics(self._font)
            FONT_HEIGHT = metrics.height()
            if (direction.LEFT == self.dir()):
                painter.drawText((rect.width()) - 4, (FONT_HEIGHT / 2) - metrics.strikeOutPos(), self.name())
            else:
                painter.drawText(-metrics.width(self.name()) - IoNodeView.SIZE + IoNodeView.SIZE / 3, (FONT_HEIGHT / 2) - metrics.strikeOutPos(), self.name())