87 GUINet& net, FXGLVisual* glVis,
91 myTLSGame(
OptionsCont::getOptions().getString("game.mode") == "tls")
93 , myCurrentVideo(
nullptr)
114 for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) {
124 "\tLocate Junctions\tLocate a junction within the network.",
126 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
129 "\tLocate Edges\tLocate an edge within the network.",
131 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
134 "\tLocate Vehicles\tLocate a vehicle within the network.",
136 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
139 "\tLocate Persons\tLocate a person within the network.",
141 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
144 "\tLocate Container\tLocate a container within the network.",
146 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
149 "\tLocate TLS\tLocate a tls within the network.",
151 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
154 "\tLocate Additional\tLocate an additional structure within the network.",
156 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
159 "\tLocate PoI\tLocate a PoI within the network.",
161 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
164 "\tLocate Polygon\tLocate a Polygon within the network.",
166 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
189 bool hide,
double hideThreshold) {
191 double minValue = std::numeric_limits<double>::infinity();
192 double maxValue = -std::numeric_limits<double>::infinity();
198 }
else if (active == 24) {
202 for (MSEdgeVector::const_iterator it = edges.begin(); it != edges.end(); ++it) {
208 minValue =
MIN2(minValue, val);
209 maxValue =
MAX2(maxValue, val);
211 const std::vector<MSLane*>& lanes = (*it)->getLanes();
212 for (std::vector<MSLane*>::const_iterator it_l = lanes.begin(); it_l != lanes.end(); it_l++) {
217 minValue =
MIN2(minValue, val);
218 maxValue =
MAX2(maxValue, val);
224 std::set<const MSJunction*> junctions;
226 junctions.insert(edge->getFromJunction());
227 junctions.insert(edge->getToJunction());
229 for (
const MSJunction* junction : junctions) {
230 minValue =
MIN2(minValue, junction->getPosition().z());
231 maxValue =
MAX2(maxValue, junction->getPosition().z());
238 std::set<SVCPermissions> codes;
240 for (
MSLane* lane : edge->getLanes()) {
241 codes.insert(lane->getPermissions());
244 int step =
MAX2(1, 360 / (
int)codes.size());
248 hue = (hue + step) % 360;
253 if (minValue != std::numeric_limits<double>::infinity()) {
257 scheme.
addColor(
RGBColor(204, 204, 204), std::numeric_limits<double>::max(),
"missing data");
260 const double rawRange = maxValue - minValue;
261 minValue =
MAX2(hideThreshold +
MIN2(1.0, rawRange / 100.0), minValue);
264 double range = maxValue - minValue;
276 std::vector<std::string>
281 return std::vector<std::string>();
285 std::vector<std::string>
287 std::set<std::string> keys;
290 for (
const auto& item : e->getParametersMap()) {
291 keys.insert(item.first);
294 for (
const auto lane : e->getLanes()) {
295 for (
const auto& item : lane->getParametersMap()) {
296 keys.insert(item.first);
301 return std::vector<std::string>(keys.begin(), keys.end());
305 std::vector<std::string>
307 std::set<std::string> keys;
311 for (
auto kv : vehIt->second->getParameter().getParametersMap()) {
312 keys.insert(kv.first);
316 return std::vector<std::string>(keys.begin(), keys.end());
319 std::vector<std::string>
321 std::set<std::string> keys;
323 for (
auto item : pois) {
324 for (
auto kv : item.second->getParametersMap()) {
325 keys.insert(kv.first);
328 return std::vector<std::string>(keys.begin(), keys.end());
337 glMatrixMode(GL_MODELVIEW);
339 glDisable(GL_TEXTURE_2D);
340 glDisable(GL_ALPHA_TEST);
342 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
343 glEnable(GL_DEPTH_TEST);
353 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
354 const float minB[2] = { (float)bound.
xmin(), (float)bound.
ymin() };
355 const float maxB[2] = { (float)bound.
xmax(), (float)bound.
ymax() };
357 glEnable(GL_POLYGON_OFFSET_FILL);
358 glEnable(GL_POLYGON_OFFSET_LINE);
362 glTranslated(0, 0, -.01);
368 glTranslated(0, 0, .01);
407 double minDist = std::numeric_limits<double>::infinity();
409 if (tlsControl.
isActive(tll) && tll->getProgramID() !=
"off") {
412 if (lanes.size() > 0) {
413 const Position& endPos = lanes[0]->getShape().back();
421 if (minTll !=
nullptr) {
423 const std::vector<MSTrafficLightLogic*> logics = vars.
getAllLogics();
424 if (logics.size() > 1) {
426 for (
int i = 0; i < (int)logics.size() - 1; ++i) {
427 if (minTll->
getProgramID() == logics[i]->getProgramID()) {
432 if (l == logics[0]) {
445 if (sel.size() == 0) {
447 double minDist = std::numeric_limits<double>::infinity();
457 if (dist < minDist) {
463 if (closest !=
nullptr) {
469 double minDist = std::numeric_limits<double>::infinity();
472 for (
auto it = stops.
begin(); it != stops.
end(); ++it) {
475 if (dist < minDist) {
480 if (closestStop != 0) {
498 if (sel.size() > 0) {
523 return dynamic_cast<GUILane*
>(o);
534 if (lane !=
nullptr) {
546 if (lane !=
nullptr) {
558 if (lane !=
nullptr) {
570 if (lane !=
nullptr) {
575 for (
MSLane*
const l : e->getLanes()) {
581 FXMenuCommand* mc =
dynamic_cast<FXMenuCommand*
>(menu);
585 std::map<MSEdge*, double> reachableEdges;
586 reachableEdges[&lane->
getEdge()] = 0;
588 check.push_back(&lane->
getEdge());
589 while (check.size() > 0) {
590 MSEdge* e = check.front();
591 check.erase(check.begin());
592 double traveltime = reachableEdges[e];
594 if (l->allowsVehicleClass(svc)) {
602 if (reachableEdges.count(nextEdge) == 0 ||
604 reachableEdges[nextEdge] > traveltime) {
605 reachableEdges[nextEdge] = traveltime;
606 check.push_back(nextEdge);
636 if (myCurrentVideo ==
nullptr) {
639 myCurrentVideo->writeFrame((uint8_t*)buf);
650 if (myCurrentVideo !=
nullptr) {
651 delete myCurrentVideo;
652 myCurrentVideo =
nullptr;
661 if (myCurrentVideo !=
nullptr) {
669 const std::vector<SUMOTime>
@ MID_LOCATEPERSON
Locate person - button.
@ MID_LOCATEJUNCTION
Locate junction - button.
@ MID_LOCATEPOLY
Locate polygons - button.
@ MID_LOCATEADD
Locate addtional structure - button.
@ MID_LOCATEPOI
Locate poi - button.
@ MID_REACHABILITY
show reachability from a given lane
@ MID_CLOSE_LANE
close lane
@ MID_LOCATEEDGE
Locate edge - button.
@ MID_LOCATEVEHICLE
Locate vehicle - button.
@ MID_LOCATETLS
Locate TLS - button.
@ MID_CLOSE_EDGE
close edge
@ MID_ADD_REROUTER
add rerouter
@ MID_LOCATECONTAINER
Locate container - button.
GUICompleteSchemeStorage gSchemeStorage
GUISelectedStorage gSelected
A global holder of selected objects.
FXDEFMAP(GUIViewTraffic) GUIViewTrafficMap[]
std::vector< MSEdge * > MSEdgeVector
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SUMO_TAG_BUS_STOP
A bus stop.
const double SUMO_const_laneWidth
#define UNUSED_PARAMETER(x)
A class that stores a 2D geometrical boundary.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
static void popMatrix()
pop matrix
static void pushMatrix()
push matrix
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
@ VO_SHOW_FUTURE_ROUTE
show vehicle's current continued from the current position
bool contains(const std::string &name) const
Returns the information whether a setting with the given name is stored.
GUIVisualizationSettings & get(const std::string &name)
Returns the named scheme.
const std::vector< std::string > & getNames() const
Returns a list of stored settings names.
std::string getCurrentScheme() const
Returns the name of the currently chosen scheme.
void setCurrentScheme(const std::string &)
Sets the named scheme as the current.
A road/street connecting two junctions (gui-version)
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
FXComboBox * getColoringSchemesCombo()
return combobox with the current coloring schemes (standard, fastest standard, real world....
FXPopup * getLocatorPopup()
@ brief return a pointer to locator popup
static const GUIGlID INVALID_ID
GUIGlID getGlID() const
Returns the numerical id of the object.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
Representation of a lane in the micro simulation (gui-version)
void setReachability(double value)
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
virtual double getDelay() const
Returns the delay (should be overwritten by subclasses if applicable)
virtual long onCmdFullScreen(FXObject *, FXSelector, void *)
Toggle full screen mode.
bool isGaming() const
return whether the gui is in gaming mode
virtual const std::vector< SUMOTime > retrieveBreakpoints() const
retrieve breakpoints if provided by the application
A MSNet extended by some values for usage within the gui.
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
void unlock()
release exclusive access to the simulation state
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
void lock()
grant exclusive access to the simulation state
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
const std::string & getName() const
int addColor(const T &color, const double threshold, const std::string &name="")
void setActive(int scheme)
void paintGLGrid()
paints a grid
virtual void checkSnapshots()
Checks whether it is time for a snapshot.
const SUMORTree * myGrid
The visualization speed-up.
GUIDialog_ViewSettings * myVisualizationChanger
Visualization changer.
FXbool makeCurrent()
A reimplementation due to some internal reasons.
void addSnapshot(SUMOTime time, const std::string &file, const int w=-1, const int h=-1)
Sets the snapshot time to file map.
GUIGlID getObjectUnderCursor()
returns the id of the front object under the cursor using GL_SELECT
GUIMainWindow * myApp
The application.
double m2p(double meter) const
meter-to-pixels conversion method
GUIVisualizationSettings * myVisualizationSettings
visualization settings
std::map< GUIGlObject *, int > myAdditionallyDrawn
List of objects for which GUIGlObject::drawGLAdditional is called.
void drawDecals()
Draws the stored decals.
A single child window which contains a view of the simulation area.
void clear()
Clears the list of selected objects.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
const std::set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
The class responsible for building and deletion of vehicles (gui-version)
void secureVehicles()
lock access to vehicle removal/additions for thread synchronization
void releaseVehicles()
unlock access to vehicle removal/additions for thread synchronization
A MSVehicle extended by some values for usage within the gui.
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
void rerouteDRTStop(MSStoppingPlace *busStop)
handle route to accomodate to given stop
A simple video encoder from RGBA pics to anything ffmpeg can handle.
long onCmdCloseEdge(FXObject *, FXSelector, void *)
long onCmdCloseLane(FXObject *, FXSelector, void *)
interaction with the simulation
void recalculateBoundaries()
recalculate boundaries
virtual ~GUIViewTraffic()
destructor
std::vector< std::string > getEdgeLaneParamKeys(bool edgeKeys) const
return list of available edge parameters
void onGamingRightClick(Position pos)
int doPaintGL(int mode, const Boundary &bound)
paint GL
SUMOTime getCurrentTimeStep() const
get the current simulation time
GUILane * getLaneUnderCursor()
void buildColorRainbow(const GUIVisualizationSettings &s, GUIColorScheme &scheme, int active, GUIGlObjectType objectType, bool hide=false, double hideThreshold=0)
recalibrate color scheme according to the current value range
void stopTrack()
Stops vehicle tracking.
void startTrack(int id)
Starts vehicle tracking.
void saveFrame(const std::string &destFile, FXColor *buf)
Adds a frame to a video snapshot which will be initialized if neccessary.
void endSnapshot()
Ends a video snapshot.
const std::vector< SUMOTime > retrieveBreakpoints() const
retrieve breakpoints from the current runThread
std::vector< std::string > getVehicleParamKeys(bool vTypeKeys) const
return list of available vehicle parameters
std::vector< std::string > getPOIParamKeys() const
return list of available POI parameters
long onCmdAddRerouter(FXObject *, FXSelector, void *)
void onGamingClick(Position pos)
handle mouse click in gaming mode
long onCmdShowReachability(FXObject *, FXSelector, void *)
highlight edges according to reachability
bool setColorScheme(const std::string &name)
set color scheme
long onDoubleClicked(FXObject *, FXSelector, void *)
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
virtual void buildViewToolBars(GUIGlChildWindow *)
builds the view toolbars
bool myTLSGame
whether game mode was set to 'tls'
void checkSnapshots()
Checks whether it is time for a snapshot.
GUIGlID getTrackedID() const
Returns the id of the tracked vehicle (-1 if none)
Stores the information about how to visualize structures.
static const double MISSING_DATA
static const std::string SCHEME_NAME_EDGEDATA_NUMERICAL
std::string name
The name of this setting.
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
bool gaming
whether the application is in gaming mode or not
bool showGrid
Information whether a grid shall be shown.
double scale
information about a lane's width (temporary, used for a single view)
GUIColorer laneColorer
The lane colorer.
static const std::string SCHEME_NAME_PERMISSION_CODE
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
A road/street connecting two junctions.
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is retured; should pro...
double getLength() const
return the length of the edge
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
The base class for an intersection.
Representation of a lane in the micro simulation.
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
MSEdge & getEdge() const
Returns the lane's edge.
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
ShapeContainer & getShapeContainer()
Returns the shapes container.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
SUMOTime duration
The duration of the phase.
A fixed traffic light logic.
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
virtual void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
A lane area vehicles can halt at.
double getEndLanePosition() const
Returns the end position of this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
Storage for all programs of a single tls.
std::vector< MSTrafficLightLogic * > getAllLogics() const
A class that stores and controls tls and switching of their programs.
std::vector< MSTrafficLightLogic * > getAllLogics() const
Returns a vector which contains all logics.
void switchTo(const std::string &id, const std::string &programID)
Switches the named (id) tls to the named (programID) program.
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
bool isActive(const MSTrafficLightLogic *tl) const
Returns whether the given tls program is the currently active for his tls.
The parent class for traffic light logics.
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
const std::string & getProgramID() const
Returns this tl-logic's id.
The class responsible for building and deletion of vehicles.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
MSLane * getMutableLane() const
Returns the lane the vehicle is on Non const version indicates that something volatile is going on.
const std::string & getID() const
Returns the id.
IDMap::const_iterator begin() const
Returns a reference to the begin iterator for the internal map.
IDMap::const_iterator end() const
Returns a reference to the end iterator for the internal map.
A storage for options typed value containers)
A point in 2D or 3D with translation and scaling methods.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
static const RGBColor BLUE
static const RGBColor YELLOW
static const RGBColor ORANGE
static const RGBColor CYAN
static const RGBColor GREEN
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
static const RGBColor MAGENTA
static const RGBColor RED
named colors
virtual int Search(const float a_min[2], const float a_max[2], const GUIVisualizationSettings &c) const
Find all within search rectangle.
std::string line
The vehicle's line (mainly for public transport)
Storage for geometrical objects.
struct for default values that depend of VClass
double maxSpeed
The vehicle type's maximum speed [m/s].