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 #ifdef _WIN32
34 #include <windows.h>
35 #endif
36 
37 #include <GL/gl.h>
38 
39 #include <string>
42 #include <utils/geom/Line.h>
43 #include <utils/geom/Boundary.h>
44 #include <utils/gui/div/GLHelper.h>
45 #include <utils/common/ToString.h>
46 #include <microsim/MSNet.h>
47 #include <microsim/MSLane.h>
48 #include <microsim/MSEdge.h>
49 #include <guisim/GUINet.h>
50 #include <guisim/GUIEdge.h>
51 #include "GUIBusStop.h"
54 #include <gui/GUIGlobals.h>
61 #include <utils/geom/GeomHelper.h>
63 #include <guisim/GUIBusStop.h>
64 
65 #ifdef CHECK_MEMORY_LEAKS
66 #include <foreign/nvwa/debug_new.h>
67 #endif // CHECK_MEMORY_LEAKS
68 
69 
70 // ===========================================================================
71 // method definitions
72 // ===========================================================================
73 GUIBusStop::GUIBusStop(const std::string& id, const std::vector<std::string> &lines, MSLane& lane,
74  SUMOReal frompos, SUMOReal topos)
75  : MSBusStop(id, lines, lane, frompos, topos),
76  GUIGlObject_AbstractAdd("bus_stop", GLO_TRIGGER, id) {
77  myFGShape = lane.getShape();
79  myFGShape = myFGShape.getSubpart(frompos, topos);
80  myFGShapeRotations.reserve(myFGShape.size() - 1);
81  myFGShapeLengths.reserve(myFGShape.size() - 1);
82  int e = (int) myFGShape.size() - 1;
83  for (int i = 0; i < e; ++i) {
84  const Position& f = myFGShape[i];
85  const Position& s = myFGShape[i + 1];
86  myFGShapeLengths.push_back(f.distanceTo(s));
87  myFGShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI);
88  }
90  tmp.move2side(1.5);
91  myFGSignPos = tmp.getLineCenter();
92  myFGSignRot = 0;
93  if (tmp.length() != 0) {
95  myFGSignRot -= 90;
96  }
97 }
98 
99 
101 
102 
105  GUISUMOAbstractView& parent) {
106  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
107  buildPopupHeader(ret, app);
111  buildPositionCopyEntry(ret, false);
112  return ret;
113 }
114 
115 
119  return 0;
120 }
121 
122 
123 void
125  glPushName(getGlID());
126  glPushMatrix();
127  RGBColor green(76. / 255., 170. / 255., 50. / 255.);
128  RGBColor yellow(255. / 255., 235. / 255., 0. / 255.);
129  // draw the area
130  size_t i;
131  glTranslated(0, 0, getType());
132  GLHelper::setColor(green);
134  // draw details unless zoomed out to far
135  if (s.scale* s.addExaggeration >= 10) {
136  // draw the lines
137  for (i = 0; i != myLines.size(); ++i) {
138  glPushMatrix();
139  glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0);
140  glRotated(180, 1, 0, 0);
141  glRotated(myFGSignRot, 0, 0, 1);
142  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
143  pfSetPosition(0, 0);
144  pfSetScale(1.f);
145  glScaled(s.addExaggeration, s.addExaggeration, 1);
146  glTranslated(1.2, -(double)i, 0);
147  pfDrawString(myLines[i].c_str());
148  glPopMatrix();
149  }
150  // draw the sign
151  glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0);
152  int noPoints = 9;
153  if (s.scale * s.addExaggeration > 25) {
154  noPoints = MIN2((int)(9.0 + (s.scale * s.addExaggeration) / 10.0), 36);
155  }
156  glScaled(s.addExaggeration, s.addExaggeration, 1);
157  GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints);
158  glTranslated(0, 0, .1);
159  GLHelper::setColor(yellow);
160  GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints);
161  if (s.scale* s.addExaggeration >= 4.5) {
162  GLHelper::drawText("H", Position(), .1, 1.6 * s.addExaggeration, green, myFGSignRot);
163  }
164  }
165  glPopMatrix();
166  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
167  glPopName();
168 }
169 
170 
171 Boundary
174  b.grow(20);
175  return b;
176 }
177 
178 
179 
180 /****************************************************************************/
181