Fix the issue about undefined pos variable
This commit is contained in:
parent
a81bc381f7
commit
5a9439be80
@ -184,27 +184,7 @@ class Canvas(QWidget):
|
|||||||
|
|
||||||
if ev.button() == Qt.LeftButton:
|
if ev.button() == Qt.LeftButton:
|
||||||
if self.drawing():
|
if self.drawing():
|
||||||
if self.current and self.current.reachMaxPoints() is False:
|
self.handleDrawing(pos)
|
||||||
initPos = self.current[0]
|
|
||||||
minX = initPos.x()
|
|
||||||
minY = initPos.y()
|
|
||||||
targetPos = self.line[1]
|
|
||||||
maxX = targetPos.x()
|
|
||||||
maxY = targetPos.y()
|
|
||||||
self.current.addPoint(QPointF(maxX, minY))
|
|
||||||
self.current.addPoint(targetPos)
|
|
||||||
self.current.addPoint(QPointF(minX, maxY))
|
|
||||||
self.current.addPoint(initPos)
|
|
||||||
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:
|
else:
|
||||||
self.selectShapePoint(pos)
|
self.selectShapePoint(pos)
|
||||||
self.prevPoint = pos
|
self.prevPoint = pos
|
||||||
@ -226,28 +206,9 @@ class Canvas(QWidget):
|
|||||||
elif ev.button() == Qt.LeftButton and self.selectedShape:
|
elif ev.button() == Qt.LeftButton and self.selectedShape:
|
||||||
self.overrideCursor(CURSOR_GRAB)
|
self.overrideCursor(CURSOR_GRAB)
|
||||||
elif ev.button() == Qt.LeftButton:
|
elif ev.button() == Qt.LeftButton:
|
||||||
|
pos = self.transformPos(ev.pos())
|
||||||
if self.drawing():
|
if self.drawing():
|
||||||
if self.current and self.current.reachMaxPoints() is False:
|
self.handleDrawing(pos)
|
||||||
initPos = self.current[0]
|
|
||||||
minX = initPos.x()
|
|
||||||
minY = initPos.y()
|
|
||||||
targetPos = self.line[1]
|
|
||||||
maxX = targetPos.x()
|
|
||||||
maxY = targetPos.y()
|
|
||||||
self.current.addPoint(QPointF(maxX, minY))
|
|
||||||
self.current.addPoint(targetPos)
|
|
||||||
self.current.addPoint(QPointF(minX, maxY))
|
|
||||||
self.current.addPoint(initPos)
|
|
||||||
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()
|
|
||||||
|
|
||||||
def endMove(self, copy=False):
|
def endMove(self, copy=False):
|
||||||
assert self.selectedShape and self.selectedShapeCopy
|
assert self.selectedShape and self.selectedShapeCopy
|
||||||
@ -273,6 +234,29 @@ class Canvas(QWidget):
|
|||||||
self.setHiding(True)
|
self.setHiding(True)
|
||||||
self.repaint()
|
self.repaint()
|
||||||
|
|
||||||
|
def handleDrawing(self, pos):
|
||||||
|
if self.current and self.current.reachMaxPoints() is False:
|
||||||
|
initPos = self.current[0]
|
||||||
|
minX = initPos.x()
|
||||||
|
minY = initPos.y()
|
||||||
|
targetPos = self.line[1]
|
||||||
|
maxX = targetPos.x()
|
||||||
|
maxY = targetPos.y()
|
||||||
|
self.current.addPoint(QPointF(maxX, minY))
|
||||||
|
self.current.addPoint(targetPos)
|
||||||
|
self.current.addPoint(QPointF(minX, maxY))
|
||||||
|
self.current.addPoint(initPos)
|
||||||
|
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()
|
||||||
|
|
||||||
def setHiding(self, enable=True):
|
def setHiding(self, enable=True):
|
||||||
self._hideBackround = self.hideBackround if enable else False
|
self._hideBackround = self.hideBackround if enable else False
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user