Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/neteditTestFunctions/general/modes.py
169678 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 modes.py
15
# @author Pablo Alvarez Lopez
16
# @date 28-05-25
17
18
# imports
19
import time
20
from ..constants import DELAY_RECOMPUTE
21
from ..input.keyboard import typeKey, typeTwoKeys
22
23
24
def changeSupermode(supermode):
25
"""
26
@brief change supermode
27
"""
28
match supermode:
29
# common modes
30
case "network":
31
typeKey('F2')
32
case "demand":
33
typeKey('F3')
34
case "data":
35
typeKey('F4')
36
case _:
37
raise Exception("Invalid supermode")
38
# wait for recompute
39
time.sleep(DELAY_RECOMPUTE)
40
41
42
def changeMode(mode):
43
"""
44
@brief change edit mode
45
"""
46
match mode:
47
# common modes
48
case "inspect":
49
typeKey('i')
50
case "delete":
51
typeKey('d')
52
case "select":
53
typeKey('s')
54
# network modes
55
case "createEdge":
56
typeKey('e')
57
case "move":
58
typeKey('m')
59
case "crossing":
60
typeKey('r')
61
case "connection":
62
typeKey('c')
63
case "additional":
64
typeKey('a')
65
case "shape":
66
typeKey('p')
67
case "TLS":
68
typeKey('t')
69
case "TAZ":
70
typeKey('z')
71
# demand modes
72
case "route":
73
typeKey('r')
74
case "vehicle":
75
typeKey('v')
76
case "type":
77
typeKey('t')
78
case "person":
79
typeKey('p')
80
case "personPlan":
81
typeKey('l')
82
case "container":
83
typeKey('c')
84
case "containerPlan":
85
typeKey('h')
86
case "stop":
87
typeKey('a')
88
# data modes
89
case "edgeData":
90
typeKey('e')
91
case "edgeRelData":
92
typeKey('r')
93
case "TAZRelData":
94
typeKey('z')
95
case "meanData":
96
typeKey('m')
97
case _:
98
raise Exception("Invalid mode")
99
# wait 1 second
100
time.sleep(1)
101
102
103
def changeEditMode(key):
104
"""
105
@brief Change edit mode (alt+1-9)
106
"""
107
typeTwoKeys('alt', key)
108
109