Example #1
0
    def __init__(self, parent=None):
        """
        Default class constructor.

        :param `parent`: Pointer to a parent widget instance.
        :type `parent`: `QGraphicsItem`_
        """
        super(BaseObject, self).__init__(parent)

        qDebug("BaseObject Constructor()")

        self.objPen = QPen()        # QPen objPen;
        self.lwtPen = QPen()        # QPen lwtPen;
        self.objLine = QLineF()     # QLineF objLine;
        self.objRubberMode = int()  # int objRubberMode;
        self.objRubberPoints = {}   # QHash<QString, QPointF> objRubberPoints;
        self.objRubberTexts = {}    # QHash<QString, QString> objRubberTexts;
        self.objID = int()          # qint64 objID;

        self.objPen.setCapStyle(Qt.RoundCap)
        self.objPen.setJoinStyle(Qt.RoundJoin)
        self.lwtPen.setCapStyle(Qt.RoundCap)
        self.lwtPen.setJoinStyle(Qt.RoundJoin)

        self.objID = QDateTime.currentMSecsSinceEpoch()
Example #2
0
 def paintEvent(self, pe):
     painter = QPainter(self)
     painter.save()
     gradient = QLinearGradient()
     gradient.setStart(self._grad_start)
     gradient.setFinalStop(self._grad_end)
     gradient.setColorAt(0, QColor(230, 230, 230))
     gradient.setColorAt(1, QColor(247, 247, 247))
     brush = QBrush(gradient)
     painter.setBrush(brush)
     pen = QPen(Qt.black)
     pen.setWidth(1)
     painter.setPen(pen)
     painter.drawPath(self._painter_path)
     painter.restore()
     font = QFont()
     font.setFamily("Tahoma")
     font.setPixelSize(11)
     font.setBold(True)
     pen = QPen(Qt.darkGray)
     painter.setPen(pen)
     painter.setFont(font)
     self_rect = QRect(self.rect())
     self_rect.moveTo(self._hor_margin, self._ver_margin // 2)
     painter.drawText(self_rect, Qt.AlignLeft, self._text)
Example #3
0
class GraphTreeItemDelegate(QtGui.QStyledItemDelegate):
	_textBrush      = QBrush( QColor( '#dd5200' ) )
	_textPen        = QPen( QColor( '#dddddd' ) )
	_textPenGroup   = QPen( QColor( '#ada993' ) )
	_backgroundBrushHovered  = QBrush( QColor( '#454768' ) )
	_backgroundBrushSelected = QBrush( QColor( '#515c84' ) )
	
	def paint(self, painter, option, index):
		painter.save()
		index0 = index.sibling( index.row(), 0 )
		utype = index0.data( Qt.UserRole )

		# # set background color
		if option.state & QStyle.State_Selected:
			painter.setPen  ( Qt.NoPen )
			painter.setBrush( GraphTreeItemDelegate._backgroundBrushSelected )
			painter.drawRect(option.rect)
		elif option.state & QStyle.State_MouseOver:
			painter.setPen  ( Qt.NoPen )
			painter.setBrush( GraphTreeItemDelegate._backgroundBrushHovered )
			painter.drawRect(option.rect)

		rect = option.rect
		icon = QIcon( index.data( Qt.DecorationRole) )
		rect.adjust( 5, 0, 0, 0 )
		if icon and not icon.isNull():
			icon.paint( painter, rect, Qt.AlignLeft )
			rect.adjust( 22, 0, 0, 0 )
		text = index.data(Qt.DisplayRole)
		if utype == 1: #GROUP
			painter.setPen( GraphTreeItemDelegate._textPenGroup )
		else:
			painter.setPen( GraphTreeItemDelegate._textPen )
		painter.drawText( rect, Qt.AlignLeft | Qt.AlignVCenter, text )
		painter.restore()
Example #4
0
 def paintEvent(self, pe):
   if not self._hover_rect:
     super(TrackerWebView, self).paintEvent(pe)
   else:
     super(TrackerWebView, self).paintEvent(pe)
     hover_rect = self._hover_rect
     self._fixRectForScroll(hover_rect)
     painter = QPainter(self)
     painter.save()
     pen = QPen(Qt.red)
     pen.setWidth(2)
     painter.setPen(pen)
     painter.drawRect(hover_rect)
     painter.restore()
     # draw green rects around the similar elements
     pen = QPen()
     pen.setWidth(2)
     for field_info in self._fields_info:
       painter.save()
       web_elements = field_info.web_elements
       color = field_info.color
       pen.setColor(color)
       painter.setPen(pen)
       for elem in web_elements:
         elem_rect = elem.absoluteGeometry()
         painter.drawRoundedRect(self._fixRectForScroll(elem_rect), 2, 2)
       painter.restore()
    def paintEvent(self, ev):
        if self.isEnabled():
            color = self.color
            colorBorder = [0.4, 0.4, 0.4]
        else:
            color = [0.8, 0.8, 0.8]
            colorBorder = [0.7, 0.7, 0.7]

        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setRenderHint(QPainter.HighQualityAntialiasing)

        if self.isChecked():
            pen = QPen(QColor.fromRgbF(0.2, 0.2, 0.2))
            pen.setWidth(2.0)
        else:
            pen = QPen(
                QColor.fromRgbF(colorBorder[0], colorBorder[1],
                                colorBorder[2]))
            pen.setWidth(1.0)

        size = self.size()
        sizeCircle = 12.0
        x = size.width() / 2.0 - (sizeCircle / 2.0)
        y = size.height() / 2.0 - (sizeCircle / 2.0)
        rect = QRectF(x, y, sizeCircle, sizeCircle)
        painter.setPen(pen)
        painter.setBrush(QColor.fromRgbF(color[0], color[1], color[2]))
        painter.drawEllipse(rect)
Example #6
0
    def draw(self, painter, scale):

        painter.save()
        painter.setPen(QPen(QBrush(QColor(232, 109, 21) if self.state is self.add_point else
                                   QColor(21, 144, 232)),
                            self.lineWidth(scale),
                            Qt.SolidLine))
        painter.drawPolygon(QPolygon(self.polygon))

        for i, poly in enumerate(self.convex_polygons):
            if poly:
                painter.setPen(QPen(QBrush(Figure.COLORS[i % len(Figure.COLORS)]),
                                    self.lineWidth(scale),
                                    Qt.SolidLine))
                color = Figure.COLORS[i % len(Figure.COLORS)]
                color.setAlpha(150)
                painter.setBrush(QBrush(QColor(color)))
                painter.drawPolygon(QPolygon(poly))

        for point in self.polygon:
            self.drawControlPoint(painter, point,
                                  QColor(31, 174, 222) if point is self.polygon[0] else
                                  QColor(222, 79, 31) if point is self.polygon[-1] else
                                  QColor(78, 222, 31), scale)

        Figure.draw(self, painter, scale)
        painter.restore()
Example #7
0
    def __init__(self, s, parent=None):
        """
        Default class constructor.

        :param `s`: TOWRITE
        :type `s`: QRubberBand.Shape
        :param `parent`: Pointer to a parent widget instance.
        :type `parent`: `QWidget`_
        """
        super(SelectBox, self).__init__(parent)

        # private
        self._leftBrushColor = QColor()
        self._rightBrushColor = QColor()
        self._leftPenColor = QColor()
        self._rightPenColor = QColor()
        self._alpha = 255  # quint8  #: TODO: what is the initial int?

        self._dirBrush = QBrush()
        self._leftBrush = QBrush()
        self._rightBrush = QBrush()

        self._dirPen = QPen()
        self._leftPen = QPen()
        self._rightPen = QPen()

        self._boxDir = False  #: TODO: is this initial bool value right?

        # Default values
        self.setColors(QColor(Qt.darkGreen), QColor(Qt.green),
                       QColor(Qt.darkBlue), QColor(Qt.blue), 32)
Example #8
0
    def paint(self, painter, option, widget=None):
        """QGraphicsRectItem virtual
        """
        # TODO LH Is there a way to clip to overlapping
        # QAbstractGraphicsItems with a larger zorder

        # TODO LH Get pixmap without tight coupling to scene
        painter.drawPixmap(self.boundingRect(),
                           self.scene().pixmap, self.sceneBoundingRect())

        with painter_state(painter):
            # Zero thickness indicates a cosmetic pen, which is drawn with the
            # same thickness regardless of the view's scale factor
            painter.setPen(QPen(self.colour, 0, Qt.SolidLine))
            r = self.boundingRect()
            painter.drawRect(r)

            if self._seeds:
                # Draw sub-segmentation seed points
                painter.setBrush(QBrush(Qt.black))
                painter.setPen(QPen(Qt.white, 5, Qt.SolidLine))
                for point in self._seeds:
                    painter.drawEllipse(point, 5, 5)

            if self.DRAW_INNER:
                painter.setPen(QPen(self.inner_colour, 1, Qt.SolidLine))
                r.adjust(1, 1, -1, -1)
                painter.drawRect(r)
Example #9
0
    def _draw_horizontal_ruler(self, painter, text, y_value, color):

        y = y_value * self.y_factor

        pen = QPen()
        pen.setCapStyle(Qt.SquareCap)
        pen.setColor(color)

        qp = QPainterPath()

        r = QRect(1,1,1000,1000)
        bb = painter.boundingRect(r,Qt.AlignLeft,text)
        bb = QRect(self.x_base,self.y_base - y - bb.height(), bb.width() + 2, bb.height())

        # print("{} {} {} {}".format(bb.x(),bb.y(),bb.width(),bb.height()))

        fill_color = QColor(0,0,0)
        fill_color.setAlpha(128)
        brush = QBrush(fill_color)

        painter.fillRect(bb,brush)

        qp.moveTo(self.x_base,self.y_base - y)
        qp.lineTo(self.total_width + self.x_base, self.y_base - y)

        painter.setPen(pen)
        painter.drawPath(qp)

        text_pen = QPen()
        text_pen.setCapStyle(Qt.RoundCap)
        text_pen.setColor(color) # alpha=255=fully opaque
        text_pen.setWidth(1)

        painter.setPen(text_pen)
        painter.drawText(self.x_base,self.y_base - y - 5,text)
Example #10
0
    def _draw_legend2(self, painter, labels):
        text_pen = QPen()
        text_pen.setCapStyle(Qt.RoundCap)
        text_pen.setColor(QColor(200, 200, 200)) # alpha=255=fully opaque
        text_pen.setWidth(1)

        highlighted_text_pen = QPen()
        highlighted_text_pen.setColor(QColor(255, 255, 255)) # alpha=255=fully opaque
        highlighted_text_pen.setWidth(1)

        line_pen = QPen()
        line_pen.setCapStyle(Qt.RoundCap)
        line_pen.setColor(QColor(200, 200, 200)) # alpha=255=fully opaque
        line_pen.setWidth(2)


        row = col = 0

        self.legend_labels_bounding_boxes = []

        for data_ndx, label in sorted( zip(range(len(labels)),labels), key=lambda a:a[1]):

            if label:
                # One can hide a series' legend by using a blank label

                x = self.margin + col * self.max_legend_label_width + 3
                y = self.legend_y_start + row * self.text_height

                # Draw coloured line

                line_pen.setColor(self.graph_colors[data_ndx % len(self.graph_colors)]) # alpha=255=fully opaque
                painter.setPen(line_pen)

                if data_ndx == self.ndx_best_serie:
                    r = QRect(x-3, y-self.text_height+3, self.max_legend_label_width, self.text_height)
                    painter.drawRect(r)
                    painter.setPen(highlighted_text_pen)
                else:
                    painter.drawLine(x,y+3,x+self.max_legend_label_width - 6,y + 3)
                    painter.setPen(text_pen)

                painter.drawText(x,y, label)

                # Remember text bounding box
                r = QRect(x,y - self.text_height, self.max_legend_label_width, self.text_height)
                bb = painter.boundingRect(r,Qt.AlignLeft,label)

                # if label == 'TV':
                #     painter.drawRect(r)

                self.legend_labels_bounding_boxes.append( (data_ndx,r) )


                if not (col < self.legend_labels_per_line - 1):
                    col = 0
                    row += 1
                else:
                    col += 1
class CustomFBX_Label(qg.QLabel):
    _pen_text = QPen(QColor(180, 255, 180, 200), 1, qc.Qt.SolidLine)
    _pen_Shadow = QPen(QColor(9, 10, 12), 1, qc.Qt.SolidLine)
    _pen_border = QPen(QColor(9, 10, 12), 2, qc.Qt.SolidLine)
    _pen_clear = QPen(QColor(0, 0, 0, 0), 1, qc.Qt.SolidLine)

    _fontSize = 16
    _fontMargin = 2

    def __init__(self, *args, **kwargs):
        super(CustomFBX_Label, self).__init__(*args, **kwargs)

        font = qg.QFont()
        font.setPointSize(self._fontSize)
        font.setFamily('Source Code Pro SemiBold')
        self.setFont(font)
        self.setMargin(self._fontMargin)
        self.setStyleSheet("background-color: transparent;")
        self.setMargin(self._fontMargin)
        #self.setStyleSheet("background-color: transparent;")

    def paintEvent(self, event):
        painter = qg.QPainter(self)
        option = qg.QStyleOption()
        option.initFrom(self)

        x = option.rect.x()
        y = option.rect.y()
        height = option.rect.height() - 1
        width = option.rect.width() - 1

        painter.setRenderHint(qg.QPainter.Antialiasing)
        painter.setRenderHint(qg.QPainter.TextAntialiasing)

        alignment = (qc.Qt.AlignHCenter | qc.Qt.AlignVCenter)

        text = self.text()
        if text == '': return

        font = self.font()
        font_metrics = qg.QFontMetrics(font)
        text_width = font_metrics.width(text)
        text_height = font.pointSize()

        textPath = qg.QPainterPath()
        textPath.addText((width - text_width) / 2,
                         height - ((height - text_height) / 2), font, text)

        if self.isEnabled():
            pens_text = self._pen_text
            pens_shadow = self._pen_Shadow

            painter.setPen(pens_shadow)
            painter.drawPath(textPath)
            painter.setPen(pens_text)
            painter.drawText(x, y, width, height, alignment, text)
Example #12
0
    def __init__(self, parent=None, conditional=False):
        if conditional:
            self.pen = QPen(CONDITIONAL_TRANSITION_COLOR)
            self.brush = QBrush(CONDITIONAL_TRANSITION_COLOR)
        else:
            self.pen = QPen(NON_CONDITIONAL_TRANSITION_COLOR)
            self.brush = QBrush(NON_CONDITIONAL_TRANSITION_COLOR)

        self.pen.setWidth(4)
        QWidget.__init__(self, parent)
Example #13
0
    def __init__(self):
        super(MyProgress, self).__init__()

        self.setMaximumHeight(50)

        self.maxValue = 100
        self.currentValue = 0

        self.outLine = QPen(QColor("#999999"))
        self.fillColor = QBrush(QColor("green"))
        self.textPen = QPen(QColor("black"))
    def setupPainter(self, painter, orientation, x1, y1, x2, y2):
        highlight = self.palette().color(QPalette.Highlight)
        gradient = QLinearGradient(x1, y1, x2, y2)
        gradient.setColorAt(0, highlight.darker(120))
        gradient.setColorAt(1, highlight.lighter(108))
        painter.setBrush(gradient)

        if orientation == QtCore.Qt.Horizontal:
            painter.setPen(QPen(highlight.darker(130), 0))
        else:
            painter.setPen(QPen(highlight.darker(150), 0))
Example #15
0
    def set_shape(self, width, height):
        ''' Compute the polygon to fit in width, height '''
        path = QPainterPath()
        path.addRoundedRect(0, 0, width, height, height / 4, height)

        if self.nested_scene and self.is_composite():
            # Distinguish composite states with dash line
            self.setPen(QPen(Qt.DashLine))
        else:
            self.setPen(QPen(Qt.SolidLine))
        self.setPath(path)
        super(State, self).set_shape(width, height)
Example #16
0
def glass_path(scene, x, y, w, h, colr):

    qp = QPainterPath()
    qp.addRoundedRect(x, y, w, h, 5, 5)

    gradient = QLinearGradient(0, +0, 0, 1)
    gradient.setCoordinateMode(QGradient.ObjectBoundingMode)
    gradient.setColorAt(0, colr)
    gradient.setColorAt(1, colr.lighter(150))
    brush = QBrush(gradient)

    item = QGraphicsPathItem()
    item.setPath(qp)
    item.setBrush(brush)
    scene.addItem(item)

    # Draw glass reflection

    glass = QPainterPath()
    r = 3
    glass.addRoundedRect(x + r, y + r, w - 2 * r, 2 * r, r, r)

    gradient = QLinearGradient(0, +0, 0, 1)
    gradient.setCoordinateMode(QGradient.ObjectBoundingMode)
    gradient.setColorAt(0, QColor(255, 255, 255, 188))
    gradient.setColorAt(1, QColor(255, 255, 255, 0))
    brush = QBrush(gradient)

    item = QGraphicsPathItem()
    item.setPath(glass)
    item.setBrush(brush)
    item.setPen(QPen(Qt.transparent))
    scene.addItem(item)
class CustomShortLabel(CustomLabel):
    _pen_text = QPen(QColor(250, 250, 250, 220), 1, qc.Qt.SolidLine)
    _fontSize = 12
    _fontMargin = 3

    def __init__(self, *args, **kwargs):
        super(CustomShortLabel, self).__init__(*args, **kwargs)
Example #18
0
 def __init__(self, *args):
     super(HooverBar, self).__init__(*args)
     self.setAcceptHoverEvents(True)
     self.gi = None
     self.description = [""]
     self.base_font = QFont()
     self.setPen(QPen(Qt.transparent))
Example #19
0
    def hoverEnterEvent(self, event):
        super(HooverBar, self).hoverEnterEvent(event)

        if self.gi == None:
            self.gi = QGraphicsRectItem(0, 0, 100, 100)
            self.gi.setBrush(QBrush(QColor(0, 64, 0, 192)))
            self.gi.setPen(QPen(Qt.transparent))
            self.gi.setPos(event.scenePos().x() + 20,
                           event.scenePos().y() + 20)

            x = y = 10
            w = 0
            for t in self.description:
                description = QGraphicsSimpleTextItem()
                description.setFont(self.base_font)
                description.setBrush(QBrush(Qt.white))
                description.setText(t)
                description.setParentItem(self.gi)
                description.setPos(x, y)
                y += description.boundingRect().height()
                w = max(w, description.boundingRect().width())
            y += x
            w += 2 * x

            self.gi.setRect(0, 0, w, y)
            self.scene().addItem(self.gi)
    def updateLines(self):
        pen = QPen(QColor.fromHsl(0, 100, 100))
        sortedNodes = sorted(self.nodes, key=lambda x: x.pos().x())
        for index in range(len(self.nodes) - 1):
            node = sortedNodes[index]
            nextNode = sortedNodes[index + 1]
            if index < len(self.lines):
                # Just update the line segment
                lineItem = self.lines[index]
            else:
                # Create a new line segment
                lineItem = QGraphicsLineItem()
                lineItem.setZValue(250)
                lineItem.setPen(pen)
                self.histogramWidget.scene().addItem(lineItem)
                self.lines.append(lineItem)
            line = QLineF(node.pos(), nextNode.pos())
            lineItem.setLine(line)

        # Clean up redundent lines
        if len(self.lines) >= len(self.nodes):
            # Remove the redundant line segments from the scene
            for index in range(len(self.nodes) - 1, len(self.lines)):
                lineItem = self.lines[index]
                self.histogramWidget.scene().removeItem(lineItem)

            # Delete the line segments from the list
            del self.lines[len(self.nodes) - 1:]
            assert len(self.lines) == len(self.nodes) - 1

        self.histogramWidget._scene.update()
Example #21
0
    def _draw_edges(self, painter, topleft_point, bottomright_point):

        for edge in self._edges:
            edge_coords = edge.coordinates

            color = QColor(0x70, 0x70, 0x70)
            pen = QPen(color)
            pen.setWidth(1.5)
            painter.setPen(pen)

            for from_, to_ in zip(edge_coords, edge_coords[1:]):
                start_point = QPointF(*from_)
                end_point = QPointF(*to_)
                # optimization: don't draw edges that are outside of the current scope
                if (start_point.x() > bottomright_point.x() or start_point.y() > bottomright_point.y()) and \
                        (end_point.x() > bottomright_point.x() or end_point.y() > bottomright_point.y()):
                    continue
                elif (start_point.x() < topleft_point.x() or start_point.y() < topleft_point.y()) and \
                        (end_point.x() < topleft_point.x() or end_point.y() < topleft_point.y()):
                    continue
                painter.drawPolyline((start_point, end_point))

            # arrow
            # end_point = self.mapToScene(*edges[-1])
            end_point = (edge_coords[-1][0], edge_coords[-1][1])
            arrow = [
                QPointF(end_point[0] - 3, end_point[1]),
                QPointF(end_point[0] + 3, end_point[1]),
                QPointF(end_point[0], end_point[1] + 6)
            ]
            brush = QBrush(color)
            painter.setBrush(brush)
            painter.drawPolygon(arrow)
Example #22
0
    def paintEvent(self, pe):

        if self._drop_zones_shown:
            painter = QPainter(self.viewport(
            ))  # See documentation to know why I draw on the viewport
            painter.setFont(self._titles_font)
            vr = self.rect()

            nb_drop_zones = len(self._drop_zones_titles)

            subr = QRect(vr)
            subr.setHeight(vr.height() / nb_drop_zones)

            for i in range(nb_drop_zones):
                c = self._drop_zones_colors[i]

                text_pen = QPen()
                text_pen.setColor(inverse_colors(c))
                painter.setPen(text_pen)

                if i == self._selected_drop_zone:
                    # mainlog.debug("selected drop zone is {}".format(i))
                    c = c.lighter(200)
                painter.setBrush(c)

                subr.moveTop(int(i * vr.height() / nb_drop_zones))
                painter.drawRect(subr)
                painter.drawText(
                    QPoint(10, int((i + 0.5) * vr.height() / nb_drop_zones)),
                    self._drop_zones_titles[i])
            return None
        else:
            return super(AnimatedTableView, self).paintEvent(pe)
Example #23
0
    def __init__(self, parent, scene, view):
        super(QNodesEditor, self).__init__(parent)

        self.scene = scene
        self.scene.installEventFilter(self)

        gridSize = 25
        gridMap = QPixmap(gridSize,gridSize)
        gridPainter = QPainter(gridMap)
        gridPainter.fillRect(0,0,gridSize,gridSize, QApplication.palette().window().color().darker(103))
        gridPainter.fillRect(1,1,gridSize-2,gridSize-2, QApplication.palette().window())
        gridPainter.end()
        self.scene.setBackgroundBrush( QBrush(gridMap) )

        originSize = 50
        originItem = QGraphicsPathItem()
        path = QPainterPath()
        path.moveTo(0,-originSize)
        path.lineTo(0,originSize)
        path.moveTo(-originSize,0)
        path.lineTo(originSize,0)
        originItem.setPath(path)
        originItem.setPen(QPen(QApplication.palette().window().color().darker(110),2))
        originItem.setZValue(-2)
        self.scene.addItem(originItem)

        self.view = view
        self.view.setDragMode(QGraphicsView.RubberBandDrag)
        self.view.setRenderHint(QPainter.Antialiasing)

        self.connection = None
Example #24
0
 def testCtorWithCreatedEnums(self):
     '''A simple case of QPen creation using created enums.'''
     width = 0
     style = Qt.PenStyle(0)
     cap = Qt.PenCapStyle(0)
     join = Qt.PenJoinStyle(0)
     pen = QPen(Qt.blue, width, style, cap, join)
Example #25
0
 def testReprFunction(self):
     reprPen = repr(QPen())
     self.assertTrue(reprPen.startswith("<PySide.QtGui.QPen"))
     reprBrush = repr(QBrush())
     self.assertTrue(reprBrush.startswith("<PySide.QtGui.QBrush"))
     reprObject = repr(QObject())
     self.assertTrue(reprObject.startswith("<PySide.QtCore.QObject"))
Example #26
0
    def paint(self, painter):
        """

        :param QPainter painter:
        :return:
        """

        # background of the node
        painter.setBrush(QColor(0xfa, 0xfa, 0xfa))
        painter.setPen(QPen(QColor(0xf0, 0xf0, 0xf0), 1.5))
        painter.drawRect(self.x, self.y, self.width, self.height)

        # content

        y_offset = self.TOP_PADDING

        for obj in self.objects:

            y_offset += self.SPACING

            obj.x = self.x + self.LEFT_PADDING
            obj.y = self.y + y_offset
            obj.paint(painter)

            y_offset += obj.height
Example #27
0
    def drawLines(self, qp):
        pen = QPen(Qt.black, 2, Qt.SolidLine)
        qp.setPen(pen)

        qp.drawRect(self.rect().left(),
                    self.rect().top(),
                    self.rect().width(),
                    self.rect().height())

        qp.drawLine(self.dd.x() + 155,
                    self.dd.y() + 5,
                    self.dd.x() + 250,
                    self.dd.y() + 5)
        pen.setStyle(Qt.DashLine)
        qp.setPen(pen)
        qp.drawLine(self.ud.x() + 155,
                    self.ud.y() + 5,
                    self.ud.x() + 250,
                    self.ud.y() + 5)
        pen.setStyle(Qt.SolidLine)
        pen.setColor(Qt.red)
        qp.setPen(pen)
        qp.drawLine(self.unid.x() + 155,
                    self.unid.y() + 5,
                    self.unid.x() + 250,
                    self.unid.y() + 5)
        pen.setColor(Qt.yellow)
        qp.setPen(pen)
        qp.drawRect(self.sel.x() + 155, self.sel.y(), 95, 20)
        pen.setColor(Qt.green)
        qp.setPen(pen)
        qp.drawRect(self.leaf.x() + 155, self.leaf.y(), 95, 20)
Example #28
0
    def init(self, parent):
        """
        """
        rad = self.factory.radius
        if not rad:
            rad = 20

        if self.control is None:
            self.control = qtLED()
            scene = QGraphicsScene()
            #             self.control.setStyleSheet("qtLED { border-style: none; }");
            #             self.control.setAutoFillBackground(True)

            # system background color
            scene.setBackgroundBrush(QBrush(QColor(237, 237, 237)))
            self.control.setStyleSheet("border: 0px")
            self.control.setMaximumWidth(rad+15)
            self.control.setMaximumHeight(rad+15)

            x, y = 10, 10
            cx = x + rad / 1.75
            cy = y + rad / 1.75

            brush = self.get_color(self.value.state, cx, cy, rad / 2)
            pen = QPen()
            pen.setWidth(0)
            self.led = scene.addEllipse(x, y, rad, rad,
                                        pen=pen,
                                        brush=brush
                                        )

            self.control.setScene(scene)

            self.value.on_trait_change(self.update_object, 'state')
Example #29
0
    def _draw_serie(self, painter, ndx_serie, color):

        serie = self.data[ndx_serie]

        #mainlog.debug(serie)

        fill_color = QColor(color)
        fill_color.setAlpha(64)
        brush = QBrush(fill_color)
        pen = QPen()
        pen.setCapStyle(Qt.SquareCap)
        pen.setColor(color)

        qp = QPainterPath()
        painter.setPen(pen)

        for i in range(len(serie)):
            x, y_top, y_below = self._item_coordinates(i)

            h = max(1, float(y_top - y_below - 1))
            qp.addRect( x,
                        float(self.y_base-y_top),
                        float(self.bar_width),
                        h)

        painter.fillPath(qp,brush)
        painter.drawPath(qp)

        #mainlog.debug("Drawing peak values, juste before {}".format(self._peak_values))
        if self._peak_values:
            #mainlog.debug("Drawing peak values")
            self._draw_peak_values(painter, self._peak_values )
class CustomClearLabel(CustomLabel):
    _pen_text = QPen(QColor(180, 200, 180, 250), 2, qc.Qt.SolidLine)
    _fontSize = 14
    _fontMargin = 4

    def __init__(self, *args, **kwargs):
        super(CustomClearLabel, self).__init__(*args, **kwargs)