def mouseDown(self, machine, *args, **kwargs): point = kwargs['point'] if Figure.pointIsControl(machine.p1, point, kwargs['scale']): self.point = machine.p1 if Figure.pointIsControl(machine.p2, point, kwargs['scale']): self.point = machine.p2 if self.point: if 'event' in kwargs and kwargs['event'].button() == Qt.RightButton: machine.state = machine.delete else: self.point.setX(point.x()) self.point.setY(point.y()) return True else: return False
def mouseDown(self, machine, *args, **kwargs): point = kwargs['point'] if Figure.pointIsControl(machine.p1, point, kwargs['scale']): self.point = machine.p1 if Figure.pointIsControl(machine.p2, point, kwargs['scale']): self.point = machine.p2 if self.point: if 'event' in kwargs and kwargs['event'].button( ) == Qt.RightButton: machine.state = machine.delete else: self.point.setX(point.x()) self.point.setY(point.y()) return True else: return False
def mouseDown(self, machine, *args, **kwargs): point = kwargs.get('point') # Если нажатие в какой нибудь точке кроме последней то просто ничего не делаем и выходим for p in machine.polygon: if Figure.pointIsControl(p, point, kwargs['scale']) and p is not machine.polygon[-1]: return True # новую фигуру добавлять не надо # Если у нас больше 1 точки и мы тыкаем в последнюю тогда ... if len(machine.polygon) > 1 and Figure.pointIsControl(machine.polygon[-1], point, kwargs['scale']): # ... делаем декомпозицию ломаной и ... machine.decompose() # ... и переходим в состояние управление ломаной machine.state = machine.control return True # в любом оставшемся случае добавляем точку в ломаную machine.polygon.append(point) return True # новую фигуру добавлять не надо
def mouseDown(self, machine, *args, **kwargs): point = kwargs['point'] scale = kwargs['scale'] if Figure.pointIsControl(machine.center, point, scale): self.point = machine.center if Figure.pointIsControl(machine.ctrl, point, scale): self.point = machine.ctrl if self.point: if 'event' in kwargs and kwargs['event'].button() is Qt.RightButton: machine.state = machine.delete elif self.point == machine.center: delta = point - machine.center machine.center += delta machine.ctrl += delta elif self.point == machine.ctrl: machine.ctrl.setX(point.x()) machine.ctrl.setY(point.y()) return True else: return False
def mouseDown(self, machine, *args, **kwargs): for p in machine.polygon: if Figure.pointIsControl(p, kwargs['point'], kwargs['scale']): if 'event' in kwargs and kwargs['event'].button() is Qt.RightButton: del machine.polygon[machine.polygon.index(p)] if len(machine.polygon) < 3: machine.state = machine.delete else: machine.decompose() else: self.control1 = p return True return False
def mouseDown(self, machine, *args, **kwargs): point = kwargs['point'] scale = kwargs['scale'] if Figure.pointIsControl(machine.center, point, scale): self.point = machine.center if Figure.pointIsControl(machine.ctrl, point, scale): self.point = machine.ctrl if self.point: if 'event' in kwargs and kwargs['event'].button( ) is Qt.RightButton: machine.state = machine.delete elif self.point == machine.center: delta = point - machine.center machine.center += delta machine.ctrl += delta elif self.point == machine.ctrl: machine.ctrl.setX(point.x()) machine.ctrl.setY(point.y()) return True else: return False
def mouseUp(self, machine, *args, **kwargs): point = kwargs['point'] machine.ctrl = point if not Figure.pointIsControl(machine.center, point, kwargs['scale']): machine.state = machine.control
def mouseUp(self, machine, *args, **kwargs): machine.p2 = kwargs['point'] if not Figure.pointIsControl(machine.p1, kwargs['point'], kwargs['scale']): machine.state = machine.control
def mouseUp(self, machine, *args, **kwargs): machine.p2 = kwargs['point'] if not Figure.pointIsControl(machine.p1, kwargs['point'], kwargs['scale']): machine.state = machine.control
def mouseUp(self, machine, *args, **kwargs): point = kwargs['point'] machine.ctrl = point if not Figure.pointIsControl(machine.center, point, kwargs['scale']): machine.state = machine.control