本文整理汇总了Python中qwt.painter.QwtPainter.drawLine方法的典型用法代码示例。如果您正苦于以下问题:Python QwtPainter.drawLine方法的具体用法?Python QwtPainter.drawLine怎么用?Python QwtPainter.drawLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qwt.painter.QwtPainter
的用法示例。
在下文中一共展示了QwtPainter.drawLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: legendIcon
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter import drawLine [as 别名]
def legendIcon(self, index, size):
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()
QwtPainter.drawLine(painter, 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
示例2: legendIcon
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter 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()
QwtPainter.drawLine(painter, 0., y, size.width(), y)
if self.__data.style in (QwtPlotMarker.VLine, QwtPlotMarker.Cross):
x = .5*size.width()
QwtPainter.drawLine(painter, 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
示例3: drawLines
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter import drawLine [as 别名]
def drawLines(self, painter, canvasRect, pos):
"""
Draw the lines marker
:param QPainter painter: Painter
:param QRectF canvasRect: Contents rectangle of the canvas in painter coordinates
:param QPointF pos: Position of the marker, translated into widget coordinates
.. seealso::
:py:meth:`drawLabel()`,
:py:meth:`qwt.symbol.QwtSymbol.drawSymbol()`
"""
if self.__data.style == self.NoLine:
return
doAlign = QwtPainter.roundingAlignment(painter)
painter.setPen(self.__data.pen)
if self.__data.style in (QwtPlotMarker.HLine, QwtPlotMarker.Cross):
y = pos.y()
if doAlign:
y = round(y)
QwtPainter.drawLine(painter, canvasRect.left(),
y, canvasRect.right()-1., y)
if self.__data.style in (QwtPlotMarker.VLine, QwtPlotMarker.Cross):
x = pos.x()
if doAlign:
x = round(x)
QwtPainter.drawLine(painter, x,
canvasRect.top(), x, canvasRect.bottom()-1.)
示例4: drawBackbone
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter import drawLine [as 别名]
def drawBackbone(self, painter):
doAlign = QwtPainter.roundingAlignment(painter)
pos = self.__data.pos
len_ = self.__data.len
pw = max([self.penWidth(), 1])
if doAlign:
if self.alignment() in (self.LeftScale, self.TopScale):
off = (pw-1)/2
else:
off = pw/2
else:
off = .5*self.penWidth()
if self.alignment() == self.LeftScale:
x = pos.x() - off
if doAlign:
x = round(x)
QwtPainter.drawLine(painter, x, pos.y(), x, pos.y()+len_)
elif self.alignment() == self.RightScale:
x = pos.x() + off
if doAlign:
x = round(x)
QwtPainter.drawLine(painter, x, pos.y(), x, pos.y()+len_)
elif self.alignment() == self.TopScale:
y = pos.y() - off
if doAlign:
y = round(y)
QwtPainter.drawLine(painter, pos.x(), y, pos.x()+len_, y)
elif self.alignment() == self.BottomScale:
y = pos.y() + off
if doAlign:
y = round(y)
QwtPainter.drawLine(painter, pos.x(), y, pos.x()+len_, y)
示例5: qwtDrawXCrossSymbols
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter import drawLine [as 别名]
def qwtDrawXCrossSymbols(painter, points, numPoints, symbol):
size =symbol.size()
off = 0
pen = QPen(symbol.pen())
if pen.width() > 1:
pen.setCapStyle(Qt.FlatCap)
off = 1
painter.setPen(pen)
if QwtPainter.roundingAlignment(painter):
sw = np.floor(size.width())
sh = np.floor(size.height())
sw2 = size.width()//2
sh2 = size.height()//2
for pos in points:
x = round(pos.x())
y = round(pos.y())
x1 = x-sw2
x2 = x1+sw+off
y1 = y-sh2
y2 = y1+sh+off
QwtPainter.drawLine(painter, x1, y1, x2, y2)
QwtPainter.drawLine(painter, x2, y1, x1, y2)
else:
sw = size.width()
sh = size.height()
sw2 = .5*size.width()
sh2 = .5*size.height()
for pos in points:
x1 = pos.x()-sw2
x2 = x1+sw
y1 = pos.y()-sh2
y2 = y1+sh
QwtPainter.drawLine(painter, x1, y1, x2, y2)
QwtPainter.drawLine(painter, x2, y1, x1, y2)
示例6: drawLines
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter import drawLine [as 别名]
def drawLines(self, painter, canvasRect, pos):
if self.__data.style == self.NoLine:
return
doAlign = QwtPainter.roundingAlignment(painter)
painter.setPen(self.__data.pen)
if self.__data.style in (QwtPlotMarker.HLine, QwtPlotMarker.Cross):
y = pos.y()
if doAlign:
y = round(y)
QwtPainter.drawLine(painter, canvasRect.left(),
y, canvasRect.right()-1., y)
if self.__data.style in (QwtPlotMarker.VLine, QwtPlotMarker.Cross):
x = pos.x()
if doAlign:
x = round(x)
QwtPainter.drawLine(painter, x,
canvasRect.top(), x, canvasRect.bottom()-1.)
示例7: drawLines
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter import drawLine [as 别名]
def drawLines(self, painter, canvasRect, orientation, scaleMap, values):
x1 = canvasRect.left()
x2 = canvasRect.right()-1.
y1 = canvasRect.top()
y2 = canvasRect.bottom()-1.
doAlign = QwtPainter.roundingAlignment(painter)
for val in values:
value = scaleMap.transform(val)
if doAlign:
value = round(value)
if orientation == Qt.Horizontal:
if qwtFuzzyGreaterOrEqual(value, y1) and\
qwtFuzzyLessOrEqual(value, y2):
QwtPainter.drawLine(painter, x1, value, x2, value)
else:
if qwtFuzzyGreaterOrEqual(value, x1) and\
qwtFuzzyLessOrEqual(value, x2):
QwtPainter.drawLine(painter, value, y1, value, y2)
示例8: drawTick
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter import drawLine [as 别名]
def drawTick(self, painter, value, len_):
"""
Draw a tick
:param QPainter painter: Painter
:param float value: Value of the tick
:param float len: Length of the tick
.. seealso::
:py:meth:`drawBackbone()`, :py:meth:`drawLabel()`
"""
if len_ <= 0:
return
roundingAlignment = QwtPainter.roundingAlignment(painter)
pos = self.__data.pos
tval = self.scaleMap().transform(value)
if roundingAlignment:
tval = round(tval)
pw = self.penWidth()
a = 0
if pw > 1 and roundingAlignment:
a = 1
if self.alignment() == self.LeftScale:
x1 = pos.x() + a
x2 = pos.x() + a - pw - len_
if roundingAlignment:
x1 = round(x1)
x2 = round(x2)
QwtPainter.drawLine(painter, x1, tval, x2, tval)
elif self.alignment() == self.RightScale:
x1 = pos.x()
x2 = pos.x() + pw + len_
if roundingAlignment:
x1 = round(x1)
x2 = round(x2)
QwtPainter.drawLine(painter, x1, tval, x2, tval)
elif self.alignment() == self.BottomScale:
y1 = pos.y()
y2 = pos.y() + pw + len_
if roundingAlignment:
y1 = round(y1)
y2 = round(y2)
QwtPainter.drawLine(painter, tval, y1, tval, y2)
elif self.alignment() == self.TopScale:
y1 = pos.y() + a
y2 = pos.y() - pw - len_ + a
if roundingAlignment:
y1 = round(y1)
y2 = round(y2)
QwtPainter.drawLine(painter, tval, y1, tval, y2)
示例9: legendIcon
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter 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()
QwtPainter.drawLine(painter, 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
示例10: legendIcon
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter import drawLine [as 别名]
def legendIcon(self, index, size):
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()
QwtPainter.drawLine(painter, 0., y, size.width(), y)
if self.__data.style in (QwtPlotMarker.VLine, QwtPlotMarker.Cross):
x = .5*size.width()
QwtPainter.drawLine(painter, 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
示例11: drawSticks
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter import drawLine [as 别名]
def drawSticks(self, painter, xMap, yMap, canvasRect, from_, to):
"""
Draw sticks
:param QPainter painter: Painter
:param qwt.scale_map.QwtScaleMap xMap: Maps x-values into pixel coordinates.
:param qwt.scale_map.QwtScaleMap yMap: Maps y-values into pixel coordinates.
:param QRectF canvasRect: Contents rectangle of the canvas
:param int from_: Index of the first point to be painted
:param int to: Index of the last point to be painted. If to < 0 the curve will be painted to its last point.
.. seealso::
:py:meth:`draw()`, :py:meth:`drawDots()`,
:py:meth:`drawSteps()`, :py:meth:`drawLines()`
"""
painter.save()
painter.setRenderHint(QPainter.Antialiasing, False)
doAlign = QwtPainter.roundingAlignment(painter)
x0 = xMap.transform(self.__data.baseline)
y0 = yMap.transform(self.__data.baseline)
if doAlign:
x0 = round(x0)
y0 = round(y0)
o = self.orientation()
series = self.data()
for i in range(from_, to+1):
sample = series.sample(i)
xi = xMap.transform(sample.x())
yi = yMap.transform(sample.y())
if doAlign:
xi = round(xi)
yi = round(yi)
if o == Qt.Horizontal:
QwtPainter.drawLine(painter, x0, yi, xi, yi)
else:
QwtPainter.drawLine(painter, xi, y0, xi, yi)
painter.restore()
示例12: drawSticks
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter import drawLine [as 别名]
def drawSticks(self, painter, xMap, yMap, canvasRect, from_, to):
painter.save()
painter.setRenderHint(QPainter.Antialiasing, False)
doAlign = QwtPainter.roundingAlignment(painter)
x0 = xMap.transform(self.__data.baseline)
y0 = yMap.transform(self.__data.baseline)
if doAlign:
x0 = round(x0)
y0 = round(y0)
o = self.orientation()
series = self.data()
for i in range(from_, to+1):
sample = series.sample(i)
xi = xMap.transform(sample.x())
yi = yMap.transform(sample.y())
if doAlign:
xi = round(xi)
yi = round(yi)
if o == Qt.Horizontal:
QwtPainter.drawLine(painter, x0, yi, xi, yi)
else:
QwtPainter.drawLine(painter, xi, y0, xi, yi)
painter.restore()
示例13: drawBackbone
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter import drawLine [as 别名]
def drawBackbone(self, painter):
"""
Draws the baseline of the scale
:param QPainter painter: Painter
.. seealso::
:py:meth:`drawTick()`, :py:meth:`drawLabel()`
"""
doAlign = QwtPainter.roundingAlignment(painter)
pos = self.__data.pos
len_ = self.__data.len
pw = max([self.penWidth(), 1])
if doAlign:
if self.alignment() in (self.LeftScale, self.TopScale):
off = (pw-1)/2
else:
off = pw/2
else:
off = .5*self.penWidth()
if self.alignment() == self.LeftScale:
x = pos.x() - off
if doAlign:
x = round(x)
QwtPainter.drawLine(painter, x, pos.y(), x, pos.y()+len_)
elif self.alignment() == self.RightScale:
x = pos.x() + off
if doAlign:
x = round(x)
QwtPainter.drawLine(painter, x, pos.y(), x, pos.y()+len_)
elif self.alignment() == self.TopScale:
y = pos.y() - off
if doAlign:
y = round(y)
QwtPainter.drawLine(painter, pos.x(), y, pos.x()+len_, y)
elif self.alignment() == self.BottomScale:
y = pos.y() + off
if doAlign:
y = round(y)
QwtPainter.drawLine(painter, pos.x(), y, pos.x()+len_, y)
示例14: drawTick
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter import drawLine [as 别名]
def drawTick(self, painter, value, len_):
if len_ <= 0:
return
roundingAlignment = QwtPainter.roundingAlignment(painter)
pos = self.__data.pos
tval = self.scaleMap().transform(value)
if roundingAlignment:
tval = round(tval)
pw = self.penWidth()
a = 0
if pw > 1 and roundingAlignment:
a = 1
if self.alignment() == self.LeftScale:
x1 = pos.x() + a
x2 = pos.x() + a - pw - len_
if roundingAlignment:
x1 = round(x1)
x2 = round(x2)
QwtPainter.drawLine(painter, x1, tval, x2, tval)
elif self.alignment() == self.RightScale:
x1 = pos.x()
x2 = pos.x() + pw + len_
if roundingAlignment:
x1 = round(x1)
x2 = round(x2)
QwtPainter.drawLine(painter, x1, tval, x2, tval)
elif self.alignment() == self.BottomScale:
y1 = pos.y()
y2 = pos.y() + pw + len_
if roundingAlignment:
y1 = round(y1)
y2 = round(y2)
QwtPainter.drawLine(painter, tval, y1, tval, y2)
elif self.alignment() == self.TopScale:
y1 = pos.y() + a
y2 = pos.y() - pw - len_ + a
if roundingAlignment:
y1 = round(y1)
y2 = round(y2)
QwtPainter.drawLine(painter, tval, y1, tval, y2)
示例15: qwtDrawLineSymbols
# 需要导入模块: from qwt.painter import QwtPainter [as 别名]
# 或者: from qwt.painter.QwtPainter import drawLine [as 别名]
def qwtDrawLineSymbols(painter, orientations, points, numPoints, symbol):
size =symbol.size()
off = 0
pen = QPen(symbol.pen())
if pen.width() > 1:
pen.setCapStyle(Qt.FlatCap)
off = 1
painter.setPen(pen)
painter.setRenderHint(QPainter.Antialiasing, False)
if QwtPainter.roundingAlignment(painter):
sw = np.floor(size.width())
sh = np.floor(size.height())
sw2 = size.width()//2
sh2 = size.height()//2
for pos in points:
if orientations & Qt.Horizontal:
x = round(pos.x())-sw2
y = round(pos.y())
QwtPainter.drawLine(painter, x, y, x+sw+off, y)
if orientations & Qt.Vertical:
x = round(pos.x())
y = round(pos.y())-sh2
QwtPainter.drawLine(painter, x, y, x, y+sh+off)
else:
sw = size.width()
sh = size.height()
sw2 = .5*size.width()
sh2 = .5*size.height()
for pos in points:
if orientations & Qt.Horizontal:
x = round(pos.x())-sw2
y = round(pos.y())
QwtPainter.drawLine(painter, x, y, x+sw, y)
if orientations & Qt.Vertical:
x = round(pos.x())
y = round(pos.y())-sh2
QwtPainter.drawLine(painter, x, y, x, y+sh)