62 #include <mesogui/GUIMEVehicleControl.h>
63 #include <mesosim/MESegment.h>
64 #include <mesosim/MELoop.h>
65 #include <mesosim/MEVehicle.h>
68 #ifdef CHECK_MEMORY_LEAKS
70 #endif // CHECK_MEMORY_LEAKS
78 const std::string& streetName,
const std::string& edgeType,
int priority)
79 :
MSEdge(id, numericalID, function, streetName, edgeType, priority),
93 assert(laneNo < myLanes->size());
94 return *((*myLanes)[laneNo]);
100 std::vector<GUIGlID> ret;
106 ret.push_back(edge->
getGlID());
116 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
117 ret.
add((*i)->getShape().getBoxBoundary());
127 netsWrappers.reserve(size);
128 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
130 netsWrappers.push_back(static_cast<GUIEdge*>((*i).second));
162 ret->
mkItem(
"allowed speed [m/s]",
false, getAllowedSpeed());
167 ret->
mkItem(
"vehicle ids",
false, getVehicleIDs());
170 ret->
mkItem(
"segment index",
false, segment->getIndex());
171 ret->
mkItem(
"segment length [m]",
false, segment->getLength());
172 ret->
mkItem(
"segment allowed speed [m/s]",
false, segment->getMaxSpeed());
173 ret->
mkItem(
"segment jam threshold [%]",
false, segment->getRelativeJamThreshold());
205 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
229 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawStreetName) {
232 if (lane1 != 0 && lane2 != 0) {
238 if (angle > 90 && angle < 270) {
243 }
else if (drawInternalEdgeName) {
245 }
else if (drawCwaEdgeName) {
248 if (drawStreetName) {
256 for (std::set<MSPerson*>::const_iterator i =
myPersons.begin(); i !=
myPersons.end(); ++i) {
271 if (vehicleControl != 0) {
273 vehicleControl->secureVehicles();
274 size_t laneIndex = 0;
275 MESegment::Queue queue;
276 for (std::vector<MSLane*>::const_iterator msl =
myLanes->begin(); msl !=
myLanes->end(); ++msl, ++laneIndex) {
283 glTranslated(laneBeg.
x(), laneBeg.
y(), 0);
284 glRotated(shapeRotations[0], 0, 0, 1);
289 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this);
290 segment != 0; segment = segment->getNextSegment()) {
291 const SUMOReal length = segment->getLength() * segment->getLengthGeometryFactor();
292 if (laneIndex < segment->numQueues()) {
294 queue = segment->getQueue(laneIndex);
295 const SUMOReal avgCarSize = segment->getBruttoOccupancy() / segment->getCarNumber();
296 const size_t queueSize = queue.size();
297 for (
size_t i = 0; i < queueSize; ++i) {
299 setVehicleColor(s, veh);
300 SUMOReal vehiclePosition = segmentOffset + length - i * avgCarSize;
302 while (vehiclePosition < segmentOffset) {
306 vehiclePosition += length;
309 while (shapeIndex < (
int)shapeRotations.size() - 1 && vehiclePosition > shapeOffset + shapeLengths[shapeIndex]) {
311 shapeOffset += shapeLengths[shapeIndex];
314 glTranslated(shape[shapeIndex].x(), shape[shapeIndex].y(), 0);
315 glRotated(shapeRotations[shapeIndex], 0, 0, 1);
318 glTranslated(xOff, -(vehiclePosition - shapeOffset),
GLO_VEHICLE);
320 glScaled(1, avgCarSize, 1);
321 glBegin(GL_TRIANGLES);
323 glVertex2d(0 - 1.25, 1);
324 glVertex2d(0 + 1.25, 1);
328 if (nameSettings.
show) {
330 Position(xOff, -(vehiclePosition - shapeOffset)),
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);
484 GUIEdge::getVehicleColorValue(
size_t activeScheme,
MSBaseVehicle* veh)
const {
485 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)
const std::vector< SUMOReal > & getShapeRotations() const
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.
SUMOReal getMaxSpeed() const
Returns the maximum speed.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
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
const std::vector< SUMOReal > & getShapeLengths() const
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.
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.
MFXMutex myLock
The mutex used to avoid concurrent updates of myPersons.
The edge is a normal street.
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.
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.
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