Path: blob/main/tools/neteditTestFunctions/general/viewport.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 viewport.py14# @author Pablo Alvarez Lopez15# @date 28-05-251617# imports18import time19from ..constants import TEXTTEST_SANDBOX, DELAY_SELECT20from ..input.keyboard import typeKey, typeTwoKeys, updateText212223def loadViewPort():24"""25@brief load viewport26"""27# open edit viewport dialog28typeTwoKeys('ctrl', 'i')29# go to load30typeKey('space')31# jump to filename TextField32typeTwoKeys('alt', 'f')33updateText(TEXTTEST_SANDBOX)34typeKey('enter')35updateText("loadViewport.xml")36typeKey('enter')37# wait38time.sleep(DELAY_SELECT)39# open edit viewport dialog40typeTwoKeys('ctrl', 'i')41# press OK Button using shortcut42typeTwoKeys('alt', 'o')434445def saveViewPort():46"""47@brief save viewport48"""49# open edit viewport dialog50typeTwoKeys('ctrl', 'i')51# go to save52typeKey('tab')53typeKey('space')54# jump to filename TextField55typeTwoKeys('alt', 'f')56updateText(TEXTTEST_SANDBOX)57typeKey('enter')58updateText("viewport.xml")59typeKey('enter')60# wait61time.sleep(DELAY_SELECT)62# open edit viewport dialog63typeTwoKeys('ctrl', 'i')64# press OK Button using shortcut65typeTwoKeys('alt', 'o')666768def setViewport(zoom, x, y, z, r):69"""70@brief edit viewport71"""72# open edit viewport dialog73typeTwoKeys('ctrl', 'i')74# go to zoom75for _ in range(2):76typeKey('tab')77# Paste X78if (len(zoom) > 0):79updateText(zoom)80# go to Y81typeKey('tab')82# Paste X83if (len(x) > 0):84updateText(x)85# go to Y86typeKey('tab')87# Paste Y88if (len(y) > 0):89updateText(y)90# go to Z91typeKey('tab')92# Paste Z93if (len(z) > 0):94updateText(z)95# go to rotation96typeKey('tab')97# Paste rotation98if (len(r) > 0):99updateText(r)100# press OK Button using shortcut101typeTwoKeys('alt', 'o')102103104