Path: blob/main/tools/neteditTestFunctions/general/undoRedo.py
169679 views
# -*- coding: utf-8 -*-1# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2# Copyright (C) 2009-2025 German Aerospace Center (DLR) and others.3# This program and the accompanying materials are made available under the4# terms of the Eclipse Public License 2.0 which is available at5# https://www.eclipse.org/legal/epl-2.0/6# This Source Code may also be made available under the following Secondary7# Licenses when the conditions for such availability set forth in the Eclipse8# Public License 2.0 are satisfied: GNU General Public License, version 29# or later which is available at10# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later1213# @file undoRedo.py14# @author Pablo Alvarez Lopez15# @date 28-05-251617# imports18import time19from ..enums.viewPositions import positions20from ..constants import DELAY_UNDOREDO21from ..general.functions import focusOnFrame22from ..input.keyboard import typeKey, typeTwoKeys23from ..input.mouse import leftClickOffset242526def undo(referencePosition, number, offsetX=0, offsetY=0):27"""28@brief undo last operation29"""30# first wait31time.sleep(DELAY_UNDOREDO)32# focus current frame33focusOnFrame()34# needed to avoid errors with undo/redo (Provisionally)35typeKey('i')36# click over referencePosition37leftClickOffset(referencePosition, positions.reference, offsetX, offsetY)38for _ in range(number):39typeTwoKeys('ctrl', 'z')40time.sleep(DELAY_UNDOREDO)414243def redo(referencePosition, number, offsetX=0, offsetY=0):44"""45@brief undo last operation46"""47# first wait48time.sleep(DELAY_UNDOREDO)49# focus current frame50focusOnFrame()51# needed to avoid errors with undo/redo (Provisionally)52typeKey('i')53# click over referencePosition54leftClickOffset(referencePosition, positions.reference, offsetX, offsetY)55for _ in range(number):56typeTwoKeys('ctrl', 'y')57time.sleep(DELAY_UNDOREDO)585960def checkUndoRedo(referencePosition, offsetX=0, offsetY=0):61"""62@brief Check undo-redo63"""64# Check undo65undo(referencePosition, 9, offsetX)66# Check redo67redo(referencePosition, 9, offsetY)686970