78 GUINet& net, FXGLVisual* glVis,
82 myTLSGame(
OptionsCont::getOptions().getString(
"game.mode") ==
"tls")
84 , myCurrentVideo(nullptr)
99 for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) {
108 (std::string(
"\t") +
TL(
"Locate Junctions") + std::string(
"\t") +
TL(
"Locate a junction within the network.")).c_str(),
113 (std::string(
"\t") +
TL(
"Locate Edges") + std::string(
"\t") +
TL(
"Locate an edge within the network.")).c_str(),
118 (std::string(
"\t") +
TL(
"Locate Vehicles") + std::string(
"\t") +
TL(
"Locate a vehicle within the network.")).c_str(),
123 (std::string(
"\t") +
TL(
"Locate Persons") + std::string(
"\t") +
TL(
"Locate a person within the network.")).c_str(),
128 (std::string(
"\t") +
TL(
"Locate Container") + std::string(
"\t") +
TL(
"Locate a container within the network.")).c_str(),
133 (std::string(
"\t") +
TL(
"Locate TLS") + std::string(
"\t") +
TL(
"Locate a tls within the network.")).c_str(),
138 (std::string(
"\t") +
TL(
"Locate Additional") + std::string(
"\t") +
TL(
"Locate an additional structure within the network.")).c_str(),
143 (std::string(
"\t") +
TL(
"Locate PoI") + std::string(
"\t") +
TL(
"Locate a PoI within the network.")).c_str(),
148 (std::string(
"\t") +
TL(
"Locate Polygon") + std::string(
"\t") +
TL(
"Locate a Polygon within the network.")).c_str(),
175 double minValue = std::numeric_limits<double>::infinity();
176 double maxValue = -std::numeric_limits<double>::infinity();
178 bool hasMissingData =
false;
183 }
else if (active == 24) {
187 for (MSEdgeVector::const_iterator it = edges.begin(); it != edges.end(); ++it) {
191 hasMissingData =
true;
194 minValue =
MIN2(minValue, val);
195 maxValue =
MAX2(maxValue, val);
197 const std::vector<MSLane*>& lanes = (*it)->getLanes();
198 for (std::vector<MSLane*>::const_iterator it_l = lanes.begin(); it_l != lanes.end(); it_l++) {
201 hasMissingData =
true;
204 minValue =
MIN2(minValue, val);
205 maxValue =
MAX2(maxValue, val);
211 std::set<const MSJunction*> junctions;
213 junctions.insert(edge->getFromJunction());
214 junctions.insert(edge->getToJunction());
216 for (
const MSJunction* junction : junctions) {
217 minValue =
MIN2(minValue, junction->getPosition().z());
218 maxValue =
MAX2(maxValue, junction->getPosition().z());
225 std::set<SVCPermissions> codes;
227 for (
MSLane* lane : edge->getLanes()) {
228 codes.insert(lane->getPermissions());
231 int step =
MAX2(1, 360 / (
int)codes.size());
235 hue = (hue + step) % 360;
243std::vector<std::string>
248 return std::vector<std::string>();
252std::vector<std::string>
257 return std::vector<std::string>();
260std::vector<std::string>
265 return std::vector<std::string>();
269std::vector<std::string>
271 std::set<std::string> keys;
274 for (
const auto& item : e->getParametersMap()) {
275 keys.insert(item.first);
278 for (
const auto lane : e->getLanes()) {
279 for (
const auto& item : lane->getParametersMap()) {
280 keys.insert(item.first);
285 return std::vector<std::string>(keys.begin(), keys.end());
289std::vector<std::string>
291 std::set<std::string> keys;
295 for (
auto kv : vehIt->second->getParameter().getParametersMap()) {
296 keys.insert(kv.first);
300 return std::vector<std::string>(keys.begin(), keys.end());
303std::vector<std::string>
305 std::set<std::string> keys;
307 for (
auto item : pois) {
308 for (
auto kv : item.second->getParametersMap()) {
309 keys.insert(kv.first);
312 return std::vector<std::string>(keys.begin(), keys.end());
319 glMatrixMode(GL_MODELVIEW);
321 glDisable(GL_TEXTURE_2D);
322 glDisable(GL_ALPHA_TEST);
324 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
325 glEnable(GL_DEPTH_TEST);
334 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
335 const float minB[2] = { (float)bound.
xmin(), (float)bound.
ymin() };
336 const float maxB[2] = { (float)bound.
xmax(), (float)bound.
ymax() };
337 glEnable(GL_POLYGON_OFFSET_FILL);
338 glEnable(GL_POLYGON_OFFSET_LINE);
344 glTranslated(0, 0, -.01);
350 glTranslated(0, 0, .01);
396 double minDist = std::numeric_limits<double>::infinity();
398 if (tlsControl.
isActive(tll) && tll->getProgramID() !=
"off") {
401 if (lanes.size() > 0) {
402 const Position& endPos = lanes[0]->getShape().back();
410 if (minTll !=
nullptr) {
418 for (
auto& phase : minTll->
getPhases()) {
419 if (phase->isGreenPhase()) {
423 int nextPhase = (ci + 1) % n;
435 for (
int i = ci - 1; i != ci; i--) {
447 for (; numGreen < 2; i = (i + 1) % n) {
455 if (dur <= spentTransition) {
456 spentTransition -= dur;
459 nextDuration = dur - spentTransition;
474 if (sel.size() == 0) {
476 double minDist = std::numeric_limits<double>::infinity();
486 if (dist < minDist) {
492 if (closest !=
nullptr) {
498 double minDist = std::numeric_limits<double>::infinity();
501 for (
auto it = stops.
begin(); it != stops.
end(); ++it) {
504 if (dist < minDist) {
509 if (closestStop != 0) {
527 if (sel.size() > 0) {
548 if (lane !=
nullptr) {
560 if (lane !=
nullptr) {
572 if (lane !=
nullptr) {
583 if (lane !=
nullptr) {
588 for (
MSLane*
const l : e->getLanes()) {
594 FXMenuCommand* mc =
dynamic_cast<FXMenuCommand*
>(menu);
598 std::map<MSEdge*, double> reachableEdges;
599 reachableEdges[&lane->
getEdge()] = 0;
601 check.push_back(&lane->
getEdge());
602 while (check.size() > 0) {
603 MSEdge* e = check.front();
604 check.erase(check.begin());
605 double traveltime = reachableEdges[e];
607 if (l->allowsVehicleClass(svc)) {
615 traveltime +=
MAX2(dt, NUMERICAL_EPS);
617 if (reachableEdges.count(nextEdge) == 0 ||
619 reachableEdges[nextEdge] > traveltime) {
620 reachableEdges[nextEdge] = traveltime;
621 check.push_back(nextEdge);
627 if (prevEdge->allowedLanes(*e, svc) !=
nullptr &&
628 (reachableEdges.count(prevEdge) == 0 ||
630 reachableEdges[prevEdge] > traveltime)) {
631 reachableEdges[prevEdge] = traveltime;
632 check.push_back(prevEdge);
646 if (lane !=
nullptr) {
666 return dynamic_cast<GUILane*
>(o);
691 if (myCurrentVideo ==
nullptr) {
694 myCurrentVideo->writeFrame((uint8_t*)buf);
705 if (myCurrentVideo !=
nullptr) {
706 delete myCurrentVideo;
707 myCurrentVideo =
nullptr;
716 if (myCurrentVideo !=
nullptr) {
724const std::vector<SUMOTime>
745 for (
auto polygonwithID : shapeContainer.
getPolygons()) {
746 if (polygonwithID.second->getShapeType() ==
"jupedsim.pedestrian_network") {
@ 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)
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_PEDESTRIAN
pedestrian
@ 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
MFXComboBoxIcon * 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)
virtual void checkSnapshots()
Checks whether it is time for a snapshot.
void paintGLGrid() const
paints a grid
FXbool makeCurrent()
A reimplementation due to some internal reasons.
void buildMinMaxRainbow(const GUIVisualizationSettings &s, GUIColorScheme &scheme, const GUIVisualizationRainbowSettings &rs, double minValue, double maxValue, bool hasMissingData)
helper function for buildColorRainbow
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::unordered_set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
Storage for geometrical objects extended by mutexes.
void removeInactivePolygonTypes(std::set< std::string > inactivePolygonTypes)
Remove some polygon types that were deemed as inactive.
void addInactivePolygonTypes(std::set< std::string > inactivePolygonTypes)
Adds new polygon types to the set of inactive ones.
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.
void saveFrame(const std::string &destFile, FXColor *buf) override
Adds a frame to a video snapshot which will be initialized if necessary.
SUMOTime getCurrentTimeStep() const override
get the current simulation time
std::vector< std::string > getVehicleParamKeys(bool vTypeKeys) const override
return list of available vehicle parameters
virtual void buildViewToolBars(GUIGlChildWindow *) override
builds the view toolbars
std::vector< std::string > getMeanDataIDs() const override
return list of loaded edgeData ids (being computed in the current simulation)
virtual ~GUIViewTraffic()
destructor
long onCmdCloseLane(FXObject *, FXSelector, void *) override
interaction with the simulation
std::vector< std::string > getMeanDataAttrs(const std::string &meanDataID) const override
return list of available attributes for the given meanData id
void stopTrack() override
Stops vehicle tracking.
int doPaintGL(int mode, const Boundary &bound) override
paint GL
GUIGlID getTrackedID() const override
Returns the id of the tracked vehicle (-1 if none)
std::vector< std::string > getPOIParamKeys() const override
return list of available POI parameters
long onCmdCloseEdge(FXObject *, FXSelector, void *) override
void onGamingClick(Position pos) override
handle mouse click in gaming mode
void endSnapshot() override
Ends a video snapshot.
long onCmdShowReachability(FXObject *, FXSelector, void *) override
highlight edges according to reachability
void drawPedestrianNetwork(const GUIVisualizationSettings &s) const override
Draw (or not) the JuPedSim pedestrian network.
void checkSnapshots() override
Checks whether it is time for a snapshot.
bool setColorScheme(const std::string &name) override
set color scheme
const std::vector< SUMOTime > retrieveBreakpoints() const override
retrieve breakpoints from the current runThread
GUILane * getLaneUnderCursor() override
returns the GUILane at cursor position (implementation depends on view)
void buildColorRainbow(const GUIVisualizationSettings &s, GUIColorScheme &scheme, int active, GUIGlObjectType objectType, const GUIVisualizationRainbowSettings &rs) override
recalibrate color scheme according to the current value range
void startTrack(int id) override
Starts vehicle tracking.
long onDoubleClicked(FXObject *, FXSelector, void *) override
std::vector< std::string > getEdgeDataAttrs() const override
return list of loaded edgeData attributes
static long showLaneReachability(GUILane *lane, FXObject *, FXSelector)
long onCmdAddRerouter(FXObject *, FXSelector, void *) override
std::vector< std::string > getEdgeLaneParamKeys(bool edgeKeys) const override
return list of available edge parameters
void changePedestrianNetworkColor(const GUIVisualizationSettings &s) const override
Change the color of the JuPedSim pedestrian network.
bool myTLSGame
whether game mode was set to 'tls'
void onGamingRightClick(Position pos) override
Stores the information about how to visualize structures.
bool showPedestrianNetwork
Flag for visualizing the pedestrian network generated for JuPedSim.
static const double MISSING_DATA
std::string name
The name of this setting.
RGBColor pedestrianNetworkColor
The color of the pedestrian network generated for JuPedSim.
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)
bool secondaryShape
whether secondary lane shape shall be drawn
GUIColorer laneColorer
The lane colorer.
static const std::string SCHEME_NAME_PERMISSION_CODE
long setCurrentItem(const FXint index, FXbool notify=FALSE)
Set the current item (index is zero-based)
FXint getNumItems() const
Return the number of items in the list.
FXint appendIconItem(const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append icon item in the last position
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 dimensions
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
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.
const Polygons & getPolygons() const
Returns all polygons.
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)