74 GUINet& net, FXGLVisual* glVis,
78 myTLSGame(
OptionsCont::getOptions().getString(
"game.mode") ==
"tls")
80 , myCurrentVideo(nullptr)
101 for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) {
111 "\tLocate Junctions\tLocate a junction within the network.",
113 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
116 "\tLocate Edges\tLocate an edge within the network.",
118 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
121 "\tLocate Vehicles\tLocate a vehicle within the network.",
123 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
126 "\tLocate Persons\tLocate a person within the network.",
128 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
131 "\tLocate Container\tLocate a container within the network.",
133 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
136 "\tLocate TLS\tLocate a tls within the network.",
138 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
141 "\tLocate Additional\tLocate an additional structure within the network.",
143 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
146 "\tLocate PoI\tLocate a PoI within the network.",
148 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
151 "\tLocate Polygon\tLocate a Polygon within the network.",
153 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
176 bool hide,
double hideThreshold,
bool hide2,
double hideThreshold2) {
178 double minValue = std::numeric_limits<double>::infinity();
179 double maxValue = -std::numeric_limits<double>::infinity();
181 bool hasMissingData =
false;
186 }
else if (active == 24) {
190 for (MSEdgeVector::const_iterator it = edges.begin(); it != edges.end(); ++it) {
194 hasMissingData =
true;
197 minValue =
MIN2(minValue, val);
198 maxValue =
MAX2(maxValue, val);
200 const std::vector<MSLane*>& lanes = (*it)->getLanes();
201 for (std::vector<MSLane*>::const_iterator it_l = lanes.begin(); it_l != lanes.end(); it_l++) {
204 hasMissingData =
true;
207 minValue =
MIN2(minValue, val);
208 maxValue =
MAX2(maxValue, val);
214 std::set<const MSJunction*> junctions;
216 junctions.insert(edge->getFromJunction());
217 junctions.insert(edge->getToJunction());
219 for (
const MSJunction* junction : junctions) {
220 minValue =
MIN2(minValue, junction->getPosition().z());
221 maxValue =
MAX2(maxValue, junction->getPosition().z());
228 std::set<SVCPermissions> codes;
230 for (
MSLane* lane : edge->getLanes()) {
231 codes.insert(lane->getPermissions());
234 int step =
MAX2(1, 360 / (
int)codes.size());
238 hue = (hue + step) % 360;
243 if (minValue != std::numeric_limits<double>::infinity()) {
251 scheme.
addColor(
RGBColor(204, 204, 204), std::numeric_limits<double>::max(),
"missing data");
254 const double rawRange = maxValue - minValue;
255 minValue =
MAX2(hideThreshold +
MIN2(1.0, rawRange / 100.0), minValue);
259 const double rawRange = maxValue - minValue;
260 maxValue =
MIN2(hideThreshold2 -
MIN2(1.0, rawRange / 100.0), maxValue);
263 double range = maxValue - minValue;
271 if (hasMissingData) {
278std::vector<std::string>
283 return std::vector<std::string>();
287std::vector<std::string>
292 return std::vector<std::string>();
295std::vector<std::string>
300 return std::vector<std::string>();
304std::vector<std::string>
306 std::set<std::string> keys;
309 for (
const auto& item : e->getParametersMap()) {
310 keys.insert(item.first);
313 for (
const auto lane : e->getLanes()) {
314 for (
const auto& item : lane->getParametersMap()) {
315 keys.insert(item.first);
320 return std::vector<std::string>(keys.begin(), keys.end());
324std::vector<std::string>
326 std::set<std::string> keys;
330 for (
auto kv : vehIt->second->getParameter().getParametersMap()) {
331 keys.insert(kv.first);
335 return std::vector<std::string>(keys.begin(), keys.end());
338std::vector<std::string>
340 std::set<std::string> keys;
342 for (
auto item : pois) {
343 for (
auto kv : item.second->getParametersMap()) {
344 keys.insert(kv.first);
347 return std::vector<std::string>(keys.begin(), keys.end());
356 glMatrixMode(GL_MODELVIEW);
358 glDisable(GL_TEXTURE_2D);
359 glDisable(GL_ALPHA_TEST);
361 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
362 glEnable(GL_DEPTH_TEST);
373 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
374 const float minB[2] = { (float)bound.
xmin(), (float)bound.
ymin() };
375 const float maxB[2] = { (float)bound.
xmax(), (float)bound.
ymax() };
376 glEnable(GL_POLYGON_OFFSET_FILL);
377 glEnable(GL_POLYGON_OFFSET_LINE);
381 glTranslated(0, 0, -.01);
387 glTranslated(0, 0, .01);
426 double minDist = std::numeric_limits<double>::infinity();
428 if (tlsControl.
isActive(tll) && tll->getProgramID() !=
"off") {
431 if (lanes.size() > 0) {
432 const Position& endPos = lanes[0]->getShape().back();
440 if (minTll !=
nullptr) {
451 if (sel.size() == 0) {
453 double minDist = std::numeric_limits<double>::infinity();
463 if (dist < minDist) {
469 if (closest !=
nullptr) {
475 double minDist = std::numeric_limits<double>::infinity();
478 for (
auto it = stops.
begin(); it != stops.
end(); ++it) {
481 if (dist < minDist) {
486 if (closestStop != 0) {
504 if (sel.size() > 0) {
525 if (lane !=
nullptr) {
537 if (lane !=
nullptr) {
549 if (lane !=
nullptr) {
560 if (lane !=
nullptr) {
562 const double UNREACHED = -1;
565 for (
MSLane*
const l : e->getLanes()) {
571 FXMenuCommand* mc =
dynamic_cast<FXMenuCommand*
>(menu);
575 std::map<MSEdge*, double> reachableEdges;
576 reachableEdges[&lane->
getEdge()] = 0;
578 check.push_back(&lane->
getEdge());
579 while (check.size() > 0) {
580 MSEdge* e = check.front();
581 check.erase(check.begin());
582 double traveltime = reachableEdges[e];
584 if (l->allowsVehicleClass(svc)) {
592 if (reachableEdges.count(nextEdge) == 0 ||
594 reachableEdges[nextEdge] > traveltime) {
595 reachableEdges[nextEdge] = traveltime;
596 check.push_back(nextEdge);
608 if (lane !=
nullptr) {
628 return dynamic_cast<GUILane*
>(o);
653 if (myCurrentVideo ==
nullptr) {
656 myCurrentVideo->writeFrame((uint8_t*)buf);
667 if (myCurrentVideo !=
nullptr) {
668 delete myCurrentVideo;
669 myCurrentVideo =
nullptr;
678 if (myCurrentVideo !=
nullptr) {
686const std::vector<SUMOTime>
@ MID_LOCATEPERSON
Locate person - button.
@ MID_LOCATEJUNCTION
Locate junction - button.
@ MID_LOCATEPOLY
Locate polygons - button.
@ MID_LOCATEADD
Locate additional structure - button.
@ MID_LOCATEPOI
Locate poi - button.
@ MID_LOCATEEDGE
Locate edge - button.
@ MID_LOCATEVEHICLE
Locate vehicle - button.
@ MID_LOCATETLS
Locate TLS - button.
@ MID_LOCATECONTAINER
Locate container - button.
GUICompleteSchemeStorage gSchemeStorage
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.
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 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 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
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.
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 *)
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)
static RGBColor COL_MISSING_DATA
GUIColorer laneColorer
The lane colorer.
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 & 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
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 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.
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
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)