Skip to content

Commit

Permalink
Fix both unHighlight and addPointToEdge with self.prevXXX
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Feb 16, 2020
1 parent b3a672b commit 45d1d04
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions labelme/widgets/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ def __init__(self, *args, **kwargs):
self._hideBackround = False
self.hideBackround = False
self.hShape = None
self.prevhShape = None
self.hVertex = None
self.prevhVertex = None
self.hEdge = None
self.prevhEdge = None
self.movingShape = False
self._painter = QtGui.QPainter()
self._cursor = CURSOR_DEFAULT
Expand Down Expand Up @@ -151,6 +154,10 @@ def unHighlight(self):
if self.hShape:
self.hShape.highlightClear()
self.update()
self.prevhShape = self.hShape
self.prevhVertex = self.hVertex
self.prevhEdge = self.hEdge
self.hShape = self.hVertex = self.hEdge = None

def selectedVertex(self):
return self.hVertex is not None
Expand Down Expand Up @@ -267,13 +274,12 @@ def mouseMoveEvent(self, ev):
break
else: # Nothing found, clear highlights, reset state.
self.unHighlight()
self.hVertex, self.hShape, self.hEdge = None, None, None
self.edgeSelected.emit(self.hEdge is not None, self.hShape)
self.vertexSelected.emit(self.hVertex is not None)

def addPointToEdge(self):
shape = self.hShape
index = self.hEdge
shape = self.prevhShape
index = self.prevhEdge
point = self.prevMovePoint
if shape is None or index is None or point is None:
return
Expand All @@ -285,11 +291,10 @@ def addPointToEdge(self):
self.movingShape = True

def removeSelectedPoint(self):
if (self.hShape is None and
self.prevMovePoint is None):
return
shape = self.hShape
shape = self.prevhShape
point = self.prevMovePoint
if shape is None or point is None:
return
index = shape.nearestVertex(point, self.epsilon)
shape.removePoint(index)
# shape.highlightVertex(index, shape.MOVE_VERTEX)
Expand Down

0 comments on commit 45d1d04

Please sign in to comment.