204 myParent->stopTrack();
238 if (microVeh !=
nullptr) {
240 if (microVeh->
getLane() !=
nullptr) {
258 if (microVeh !=
nullptr) {
262 std::string errorOut;
265 if (stopPos.first !=
nullptr) {
267 stop.
lane = stopPos.first->getID();
269 stop.
endPos = stopPos.second + POSITION_EPS;
272 if (errorOut !=
"") {
278 WRITE_WARNING(
"GUI-triggered stop not implemented for meso");
304 while (i->first->removeAdditionalGLVisualisation(
this));
340 showLoops->setCheck(
false);
343 showLoops->setCheck(
true);
355 new FXMenuSeparator(ret);
366 new FXMenuSeparator(ret);
400 const double degAngle =
RAD2DEG(angle +
M_PI / 2.);
403 glRotated(degAngle, 0, 0, 1);
408 double upscaleLength = upscale;
409 if (upscale > 1 && length > 5) {
412 const double shrinkFactor =
MIN2(widthLengthFactor, sqrt(upscaleLength));
413 upscaleLength /= shrinkFactor;
415 glScaled(upscale, upscaleLength, 1);
427 bool drawCarriages =
false;
439 glTranslated(0, 0, .1);
450 glColor3d(0., 1., 0.);
453 glVertex2d(0., minGap);
454 glVertex2d(-.5, minGap);
455 glVertex2d(.5, minGap);
460 glColor3d(1., 0., 0.);
463 glVertex2d(0., brakeGap);
464 glVertex2d(-.5, brakeGap);
465 glVertex2d(.5, brakeGap);
470 glColor3d(1., 0., 0.);
475 glTranslated(0, 0, .1);
492 if (!drawCarriages) {
546 glTranslated(0,
MIN2(length / 2,
double(5)), -
getType());
547 glScaled(1 / upscale, 1 / upscaleLength, 1);
548 glRotated(-degAngle, 0, 0, 1);
551 glRotated(-s.
angle, 0, 0, 1);
553 glRotated(s.
angle, 0, 0, 1);
557 glRotated(-s.
angle, 0, 0, 1);
559 glRotated(s.
angle, 0, 0, 1);
568 glRotated(-s.
angle, 0, 0, 1);
570 glRotated(s.
angle, 0, 0, 1);
571 for (std::string& line : lines) {
573 glRotated(-s.
angle, 0, 0, 1);
575 glRotated(s.
angle, 0, 0, 1);
580 if (!drawCarriages) {
585 const Position back = (p1 +
Position(-length * upscaleLength, 0)).rotateAround2D(angle, p1);
609 glTranslated(0, 0,
getType() - .1);
623 for (
int i = noReroutePlus1 - 1; i >= 0; i--) {
624 double darken = double(0.4) / double(noReroutePlus1) * double(i);
641 glTranslated(pos.
x(), pos.
y(), -.1);
645 glTranslated(-pos.
x(), -pos.
y(), .1);
663 switch (activeScheme) {
719 double hue = 180. + atan2(center.
x() - p.
x(), center.
y() - p.
y()) * 180. /
M_PI;
728 double hue = 180. + atan2(center.
x() - p.
x(), center.
y() - p.
y()) * 180. /
M_PI;
737 double hue = 180. + atan2(pb.
x() - pe.
x(), pb.
y() - pe.
y()) * 180. /
M_PI;
745 std::hash<const MSBaseVehicle*> ptr_hash;
746 const double hue = (double)(ptr_hash(veh) % 360);
747 const double sat = ((ptr_hash(veh) / 360) % 67) / 100.0 + 0.33;
797 if (route !=
nullptr) {
821 for (std::vector<MSTransportable*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
830 int containerIndex = 0;
831 for (std::vector<MSTransportable*>::const_iterator i = cs.begin(); i != cs.end(); ++i) {
833 assert(container != 0);
838 #ifdef DRAW_BOUNDING_BOX
843 boundingBox.push_back(boundingBox.front());
847 glColor3d(0.5, .8, 0);
858 if (
getVType().getParameter().carriageLength > 0) {
891 std::vector<std::string> devs;
893 devs.push_back(d->deviceName());
901 if (requiredSeats <= 0) {
904 maxSeats =
MAX2(maxSeats, 1);
905 seatOffset *= exaggeration;
908 const int rowSize =
MAX2(1, (
int)floor(vehWidth / seatOffset));
909 const double rowOffset = (length - 1) / ceil((
double)maxSeats / rowSize);
910 const double sideOffset = (rowSize - 1) / 2.0 * seatOffset;
911 double rowPos = 1 - rowOffset;
914 for (
int i = 0; requiredSeats > 0 && i < maxSeats; i++) {
915 int seat = (i % rowSize);
@ MID_HIDE_ALLROUTES
Hide all vehicle's routes.
@ MID_HIDE_BEST_LANES
Hide vehicle's best lanes.
@ MID_HIDE_CURRENTROUTE
Hide vehicle's current route.
@ MID_SHOW_FOES
select foes of a vehicle
@ MID_SHOW_BEST_LANES
Show vehicle's best lanes.
@ MID_START_TRACK
Start to track a vehicle.
@ MID_SHOW_ALLROUTES
Show all vehicle's routes.
@ MID_SHOW_ROUTE_NOLOOPS
Show vehicle's future route (without loops)
@ MID_HIDE_ROUTE_NOLOOPS
Hide vehicle's future route (without loops)
@ MID_TOGGLE_STOP
toggle stop state of a vehice or person
@ MID_REMOVE_OBJECT
remove a vehice or person
@ MID_SHOW_FUTUREROUTE
Show vehicle's future route.
@ MID_HIDE_FUTUREROUTE
Hide vehicle's future route.
@ MID_SHOW_CURRENTROUTE
Show vehicle's current route.
@ MID_STOP_TRACK
Stop to track a vehicle.
FXDEFMAP(GUIBaseVehicle::GUIBaseVehiclePopupMenu) GUIBaseVehiclePopupMenuMap[]
#define WRITE_WARNING(msg)
const int VTYPEPARS_COLOR_SET
@ SVS_BICYCLE
render as a bicycle
@ SVS_FIREBRIGADE
render as a fire brigade
@ SVS_ANT
render as a giant ant
@ SVS_RAIL
render as a rail
@ SVS_EMERGENCY
render as an emergency vehicle
@ SVS_MOTORCYCLE
render as a motorcycle
@ SVS_MOPED
render as a moped
@ SVS_RAIL_CARGO
render as a cargo train
@ SVS_SHIP
render as a arbitrary ship
@ SVS_RAIL_CAR
render as a (city) rail without locomotive
@ SVS_PEDESTRIAN
render as a pedestrian
@ SVS_POLICE
render as a police car
const int VEHPARS_COLOR_SET
const double SUMO_const_waitingContainerWidth
const double SUMO_const_waitingPersonWidth
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
Position getCenter() const
Returns the center of the boundary.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
Boundary & grow(double by)
extends the boundary by the given amount
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
static void drawOutlineCircle(double width, double iwidth, int steps=8)
Draws an unfilled circle around (0,0)
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
static void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s, const SUMOVehicleShape shape, const double width, const double length, int carriageIndex=-1)
draw vehicle as a polygon
static void drawAction_drawVehicleAsTrianglePlus(const double width, const double length)
draw vehicle as a triangle
static bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, const std::string &file, const GUIGlObject *o, const double width, double length)
try to draw vehicle as raster image and return true if sucessful
static void drawAction_drawVehicleAsBoxPlus(const double width, const double length)
draw vehicle as a Box
A MSVehicle extended by some values for usage within the gui.
const Seat & getContainerPosition(int containerIndex) const
static bool setFunctionalColor(int activeScheme, const MSBaseVehicle *veh, RGBColor &col)
sets the color according to the current scheme index and some vehicle function
const std::string getOptionalName() const
Returns the value for generic parameter 'name' or ''.
virtual void drawAction_drawLinkItems(const GUIVisualizationSettings &) const
const Seat & getSeatPosition(int personIndex) const
returns the seat position for the person with the given index
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
int getNumContainers() const
return the number of passengers
void drawOnPos(const GUIVisualizationSettings &s, const Position &pos, const double angle) const
Draws the object on the specified position with the specified angle.
GUIGLObjectPopupMenu * myPopup
current popup (to clean up in destructor). GUIBaseVehicle is not responsible for removal
GUIBaseVehicle(MSBaseVehicle &vehicle)
MSDevice_Vehroutes * myRoutes
virtual void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &s) const
bool hasActiveAddVisualisation(GUISUMOAbstractView *const parent, int which) const
Returns whether the named feature is enabled in the given view.
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
void drawRoute(const GUIVisualizationSettings &s, int routeNo, double darken, bool future=false, bool noLoop=false) const
Chooses the route to draw and draws it, darkening it as given.
std::vector< Seat > Seats
MSBaseVehicle & myVehicle
The vehicle to which all calls should be delegated.
bool drawAction_drawVehicleAsPolyWithCarriagges(const GUIVisualizationSettings &s, bool asImage=false) const
draw vehicle body and return whether carriages are being drawn
virtual void drawAction_drawVehicleBlinker(double) const
void removedPopupMenu()
notify object about popup menu removal
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate)
virtual void drawBestLanes() const
Draws the vehicle's best lanes.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void computeSeats(const Position &front, const Position &back, double seatOffset, int maxSeats, double exaggeration, int &requiredSeats, Seats &into) const
add seats to mySeatPositions and update requiredSeats
virtual Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
@ VO_SHOW_LFLINKITEMS
LFLinkItems.
@ VO_SHOW_ALL_ROUTES
show all vehicle's routes
@ VO_SHOW_ROUTE_NOLOOP
show vehicle's routes without loops
@ VO_SHOW_FUTURE_ROUTE
show vehicle's current continued from the current position
@ VO_SHOW_ROUTE
show vehicle's current route
@ VO_SHOW_BEST_LANES
show vehicle's best lanes
virtual void drawAction_drawCarriageClass(const GUIVisualizationSettings &s, bool asImage) const =0
draws the given guiShape with distinct carriages/modules
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additionally triggered visualisations.
Seats myContainerPositions
virtual double getAngle() const =0
Returns the vehicle's direction in radians.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
virtual void drawAction_drawVehicleBrakeLight(double length, bool onlyOne=false) const
virtual double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const =0
gets the color value according to the current scheme index
int getNumPassengers() const
return the number of passengers
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
~GUIBaseVehicle()
destructor
virtual void drawAction_drawVehicleBlueLight() const
virtual void drawRouteHelper(const GUIVisualizationSettings &s, const MSRoute &r, bool future, bool noLoop, const RGBColor &col) const =0
Draws the route.
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
virtual void selectBlockingFoes() const =0
adds the blocking foes to the current selection
Seats mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
std::string getDeviceDescription()
lists equipped device (types) for the current vehicle
const MSVehicleType & getVType() const
A shortcut to myVehicle.myType.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
void setPositionInVehicle(const GUIBaseVehicle::Seat &pos)
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the type parameter window.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
GUIGlID getGlID() const
Returns the numerical id of the object.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
A MSNet extended by some values for usage within the gui.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
void setPositionInVehicle(const GUIBaseVehicle::Seat &pos)
const T getColor(const double value) const
bool removeAdditionalGLVisualisation(GUIGlObject *const which)
Removes an object from the list of objects that show additional things.
void destroyPopup()
destoys the popup
bool addAdditionalGLVisualisation(GUIGlObject *const which)
Adds an object to call its additional visualisation method.
virtual GUIGlID getTrackedID() const
get tracked id
Stores the information about how to visualize structures.
GUIVisualizationTextSettings vehicleName
GUIVisualizationSizeSettings vehicleSize
bool showBlinker
Information whether vehicle blinkers shall be drawn.
GUIColorer vehicleColorer
The vehicle colorer.
GUIVisualizationTextSettings vehicleValue
int vehicleQuality
The quality of vehicle drawing.
std::string vehicleTextParam
key for rendering vehicle textual parameter
double scale
information about a lane's width (temporary, used for a single view)
bool drawMinGap
Information whether the minimum gap shall be drawn.
GUIVisualizationTextSettings vehicleText
bool showBTRange
Information whether the communication range shall be drawn.
bool drawBrakeGap
Information whether the brake gap shall be drawn.
bool drawLaneChangePreference
Information whether the lane change preference shall be drawn.
double angle
The current view rotation angle.
static double naviDegree(const double angle)
void vaporizeCar(MEVehicle *v, MSMoveReminder::Notification reason)
remove the given car and clean up the relevant data structures
A vehicle from the mesoscopic point of view.
The base class for microscopic and mesoscopic vehicles.
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
const MSDevice_Transportable * getPersonDevice() const
MoveReminderCont myMoveReminders
Currently relevant move reminders.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
const MSDevice_Transportable * getContainerDevice() const
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
std::string getPrefixedParameter(const std::string &key, std::string &error) const
retrieve parameters of devices, models and the vehicle itself
const std::vector< MSVehicleDevice * > & getDevices() const
Returns this vehicle's devices.
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
const MSRoute & getRoute() const
Returns the current route.
bool isStopped() const
Returns whether the vehicle is at a stop.
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
static double getRange()
Returns the configured range.
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
int size() const
Return the number of passengers / containers.
static MSDevice_Vehroutes * buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into, int maxRoutes=std::numeric_limits< int >::max())
Build devices for the given vehicle, if needed.
const MSRoute * getRoute(int index) const
Called on route retrieval.
Abstract in-vehicle / in-person device.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Representation of a lane in the micro simulation.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
@ NOTIFICATION_VAPORIZED_GUI
The vehicle got removed via the GUI.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
const RGBColor & getColor() const
Returns the color.
const ConstMSEdgeVector & getEdges() const
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
Representation of a vehicle in the micro simulation.
MSLane * getMutableLane() const
Returns the lane the vehicle is on Non const version indicates that something volatile is going on.
bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string &errorMsg)
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
bool resumeFromStopping()
std::pair< const MSLane *, double > getLanePosAfterDist(double distance) const
return lane and position along bestlanes at the given distance
double getSpeed() const
Returns the vehicle's current speed.
const MSLane * getLane() const
Returns the lane the vehicle is on.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double getMinGap() const
Get the free space in front of vehicles of this class.
const RGBColor & getColor() const
Returns this type's color.
double getLength() const
Get vehicle's length [m].
SUMOVehicleShape getGuiShape() const
Get this vehicle type's shape.
bool wasSet(int what) const
Returns whether the given parameter was set.
const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
A point in 2D or 3D with translation and scaling methods.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
double x() const
Returns the x-position.
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
double y() const
Returns the y-position.
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
static const RGBColor WHITE
static const RGBColor BLUE
static const RGBColor GREEN
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
static const RGBColor RED
named colors
virtual double getSpeed() const =0
Returns the object's current speed.
virtual double getAngle() const =0
Get the vehicle's angle.
Definition of vehicle stop (position and duration)
std::string lane
The lane to stop at.
double startPos
The stopping position start.
double endPos
The stopping position end.
SUMOTime duration
The stopping duration.
RGBColor color
The vehicle's color, TraCI may change this.
bool wasSet(int what) const
Returns whether the given parameter was set.
std::string line
The vehicle's line (mainly for public transport)
static const int NEWLINE
identifier for splitting the given string at all newline characters
std::vector< std::string > getVector()
return vector of strings
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
double scaledSize(double scale, double constFactor=0.1) const
get scale size