Eclipse SUMO - Simulation of Urban MObility
GUI.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2017-2022 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 
27 namespace libtraci {
28 
29 typedef Domain<libsumo::CMD_GET_GUI_VARIABLE, libsumo::CMD_SET_GUI_VARIABLE> Dom;
30 
31 // ===========================================================================
32 // static member definitions
33 // ===========================================================================
34 std::vector<std::string>
35 GUI::getIDList() {
37 }
38 
39 
40 int
41 GUI::getIDCount() {
42  return Dom::getInt(libsumo::ID_COUNT, "");
43 }
44 
45 
46 double
47 GUI::getZoom(const std::string& viewID) {
48  return Dom::getDouble(libsumo::VAR_VIEW_ZOOM, viewID);
49 }
50 
51 
53 GUI::getOffset(const std::string& viewID) {
54  return Dom::getPos(libsumo::VAR_VIEW_OFFSET, viewID);
55 }
56 
57 
58 std::string
59 GUI::getSchema(const std::string& viewID) {
61 }
62 
63 
65 GUI::getBoundary(const std::string& viewID) {
67 }
68 
69 
71 
72 
73 void
74 GUI::setZoom(const std::string& viewID, double zoom) {
76 }
77 
78 
79 void
80 GUI::setOffset(const std::string& viewID, double x, double y) {
81  tcpip::Storage content;
83  content.writeDouble(x);
84  content.writeDouble(y);
85  Dom::set(libsumo::VAR_VIEW_OFFSET, viewID, &content);
86 }
87 
88 
89 void
90 GUI::setSchema(const std::string& viewID, const std::string& schemeName) {
91  Dom::setString(libsumo::VAR_VIEW_SCHEMA, viewID, schemeName);
92 }
93 
94 
95 void
96 GUI::setBoundary(const std::string& viewID, double xmin, double ymin, double xmax, double ymax) {
97  tcpip::Storage content;
99  content.writeUnsignedByte(2);
100  content.writeDouble(xmin);
101  content.writeDouble(ymin);
102  content.writeDouble(xmax);
103  content.writeDouble(ymax);
104  Dom::set(libsumo::VAR_VIEW_BOUNDARY, viewID, &content);
105 }
106 
107 
108 void
109 GUI::screenshot(const std::string& viewID, const std::string& filename, const int width, const int height) {
110  tcpip::Storage content;
111  StoHelp::writeCompound(content, 3);
112  StoHelp::writeTypedString(content, filename);
113  StoHelp::writeTypedInt(content, width);
114  StoHelp::writeTypedInt(content, height);
115  Dom::set(libsumo::VAR_SCREENSHOT, viewID, &content);
116 }
117 
118 
119 void
120 GUI::trackVehicle(const std::string& viewID, const std::string& vehID) {
122 }
123 
124 
125 bool
126 GUI::hasView(const std::string& viewID) {
127  return Dom::getInt(libsumo::VAR_HAS_VIEW, viewID) != 0;
128 }
129 
130 
131 std::string
132 GUI::getTrackedVehicle(const std::string& viewID) {
134 }
135 
136 
137 void
138 GUI::track(const std::string& objID, const std::string& viewID) {
140 }
141 
142 
143 bool
144 GUI::isSelected(const std::string& objID, const std::string& objType) {
145  tcpip::Storage content;
146  StoHelp::writeTypedString(content, objType);
147  return Dom::getInt(libsumo::VAR_SELECT, objID, &content) != 0;
148 }
149 
150 
151 void
152 GUI::toggleSelection(const std::string& objID, const std::string& objType) {
153  Dom::setString(libsumo::VAR_SELECT, objID, objType);
154 }
155 
156 
158 
159 
160 }
161 
162 
163 /****************************************************************************/
#define LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
Definition: Domain.h:38
#define LIBTRACI_PARAMETER_IMPLEMENTATION(CLASS, DOMAIN)
Definition: Domain.h:76
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:215
static libsumo::TraCIPosition getPos(int var, const std::string &id, tcpip::Storage *add=nullptr, const bool isGeo=false)
Definition: Domain.h:149
static std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:170
static std::string getString(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:166
static int getInt(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:124
static libsumo::TraCIPositionVector getPolygon(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:132
static void set(int var, const std::string &id, tcpip::Storage *add)
Definition: Domain.h:204
static double getDouble(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:128
static void setString(int var, const std::string &id, const std::string &value)
Definition: Domain.h:222
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_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 VAR_SELECT
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom
A 3D-position.
Definition: TraCIDefs.h:164
A list of positions.
Definition: TraCIDefs.h:207