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.sourceforge.net/
12 // Copyright (C) 2001-2012 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>
56 #include <utils/geom/GeomHelper.h>
57 #include <guisim/GUIBusStop.h>
59 
60 #ifdef CHECK_MEMORY_LEAKS
61 #include <foreign/nvwa/debug_new.h>
62 #endif // CHECK_MEMORY_LEAKS
63 
64 
65 // ===========================================================================
66 // method definitions
67 // ===========================================================================
68 GUIBusStop::GUIBusStop(const std::string& id, const std::vector<std::string>& lines, MSLane& lane,
69  SUMOReal frompos, SUMOReal topos)
70  : MSBusStop(id, lines, lane, frompos, topos),
71  GUIGlObject_AbstractAdd("busStop", GLO_TRIGGER, id) {
72  myFGShape = lane.getShape();
74  myFGShape = myFGShape.getSubpart(frompos, topos);
75  myFGShapeRotations.reserve(myFGShape.size() - 1);
76  myFGShapeLengths.reserve(myFGShape.size() - 1);
77  int e = (int) myFGShape.size() - 1;
78  for (int i = 0; i < e; ++i) {
79  const Position& f = myFGShape[i];
80  const Position& s = myFGShape[i + 1];
81  myFGShapeLengths.push_back(f.distanceTo(s));
82  myFGShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI);
83  }
85  tmp.move2side(1.5);
86  myFGSignPos = tmp.getLineCenter();
87  myFGSignRot = 0;
88  if (tmp.length() != 0) {
90  myFGSignRot -= 90;
91  }
92 }
93 
94 
96 
97 
100  GUISUMOAbstractView& parent) {
101  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
102  buildPopupHeader(ret, app);
107  buildPositionCopyEntry(ret, false);
108  return ret;
109 }
110 
111 
116  new GUIParameterTableWindow(app, *this, 4);
117  // add items
118  ret->mkItem("begin position [m]", false, myBegPos);
119  ret->mkItem("end position [m]", false, myEndPos);
120  ret->mkItem("person number [#]", true, new FunctionBinding<GUIBusStop, unsigned int>(this, &MSBusStop::getPersonNumber));
121  // close building
122  ret->closeBuilding();
123  return ret;
124 }
125 
126 
127 void
129  glPushName(getGlID());
130  glPushMatrix();
131  RGBColor green(76. / 255., 170. / 255., 50. / 255.);
132  RGBColor yellow(255. / 255., 235. / 255., 0. / 255.);
133  // draw the area
134  size_t i;
135  glTranslated(0, 0, getType());
136  GLHelper::setColor(green);
138  // draw details unless zoomed out to far
139  if (s.scale * s.addExaggeration >= 10) {
140  // draw the lines
141  for (i = 0; i != myLines.size(); ++i) {
142  glPushMatrix();
143  glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0);
144  glRotated(180, 1, 0, 0);
145  glRotated(myFGSignRot, 0, 0, 1);
146  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
147  pfSetPosition(0, 0);
148  pfSetScale(1.f);
149  glScaled(s.addExaggeration, s.addExaggeration, 1);
150  glTranslated(1.2, -(double)i, 0);
151  pfDrawString(myLines[i].c_str());
152  glPopMatrix();
153  }
154  // draw the sign
155  glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0);
156  int noPoints = 9;
157  if (s.scale * s.addExaggeration > 25) {
158  noPoints = MIN2((int)(9.0 + (s.scale * s.addExaggeration) / 10.0), 36);
159  }
160  glScaled(s.addExaggeration, s.addExaggeration, 1);
161  GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints);
162  glTranslated(0, 0, .1);
163  GLHelper::setColor(yellow);
164  GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints);
165  if (s.scale * s.addExaggeration >= 4.5) {
166  GLHelper::drawText("H", Position(), .1, 1.6 * s.addExaggeration, green, myFGSignRot);
167  }
168  }
169  glPopMatrix();
170  glPopName();
171  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
172  for (std::vector<MSPerson*>::const_iterator i = myWaitingPersons.begin(); i != myWaitingPersons.end(); ++i) {
173  glTranslated(0, 1, 0); // make multiple persons viewable
174  static_cast<GUIPerson*>(*i)->drawGL(s);
175  }
176 }
177 
178 
179 Boundary
182  b.grow(20);
183  return b;
184 }
185 
186 
187 
188 /****************************************************************************/
189