63 #include <mesogui/GUIMEVehicleControl.h>
64 #include <mesosim/MESegment.h>
65 #include <mesosim/MELoop.h>
66 #include <mesosim/MEVehicle.h>
69 #ifdef CHECK_MEMORY_LEAKS
71 #endif // CHECK_MEMORY_LEAKS
79 const std::string& streetName,
const std::string& edgeType,
int priority)
80 :
MSEdge(id, numericalID, function, streetName, edgeType, priority),
94 assert(laneNo < myLanes->size());
95 return *((*myLanes)[laneNo]);
101 std::vector<GUIGlID> ret;
107 ret.push_back(edge->
getGlID());
118 const MSEdge* edge = i->second;
131 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
132 ret.
add((*i)->getShape().getBoxBoundary());
142 netsWrappers.reserve(size);
143 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
145 netsWrappers.push_back(static_cast<GUIEdge*>((*i).second));
177 ret->
mkItem(
"allowed speed [m/s]",
false, getAllowedSpeed());
182 ret->
mkItem(
"vehicle ids",
false, getVehicleIDs());
185 ret->
mkItem(
"segment index",
false, segment->getIndex());
186 ret->
mkItem(
"segment length [m]",
false, segment->getLength());
187 ret->
mkItem(
"segment allowed speed [m/s]",
false, segment->getMaxSpeed());
188 ret->
mkItem(
"segment jam threshold [%]",
false, segment->getRelativeJamThreshold());
220 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
244 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawStreetName) {
247 if (lane1 != 0 && lane2 != 0) {
253 if (angle > 90 && angle < 270) {
258 }
else if (drawInternalEdgeName) {
260 }
else if (drawCwaEdgeName) {
263 if (drawStreetName) {
271 for (std::set<MSPerson*>::const_iterator i =
myPersons.begin(); i !=
myPersons.end(); ++i) {
282 assert(container != 0);
296 if (vehicleControl != 0) {
298 vehicleControl->secureVehicles();
299 size_t laneIndex = 0;
300 MESegment::Queue queue;
301 for (std::vector<MSLane*>::const_iterator msl =
myLanes->begin(); msl !=
myLanes->end(); ++msl, ++laneIndex) {
305 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this);
306 segment != 0; segment = segment->getNextSegment()) {
307 const SUMOReal length = segment->getLength() * segment->getLengthGeometryFactor();
308 if (laneIndex < segment->numQueues()) {
310 queue = segment->getQueue(laneIndex);
311 const SUMOReal avgCarSize = segment->getBruttoOccupancy() / segment->getCarNumber();
312 const SUMOReal avgCarHalfSize = 0.5 * avgCarSize;
313 const size_t queueSize = queue.size();
314 SUMOReal vehiclePosition = segmentOffset + length;
317 for (
size_t i = 0; i < queueSize; ++i) {
320 setVehicleColor(s, veh);
321 while (vehiclePosition < segmentOffset) {
325 vehiclePosition += length;
331 glTranslated(p.
x(), p.
y(), 0);
332 glRotated(angle, 0, 0, 1);
334 glScaled(exaggeration, vehLength * exaggeration, 1);
335 glBegin(GL_TRIANGLES);
337 glVertex2d(0 - 1.25, 1);
338 glVertex2d(0 + 1.25, 1);
341 if (nameSettings.
show) {
343 glRotated(angle, 0, 0, 1);
344 glTranslated(xOff, 0, 0);
345 glRotated(-angle, 0, 0, 1);
351 vehiclePosition -= vehLength;
354 segmentOffset += length;
358 vehicleControl->releaseVehicles();
365 GUIEdge::getVehicleNo()
const {
367 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
368 vehNo += segment->getCarNumber();
370 return (
unsigned int)vehNo;
375 GUIEdge::getVehicleIDs()
const {
376 std::string result =
" ";
377 std::vector<const MEVehicle*> vehs;
378 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
379 std::vector<const MEVehicle*> segmentVehs = segment->getVehicles();
380 vehs.insert(vehs.end(), segmentVehs.begin(), segmentVehs.end());
382 for (std::vector<const MEVehicle*>::const_iterator it = vehs.begin(); it != vehs.end(); it++) {
383 result += (*it)->getID() +
" ";
390 GUIEdge::getFlow()
const {
392 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
393 flow += (
SUMOReal) segment->getCarNumber() * segment->getMeanSpeed();
395 return 3600 * flow / (*myLanes)[0]->getLength();
400 GUIEdge::getBruttoOccupancy()
const {
402 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
403 occ += segment->getBruttoOccupancy();
410 GUIEdge::getMeanSpeed()
const {
413 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
415 v += vehNo * segment->getMeanSpeed();
426 GUIEdge::getAllowedSpeed()
const {
427 return (*
myLanes)[0]->getSpeedLimit();
432 GUIEdge::getRelativeSpeed()
const {
433 return getMeanSpeed() / getAllowedSpeed();
439 GLHelper::setColor(s.edgeColorer.getScheme().getColor(getColorValue(s.edgeColorer.getActive())));
444 GUIEdge::getColorValue(
size_t activeScheme)
const {
445 switch (activeScheme) {
451 return getAllowedSpeed();
453 return getBruttoOccupancy();
455 return getMeanSpeed();
459 return getRelativeSpeed();
466 GUIEdge::getScaleValue(
size_t activeScheme)
const {
467 switch (activeScheme) {
471 return getAllowedSpeed();
473 return getBruttoOccupancy();
475 return getMeanSpeed();
479 return getRelativeSpeed();
486 GUIEdge::getSegmentAtPosition(
const Position& pos) {
489 return MSGlobals::gMesoNet->getSegmentForEdge(*
this, lanePos);
503 GUIEdge::getVehicleColorValue(
size_t activeScheme,
MSBaseVehicle* veh)
const {
504 switch (activeScheme) {
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
std::set< MSPerson * > myPersons
Persons on the edge (only for drawing)
unsigned int getNumberReroutes() const
Returns the number of new routes this vehicle got.
GUIVisualizationTextSettings streetName
static bool setFunctionalColor(size_t activeScheme, const MSBaseVehicle *veh)
sets the color according to the current scheme index and some vehicle function
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
SUMOReal getMaxSpeed() const
Returns the maximum speed.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
Stores the information about how to visualize structures.
const EdgeBasicFunction myFunction
the purpose of the edge
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)
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.
The base class for microscopic and mesoscopic vehicles.
EdgeBasicFunction
Defines possible edge types.
static SUMOReal getTotalLength(bool includeInternal, bool eachLane)
SUMOReal x() const
Returns the x-position.
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)
GUIColorer vehicleColorer
The vehicle colorer.
GUIVisualizationTextSettings edgeName
A road/street connecting two junctions (gui-version)
A road/street connecting two junctions.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
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).
GUIVisualizationTextSettings internalEdgeName
A point in 2D or 3D with translation and scaling methods.
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.
const T getColor(const SUMOReal value) const
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 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)
virtual SUMOReal getSpeed() const =0
Returns the vehicle's current speed.
std::set< MSContainer * > myContainers
Containers on the edge.
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
SUMOReal y() const
Returns the y-position.
The edge is a pedestrian crossing (a special type of internal edge)
static size_t dictSize()
Returns the number of edges.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
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
virtual SUMOTime getWaitingTime() const =0
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.
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the maximum speed the vehicle may use on this edge.
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 std::string & getID() const
Returns the name of the vehicle.
const PositionVector & getShape() const