Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
libtraci/GUI.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2017-2024 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/****************************************************************************/
18// C++ TraCI client API implementation
19/****************************************************************************/
20#include <config.h>
21
22#define LIBTRACI 1
23#include "Domain.h"
24#include <libsumo/GUI.h>
25
26
27namespace libtraci {
28
29typedef Domain<libsumo::CMD_GET_GUI_VARIABLE, libsumo::CMD_SET_GUI_VARIABLE> Dom;
30
31// ===========================================================================
32// static member definitions
33// ===========================================================================
34std::vector<std::string>
35GUI::getIDList() {
37}
38
39
40int
41GUI::getIDCount() {
43}
44
45
46double
47GUI::getZoom(const std::string& viewID) {
49}
50
51
52double
53GUI::getAngle(const std::string& viewID) {
54 return Dom::getDouble(libsumo::VAR_ANGLE, viewID);
55}
56
57
59GUI::getOffset(const std::string& viewID) {
61}
62
63
64std::string
65GUI::getSchema(const std::string& viewID) {
67}
68
69
71GUI::getBoundary(const std::string& viewID) {
73}
74
75
77
78
79void
80GUI::setZoom(const std::string& viewID, double zoom) {
82}
83
84
85void
86GUI::setAngle(const std::string& viewID, double angle) {
87 Dom::setDouble(libsumo::VAR_ANGLE, viewID, angle);
88}
89
90
91void
92GUI::setOffset(const std::string& viewID, double x, double y) {
93 tcpip::Storage content;
95 content.writeDouble(x);
96 content.writeDouble(y);
97 Dom::set(libsumo::VAR_VIEW_OFFSET, viewID, &content);
98}
99
100
101void
102GUI::setSchema(const std::string& viewID, const std::string& schemeName) {
103 Dom::setString(libsumo::VAR_VIEW_SCHEMA, viewID, schemeName);
104}
105
106void
107GUI::addView(const std::string& viewID, const std::string& schemeName, bool in3D) {
108 tcpip::Storage content;
109 StoHelp::writeCompound(content, 2);
110 StoHelp::writeTypedString(content, schemeName);
111 StoHelp::writeTypedInt(content, in3D ? 1 : 0);
112 Dom::set(libsumo::ADD, viewID, &content);
113}
114
115void
116GUI::removeView(const std::string& viewID) {
117 Dom::set(libsumo::REMOVE, viewID, nullptr);
118}
119
120
121void
122GUI::setBoundary(const std::string& viewID, double xmin, double ymin, double xmax, double ymax) {
123 tcpip::Storage content;
125 content.writeUnsignedByte(2);
126 content.writeDouble(xmin);
127 content.writeDouble(ymin);
128 content.writeDouble(xmax);
129 content.writeDouble(ymax);
130 Dom::set(libsumo::VAR_VIEW_BOUNDARY, viewID, &content);
131}
132
133
134void
135GUI::screenshot(const std::string& viewID, const std::string& filename, const int width, const int height) {
136 tcpip::Storage content;
137 StoHelp::writeCompound(content, 3);
138 StoHelp::writeTypedString(content, filename);
139 StoHelp::writeTypedInt(content, width);
140 StoHelp::writeTypedInt(content, height);
141 Dom::set(libsumo::VAR_SCREENSHOT, viewID, &content);
142}
143
144
145void
146GUI::trackVehicle(const std::string& viewID, const std::string& vehID) {
148}
149
150
151bool
152GUI::hasView(const std::string& viewID) {
153 return Dom::getInt(libsumo::VAR_HAS_VIEW, viewID) != 0;
154}
155
156
157std::string
158GUI::getTrackedVehicle(const std::string& viewID) {
160}
161
162
163void
164GUI::track(const std::string& objID, const std::string& viewID) {
166}
167
168
169bool
170GUI::isSelected(const std::string& objID, const std::string& objType) {
171 tcpip::Storage content;
172 StoHelp::writeTypedString(content, objType);
173 return Dom::getInt(libsumo::VAR_SELECT, objID, &content) != 0;
174}
175
176
177void
178GUI::toggleSelection(const std::string& objID, const std::string& objType) {
179 Dom::setString(libsumo::VAR_SELECT, objID, objType);
180}
181
182
184
185
186}
187
188
189/****************************************************************************/
#define LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
Definition Domain.h:38
#define LIBTRACI_PARAMETER_IMPLEMENTATION(CLASS, DOMAIN)
Definition Domain.h:77
C++ TraCI client API implementation.
static void writeCompound(tcpip::Storage &content, int size)
static void writeTypedInt(tcpip::Storage &content, int value)
static void writeTypedString(tcpip::Storage &content, const std::string &value)
static void setDouble(int var, const std::string &id, double value)
Definition Domain.h:231
static libsumo::TraCIPosition getPos(int var, const std::string &id, tcpip::Storage *add=nullptr, const bool isGeo=false)
Definition Domain.h:153
static std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:177
static std::string getString(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:172
static int getInt(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:125
static libsumo::TraCIPositionVector getPolygon(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:135
static void set(int var, const std::string &id, tcpip::Storage *add)
Definition Domain.h:219
static double getDouble(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:130
static void setString(int var, const std::string &id, const std::string &value)
Definition Domain.h:238
virtual void writeDouble(double)
Definition storage.cpp:354
virtual void writeUnsignedByte(int)
Definition storage.cpp:165
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_VIEW_BOUNDARY
TRACI_CONST int VAR_SCREENSHOT
TRACI_CONST int VAR_ANGLE
TRACI_CONST int VAR_VIEW_OFFSET
TRACI_CONST int VAR_VIEW_SCHEMA
TRACI_CONST int POSITION_2D
TRACI_CONST int TYPE_POLYGON
TRACI_CONST int VAR_VIEW_ZOOM
TRACI_CONST int VAR_TRACK_VEHICLE
TRACI_CONST int VAR_HAS_VIEW
TRACI_CONST int ID_COUNT
TRACI_CONST int REMOVE
TRACI_CONST int VAR_SELECT
TRACI_CONST int ADD
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom
A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE.
Definition TraCIDefs.h:178
A list of positions.
Definition TraCIDefs.h:234