69 #ifdef CHECK_MEMORY_LEAKS 71 #endif // CHECK_MEMORY_LEAKS 86 #pragma warning(disable: 4355) 90 MSVehicle(pars, route, type, speedFactor),
94 #pragma warning(default: 4355) 111 ret->
mkItem(
"shadow lane [id]",
false, shadowLane == 0 ?
"" : shadowLane->
getID());
113 ret->
mkItem(
"position [m]",
true,
115 ret->
mkItem(
"lateral offset [m]",
true,
117 ret->
mkItem(
"speed [m/s]",
true,
119 ret->
mkItem(
"angle [degree]",
true,
121 ret->
mkItem(
"slope [degree]",
true,
126 ret->
mkItem(
"time gap [s]",
true,
128 ret->
mkItem(
"waiting time [s]",
true,
132 ret->
mkItem(
"impatience",
true,
134 ret->
mkItem(
"last lane change [s]",
true,
149 ret->
mkItem(
"CO2 [mg/s]",
true,
151 ret->
mkItem(
"CO [mg/s]",
true,
153 ret->
mkItem(
"HC [mg/s]",
true,
155 ret->
mkItem(
"NOx [mg/s]",
true,
157 ret->
mkItem(
"PMx [mg/s]",
true,
159 ret->
mkItem(
"fuel [ml/s]",
true,
161 ret->
mkItem(
"electricity [Wh/s]",
true,
163 ret->
mkItem(
"noise (Harmonoise) [dB]",
true,
165 std::ostringstream str;
166 for (std::vector<MSDevice*>::const_iterator i =
myDevices.begin(); i !=
myDevices.end(); ++i) {
170 str << (*i)->getID().substr(0, (*i)->getID().find(
getID()));
172 ret->
mkItem(
"devices",
false, str.str());
173 ret->
mkItem(
"persons",
true,
175 ret->
mkItem(
"containers",
true,
191 ret->
mkItem(
"Type Information:",
false,
"");
220 for (std::vector<MSTransportable*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
229 int containerIndex = 0;
230 for (std::vector<MSTransportable*>::const_iterator i = cs.begin(); i != cs.end(); ++i) {
232 assert(container != 0);
237 #ifdef DRAW_BOUNDING_BOX 242 boundingBox.push_back(boundingBox.front());
246 glColor3d(0.5, .8, 0);
258 if ((*i).myLink == 0) {
261 MSLink* link = (*i).myLink;
265 if ((*i).mySetRequest) {
270 const SUMOTime leaveTime = (*i).myLink->getLeaveTime(
307 #define BLINKER_POS_FRONT .5 308 #define BLINKER_POS_BACK .5 312 glColor3d(1.f, .8f, 0);
348 glColor3f(1.f, .2f, 0);
351 glTranslated(0, length, -0.1);
368 glTranslated(0, 2.5, .5);
378 switch (activeScheme) {
428 std::vector<std::vector<MSVehicle::LaneQ> > bestLanes =
myBestLanes;
430 for (std::vector<std::vector<MSVehicle::LaneQ> >::iterator j = bestLanes.begin(); j != bestLanes.end(); ++j) {
431 std::vector<MSVehicle::LaneQ>& lanes = *j;
434 for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
435 gmax =
MAX2((*i).length, gmax);
436 rmax =
MAX2((*i).occupation, rmax);
438 for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
441 SUMOReal r = (*i).occupation / rmax;
443 SUMOReal width = 0.5 / (1 +
abs((*i).bestLaneOffset));
465 int bestLaneIndex = (&r ==
myRoute ? 0 : (int)bestLaneConts.
size());
466 for (; i != r.
end(); ++i) {
468 if (bestLaneIndex < (
int)bestLaneConts.size() && bestLaneConts[bestLaneIndex] != 0 && (*i) == &(bestLaneConts[bestLaneIndex]->getEdge())) {
469 lane =
static_cast<GUILane*
>(bestLaneConts[bestLaneIndex]);
472 lane =
static_cast<GUILane*
>((*i)->getLanes()[0]);
495 defaultLength *= exaggeration;
496 if (exaggeration == 0) {
499 carriageGap *= exaggeration;
505 const SUMOReal xCornerCut = 0.3 * exaggeration;
506 const SUMOReal yCornerCut = 0.4 * exaggeration;
508 const int numCarriages = (int)(length / (defaultLength + carriageGap) + 0.5);
509 assert(numCarriages > 0);
510 const SUMOReal carriageLengthWithGap = length / numCarriages;
511 const SUMOReal carriageLength = carriageLengthWithGap - carriageGap;
514 int furtherIndex = 0;
517 int backFurtherIndex = furtherIndex;
523 if (requiredSeats > 0) {
529 for (
int i = 0; i < numCarriages; ++i) {
530 while (carriageOffset < 0) {
540 while (carriageBackOffset < 0) {
542 if (prev != backLane) {
546 carriageBackOffset = 0;
558 if (i >= firstPassengerCarriage) {
562 glTranslated(front.
x(), front.
y(),
getType());
563 glRotated(angle, 0, 0, 1);
565 glBegin(GL_TRIANGLE_FAN);
566 glVertex2d(-halfWidth + xCornerCut, 0);
567 glVertex2d(-halfWidth, yCornerCut);
568 glVertex2d(-halfWidth, drawnCarriageLength - yCornerCut);
569 glVertex2d(-halfWidth + xCornerCut, drawnCarriageLength);
570 glVertex2d(halfWidth - xCornerCut, drawnCarriageLength);
571 glVertex2d(halfWidth, drawnCarriageLength - yCornerCut);
572 glVertex2d(halfWidth, yCornerCut);
573 glVertex2d(halfWidth - xCornerCut, 0);
577 carriageOffset -= carriageLengthWithGap;
578 carriageBackOffset -= carriageLengthWithGap;
583 glTranslated(front.
x(), front.
y(),
getType());
584 glRotated(angle, 0, 0, 1);
600 if (requiredSeats <= 0) {
609 for (
SUMOReal p = 2; p <= length - 1; p += 1) {
625 std::string result =
"";
633 if (
myStops.front().triggered) {
634 result +=
", triggered";
635 }
else if (
myStops.front().containerTriggered) {
636 result +=
", containerTriggered";
652 std::vector<const SUMOVehicle*> blockingFoes;
653 std::vector<const MSPerson*> blockingPersons;
658 if (parallelLink != 0) {
667 for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
670 #ifdef HAVE_INTERNAL_LANES 672 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
680 for (std::vector<const MSPerson*>::iterator it_p = blockingPersons.begin(); it_p != blockingPersons.end(); ++it_p) {
SUMOReal getWidth() const
Returns the lane's width.
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
bool drawAction_drawCarriageClass(const GUIVisualizationSettings &s, SUMOVehicleShape guiShape, bool asImage) const
draws the given guiShape if it has distinct carriages/modules and returns true if so ...
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
const MSVehicleType * myType
This Vehicle's type.
SUMOReal getLength() const
Returns the lane's length.
SUMOReal getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
Representation of a vehicle in the micro simulation.
int size() const
Return the number of passengers / containers.
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
PositionVector getBoundingPoly() const
get bounding polygon
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
std::vector< std::vector< LaneQ > > myBestLanes
std::vector< MSLane * > myFurtherLanes
The information into which lanes the vehicle laps into.
State myState
This Vehicles driving state (pos and speed)
DriveItemVector myLFLinkLanes
MSLane * getLane() const
Returns the lane the vehicle is on.
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
int getNumPassengers() const
return the number of passengers
int getShadowDirection() const
return the direction in which the current shadow lane lies
int getPersonNumber() const
Returns the number of persons.
Stores the information about how to visualize structures.
MSLane * getPreviousLane(MSLane *current, int &furtherIndex) const
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
render as a flexible city bus
void drawAction_drawVehicleBrakeLight(SUMOReal length, bool onlyOne=1) const
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
SUMOReal getMaxDecel() const
Get the vehicle type's maximum deceleration [m/s^2].
int getBestLaneOffset() const
returns the current offset from the best lane
std::string time2string(SUMOTime t)
GUIVisualizationTextSettings vehicleName
SUMOReal getLength() const
Get vehicle's length [m].
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
SUMOReal getNOxEmissions() const
Returns NOx emission of the current state.
static void drawBoxLines(const PositionVector &geom, const std::vector< SUMOReal > &rots, const std::vector< SUMOReal > &lengths, SUMOReal width, int cornerDetail=0, SUMOReal offset=0)
Draws thick lines.
SUMOReal getLeaveSpeed() const
SUMOReal getLastLaneChangeOffset() const
Returns the time since the last lane change in seconds.
SUMOTime getDepartDelay() const
Returns the depart delay.
void drawOutsideNetwork(bool add)
register vehicle for drawing while outside the network
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
const PositionVector & getShape() const
Returns this lane's shape.
const MSRoute * myRoute
This Vehicle's route.
PositionVector getBoundingBox() const
get bounding rectangle
const std::vector< SUMOReal > & getShapeLengths() const
void drawBestLanes() const
Draws the vehicle's best lanes.
bool addAdditionalGLVisualisation(const GUIGlObject *const which)
Adds an object to call its additional visualisation method.
const SUMOVehicleParameter * myParameter
This Vehicle's parameter.
const std::string & getID() const
Returns the id.
The base class for microscopic and mesoscopic vehicles.
int size() const
Returns the number of edges to pass.
SUMOReal getCO2Emissions() const
Returns CO2 emission of the current state.
int getPersonCapacity() const
Get this vehicle type's person capacity.
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
std::string getStopInfo() const
retrieve information about the current stop state
#define UNUSED_PARAMETER(x)
int getContainerCapacity() const
Get this vehicle type's container capacity.
bool removeAdditionalGLVisualisation(const GUIGlObject *const which)
Removes an object from the list of objects that show additional things.
The car-following model and parameter.
MSAbstractLaneChangeModel & getLaneChangeModel()
SUMOReal scale
information about a lane's width (temporary, used for a single view)
SUMOReal getColorValue(int activeScheme) const
gets the color value according to the current scheme index
MSLink * getParallelLink(int direction) const
return the link that is parallel to this lane or 0
void drawAction_drawVehicleBlinker(SUMOReal length) const
Right blinker lights are switched on.
PositionVector mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
Representation of a lane in the micro simulation (gui-version)
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
bool signalSet(int which) const
Returns whether the given signal is on.
static void drawFilledCircle(SUMOReal width, int steps=8)
Draws a filled circle around (0,0)
GUISUMOAbstractView * getActiveView() const
get the active view or 0
SUMOReal getWidth() const
Get the width which vehicles of this class shall have when being drawn.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
SUMOReal getCOEmissions() const
Returns CO emission of the current state.
SUMOReal getFuelConsumption() const
Returns fuel consumption of the current state.
Left blinker lights are switched on.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
GUIVehicle(SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type, const SUMOReal speedFactor)
Constructor.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
static GUIMainWindow * getInstance()
A point in 2D or 3D with translation and scaling methods.
SUMOReal getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs...
SUMOReal getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the subpart of best lanes that describes the vehicle's current lane and their successors...
SUMOReal getPMxEmissions() const
Returns PMx emission of the current state.
std::list< Stop > myStops
The vehicle's list of stops.
ConstMSEdgeVector::const_iterator MSRouteIterator
MSLane * myLane
The lane the vehicle is on.
Blinker lights on both sides are switched on.
SUMOReal getMaxSpeed() const
Returns the maximum speed.
void setPositionInVehicle(const Position &pos)
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
render as a (city) rail without locomotive
SUMOReal x() const
Returns the x-position.
bool isLeader(const MSVehicle *ego, const MSVehicle *foe)
std::vector< LinkLeader > LinkLeaders
SUMOReal getTimeGap() const
Returns the time gap in seconds to the leader of the vehicle looking for a fixed distance.
A MSVehicle extended by some values for usage within the gui.
const PositionVector & getShape() const
void drawAction_drawRailCarriages(const GUIVisualizationSettings &s, SUMOReal defaultLength, SUMOReal carriageGap, int firstPassengerCarriage, bool asImage) const
A blue emergency light is on.
bool opened(SUMOTime arrivalTime, SUMOReal arrivalSpeed, SUMOReal leaveSpeed, SUMOReal vehicleLength, SUMOReal impatience, SUMOReal decel, SUMOTime waitingTime, SUMOReal posLat=0, std::vector< const SUMOVehicle *> *collectFoes=0) const
Returns the information whether the link may be passed.
SUMOReal getNaviDegree() const
return the current angle in navigational degrees
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
SUMOReal getSlope() const
Returns the slope of the road at vehicle's position.
void drawAction_drawLinkItems(const GUIVisualizationSettings &s) const
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
SUMOReal pos() const
Position of this state.
void selectBlockingFoes() const
adds the blocking foes to the current selection
const SUMOVTypeParameter & getParameter() const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own type parameter window.
std::string line
The vehicle's line (mainly for public transport)
void setPositionInVehicle(const Position &pos)
void unlock()
release mutex lock
SUMOReal getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Structure representing possible vehicle parameter.
draw vehicle outside the road network
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, SUMOReal length=-1) const
const Position & getSeatPosition(int personIndex) const
returns the seat position for the person with the given index
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate)
SUMOReal getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
static SUMOReal gLateralResolution
const std::string & getID() const
Returns the name of the vehicle type.
void computeSeats(const Position &front, const Position &back, int &requiredSeats) const
add seats to mySeatPositions and update requiredSeats
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
void drawAction_drawBlinker(double dir, SUMOReal length)
int getContainerNumber() const
Returns the number of containers.
static SUMOTime gWaitingTimeMemory
length of memory for waiting times (in millisecs)
SUMOReal getHCEmissions() const
Returns HC emission of the current state.
GUIGlID getGlID() const
Returns the numerical id of the object.
Position positionAtOffset2D(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
static void drawLine(const Position &beg, SUMOReal rot, SUMOReal visLength)
Draws a thin line.
void move2side(SUMOReal amount)
move position vector to side using certain ammount
#define BLINKER_POS_FRONT
GUIVisualizationSizeSettings vehicleSize
void drawRouteHelper(const MSRoute &r, SUMOReal exaggeration) const
Draws the route.
SUMOReal getExaggeration(const GUIVisualizationSettings &s, SUMOReal factor=20) const
return the drawing size including exaggeration and constantSize values
const std::vector< SUMOReal > & getShapeRotations() const
MSLane * getShadowLane() const
Returns the lane the vehicles shadow is on during continuous/sublane lane change. ...
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
bool isStopped() const
Returns whether the vehicle is at a stop.
void drawAction_drawVehicleBlueLight() const
bool isParking() const
Returns whether the vehicle is parking.
SUMOReal getElectricityConsumption() const
Returns electricity consumption of the current state.
SUMOReal getAcceleration() const
Returns the vehicle's acceleration in m/s (this is computed as the last step's mean acceleration in c...
SUMOReal getImpatience() const
Returns this vehicles impatience.
SUMOReal y() const
Returns the y-position.
static SUMOTime gLaneChangeDuration
const std::string & getID() const
Returns the name of the vehicle.
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.
std::vector< MSDevice * > myDevices
The devices this vehicle has.
void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &s) const
A window containing a gl-object's parameter.
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
SUMOReal getSpeed() const
Returns the vehicle's current speed.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
const Position geometryPositionAtOffset(SUMOReal offset, SUMOReal lateralOffset=0) const
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
static RGBColor getColor()
gets the gl-color
A MSVehicle extended by some values for usage within the gui.