Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/neteditTestFunctions/frames/network/shape.py
169686 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 shape.py
15
# @author Pablo Alvarez Lopez
16
# @date 28-05-25
17
18
# imports
19
from ...general.functions import focusOnFrame
20
from ...input.mouse import leftClick, leftClickOffset
21
from ...input.keyboard import typeKey
22
23
24
def createSquaredShape(referencePosition, position, size, close):
25
"""
26
@brief Create squared Polygon in position with a certain size
27
"""
28
# call create rectangled shape
29
createRectangledShape(referencePosition, position, size, size, close)
30
31
32
def createRectangledShape(referencePosition, position, sizex, sizey, close):
33
"""
34
@brief Create rectangle Polygon in position with a certain size
35
"""
36
# focus current frame
37
focusOnFrame()
38
# start draw
39
typeKey('enter')
40
# create polygon
41
leftClick(referencePosition, position)
42
leftClickOffset(referencePosition, position, 0, int(float(sizey) / -2))
43
leftClickOffset(referencePosition, position, int(sizex / float(-2)), int(float(sizey) / -2))
44
leftClickOffset(referencePosition, position, int(sizex / float(-2)), 0)
45
# check if polygon has to be closed
46
if (close is True):
47
leftClick(referencePosition, position)
48
# finish draw
49
typeKey('enter')
50
51
52
def createLineShape(referencePosition, position, sizex, sizey, close):
53
"""
54
@brief Create line Polygon in position with a certain size
55
"""
56
# focus current frame
57
focusOnFrame()
58
# start draw
59
typeKey('enter')
60
# create polygon
61
leftClick(referencePosition, position)
62
leftClickOffset(referencePosition, position, (sizex / -2), (sizey / -2))
63
# check if polygon has to be closed
64
if (close is True):
65
leftClick(referencePosition, position)
66
# finish draw
67
typeKey('enter')
68
69
70
def createGEOPOI():
71
"""
72
@brief create GEO POI
73
"""
74
# focus current frame
75
focusOnFrame()
76
# place cursor in create GEO POI
77
for _ in range(20):
78
typeKey('tab')
79
# create geoPOI
80
typeKey('space')
81
82
83
def GEOPOILonLat():
84
"""
85
@brief change GEO POI format as Lon Lat
86
"""
87
# focus current frame
88
focusOnFrame()
89
# place cursor in lon-lat
90
for _ in range(16):
91
typeKey('tab')
92
# Change current value
93
typeKey('space')
94
95
96
def GEOPOILatLon():
97
"""
98
@brief change GEO POI format as Lat Lon
99
"""
100
# focus current frame
101
focusOnFrame()
102
# place cursor in lat-lon
103
for _ in range(17):
104
typeKey('tab')
105
# Change current value
106
typeKey('space')
107
108