 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
184 myParent->stopTrack();
218 if (microVeh !=
nullptr) {
220 if (microVeh->
getLane() !=
nullptr) {
251 if (i->first->getTrackedID() ==
getGlID()) {
252 i->first->stopTrack();
254 while (i->first->removeAdditionalGLVisualisation(
this));
298 new FXMenuSeparator(ret);
300 new FXMenuCommand(ret,
"Start Tracking",
nullptr, ret,
MID_START_TRACK);
302 new FXMenuCommand(ret,
"Stop Tracking",
nullptr, ret,
MID_STOP_TRACK);
304 new FXMenuCommand(ret,
"Select Foes",
nullptr, ret,
MID_SHOW_FOES);
309 new FXMenuSeparator(ret);
343 const double degAngle =
RAD2DEG(angle +
M_PI / 2.);
346 glRotated(degAngle, 0, 0, 1);
351 double upscaleLength = upscale;
352 if (upscale > 1 && length > 5) {
354 upscaleLength =
MAX2(1.0, upscaleLength * (5 + sqrt(length - 5)) / length);
356 glScaled(upscale, upscaleLength, 1);
368 bool drawCarriages =
false;
380 glTranslated(0, 0, .1);
391 glColor3d(0., 1., 0.);
394 glVertex2d(0., minGap);
395 glVertex2d(-.5, minGap);
396 glVertex2d(.5, minGap);
401 glColor3d(1., 0., 0.);
404 glVertex2d(0., brakeGap);
405 glVertex2d(-.5, brakeGap);
406 glVertex2d(.5, brakeGap);
411 glColor3d(1., 0., 0.);
416 glTranslated(0, 0, .1);
433 if (!drawCarriages) {
487 glTranslated(0,
MIN2(length / 2,
double(5)), -
getType());
488 glScaled(1 / upscale, 1 / upscaleLength, 1);
489 glRotated(-degAngle, 0, 0, 1);
492 glRotated(-s.
angle, 0, 0, 1);
494 glRotated(s.
angle, 0, 0, 1);
498 glRotated(-s.
angle, 0, 0, 1);
500 glRotated(s.
angle, 0, 0, 1);
508 glRotated(-s.
angle, 0, 0, 1);
510 glRotated(s.
angle, 0, 0, 1);
511 for (std::string& line : lines) {
513 glRotated(-s.
angle, 0, 0, 1);
515 glRotated(s.
angle, 0, 0, 1);
520 if (!drawCarriages) {
524 const Position back = (p1 +
Position(-length * upscaleLength, 0)).rotateAround2D(angle, p1);
525 computeSeats(p1, back, totalSeats, upscale, requiredSeats);
547 glTranslated(0, 0,
getType() - .1);
560 for (
int i = noReroutePlus1 - 1; i >= 0; i--) {
561 double darken = double(0.4) / double(noReroutePlus1) * double(i);
578 glTranslated(pos.
x(), pos.
y(), -.1);
582 glTranslated(-pos.
x(), -pos.
y(), .1);
600 switch (activeScheme) {
656 double hue = 180. + atan2(center.
x() - p.
x(), center.
y() - p.
y()) * 180. /
M_PI;
665 double hue = 180. + atan2(center.
x() - p.
x(), center.
y() - p.
y()) * 180. /
M_PI;
674 double hue = 180. + atan2(pb.
x() - pe.
x(), pb.
y() - pe.
y()) * 180. /
M_PI;
682 std::hash<const MSBaseVehicle*> ptr_hash;
683 const double hue = (double)(ptr_hash(veh) % 360);
684 const double sat = ((ptr_hash(veh) / 360) % 67) / 100.0 + 0.33;
729 if (route !=
nullptr) {
747 for (std::vector<MSTransportable*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
756 int containerIndex = 0;
757 for (std::vector<MSTransportable*>::const_iterator i = cs.begin(); i != cs.end(); ++i) {
759 assert(container != 0);
764 #ifdef DRAW_BOUNDING_BOX
769 boundingBox.push_back(boundingBox.front());
773 glColor3d(0.5, .8, 0);
784 if (
getVType().getParameter().carriageLength > 0) {
818 if (requiredSeats <= 0) {
824 const int rowSize =
MAX2(1, (
int)floor(vehWidth / seatOffset));
825 const double rowOffset = (length - 1) / ceil((
double)maxSeats / rowSize);
826 const double sideOffset = (rowSize - 1) / 2 * seatOffset;
827 double rowPos = 1 - rowOffset;
828 for (
int i = 0; requiredSeats > 0 && i < maxSeats; i++) {
829 int seat = (i % rowSize);
834 seat * seatOffset - sideOffset));
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
A vehicle from the mesoscopic point of view.
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
const MSRoute * getRoute(int index) const
Called on route retrieval.
@ MID_HIDE_FUTUREROUTE
Hide vehicle's future route.
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
bool wasSet(int what) const
Returns whether the given parameter was set.
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048)
static bool setFunctionalColor(int activeScheme, const MSBaseVehicle *veh, RGBColor &col)
sets the color according to the current scheme index and some vehicle function
void removedPopupMenu()
notify object about popup menu removal
A MSVehicle extended by some values for usage within the gui.
int getNumPassengers() const
return the number of passengers
@ SVS_MOTORCYCLE
render as a motorcycle
void drawRoute(const GUIVisualizationSettings &s, int routeNo, double darken, bool future=false) const
Chooses the route to draw and draws it, darkening it as given.
GUIVisualizationTextSettings vehicleValue
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
RGBColor color
The vehicle's color, TraCI may change this.
double ymin() const
Returns minimum y-coordinate.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
SUMOVehicleShape getGuiShape() const
Get this vehicle type's shape.
int getNumContainers() const
return the number of passengers
double angle
The current view rotation angle.
bool drawAction_drawVehicleAsPolyWithCarriagges(const GUIVisualizationSettings &s, bool asImage=false) const
draw vehicle body and return whether carriages are being drawn
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
@ MID_SHOW_CURRENTROUTE
Show vehicle's current route.
static void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s, const SUMOVehicleShape shape, const double width, const double length, int carriageIndex=-1)
draw vehicle as a polygon
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
@ MID_START_TRACK
Start to track a vehicle.
void setPositionInVehicle(const Position &pos)
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
@ VO_SHOW_LFLINKITEMS
LFLinkItems.
const MSRoute & getRoute() const
Returns the current route.
double xmax() const
Returns maximum x-coordinate.
~GUIBaseVehicle()
destructor
const MSDevice_Transportable * getPersonDevice() const
const Position & getSeatPosition(int personIndex) const
returns the seat position for the person with the given index
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
const ConstMSEdgeVector & getEdges() const
PositionVector mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
const MSVehicleType & getVType() const
A shortcut to myVehicle.myType.
@ MID_STOP_TRACK
Stop to track a vehicle.
GUIVisualizationSizeSettings vehicleSize
GUIColorer vehicleColorer
The vehicle colorer.
bool hasActiveAddVisualisation(GUISUMOAbstractView *const parent, int which) const
Returns whether the named feature is enabled in the given view.
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
const RGBColor & getColor() const
Returns the color.
void setPositionInVehicle(const Position &pos)
int getPersonCapacity() const
Get this vehicle type's person capacity.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
bool drawMinGap
Information whether the minimum gap shall be drawn.
virtual void drawRouteHelper(const GUIVisualizationSettings &s, const MSRoute &r, bool future, const RGBColor &col) const =0
Draws the route.
double scaledSize(double scale, double constFactor=0.1) const
get scale size
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
@ NOTIFICATION_VAPORIZED
The vehicle got vaporized.
virtual void drawBestLanes() const
Draws the vehicle's best lanes.
@ VO_SHOW_ALL_ROUTES
show all vehicle's routes
@ SVS_BICYCLE
render as a bicycle
std::string line
The vehicle's line (mainly for public transport)
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
void drawOnPos(const GUIVisualizationSettings &s, const Position &pos, const double angle) const
Draws the object on the specified position with the specified angle.
static const int NEWLINE
identifier for splitting the given string at all newline characters
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, int align=0, double width=-1)
virtual void drawAction_drawVehicleBlueLight() const
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
const double SUMO_const_waitingPersonWidth
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
static void drawOutlineCircle(double width, double iwidth, int steps=8)
Draws an unfilled circle around (0,0)
double xmin() const
Returns minimum x-coordinate.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
@ MID_SHOW_BEST_LANES
Show vehicle's best lanes.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
virtual void selectBlockingFoes() const =0
adds the blocking foes to the current selection
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.
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
const int VEHPARS_COLOR_SET
int vehicleQuality
The quality of vehicle drawing.
void computeSeats(const Position &front, const Position &back, int maxSeats, double exaggeration, int &requiredSeats) const
add seats to mySeatPositions and update requiredSeats
GUIGlID getGlID() const
Returns the numerical id of the object.
virtual double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const =0
gets the color value according to the current scheme index
A class that stores a 2D geometrical boundary.
const RGBColor & getColor() const
Returns this type's color.
static const RGBColor BLUE
double scale
information about a lane's width (temporary, used for a single view)
@ SVS_RAIL_CARGO
render as a cargo train
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
static double getRange()
Returns the configured range.
GUIVisualizationTextSettings vehicleName
A point in 2D or 3D with translation and scaling methods.
void vaporizeCar(MEVehicle *v)
remove the given car and clean up the relevant data structures
double x() const
Returns the x-position.
virtual void drawAction_drawLinkItems(const GUIVisualizationSettings &) const
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
@ SVS_MOPED
render as a moped
std::string vehicleTextParam
key for rendering textual parameter
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
@ MID_SHOW_ALLROUTES
Show all vehicle's routes.
double getMinGap() const
Get the free space in front of vehicles of this class.
static const RGBColor RED
named colors
GUIBaseVehicle(MSBaseVehicle &vehicle)
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
@ SVS_POLICE
render as a police car
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
static void drawAction_drawVehicleAsBoxPlus(const double width, const double length)
draw vehicle as a Box
@ VO_SHOW_ROUTE
show vehicle's current route
MSBaseVehicle & myVehicle
The vehicle to which all calls should be delegated.
@ SVS_RAIL_CAR
render as a (city) rail without locomotive
virtual void drawAction_drawCarriageClass(const GUIVisualizationSettings &s, bool asImage) const =0
draws the given guiShape with distinct carriages/modules
@ MID_HIDE_ALLROUTES
Hide all vehicle's routes.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
MSLane * getLane() const
Returns the lane the vehicle is on.
@ SVS_PEDESTRIAN
render as a pedestrian
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
GUIVisualizationTextSettings vehicleText
@ VO_SHOW_BEST_LANES
show vehicle's best lanes
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
@ VO_SHOW_FUTURE_ROUTE
show vehicle's current continued from the current position
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
@ MID_SHOW_FUTUREROUTE
Show vehicle's future route.
virtual double getAngle() const =0
Returns the vehicle's direction in radians.
const MSDevice_Transportable * getContainerDevice() const
bool removeAdditionalGLVisualisation(GUIGlObject *const which)
Removes an object from the list of objects that show additional things.
const std::string getOptionalName() const
Returns the value for generic parameter 'name' or ''.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double y() const
Returns the y-position.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
bool addAdditionalGLVisualisation(GUIGlObject *const which)
Adds an object to call its additional visualisation method.
bool drawLaneChangePreference
Information whether the lane change preference shall be drawn.
Position getCenter() const
Returns the center of the boundary.
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
virtual void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &s) const
int size() const
Return the number of passengers / containers.
FXDEFMAP(GUIBaseVehicle::GUIBaseVehiclePopupMenu) GUIBaseVehiclePopupMenuMap[]
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double getLength() const
Get vehicle's length [m].
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
bool showBlinker
Information whether vehicle blinkers shall be drawn.
bool wasSet(int what) const
Returns whether the given parameter was set.
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.
@ SVS_EMERGENCY
render as an emergency vehicle
The base class for microscopic and mesoscopic vehicles.
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate)
@ SVS_SHIP
render as a arbitrary ship
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
virtual void drawAction_drawVehicleBrakeLight(double length, bool onlyOne=false) const
@ MID_SHOW_FOES
select foes of a vehicle
std::vector< std::string > getVector()
return vector of strings
@ SVS_FIREBRIGADE
render as a fire brigade
GUIGLObjectPopupMenu * myPopup
current popup (to clean up in destructor). GUIBaseVehicle is not responsible for removal
int getContainerCapacity() const
Get this vehicle type's container capacity.
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additionally triggered visualisations.
@ MID_HIDE_CURRENTROUTE
Hide vehicle's current route.
@ SVS_ANT
render as a giant ant
Boundary & grow(double by)
extends the boundary by the given amount
virtual void drawAction_drawVehicleBlinker(double) const
static const RGBColor GREEN
bool drawBrakeGap
Information whether the brake gap shall be drawn.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
MSDevice_Vehroutes * myRoutes
Stores the information about how to visualize structures.
const int VTYPEPARS_COLOR_SET
void destroyPopup()
destoys the popup
A MSNet extended by some values for usage within the gui.
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
MoveReminderCont myMoveReminders
Currently relevant move reminders.
@ MID_HIDE_BEST_LANES
Hide vehicle's best lanes.
const T getColor(const double value) const
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
virtual GUIGlID getTrackedID() const
get tracked id
static void drawAction_drawVehicleAsTrianglePlus(const double width, const double length)
draw vehicle as a triangle
bool showBTRange
Information whether the communication range shall be drawn.
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
@ MID_REMOVE_OBJECT
remove a vehice or person
virtual double getSpeed() const =0
Returns the vehicle's current speed.
static const RGBColor WHITE
double ymax() const
Returns maximum y-coordinate.
@ SVS_RAIL
render as a rail
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
Representation of a vehicle in the micro simulation.