Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/neteditTestFunctions/general/viewport.py
169679 views
1
# -*- coding: utf-8 -*-
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2009-2025 German Aerospace Center (DLR) and others.
4
# This program and the accompanying materials are made available under the
5
# terms of the Eclipse Public License 2.0 which is available at
6
# https://www.eclipse.org/legal/epl-2.0/
7
# This Source Code may also be made available under the following Secondary
8
# Licenses when the conditions for such availability set forth in the Eclipse
9
# Public License 2.0 are satisfied: GNU General Public License, version 2
10
# or later which is available at
11
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14
# @file viewport.py
15
# @author Pablo Alvarez Lopez
16
# @date 28-05-25
17
18
# imports
19
import time
20
from ..constants import TEXTTEST_SANDBOX, DELAY_SELECT
21
from ..input.keyboard import typeKey, typeTwoKeys, updateText
22
23
24
def loadViewPort():
25
"""
26
@brief load viewport
27
"""
28
# open edit viewport dialog
29
typeTwoKeys('ctrl', 'i')
30
# go to load
31
typeKey('space')
32
# jump to filename TextField
33
typeTwoKeys('alt', 'f')
34
updateText(TEXTTEST_SANDBOX)
35
typeKey('enter')
36
updateText("loadViewport.xml")
37
typeKey('enter')
38
# wait
39
time.sleep(DELAY_SELECT)
40
# open edit viewport dialog
41
typeTwoKeys('ctrl', 'i')
42
# press OK Button using shortcut
43
typeTwoKeys('alt', 'o')
44
45
46
def saveViewPort():
47
"""
48
@brief save viewport
49
"""
50
# open edit viewport dialog
51
typeTwoKeys('ctrl', 'i')
52
# go to save
53
typeKey('tab')
54
typeKey('space')
55
# jump to filename TextField
56
typeTwoKeys('alt', 'f')
57
updateText(TEXTTEST_SANDBOX)
58
typeKey('enter')
59
updateText("viewport.xml")
60
typeKey('enter')
61
# wait
62
time.sleep(DELAY_SELECT)
63
# open edit viewport dialog
64
typeTwoKeys('ctrl', 'i')
65
# press OK Button using shortcut
66
typeTwoKeys('alt', 'o')
67
68
69
def setViewport(zoom, x, y, z, r):
70
"""
71
@brief edit viewport
72
"""
73
# open edit viewport dialog
74
typeTwoKeys('ctrl', 'i')
75
# go to zoom
76
for _ in range(2):
77
typeKey('tab')
78
# Paste X
79
if (len(zoom) > 0):
80
updateText(zoom)
81
# go to Y
82
typeKey('tab')
83
# Paste X
84
if (len(x) > 0):
85
updateText(x)
86
# go to Y
87
typeKey('tab')
88
# Paste Y
89
if (len(y) > 0):
90
updateText(y)
91
# go to Z
92
typeKey('tab')
93
# Paste Z
94
if (len(z) > 0):
95
updateText(z)
96
# go to rotation
97
typeKey('tab')
98
# Paste rotation
99
if (len(r) > 0):
100
updateText(r)
101
# press OK Button using shortcut
102
typeTwoKeys('alt', 'o')
103
104