55FXApp* GUI::myApp =
nullptr;
61std::vector<std::string>
64 throw TraCIException(
"GUI is not running, command not implemented in command line sumo");
73 throw TraCIException(
"GUI is not running, command not implemented in command line sumo");
80GUI::getZoom(
const std::string& viewID) {
81 return getView(viewID)->getChanger().getZoom();
86GUI::getAngle(
const std::string& viewID) {
87 return getView(viewID)->getChanger().getRotation();
92GUI::getOffset(
const std::string& viewID) {
102GUI::getSchema(
const std::string& viewID) {
103 return getView(viewID)->getVisualisationSettings().name;
108GUI::getBoundary(
const std::string& viewID) {
109 const Boundary& b = getView(viewID)->getVisibleBoundary();
110 TraCIPositionVector tb;
119 tb.value.push_back(minV);
120 tb.value.push_back(maxV);
126GUI::setZoom(
const std::string& viewID,
double zoom) {
129 const Position p(off.x(), off.y(), 0);
135GUI::setAngle(
const std::string& viewID,
double angle) {
138 const Position p(off.x(), off.y(), 0);
144GUI::setOffset(
const std::string& viewID,
double x,
double y) {
153GUI::setSchema(
const std::string& viewID,
const std::string& schemeName) {
154 getView(viewID)->setColorScheme(schemeName);
159GUI::addView(
const std::string& viewID,
const std::string& schemeName,
bool in3D) {
162 throw TraCIException(
"GUI is not running, command not implemented in command line sumo");
171GUI::removeView(
const std::string& viewID) {
174 throw TraCIException(
"GUI is not running, command not implemented in command line sumo");
183GUI::setBoundary(
const std::string& viewID,
double xmin,
double ymin,
double xmax,
double ymax) {
184 getView(viewID)->centerTo(
Boundary(xmin, ymin, xmax, ymax));
189GUI::screenshot(
const std::string& viewID,
const std::string& filename,
const int width,
const int height) {
190 getView(viewID)->addSnapshot(
SIMSTEP, filename, width, height);
195GUI::trackVehicle(
const std::string& viewID,
const std::string& vehID) {
202 if (veh !=
nullptr) {
203 glID =
static_cast<GUIVehicle*
>(veh)->getGlID();
206 if (person !=
nullptr) {
207 glID =
static_cast<GUIPerson*
>(person)->getGlID();
210 if (container !=
nullptr) {
211 glID =
static_cast<GUIContainer*
>(container)->getGlID();
213 throw TraCIException(
"Could not find vehicle or person '" + vehID +
"'.");
225GUI::hasView(
const std::string& viewID) {
228 throw TraCIException(
"GUI is not running, command not implemented in command line sumo");
235GUI::getTrackedVehicle(
const std::string& viewID) {
242 const std::string result = tracked ==
nullptr ?
"" : tracked->
getMicrosimID();
251GUI::track(
const std::string& objID,
const std::string& viewID) {
252 trackVehicle(viewID, objID);
257GUI::isSelected(
const std::string& objID,
const std::string& objType) {
258 const std::string fullName = objType +
":" + objID;
260 if (obj ==
nullptr) {
262 throw TraCIException(
"The " + objType +
" " + objID +
" is not known.");
271GUI::toggleSelection(
const std::string& objID,
const std::string& objType) {
272 const std::string fullName = objType +
":" + objID;
274 if (obj ==
nullptr) {
276 throw TraCIException(
"The " + objType +
" " + objID +
" is not known.");
284GUI::getParameter(
const std::string& ,
const std::string& ) {
290GUI::setParameter(
const std::string& ,
const std::string& ,
const std::string& ) {
299GUI::start(
const std::vector<std::string>& cmd) {
300 if (cmd[0].find(
"sumo-gui") == std::string::npos && std::getenv(
"LIBSUMO_GUI") ==
nullptr) {
304 WRITE_WARNING(
"Libsumo on Windows does not work with GUI, falling back to plain libsumo.");
308 if (!GUI::close(
"Libsumo started new instance.")) {
312 char array[1][10] = {{0}};
313 strcpy(array[0],
"dummy");
321 std::vector<std::string> args(cmd.begin() + 1, cmd.end());
326 myApp =
new FXApp(
"SUMO GUI",
"sumo-gui");
327 myApp->init(argc, argv);
329 if (!FXGLVisual::supported(myApp, major, minor)) {
330 throw ProcessError(
TL(
"This system has no OpenGL support. Exiting."));
336 myWindow->dependentBuild(
true);
338 myWindow->getRunner()->enableLibsumo();
340 myWindow->loadOnStartup(
true);
342 throw TraCIException(e.what());
350GUI::load(
const std::vector<std::string>& ) {
351 if (myWindow !=
nullptr) {
352 WRITE_ERROR(
"libsumo.load is not implemented for the GUI.");
361 return myWindow !=
nullptr;
367 if (myWindow !=
nullptr) {
372 myWindow->getRunner()->tryStep();
381GUI::close(
const std::string& ) {
382 if (myWindow !=
nullptr) {
395GUI::getView(
const std::string&
id) {
399 throw TraCIException(
"GUI is not running, command not implemented in command line sumo");
403 throw TraCIException(
"View '" +
id +
"' is not known");
409std::shared_ptr<VariableWrapper>
411 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
416GUI::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* ) {
419 return wrapper->wrapStringList(objID, variable, getIDList());
421 return wrapper->wrapInt(objID, variable, getIDCount());
423 return wrapper->wrapDouble(objID, variable, getZoom(objID));
425 return wrapper->wrapPosition(objID, variable, getOffset(objID));
427 return wrapper->wrapString(objID, variable, getSchema(objID));
429 return wrapper->wrapDouble(objID, variable, getAngle(objID));
431 return wrapper->wrapPositionVector(objID, variable, getBoundary(objID));
433 return wrapper->wrapInt(objID, variable, hasView(objID) ? 1 : 0);
435 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.