61 #include <mesogui/GUIMEVehicleControl.h>
62 #include <mesosim/MESegment.h>
63 #include <mesosim/MELoop.h>
64 #include <mesosim/MEVehicle.h>
67 #ifdef CHECK_MEMORY_LEAKS
69 #endif // CHECK_MEMORY_LEAKS
77 :
MSEdge(id, numericalID, function, streetName),
91 assert(laneNo < myLanes->size());
92 return *((*myLanes)[laneNo]);
98 std::vector<GUIGlID> ret;
104 ret.push_back(edge->
getGlID());
114 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
115 ret.
add((*i)->getShape().getBoxBoundary());
125 netsWrappers.reserve(size);
126 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
128 netsWrappers.push_back(static_cast<GUIEdge*>((*i).second));
160 ret->
mkItem(
"allowed speed [m/s]",
false, getAllowedSpeed());
161 ret->
mkItem(
"occupancy [%]",
true,
163 ret->
mkItem(
"mean vehicle speed [m/s]",
true,
165 ret->
mkItem(
"flow [veh/h/lane]",
true,
167 ret->
mkItem(
"#vehicles",
true,
169 ret->
mkItem(
"vehicle ids",
false, getVehicleIDs());
172 ret->
mkItem(
"segment index",
false, segment->getIndex());
173 ret->
mkItem(
"segment length [m]",
false, segment->getLength());
174 ret->
mkItem(
"segment allowed speed [m/s]",
false, segment->getMaxSpeed());
175 ret->
mkItem(
"segment jam threshold [%]",
false, segment->getRelativeJamThreshold());
209 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
224 if (vehicleControl != 0) {
226 vehicleControl->secureVehicles();
227 size_t laneIndex = 0;
228 MESegment::Queue queue;
229 for (std::vector<MSLane*>::const_iterator msl =
myLanes->begin(); msl !=
myLanes->end(); ++msl, ++laneIndex) {
236 glTranslated(laneBeg.
x(), laneBeg.
y(), 0);
237 glRotated(shapeRotations[0], 0, 0, 1);
242 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this);
243 segment != 0; segment = segment->getNextSegment()) {
244 const SUMOReal length = segment->getLength();
245 if (laneIndex < segment->numQueues()) {
247 queue = segment->getQueue(laneIndex);
248 const SUMOReal avgCarSize = segment->getOccupancy() / segment->getCarNumber();
249 const size_t queueSize = queue.size();
250 for (
size_t i = 0; i < queueSize; ++i) {
252 setVehicleColor(s, veh);
253 SUMOReal vehiclePosition = segmentOffset + length - i * avgCarSize;
255 while (vehiclePosition < segmentOffset) {
259 vehiclePosition += length;
262 while (shapeIndex < (
int)shapeRotations.size() - 1 && vehiclePosition > shapeOffset + shapeLengths[shapeIndex]) {
264 shapeOffset += shapeLengths[shapeIndex];
267 glTranslated(shape[shapeIndex].x(), shape[shapeIndex].y(), 0);
268 glRotated(shapeRotations[shapeIndex], 0, 0, 1);
271 glTranslated(xOff, -(vehiclePosition - shapeOffset),
GLO_VEHICLE);
273 glScaled(1, avgCarSize, 1);
274 glBegin(GL_TRIANGLES);
276 glVertex2d(0 - 1.25, 1);
277 glVertex2d(0 + 1.25, 1);
281 if (nameSettings.
show) {
283 Position(xOff, -(vehiclePosition - shapeOffset)),
288 segmentOffset += length;
292 vehicleControl->releaseVehicles();
301 if (drawEdgeName || drawInternalEdgeName || drawStreetName) {
304 if (lane1 != 0 && lane2 != 0) {
310 if (angle > 90 && angle < 270) {
315 }
else if (drawInternalEdgeName) {
318 if (drawStreetName) {
325 for (std::set<MSPerson*>::const_iterator i =
myPersons.begin(); i !=
myPersons.end(); ++i) {
335 GUIEdge::getVehicleNo()
const {
337 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
338 vehNo += segment->getCarNumber();
340 return (
unsigned int)vehNo;
345 GUIEdge::getVehicleIDs()
const {
346 std::string result =
" ";
347 std::vector<const MEVehicle*> vehs;
348 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
349 std::vector<const MEVehicle*> segmentVehs = segment->getVehicles();
350 vehs.insert(vehs.end(), segmentVehs.begin(), segmentVehs.end());
352 for (std::vector<const MEVehicle*>::const_iterator it = vehs.begin(); it != vehs.end(); it++) {
353 result += (*it)->getID() +
" ";
360 GUIEdge::getFlow()
const {
362 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
363 flow += (
SUMOReal) segment->getCarNumber() * segment->getMeanSpeed();
365 return 3600 * flow / (*myLanes)[0]->getLength();
370 GUIEdge::getOccupancy()
const {
372 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
373 occ += segment->getOccupancy();
380 GUIEdge::getMeanSpeed()
const {
383 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
385 v += vehNo * segment->getMeanSpeed();
396 GUIEdge::getAllowedSpeed()
const {
397 return (*
myLanes)[0]->getSpeedLimit();
402 GUIEdge::getRelativeSpeed()
const {
403 return getMeanSpeed() / getAllowedSpeed();
409 GLHelper::setColor(s.edgeColorer.getScheme().getColor(getColorValue(s.edgeColorer.getActive())));
414 GUIEdge::getColorValue(
size_t activeScheme)
const {
415 switch (activeScheme) {
421 return getAllowedSpeed();
423 return getOccupancy();
425 return getMeanSpeed();
429 return getRelativeSpeed();
436 GUIEdge::getSegmentAtPosition(
const Position& pos) {
439 return MSGlobals::gMesoNet->getSegmentForEdge(*
this, lanePos);
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
RGBColor color
The vehicle's color.
std::vector< MSLane * > * myLanes
Container for the edge's lane; should be sorted: (right-hand-traffic) the more left the lane...
GUIVisualizationTextSettings streetName
const RGBColor getColor(const SUMOReal value) const
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
Position positionAtOffset(SUMOReal pos) const
Returns the position at the given length.
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 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)
const MSRoute & getRoute() const
Returns the current route.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
GUIEdge(const std::string &id, int numericalID, const EdgeBasicFunction function, const std::string &streetName)
Constructor.
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.
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
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)
GUIColorScheme & getScheme()
MFXMutex myLock
The mutex used to avoid concurrent updates of myPersons.
The edge is a normal street.
SUMOReal y() const
Returns the y-position.
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.
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.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
Base class for coloring. Allows changing the used colors and sets the used color in dependence to a v...
const RGBColor & getColor() const
Returns this type's color.
static DictType myDict
Static dictionary to associate string-ids with objects.
const RGBColor & getColor() const
Returns the color.
static const bool gUseMesoSim
Boundary getBoundary() const
Returns the street's geometry.
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)
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