Path: blob/main/tools/neteditTestFunctions/frames/network/shape.py
169686 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 shape.py14# @author Pablo Alvarez Lopez15# @date 28-05-251617# imports18from ...general.functions import focusOnFrame19from ...input.mouse import leftClick, leftClickOffset20from ...input.keyboard import typeKey212223def createSquaredShape(referencePosition, position, size, close):24"""25@brief Create squared Polygon in position with a certain size26"""27# call create rectangled shape28createRectangledShape(referencePosition, position, size, size, close)293031def createRectangledShape(referencePosition, position, sizex, sizey, close):32"""33@brief Create rectangle Polygon in position with a certain size34"""35# focus current frame36focusOnFrame()37# start draw38typeKey('enter')39# create polygon40leftClick(referencePosition, position)41leftClickOffset(referencePosition, position, 0, int(float(sizey) / -2))42leftClickOffset(referencePosition, position, int(sizex / float(-2)), int(float(sizey) / -2))43leftClickOffset(referencePosition, position, int(sizex / float(-2)), 0)44# check if polygon has to be closed45if (close is True):46leftClick(referencePosition, position)47# finish draw48typeKey('enter')495051def createLineShape(referencePosition, position, sizex, sizey, close):52"""53@brief Create line Polygon in position with a certain size54"""55# focus current frame56focusOnFrame()57# start draw58typeKey('enter')59# create polygon60leftClick(referencePosition, position)61leftClickOffset(referencePosition, position, (sizex / -2), (sizey / -2))62# check if polygon has to be closed63if (close is True):64leftClick(referencePosition, position)65# finish draw66typeKey('enter')676869def createGEOPOI():70"""71@brief create GEO POI72"""73# focus current frame74focusOnFrame()75# place cursor in create GEO POI76for _ in range(20):77typeKey('tab')78# create geoPOI79typeKey('space')808182def GEOPOILonLat():83"""84@brief change GEO POI format as Lon Lat85"""86# focus current frame87focusOnFrame()88# place cursor in lon-lat89for _ in range(16):90typeKey('tab')91# Change current value92typeKey('space')939495def GEOPOILatLon():96"""97@brief change GEO POI format as Lat Lon98"""99# focus current frame100focusOnFrame()101# place cursor in lat-lon102for _ in range(17):103typeKey('tab')104# Change current value105typeKey('space')106107108