Skip to content

Commit

Permalink
Merge pull request HumanSignal#151 from jaewchoi/create
Browse files Browse the repository at this point in the history
Fix a bug: creating a box with one point
  • Loading branch information
tzutalin authored Aug 25, 2017
2 parents 295e0e9 + 835af44 commit 79f7361
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 7 additions & 4 deletions libs/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,7 @@ def handleDrawing(self, pos):
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()
self.finalise()
elif not self.outOfPixmap(pos):
self.current = Shape()
self.current.addPoint(pos)
Expand Down Expand Up @@ -447,6 +444,12 @@ def outOfPixmap(self, p):

def finalise(self):
assert self.current
if self.current.points[0] == self.current.points[-1]:
self.current = None
self.drawingPolygon.emit(False)
self.update()
return

self.current.close()
self.shapes.append(self.current)
self.current = None
Expand Down
4 changes: 1 addition & 3 deletions libs/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ def reachMaxPoints(self):
return False

def addPoint(self, point):
if self.points and point == self.points[0]:
self.close()
else:
if not self.reachMaxPoints():
self.points.append(point)

def popPoint(self):
Expand Down

0 comments on commit 79f7361

Please sign in to comment.