MiRCARTToolLine.py: correctly cache colours on first click.

This commit is contained in:
Lucio Andrés Illanes Albornoz 2018-01-10 14:53:35 +01:00
parent 2254a0638b
commit 49ef54ef76

View File

@ -27,7 +27,7 @@ from MiRCARTTool import MiRCARTTool
class MiRCARTToolLine(MiRCARTTool):
"""XXX"""
name = "Line"
toolOriginPoint = toolState = None
toolColours = toolOriginPoint = toolState = None
TS_NONE = 0
TS_ORIGIN = 1
@ -80,21 +80,25 @@ class MiRCARTToolLine(MiRCARTTool):
brushColours[1] = brushColours[0]
if self.toolState == self.TS_NONE:
if isLeftDown or isRightDown:
self.toolColours = brushColours
self.toolOriginPoint = list(atPoint)
self.toolState = self.TS_ORIGIN
dispatchFn(eventDc, True, [atPoint, brushColours, 0, " "])
elif self.toolState == self.TS_ORIGIN:
targetPoint = list(atPoint)
originPoint = self.toolOriginPoint
self._getLine(brushColours, brushSize, \
self._getLine(self.toolColours, brushSize, \
eventDc, isLeftDown or isRightDown, \
originPoint, targetPoint, dispatchFn)
if isLeftDown or isRightDown:
self.toolColours = None
self.toolOriginPoint = None
self.toolState = self.TS_NONE
# __init__(self, *args): initialisation method
def __init__(self, *args):
super().__init__(*args)
self.toolColours = None
self.toolOriginPoint = None
self.toolState = self.TS_NONE