 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
86 GUINet& net, FXGLVisual* glVis,
90 myTLSGame(
OptionsCont::getOptions().getString("game.mode") == "tls")
92 , myCurrentVideo(
nullptr)
107 for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) {
117 "\tLocate Junction\tLocate a junction within the network.",
119 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
122 "\tLocate Street\tLocate a street within the network.",
124 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
128 "\tLocate Vehicle\tLocate a vehicle within the network.",
130 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
135 "\tLocate Vehicle\tLocate a person within the network.",
137 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
142 "\tLocate TLS\tLocate a tls within the network.",
144 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
147 "\tLocate Additional\tLocate an additional structure within the network.",
149 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
152 "\tLocate PoI\tLocate a PoI within the network.",
154 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
157 "\tLocate Polygon\tLocate a Polygon within the network.",
159 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
182 bool hide,
double hideThreshold) {
184 double minValue = std::numeric_limits<double>::infinity();
185 double maxValue = -std::numeric_limits<double>::infinity();
191 }
else if (active == 24) {
195 for (MSEdgeVector::const_iterator it = edges.begin(); it != edges.end(); ++it) {
198 minValue =
MIN2(minValue, val);
199 maxValue =
MAX2(maxValue, val);
201 const std::vector<MSLane*>& lanes = (*it)->getLanes();
202 for (std::vector<MSLane*>::const_iterator it_l = lanes.begin(); it_l != lanes.end(); it_l++) {
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;
240 if (minValue != std::numeric_limits<double>::infinity()) {
244 minValue =
MAX2(hideThreshold + 1, minValue);
247 double range = maxValue - minValue;
259 std::vector<std::string>
264 return std::vector<std::string>();
268 std::vector<std::string>
270 std::set<std::string> keys;
273 for (
const auto& item : e->getParametersMap()) {
274 keys.insert(item.first);
277 for (
const auto lane : e->getLanes()) {
278 for (
const auto& item : lane->getParametersMap()) {
279 keys.insert(item.first);
284 return std::vector<std::string>(keys.begin(), keys.end());
288 std::vector<std::string>
290 std::set<std::string> keys;
294 for (
auto kv : vehIt->second->getParameter().getParametersMap()) {
295 keys.insert(kv.first);
299 return std::vector<std::string>(keys.begin(), keys.end());
309 glMatrixMode(GL_MODELVIEW);
311 glDisable(GL_TEXTURE_2D);
312 glDisable(GL_ALPHA_TEST);
314 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
315 glEnable(GL_DEPTH_TEST);
326 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
327 const float minB[2] = { (float)bound.
xmin(), (float)bound.
ymin() };
328 const float maxB[2] = { (float)bound.
xmax(), (float)bound.
ymax() };
330 glEnable(GL_POLYGON_OFFSET_FILL);
331 glEnable(GL_POLYGON_OFFSET_LINE);
335 glTranslated(0, 0, -.01);
341 glTranslated(0, 0, .01);
380 double minDist = std::numeric_limits<double>::infinity();
382 if (tlsControl.
isActive(tll) && tll->getProgramID() !=
"off") {
385 if (lanes.size() > 0) {
386 const Position& endPos = lanes[0]->getShape().back();
394 if (minTll !=
nullptr) {
396 const std::vector<MSTrafficLightLogic*> logics = vars.
getAllLogics();
397 if (logics.size() > 1) {
399 for (
int i = 0; i < (int)logics.size() - 1; ++i) {
400 if (minTll->
getProgramID() == logics[i]->getProgramID()) {
405 if (l == logics[0]) {
418 if (sel.size() == 0) {
420 double minDist = std::numeric_limits<double>::infinity();
430 if (dist < minDist) {
436 if (closest !=
nullptr) {
442 double minDist = std::numeric_limits<double>::infinity();
445 for (
auto it = stops.
begin(); it != stops.
end(); ++it) {
448 if (dist < minDist) {
453 if (closestStop != 0) {
471 if (sel.size() > 0) {
496 return dynamic_cast<GUILane*
>(o);
507 if (lane !=
nullptr) {
519 if (lane !=
nullptr) {
531 if (lane !=
nullptr) {
543 if (lane !=
nullptr) {
548 for (
MSLane*
const l : e->getLanes()) {
554 FXMenuCommand* mc =
dynamic_cast<FXMenuCommand*
>(menu);
558 std::map<MSEdge*, double> reachableEdges;
559 reachableEdges[&lane->
getEdge()] = 0;
561 check.push_back(&lane->
getEdge());
562 while (check.size() > 0) {
563 MSEdge* e = check.front();
564 check.erase(check.begin());
565 double traveltime = reachableEdges[e];
567 if (l->allowsVehicleClass(svc)) {
575 if (reachableEdges.count(nextEdge) == 0 ||
577 reachableEdges[nextEdge] > traveltime) {
578 reachableEdges[nextEdge] = traveltime;
579 check.push_back(nextEdge);
609 if (myCurrentVideo ==
nullptr) {
612 myCurrentVideo->writeFrame((uint8_t*)buf);
623 if (myCurrentVideo !=
nullptr) {
624 delete myCurrentVideo;
625 myCurrentVideo =
nullptr;
634 if (myCurrentVideo !=
nullptr) {
642 const std::vector<SUMOTime>
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
@ MID_LOCATEPOI
Locate poi - button.
const MSLane & getLane() const
Returns the lane this stop is located at.
@ MID_LOCATETLS
Locate TLS - button.
#define UNUSED_PARAMETER(x)
std::string name
The name of this setting.
FXbool makeCurrent()
A reimplementation due to some internal reasons.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
virtual double getDelay() const
Returns the delay (should be overwritten by subclasses if applicable)
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
void endSnapshot()
Ends a video snapshot.
@ MID_CLOSE_EDGE
close edge
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
A lane area vehicles can halt at.
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is retured; should pro...
@ MID_LOCATEEDGE
Locate edge - button.
bool isActive(const MSTrafficLightLogic *tl) const
Returns whether the given tls program is the currently active for his tls.
Representation of a lane in the micro simulation.
A single child window which contains a view of the simulation area.
std::map< GUIGlObject *, int > myAdditionallyDrawn
List of objects for which GUIGlObject::drawGLAdditional is called.
double ymin() const
Returns minimum y-coordinate.
The base class for an intersection.
double getEndLanePosition() const
Returns the end position of this stop.
const std::string & getProgramID() const
Returns this tl-logic's id.
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
void stopTrack()
Stops vehicle tracking.
A simple video encoder from RGBA pics to anything ffmpeg can handle.
double m2p(double meter) const
meter-to-pixels conversion method
static const std::string SCHEME_NAME_PERMISSION_CODE
bool showGrid
Information whether a grid shall be shown.
static const RGBColor YELLOW
GUIGlID getObjectUnderCursor()
returns the id of the front object under the cursor using GL_SELECT
void rerouteDRTStop(MSStoppingPlace *busStop)
handle route to accomodate to given stop
static const RGBColor CYAN
std::vector< MSTrafficLightLogic * > getAllLogics() const
Returns a vector which contains all logics.
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
long onCmdCloseLane(FXObject *, FXSelector, void *)
interaction with the simulation
double xmax() const
Returns maximum x-coordinate.
void addSnapshot(SUMOTime time, const std::string &file, const int w=-1, const int h=-1)
Sets the snapshot time to file map.
GUILane * getLaneUnderCursor()
@ MID_REACHABILITY
show reachability from a given lane
void secureVehicles()
lock access to vehicle removal/additions for thread synchronization
const double SUMO_const_laneWidth
virtual void checkSnapshots()
Checks whether it is time for a snapshot.
The class responsible for building and deletion of vehicles (gui-version)
@ MID_LOCATEPERSON
Locate person - button.
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
double getLength() const
return the length of the edge
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
void onGamingClick(Position pos)
handle mouse click in gaming mode
virtual const std::vector< SUMOTime > retrieveBreakpoints() const
retrieve breakpoints if provided by the application
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
const std::vector< std::string > & getNames() const
Returns a list of stored settings names.
std::string line
The vehicle's line (mainly for public transport)
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
std::vector< MSTrafficLightLogic * > getAllLogics() const
SUMOTime duration
The duration of the phase.
static const RGBColor MAGENTA
static const GUIGlID INVALID_ID
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
bool isGaming() const
return whether the gui is in gaming mode
A map of named object pointers.
double xmin() const
Returns minimum x-coordinate.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
void setReachability(double value)
static const RGBColor ORANGE
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
GUIGlID getTrackedID() const
Returns the id of the tracked vehicle (-1 if none)
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
long onCmdShowReachability(FXObject *, FXSelector, void *)
highlight edges according to reachability
A MSVehicle extended by some values for usage within the gui.
double maxSpeed
The vehicle type's maximum speed [m/s].
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
IDMap::const_iterator begin() const
Returns a reference to the begin iterator for the internal map.
GUIGlID getGlID() const
Returns the numerical id of the object.
@ MID_ADD_REROUTER
add rerouter
A class that stores a 2D geometrical boundary.
static const RGBColor BLUE
double scale
information about a lane's width (temporary, used for a single view)
long onDoubleClicked(FXObject *, FXSelector, void *)
A point in 2D or 3D with translation and scaling methods.
GUICompleteSchemeStorage gSchemeStorage
A fixed traffic light logic.
const std::vector< SUMOTime > retrieveBreakpoints() const
retrieve breakpoints from the current runThread
static const RGBColor RED
named colors
A storage for options typed value containers)
A road/street connecting two junctions.
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
The parent class for traffic light logics.
GUIVisualizationSettings * myVisualizationSettings
visualization settings
void drawDecals()
Draws the stored decals.
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
bool setColorScheme(const std::string &name)
set color scheme
void lock()
grant exclusive access to the simulation state
virtual ~GUIViewTraffic()
destructor
MSLane * getLane() const
Returns the lane the vehicle is on.
void clear()
Clears the list of selected objects.
MSEdge & getEdge() const
Returns the lane's edge.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
std::vector< std::string > getEdgeLaneParamKeys(bool edgeKeys) const
return list of available edge parameters
void checkSnapshots()
Checks whether it is time for a snapshot.
@ VO_SHOW_FUTURE_ROUTE
show vehicle's current continued from the current position
void unblockObject(GUIGlID id)
Marks an object as unblocked.
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Representation of a lane in the micro simulation (gui-version)
@ SUMO_TAG_BUS_STOP
A bus stop.
void switchTo(const std::string &id, const std::string &programID)
Switches the named (id) tls to the named (programID) program.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
A road/street connecting two junctions (gui-version)
void setCurrentScheme(const std::string &)
Sets the named scheme as the current.
@ MID_LOCATEJUNCTION
Locate junction - button.
@ MID_CLOSE_LANE
close lane
FXDEFMAP(GUIViewTraffic) GUIViewTrafficMap[]
long onCmdCloseEdge(FXObject *, FXSelector, void *)
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
IDMap::const_iterator end() const
Returns a reference to the end iterator for the internal map.
virtual long onCmdFullScreen(FXObject *, FXSelector, void *)
Toggle full screen mode.
struct for default values that depend of VClass
GUIMainWindow * myApp
The application.
void releaseVehicles()
unlock access to vehicle removal/additions for thread synchronization
int doPaintGL(int mode, const Boundary &bound)
paint GL
std::vector< MSEdge * > MSEdgeVector
void unlock()
release exclusive access to the simulation state
const std::string & getName() const
virtual void buildViewToolBars(GUIGlChildWindow &)
builds the view toolbars
SUMORTree * myGrid
The visualization speed-up.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
void paintGLGrid()
paints a grid
GUISelectedStorage gSelected
A global holder of selected objects.
FXComboBox * getColoringSchemesCombo()
return combobox with the current coloring schemes (standard, fastest standard, real world....
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
@ MID_LOCATEVEHICLE
Locate vehicle - button.
bool myUseToolTips
use tool tips
Storage for all programs of a single tls.
int addColor(const T &color, const double threshold, const std::string &name="")
SUMOTime getCurrentTimeStep() const
get the current simulation time
virtual int Search(const float a_min[2], const float a_max[2], const GUIVisualizationSettings &c) const
Find all within search rectangle.
The class responsible for building and deletion of vehicles.
void saveFrame(const std::string &destFile, FXColor *buf)
Adds a frame to a video snapshot which will be initialized if neccessary.
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
GUIDialog_ViewSettings * myVisualizationChanger
Visualization changer.
GUIColorer laneColorer
The lane colorer.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
A class that stores and controls tls and switching of their programs.
static const RGBColor GREEN
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
bool myTLSGame
whether game mode was set to 'tls'
Stores the information about how to visualize structures.
const std::set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
@ MID_LOCATEPOLY
Locate polygons - button.
std::vector< std::string > getVehicleParamKeys(bool vTypeKeys) const
return list of available vehicle parameters
A MSNet extended by some values for usage within the gui.
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
void startTrack(int id)
Starts vehicle tracking.
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
bool contains(const std::string &name) const
Returns the information whether a setting with the given name is stored.
@ MID_LOCATEADD
Locate addtional structure - button.
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
bool gaming
whether the application is in gaming mode or not
const std::string & getID() const
Returns the id.
long onCmdAddRerouter(FXObject *, FXSelector, void *)
void setActive(int scheme)
GUIVisualizationSettings & get(const std::string &name)
Returns the named scheme.
FXPopup * getLocatorPopup()
@ brief return a pointer to locator popup
std::string getCurrentScheme() const
Returns the name of the currently chosen scheme.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
void onGamingRightClick(Position pos)
double ymax() const
Returns maximum y-coordinate.
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.