Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
 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)