當前位置: 首頁>>代碼示例>>Python>>正文


Python QPainter.drawLine方法代碼示例

本文整理匯總了Python中qwt.qt.QtGui.QPainter.drawLine方法的典型用法代碼示例。如果您正苦於以下問題:Python QPainter.drawLine方法的具體用法?Python QPainter.drawLine怎麽用?Python QPainter.drawLine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在qwt.qt.QtGui.QPainter的用法示例。


在下文中一共展示了QPainter.drawLine方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: legendIcon

# 需要導入模塊: from qwt.qt.QtGui import QPainter [as 別名]
# 或者: from qwt.qt.QtGui.QPainter import drawLine [as 別名]
 def legendIcon(self, index, size):
     """
     :param int index: Index of the legend entry (ignored as there is only one)
     :param QSizeF size: Icon size
     :return: Icon representing the marker on the legend
     
     .. seealso::
     
         :py:meth:`qwt.plot.QwtPlotItem.setLegendIconSize()`,
         :py:meth:`qwt.plot.QwtPlotItem.legendData()`
     """
     if size.isEmpty():
         return QwtGraphic()
     icon = QwtGraphic()
     icon.setDefaultSize(size)
     icon.setRenderHint(QwtGraphic.RenderPensUnscaled, True)
     painter = QPainter(icon)
     painter.setRenderHint(QPainter.Antialiasing,
                       self.testRenderHint(QwtPlotItem.RenderAntialiased))
     if self.__data.style != QwtPlotMarker.NoLine:
         painter.setPen(self.__data.pen)
         if self.__data.style in (QwtPlotMarker.HLine, QwtPlotMarker.Cross):
             y = .5*size.height()
             painter.drawLine(0., y, size.width(), y)
         if self.__data.style in (QwtPlotMarker.VLine, QwtPlotMarker.Cross):
             x = .5*size.width()
             painter.drawLine(x, 0., x, size.height())
     if self.__data.symbol:
         r = QRect(0, 0, size.width(), size.height())
         self.__data.symbol.drawSymbol(painter, r)
     return icon
開發者ID:berrosse,項目名稱:PythonQwt,代碼行數:33,代碼來源:plot_marker.py

示例2: drawColorBar

# 需要導入模塊: from qwt.qt.QtGui import QPainter [as 別名]
# 或者: from qwt.qt.QtGui.QPainter import drawLine [as 別名]
 def drawColorBar(self, painter, colorMap, interval, scaleMap,
                  orientation, rect):
     colorTable = []
     if colorMap.format() == QwtColorMap.Indexed:
         colorTable = colorMap.colorTable(interval)
     c = QColor()
     devRect = rect.toAlignedRect()
     pixmap = QPixmap(devRect.size())
     pixmap.fill(Qt.transparent)
     pmPainter = QPainter(pixmap)
     pmPainter.translate(-devRect.x(), -devRect.y())
     if orientation == Qt.Horizontal:
         sMap = scaleMap
         sMap.setPaintInterval(rect.left(), rect.right())
         for x in range(devRect.left(), devRect.right()+1):
             value = sMap.invTransform(x)
             if colorMap.format() == QwtColorMap.RGB:
                 c.setRgba(colorMap.rgb(interval, value))
             else:
                 c = colorTable[colorMap.colorIndex(interval, value)]
             pmPainter.setPen(c)
             pmPainter.drawLine(x, devRect.top(), devRect.bottom())
     else:
         sMap = scaleMap
         sMap.setPaintInterval(rect.bottom(), rect.top())
         for y in range(devRect.top(), devRect.bottom()+1):
             value = sMap.invTransform(y)
             if colorMap.format() == QwtColorMap.RGB:
                 c.setRgba(colorMap.rgb(interval, value))
             else:
                 c = colorTable[colorMap.colorIndex(interval, value)]
             pmPainter.setPen(c)
             pmPainter.drawLine(devRect.left(), y, devRect.right(), y)
     pmPainter.end()
     self.drawPixmap(painter, rect, pixmap)
開發者ID:petebachant,項目名稱:python-qwt,代碼行數:37,代碼來源:painter.py

示例3: drawColorBar

# 需要導入模塊: from qwt.qt.QtGui import QPainter [as 別名]
# 或者: from qwt.qt.QtGui.QPainter import drawLine [as 別名]
 def drawColorBar(self, painter, colorMap, interval, scaleMap,
                  orientation, rect):
     """
     Draw a color bar into a rectangle
     
     :param QPainter painter: Painter
     :param qwt.color_map.QwtColorMap colorMap: Color map
     :param qwt.interval.QwtInterval interval: Value range
     :param qwt.scalemap.QwtScaleMap scaleMap: Scale map
     :param Qt.Orientation orientation: Orientation
     :param QRectF rect: Target rectangle
     """
     colorTable = []
     if colorMap.format() == QwtColorMap.Indexed:
         colorTable = colorMap.colorTable(interval)
     c = QColor()
     devRect = rect.toAlignedRect()
     pixmap = QPixmap(devRect.size())
     pixmap.fill(Qt.transparent)
     pmPainter = QPainter(pixmap)
     pmPainter.translate(-devRect.x(), -devRect.y())
     if orientation == Qt.Horizontal:
         sMap = QwtScaleMap(scaleMap)
         sMap.setPaintInterval(rect.left(), rect.right())
         for x in range(devRect.left(), devRect.right()+1):
             value = sMap.invTransform(x)
             if colorMap.format() == QwtColorMap.RGB:
                 c.setRgba(colorMap.rgb(interval, value))
             else:
                 c = colorTable[colorMap.colorIndex(interval, value)]
             pmPainter.setPen(c)
             pmPainter.drawLine(x, devRect.top(), x, devRect.bottom())
     else:
         sMap = QwtScaleMap(scaleMap)
         sMap.setPaintInterval(rect.bottom(), rect.top())
         for y in range(devRect.top(), devRect.bottom()+1):
             value = sMap.invTransform(y)
             if colorMap.format() == QwtColorMap.RGB:
                 c.setRgba(colorMap.rgb(interval, value))
             else:
                 c = colorTable[colorMap.colorIndex(interval, value)]
             pmPainter.setPen(c)
             pmPainter.drawLine(devRect.left(), y, devRect.right(), y)
     pmPainter.end()
     self.drawPixmap(painter, rect, pixmap)
開發者ID:gyenney,項目名稱:Tools,代碼行數:47,代碼來源:painter.py

示例4: legendIcon

# 需要導入模塊: from qwt.qt.QtGui import QPainter [as 別名]
# 或者: from qwt.qt.QtGui.QPainter import drawLine [as 別名]
    def legendIcon(self, index, size):
        """
        :param int index: Index of the legend entry (ignored as there is only one)
        :param QSizeF size: Icon size
        :return: Icon representing the curve on the legend
        
        .. seealso::
        
            :py:meth:`qwt.plot.QwtPlotItem.setLegendIconSize()`,
            :py:meth:`qwt.plot.QwtPlotItem.legendData()`
        """
        if size.isEmpty():
            return QwtGraphic()
        graphic = QwtGraphic()
        graphic.setDefaultSize(size)
        graphic.setRenderHint(QwtGraphic.RenderPensUnscaled, True)
        painter = QPainter(graphic)
        painter.setRenderHint(QPainter.Antialiasing,
                          self.testRenderHint(QwtPlotItem.RenderAntialiased))
        if self.__data.legendAttributes == 0 or\
           (self.__data.legendAttributes & QwtPlotCurve.LegendShowBrush):
            brush = self.__data.brush
            if brush.style() == Qt.NoBrush and self.__data.legendAttributes == 0:
                if self.style() != QwtPlotCurve.NoCurve:
                    brush = QBrush(self.pen().color())
                elif self.__data.symbol and\
                     self.__data.symbol.style() != QwtSymbol.NoSymbol:
                    brush = QBrush(self.__data.symbol.pen().color())
            if brush.style() != Qt.NoBrush:
                r = QRectF(0, 0, size.width(), size.height())
                painter.fillRect(r, brush)
        if self.__data.legendAttributes & QwtPlotCurve.LegendShowLine:
            if self.pen() != Qt.NoPen:
                pn = self.pen()
#                pn.setCapStyle(Qt.FlatCap)
                painter.setPen(pn)
                y = .5*size.height()
                painter.drawLine(0., y, size.width(), y)
        if self.__data.legendAttributes & QwtPlotCurve.LegendShowSymbol:
            if self.__data.symbol:
                r = QRectF(0, 0, size.width(), size.height())
                self.__data.symbol.drawSymbol(painter, r)
        return graphic    
開發者ID:berrosse,項目名稱:PythonQwt,代碼行數:45,代碼來源:plot_curve.py


注:本文中的qwt.qt.QtGui.QPainter.drawLine方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。