本文整理汇总了Python中PyQt4.QtCore.QPointF.y方法的典型用法代码示例。如果您正苦于以下问题:Python QPointF.y方法的具体用法?Python QPointF.y怎么用?Python QPointF.y使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QPointF
的用法示例。
在下文中一共展示了QPointF.y方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paint
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
def paint(self, painter, option, widget=None):
pt = QPointF(-self.WIDTH / 2, -self.HEIGHT / 2) + self.position
rect = QRectF(pt.x(), pt.y(), self.WIDTH, self.HEIGHT)
if self.isIn:
painter.setPen(QPen(Qt.transparent, 1))
painter.setBrush(QBrush(Qt.lightGray, Qt.SolidPattern))
else:
painter.setPen(QPen(Qt.transparent, 1))
painter.setBrush(QBrush(Qt.transparent, Qt.SolidPattern))
painter.drawRect(rect)
painter.drawPixmap(pt.x(), pt.y(), self.pixmap)
示例2: drawPipeline
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
def drawPipeline(self, qp):
"""Called by paintEvent, it draws figures and link between them.
Parameters
----------
qp : QtGui.QPainter
Performs low-level painting
"""
# If self.levels is empty, indeed, it does not make sense to draw
# something.
if self.levels is None:
return
# define Rep position because they change whan resising main windows
width = self.size().width()
height = self.size().height()
if len(self.levels) != 0:
total_height = (len(self.levels) - 1) * (
STAGE_SIZE_Y + ROUTER_SIZE_Y)
self.zoom = height / total_height
else:
self.zoom = 1
# center figures on screen
last_point = QPointF(width / 2, -GAP_Y / 2 * self.zoom)
for level in self.levels:
total_x = len(level) * STAGE_SIZE_X * self.zoom + (
len(level) - 1 * STAGE_GAP_X * self.zoom)
last_point.setX(width / 2 - total_x / 2)
last_point.setY(last_point.y() + GAP_Y * self.zoom)
for figure in level:
figure.setCenter(QPointF(last_point))
last_point.setX(last_point.x() + STAGE_GAP_X * self.zoom)
# Start to paint
size = self.size()
lines = list()
last_level_pt = list()
for level in self.levels:
current_level_pt = list()
for figure in level:
figure.draw(qp, zoom=self.zoom)
connexion_pt = QPointF(figure.center.x(), figure.center.y()
- figure.size_y / 2 * self.zoom)
current_level_pt.append(QPointF(connexion_pt.x(),
connexion_pt.y() + figure.size_y * self.zoom))
# Link to previous level connexion point(s)
for point in last_level_pt:
lines.append(QLineF(point, connexion_pt))
# Keep points for next level
last_level_pt = list(current_level_pt)
for line in lines:
qp.setPen(QtGui.QPen(self.blue_cta, 1, QtCore.Qt.SolidLine))
qp.drawLine(line)
示例3: __init__
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
def __init__(self, element, model):
super(ModelerGraphicItem, self).__init__(None, None)
self.model = model
self.element = element
if isinstance(element, ModelerParameter):
icon = QIcon(os.path.join(pluginPath, 'images', 'input.png'))
self.pixmap = icon.pixmap(20, 20, state=QIcon.On)
self.text = element.param.description
elif isinstance(element, ModelerOutput):
# Output name
icon = QIcon(os.path.join(pluginPath, 'images', 'output.png'))
self.pixmap = icon.pixmap(20, 20, state=QIcon.On)
self.text = element.description
else:
self.text = element.description
self.pixmap = element.algorithm.getIcon().pixmap(15, 15)
self.arrows = []
self.setFlag(QGraphicsItem.ItemIsMovable, True)
self.setFlag(QGraphicsItem.ItemIsSelectable, True)
self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True)
self.setZValue(1000)
if not isinstance(element, ModelerOutput):
icon = QIcon(os.path.join(pluginPath, 'images', 'edit.png'))
pt = QPointF(ModelerGraphicItem.BOX_WIDTH / 2
- FlatButtonGraphicItem.WIDTH / 2,
ModelerGraphicItem.BOX_HEIGHT / 2
- FlatButtonGraphicItem.HEIGHT / 2 + 1)
self.editButton = FlatButtonGraphicItem(icon, pt, self.editElement)
self.editButton.setParentItem(self)
icon = QIcon(os.path.join(pluginPath, 'images', 'delete.png'))
pt = QPointF(ModelerGraphicItem.BOX_WIDTH / 2
- FlatButtonGraphicItem.WIDTH / 2,
- ModelerGraphicItem.BOX_HEIGHT / 2
+ FlatButtonGraphicItem.HEIGHT / 2 + 1)
self.deleteButton = FlatButtonGraphicItem(icon, pt,
self.removeElement)
self.deleteButton.setParentItem(self)
if isinstance(element, Algorithm):
alg = element.algorithm
if alg.parameters:
pt = self.getLinkPointForParameter(-1)
pt = QPointF(0, pt.y() + 2)
self.inButton = FoldButtonGraphicItem(pt, self.foldInput, self.element.paramsFolded)
self.inButton.setParentItem(self)
if alg.outputs:
pt = self.getLinkPointForOutput(-1)
pt = QPointF(0, pt.y() + 2)
self.outButton = FoldButtonGraphicItem(pt, self.foldOutput, self.element.outputsFolded)
self.outButton.setParentItem(self)
示例4: draw
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
def draw(self, qpainter, zoom=1):
"""Draw this figure
Parameters
----------
qpainter: PySide.QtGui.QPainter
"""
size_x = self.size_x * zoom
size_y = self.size_y * zoom
pensize = 3
qpainter.setPen(
QtGui.QPen(PipelineDrawer.blue_cta, pensize, QtCore.Qt.SolidLine))
text_pos = QPointF(self.center)
text_pos.setX(text_pos.x() - size_x / 2 + 2)
text_pos.setY(text_pos.y() + pensize)
qpainter.drawText(text_pos, str(self.nb_job_done))
pt = QPointF(self.center)
pt.setX(5)
pos = self.name.find("$$thread_number$$")
if pos != -1:
name = self.name[0:pos]
else:
name = self.name
qpainter.drawText(pt, name)
if self.running == True:
qpainter.setPen(
QtGui.QPen(PipelineDrawer.mygreen, 3, QtCore.Qt.SolidLine))
else:
qpainter.setPen(
QtGui.QPen(PipelineDrawer.blue_cta, 3, QtCore.Qt.SolidLine))
x1 = self.center.x() - (size_x / 2)
y1 = self.center.y() - (size_y / 2)
qpainter.drawRoundedRect(x1, y1, size_x, size_y, 12.0, 12.0)
示例5: showMoveHelper
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
def showMoveHelper(self, visible=True):
"""show help text In empty HandBoards"""
if visible:
if not self.__moveHelper:
splitter = QGraphicsRectItem(self)
hbCenter = self.rect().center()
splitter.setRect(hbCenter.x() * 0.5, hbCenter.y(), hbCenter.x() * 1, 1)
helpItems = [splitter]
for name, yFactor in [(m18n('Move Exposed Tiles Here'), 0.5),
(m18n('Move Concealed Tiles Here'), 1.5)]:
helper = QGraphicsSimpleTextItem(name, self)
helper.setScale(3)
nameRect = QRectF()
nameRect.setSize(helper.mapToParent(helper.boundingRect()).boundingRect().size())
center = QPointF(hbCenter)
center.setY(center.y() * yFactor)
helper.setPos(center - nameRect.center())
if self.sceneRotation() == 180:
rotateCenter(helper, 180)
helpItems.append(helper)
self.__moveHelper = self.scene().createItemGroup(helpItems)
self.__moveHelper.setVisible(True)
else:
if self.__moveHelper:
self.__moveHelper.setVisible(False)
示例6: paint
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
def paint(self, painter, option, widget=None):
myPen = self.pen()
myPen.setColor(self.myColor)
painter.setPen(myPen)
painter.setBrush(self.myColor)
controlPoints = []
endPt = self.endItem.getLinkPointForParameter(self.endIndex)
startPt = self.startItem.getLinkPointForOutput(self.startIndex)
if isinstance(self.startItem.element, Algorithm):
if self.startIndex != -1:
controlPoints.append(self.startItem.pos() + startPt)
controlPoints.append(self.startItem.pos() + startPt
+ QPointF(ModelerGraphicItem.BOX_WIDTH / 2, 0))
controlPoints.append(self.endItem.pos() + endPt
- QPointF(ModelerGraphicItem.BOX_WIDTH / 2, 0))
controlPoints.append(self.endItem.pos() + endPt)
pt = QPointF(self.startItem.pos() + startPt
+ QPointF(-3, -3))
painter.drawEllipse(pt.x(), pt.y(), 6, 6)
pt = QPointF(self.endItem.pos() + endPt +
QPointF(-3, -3))
painter.drawEllipse(pt.x(), pt.y(), 6, 6)
else:
# Case where there is a dependency on an algorithm not
# on an output
controlPoints.append(self.startItem.pos() + startPt)
controlPoints.append(self.startItem.pos() + startPt
+ QPointF(ModelerGraphicItem.BOX_WIDTH / 2, 0))
controlPoints.append(self.endItem.pos() + endPt
- QPointF(ModelerGraphicItem.BOX_WIDTH / 2, 0))
controlPoints.append(self.endItem.pos() + endPt)
else:
controlPoints.append(self.startItem.pos())
controlPoints.append(self.startItem.pos()
+ QPointF(ModelerGraphicItem.BOX_WIDTH / 2, 0))
controlPoints.append(self.endItem.pos() + endPt
- QPointF(ModelerGraphicItem.BOX_WIDTH / 2, 0))
controlPoints.append(self.endItem.pos() + endPt)
pt = QPointF(self.endItem.pos() + endPt + QPointF(-3, -3))
painter.drawEllipse(pt.x(), pt.y(), 6, 6)
path = QPainterPath()
path.moveTo(controlPoints[0])
path.cubicTo(*controlPoints[1:])
painter.strokePath(path, painter.pen())
self.setPath(path)
示例7: foldInput
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
def foldInput(self, folded):
self.element.paramsFolded = folded
self.prepareGeometryChange()
if self.element.algorithm.outputs:
pt = self.getLinkPointForOutput(-1)
pt = QPointF(0, pt.y())
self.outButton.position = pt
self.update()
示例8: distToLine
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
def distToLine(pt, p1, p2):
"""
Compute the distance from the point `pt` to the line segment [p1,p2]
"""
u = p2-p1
lu = u.x()*u.x() + u.y()*u.y()
pmax = QPointF(max(abs(p1.x()), abs(p2.x())), max(abs(p1.y()), abs(p2.y())))
if lu / (pmax.x()*pmax.x() + pmax.y()*pmax.y()) < 1e-10:
diff = u - p1
return sqrt(diff.x()*diff.x() + diff.y()*diff.y())
dp = pt-p1
proj = (u.x()*dp.x() + u.y()*dp.y())
if proj >= 0 and proj <= lu:
return abs(dp.x()*u.y() - u.x()*dp.y())/sqrt(lu)
elif proj < 0:
return dp.x()*dp.x() + dp.y()*dp.y()
else:
return dist(pt, p2)
示例9: paint
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
def paint(self, painter, option, widget):
arc_rect = 10
connector_length = 5
painter.setPen(self.pen)
path = QtGui.QPainterPath()
if self.source.x() == self.dest.x():
path.moveTo(self.source.x(), self.source.y())
path.lineTo(self.dest.x(), self.dest.y())
painter.drawPath(path)
else:
#Define points starting from source
point1 = QPointF(self.source.x(), self.source.y())
point2 = QPointF(point1.x(), point1.y() - connector_length)
point3 = QPointF(point2.x() + arc_rect, point2.y() - arc_rect)
#Define points starting from dest
point4 = QPointF(self.dest.x(), self.dest.y())
point5 = QPointF(point4.x(),point3.y() - arc_rect)
point6 = QPointF(point5.x() - arc_rect, point5.y() + arc_rect)
start_angle_arc1 = 180
span_angle_arc1 = 90
start_angle_arc2 = 90
span_angle_arc2 = -90
# If the dest is at the left of the source, then we
# need to reverse some values
if self.source.x() > self.dest.x():
point5 = QPointF(point4.x(), point4.y() + connector_length)
point6 = QPointF(point5.x() + arc_rect, point5.y() + arc_rect)
point3 = QPointF(self.source.x() - arc_rect, point6.y())
point2 = QPointF(self.source.x(), point3.y() + arc_rect)
span_angle_arc1 = 90
path.moveTo(point1)
path.lineTo(point2)
path.arcTo(QRectF(point2, point3),
start_angle_arc1, span_angle_arc1)
path.lineTo(point6)
path.arcTo(QRectF(point6, point5),
start_angle_arc2, span_angle_arc2)
path.lineTo(point4)
painter.drawPath(path)
示例10: movePoints
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
def movePoints(self, image_name, pt_ids):
if image_name == self.image_name:
data = self.current_data
dm = self.data_manager
points = self.points
cells = self.cells
for pt_id in pt_ids:
pos = data[pt_id]
pos = QPointF(pos.x() / self.min_scale, pos.y() / self.min_scale)
points[pt_id].setPos(pos)
for cid in dm.cell_points[pt_id]:
cell = cells.get(cid, None)
if cell is not None and cell.isVisible():
cell.setGeometry()
示例11: updateSmooth
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
def updateSmooth(self):
if self.m_smooth:
if self.m_cursor.x() != self.m_smooth_x or self.m_cursor.y() != self.m_smooth_y:
if abs(self.m_cursor.x() - self.m_smooth_x) <= 0.001:
self.m_smooth_x = self.m_cursor.x()
return
elif abs(self.m_cursor.y() - self.m_smooth_y) <= 0.001:
self.m_smooth_y = self.m_cursor.y()
return
new_x = (self.m_smooth_x + self.m_cursor.x() * 3) / 4
new_y = (self.m_smooth_y + self.m_cursor.y() * 3) / 4
pos = QPointF(new_x, new_y)
self.m_cursor.setPos(pos)
self.m_lineH.setY(pos.y())
self.m_lineV.setX(pos.x())
xp = pos.x() / (self.p_size.x() + self.p_size.width())
yp = pos.y() / (self.p_size.y() + self.p_size.height())
self.sendMIDI(xp, yp)
self.emit(SIGNAL("cursorMoved(double, double)"), xp, yp)
示例12: path_link_disabled
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
def path_link_disabled(basepath):
"""
Return a QPainterPath 'styled' to indicate a 'disabled' link.
A disabled link is displayed with a single disconnection symbol in the
middle (--||--)
Parameters
----------
basepath : QPainterPath
The base path (a simple curve spine).
Returns
-------
path : QPainterPath
A 'styled' link path
"""
segmentlen = basepath.length()
px = 5
if segmentlen < 10:
return QPainterPath(basepath)
t = (px / 2) / segmentlen
p1, _ = qpainterpath_simple_split(basepath, 0.50 - t)
_, p2 = qpainterpath_simple_split(basepath, 0.50 + t)
angle = -basepath.angleAtPercent(0.5) + 90
angler = math.radians(angle)
normal = QPointF(math.cos(angler), math.sin(angler))
end1 = p1.currentPosition()
start2 = QPointF(p2.elementAt(0).x, p2.elementAt(0).y)
p1.moveTo(start2.x(), start2.y())
p1.addPath(p2)
def QPainterPath_addLine(path, line):
path.moveTo(line.p1())
path.lineTo(line.p2())
QPainterPath_addLine(p1, QLineF(end1 - normal * 3, end1 + normal * 3))
QPainterPath_addLine(p1, QLineF(start2 - normal * 3, start2 + normal * 3))
return p1
示例13: mouseReleaseEvent
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
def mouseReleaseEvent(self, event):
position = QPointF(event.scenePos())
self.clicked.emit((position.x(), position.y()))
示例14: BrushingModel
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
class BrushingModel(QObject):
brushSizeChanged = pyqtSignal(int)
brushColorChanged = pyqtSignal(QColor)
brushStrokeAvailable = pyqtSignal(QPointF, object)
drawnNumberChanged = pyqtSignal(int)
minBrushSize = 1
maxBrushSize = 61
defaultBrushSize = 3
defaultDrawnNumber = 1
defaultColor = Qt.white
erasingColor = Qt.black
erasingNumber = 100
def __init__(self, parent=None):
QObject.__init__(self, parent=parent)
self.sliceRect = None
self.bb = QRect() #bounding box enclosing the drawing
self.brushSize = self.defaultBrushSize
self.drawColor = self.defaultColor
self._temp_color = None
self._temp_number = None
self.drawnNumber = self.defaultDrawnNumber
self.pos = None
self.erasing = False
self._hasMoved = False
self.drawOnto = None
#an empty scene, where we add all drawn line segments
#a QGraphicsLineItem, and which we can use to then
#render to an image
self.scene = QGraphicsScene()
def toggleErase(self):
self.erasing = not(self.erasing)
if self.erasing:
self.setErasing()
else:
self.disableErasing()
def setErasing(self):
self.erasing = True
self._temp_color = self.drawColor
self._temp_number = self.drawnNumber
self.setBrushColor(self.erasingColor)
self.brushColorChanged.emit(self.erasingColor)
self.setDrawnNumber(self.erasingNumber)
def disableErasing(self):
self.erasing = False
self.setBrushColor(self._temp_color)
self.brushColorChanged.emit(self.drawColor)
self.setDrawnNumber(self._temp_number)
def setBrushSize(self, size):
self.brushSize = size
self.brushSizeChanged.emit(self.brushSize)
def setDrawnNumber(self, num):
self.drawnNumber = num
self.drawnNumberChanged.emit(num)
def getBrushSize(self):
return self.brushSize
def brushSmaller(self):
b = self.brushSize
if b > self.minBrushSize:
self.setBrushSize(b-1)
def brushBigger(self):
b = self.brushSize
if self.brushSize < self.maxBrushSize:
self.setBrushSize(b+1)
def setBrushColor(self, color):
self.drawColor = color
self.brushColorChanged.emit(self.drawColor)
def beginDrawing(self, pos, sliceRect):
'''
pos -- QPointF-like
'''
self.sliceRect = sliceRect
self.scene.clear()
self.bb = QRect()
self.pos = QPointF(pos.x(), pos.y())
self._hasMoved = False
def endDrawing(self, pos):
has_moved = self._hasMoved # _hasMoved will change after calling moveTo
if has_moved:
self.moveTo(pos)
else:
assert(self.pos == pos)
self.moveTo(QPointF(pos.x()+0.0001, pos.y()+0.0001)) # move a little
#.........这里部分代码省略.........
示例15: TracepointWaveScene
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import y [as 别名]
class TracepointWaveScene(QtGui.QGraphicsScene):
'''QGraphicsView for wave'''
def __init__(self, type_, values, duration):
'''CTOR
@param type_: string, must be in supported types
@param values: list of values of variable
@param duration: integer, holds stepwidth of wave
'''
QtGui.QGraphicsScene.__init__(self)
self.supportedTypes = ["bool", "int", "float", "double"]
self.vSpace = 10
self.values = []
self.curPos = QPointF(0, 2)
self.type = type_
self.width = duration
self.valFont = QtGui.QFont("Arial", 7)
self.valFontColor = QtGui.QColor()
self.valFontColor.setGreen(100)
self.setSceneRect(0, 0, self.width, 15)
for v in values:
self.appendValue(v, duration)
def getSupportedTypes(self):
''' Returns supported waveform types
@return list[string]
'''
return self.supportedTypes
def getType(self):
''' @return string identifying type of TracepointWaveScene'''
return self.type
def appendValue(self, value, duration):
''' Append value to wave
@param value: value to add
@param duration: integer, defines duration(length) of value in wave
'''
drawEdge = len(self.values) > 0 and self.values[len(self.values) - 1] != value
if drawEdge:
self.__drawEdge()
self.values.append(value)
self.__drawLine(value, duration, drawEdge or len(self.values) == 1)
self.setSceneRect(0, 0, self.width, 15)
def __drawEdge(self):
''' Draws an edge depending on the type of the waveform. '''
if self.type == "bool":
self.addItem(QtGui.QGraphicsLineItem(QLineF(self.curPos, QPointF(self.curPos.x(), self.curPos.y() + self.vSpace))))
elif self.type in self.supportedTypes:
self.addItem(QtGui.QGraphicsLineItem(QLineF(self.curPos, QPointF(self.curPos.x() + 2, self.curPos.y() + self.vSpace))))
self.addItem(QtGui.QGraphicsLineItem(QLineF(QPointF(self.curPos.x() + 2, self.curPos.y()), QPointF(self.curPos.x(), self.curPos.y() + self.vSpace))))
def __drawLine(self, value, duration, printvalue=True):
''' Draws a line depending on the type of the waveform.
@param value: value to add to wave
@param duration: integer, defines duration(length) of value in wave
@param printvalue: bool, add values to waveform (for value-type waveforms only)
'''
self.width = self.width + duration
tmp = self.curPos
self.curPos = QPointF(self.curPos.x() + duration, self.curPos.y())
if self.type == "bool":
if value:
self.addItem(QtGui.QGraphicsLineItem(QLineF(tmp, self.curPos)))
else:
self.addItem(QtGui.QGraphicsLineItem(tmp.x(), tmp.y() + self.vSpace, self.curPos.x(), self.curPos.y() + self.vSpace))
elif self.type in self.supportedTypes:
if printvalue:
text = QtGui.QGraphicsTextItem(str(value))
text.setFont(self.valFont)
text.setDefaultTextColor(self.valFontColor)
text.setPos(QPointF(tmp.x() + 4, tmp.y() - 5))
self.addItem(text)
self.addItem(QtGui.QGraphicsLineItem(QLineF(tmp, self.curPos)))
self.addItem(QtGui.QGraphicsLineItem(tmp.x(), tmp.y() + self.vSpace, self.curPos.x(), self.curPos.y() + self.vSpace))