64 #include <mesogui/GUIMEVehicleControl.h> 65 #include <mesogui/GUIMEVehicle.h> 66 #include <mesosim/MESegment.h> 67 #include <mesosim/MELoop.h> 68 #include <mesosim/MEVehicle.h> 71 #ifdef CHECK_MEMORY_LEAKS 73 #endif // CHECK_MEMORY_LEAKS 81 const std::string& streetName,
const std::string& edgeType,
int priority)
82 :
MSEdge(id, numericalID, function, streetName, edgeType, priority),
96 assert(laneNo < myLanes->size());
97 return *((*myLanes)[laneNo]);
103 std::vector<GUIGlID> ret;
109 ret.push_back(edge->
getGlID());
120 const MSEdge* edge = i->second;
133 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
134 ret.
add((*i)->getShape().getBoxBoundary());
144 netsWrappers.reserve(size);
145 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
147 netsWrappers.push_back(static_cast<GUIEdge*>((*i).second));
165 new FXMenuCommand(ret, (
"pos: " +
toString(pos)).c_str(), 0, 0, 0);
179 ret->
mkItem(
"allowed speed [m/s]",
false, getAllowedSpeed());
184 ret->
mkItem(
"vehicle ids",
false, getVehicleIDs());
187 ret->
mkItem(
"segment index",
false, segment->getIndex());
188 ret->
mkItem(
"segment length [m]",
false, segment->getLength());
189 ret->
mkItem(
"segment allowed speed [m/s]",
false, segment->getMaxSpeed());
190 ret->
mkItem(
"segment jam threshold [%]",
false, segment->getRelativeJamThreshold());
222 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
246 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawStreetName) {
249 if (lane1 != 0 && lane2 != 0) {
255 if (angle > 90 && angle < 270) {
260 }
else if (drawInternalEdgeName) {
262 }
else if (drawCwaEdgeName) {
265 if (drawStreetName) {
273 for (std::set<MSTransportable*>::const_iterator i =
myPersons.begin(); i !=
myPersons.end(); ++i) {
284 assert(container != 0);
298 if (vehicleControl != 0) {
300 vehicleControl->secureVehicles();
301 size_t laneIndex = 0;
302 MESegment::Queue queue;
303 for (std::vector<MSLane*>::const_iterator msl =
myLanes->begin(); msl !=
myLanes->end(); ++msl, ++laneIndex) {
307 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this);
308 segment != 0; segment = segment->getNextSegment()) {
309 const SUMOReal length = segment->getLength();
310 if (laneIndex < segment->numQueues()) {
312 queue = segment->getQueue(laneIndex);
313 const SUMOReal avgCarSize = segment->getBruttoOccupancy() / segment->getCarNumber();
314 const size_t queueSize = queue.size();
315 SUMOReal vehiclePosition = segmentOffset + length;
318 for (
size_t i = 0; i < queueSize; ++i) {
319 GUIMEVehicle* veh =
static_cast<GUIMEVehicle*
>(queue[queueSize - i - 1]);
320 const SUMOReal vehLength = veh->getVehicleType().getLengthWithGap();
321 while (vehiclePosition < segmentOffset) {
325 vehiclePosition += length;
330 veh->setPositionAndAngle(p, angle);
332 vehiclePosition -= vehLength;
335 segmentOffset += length;
339 vehicleControl->releaseVehicles();
346 GUIEdge::getVehicleNo()
const {
348 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
349 vehNo += segment->getCarNumber();
351 return (
unsigned int)vehNo;
356 GUIEdge::getVehicleIDs()
const {
357 std::string result =
" ";
358 std::vector<const MEVehicle*> vehs;
359 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
360 std::vector<const MEVehicle*> segmentVehs = segment->getVehicles();
361 vehs.insert(vehs.end(), segmentVehs.begin(), segmentVehs.end());
363 for (std::vector<const MEVehicle*>::const_iterator it = vehs.begin(); it != vehs.end(); it++) {
364 result += (*it)->getID() +
" ";
371 GUIEdge::getFlow()
const {
373 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
374 flow += (
SUMOReal) segment->getCarNumber() * segment->getMeanSpeed();
376 return 3600 * flow / (*myLanes)[0]->getLength();
381 GUIEdge::getBruttoOccupancy()
const {
383 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
384 occ += segment->getBruttoOccupancy();
391 GUIEdge::getMeanSpeed()
const {
394 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
396 v += vehNo * segment->getMeanSpeed();
407 GUIEdge::getAllowedSpeed()
const {
408 return (*
myLanes)[0]->getSpeedLimit();
413 GUIEdge::getRelativeSpeed()
const {
414 return getMeanSpeed() / getAllowedSpeed();
420 GLHelper::setColor(s.edgeColorer.getScheme().getColor(getColorValue(s.edgeColorer.getActive())));
425 GUIEdge::getColorValue(
size_t activeScheme)
const {
426 switch (activeScheme) {
432 return getAllowedSpeed();
434 return getBruttoOccupancy();
436 return getMeanSpeed();
440 return getRelativeSpeed();
447 GUIEdge::getScaleValue(
size_t activeScheme)
const {
448 switch (activeScheme) {
452 return getAllowedSpeed();
454 return getBruttoOccupancy();
456 return getMeanSpeed();
460 return getRelativeSpeed();
467 GUIEdge::getSegmentAtPosition(
const Position& pos) {
470 return MSGlobals::gMesoNet->getSegmentForEdge(*
this, lanePos);
479 const std::vector<MSLane*>& lanes =
getLanes();
480 const bool isClosed = lane->
isClosed();
481 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
494 edges.push_back(
this);
505 const std::vector<MSLane*>& lanes =
getLanes();
506 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
508 for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
509 if ((*v)->getLane() == (*i)) {
513 (*i)->releaseVehicles();
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
std::set< MSTransportable * > myContainers
Containers on the edge.
GUIVisualizationTextSettings streetName
Reroutes vehicles passing an edge One rerouter can be active on multiple edges. To reduce drawing loa...
SUMOReal rotationAtOffset(SUMOReal pos) const
Returns the rotation at the given length.
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void add(const Position &pos)
Adds the given position to this one.
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
const Position geometryPositionAtOffset(SUMOReal offset) const
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
RandomDistributor< MSEdge * > edgeProbs
The distributions of new destinations to use.
The vehicle arrived at a junction.
bool add(SUMOReal prob, T val, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
Stores the information about how to visualize structures.
const EdgeBasicFunction myFunction
the purpose of the edge
std::vector< MSVehicle * > VehCont
Container for vehicles.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
GUIVisualizationTextSettings vehicleName
const std::string & getStreetName() const
Returns the street name of the edge.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
The edge is a macroscopic connector (source/sink)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
GUIVisualizationTextSettings cwaEdgeName
static void drawText(const std::string &text, const Position &pos, const SUMOReal layer, const SUMOReal size, const RGBColor &col=RGBColor::BLACK, const SUMOReal angle=0)
draw Text with given parameters
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
EdgeBasicFunction
Defines possible edge types.
static SUMOReal getTotalLength(bool includeInternal, bool eachLane)
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used, also builds an entry for copying the geo-position.
GUIGlID getGlID() const
Returns the numerical id of the object.
#define UNUSED_PARAMETER(x)
A class that stores a 2D geometrical boundary.
SUMOReal scale
information about a lane's width (temporary, used for a single view)
Representation of a lane in the micro simulation (gui-version)
GUIVisualizationTextSettings edgeName
A road/street connecting two junctions (gui-version)
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void rebuildAllowedLanes()
SUMOReal getLength() const
return the length of the edge
The edge is a district edge.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
void closeTraffic(const GUILane *lane)
close this edge for traffic
GUIVisualizationTextSettings internalEdgeName
A point in 2D or 3D with translation and scaling methods.
SUMOTime begin
The begin time these definitions are valid.
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
static MSEdge mySpecialDest_keepDestination
special destination values
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Tries to reroute the vehicle.
float minSize
The minimum size to draw this object.
const std::vector< MSLane * > * myLanes
Container for the edge's lane; should be sorted: (right-hand-traffic) the more left the lane...
MSLane & getLane(size_t laneNo)
returns the enumerated lane (!!! why not private with a friend?)
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
SUMOReal getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
void addRerouter()
add a rerouter
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
void unlock()
release mutex lock
GUIEdge(const std::string &id, int numericalID, const EdgeBasicFunction function, const std::string &streetName, const std::string &edgeType, int priority)
Constructor.
The edge is a pedestrian walking area (a special type of internal edge)
static std::vector< GUIGlID > getIDs(bool includeInternal)
SUMOReal length() const
Returns the length.
SUMOReal rotationDegreeAtOffset(SUMOReal pos) const
Returns the rotation at the given length.
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
SUMOTime end
The end time these definitions are valid.
GUIVisualizationSizeSettings containerSize
MFXMutex myLock
The mutex used to avoid concurrent updates of myPersons/ myContainers.
The edge is a normal street.
SUMOReal interpolateLanePosToGeometryPos(SUMOReal lanePos) const
The edge is a pedestrian crossing (a special type of internal edge)
static size_t dictSize()
Returns the number of edges.
std::vector< RerouteInterval > myIntervals
List of rerouting definition intervals.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
std::string myStreetName
the real-world name of this edge (need not be unique)
void mul(SUMOReal val)
Multiplies both positions with the given value.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
GUIVisualizationSizeSettings personSize
static DictType myDict
Static dictionary to associate string-ids with objects.
static const bool gUseMesoSim
GUIVisualizationSizeSettings vehicleSize
Boundary getBoundary() const
Returns the street's geometry.
std::vector< MSEdge * > MSEdgeVector
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
The edge is an internal edge.
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
GUISelectedStorage gSelected
A global holder of selected objects.
void closeBuilding()
Closes the building of the table.
Representation of a lane in the micro simulation.
A window containing a gl-object's parameter.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
static void fill(std::vector< GUIEdge * > &netsWrappers)
SUMOReal getExaggeration(const GUIVisualizationSettings &s) const
return the drawing size including exaggeration and constantSize values
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
const PositionVector & getShape() const
std::set< MSTransportable * > myPersons
Persons on the edge (only for drawing)