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());
165 ret->
mkItem(
"vehicle ids",
false, getVehicleIDs());
168 ret->
mkItem(
"segment index",
false, segment->getIndex());
169 ret->
mkItem(
"segment length [m]",
false, segment->getLength());
170 ret->
mkItem(
"segment allowed speed [m/s]",
false, segment->getMaxSpeed());
171 ret->
mkItem(
"segment jam threshold [%]",
false, segment->getRelativeJamThreshold());
205 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
220 if (vehicleControl != 0) {
222 vehicleControl->secureVehicles();
223 size_t laneIndex = 0;
224 MESegment::Queue queue;
225 for (std::vector<MSLane*>::const_iterator msl =
myLanes->begin(); msl !=
myLanes->end(); ++msl, ++laneIndex) {
232 glTranslated(laneBeg.
x(), laneBeg.
y(), 0);
233 glRotated(shapeRotations[0], 0, 0, 1);
238 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this);
239 segment != 0; segment = segment->getNextSegment()) {
240 const SUMOReal length = segment->getLength();
241 if (laneIndex < segment->numQueues()) {
243 queue = segment->getQueue(laneIndex);
244 const SUMOReal avgCarSize = segment->getBruttoOccupancy() / segment->getCarNumber();
245 const size_t queueSize = queue.size();
246 for (
size_t i = 0; i < queueSize; ++i) {
248 setVehicleColor(s, veh);
249 SUMOReal vehiclePosition = segmentOffset + length - i * avgCarSize;
251 while (vehiclePosition < segmentOffset) {
255 vehiclePosition += length;
258 while (shapeIndex < (
int)shapeRotations.size() - 1 && vehiclePosition > shapeOffset + shapeLengths[shapeIndex]) {
260 shapeOffset += shapeLengths[shapeIndex];
263 glTranslated(shape[shapeIndex].x(), shape[shapeIndex].y(), 0);
264 glRotated(shapeRotations[shapeIndex], 0, 0, 1);
267 glTranslated(xOff, -(vehiclePosition - shapeOffset),
GLO_VEHICLE);
269 glScaled(1, avgCarSize, 1);
270 glBegin(GL_TRIANGLES);
272 glVertex2d(0 - 1.25, 1);
273 glVertex2d(0 + 1.25, 1);
277 if (nameSettings.
show) {
279 Position(xOff, -(vehiclePosition - shapeOffset)),
284 segmentOffset += length;
288 vehicleControl->releaseVehicles();
297 if (drawEdgeName || drawInternalEdgeName || drawStreetName) {
300 if (lane1 != 0 && lane2 != 0) {
306 if (angle > 90 && angle < 270) {
311 }
else if (drawInternalEdgeName) {
314 if (drawStreetName) {
321 for (std::set<MSPerson*>::const_iterator i =
myPersons.begin(); i !=
myPersons.end(); ++i) {
331 GUIEdge::getVehicleNo()
const {
333 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
334 vehNo += segment->getCarNumber();
336 return (
unsigned int)vehNo;
341 GUIEdge::getVehicleIDs()
const {
342 std::string result =
" ";
343 std::vector<const MEVehicle*> vehs;
344 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
345 std::vector<const MEVehicle*> segmentVehs = segment->getVehicles();
346 vehs.insert(vehs.end(), segmentVehs.begin(), segmentVehs.end());
348 for (std::vector<const MEVehicle*>::const_iterator it = vehs.begin(); it != vehs.end(); it++) {
349 result += (*it)->getID() +
" ";
356 GUIEdge::getFlow()
const {
358 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
359 flow += (
SUMOReal) segment->getCarNumber() * segment->getMeanSpeed();
361 return 3600 * flow / (*myLanes)[0]->getLength();
366 GUIEdge::getBruttoOccupancy()
const {
368 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
369 occ += segment->getBruttoOccupancy();
376 GUIEdge::getMeanSpeed()
const {
379 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this); segment != 0; segment = segment->getNextSegment()) {
381 v += vehNo * segment->getMeanSpeed();
392 GUIEdge::getAllowedSpeed()
const {
393 return (*
myLanes)[0]->getSpeedLimit();
398 GUIEdge::getRelativeSpeed()
const {
399 return getMeanSpeed() / getAllowedSpeed();
405 GLHelper::setColor(s.edgeColorer.getScheme().getColor(getColorValue(s.edgeColorer.getActive())));
410 GUIEdge::getColorValue(
size_t activeScheme)
const {
411 switch (activeScheme) {
417 return getAllowedSpeed();
419 return getBruttoOccupancy();
421 return getMeanSpeed();
425 return getRelativeSpeed();
432 GUIEdge::getSegmentAtPosition(
const Position& pos) {
435 return MSGlobals::gMesoNet->getSegmentForEdge(*
this, lanePos);
bool wasSet(int what) const
Returns whether the given parameter was set.
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).
bool wasSet(int what) const
Returns whether the given parameter was set.
GUIVisualizationTextSettings internalEdgeName
A point in 2D or 3D with translation and scaling methods.
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
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...
const int VEHPARS_COLOR_SET
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.
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.
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.
const int VTYPEPARS_COLOR_SET
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