本文整理汇总了Python中PySide.QtGui.QPainterPath.addRect方法的典型用法代码示例。如果您正苦于以下问题:Python QPainterPath.addRect方法的具体用法?Python QPainterPath.addRect怎么用?Python QPainterPath.addRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPainterPath
的用法示例。
在下文中一共展示了QPainterPath.addRect方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setupPaint
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRect [as 别名]
def setupPaint(self):
"""Offscreen rather than onscreen redraw (few changes)."""
path = QPainterPath()
if self.data.isInput:
path.addEllipse(
self.pinW / 2, self.pinW / 2, self.bodyW, self.bodyW)
else:
path.addRect(
3 * self.pinW / 2 + 1, self.pinW / 2, self.bodyW, self.bodyW)
path.addPath(self.pinPath)
self.setPath(path)
self.name.setVisible(self.showName)
self.name.setText(self.data.name)
br = self.mapToScene(self.boundingRect())
w = self.boundingRect().width()
h = self.boundingRect().height()
realX = min([i.x() for i in br])
realY = min([i.y() for i in br])
self.name.setPos(self.mapFromScene(
realX, realY + (w if self.rotation() % 180 else h) + 1))
self.value.setText(
str(int(self.data.value)) if self.data.value is not None else 'E')
self.value.setPos(self.mapFromScene(realX + w / 3, realY + h / 3))
self.value.setBrush(QColor('green' if self.data.value else 'red'))
self.update() # Force onscreen redraw after changes.
示例2: __init__
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRect [as 别名]
def __init__(self, pos, edge, symbol):
''' Create the point - as a small, lightblue box '''
super(Connectionpoint, self).__init__(pos, edge=edge)
path = QPainterPath()
path.addRect(0, 0, 10, 10)
self.setPath(path)
self.setPos(pos.x() - 5, pos.y() - 5)
# Symbol actually owning the connection point
self.symbol = symbol
示例3: objectSavePath
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRect [as 别名]
def objectSavePath(self):
"""
TOWRITE
:rtype: `QPainterPath`_
"""
path = QPainterPath()
path.addRect(-0.00000001, -0.00000001, 0.00000002, 0.00000002)
return path
示例4: set_shape
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRect [as 别名]
def set_shape(self, width, height):
''' Compute the polygon to fit in width, height '''
path = QPainterPath()
path.addRect(0, 0, width, height)
path.moveTo(7, 0)
path.lineTo(7, height)
path.moveTo(width - 7, 0)
path.lineTo(width - 7, height)
self.setPath(path)
super(ProcedureCall, self).set_shape(width, height)
示例5: setRectFromRect
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRect [as 别名]
def setRectFromRect(self, r):
"""
TOWRITE
:param `r`: TOWRITE
:type `r`: QPointF
"""
p = QPainterPath()
p.addRect(r)
self.setPath(p)
示例6: paintEvent
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRect [as 别名]
def paintEvent(self, event):
cX = self.parent.leftMargin + self.scaleMarkLen
cY = self.parent.topMargin + self.scaleMarkLen
worldX = self.parent.chunkX*16
worldZ = self.parent.chunkZ*16
painter = QPainter()
path = QPainterPath()
painter.begin(self)
painter.save()
#painter.setFont(QFont('Arial Narrow', 8)) #QFont.Bold
# draw scale
x = cX
y = cY
painter.rotate(-90)
for i in range(16):
fr = QRectF(-y, x, self.scaleMarkLen, self.edgeLen)
painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
painter.drawRect(fr)
#fr = QRectF(-y - 16*self.edgeLen - self.scaleMarkLen, x, self.scaleMarkLen, self.edgeLen)
#painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
#painter.drawRect(fr)
x += self.edgeLen
painter.rotate(90)
x = self.parent.leftMargin
y = cY
for i in range(16):
fr = QRectF(x, y, self.scaleMarkLen, self.edgeLen)
painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
painter.drawRect(fr)
#fr = QRectF(x + self.scaleMarkLen + 16*self.edgeLen, y, self.scaleMarkLen, self.edgeLen)
#painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
#painter.drawRect(fr)
y += self.edgeLen
x = cX
y = cY
for i in range(16):
for j in range(16):
path.addRect(x, y, self.edgeLen, self.edgeLen)
fr = QRectF(x, y, self.edgeLen, self.edgeLen)
#painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
x += self.edgeLen
x = cX
y += self.edgeLen
painter.drawPath(path)
painter.restore()
painter.end()
del painter
示例7: updatePath
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRect [as 别名]
def updatePath(self):
"""
TOWRITE
"""
path = QPainterPath()
r = self.rect() # QRectF
# Add the center point.
path.addRect(-0.00000001, -0.00000001, 0.00000002, 0.00000002)
# Add the circle.
path.arcMoveTo(r, 0)
path.arcTo(r, 0, 360)
# NOTE: Reverse the path so that the inside area isn't considered part of the circle.
path.arcTo(r, 0, -360)
self.setObjectPath(path)
示例8: setRectFromXYWH
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRect [as 别名]
def setRectFromXYWH(self, x, y, w, h):
"""
TOWRITE
:param `x`: TOWRITE
:type `x`: qreal
:param `y`: TOWRITE
:type `y`: qreal
:param `w`: TOWRITE
:type `w`: qreal
:param `h`: TOWRITE
:type `h`: qreal
"""
p = QPainterPath()
p.addRect(x, y, w, h)
self.setPath(p)
示例9: paintEvent
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRect [as 别名]
def paintEvent(self, event):
painter = QPainter(self)
# Фон
painter_path = QPainterPath()
painter_path.addRect(0, 0, self.width() - 1, self.height() - 1)
painter.fillPath(painter_path,
QBrush(QImage(':/main/background.png')))
if self.image:
painter.drawText(10, 20, str(self.image.draw_scale))
painter.setTransform(QTransform().
scale(self.image.draw_scale, self.image.draw_scale).
translate(self.image.draw_offset.x(), self.image.draw_offset.y()))
old_pen = painter.pen()
new_pen = QPen()
new_pen.setColor(QColor(0, 150, 0))
painter.setPen(new_pen)
self.image.draw(painter)
painter.setPen(old_pen)
示例10: paintEvent
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRect [as 别名]
def paintEvent(self, event):
cX = self.parent.lytLeftMargin + self.scaleMarkLen
cY = self.parent.lytTopMargin + self.scaleMarkLen
worldX = self.parent.presenter.showChunkX*16
worldZ = self.parent.presenter.showChunkZ*16
painter = QPainter()
path = QPainterPath()
painter.begin(self)
painter.save()
#painter.setFont(QFont('Arial Narrow', 8)) #QFont.Bold
# draw scale
x = cX
y = cY
painter.rotate(-90)
for i in range(16):
fr = QRectF(-y, x, self.scaleMarkLen, self.edgeLen)
painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, str(worldX))
#painter.drawRect(fr)
#fr = QRectF(-y - 16*self.edgeLen - self.scaleMarkLen, x, self.scaleMarkLen, self.edgeLen)
#painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
#painter.drawRect(fr)
x += self.edgeLen
worldX += 1
painter.rotate(90)
x = self.parent.lytLeftMargin
y = cY
for i in range(16):
fr = QRectF(x, y, self.scaleMarkLen, self.edgeLen)
painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, str(worldZ))
#painter.drawRect(fr)
#fr = QRectF(x + self.scaleMarkLen + 16*self.edgeLen, y, self.scaleMarkLen, self.edgeLen)
#painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
#painter.drawRect(fr)
y += self.edgeLen
worldZ += 1
x = cX
y = cY
for i in range(16):
for j in range(16):
path.addRect(x, y, self.edgeLen, self.edgeLen)
#fr = QRectF(x, y, self.edgeLen, self.edgeLen)
#painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
x += self.edgeLen
x = cX
y += self.edgeLen
painter.drawPath(path)
slice_ = self.parent.presenter.getSlice(self.parent.presenter.elevation)
x = cX
y = cY
bru = QBrush()
#path1 = QPainterPath()
for i in range(16):
for j in range(16):
if slice_[i][j] in self.parent.selectedMinerals.list_:
lePen = painter.pen()
newPen = QPen(bru, 3)
newPen.setColor(self.parent.selectedMinerals.getColor(slice_[i][j]))
painter.setPen(newPen)
painter.drawRect(x, y, self.edgeLen, self.edgeLen)
painter.setPen(lePen)
x += self.edgeLen
x = cX
y += self.edgeLen
painter.restore()
painter.end()
del painter
示例11: updateLeader
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRect [as 别名]
def updateLeader(self):
"""
TOWRITE
"""
arrowStyle = Closed # int # TODO: Make this customizable
arrowStyleAngle = 15.0 # qreal # TODO: Make this customizable
arrowStyleLength = 1.0 # qreal # TODO: Make this customizable
self.lineStyleAngle = 45.0 # qreal # TODO: Make this customizable
self.lineStyleLength = 1.0 # qreal # TODO: Make this customizable
lyne = self.line() # QLineF
angle = lyne.angle() # qreal
ap0 = lyne.p1() # QPointF
lp0 = lyne.p2() # QPointF
# Arrow
lynePerp = QLineF(lyne.pointAt(arrowStyleLength / lyne.length()), lp0)
lynePerp.setAngle(angle + 90)
lyne1 = QLineF(ap0, lp0)
lyne2 = QLineF(ap0, lp0)
lyne1.setAngle(angle + arrowStyleAngle)
lyne2.setAngle(angle - arrowStyleAngle)
# ap1 = QPointF()
# ap2 = QPointF()
_, ap1 = lynePerp.intersect(lyne1)
_, ap2 = lynePerp.intersect(lyne2)
# Math Diagram
# .(ap1) .(lp1)
# /| /|
# / | / |
# / | / |
# / | / |
# / | / |
# / | / |
# / | / |
# / | / |
# /+(aSA) | /+(lSA) |
# (ap0)./__(aSL)__|__________(lp0)./__(lSL)__|
# \ -(aSA) | \ -(lSA) |
# \ | \ |
# \ | \ |
# \ | \ |
# \ | \ |
# \ | \ |
# \ | \ |
# \ | \ |
# \ | \ |
# \| \|
# .(ap2) .(lp2)
if arrowStyle == Open:
arrowStylePath = QPainterPath()
arrowStylePath.moveTo(ap1)
arrowStylePath.lineTo(ap0)
arrowStylePath.lineTo(ap2)
arrowStylePath.lineTo(ap0)
arrowStylePath.lineTo(ap1)
elif arrowStyle == Closed:
arrowStylePath = QPainterPath()
arrowStylePath.moveTo(ap1)
arrowStylePath.lineTo(ap0)
arrowStylePath.lineTo(ap2)
arrowStylePath.lineTo(ap1)
elif arrowStyle == Dot:
arrowStylePath = QPainterPath()
arrowStylePath.addEllipse(ap0, arrowStyleLength, arrowStyleLength)
elif arrowStyle == Box:
arrowStylePath = QPainterPath()
side = QLineF(ap1, ap2).length() # qreal
ar0 = QRectF(0, 0, side, side)
ar0.moveCenter(ap0)
arrowStylePath.addRect(ar0)
elif arrowStyle == Tick:
pass #TODO/PORT# Is this supposed to be empty?
lineStylePath = QPainterPath()
lineStylePath.moveTo(ap0)
lineStylePath.lineTo(lp0)
示例12: set_shape
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRect [as 别名]
def set_shape(self, width, height):
''' Set a box - actual shape is computed in the paint function '''
path = QPainterPath()
path.addRect(0, 0, width, height)
self.setPath(path)
super(Comment, self).set_shape(width, height)