本文整理汇总了Python中PyQt4.QtCore.QPointF.setY方法的典型用法代码示例。如果您正苦于以下问题:Python QPointF.setY方法的具体用法?Python QPointF.setY怎么用?Python QPointF.setY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QPointF
的用法示例。
在下文中一共展示了QPointF.setY方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import setY [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)
示例2: showMoveHelper
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import setY [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)
示例3: pointAt
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import setY [as 别名]
def pointAt(self, axes, axis_values):
"""
Returns the point that best represents this graph information.
:param axes | [<XChartAxis>, ..]
axis_values | {<str> axisName, <variant> value
:return <QPointF>
"""
point = QPointF()
rect = self._buildData.get('axis_rect')
if not rect:
return point
x_range = rect.right() - rect.left()
y_range = rect.bottom() - rect.top()
for axis in axes:
if not axis.name() in axis_values:
continue
perc = axis.percentAt(axis_values[axis.name()])
if axis.orientation() == Qt.Vertical:
point.setY(rect.bottom() - perc * y_range)
else:
point.setX(rect.left() + perc * x_range)
return point
示例4: drawPipeline
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import setY [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)
示例5: GroundControlPoint
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import setY [as 别名]
class GroundControlPoint():
def __init__(self, raw=None, map=None, enabled=True):
self._raw = QPointF()
self._map = QgsPoint()
self._local = QPointF()
self._enabled = True
self.setRaw(raw)
self.setMap(map)
self.setEnabled(enabled)
def isValid(self):
return self.isRawSet() and self.isMapSet()
def isRawSet(self):
return self._raw is not None
def raw(self):
if self._raw is None:
return QPointF()
else:
return self._raw
def setRaw(self, raw):
if raw is None:
self._raw = None
else:
self._raw = raw
def setRawX(self, x):
if self._raw is None:
self._raw = QPointF()
self._raw.setX(x)
def setRawY(self, y):
if self._raw is None:
self._raw = QPointF()
self._raw.setY(y)
def isMapSet(self):
return self._raw is not None
def map(self):
if self._map is None:
return QgsPoint()
else:
return self._map
def setMap(self, map):
if map is None:
self._map = None
else:
self._map = map
def local(self):
if self._local is None:
return QPointF()
else:
return self._local
def setLocal(self, local):
if local is None:
self._local = None
else:
self._local = local
def isEnabled(self):
return self._enabled
def setEnabled(self, enabled):
self._enabled = enabled
def asCsv(self):
return utils.csv([self.map().x(), self.map().y(), self.raw().x(), self.raw().y(), int(self._enabled)])
示例6: getXover
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import setY [as 别名]
def getXover(self, phg, strandtype, fromHelix,\
fromIndex, toHelix, toIndex):
"""
Draws a line from the center of the fromBase (pA) to the
top or bottom of that same base, depending on its direction (qA),
then a quad curve to the top or bottom of the toBase (qB), and
finally to the center of the toBase (pB).
"""
# if we need to speed this up, we could keep track if pA changed?
pA = QPointF(*fromHelix.baseLocation(strandtype,\
fromIndex,\
center=True))
pA = phg.mapFromItem(fromHelix, pA)
pB = QPointF(*toHelix.baseLocation(strandtype,\
toIndex,\
center=True))
pB = phg.mapFromItem(toHelix, pB)
yA = yB = self._baseWidth / 2
if fromHelix.vhelix().directionOfStrandIs5to3(strandtype):
orientA = HandleOrient.LeftUp
yA = -yA
else:
orientA = HandleOrient.RightDown
if toHelix.vhelix().directionOfStrandIs5to3(strandtype):
orientB = HandleOrient.RightUp
yB = -yB
else:
orientB = HandleOrient.LeftDown
# Determine start and end points of quad curve
qA = QPointF(pA.x(), pA.y() + yA)
qB = QPointF(pB.x(), pB.y() + yB)
# Determine control point of quad curve
c1 = QPointF()
# case 1: same strand
if fromHelix.number() == toHelix.number():
if pA.x() < pB.x(): # draw only from left
if orientA == HandleOrient.LeftUp or \
orientA == HandleOrient.RightUp:
dx = abs(pB.x() - pA.x())
c1.setX(0.5 * (pA.x() + pB.x()))
c1.setY(pA.y() - self.yScale * dx)
# end if
# end if
# case 2: same parity
elif fromHelix.evenParity() == toHelix.evenParity():
dy = abs(pB.y() - pA.y())
c1.setX(pA.x() + self.xScale * dy)
c1.setY(0.5 * (pA.y() + pB.y()))
# case 3: default
else:
if orientA == HandleOrient.LeftUp:
c1.setX(pA.x() - self.xScale * abs(pB.y() - pA.y()))
else:
c1.setX(pA.x() + self.xScale * abs(pB.y() - pA.y()))
c1.setY(0.5 * (pA.y() + pB.y()))
# Construct painter path
painterpath = QPainterPath()
painterpath.moveTo(pA)
painterpath.lineTo(qA)
painterpath.quadTo(c1, qB)
painterpath.lineTo(pB)
return painterpath
示例7: PixmapDial
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import setY [as 别名]
class PixmapDial(QDial):
# enum CustomPaint
CUSTOM_PAINT_NULL = 0
CUSTOM_PAINT_CARLA_WET = 1
CUSTOM_PAINT_CARLA_VOL = 2
CUSTOM_PAINT_CARLA_L = 3
CUSTOM_PAINT_CARLA_R = 4
# enum Orientation
HORIZONTAL = 0
VERTICAL = 1
HOVER_MIN = 0
HOVER_MAX = 9
def __init__(self, parent):
QDial.__init__(self, parent)
self.fPixmap = QPixmap("./bitmaps/dial_01d.png")
self.fPixmapNum = "01"
self.fCustomPaint = self.CUSTOM_PAINT_NULL
self.fHovered = False
self.fHoverStep = self.HOVER_MIN
if self.fPixmap.width() > self.fPixmap.height():
self.fOrientation = self.HORIZONTAL
else:
self.fOrientation = self.VERTICAL
self.fLabel = ""
self.fLabelPos = QPointF(0.0, 0.0)
self.fLabelFont = QFont()
self.fLabelFont.setPointSize(6)
self.fLabelWidth = 0
self.fLabelHeight = 0
self.fLabelGradient = QLinearGradient(0, 0, 0, 1)
if self.palette().window().color().lightness() > 100:
# Light background
c = self.palette().dark().color()
self.fColor1 = c
self.fColor2 = QColor(c.red(), c.green(), c.blue(), 0)
self.fColorT = [self.palette().buttonText().color(), self.palette().mid().color()]
else:
# Dark background
self.fColor1 = QColor(0, 0, 0, 255)
self.fColor2 = QColor(0, 0, 0, 0)
self.fColorT = [Qt.white, Qt.darkGray]
self.updateSizes()
def getSize(self):
return self.fSize
def setCustomPaint(self, paint):
self.fCustomPaint = paint
self.fLabelPos.setY(self.fSize + self.fLabelHeight/2)
self.update()
def setEnabled(self, enabled):
if self.isEnabled() != enabled:
self.fPixmap.load("./bitmaps/dial_%s%s.png" % (self.fPixmapNum, "" if enabled else "d"))
self.updateSizes()
self.update()
QDial.setEnabled(self, enabled)
def setLabel(self, label):
self.fLabel = label
self.fLabelWidth = QFontMetrics(self.fLabelFont).width(label)
self.fLabelHeight = QFontMetrics(self.fLabelFont).height()
self.fLabelPos.setX(float(self.fSize)/2.0 - float(self.fLabelWidth)/2.0)
self.fLabelPos.setY(self.fSize + self.fLabelHeight)
self.fLabelGradient.setColorAt(0.0, self.fColor1)
self.fLabelGradient.setColorAt(0.6, self.fColor1)
self.fLabelGradient.setColorAt(1.0, self.fColor2)
self.fLabelGradient.setStart(0, float(self.fSize)/2.0)
self.fLabelGradient.setFinalStop(0, self.fSize + self.fLabelHeight + 5)
self.fLabelGradientRect = QRectF(float(self.fSize)/8.0, float(self.fSize)/2.0, float(self.fSize*6)/8.0, self.fSize+self.fLabelHeight+5)
self.update()
def setPixmap(self, pixmapId):
self.fPixmapNum = "%02i" % pixmapId
self.fPixmap.load("./bitmaps/dial_%s%s.png" % (self.fPixmapNum, "" if self.isEnabled() else "d"))
if self.fPixmap.width() > self.fPixmap.height():
self.fOrientation = self.HORIZONTAL
else:
self.fOrientation = self.VERTICAL
self.updateSizes()
self.update()
def minimumSizeHint(self):
return QSize(self.fSize, self.fSize)
#.........这里部分代码省略.........
示例8: draw
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import setY [as 别名]
#.........这里部分代码省略.........
if position == "Left":
shift_left = dist_to_bar
shift_top = None
elif position == "Right":
shift_left = -dist_to_bar-max_width
shift_top = None
elif position == "Top":
shift_left = None
shift_top = dist_to_bar
else:
shift_left = None
shift_top = -dist_to_bar-max_height
painter.save()
painter.translate(viewport.topLeft())
#print("viewport.topLeft() = {0}x{1}".format(viewport.left(), viewport.top()))
painter.setBrush(gr)
line_pen = QPen(line_color)
line_pen.setWidth(line_thickness)
painter.setPen(line_pen)
painter.drawRect(scale_rect)
bounding_rect |= scale_rect
#print("Scale rect: +{0}+{1}x{2}x{3}".format(scale_rect.left(),
#scale_rect.top(), scale_rect.width(), scale_rect.height()))
painter.setFont(font)
painter.setPen(text_color)
for ts,t in zip(ticks_str, ticks):
r = metric.boundingRect(ts)
pos = start_pos+shift_pos*(t-value_range[0])
if shift_left is None:
pos.setX( pos.x() - r.width()/2 )
else:
pos.setX( pos.x() + shift_left )
if shift_top is None:
pos.setY( pos.y() - r.height()/2)
else:
pos.setY( pos.y() + shift_top )
r.moveTo(pos)
real_rect = painter.drawText(r, Qt.TextDontClip | Qt.AlignVCenter | Qt.AlignHCenter, ts)
bounding_rect |= real_rect
if ticks_extra is not None or self.unit:
unit = self.unit
exp_width = width = space_width = 0
exp_txt = ""
r = exp_r = unit_r = QRectF()
exp_font = None
if ticks_extra is not None:
exp_txt = u"×10"
r = metric.boundingRect(exp_txt)
exp_font = QFont(font)
exp_size = self.exp_size
if exp_font.pixelSize() != -1:
exp_font.setPixelSize(exp_size*exp_font.pixelSize())
else:
exp_font.setPointSizeF(exp_size*exp_font.pointSizeF())
exp_metric = QFontMetricsF(exp_font, painter.device())
exp_r = exp_metric.boundingRect(ticks_extra)
if unit:
unit_r = metric.boundingRect(unit)
total_width = r.width()+exp_r.width()+unit_r.width()
total_height = max(r.height(),unit_r.height())+exp_r.height()/2
pos = scale_rect.topRight()
log_debug("top right of scale bar = (%g,%g)" % (pos.x(), pos.y()))
log_debug("Size of image = (%d,%d)" % (w,h))
log_debug("Size of text = (%g,%g)" % (total_width, total_height))
if position == "Bottom":
pos.setY(pos.y() + scale_rect.height() + dist_to_bar)
示例9: getRectBetweenTwoPoints
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import setY [as 别名]
def getRectBetweenTwoPoints(self, firstP, secondP, firstCorner=CornerType.UNDEFINED, secondCorner=CornerType.UNDEFINED):
halfthick = 0.5 * self.CONNECTION_THICKNESS * self.zoomFactor()
cornerRoundness = halfthick ** 0.5
offset = 2*halfthick #* (cornerRoundness + 1) - 1 # -1 prevents one pixel gaps which sometimes appear at corners.
direction = self.getPointToPointDirection(firstP, secondP)
firstOffset = 0
if self.cornerIsDefined(firstCorner):
firstOffset = offset
secondOffset = 0
if self.cornerIsDefined(secondCorner):
secondOffset = offset
topLeft = QPointF()
bottomRight = QPointF()
if direction == self.ConnectionDirection.LEFT:
# horizontal, negative
topLeft.setX(secondP.x() + secondOffset)
topLeft.setY(secondP.y() - halfthick)
bottomRight.setX(firstP.x() - firstOffset + 1)
bottomRight.setY(firstP.y() + halfthick)
elif direction == self.ConnectionDirection.RIGHT:
# horizontal, positive
topLeft.setX(firstP.x() + firstOffset)
topLeft.setY(firstP.y() - halfthick)
bottomRight.setX(secondP.x() - secondOffset + 1)
bottomRight.setY(secondP.y() + halfthick)
elif direction == self.ConnectionDirection.UP:
# vrtical, negative
topLeft.setX(secondP.x() - halfthick)
topLeft.setY(secondP.y() + secondOffset)
bottomRight.setX(firstP.x() + halfthick)
bottomRight.setY(firstP.y() - firstOffset + 1)
elif direction == self.ConnectionDirection.DOWN:
# vertical, positive
topLeft.setX(firstP.x() - halfthick)
topLeft.setY(firstP.y() + firstOffset)
bottomRight.setX(secondP.x() + halfthick)
bottomRight.setY(secondP.y() - secondOffset + 1)
else:
return QRectF(topLeft, bottomRight)
return QRectF(topLeft, bottomRight)
示例10: betweenTwoPoints
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import setY [as 别名]
def betweenTwoPoints(self, point, first, second):
""" Checks whether 'point' lies between 'first' and 'second'.
This function can currently (08-11-15) only deal with horizontal and vertical distances.
"""
halfthick = 0.5 * self.CONNECTION_THICKNESS * self.zoomFactor()
direction = self.getPointToPointDirection(first, second)
topLeft = QPointF()
bottomRight = QPointF()
if direction == self.ConnectionDirection.LEFT:
# horizontal, negative
topLeft.setX(second.x())
topLeft.setY(second.y() - halfthick)
bottomRight.setX(first.x())
bottomRight.setY(first.y() + halfthick)
elif direction == self.ConnectionDirection.RIGHT:
# horizontal, positive
topLeft.setX(first.x())
topLeft.setY(first.y() - halfthick)
bottomRight.setX(second.x())
bottomRight.setY(second.y() + halfthick)
elif direction == self.ConnectionDirection.UP:
# vertical, negative
topLeft.setX(second.x() - halfthick)
topLeft.setY(second.y())
bottomRight.setX(first.x() + halfthick)
bottomRight.setY(first.y())
elif direction == self.ConnectionDirection.UP:
# vertical, positive
topLeft.setX(first.x() - halfthick)
topLeft.setY(first.y())
bottomRight.setX(second.x() + halfthick)
bottomRight.setY(second.y())
else:
return False
rect = QRectF(topLeft, bottomRight)
return rect.contains(QPointF(point))
示例11: PixmapDial
# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import setY [as 别名]
class PixmapDial(QDial):
HORIZONTAL = 0
VERTICAL = 1
CUSTOM_PAINT_CARLA_WET = 1
CUSTOM_PAINT_CARLA_VOL = 2
CUSTOM_PAINT_CARLA_L = 3
CUSTOM_PAINT_CARLA_R = 4
HOVER_MIN = 0
HOVER_MAX = 9
def __init__(self, parent):
QDial.__init__(self, parent)
self.m_pixmap = QPixmap(":/bitmaps/dial_01d.png")
self.m_pixmap_n_str = "01"
self.m_custom_paint = 0
self.m_hovered = False
self.m_hover_step = self.HOVER_MIN
if self.m_pixmap.width() > self.m_pixmap.height():
self.m_orientation = self.HORIZONTAL
else:
self.m_orientation = self.VERTICAL
self.m_label = ""
self.m_label_pos = QPointF(0.0, 0.0)
self.m_label_width = 0
self.m_label_height = 0
self.m_label_gradient = QLinearGradient(0, 0, 0, 1)
if self.palette().window().color().lightness() > 100:
# Light background
self.m_color1 = QColor(100, 100, 100, 255)
self.m_color2 = QColor(0, 0, 0, 0)
self.m_colorT = [self.palette().text().color(), self.palette().mid().color()]
else:
# Dark background
self.m_color1 = QColor(0, 0, 0, 255)
self.m_color2 = QColor(0, 0, 0, 0)
self.m_colorT = [Qt.white, Qt.darkGray]
self.updateSizes()
def getSize(self):
return self.p_size
def setCustomPaint(self, paint):
self.m_custom_paint = paint
self.update()
def setEnabled(self, enabled):
if self.isEnabled() != enabled:
self.m_pixmap.load(":/bitmaps/dial_%s%s.png" % (self.m_pixmap_n_str, "" if enabled else "d"))
self.updateSizes()
self.update()
QDial.setEnabled(self, enabled)
def setLabel(self, label):
self.m_label = label
self.m_label_width = QFontMetrics(self.font()).width(label)
self.m_label_height = QFontMetrics(self.font()).height()
self.m_label_pos.setX((self.p_size / 2) - (self.m_label_width / 2))
self.m_label_pos.setY(self.p_size + self.m_label_height)
self.m_label_gradient.setColorAt(0.0, self.m_color1)
self.m_label_gradient.setColorAt(0.6, self.m_color1)
self.m_label_gradient.setColorAt(1.0, self.m_color2)
self.m_label_gradient.setStart(0, self.p_size / 2)
self.m_label_gradient.setFinalStop(0, self.p_size + self.m_label_height + 5)
self.m_label_gradient_rect = QRectF(self.p_size * 1 / 8, self.p_size / 2, self.p_size * 6 / 8, self.p_size + self.m_label_height + 5)
self.update()
def setPixmap(self, pixmap_id):
if pixmap_id > 10:
self.m_pixmap_n_str = str(pixmap_id)
else:
self.m_pixmap_n_str = "0%i" % pixmap_id
self.m_pixmap.load(":/bitmaps/dial_%s%s.png" % (self.m_pixmap_n_str, "" if self.isEnabled() else "d"))
if self.m_pixmap.width() > self.m_pixmap.height():
self.m_orientation = self.HORIZONTAL
else:
self.m_orientation = self.VERTICAL
self.updateSizes()
self.update()
def minimumSizeHint(self):
return QSize(self.p_size, self.p_size)
def sizeHint(self):
return QSize(self.p_size, self.p_size)
#.........这里部分代码省略.........