77 GUINet& net, FXGLVisual* glVis,
81 myTLSGame(
OptionsCont::getOptions().getString(
"game.mode") ==
"tls")
83 , myCurrentVideo(nullptr)
104 for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) {
114 (std::string(
"\t") +
TL(
"Locate Junctions") + std::string(
"\t") +
TL(
"Locate a junction within the network.")).c_str(),
119 (std::string(
"\t") +
TL(
"Locate Edges") + std::string(
"\t") +
TL(
"Locate an edge within the network.")).c_str(),
124 (std::string(
"\t") +
TL(
"Locate Vehicles") + std::string(
"\t") +
TL(
"Locate a vehicle within the network.")).c_str(),
129 (std::string(
"\t") +
TL(
"Locate Persons") + std::string(
"\t") +
TL(
"Locate a person within the network.")).c_str(),
134 (std::string(
"\t") +
TL(
"Locate Container") + std::string(
"\t") +
TL(
"Locate a container within the network.")).c_str(),
139 (std::string(
"\t") +
TL(
"Locate TLS") + std::string(
"\t") +
TL(
"Locate a tls within the network.")).c_str(),
144 (std::string(
"\t") +
TL(
"Locate Additional") + std::string(
"\t") +
TL(
"Locate an additional structure within the network.")).c_str(),
149 (std::string(
"\t") +
TL(
"Locate PoI") + std::string(
"\t") +
TL(
"Locate a PoI within the network.")).c_str(),
154 (std::string(
"\t") +
TL(
"Locate Polygon") + std::string(
"\t") +
TL(
"Locate a Polygon within the network.")).c_str(),
179 bool hide,
double hideThreshold,
bool hide2,
double hideThreshold2) {
181 double minValue = std::numeric_limits<double>::infinity();
182 double maxValue = -std::numeric_limits<double>::infinity();
184 bool hasMissingData =
false;
189 }
else if (active == 24) {
193 for (MSEdgeVector::const_iterator it = edges.begin(); it != edges.end(); ++it) {
197 hasMissingData =
true;
200 minValue =
MIN2(minValue, val);
201 maxValue =
MAX2(maxValue, val);
203 const std::vector<MSLane*>& lanes = (*it)->getLanes();
204 for (std::vector<MSLane*>::const_iterator it_l = lanes.begin(); it_l != lanes.end(); it_l++) {
207 hasMissingData =
true;
210 minValue =
MIN2(minValue, val);
211 maxValue =
MAX2(maxValue, val);
217 std::set<const MSJunction*> junctions;
219 junctions.insert(edge->getFromJunction());
220 junctions.insert(edge->getToJunction());
222 for (
const MSJunction* junction : junctions) {
223 minValue =
MIN2(minValue, junction->getPosition().z());
224 maxValue =
MAX2(maxValue, junction->getPosition().z());
231 std::set<SVCPermissions> codes;
233 for (
MSLane* lane : edge->getLanes()) {
234 codes.insert(lane->getPermissions());
237 int step =
MAX2(1, 360 / (
int)codes.size());
241 hue = (hue + step) % 360;
246 if (hide && hide2 && minValue == std::numeric_limits<double>::infinity()) {
247 minValue = hideThreshold;
248 maxValue = hideThreshold2;
250 if (minValue != std::numeric_limits<double>::infinity()) {
262 const double rawRange = maxValue - minValue;
263 minValue =
MAX2(hideThreshold +
MIN2(1.0, rawRange / 100.0), minValue);
267 const double rawRange = maxValue - minValue;
268 maxValue =
MIN2(hideThreshold2 -
MIN2(1.0, rawRange / 100.0), maxValue);
271 double range = maxValue - minValue;
283std::vector<std::string>
288 return std::vector<std::string>();
292std::vector<std::string>
297 return std::vector<std::string>();
300std::vector<std::string>
305 return std::vector<std::string>();
309std::vector<std::string>
311 std::set<std::string> keys;
314 for (
const auto& item : e->getParametersMap()) {
315 keys.insert(item.first);
318 for (
const auto lane : e->getLanes()) {
319 for (
const auto& item : lane->getParametersMap()) {
320 keys.insert(item.first);
325 return std::vector<std::string>(keys.begin(), keys.end());
329std::vector<std::string>
331 std::set<std::string> keys;
335 for (
auto kv : vehIt->second->getParameter().getParametersMap()) {
336 keys.insert(kv.first);
340 return std::vector<std::string>(keys.begin(), keys.end());
343std::vector<std::string>
345 std::set<std::string> keys;
347 for (
auto item : pois) {
348 for (
auto kv : item.second->getParametersMap()) {
349 keys.insert(kv.first);
352 return std::vector<std::string>(keys.begin(), keys.end());
362 glMatrixMode(GL_MODELVIEW);
364 glDisable(GL_TEXTURE_2D);
365 glDisable(GL_ALPHA_TEST);
367 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
368 glEnable(GL_DEPTH_TEST);
379 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
380 const float minB[2] = { (float)bound.
xmin(), (float)bound.
ymin() };
381 const float maxB[2] = { (float)bound.
xmax(), (float)bound.
ymax() };
382 glEnable(GL_POLYGON_OFFSET_FILL);
383 glEnable(GL_POLYGON_OFFSET_LINE);
389 glTranslated(0, 0, -.01);
395 glTranslated(0, 0, .01);
441 double minDist = std::numeric_limits<double>::infinity();
443 if (tlsControl.
isActive(tll) && tll->getProgramID() !=
"off") {
446 if (lanes.size() > 0) {
447 const Position& endPos = lanes[0]->getShape().back();
455 if (minTll !=
nullptr) {
463 for (
auto& phase : minTll->
getPhases()) {
464 if (phase->isGreenPhase()) {
468 int nextPhase = (ci + 1) % n;
480 for (
int i = ci - 1; i != ci; i--) {
492 for (; numGreen < 2; i = (i + 1) % n) {
500 if (dur <= spentTransition) {
501 spentTransition -= dur;
504 nextDuration = dur - spentTransition;
519 if (sel.size() == 0) {
521 double minDist = std::numeric_limits<double>::infinity();
531 if (dist < minDist) {
537 if (closest !=
nullptr) {
543 double minDist = std::numeric_limits<double>::infinity();
546 for (
auto it = stops.
begin(); it != stops.
end(); ++it) {
549 if (dist < minDist) {
554 if (closestStop != 0) {
572 if (sel.size() > 0) {
593 if (lane !=
nullptr) {
605 if (lane !=
nullptr) {
617 if (lane !=
nullptr) {
628 if (lane !=
nullptr) {
633 for (
MSLane*
const l : e->getLanes()) {
639 FXMenuCommand* mc =
dynamic_cast<FXMenuCommand*
>(menu);
643 std::map<MSEdge*, double> reachableEdges;
644 reachableEdges[&lane->
getEdge()] = 0;
646 check.push_back(&lane->
getEdge());
647 while (check.size() > 0) {
648 MSEdge* e = check.front();
649 check.erase(check.begin());
650 double traveltime = reachableEdges[e];
652 if (l->allowsVehicleClass(svc)) {
660 traveltime +=
MAX2(dt, NUMERICAL_EPS);
662 if (reachableEdges.count(nextEdge) == 0 ||
664 reachableEdges[nextEdge] > traveltime) {
665 reachableEdges[nextEdge] = traveltime;
666 check.push_back(nextEdge);
672 if (prevEdge->allowedLanes(*e, svc) !=
nullptr &&
673 (reachableEdges.count(prevEdge) == 0 ||
675 reachableEdges[prevEdge] > traveltime)) {
676 reachableEdges[prevEdge] = traveltime;
677 check.push_back(prevEdge);
691 if (lane !=
nullptr) {
711 return dynamic_cast<GUILane*
>(o);
736 if (myCurrentVideo ==
nullptr) {
739 myCurrentVideo->writeFrame((uint8_t*)buf);
750 if (myCurrentVideo !=
nullptr) {
751 delete myCurrentVideo;
752 myCurrentVideo =
nullptr;
761 if (myCurrentVideo !=
nullptr) {
769const std::vector<SUMOTime>
@ MID_HOTKEY_SHIFT_O_LOCATEPOI
Locate poi - button.
@ MID_HOTKEY_SHIFT_A_LOCATEADDITIONAL
Locate additional structure - button.
@ MID_HOTKEY_SHIFT_C_LOCATECONTAINER
Locate container - button.
@ MID_HOTKEY_SHIFT_V_LOCATEVEHICLE
Locate vehicle - button.
@ MID_HOTKEY_SHIFT_L_LOCATEPOLY
Locate polygons - button.
@ MID_HOTKEY_SHIFT_E_LOCATEEDGE
Locate edge - button.
@ MID_HOTKEY_SHIFT_P_LOCATEPERSON
Locate person - button.
@ MID_HOTKEY_SHIFT_J_LOCATEJUNCTION
Locate junction - button.
@ MID_HOTKEY_SHIFT_T_LOCATETLS
Locate TLS - button.
GUICompleteSchemeStorage gSchemeStorage
#define GUIDesignButtonPopup
checkable button placed in popup (for example, locate buttons)
GUISelectedStorage gSelected
A global holder of selected objects.
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.
@ SVC_PEDESTRIAN
pedestrian
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 INVALID_DOUBLE
invalid double
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
A MSVehicle extended by some values for usage within the gui.
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_TRACK
track the vehicle (only needed for cleaning up)
@ 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 override
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.
GUIGlObject * getObjectBlocking(GUIGlID id) const
Returns the object from the container locking it.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
static bool gSecondaryShape
whether secondary shapes are currently being drawn
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)
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
virtual const std::vector< SUMOTime > retrieveBreakpoints() const
retrieve breakpoints if provided by the application
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
MFXStaticToolTip * getStaticTooltipMenu() const
get static toolTip for menus
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
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
std::vector< std::string > getMeanDataIDs() const
return list of loaded edgeData ids (being computed in the current simulation)
void lock()
grant exclusive access to the simulation state
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
std::vector< std::string > getMeanDataAttrs(const std::string &meanDataID) const
return list of available attributes for the given meanData id
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.
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
GUIDialog_ViewSettings * myGUIDialogViewSettings
Visualization changer.
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 notifyChanged()
inform the update target of earlier changes
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 *)
void buildColorRainbow(const GUIVisualizationSettings &s, GUIColorScheme &scheme, int active, GUIGlObjectType objectType, bool hide=false, double hideThreshold=0, bool hide2=false, double hideThreshold2=0)
recalibrate color scheme according to the current value range
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()
returns the GUILane at cursor position (implementation depends on view)
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.
std::vector< std::string > getMeanDataIDs() const
return list of loaded edgeData ids (being computed in the current simulation)
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 *)
static long showLaneReachability(GUILane *lane, FXObject *, FXSelector)
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 > getMeanDataAttrs(const std::string &meanDataID) const
return list of available attributes for the given meanData id
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 std::string SCHEME_NAME_DATA_ATTRIBUTE_NUMERICAL
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
static const std::string SCHEME_NAME_LANE_PARAM_NUMERICAL
bool showGrid
Information whether a grid shall be shown.
double scale
information about a lane's width (temporary, used for a single view)
bool secondaryShape
whether secondary lane shape shall be drawn
static RGBColor COL_MISSING_DATA
GUIColorer laneColorer
The lane colorer.
bool forceDrawForPositionSelection
flag to force draw for position selection (see drawForPositionSelection)
static const std::string SCHEME_NAME_EDGE_PARAM_NUMERICAL
scheme names
static const std::string SCHEME_NAME_PERMISSION_CODE
static const std::string SCHEME_NAME_PARAM_NUMERICAL
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 & getPredecessors() const
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.
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
MSEdge & getEdge() const
Returns the lane's edge.
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.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
ShapeContainer & getShapeContainer()
Returns the shapes container.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
SUMOTime duration
The duration of the phase.
bool isGreenPhase() const
Returns whether this phase is a pure "green" phase.
bool isAllRedPhase() const
Returns whether this phase is an "all red" phase.
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.
A class that stores and controls tls and switching of their programs.
std::vector< MSTrafficLightLogic * > getAllLogics() const
Returns a vector which contains all logics.
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.
virtual const MSPhaseDefinition & getCurrentPhaseDef() const =0
Returns the definition of the current phase.
virtual int getPhaseNumber() const =0
Returns the number of phases.
virtual int getCurrentPhaseIndex() const =0
Returns the current index within the program.
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
virtual void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)=0
Changes the current phase and her duration.
virtual const MSPhaseDefinition & getPhase(int givenstep) const =0
Returns the definition of the phase from the given position within the plan.
virtual const Phases & getPhases() const =0
Returns the phases of this tls program.
SUMOTime getSpentDuration(SUMOTime simStep=-1) const
Returns the duration spent in the current phase.
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.
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
A RT-tree for efficient storing of SUMO's GL-objects.
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] (technical limit, not subject to speed deviation)