SUMO - Simulation of Urban MObility
GUIContainerStop.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // A lane area vehicles can halt at (gui-version)
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <string>
28 #include <utils/geom/Boundary.h>
29 #include <utils/gui/div/GLHelper.h>
30 #include <utils/common/ToString.h>
31 #include <microsim/MSNet.h>
32 #include <microsim/MSLane.h>
33 #include <microsim/MSEdge.h>
34 #include "GUINet.h"
35 #include "GUIEdge.h"
36 #include "GUIContainer.h"
37 #include "GUIContainerStop.h"
40 #include <gui/GUIGlobals.h>
45 #include <utils/geom/GeomHelper.h>
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 GUIContainerStop::GUIContainerStop(const std::string& id, const std::vector<std::string>& lines, MSLane& lane,
55  double frompos, double topos)
56  : MSStoppingPlace(id, lines, lane, frompos, topos),
58  const double offsetSign = MSNet::getInstance()->lefthand() ? -1 : 1;
59  myFGShape = lane.getShape();
60  myFGShape.move2side(1.65 * offsetSign);
62  lane.interpolateLanePosToGeometryPos(frompos),
64  myFGShapeRotations.reserve(myFGShape.size() - 1);
65  myFGShapeLengths.reserve(myFGShape.size() - 1);
66  int e = (int) myFGShape.size() - 1;
67  for (int i = 0; i < e; ++i) {
68  const Position& f = myFGShape[i];
69  const Position& s = myFGShape[i + 1];
70  myFGShapeLengths.push_back(f.distanceTo(s));
71  myFGShapeRotations.push_back((double) atan2((s.x() - f.x()), (f.y() - s.y())) * (double) 180.0 / (double) M_PI);
72  }
74  tmp.move2side(1.5 * offsetSign);
75  myFGSignPos = tmp.getLineCenter();
76  myFGSignRot = 0;
77  if (tmp.length() != 0) {
79  myFGSignRot -= 90;
80  }
81 }
82 
83 
85 
86 
89  GUISUMOAbstractView& parent) {
90  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
91  buildPopupHeader(ret, app);
96  buildPositionCopyEntry(ret, false);
97  return ret;
98 }
99 
100 
105  new GUIParameterTableWindow(app, *this, 7);
106  // add items
107  ret->mkItem("name", false, getMyName());
108  ret->mkItem("begin position [m]", false, myBegPos);
109  ret->mkItem("end position [m]", false, myEndPos);
110  ret->mkItem("container number [#]", true, new FunctionBinding<GUIContainerStop, int>(this, &MSStoppingPlace::getTransportableNumber));
111  ret->mkItem("stopped vehicles[#]", true, new FunctionBinding<GUIContainerStop, int>(this, &MSStoppingPlace::getStoppedVehicleNumber));
112  ret->mkItem("last free pos[m]", true, new FunctionBinding<GUIContainerStop, double>(this, &MSStoppingPlace::getLastFreePos));
113  // close building
114  ret->closeBuilding();
115  return ret;
116 }
117 
118 
119 void
121  glPushName(getGlID());
122  glPushMatrix();
123  // draw the area
124  glTranslated(0, 0, getType());
126  const double exaggeration = s.addSize.getExaggeration(s, this);
128  // draw details unless zoomed out to far
129  if (s.scale * exaggeration >= 10) {
130  glPushMatrix();
131  // draw the lines
132  const double rotSign = MSNet::getInstance()->lefthand() ? -1 : 1;
133  // Iterate over every line
134  for (int i = 0; i < (int)myLines.size(); ++i) {
135  // push a new matrix for every line
136  glPushMatrix();
137  // traslate and rotate
138  glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0);
139  glRotated(rotSign * myFGSignRot, 0, 0, 1);
140  // draw line
141  GLHelper::drawText(myLines[i].c_str(), Position(1.2, (double)i), .1, 1.f, s.SUMO_color_containerStop, 0, FONS_ALIGN_LEFT);
142  // pop matrix for every line
143  glPopMatrix();
144  }
145  // draw the sign
146  glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0);
147  int noPoints = 9;
148  if (s.scale * exaggeration > 25) {
149  noPoints = MIN2((int)(9.0 + (s.scale * exaggeration) / 10.0), 36);
150  }
151  glScaled(exaggeration, exaggeration, 1);
152  GLHelper::drawFilledCircle((double) 1.1, noPoints);
153  glTranslated(0, 0, .1);
155  GLHelper::drawFilledCircle((double) 0.9, noPoints);
156  if (s.scale * exaggeration >= 4.5) {
158  }
159  glPopMatrix();
160  }
161  glPopMatrix();
162  glPopName();
163  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
164  for (std::vector<MSTransportable*>::const_iterator i = myWaitingTransportables.begin(); i != myWaitingTransportables.end(); ++i) {
165  glTranslated(0, 1, 0); // make multiple containers viewable
166  static_cast<GUIContainer*>(*i)->drawGL(s);
167  }
168 }
169 
170 
171 Boundary
174  b.grow(20);
175  return b;
176 }
177 
178 
179 
180 /****************************************************************************/
181 
PositionVector myFGShape
The shape.
a containerStop
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
std::vector< double > myFGShapeLengths
The lengths of the shape parts.
double scale
information about a lane&#39;s width (temporary, used for a single view)
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition: GLHelper.cpp:178
GUIVisualizationTextSettings addName
std::vector< MSTransportable * > myWaitingTransportables
Persons waiting at this stop.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
A lane area vehicles can halt at.
const double myEndPos
The end position this bus stop is located at.
Stores the information about how to visualize structures.
int getStoppedVehicleNumber() const
Returns the number of stopped vehicles waiting on this stop.
double y() const
Returns the y-position.
Definition: Position.h:62
~GUIContainerStop()
Destructor.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
double x() const
Returns the x-position.
Definition: Position.h:57
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
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)
Definition: GLHelper.cpp:611
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:165
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:456
int getTransportableNumber() const
Returns the number of transportables waiting on this stop.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:344
const std::string & getMyName() const
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.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
Position getLineCenter() const
get line center
GUIVisualizationSizeSettings addSize
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:573
static const RGBColor SUMO_color_containerStop_sign
color for containerStop signs
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
A list of positions.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Position myFGSignPos
The position of the sign.
T MIN2(T a, T b)
Definition: StdDefs.h:70
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
PositionVector getSubpart(double beginOffset, double endOffset) const
get subpart of a position vector
double myFGSignRot
The rotation of the sign.
bool lefthand() const
return whether the network was built for lefthand traffic
Definition: MSNet.h:615
void move2side(double amount)
move position vector to side using certain ammount
static const RGBColor SUMO_color_containerStop
color for containerStops
const double myBegPos
The begin position this bus stop is located at.
GUIContainerStop(const std::string &id, const std::vector< std::string > &lines, MSLane &lane, double frompos, double topos)
Constructor.
double length() const
Returns the length.
#define M_PI
Definition: odrSpiral.cpp:40
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:472
The popup menu of a globject.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
std::vector< double > myFGShapeRotations
The rotations of the shape parts.
GUIGlID getGlID() const
Returns the numerical id of the object.
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:234
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
double getLastFreePos() const
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
std::vector< std::string > myLines
The list of lines that are assigned to this stop.
Representation of a lane in the micro simulation.
Definition: MSLane.h:78
A window containing a gl-object&#39;s parameter.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.