def drawBorder(self, painter): if self.__data.borderRadius > 0: if self.frameWidth() > 0: QwtPainter.drawRoundedFrame(painter, QRectF(self.frameRect()), self.__data.borderRadius, self.__data.borderRadius, self.palette(), self.frameWidth(), self.frameStyle()) else: if QT_VERSION >= 0x040500: if PYQT5: from qwt.qt.QtGui import QStyleOptionFrame else: from qwt.qt.QtGui import QStyleOptionFrameV3 as\ QStyleOptionFrame opt = QStyleOptionFrame() opt.initFrom(self) frameShape = self.frameStyle() & QFrame.Shape_Mask frameShadow = self.frameStyle() & QFrame.Shadow_Mask opt.frameShape = QFrame.Shape(int(opt.frameShape) | frameShape) if frameShape in (QFrame.Box, QFrame.HLine, QFrame.VLine, QFrame.StyledPanel, QFrame.Panel): opt.lineWidth = self.lineWidth() opt.midLineWidth = self.midLineWidth() else: opt.lineWidth = self.frameWidth() if frameShadow == self.Sunken: opt.state |= QStyle.State_Sunken elif frameShadow == self.Raised: opt.state |= QStyle.State_Raised self.style().drawControl(QStyle.CE_ShapedFrame, opt, painter, self) else: self.drawFrame(painter)
def drawBorder(self, painter): if self.__data.borderRadius > 0: if self.frameWidth() > 0: QwtPainter.drawRoundedFrame(painter, QRectF(self.frameRect()), self.__data.borderRadius, self.__data.borderRadius, self.palette(), self.frameWidth(), self.frameStyle()) else: if QT_VERSION >= 0x040500: if PYQT5: from qwt.qt.QtGui import QStyleOptionFrame else: from qwt.qt.QtGui import QStyleOptionFrameV3 as\ QStyleOptionFrame opt = QStyleOptionFrame() opt.initFrom(self) frameShape = self.frameStyle() & QFrame.Shape_Mask frameShadow = self.frameStyle() & QFrame.Shadow_Mask opt.frameShape = QFrame.Shape(int(opt.frameShape)|frameShape) if frameShape in (QFrame.Box, QFrame.HLine, QFrame.VLine, QFrame.StyledPanel, QFrame.Panel): opt.lineWidth = self.lineWidth() opt.midLineWidth = self.midLineWidth() else: opt.lineWidth = self.frameWidth() if frameShadow == self.Sunken: opt.state |= QStyle.State_Sunken elif frameShadow == self.Raised: opt.state |= QStyle.State_Raised self.style().drawControl(QStyle.CE_ShapedFrame, opt, painter, self) else: self.drawFrame(painter)
def drawBorder(self, painter): """ Draw the border of the plot canvas :param QPainter painter: Painter .. seealso:: :py:meth:`setBorderRadius()` """ if self.__data.borderRadius > 0: if self.frameWidth() > 0: QwtPainter.drawRoundedFrame( painter, QRectF(self.frameRect()), self.__data.borderRadius, self.__data.borderRadius, self.palette(), self.frameWidth(), self.frameStyle(), ) else: if PYQT5: from qtpy.QtWidgets import QStyleOptionFrame else: try: from PyQt4.QtGui import QStyleOptionFrameV3 as QStyleOptionFrame except ImportError: from PySide2.QtWidgets import QStyleOptionFrame opt = QStyleOptionFrame() opt.initFrom(self) frameShape = self.frameStyle() & QFrame.Shape_Mask frameShadow = self.frameStyle() & QFrame.Shadow_Mask opt.frameShape = QFrame.Shape(int(opt.frameShape) | frameShape) if frameShape in ( QFrame.Box, QFrame.HLine, QFrame.VLine, QFrame.StyledPanel, QFrame.Panel, ): opt.lineWidth = self.lineWidth() opt.midLineWidth = self.midLineWidth() else: opt.lineWidth = self.frameWidth() if frameShadow == self.Sunken: opt.state |= QStyle.State_Sunken elif frameShadow == self.Raised: opt.state |= QStyle.State_Raised self.style().drawControl(QStyle.CE_ShapedFrame, opt, painter, self)
def drawBorder(self, painter): """ Draw the border of the plot canvas :param QPainter painter: Painter .. seealso:: :py:meth:`setBorderRadius()` """ if self.__data.borderRadius > 0: if self.frameWidth() > 0: QwtPainter.drawRoundedFrame( painter, QRectF(self.frameRect()), self.__data.borderRadius, self.__data.borderRadius, self.palette(), self.frameWidth(), self.frameStyle(), ) else: opt = QStyleOptionFrame() opt.initFrom(self) try: shape_mask = QFrame.Shape_Mask.value shadow_mask = QFrame.Shadow_Mask.value except AttributeError: shape_mask = QFrame.Shape_Mask shadow_mask = QFrame.Shadow_Mask frameShape = self.frameStyle() & shape_mask frameShadow = self.frameStyle() & shadow_mask opt.frameShape = QFrame.Shape(int(opt.frameShape) | frameShape) if frameShape in ( QFrame.Box, QFrame.HLine, QFrame.VLine, QFrame.StyledPanel, QFrame.Panel, ): opt.lineWidth = self.lineWidth() opt.midLineWidth = self.midLineWidth() else: opt.lineWidth = self.frameWidth() if frameShadow == self.Sunken: opt.state |= QStyle.State_Sunken elif frameShadow == self.Raised: opt.state |= QStyle.State_Raised self.style().drawControl(QStyle.CE_ShapedFrame, opt, painter, self)
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()
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()
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()
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()