コード例 #1
0
 def renderCanvas(self, plot, painter, canvasRect, maps):
     canvas = plot.canvas()
     r = canvasRect.adjusted(0., 0., -1., 1.)
     if self.__data.layoutFlags & self.FrameWithScales:
         painter.save()
         r.adjust(-1., -1., 1., 1.)
         painter.setPen(QPen(Qt.black))
         if not (self.__data.discardFlags & self.DiscardCanvasBackground):
             bgBrush = canvas.palette().brush(plot.backgroundRole())
             painter.setBrush(bgBrush)
         QwtPainter.drawRect(painter, r)
         painter.restore()
         painter.save()
         painter.setClipRect(canvasRect)
         plot.drawItems(painter, canvasRect, maps)
         painter.restore()
     elif canvas.testAttribute(Qt.WA_StyledBackground):
         clipPath = QPainterPath()
         painter.save()
         if not self.__data.discardFlags & self.DiscardCanvasBackground:
             QwtPainter.drawBackground(painter, r, canvas)
             clipPath = qwtCanvasClip(canvas, canvasRect)
         painter.restore()
         painter.save()
         if clipPath.isEmpty():
             painter.setClipRect(canvasRect)
         else:
             painter.setClipPath(clipPath)
         plot.drawItems(painter, canvasRect, maps)
         painter.restore()
     else:
         clipPath = QPainterPath()
         frameWidth = 0
         if not self.__data.discardFlags & self.DiscardCanvasFrame:
             frameWidth = canvas.frameWidth()
             clipPath = qwtCanvasClip(canvas, canvasRect)
         innerRect = canvasRect.adjusted(frameWidth, frameWidth,
                                         -frameWidth, -frameWidth)
         painter.save()
         if clipPath.isEmpty():
             painter.setClipRect(innerRect)
         else:
             painter.setClipPath(clipPath)
         if not self.__data.discardFlags & self.DiscardCanvasBackground:
             QwtPainter.drawBackground(painter, innerRect, canvas)
         plot.drawItems(painter, innerRect, maps)
         painter.restore()
         if frameWidth > 0:
             painter.save()
             frameStyle = canvas.frameShadow() | canvas.frameShape()
             frameWidth = canvas.frameWidth()
             borderRadius = canvas.borderRadius()
             if borderRadius > 0.:
                 QwtPainter.drawRoundedFrame(painter, canvasRect, r, r,
                                             canvas.palette(), frameWidth,
                                             frameStyle)
             else:
                 midLineWidth = canvas.midLineWidth()
                 QwtPainter.drawFrame(painter, canvasRect, canvas.palette(),
                                      canvas.foregroundRole(), frameWidth,
                                      midLineWidth, frameStyle)
             painter.restore()
コード例 #2
0
ファイル: plot_renderer.py プロジェクト: robinkqin/PythonQwt
    def renderCanvas(self, plot, painter, canvasRect, maps):
        """
        Render the canvas into a given rectangle.

        :param qwt.plot.QwtPlot plot: Plot widget
        :param QPainter painter: Painter
        :param qwt.scale_map.QwtScaleMap maps: mapping between plot and paint device coordinates
        :param QRectF rect: Bounding rectangle
        """
        canvas = plot.canvas()
        r = canvasRect.adjusted(0., 0., -1., 1.)
        if self.__data.layoutFlags & self.FrameWithScales:
            painter.save()
            r.adjust(-1., -1., 1., 1.)
            painter.setPen(QPen(Qt.black))
            if not (self.__data.discardFlags & self.DiscardCanvasBackground):
                bgBrush = canvas.palette().brush(plot.backgroundRole())
                painter.setBrush(bgBrush)
            painter.drawRect(r)
            painter.restore()
            painter.save()
            painter.setClipRect(canvasRect)
            plot.drawItems(painter, canvasRect, maps)
            painter.restore()
        elif canvas.testAttribute(Qt.WA_StyledBackground):
            clipPath = QPainterPath()
            painter.save()
            if not self.__data.discardFlags & self.DiscardCanvasBackground:
                QwtPainter.drawBackground(painter, r, canvas)
                clipPath = qwtCanvasClip(canvas, canvasRect)
            painter.restore()
            painter.save()
            if clipPath.isEmpty():
                painter.setClipRect(canvasRect)
            else:
                painter.setClipPath(clipPath)
            plot.drawItems(painter, canvasRect, maps)
            painter.restore()
        else:
            clipPath = QPainterPath()
            frameWidth = 0
            if not self.__data.discardFlags & self.DiscardCanvasFrame:
                frameWidth = canvas.frameWidth()
                clipPath = qwtCanvasClip(canvas, canvasRect)
            innerRect = canvasRect.adjusted(frameWidth, frameWidth,
                                            -frameWidth, -frameWidth)
            painter.save()
            if clipPath.isEmpty():
                painter.setClipRect(innerRect)
            else:
                painter.setClipPath(clipPath)
            if not self.__data.discardFlags & self.DiscardCanvasBackground:
                QwtPainter.drawBackground(painter, innerRect, canvas)
            plot.drawItems(painter, innerRect, maps)
            painter.restore()
            if frameWidth > 0:
                painter.save()
                frameStyle = canvas.frameShadow() | canvas.frameShape()
                frameWidth = canvas.frameWidth()
                borderRadius = canvas.borderRadius()
                if borderRadius > 0.:
                    QwtPainter.drawRoundedFrame(painter, canvasRect, r, r,
                                                canvas.palette(), frameWidth,
                                                frameStyle)
                else:
                    midLineWidth = canvas.midLineWidth()
                    QwtPainter.drawFrame(painter, canvasRect, canvas.palette(),
                                         canvas.foregroundRole(), frameWidth,
                                         midLineWidth, frameStyle)
                painter.restore()
コード例 #3
0
ファイル: plot_renderer.py プロジェクト: gyenney/Tools
    def renderCanvas(self, plot, painter, canvasRect, maps):
        """
        Render the canvas into a given rectangle.

        :param qwt.plot.QwtPlot plot: Plot widget
        :param QPainter painter: Painter
        :param qwt.scale_map.QwtScaleMap maps: mapping between plot and paint device coordinates
        :param QRectF rect: Bounding rectangle
        """
        canvas = plot.canvas()
        r = canvasRect.adjusted(0., 0., -1., 1.)
        if self.__data.layoutFlags & self.FrameWithScales:
            painter.save()
            r.adjust(-1., -1., 1., 1.)
            painter.setPen(QPen(Qt.black))
            if not (self.__data.discardFlags & self.DiscardCanvasBackground):
                bgBrush = canvas.palette().brush(plot.backgroundRole())
                painter.setBrush(bgBrush)
            QwtPainter.drawRect(painter, r)
            painter.restore()
            painter.save()
            painter.setClipRect(canvasRect)
            plot.drawItems(painter, canvasRect, maps)
            painter.restore()
        elif canvas.testAttribute(Qt.WA_StyledBackground):
            clipPath = QPainterPath()
            painter.save()
            if not self.__data.discardFlags & self.DiscardCanvasBackground:
                QwtPainter.drawBackground(painter, r, canvas)
                clipPath = qwtCanvasClip(canvas, canvasRect)
            painter.restore()
            painter.save()
            if clipPath.isEmpty():
                painter.setClipRect(canvasRect)
            else:
                painter.setClipPath(clipPath)
            plot.drawItems(painter, canvasRect, maps)
            painter.restore()
        else:
            clipPath = QPainterPath()
            frameWidth = 0
            if not self.__data.discardFlags & self.DiscardCanvasFrame:
                frameWidth = canvas.frameWidth()
                clipPath = qwtCanvasClip(canvas, canvasRect)
            innerRect = canvasRect.adjusted(frameWidth, frameWidth,
                                            -frameWidth, -frameWidth)
            painter.save()
            if clipPath.isEmpty():
                painter.setClipRect(innerRect)
            else:
                painter.setClipPath(clipPath)
            if not self.__data.discardFlags & self.DiscardCanvasBackground:
                QwtPainter.drawBackground(painter, innerRect, canvas)
            plot.drawItems(painter, innerRect, maps)
            painter.restore()
            if frameWidth > 0:
                painter.save()
                frameStyle = canvas.frameShadow() | canvas.frameShape()
                frameWidth = canvas.frameWidth()
                borderRadius = canvas.borderRadius()
                if borderRadius > 0.:
                    QwtPainter.drawRoundedFrame(painter, canvasRect, r, r,
                                                canvas.palette(), frameWidth,
                                                frameStyle)
                else:
                    midLineWidth = canvas.midLineWidth()
                    QwtPainter.drawFrame(painter, canvasRect, canvas.palette(),
                                         canvas.foregroundRole(), frameWidth,
                                         midLineWidth, frameStyle)
                painter.restore()
コード例 #4
0
 def renderCanvas(self, plot, painter, canvasRect, maps):
     canvas = plot.canvas()
     r = canvasRect.adjusted(0., 0., -1., 1.)
     if self.__data.layoutFlags & self.FrameWithScales:
         painter.save()
         r.adjust(-1., -1., 1., 1.)
         painter.setPen(QPen(Qt.black))
         if not (self.__data.discardFlags & self.DiscardCanvasBackground):
             bgBrush = canvas.palette().brush(plot.backgroundRole())
             painter.setBrush(bgBrush)
         QwtPainter.drawRect(painter, r)
         painter.restore()
         painter.save()
         painter.setClipRect(canvasRect)
         plot.drawItems(painter, canvasRect, maps)
         painter.restore()
     elif canvas.testAttribute(Qt.WA_StyledBackground):
         clipPath = QPainterPath()
         painter.save()
         if not self.__data.discardFlags & self.DiscardCanvasBackground:
             QwtPainter.drawBackground(painter, r, canvas)
             clipPath = qwtCanvasClip(canvas, canvasRect)
         painter.restore()
         painter.save()
         if clipPath.isEmpty():
             painter.setClipRect(canvasRect)
         else:
             painter.setClipPath(clipPath)
         plot.drawItems(painter, canvasRect, maps)
         painter.restore()
     else:
         clipPath = QPainterPath()
         frameWidth = 0
         if not self.__data.discardFlags & self.DiscardCanvasFrame:
             frameWidth = canvas.frameWidth()
             clipPath = qwtCanvasClip(canvas, canvasRect)
         innerRect = canvasRect.adjusted(frameWidth, frameWidth,
                                         -frameWidth, -frameWidth)
         painter.save()
         if clipPath.isEmpty():
             painter.setClipRect(innerRect)
         else:
             painter.setClipPath(clipPath)
         if not self.__data.discardFlags & self.DiscardCanvasBackground:
             QwtPainter.drawBackground(painter, innerRect, canvas)
         plot.drawItems(painter, innerRect, maps)
         painter.restore()
         if frameWidth > 0:
             painter.save()
             frameStyle = canvas.frameShadow() | canvas.frameShape()
             frameWidth = canvas.frameWidth()
             borderRadius = canvas.borderRadius()
             if borderRadius > 0.:
                 QwtPainter.drawRoundedFrame(painter, canvasRect, r, r,
                                             canvas.palette(), frameWidth,
                                             frameStyle)
             else:
                 midLineWidth = canvas.midLineWidth()
                 QwtPainter.drawFrame(painter, canvasRect, canvas.palette(),
                                      canvas.foregroundRole(), frameWidth,
                                      midLineWidth, frameStyle)
             painter.restore()