87 GUINet& net, FXGLVisual* glVis,
91 myTLSGame(
OptionsCont::getOptions().getString("game.mode") == "tls")
93 , myCurrentVideo(
nullptr)
108 for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) {
118 "\tLocate Junctions\tLocate a junction within the network.",
120 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
123 "\tLocate Edges\tLocate an edge within the network.",
125 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
128 "\tLocate Vehicles\tLocate a vehicle within the network.",
130 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
133 "\tLocate Persons\tLocate a person within the network.",
135 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
138 "\tLocate Container\tLocate a container within the network.",
140 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
143 "\tLocate TLS\tLocate a tls within the network.",
145 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
148 "\tLocate Additional\tLocate an additional structure within the network.",
150 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
153 "\tLocate PoI\tLocate a PoI within the network.",
155 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
158 "\tLocate Polygon\tLocate a Polygon within the network.",
160 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
183 bool hide,
double hideThreshold) {
185 double minValue = std::numeric_limits<double>::infinity();
186 double maxValue = -std::numeric_limits<double>::infinity();
192 }
else if (active == 24) {
196 for (MSEdgeVector::const_iterator it = edges.begin(); it != edges.end(); ++it) {
202 minValue =
MIN2(minValue, val);
203 maxValue =
MAX2(maxValue, val);
205 const std::vector<MSLane*>& lanes = (*it)->getLanes();
206 for (std::vector<MSLane*>::const_iterator it_l = lanes.begin(); it_l != lanes.end(); it_l++) {
211 minValue =
MIN2(minValue, val);
212 maxValue =
MAX2(maxValue, val);
218 std::set<const MSJunction*> junctions;
220 junctions.insert(edge->getFromJunction());
221 junctions.insert(edge->getToJunction());
223 for (
const MSJunction* junction : junctions) {
224 minValue =
MIN2(minValue, junction->getPosition().z());
225 maxValue =
MAX2(maxValue, junction->getPosition().z());
232 std::set<SVCPermissions> codes;
234 for (
MSLane* lane : edge->getLanes()) {
235 codes.insert(lane->getPermissions());
238 int step =
MAX2(1, 360 / (
int)codes.size());
242 hue = (hue + step) % 360;
247 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);
258 double range = maxValue - minValue;
270 std::vector<std::string>
275 return std::vector<std::string>();
279 std::vector<std::string>
281 std::set<std::string> keys;
284 for (
const auto& item : e->getParametersMap()) {
285 keys.insert(item.first);
288 for (
const auto lane : e->getLanes()) {
289 for (
const auto& item : lane->getParametersMap()) {
290 keys.insert(item.first);
295 return std::vector<std::string>(keys.begin(), keys.end());
299 std::vector<std::string>
301 std::set<std::string> keys;
305 for (
auto kv : vehIt->second->getParameter().getParametersMap()) {
306 keys.insert(kv.first);
310 return std::vector<std::string>(keys.begin(), keys.end());
313 std::vector<std::string>
315 std::set<std::string> keys;
317 for (
auto item : pois) {
318 for (
auto kv : item.second->getParametersMap()) {
319 keys.insert(kv.first);
322 return std::vector<std::string>(keys.begin(), keys.end());
331 glMatrixMode(GL_MODELVIEW);
333 glDisable(GL_TEXTURE_2D);
334 glDisable(GL_ALPHA_TEST);
336 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
337 glEnable(GL_DEPTH_TEST);
347 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
348 const float minB[2] = { (float)bound.
xmin(), (float)bound.
ymin() };
349 const float maxB[2] = { (float)bound.
xmax(), (float)bound.
ymax() };
351 glEnable(GL_POLYGON_OFFSET_FILL);
352 glEnable(GL_POLYGON_OFFSET_LINE);
356 glTranslated(0, 0, -.01);
362 glTranslated(0, 0, .01);
401 double minDist = std::numeric_limits<double>::infinity();
403 if (tlsControl.
isActive(tll) && tll->getProgramID() !=
"off") {
406 if (lanes.size() > 0) {
407 const Position& endPos = lanes[0]->getShape().back();
415 if (minTll !=
nullptr) {
417 const std::vector<MSTrafficLightLogic*> logics = vars.
getAllLogics();
418 if (logics.size() > 1) {
420 for (
int i = 0; i < (int)logics.size() - 1; ++i) {
421 if (minTll->
getProgramID() == logics[i]->getProgramID()) {
426 if (l == logics[0]) {
439 if (sel.size() == 0) {
441 double minDist = std::numeric_limits<double>::infinity();
451 if (dist < minDist) {
457 if (closest !=
nullptr) {
463 double minDist = std::numeric_limits<double>::infinity();
466 for (
auto it = stops.
begin(); it != stops.
end(); ++it) {
469 if (dist < minDist) {
474 if (closestStop != 0) {
492 if (sel.size() > 0) {
517 return dynamic_cast<GUILane*
>(o);
528 if (lane !=
nullptr) {
540 if (lane !=
nullptr) {
552 if (lane !=
nullptr) {
564 if (lane !=
nullptr) {
569 for (
MSLane*
const l : e->getLanes()) {
575 FXMenuCommand* mc =
dynamic_cast<FXMenuCommand*
>(menu);
579 std::map<MSEdge*, double> reachableEdges;
580 reachableEdges[&lane->
getEdge()] = 0;
582 check.push_back(&lane->
getEdge());
583 while (check.size() > 0) {
584 MSEdge* e = check.front();
585 check.erase(check.begin());
586 double traveltime = reachableEdges[e];
588 if (l->allowsVehicleClass(svc)) {
596 if (reachableEdges.count(nextEdge) == 0 ||
598 reachableEdges[nextEdge] > traveltime) {
599 reachableEdges[nextEdge] = traveltime;
600 check.push_back(nextEdge);
630 if (myCurrentVideo ==
nullptr) {
633 myCurrentVideo->writeFrame((uint8_t*)buf);
644 if (myCurrentVideo !=
nullptr) {
645 delete myCurrentVideo;
646 myCurrentVideo =
nullptr;
655 if (myCurrentVideo !=
nullptr) {
663 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.
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
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
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
std::string name
The name of this setting.
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.
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].