55FXApp* GUI::myApp =
nullptr;
61std::vector<std::string>
66 throw TraCIException(
"GUI is not running, command not implemented in command line sumo");
76 throw TraCIException(
"GUI is not running, command not implemented in command line sumo");
82GUI::getZoom(
const std::string& viewID) {
83 return getView(viewID)->getChanger().getZoom();
88GUI::getAngle(
const std::string& viewID) {
89 return getView(viewID)->getChanger().getRotation();
94GUI::getOffset(
const std::string& viewID) {
104GUI::getSchema(
const std::string& viewID) {
105 return getView(viewID)->getVisualisationSettings().name;
110GUI::getBoundary(
const std::string& viewID) {
111 const Boundary& b = getView(viewID)->getVisibleBoundary();
112 TraCIPositionVector tb;
121 tb.value.push_back(minV);
122 tb.value.push_back(maxV);
128GUI::setZoom(
const std::string& viewID,
double zoom) {
131 const Position p(off.x(), off.y(), 0);
137GUI::setAngle(
const std::string& viewID,
double angle) {
140 const Position p(off.x(), off.y(), 0);
146GUI::setOffset(
const std::string& viewID,
double x,
double y) {
155GUI::setSchema(
const std::string& viewID,
const std::string& schemeName) {
156 getView(viewID)->setColorScheme(schemeName);
161GUI::addView(
const std::string& viewID,
const std::string& schemeName,
bool in3D) {
166 throw TraCIException(
"GUI is not running, command not implemented in command line sumo");
173GUI::removeView(
const std::string& viewID) {
178 throw TraCIException(
"GUI is not running, command not implemented in command line sumo");
185GUI::setBoundary(
const std::string& viewID,
double xmin,
double ymin,
double xmax,
double ymax) {
186 getView(viewID)->centerTo(
Boundary(xmin, ymin, xmax, ymax));
191GUI::screenshot(
const std::string& viewID,
const std::string& filename,
const int width,
const int height) {
192 getView(viewID)->addSnapshot(
SIMSTEP, filename, width, height);
197GUI::trackVehicle(
const std::string& viewID,
const std::string& vehID) {
204 if (veh !=
nullptr) {
205 glID =
static_cast<GUIVehicle*
>(veh)->getGlID();
208 if (person !=
nullptr) {
209 glID =
static_cast<GUIPerson*
>(person)->getGlID();
212 if (container !=
nullptr) {
213 glID =
static_cast<GUIContainer*
>(container)->getGlID();
215 throw TraCIException(
"Could not find vehicle or person '" + vehID +
"'.");
227GUI::hasView(
const std::string& viewID) {
231 throw TraCIException(
"GUI is not running, command not implemented in command line sumo");
237GUI::getTrackedVehicle(
const std::string& viewID) {
244 const std::string result = tracked ==
nullptr ?
"" : tracked->
getMicrosimID();
253GUI::track(
const std::string& objID,
const std::string& viewID) {
254 trackVehicle(viewID, objID);
259GUI::isSelected(
const std::string& objID,
const std::string& objType) {
260 const std::string fullName = objType +
":" + objID;
262 if (obj ==
nullptr) {
264 throw TraCIException(
"The " + objType +
" " + objID +
" is not known.");
273GUI::toggleSelection(
const std::string& objID,
const std::string& objType) {
274 const std::string fullName = objType +
":" + objID;
276 if (obj ==
nullptr) {
278 throw TraCIException(
"The " + objType +
" " + objID +
" is not known.");
286GUI::getParameter(
const std::string& ,
const std::string& ) {
292GUI::setParameter(
const std::string& ,
const std::string& ,
const std::string& ) {
301GUI::start(
const std::vector<std::string>& cmd) {
302 if (cmd[0].find(
"sumo-gui") == std::string::npos && std::getenv(
"LIBSUMO_GUI") ==
nullptr) {
306 WRITE_WARNING(
"Libsumo on Windows does not work with GUI, falling back to plain libsumo.");
310 if (!GUI::close(
"Libsumo started new instance.")) {
314 char array[1][10] = {{0}};
315 strcpy(array[0],
"dummy");
323 std::vector<std::string> args(cmd.begin() + 1, cmd.end());
328 myApp =
new FXApp(
"SUMO GUI",
"sumo-gui");
329 myApp->init(argc, argv);
331 if (!FXGLVisual::supported(myApp, major, minor)) {
332 throw ProcessError(
TL(
"This system has no OpenGL support. Exiting."));
338 myWindow->dependentBuild(
true);
340 myWindow->getRunner()->enableLibsumo();
342 myWindow->loadOnStartup(
true);
344 throw TraCIException(e.what());
352GUI::load(
const std::vector<std::string>& ) {
353 if (myWindow !=
nullptr) {
354 WRITE_ERROR(
"libsumo.load is not implemented for the GUI.");
363 return myWindow !=
nullptr;
369 if (myWindow !=
nullptr) {
374 myWindow->getRunner()->tryStep();
383GUI::close(
const std::string& ) {
384 if (myWindow !=
nullptr) {
397GUI::getView(
const std::string&
id) {
402 throw TraCIException(
"View '" +
id +
"' is not known");
406 throw TraCIException(
"GUI is not running, command not implemented in command line sumo");
411std::shared_ptr<VariableWrapper>
413 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
418GUI::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* ) {
421 return wrapper->wrapStringList(objID, variable, getIDList());
423 return wrapper->wrapInt(objID, variable, getIDCount());
425 return wrapper->wrapDouble(objID, variable, getZoom(objID));
427 return wrapper->wrapPosition(objID, variable, getOffset(objID));
429 return wrapper->wrapString(objID, variable, getSchema(objID));
431 return wrapper->wrapDouble(objID, variable, getAngle(objID));
433 return wrapper->wrapPositionVector(objID, variable, getBoundary(objID));
435 return wrapper->wrapInt(objID, variable, hasView(objID) ? 1 : 0);
437 return wrapper->wrapString(objID, variable, getTrackedVehicle(objID));
GUICompleteSchemeStorage gSchemeStorage
GUISelectedStorage gSelected
A global holder of selected objects.
#define WRITE_WARNING(msg)
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
A class that stores a 2D geometrical boundary.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
double zmin() const
Returns minimum z-coordinate.
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
double zmax() const
Returns maximum z-coordinate.
The main window of the SUMO-gui.
void init(FXApp *app, bool netedit=false)
Initialises the storage with some default settings.
GUISUMOAbstractView * getView() const
return GUISUMOAbstractView
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
static const GUIGlID INVALID_ID
GUIGlID getGlID() const
Returns the numerical id of the object.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
GUIGlObject * getObjectBlocking(GUIGlID id) const
Returns the object from the container locking it.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
C++ TraCI client API implementation.
GUIGlChildWindow * getViewByID(const std::string &id) const
get specific view by ID
std::vector< std::string > getViewIDs() const
get view IDs
static GUIMainWindow * getInstance()
get instance
virtual void sendBlockingEvent(GUIEvent *event)
Sends an event from the application thread to the GUI and waits until it is handled.
virtual double zoom2ZPos(double zoom) const =0
Returns the camera height at which the given zoom level is reached.
virtual double getRotation() const =0
Returns the rotation of the canvas stored in this changer.
virtual double getXPos() const =0
Returns the x-offset of the field to show stored in this changer.
virtual double getYPos() const =0
Returns the y-offset of the field to show stored in this changer.
virtual double getZPos() const =0
Returns the camera height corresponding to the current zoom factor.
GUIPerspectiveChanger & getChanger() const
get changer
virtual void setViewportFromToRot(const Position &lookFrom, const Position &lookAt, double rotation)
applies the given viewport settings
virtual void stopTrack()
stop track
virtual void startTrack(int)
star track
virtual GUIGlID getTrackedID() const
get tracked id
void toggleSelection(GUIGlID id)
Toggles selection of an object.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
A MSVehicle extended by some values for usage within the gui.
static void fillOptions()
Inserts options used by the simulation into the OptionsCont-singleton.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual MSTransportableControl & getContainerControl()
Returns the container control.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
static void setFactory(Factory func)
Sets the factory function to use for new MsgHandlers.
static MsgHandler * create(MsgType type)
static OptionsCont & getOptions()
Retrieves the options.
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
A point in 2D or 3D with translation and scaling methods.
Representation of a vehicle.
static void close()
Closes all of an applications subsystems.
static void init()
Initialises the xml-subsystem.
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_VIEW_BOUNDARY
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int VAR_ANGLE
TRACI_CONST int VAR_VIEW_OFFSET
TRACI_CONST int VAR_VIEW_SCHEMA
TRACI_CONST int VAR_VIEW_ZOOM
TRACI_CONST int VAR_TRACK_VEHICLE
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_HAS_VIEW
@ array
array (ordered collection of values)
A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE.