本文整理汇总了Python中PyQt4.QtGui.QPolygonF.append方法的典型用法代码示例。如果您正苦于以下问题:Python QPolygonF.append方法的具体用法?Python QPolygonF.append怎么用?Python QPolygonF.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QPolygonF
的用法示例。
在下文中一共展示了QPolygonF.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
def __init__(self, parent):
points = QPolygonF()
self._mediator = ArrowMediator()
for poly in (QPointF(7,0), QPointF(-7,7), QPointF(-5,2), QPointF(-11,2),
QPointF(-11,-2), QPointF(-5,-2), QPointF(-7,-7)):
points.append(poly)
QGraphicsPolygonItem.__init__(self, points, parent)
self.setPen(Qt.darkCyan)
self.setBrush(Qt.cyan)
示例2: _draw_polygon
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
def _draw_polygon(self, painter, xMap, yMap, range_tuple):
# range_tuple might contain more then four values !
rtmin, rtmax, mzmin, mzmax = range_tuple[:4]
points = QPolygonF()
points.append(QPointF(xMap.transform(rtmin), yMap.transform(mzmin)))
points.append(QPointF(xMap.transform(rtmin), yMap.transform(mzmax)))
points.append(QPointF(xMap.transform(rtmax), yMap.transform(mzmax)))
points.append(QPointF(xMap.transform(rtmax), yMap.transform(mzmin)))
painter.drawPolygon(points)
return points
示例3: _paintPolygon
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
def _paintPolygon(self, painter, polygon):
path = QPainterPath()
for line in polygon:
ring = QPolygonF()
for point in line:
cur = self.toCanvasCoordinates(point) - self.pos()
ring.append(cur)
ring.append(ring[0])
path.addPolygon(ring)
painter.drawPath(path)
示例4: sample_interpolate
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
def sample_interpolate(self, x, y):
spline = QwtSpline()
points = QPolygonF()
for point in zip(x, y):
points.append(QPointF(*point))
spline.setSplineType(QwtSpline.Natural)
spline.setPoints(points)
px = range(0, 2**12, DistanceIR.DIVIDER)
py = []
for X in px:
py.append(spline.value(X))
for i in range(x[0]/DistanceIR.DIVIDER):
py[i] = y[0]
for i in range(x[-1]/DistanceIR.DIVIDER, 2**12/DistanceIR.DIVIDER):
py[i] = y[-1]
for i in range(len(py)):
if py[i] > y[0]:
py[i] = y[0]
if py[i] < y[-1]:
py[i] = y[-1]
try:
old_text = self.sample_edit.text()
for i in range(DistanceIR.NUM_VALUES):
value = int(round(py[i]*100))
self.dist.set_sampling_point(i, value)
set_value = self.dist.get_sampling_point(i)
if set_value != value:
self.sample_edit.setText("Error while writing sample point " + str(i))
self.sample_edit.setText("writing sample point, value: " + str((i, value)))
QApplication.processEvents()
self.sample_edit.setText(old_text)
except ip_connection.Error:
return
示例5: __init__
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
def __init__(self, *args):
self.seleccionado = False
self.velocity = random.randint(1,10)
QGraphicsPixmapItem.__init__(self, *args)
self.setPixmap(QPixmap("sprites/"+str(random.randint(1,45))+".png"))
self.setTransformOriginPoint(self.boundingRect().width()/2.0,self.boundingRect().height()/2.0)
self.setZValue(10)
##menu contextual
self.menu = QMenu()
self.Actions =[] #arreglo de acciones
self.Actions.append( self.menu.addAction("Seguir") )
self.Actions.append( self.menu.addAction("Editar") )
self.Actions.append( self.menu.addAction("girar clockwise") )
self.Actions.append( self.menu.addAction("girar anti-clockwise") )
self.Actions.append( self.menu.addAction("Colisiones") )
self.Actions.append( self.menu.addAction("Duplicar") )
self.Actions.append( self.menu.addAction("Eliminar") )
self.menu.triggered[QAction].connect(self.test)
##offset para el arrastre
self.offset= QPointF(0,0)
##poligono de vision
poligono = QPolygonF()
poligono.append(QPointF(-1,10))
poligono.append(QPointF(-1,20))
poligono.append(QPointF(-30,40))
poligono.append(QPointF(-40,15))
poligono.append(QPointF(-30,-10))
self.vision = QGraphicsPolygonItem(poligono,self,self.scene())
self.vision.setBrush(QColor(255, 255, 0,100))
self.vision.setPen(QColor(255, 255, 0))
示例6: item
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
def item(self):
if self.item_ is None:
num_pts = len(self.pts_)
if num_pts == 1:
# draw a point
item = QGraphicsEllipseItem(self.pts_[0][0]-self.radius_,
self.pts_[0][1]-self.radius_,
2*self.radius_,
2*self.radius_)
item.setBrush(self.qcolor)
elif num_pts == 2:
item = QGraphicsLineItem(self.pts_[0][0], self.pts_[0][1],
self.pts_[1][0], self.pts_[1][1])
else:
poly = QPolygonF()
for p in self.pts_:
poly.append(QPointF(p[0],p[1]))
item = QGraphicsPolygonItem(poly)
item.setFlags(QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemIsFocusable)
item.setPen(self.qcolor)
item.setEnabled(True)
item.setActive(True)
self.item_ = item
return self.item_
示例7: setSpinBoxDownIcon
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
def setSpinBoxDownIcon(self, opacity=0.6):
self.buttonStyle = "spinDown"
self.setToolTip("- 1")
pixmap = QPixmap(250, 250)
pixmap.fill(self.backgroundColor)
painter = QPainter()
painter.begin(pixmap)
painter.setRenderHint(QPainter.Antialiasing)
painter.setOpacity(opacity)
brush = QBrush(self.foregroundColor)
painter.setBrush(brush)
pen = QPen(self.foregroundColor)
painter.setPen(pen)
points = QPolygonF()
points.append(QPointF(125.0, 200.0))
points.append(QPointF(200.0, 70.0))
points.append(QPointF(50.0, 70.0))
painter.drawPolygon(points)
painter.end()
pixmap = pixmap.scaled(QSize(self.pixmapWidth, self.pixmapHeight),Qt.KeepAspectRatio, Qt.SmoothTransformation)
self.setPixmap(pixmap)
示例8: paintEvent
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
def paintEvent(self, event):
page_bottom = self.edit.viewport().height()
font_metrics = QFontMetrics(self.edit.document().defaultFont())
current_block = self.edit.document().findBlock(
self.edit.textCursor().position())
pattern = self.pat if self.edit.lang == "python" else self.patNotPython
painter = QPainter(self)
background = resources.CUSTOM_SCHEME.get('sidebar-background',
resources.COLOR_SCHEME['sidebar-background'])
foreground = resources.CUSTOM_SCHEME.get('sidebar-foreground',
resources.COLOR_SCHEME['sidebar-foreground'])
painter.fillRect(self.rect(), QColor(background))
block = self.edit.firstVisibleBlock()
viewport_offset = self.edit.contentOffset()
line_count = block.blockNumber()
painter.setFont(self.edit.document().defaultFont())
while block.isValid():
line_count += 1
# The top left position of the block in the document
position = self.edit.blockBoundingGeometry(block).topLeft() + \
viewport_offset
# Check if the position of the block is outside of the visible area
if position.y() > page_bottom:
break
# Set the Painter Pen depending on special lines
painter.setPen(QColor(foreground))
error = False
checkers = sorted(self._neditable.registered_checkers,
key=lambda x: x[2], reverse=True)
for items in checkers:
checker, color, _ = items
if (line_count - 1) in checker.checks:
painter.setPen(QColor(color))
font = painter.font()
font.setItalic(True)
font.setUnderline(True)
painter.setFont(font)
error = True
break
# We want the line number for the selected line to be bold.
bold = False
if block == current_block:
bold = True
font = painter.font()
font.setBold(True)
painter.setFont(font)
# Draw the line number right justified at the y position of the
# line. 3 is a magic padding number. drawText(x, y, text).
if block.isVisible():
painter.drawText(self.width() - self.foldArea -
font_metrics.width(str(line_count)) - 3,
round(position.y()) + font_metrics.ascent() +
font_metrics.descent() - 1,
str(line_count))
# Remove the bold style if it was set previously.
if bold:
font = painter.font()
font.setBold(False)
painter.setFont(font)
if error:
font = painter.font()
font.setItalic(False)
font.setUnderline(False)
painter.setFont(font)
block = block.next()
self.highest_line = line_count
#Code Folding
xofs = self.width() - self.foldArea
painter.fillRect(xofs, 0, self.foldArea, self.height(),
QColor(resources.CUSTOM_SCHEME.get('fold-area',
resources.COLOR_SCHEME['fold-area'])))
if self.foldArea != self.rightArrowIcon.width():
polygon = QPolygonF()
self.rightArrowIcon = QPixmap(self.foldArea, self.foldArea)
self.rightArrowIcon.fill(Qt.transparent)
self.downArrowIcon = QPixmap(self.foldArea, self.foldArea)
self.downArrowIcon.fill(Qt.transparent)
polygon.append(QPointF(self.foldArea * 0.4, self.foldArea * 0.25))
polygon.append(QPointF(self.foldArea * 0.4, self.foldArea * 0.75))
polygon.append(QPointF(self.foldArea * 0.8, self.foldArea * 0.5))
iconPainter = QPainter(self.rightArrowIcon)
iconPainter.setRenderHint(QPainter.Antialiasing)
iconPainter.setPen(Qt.NoPen)
iconPainter.setBrush(QColor(
resources.CUSTOM_SCHEME.get('fold-arrow',
resources.COLOR_SCHEME['fold-arrow'])))
iconPainter.drawPolygon(polygon)
polygon.clear()
#.........这里部分代码省略.........
示例9: Pointer
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
#.........这里部分代码省略.........
else:
# Start von unterer Seite
pStart = QPointF(pM1.x() + (self.fromView.size().height() / 2) * (deltaX / deltaY),
pM1.y() + self.fromView.size().height() / 2)
if deltaX / deltaY >= self.toView.size().width() / self.toView.size().height():
# Ende bei linker Seite
pEnd = QPointF(pM2.x() - self.toView.size().width() / 2,
pM2.y() - (self.toView.size().width() / 2) * (deltaY / deltaX))
else:
# Ende bei oberer Seite
pEnd = QPointF(pM2.x() - (self.toView.size().height() / 2) * (deltaX / deltaY),
pM2.y() - self.toView.size().height() / 2)
else:
# rechts oben
if deltaX / deltaY * -1 >= self.fromView.size().width() / self.fromView.size().height():
# Start von rechter Seite
pStart = QPointF(pM1.x() + self.fromView.size().width() / 2,
pM1.y() + (self.fromView.size().width() / 2) * (deltaY / deltaX))
else:
# Start von oberer Seite
pStart = QPointF(pM1.x() - (self.fromView.size().height() / 2) * (deltaX / deltaY),
pM1.y() - self.fromView.size().height() / 2)
if deltaX / deltaY * -1 >= self.toView.size().width() / self.toView.size().height():
# Ende bei linker Seite
pEnd = QPointF(pM2.x() - self.toView.size().width() / 2,
pM2.y() - (self.toView.size().width() / 2) * (deltaY / deltaX))
else:
# Ende bei unterer Seite
pEnd = QPointF(pM2.x() + (self.toView.size().height() / 2) * (deltaX / deltaY),
pM2.y() + self.toView.size().height() / 2)
else:
if deltaY >= 0:
# links unten
if deltaX / deltaY * -1 >= self.fromView.size().width() / self.fromView.size().height():
# Start von linker Seite
pStart = QPointF(pM1.x() - self.fromView.size().width() / 2,
pM1.y() - (self.fromView.size().width() / 2) * (deltaY / deltaX))
else:
# Start von unterer Seite
pStart = QPointF(pM1.x() + (self.fromView.size().height() / 2) * (deltaX / deltaY),
pM1.y() + self.fromView.size().height() / 2)
if deltaX / deltaY * -1 >= self.toView.size().width() / self.toView.size().height():
# Ende bei rechten Seite
pEnd = QPointF(pM2.x() + self.toView.size().width() / 2,
pM2.y() + (self.toView.size().width() / 2) * (deltaY / deltaX))
else:
# Ende bei oberer Seite
pEnd = QPointF(pM2.x() - (self.toView.size().height() / 2) * (deltaX / deltaY),
pM2.y() - self.toView.size().height() / 2)
else:
# links oben
if deltaX / deltaY >= self.fromView.size().width() / self.fromView.size().height():
# Start von linker Seite
pStart = QPointF(pM1.x() - self.fromView.size().width() / 2,
pM1.y() - (self.fromView.size().width() / 2) * (deltaY / deltaX))
else:
# Start von oberer Seite
pStart = QPointF(pM1.x() - (self.fromView.size().height() / 2) * (deltaX / deltaY),
pM1.y() - self.fromView.size().height() / 2)
if deltaX / deltaY >= self.toView.size().width() / self.toView.size().height():
# Ende bei rechter Seite
pEnd = QPointF(pM2.x() + self.toView.size().width() / 2,
pM2.y() + (self.toView.size().width() / 2) * (deltaY / deltaX))
else:
# Ende bei unterer Seite
pEnd = QPointF(pM2.x() + (self.toView.size().height() / 2) * (deltaX / deltaY),
pM2.y() + self.toView.size().height() / 2)
self.setLine(QLineF(pEnd, pStart))
if self.line().length() != 0:
angle = math.acos(self.line().dx() / self.line().length())
if self.line().dy() >= 0:
angle = math.pi * 2 - angle
arrowP1 = self.line().p1() + QPointF(math.sin(angle + math.pi / 2.5) * self.arrowSize, math.cos(angle + math.pi / 2.5) * self.arrowSize)
arrowP2 = self.line().p1() + QPointF(math.sin(angle + math.pi - math.pi / 2.5) * self.arrowSize, math.cos(angle + math.pi - math.pi / 2.5) * self.arrowSize)
self.arrowhead.clear()
self.arrowhead.append(self.line().p1())
self.arrowhead.append(arrowP1)
self.arrowhead.append(arrowP2)
painter.setBrush(QBrush(self.bgcolor))
painter.drawLine(self.line())
painter.drawPolygon(self.arrowhead)
def delete(self):
""" removes the pointer from the DataGraph """
self.toView.incomingPointers.remove(self)
self.fromView.outgoingPointers.remove(self)
self.distributedObjects.datagraphController.removePointer(self)
def setX(self, _):
logging.error("Ignoring setting our Pointer's x position")
def setY(self, _):
logging.error("Ignoring setting our Pointer's y position")
示例10: paintEvent
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
def paintEvent(self, event):
page_bottom = self.edit.viewport().height()
font_metrics = QFontMetrics(self.edit.document().defaultFont())
current_block = self.edit.document().findBlock(
self.edit.textCursor().position())
painter = QPainter(self)
painter.fillRect(self.rect(), Qt.lightGray)
block = self.edit.firstVisibleBlock()
viewport_offset = self.edit.contentOffset()
line_count = block.blockNumber()
painter.setFont(self.edit.document().defaultFont())
while block.isValid():
line_count += 1
# The top left position of the block in the document
position = self.edit.blockBoundingGeometry(block).topLeft() + \
viewport_offset
# Check if the position of the block is outside of the visible area
if position.y() > page_bottom:
break
# Set the Painter Pen depending on special lines
error = False
if settings.CHECK_STYLE and \
((line_count - 1) in self._pep8Lines):
painter.setPen(Qt.darkYellow)
font = painter.font()
font.setItalic(True)
font.setUnderline(True)
painter.setFont(font)
error = True
elif settings.FIND_ERRORS and \
((line_count - 1) in self._errorsLines):
painter.setPen(Qt.red)
font = painter.font()
font.setItalic(True)
font.setUnderline(True)
painter.setFont(font)
error = True
else:
painter.setPen(Qt.black)
# We want the line number for the selected line to be bold.
bold = False
if block == current_block:
bold = True
font = painter.font()
font.setBold(True)
painter.setFont(font)
# Draw the line number right justified at the y position of the
# line. 3 is a magic padding number. drawText(x, y, text).
if block.isVisible():
painter.drawText(self.width() - self.foldArea - \
font_metrics.width(str(line_count)) - 3,
round(position.y()) + font_metrics.ascent() + \
font_metrics.descent() - 1,
str(line_count))
# Remove the bold style if it was set previously.
if bold:
font = painter.font()
font.setBold(False)
painter.setFont(font)
if error:
font = painter.font()
font.setItalic(False)
font.setUnderline(False)
painter.setFont(font)
block = block.next()
self.highest_line = line_count
#Code Folding
xofs = self.width() - self.foldArea
painter.fillRect(xofs, 0, self.foldArea, self.height(),
QColor(resources.CUSTOM_SCHEME.get('fold-area',
resources.COLOR_SCHEME['fold-area'])))
if self.foldArea != self.rightArrowIcon.width():
polygon = QPolygonF()
self.rightArrowIcon = QPixmap(self.foldArea, self.foldArea)
self.rightArrowIcon.fill(Qt.transparent)
self.downArrowIcon = QPixmap(self.foldArea, self.foldArea)
self.downArrowIcon.fill(Qt.transparent)
polygon.append(QPointF(self.foldArea * 0.4, self.foldArea * 0.25))
polygon.append(QPointF(self.foldArea * 0.4, self.foldArea * 0.75))
polygon.append(QPointF(self.foldArea * 0.8, self.foldArea * 0.5))
iconPainter = QPainter(self.rightArrowIcon)
iconPainter.setRenderHint(QPainter.Antialiasing)
iconPainter.setPen(Qt.NoPen)
iconPainter.setBrush(QColor(
resources.CUSTOM_SCHEME.get('fold-arrow',
resources.COLOR_SCHEME['fold-arrow'])))
iconPainter.drawPolygon(polygon)
polygon.clear()
#.........这里部分代码省略.........
示例11: _paintLine
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
def _paintLine(self, painter, line):
polyline = QPolygonF()
for point in line:
polyline.append(self.toCanvasCoordinates(point) - self.pos())
painter.drawPolyline(polyline)
示例12: drawPolygon
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
def drawPolygon(self, Polygon):
"""Draw a polygon on the canvas"""
polygon = QPolygonF()
for point in Polygon:
polygon.append(QPointF(point[0], point[1]))
self.canvasScene.addPolygon(polygon, self.pen)
示例13: calcArrow
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
def calcArrow(srcdes_list,itemignoreZooming,iconScale):
''' if PoolItem then boundingrect should be background rather than graphicsobject '''
src = srcdes_list[0]
des = srcdes_list[1]
endtype = srcdes_list[2]
order = srcdes_list[3]
# print("Source => ", src)
compartment = src.parentItem()
srcobj = src.gobj
desobj = des.gobj
if isinstance(src,PoolItem):
srcobj = src.bg
if isinstance(des,PoolItem):
desobj = des.bg
# if itemignoreZooming:
# srcRect = self.recalcSceneBoundingRect(srcobj)
# desRect = self.recalcSceneBoundingRect(desobj)
# else:
srcRect = compartment.mapFromScene(srcobj.sceneBoundingRect()).boundingRect()
desRect = compartment.mapFromScene(desobj.sceneBoundingRect()).boundingRect()
arrow = QPolygonF()
if srcRect.intersects(desRect):
''' This is created for getting a emptyline reference \
because 'lineCord' function keeps a reference between qgraphicsline and its src and des
'''
arrow.append(QPointF(0,0))
arrow.append(QPointF(0,0))
return arrow
if (order == 0):
tmpLine = QLineF(srcRect.center().x(),
srcRect.center().y(),
desRect.center().x(),
desRect.center().y())
elif(order > 0):
dx = desRect.center().x()- srcRect.center().x()
dy = desRect.center().y()- srcRect.center().y()
dx0 = dy
dy0 = -dx
tetha1 = (math.atan2(dy0,dx0))
a0 = 4 *(math.cos(tetha1))
b0 = 4 *(math.sin(tetha1))
''' Higher order ( > 4) connectivity will not be done'''
if ((order == 3) or (order == 4)):
a0 = a0*2
b0 = b0*2
if(order %2 == 0):
srcCentera0 = srcRect.center().x()-a0
srcCenterb0 = srcRect.center().y()-b0
desCentera0 = desRect.center().x()-a0
desCenterb0 = desRect.center().y()-b0
else:
srcCentera0 = srcRect.center().x()+a0
srcCenterb0 = srcRect.center().y()+b0
desCentera0 = desRect.center().x()+a0
desCenterb0 = desRect.center().y()+b0
pointa = QPointF(srcCentera0,srcCenterb0)
pointb = QPointF(desCentera0,desCenterb0)
tmpLine = QLineF(srcCentera0,srcCenterb0,desCentera0,desCenterb0)
srcIntersects, lineSrcPoint = calcLineRectIntersection(srcRect, tmpLine)
destIntersects, lineDestPoint = calcLineRectIntersection(desRect, tmpLine)
if not srcIntersects:
print 'Source does not intersect line. Arrow points:',lineSrcPoint,src.mobj.name, src.mobj.className
if not destIntersects:
print 'Dest does not intersect line. Arrow points:', lineDestPoint, des.mobj.name, des.mobj.className
'''src and des are connected with line co-ordinates
Arrow head is drawned if the distance between src and des line is >8 just for clean appeareance
'''
if (abs(lineSrcPoint.x()-lineDestPoint.x()) > 8 or abs(lineSrcPoint.y()-lineDestPoint.y())>8):
srcAngle = tmpLine.angle()
if endtype == 'p' or endtype == 'stp':
''' Arrow head for Destination is calculated'''
arrow.append(lineSrcPoint)
arrow.append(lineDestPoint)
degree = -60
srcXArr1,srcYArr1= arrowHead(srcAngle,degree,lineDestPoint,iconScale)
arrow.append(QPointF(srcXArr1,srcYArr1))
arrow.append(QPointF(lineDestPoint.x(),lineDestPoint.y()))
degree = -120
srcXArr2,srcYArr2 = arrowHead(srcAngle,degree,lineDestPoint,iconScale)
arrow.append(QPointF(srcXArr2,srcYArr2))
arrow.append(QPointF(lineDestPoint.x(),lineDestPoint.y()))
elif endtype == 'st':
''' Arrow head for Source is calculated'''
arrow.append(lineDestPoint)
arrow.append(lineSrcPoint)
degree = 60
srcXArr2,srcYArr2 = arrowHead(srcAngle,degree,lineSrcPoint,iconScale)
arrow.append(QPointF(srcXArr2,srcYArr2))
arrow.append(QPointF(lineSrcPoint.x(),lineSrcPoint.y()))
degree = 120
srcXArr1,srcYArr1= arrowHead(srcAngle,degree,lineSrcPoint,iconScale)
arrow.append(QPointF(srcXArr1,srcYArr1))
arrow.append(QPointF(lineSrcPoint.x(),lineSrcPoint.y()))
#.........这里部分代码省略.........
示例14: paintEvent
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
width = self.width()
height = self.height()
if self.dynamic_resize:
knob_radius = self.dynamic_knob_radius
else:
knob_radius = self.knob_radius
# ensure that the center point is in the middle of a pixel to ensure
# that exact vertial and horizantal ticks are drawn exactly 1px wide
x = math.floor(width / 2.0) + 0.5
y = math.floor(height / 2.0) + 0.5
if DEBUG:
painter.fillRect(0, 0, width, height, Qt.yellow)
painter.translate(x, y)
if self.knob_style == KnobWidget.STYLE_NEEDLE:
r = min(x, y) - 1
painter.setPen(Qt.white)
painter.setBrush(Qt.white)
painter.drawEllipse(QPoint(0, 0), r, r)
angle = self.value_factor * self.total_angle - (self.total_angle / 2.0)
# draw base knob or needle spike
if self.knob_style == KnobWidget.STYLE_ROUND:
painter.setPen(self.border_color)
if self.pressed:
gradient = QRadialGradient(0, 0, knob_radius)
gradient.setColorAt(0, self.base_color_pressed)
gradient.setColorAt(0.85, self.base_color)
gradient.setColorAt(1, self.base_color)
painter.setBrush(gradient)
else:
painter.setBrush(self.base_color)
painter.drawEllipse(QPoint(0, 0), knob_radius, knob_radius)
elif self.knob_style == KnobWidget.STYLE_NEEDLE:
painter.save()
painter.rotate(angle)
painter.setPen(self.needle_color)
painter.setBrush(self.needle_color)
needle = QPolygonF()
needle.append(QPointF(self.needle_base_radius * 0.6, 0))
needle.append(QPointF(0, -knob_radius))
needle.append(QPointF(-self.needle_base_radius * 0.6, 0))
painter.drawPolygon(needle)
painter.restore()
# draw knob mark or needle base
if self.knob_style == KnobWidget.STYLE_ROUND:
painter.save()
painter.rotate(angle)
painter.setPen(QPen(self.mark_color, 2))
painter.drawLine(0, -knob_radius * 0.4, 0, -knob_radius * 0.8)
painter.restore()
elif self.knob_style == KnobWidget.STYLE_NEEDLE:
painter.setPen(self.border_color)
painter.setBrush(self.base_color)
painter.drawEllipse(QPoint(0, 0), self.needle_base_radius, self.needle_base_radius)
if self.scale_visible:
painter.setPen(Qt.black)
# draw scale arc
if self.scale_arc_visible:
painter.drawArc(-knob_radius - self.knob_to_scale,
-knob_radius - self.knob_to_scale,
knob_radius * 2 + self.knob_to_scale * 2,
knob_radius * 2 + self.knob_to_scale * 2,
(90 + self.total_angle / 2) * 16, -self.total_angle * 16)
# draw scale ticks
def value_to_angle(value):
return (float(value - self.minimum_value) / self.value_range) * self.total_angle - (self.total_angle / 2.0)
value = self.minimum_value
while value <= self.maximum_value:
angle = value_to_angle(value)
painter.save()
painter.rotate(value_to_angle(value))
painter.drawLine(0, -knob_radius - self.knob_to_scale,
0, -knob_radius - self.knob_to_scale - self.tick_size_large)
if self.scale_text_visible:
p = painter.worldTransform().map(QPoint(0, -knob_radius - \
self.knob_to_scale - \
self.tick_size_large - \
#.........这里部分代码省略.........
示例15: paintEvent
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import append [as 别名]
#.........这里部分代码省略.........
# Remove the bold style if it was set previously.
if bold:
font = painter.font()
font.setBold(False)
painter.setFont(font)
if error:
font = painter.font()
font.setItalic(False)
font.setUnderline(False)
painter.setFont(font)
block = block.next()
self.highest_line = line_count
# Code Folding
xofs = self.width() - self.foldArea
painter.fillRect(
xofs,
0,
self.foldArea,
self.height(),
QColor(resources.CUSTOM_SCHEME.get("fold-area", resources.COLOR_SCHEME["fold-area"])),
)
if self.foldArea != self.rightArrowIcon.width():
polygon = QPolygonF()
self.rightArrowIcon = QPixmap(self.foldArea, self.foldArea)
self.rightArrowIcon.fill(Qt.transparent)
self.downArrowIcon = QPixmap(self.foldArea, self.foldArea)
self.downArrowIcon.fill(Qt.transparent)
polygon.append(QPointF(self.foldArea * 0.4, self.foldArea * 0.25))
polygon.append(QPointF(self.foldArea * 0.4, self.foldArea * 0.75))
polygon.append(QPointF(self.foldArea * 0.8, self.foldArea * 0.5))
iconPainter = QPainter(self.rightArrowIcon)
iconPainter.setRenderHint(QPainter.Antialiasing)
iconPainter.setPen(Qt.NoPen)
iconPainter.setBrush(
QColor(resources.CUSTOM_SCHEME.get("fold-arrow", resources.COLOR_SCHEME["fold-arrow"]))
)
iconPainter.drawPolygon(polygon)
polygon.clear()
polygon.append(QPointF(self.foldArea * 0.25, self.foldArea * 0.4))
polygon.append(QPointF(self.foldArea * 0.75, self.foldArea * 0.4))
polygon.append(QPointF(self.foldArea * 0.5, self.foldArea * 0.8))
iconPainter = QPainter(self.downArrowIcon)
iconPainter.setRenderHint(QPainter.Antialiasing)
iconPainter.setPen(Qt.NoPen)
iconPainter.setBrush(
QColor(resources.CUSTOM_SCHEME.get("fold-arrow", resources.COLOR_SCHEME["fold-arrow"]))
)
iconPainter.drawPolygon(polygon)
if self._firstPaintEvent is True:
block = self.edit.document().findBlock(0)
else:
block = self.edit.firstVisibleBlock()
# block = self.edit.firstVisibleBlock()
line_count = block.blockNumber()
while block.isValid():
# while line_count < 5000:
line_count += 1
position = self.edit.blockBoundingGeometry(block).topLeft() + viewport_offset