 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
98 :
GUIGLObjectPopupMenu(app, parent, o), myVehiclesAdditionalVisualizations(additionalVisualizations) {
108 if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent,
VO_SHOW_ALL_ROUTES)) {
109 static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent,
VO_SHOW_ALL_ROUTES);
117 static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent,
VO_SHOW_ALL_ROUTES);
125 if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent,
VO_SHOW_ROUTE)) {
126 static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent,
VO_SHOW_ROUTE);
134 static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent,
VO_SHOW_ROUTE);
142 if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent,
VO_SHOW_FUTURE_ROUTE)) {
143 static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent,
VO_SHOW_FUTURE_ROUTE);
151 static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent,
VO_SHOW_FUTURE_ROUTE);
159 if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent,
VO_SHOW_BEST_LANES)) {
160 static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent,
VO_SHOW_BEST_LANES);
168 static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent,
VO_SHOW_BEST_LANES);
176 if (myParent->getTrackedID() != static_cast<GUIBaseVehicle*>(myObject)->getGlID()) {
177 myParent->startTrack(static_cast<GUIBaseVehicle*>(myObject)->
getGlID());
185 myParent->stopTrack();
193 if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent,
VO_SHOW_LFLINKITEMS)) {
194 static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent,
VO_SHOW_LFLINKITEMS);
202 static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent,
VO_SHOW_LFLINKITEMS);
209 static_cast<GUIBaseVehicle*>(myObject)->selectBlockingFoes();
219 if (microVeh !=
nullptr) {
221 if (microVeh->
getLane() !=
nullptr) {
251 if (i->first->getTrackedID() ==
getGlID()) {
252 i->first->stopTrack();
254 while (i->first->removeAdditionalGLVisualisation(
this));
295 new FXMenuSeparator(ret);
297 new FXMenuCommand(ret,
"Start Tracking",
nullptr, ret,
MID_START_TRACK);
299 new FXMenuCommand(ret,
"Stop Tracking",
nullptr, ret,
MID_STOP_TRACK);
301 new FXMenuCommand(ret,
"Select Foes",
nullptr, ret,
MID_SHOW_FOES);
306 new FXMenuSeparator(ret);
335 const double degAngle =
RAD2DEG(angle +
M_PI / 2.);
338 glRotated(degAngle, 0, 0, 1);
343 double upscaleLength = upscale;
344 if (upscale > 1 && length > 5) {
346 upscaleLength =
MAX2(1.0, upscaleLength * (5 + sqrt(length - 5)) / length);
348 glScaled(upscale, upscaleLength, 1);
360 bool drawCarriages =
false;
372 glTranslated(0, 0, .1);
383 glColor3d(0., 1., 0.);
386 glVertex2d(0., minGap);
387 glVertex2d(-.5, minGap);
388 glVertex2d(.5, minGap);
393 glColor3d(1., 0., 0.);
396 glVertex2d(0., brakeGap);
397 glVertex2d(-.5, brakeGap);
398 glVertex2d(.5, brakeGap);
403 glColor3d(1., 0., 0.);
408 glTranslated(0, 0, .1);
425 if (!drawCarriages) {
479 glTranslated(0,
MIN2(length / 2,
double(5)), -
getType());
480 glScaled(1 / upscale, 1 / upscaleLength, 1);
481 glRotated(-degAngle, 0, 0, 1);
484 glRotated(-s.
angle, 0, 0, 1);
486 glRotated(s.
angle, 0, 0, 1);
490 glRotated(-s.
angle, 0, 0, 1);
492 glRotated(s.
angle, 0, 0, 1);
497 if (!drawCarriages) {
501 const Position back = (p1 +
Position(-length * upscaleLength, 0)).rotateAround2D(angle, p1);
502 computeSeats(p1, back, totalSeats, upscale, requiredSeats);
524 glTranslated(0, 0,
getType() - .1);
537 for (
int i = noReroutePlus1 - 1; i >= 0; i--) {
538 double darken = double(0.4) / double(noReroutePlus1) * double(i);
555 glTranslated(pos.
x(), pos.
y(), -.1);
559 glTranslated(-pos.
x(), -pos.
y(), .1);
574 switch (activeScheme) {
630 double hue = 180. + atan2(center.
x() - p.
x(), center.
y() - p.
y()) * 180. /
M_PI;
639 double hue = 180. + atan2(center.
x() - p.
x(), center.
y() - p.
y()) * 180. /
M_PI;
648 double hue = 180. + atan2(pb.
x() - pe.
x(), pb.
y() - pe.
y()) * 180. /
M_PI;
651 double sat = pb.
distanceTo(pe) / minp.distanceTo(maxp);
656 std::hash<const MSBaseVehicle*> ptr_hash;
657 const double hue = (double)(ptr_hash(veh) % 360);
658 const double sat = ((ptr_hash(veh) / 360) % 67) / 100.0 + 0.33;
695 glGetDoublev(GL_CURRENT_COLOR, colors);
719 if (route !=
nullptr) {
737 for (std::vector<MSTransportable*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
738 GUIPerson* person = dynamic_cast<GUIPerson*>(*i);
746 int containerIndex = 0;
747 for (std::vector<MSTransportable*>::const_iterator i = cs.begin(); i != cs.end(); ++i) {
748 GUIContainer* container = dynamic_cast<GUIContainer*>(*i);
749 assert(container != 0);
754 #ifdef DRAW_BOUNDING_BOX
759 boundingBox.push_back(boundingBox.front());
763 glColor3d(0.5, .8, 0);
774 if (
getVType().getParameter().carriageLength > 0) {
808 if (requiredSeats <= 0) {
814 const int rowSize =
MAX2(1, (
int)floor(vehWidth / seatOffset));
815 const double rowOffset = (length - 1) / ceil((
double)maxSeats / rowSize);
816 const double sideOffset = (rowSize - 1) / 2 * seatOffset;
817 double rowPos = 1 - rowOffset;
818 for (
int i = 0; requiredSeats > 0 && i < maxSeats; i++) {
819 int seat = (i % rowSize);
824 seat * seatOffset - sideOffset));
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
bool addAdditionalGLVisualisation(const GUIGlObject *const which)
Adds an object to call its additional visualisation method.
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.
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)
A MSVehicle extended by some values for usage within the gui.
int getNumPassengers() const
return the number of passengers
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
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
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.
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.
Start to track a vehicle.
void setPositionInVehicle(const Position &pos)
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
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.
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.
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.
The vehicle got vaporized.
virtual void drawBestLanes() const
Draws the vehicle's best lanes.
show all vehicle's routes
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 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.
virtual void drawRouteHelper(const GUIVisualizationSettings &s, const MSRoute &r, bool future) const =0
Draws the route.
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.
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.
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)
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.
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
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)
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
show vehicle's current route
MSBaseVehicle & myVehicle
The vehicle to which all calls should be delegated.
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
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.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
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)
show vehicle's current continued from the current position
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Show vehicle's future route.
virtual double getAngle() const =0
Returns the vehicle's direction in radians.
const MSDevice_Transportable * getContainerDevice() const
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 drawLaneChangePreference
Information whether the lane change preference shall be drawn.
Position getCenter() const
Returns the center of the boundary.
bool removeAdditionalGLVisualisation(const GUIGlObject *const which)
Removes an object from the list of objects that show additional things.
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.
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)
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
int getContainerCapacity() const
Get this vehicle type's container capacity.
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additionally triggered visualisations.
Hide vehicle's current route.
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
A MSNet extended by some values for usage within the gui.
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.
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
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.
static bool setFunctionalColor(int activeScheme, const MSBaseVehicle *veh)
sets the color according to the current scheme index and some vehicle function
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
Representation of a vehicle in the micro simulation.