Пример #1
0
    def animate(self):

        bubbles = []
        left = False
        for bubble in self.bubbles:

            bubble.position = bubble.position + QtCore.QPointF(
                0, -bubble.speed)

            self.update(
                QtCore.QRectF(bubble.position - \
                       QtCore.QPointF(bubble.radius + 1, bubble.radius + 1),
                       QtCore.QSizeF(2*bubble.radius + 2, 2*bubble.radius + 2 + bubble.speed)).toRect()
                )

            if bubble.position.y() + bubble.radius > 0:
                bubbles.append(bubble)
            else:
                self.bubbleLeft.emit()
                left = True

        if self.newBubble:
            self.update(
                QtCore.QRectF(self.newBubble.position - \
                       QtCore.QPointF(self.newBubble.radius + 1, self.newBubble.radius + 1),
                       QtCore.QSizeF(2*self.newBubble.radius + 2, 2*self.newBubble.radius + 2)).toRect()
                )

        self.bubbles = bubbles
        if left:
            self.bubblesRemaining.emit(len(self.bubbles))
Пример #2
0
    def updateExampleSummary(self):
        if 'image files' in self.examples[self.currentExample]:
            self.currentFrame.metadata["fade"] = -15
            self.currentFrame.setTarget(
                QtCore.QPointF((self.currentFrame.position() -
                                QtCore.QPointF(0.5 * self.width(), 0))))
            self.slideshowFrame = (self.slideshowFrame + 1) % len(
                self.examples[self.currentExample]['image files'])
            image = QtGui.QImage(self.examples[self.currentExample]
                                 ['image files'][self.slideshowFrame])

            imageSize = self.currentFrame.maxSize
            imagePosition = QtCore.QPointF(
                self.width() - imageSize.width() / 2,
                self.currentFrame.position().y())

            self.currentFrame = ImageShape(image,
                                           QtCore.QPointF(imagePosition),
                                           QtCore.QSizeF(imageSize))
            self.currentFrame.metadata["fade"] = 15
            self.currentFrame.setTarget(
                QtCore.QPointF(self.width() / 2 - imageSize.width() / 2,
                               imagePosition.y()))

            self.display.appendShape(self.currentFrame)
Пример #3
0
class LegendItemCircle(ColorIndicator):
    """Legend circle item.

    The legend circle item is a small colored circle image that can be plugged
    into the legend in front of the text object.

    This should only really be used in conjunction with ˙LegendItem˙.

    Parameters
    ----------
    color : QtGui.QColor
        The color of the square.
    parent : QtGui.QGraphicsItem

    See Also
    --------
    LegendItemSquare

    """

    SIZE = QtCore.QSizeF(12, 12)

    def __init__(self, color, parent):
        super().__init__(parent)

        height, width = self.SIZE.height(), self.SIZE.width()
        self.__circle = QtGui.QGraphicsEllipseItem(0, 0, height, width)
        self.__circle.setBrush(QtGui.QBrush(color))
        self.__circle.setPen(QtGui.QPen(QtGui.QColor(0, 0, 0, 0)))
        self.__circle.setParentItem(self)

    def sizeHint(self, size_hint, size_constraint=None, *args, **kwargs):
        return QtCore.QSizeF(self.__circle.boundingRect().size())
Пример #4
0
    def updateLayout(self):
        labelHeight = self._label.boundingRect().height()
        height = self._spacerConstant + labelHeight + self._spacerConstant

        inputHookOffset = 0
        if self._inputHook:
            hookY = (height - self._inputHook.boundingRect().height()) / 2.0
            self._inputHook.setPos(self._spacerConstant, hookY)
            inputHookOffset = self._inputHook.boundingRect().width(
            ) + self._inputHook.pos().x()

        self._label.setPos(inputHookOffset + self._spacerConstant,
                           (height - labelHeight) / 2.0)

        outputHookOffset = self._label.pos().x() + self._label.boundingRect(
        ).width()
        if self._outputHook:
            hookY = (height - self._outputHook.boundingRect().height()) / 2.0
            self._outputHook.setPos(outputHookOffset + self._spacerConstant,
                                    hookY)
            outputHookOffset = self._outputHook.pos().x(
            ) + self._outputHook.boundingRect().width()

        self.resize(
            QtCore.QSizeF(outputHookOffset + self._spacerConstant, height))
Пример #5
0
    def print_to_pdf(
        self,
        path,
        paper_size=(8.5, 11.0),
        paper_margins=(0, 0, 0, 0),
        paper_units=QPrinter.Inch,
        zoom_factor=1.0,
    ):
        """Saves page as a pdf file.

        See qt4 QPrinter documentation for more detailed explanations
        of options.

        :param path: The destination path.
        :param paper_size: A 2-tuple indicating size of page to print to.
        :param paper_margins: A 4-tuple indicating size of each margin.
        :param paper_units: Units for pager_size, pager_margins.
        :param zoom_factor: Scale the output content.
        """
        assert len(paper_size) == 2
        assert len(paper_margins) == 4
        printer = QPrinter(mode=QPrinter.ScreenResolution)
        printer.setOutputFormat(QPrinter.PdfFormat)
        printer.setPaperSize(QtCore.QSizeF(*paper_size), paper_units)
        printer.setPageMargins(*(paper_margins + (paper_units, )))
        printer.setFullPage(True)
        printer.setOutputFileName(path)
        if self.webview is None:
            self.webview = QtWebKit.QWebView()
            self.webview.setPage(self.page)
        self.webview.setZoomFactor(zoom_factor)
        self.webview.print_(printer)
Пример #6
0
def setup_printer(filename, resolution=300, page_height=297, page_width=210):
    """Create a QPrinter instance defaulted to print to an A4 portrait pdf.

    :param filename: Filename for the pdf print device.
    :type filename: str

    :param resolution: Resolution (in dpi) for the output.
    :type resolution: int

    :param page_height: Height of the page in mm.
    :type page_height: int

    :param page_width: Width of the page in mm.
    :type page_width: int
    """
    #
    # Create a printer device (we are 'printing' to a pdf
    #
    LOGGER.debug('InaSAFE Map setupPrinter called')
    myPrinter = QtGui.QPrinter()
    myPrinter.setOutputFormat(QtGui.QPrinter.PdfFormat)
    myPrinter.setOutputFileName(filename)
    myPrinter.setPaperSize(QtCore.QSizeF(page_width, page_height),
                           QtGui.QPrinter.Millimeter)
    myPrinter.setFullPage(True)
    myPrinter.setColorMode(QtGui.QPrinter.Color)
    myPrinter.setResolution(resolution)
    return myPrinter
Пример #7
0
   def __init__(self, sourceNode, destNode):
      QtGui.QGraphicsItem.__init__(self)
      self.arrowSize = 10.0
      #self.setAcceptedMouseButtons(QtCore.Qt.NoButton)
      self.setAcceptsHoverEvents(True)

      # XXX: When allowing the user to create groups using
      #      the RubberBandDrage mode an item must have the
      #      same value for Movable and Selectable flags.
      #self.setFlag(QtGui.QGraphicsItem.ItemIsMovable)
      #self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable)
      self.setFlag(QtGui.QGraphicsItem.ItemIsFocusable)

      self.source = sourceNode
      self.dest = destNode

      # Add self to source node.
      self.source.outEdgeList.append(self)
      # Add self to dest node.
      self.dest.inEdgeList.append(self)

      # Update our current position.
      self.adjust()

      self.mHotRect = QtCore.QRectF()
      self.mHotRect.setSize(QtCore.QSizeF(40.0, 40.0))
      self.mArrowColor = QtCore.Qt.black
Пример #8
0
 def __init__(self, core_id):
     super(Core, self).__init__()
     # Core Information
     self.core_id = core_id
     self.buffers = []
     self.link_ids = []
     self.draw_row = core_id % networkAttr.CORE_COLS
     self.draw_col = math.floor(core_id / networkAttr.CORE_COLS)
     self.row = None
     self.col = None
     # Graphics Options
     self.size = QtCore.QSizeF(drawAttr.CORE_SIZE, drawAttr.CORE_SIZE)
     self.setMinimumSize(drawAttr.CORE_SIZE, drawAttr.CORE_SIZE)
     # Pixel positions
     self.top_left_corner = QtCore.QPointF(
         self.draw_row * drawAttr.CORE_SIZE +
         self.draw_row * drawAttr.LINK_LENGTH,
         self.draw_col * drawAttr.CORE_SIZE +
         self.draw_col * drawAttr.LINK_LENGTH)
     # Core Rectangle Object
     self.rect = QtCore.QRectF(self.top_left_corner, self.size)
     self.text_id = str(self.core_id)
     self.text_id_pos = QtCore.QPointF()
     self.create_buffers()
     self.create_core_id_text()
Пример #9
0
    def mousePressEvent(self, event):
        # grabbing the position of the widget
        sp = self.mapToScene(event.pos())
        ret = self.scene().areaAt(sp)

        edge = ret % 100
        iArea = ret / 100 - 1

        # resizing/moving the area if it exists
        if edge:
            self.bResizing = True
            self.resizingEdge = edge
            self.resizingArea = self.scene().areas[iArea]
            self.resizingStartingPos = sp
            self.resizingAreaRect = self.resizingArea.rect()
            self.resizingAreaPos = self.resizingArea.pos()
            self.resizingArea.setFlag(QtGui.QGraphicsItem.ItemIsMovable, False)
        # creation of a new area
        elif iArea == -1:
            size = QtCore.QSizeF(0, 0)
            newArea = self.scene().createArea(sp, size, self.areaType,
                                              self.areaBorder,
                                              self.areaTextSize)

            self.bResizing = True
            self.resizingEdge = 10
            self.resizingArea = newArea
            self.resizingStartingPos = sp
            self.resizingAreaRect = self.resizingArea.rect()
            self.resizingAreaPos = self.resizingArea.pos()
            self.resizingArea.setFlag(QtGui.QGraphicsItem.ItemIsMovable, False)

        QtGui.QGraphicsView.mousePressEvent(self, event)
Пример #10
0
   def __init__(self, elm=None, graphWidget=None):
      QtGui.QGraphicsItem.__init__(self)
      self.newPos = QtCore.QPointF()
      self.graph = graphWidget
      self.setFlag(QtGui.QGraphicsItem.ItemIsMovable)
      self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable)
      self.setFlag(QtGui.QGraphicsItem.ItemIsFocusable)
      self.setZValue(1)
      self.setAcceptDrops(True)

      # Appearance
      self.mSize = QtCore.QSizeF(100.0, 100.0)
      self.mColor = QtGui.QColor(0, 127, 127, 191)
      self.mEnabled = True
      self.dropShadowWidth = 5.0
      self.penWidth = 1

      # XML data to represent.
      self.mElement = elm

      # Editing attributes.
      self.mTitle = "Node"

      # Tree structure attributes.
      self.mParent = None
      self.mChildren = []

      # Edge references
      self.inEdgeList = []
      self.outEdgeList = []

      self.mPropertyMap = self.__class__.mPropertyMap
Пример #11
0
 def boundingRect(self):
     extra = (self.pen().width() + Edge.ARROW_SIZE) / 2
     p1, p2 = self.line().p1(), self.line().p2()
     return QtCore.QRectF(p1, QtCore.QSizeF(
         p2.x() - p1.x(),
         p2.y() - p1.y())).normalized().adjusted(-extra, -extra, extra,
                                                 extra)
Пример #12
0
 def __init__(self, startHook, endHook = None):
     QtGui.QGraphicsItem.__init__(self, None, startHook.scene())
     
     self._rect = QtCore.QRectF(0, 0, 0, 0)
     self._startHook = weakref.ref(startHook)
     self._endHook = None
     self._color = startHook.colorRef()
     self._pen = QtGui.QPen(self._color)
     self._pen.setWidth(1)
     self._isTempConnection = False
     self._path = QtGui.QPainterPath()
     
     startHook.addConnection(self)
     
     if endHook:
         self._endHook = weakref.ref(endHook)
         endHook.addConnection(self)
     else:
         # creating a dummy endHook for temporary connection dragging
         self._endHook = weakref.ref(ConnectionHook(startHook.parentAttributeUi(), parentItem = self))
         self._endHook().boundingRect().setSize(QtCore.QSizeF(2.0, 2.0))
         self._isTempConnection = True
         
     self.updateStartPos()
     
     self.setZValue(-1.0)
Пример #13
0
    def paintEvent(self, event):

        background = QtGui.QRadialGradient(
            QtCore.QPointF(self.rect().topLeft()), 500,
            QtCore.QPointF(self.rect().bottomRight()))
        background.setColorAt(0, self.backgroundColor1)
        background.setColorAt(1, self.backgroundColor2)

        painter = QtGui.QPainter()
        painter.begin(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        painter.fillRect(event.rect(), QtGui.QBrush(background))

        painter.setPen(self.pen)

        for bubble in self.bubbles:

            if QtCore.QRectF(
                    bubble.position -
                    QtCore.QPointF(bubble.radius, bubble.radius),
                    QtCore.QSizeF(2 * bubble.radius,
                                  2 * bubble.radius)).intersects(
                                      QtCore.QRectF(event.rect())):
                bubble.drawBubble(painter)

        if self.newBubble:

            self.newBubble.drawBubble(painter)

        painter.end()
Пример #14
0
    def __init__(self, source, dest):

        QtGui.QGraphicsItem.__init__(self)

        self.setAcceptedMouseButtons(Qt.NoButton)
        self.source = source
        self.dest = dest
        self.commit = source.commit
        self.setZValue(-2)

        dest_pt = Commit.item_bbox.center()

        self.source_pt = self.mapFromItem(self.source, dest_pt)
        self.dest_pt = self.mapFromItem(self.dest, dest_pt)
        self.line = QtCore.QLineF(self.source_pt, self.dest_pt)

        width = self.dest_pt.x() - self.source_pt.x()
        height = self.dest_pt.y() - self.source_pt.y()
        rect = QtCore.QRectF(self.source_pt, QtCore.QSizeF(width, height))
        self.bound = rect.normalized()

        # Choose a new color for new branch edges
        if self.source.x() < self.dest.x():
            color = EdgeColor.next()
            line = Qt.SolidLine
        elif self.source.x() != self.dest.x():
            color = EdgeColor.current()
            line = Qt.SolidLine
        else:
            color = EdgeColor.current()
            line = Qt.SolidLine

        self.pen = QtGui.QPen(color, 4.0, line, Qt.SquareCap, Qt.RoundJoin)
Пример #15
0
 def sizeHint(self, z, sizeh):
     """Get the size."""
     boundingrec = self.gitem.boundingRect()
     r = QtCore.QSizeF()
     r.setHeight(boundingrec.height())
     r.setWidth(boundingrec.width())
     return r
Пример #16
0
def setupPrinter(theFilename,
                 theResolution=300,
                 thePageHeight=297,
                 thePageWidth=210):
    """Create a QPrinter instance defaulted to print to an A4 portrait pdf

    Args:
        theFilename - filename for pdf generated using this printer
    Returns:
        None
    Raises:
        None
    """
    #
    # Create a printer device (we are 'printing' to a pdf
    #
    LOGGER.debug('InaSAFE Map setupPrinter called')
    myPrinter = QtGui.QPrinter()
    myPrinter.setOutputFormat(QtGui.QPrinter.PdfFormat)
    myPrinter.setOutputFileName(theFilename)
    myPrinter.setPaperSize(QtCore.QSizeF(thePageWidth, thePageHeight),
                           QtGui.QPrinter.Millimeter)
    myPrinter.setFullPage(True)
    myPrinter.setColorMode(QtGui.QPrinter.Color)
    myPrinter.setResolution(theResolution)
    return myPrinter
Пример #17
0
 def boundingRect(self):
     """
     Get the bounding rectangle of the edge.
     """
     extra = (self.pen().width() + 20) / 2.0
     p1 = self.line().p1()
     p2 = self.line().p2()
     return QtCore.QRectF(p1, QtCore.QSizeF(p2.x() - p1.x(), p2.y() - p1.y())).normalized().adjusted(-extra, -extra, extra, extra)
Пример #18
0
    def __init__(self, widget, parent=None, max_size=150, **kwargs):
        self._max_size = QtCore.QSizeF(max_size, max_size)
        # We store the offsets from the top left corner to move widget properly
        self.__offset_x = self.__offset_y = 0

        super().__init__(widget, parent, **kwargs)

        self._resize_widget()
Пример #19
0
    def mouseMoveEvent(self, event):

        if self.newBubble:

            self.update(
                QtCore.QRectF(self.newBubble.position - \
                       QtCore.QPointF(self.newBubble.radius + 1, self.newBubble.radius + 1),
                       QtCore.QSizeF(2*self.newBubble.radius + 2, 2*self.newBubble.radius + 2)).toRect()
                )
            self.newBubble.position = QtCore.QPointF(event.pos())
            self.update(
                QtCore.QRectF(self.newBubble.position - \
                       QtCore.QPointF(self.newBubble.radius + 1, self.newBubble.radius + 1),
                       QtCore.QSizeF(2*self.newBubble.radius + 2, 2*self.newBubble.radius + 2)).toRect()
                )

        event.accept()
Пример #20
0
    def intrinsicSize(self, doc, posInDocument, format):
        renderer = QtSvg.QSvgRenderer(format.property(Window.SvgData))
        size = renderer.defaultSize()

        if size.height() > 25:
            size *= 25.0 / size.height()

        return QtCore.QSizeF(size)
Пример #21
0
    def boundingRect(self):
        extra = (self.pen().width() + 20) / 2.0
        p1 = self.line().p1()
        p2 = self.line().p2()
        r = QtCore.QRectF(p1, QtCore.QSizeF(p2.x() - p1.x(), p2.y() - p1.y())).normalized().adjusted(-extra, -extra, extra, extra)
        if (r.x() < 0 or r.y() < 0):
            start_center = self.start_box.center()
            end_center = self.end_box.center()
            center_line = QtCore.QLineF(end_center, start_center)
            p1 = center_line.p1()
            p2 = center_line.p2()

        r = QtCore.QRectF(p1, QtCore.QSizeF(p2.x() - p1.x(), p2.y() - p1.y())).normalized().adjusted(-extra, -extra, extra, extra)


        #print "Bounding rect: %s" % str(r)
        return r
Пример #22
0
 def drawShape(self, p, shape, rect):
     """Draws the shape on painter p inside rect."""
     # TODO: Draw missing shapes
     if shape == SignalShape.CIRCLE:
         p.drawEllipse(rect)
     elif shape == SignalShape.SQUARE:
         p.drawRect(rect)
     elif shape == SignalShape.QUARTER_SW:
         points = {rect.topLeft(), rect.topRight(), rect.bottomLeft()}
         p.drawPolygon(points)
     elif shape == SignalShape.QUARTER_NW:
         points = {rect.topRight(), rect.bottomRight(), rect.topLeft()}
         p.drawPolygon(points)
     elif shape == SignalShape.QUARTER_NE:
         points = {rect.bottomRight(), rect.bottomLeft(), rect.topRight()}
         p.drawPolygon(points)
     elif shape == SignalShape.QUARTER_SE:
         points = {rect.bottomLeft(), rect.topLeft(), rect.bottomRight()}
         p.drawPolygon(points)
     elif shape == SignalShape.BAR_N_S:
         tl = rect.topLeft() + QtCore.QPointF(1, 3)
         p.drawRect(QtCore.QRectF(tl, QtCore.QSizeF(6, 2)))
     elif shape == SignalShape.BAR_E_W:
         tl = rect.topLeft() + QtCore.QPointF(3, 1)
         p.drawRect(QtCore.QRectF(tl, QtCore.QSizeF(2, 6)))
     elif (shape == SignalShape.POLE_NE or
           shape == SignalShape.POLE_NS or
           shape == SignalShape.POLE_NSE or
           shape == SignalShape.POLE_NSW):
         tm = QtCore.QPointF(rect.center().x(), rect.top())
         p.drawLine(rect.center(), tm)
     elif (shape == SignalShape.POLE_NS or
           shape == SignalShape.POLE_NSE or
           shape == SignalShape.POLE_NSW or
           shape == SignalShape.POLE_SW):
         bm = QtCore.QPointF(rect.center().x(), rect.bottom())
         p.drawLine(rect.center(), bm)
     elif (shape == SignalShape.POLE_NE or
           shape == SignalShape.POLE_NSE):
         rm = QtCore.QPointF(rect.right().x(), rect.center().y())
         p.drawLine(rect.center(), rm)
     elif (shape == SignalShape.POLE_NSW or
           shape == SignalShape.POLE_SW):
         lm = QtCore.QPointF(rect.left().x(), rect.center().y())
         p.drawLine(rect.center(), lm)
Пример #23
0
    def _calculate_picture_size(self):
        '''calculate and cache some useful values to speed up rendering'''
        self._picture_size = self.session.config.get_or_set(
            'i_avatar_size', 32)
        self._pic_sizef = QtCore.QSizeF(self._picture_size, self._picture_size)
        self._pic_size = QtCore.QSize(self._picture_size, self._picture_size)

        #recreate blocked overlay
        self._generate_block_overlay()
Пример #24
0
    def __getNodeSize(self, node):
        """
		Return the size of the string plus a 10 pixel margin.
		"""

        fontMetrics = self.painter.fontMetrics()
        width = fontMetrics.width(QtCore.QString(node.name))

        return QtCore.QSizeF(30 + width, 30)
Пример #25
0
 def _paintNewBpm(self, painter):
     text = "BPM = %d" % self._measure.newBpm
     painter.drawText(1, self._bpmBase + self._props.bpmHeight() - 1, text)
     textWidth = QtGui.QFontMetrics(painter.font()).width(text)
     if self._bpmRect is None:
         self._bpmRect = QtCore.QRectF(0, 0, 0, 0)
     self._bpmRect.setSize(QtCore.QSizeF(textWidth,
                                         self._props.bpmHeight()))
     self._bpmRect.moveTopLeft(QtCore.QPointF(1, self._bpmBase))
Пример #26
0
   def boundingRect(self):
      if self.source is None or self.dest is None:
         return QtCore.QRectF()

      penWidth = 1.0
      extra = (penWidth + self.arrowSize) / 2.0

      return QtCore.QRectF(self.sourcePoint, QtCore.QSizeF(self.destPoint.x() - self.sourcePoint.x(),
                                                           self.destPoint.y() - self.sourcePoint.y())).normalized().adjusted(-extra, -extra, extra, extra)
Пример #27
0
 def boundingRect(self):
     penWidth = 2.0
     extra = penWidth / 2.0
     return QtCore.QRectF(
         self.startNode.pos(),
         QtCore.QSizeF(self.endNode.x() - self.startNode.x(),
                       self.endNode.y() -
                       self.startNode.y())).normalized().adjusted(
                           -extra, -extra, extra, extra)
Пример #28
0
    def boundingRect(self):
        if not self.source or not self.dest:
            return QtCore.QRectF()

        penWidth = 1.0
        extra = (penWidth) / 2.0

        return QtCore.QRectF(self.sourcePoint, QtCore.QSizeF(self.destPoint.x() - self.sourcePoint.x(),
                        self.destPoint.y() - self.sourcePoint.y())).normalized().adjusted(-extra, -extra, extra, extra)
Пример #29
0
    def drawWidget(self, painter):
        painter.save()
        painter.setRenderHint(QtGui.QPainter.SmoothPixmapTransform)

        old_pixmap, old_opacity, old_filename = self._back
        new_pixmap, new_opacity, new_filename = self._front
        if isinstance(self._back[0], QtGui.QMovie):
            old_pixmap = old_pixmap.currentPixmap()
        if isinstance(self._front[0], QtGui.QMovie):
            new_pixmap = new_pixmap.currentPixmap()
            new_pixmap = Utils.pixmap_rounder(
                new_pixmap.scaled(self._size,
                                  transformMode=Qt.SmoothTransformation))

        if not self.crossfade:
            painter.drawPixmap(self._rect, new_pixmap, self._rect)
        else:
            painter.fillRect(self._rect, Qt.transparent)
            painter.setCompositionMode(QtGui.QPainter.CompositionMode_Source)
            #FIXME: old pixmap fading isn't working correctly
            #            painter.setOpacity(old_opacity)
            painter.setOpacity(0)
            painter.drawPixmap(self._rect, old_pixmap, self._rect)
            painter.setCompositionMode(
                QtGui.QPainter.CompositionMode_SourceOver)
            painter.setOpacity(new_opacity)
            painter.drawPixmap(self._rect, new_pixmap, self._rect)

        if self.blocked:
            origin = QtCore.QPointF(0.0, 0.0)
            source = QtCore.QRectF(origin,
                                   QtCore.QSizeF(self.blocked_pic.size()))
            x_emblem_offset = self._size.width() - self.blocked_pic.size(
            ).width()
            y_emblem_offset = self._size.height() - self.blocked_pic.size(
            ).height()
            xy_emblem_offset = QtCore.QPointF(x_emblem_offset, y_emblem_offset)
            target = QtCore.QRectF(origin + xy_emblem_offset,
                                   QtCore.QSizeF(self.blocked_pic.size()))
            painter.setCompositionMode(
                QtGui.QPainter.CompositionMode_SourceOver)
            painter.drawPixmap(target, self.blocked_pic, source)

        painter.restore()
Пример #30
0
 def make_scale(self):
     scene_rect = self.tomography_scene.sceneRect()
     bl = scene_rect.bottomRight()
     size = QtCore.QSizeF(scene_rect.width() / 4, scene_rect.height() / 20)
     self.scale_rect = QRectF(
         bl - QtCore.QPointF(size.width() + size.height(),
                             size.height() * 2), size)
     self.scale_item = self.tomography_scene.addRect(
         self.scale_rect, QPen(Qt.Qt.yellow, 1),
         QBrush(Qt.Qt.yellow, Qt.Qt.SolidPattern))