SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIBusStop.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A lane area vehicles can halt at (gui-version)
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <string>
36 #include <utils/geom/Line.h>
37 #include <utils/geom/Boundary.h>
38 #include <utils/gui/div/GLHelper.h>
39 #include <utils/common/ToString.h>
40 #include <microsim/MSNet.h>
41 #include <microsim/MSLane.h>
42 #include <microsim/MSEdge.h>
43 #include "GUINet.h"
44 #include "GUIEdge.h"
45 #include "GUIPerson.h"
46 #include "GUIBusStop.h"
49 #include <gui/GUIGlobals.h>
55 #include <utils/geom/GeomHelper.h>
56 #include <guisim/GUIBusStop.h>
58 
59 #ifdef CHECK_MEMORY_LEAKS
60 #include <foreign/nvwa/debug_new.h>
61 #endif // CHECK_MEMORY_LEAKS
62 
63 
64 // ===========================================================================
65 // method definitions
66 // ===========================================================================
67 GUIBusStop::GUIBusStop(const std::string& id, const std::vector<std::string>& lines, MSLane& lane,
68  SUMOReal frompos, SUMOReal topos)
69  : MSBusStop(id, lines, lane, frompos, topos),
70  GUIGlObject_AbstractAdd("busStop", GLO_TRIGGER, id) {
71  myFGShape = lane.getShape();
73  myFGShape = myFGShape.getSubpart(frompos, topos);
74  myFGShapeRotations.reserve(myFGShape.size() - 1);
75  myFGShapeLengths.reserve(myFGShape.size() - 1);
76  int e = (int) myFGShape.size() - 1;
77  for (int i = 0; i < e; ++i) {
78  const Position& f = myFGShape[i];
79  const Position& s = myFGShape[i + 1];
80  myFGShapeLengths.push_back(f.distanceTo(s));
81  myFGShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI);
82  }
84  tmp.move2side(1.5);
85  myFGSignPos = tmp.getLineCenter();
86  myFGSignRot = 0;
87  if (tmp.length() != 0) {
89  myFGSignRot -= 90;
90  }
91 }
92 
93 
95 
96 
99  GUISUMOAbstractView& parent) {
100  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
101  buildPopupHeader(ret, app);
106  buildPositionCopyEntry(ret, false);
107  return ret;
108 }
109 
110 
115  new GUIParameterTableWindow(app, *this, 4);
116  // add items
117  ret->mkItem("begin position [m]", false, myBegPos);
118  ret->mkItem("end position [m]", false, myEndPos);
119  ret->mkItem("person number [#]", true, new FunctionBinding<GUIBusStop, unsigned int>(this, &MSBusStop::getPersonNumber));
120  // close building
121  ret->closeBuilding();
122  return ret;
123 }
124 
125 
126 void
128  glPushName(getGlID());
129  glPushMatrix();
130  RGBColor green(76, 170, 50, 255);
131  RGBColor yellow(255, 235, 0, 255);
132  // draw the area
133  size_t i;
134  glTranslated(0, 0, getType());
135  GLHelper::setColor(green);
137  // draw details unless zoomed out to far
138  if (s.scale * s.addExaggeration >= 10) {
139  // draw the lines
140  for (i = 0; i != myLines.size(); ++i) {
141  glPushMatrix();
142  glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0);
143  glRotated(180, 1, 0, 0);
144  glRotated(myFGSignRot, 0, 0, 1);
145  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
146  pfSetPosition(0, 0);
147  pfSetScale(1.f);
148  glScaled(s.addExaggeration, s.addExaggeration, 1);
149  glTranslated(1.2, -(double)i, 0);
150  pfDrawString(myLines[i].c_str());
151  glPopMatrix();
152  }
153  // draw the sign
154  glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0);
155  int noPoints = 9;
156  if (s.scale * s.addExaggeration > 25) {
157  noPoints = MIN2((int)(9.0 + (s.scale * s.addExaggeration) / 10.0), 36);
158  }
159  glScaled(s.addExaggeration, s.addExaggeration, 1);
160  GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints);
161  glTranslated(0, 0, .1);
162  GLHelper::setColor(yellow);
163  GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints);
164  if (s.scale * s.addExaggeration >= 4.5) {
165  GLHelper::drawText("H", Position(), .1, 1.6 * s.addExaggeration, green, myFGSignRot);
166  }
167  }
168  glPopMatrix();
169  glPopName();
170  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
171  for (std::vector<MSPerson*>::const_iterator i = myWaitingPersons.begin(); i != myWaitingPersons.end(); ++i) {
172  glTranslated(0, 1, 0); // make multiple persons viewable
173  static_cast<GUIPerson*>(*i)->drawGL(s);
174  }
175 }
176 
177 
178 Boundary
181  b.grow(20);
182  return b;
183 }
184 
185 
186 
187 /****************************************************************************/
188