本文整理汇总了Python中shape.Shape.addPoint方法的典型用法代码示例。如果您正苦于以下问题:Python Shape.addPoint方法的具体用法?Python Shape.addPoint怎么用?Python Shape.addPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shape.Shape
的用法示例。
在下文中一共展示了Shape.addPoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadLabels
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import addPoint [as 别名]
def loadLabels(self, shapes):
s = []
for label, points, line_color, fill_color in shapes:
shape = Shape(label=label)
for x, y in points:
shape.addPoint(QPointF(x, y))
shape.close()
s.append(shape)
self.addLabel(shape)
if line_color:
shape.line_color = QColor(*line_color)
if fill_color:
shape.fill_color = QColor(*fill_color)
self.canvas.loadShapes(s)
示例2: Canvas
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import addPoint [as 别名]
#.........这里部分代码省略.........
# Look for a nearby vertex to highlight. If that fails,
# check if we happen to be inside a shape.
index = shape.nearestVertex(pos, self.epsilon)
if index is not None:
if self.selectedVertex():
self.hShape.highlightClear()
self.hVertex, self.hShape = index, shape
shape.highlightVertex(index, shape.MOVE_VERTEX)
self.overrideCursor(CURSOR_POINT)
self.setToolTip("Click & drag to move point")
self.setStatusTip(self.toolTip())
self.update()
break
elif shape.containsPoint(pos):
if self.selectedVertex():
self.hShape.highlightClear()
self.hVertex, self.hShape = None, shape
self.setToolTip("Click & drag to move shape '%s'" % shape.label)
self.setStatusTip(self.toolTip())
self.overrideCursor(CURSOR_GRAB)
self.update()
break
else: # Nothing found, clear highlights, reset state.
if self.hShape:
self.hShape.highlightClear()
self.update()
self.hVertex, self.hShape = None, None
def mousePressEvent(self, ev):
pos = self.transformPos(ev.posF())
if ev.button() == Qt.LeftButton:
if self.drawing():
if self.current:
self.current.addPoint(self.line[1])
self.line[0] = self.current[-1]
if self.current.isClosed():
self.finalise()
elif not self.outOfPixmap(pos):
self.current = Shape()
self.current.addPoint(pos)
self.line.points = [pos, pos]
self.setHiding()
self.drawingPolygon.emit(True)
self.update()
else:
self.selectShapePoint(pos)
self.prevPoint = pos
self.repaint()
elif ev.button() == Qt.RightButton and self.editing():
self.selectShapePoint(pos)
self.prevPoint = pos
self.repaint()
def mouseReleaseEvent(self, ev):
if ev.button() == Qt.RightButton:
menu = self.menus[bool(self.selectedShapeCopy)]
self.restoreCursor()
if not menu.exec_(self.mapToGlobal(ev.pos())) and self.selectedShapeCopy:
# Cancel the move by deleting the shadow copy.
self.selectedShapeCopy = None
self.repaint()
elif ev.button() == Qt.LeftButton and self.selectedShape:
self.overrideCursor(CURSOR_GRAB)
def endMove(self, copy=False):
assert self.selectedShape and self.selectedShapeCopy
示例3: Canvas
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import addPoint [as 别名]
#.........这里部分代码省略.........
break
else: # Nothing found, clear highlights, reset state.
if self.hShape:
self.hShape.highlightClear()
self.update()
self.hVertex, self.hShape = None, None
self.overrideCursor(CURSOR_DEFAULT)
def mousePressEvent(self, ev):
pos = self.transformPos(ev.pos())
self._pos = pos
if ev.button() == Qt.LeftButton:
if self.drawing():
self.isLeftPressed = True
self.releaseTime = time.time()
print('press: ', self.releaseTime)
self.pQTimerSingleClicked.start(300)
else:
self.selectShapePoint(pos)
self.prevPoint = pos
self.repaint()
elif ev.button() == Qt.RightButton and self.editing():
self.selectShapePoint(pos)
self.prevPoint = pos
self.repaint()
def singleClickEvent(self):
self.pQTimerSingleClicked.stop()
pos = self._pos
if self.drawing():
if not self.current:
if not self.outOfPixmap(pos):
self.current = Shape()
self.current.addPoint(pos)
self.line.points = [pos, pos]
self.setHiding()
self.drawingPolygon.emit(True)
self.update()
else:
if not self.current.reachMaxPoints():
self.current.addPoint(pos)
self.line.points = [pos, pos]
if self.current.reachMaxPoints():
self.current._shapetype = 'Polygon'
self.finalise()
else:
self.selectShapePoint(pos)
self.prevPoint = pos
self.repaint()
def mouseDoubleClickEvent(self, ev):
# We need at least 4 points here, since the mousePress handler
# adds an extra one before this handler is called.
self.pQTimerSingleClicked.stop()
print('Double Click')
if self.current:
print('None')
else:
pos = self.transformPos(ev.pos())
self.handleDrawingPoint(pos)
#if self.canCloseShape() and len(self.current) > 3:
#self.current.popPoint()
#self.finalise()