SUMO - Simulation of Urban MObility
GNEConnection.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A class for visualizing connections between lanes
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <string>
32 #include <iostream>
33 #include <utility>
34 #include <time.h>
40 #include <utils/common/ToString.h>
45 #include <utils/gui/div/GLHelper.h>
47 
48 #include "GNEConnection.h"
49 #include "GNEJunction.h"
50 #include "GNEEdge.h"
51 #include "GNELane.h"
52 
53 #ifdef CHECK_MEMORY_LEAKS
54 #include <foreign/nvwa/debug_new.h>
55 #endif // CHECK_MEMORY_LEAKS
56 
57 
58 
59 // ===========================================================================
60 // static member definitions
61 // ===========================================================================
62 int NUM_POINTS = 5;
63 
64 // ===========================================================================
65 // method definitions
66 // ===========================================================================
67 
68 GNEConnection::GNEConnection(GNEEdge &from, int fromLane, GNEEdge &to, int toLane, bool pass, bool keepClear, SUMOReal contPos, bool uncontrolled, int tlIndex) :
69  GNENetElement(from.getNet(), from.getID() + "_" + toString(fromLane) + "_" + to.getID() + "_" + toString(toLane) , GLO_JUNCTION, SUMO_TAG_CONNECTION),
70  myNBConnection(from.getNBEdge(), fromLane, to.getNBEdge(), toLane, tlIndex),
71  myConnection(fromLane, to.getNBEdge(), toLane),
72  myFromEdge(from),
73  myToEdge(to),
74  myJunction(from.getNBEdge()->getToNode()),
75  myPass(pass),
76  myKeepClear(keepClear),
77  myContPos(contPos),
78  myUncontrolled(uncontrolled) {
79  // Update geometry
81 }
82 
84 
85 
86 void
88  // Get shape of connection
90  int segments = (int) myShape.size() - 1;
91  if (segments >= 0) {
92  myShapeRotations.reserve(segments);
93  myShapeLengths.reserve(segments);
94  for (int i = 0; i < segments; ++i) {
95  const Position& f = myShape[i];
96  const Position& s = myShape[i + 1];
97  myShapeLengths.push_back(f.distanceTo2D(s));
98  myShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI);
99  }
100  }
101 }
102 
103 
104 Boundary
106  return Boundary();
107 }
108 
109 
110 GNEEdge&
112  return myFromEdge;
113 }
114 
115 
116 GNEEdge&
118  return myToEdge;
119 }
120 
121 
122 GNELane*
125 }
126 
127 
128 GNELane*
130  return myToEdge.getLanes().at(myConnection.toLane);
131 }
132 
133 
134 int
136  return myConnection.fromLane;
137 }
138 
139 
140 int
142  return myConnection.toLane;
143 }
144 
145 
146 bool
148  return myPass;
149 }
150 
151 
152 bool
154  return myKeepClear;
155 }
156 
157 
158 SUMOReal
160  return myContPos;
161 }
162 
163 
164 bool
166  return myUncontrolled;
167 }
168 
169 
170 const NBConnection&
172  return myNBConnection;
173 }
174 
175 
176 const NBEdge::Connection&
178  return myConnection;
179 }
180 
181 void
183  myPass = pass;
184 }
185 
186 
187 void
189  myKeepClear = keepClear;
190 }
191 
192 
193 void
195  myContPos = contPos;
196 }
197 
198 
199 void
200 GNEConnection::setUncontrolled(bool uncontrolled) {
201  myUncontrolled = uncontrolled ;
202 }
203 
204 
207  // Currently ignored before implementation to avoid warnings
208  UNUSED_PARAMETER(app);
209  UNUSED_PARAMETER(parent);
210  return NULL;
211 }
212 
213 
216  // Currently ignored before implementation to avoid warnings
217  UNUSED_PARAMETER(app);
218  UNUSED_PARAMETER(parent);
219  return NULL;
220 }
221 
222 
223 Boundary
225  return Boundary();
226 }
227 
228 
229 void
231  glPushMatrix();
232  glPushName(getGlID());
233  glTranslated(0, 0, GLO_JUNCTION + 0.1); // must draw on top of junction
234 // GLHelper::setColor(colorForLinksState(myState));
235  // draw lane
236  // check whether it is not too small
237  if (s.scale < 1.) {
239  } else {
241  }
242  glPopName();
243  glPopMatrix();
244 }
245 
246 
247 std::string
249  // Currently ignored before implementation to avoid warnings
250  UNUSED_PARAMETER(key);
251  return "";
252 }
253 
254 
255 void
256 GNEConnection::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
257  // Currently ignored before implementation to avoid warnings
258  UNUSED_PARAMETER(key);
259  UNUSED_PARAMETER(value);
260  UNUSED_PARAMETER(undoList);
261 }
262 
263 
264 bool
265 GNEConnection::isValid(SumoXMLAttr key, const std::string& value) {
266  // Currently ignored before implementation to avoid warnings
267  UNUSED_PARAMETER(key);
268  UNUSED_PARAMETER(value);
269  return false;
270 }
271 
272 
273 void
274 GNEConnection::setAttribute(SumoXMLAttr key, const std::string& value) {
275  // Currently ignored before implementation to avoid warnings
276  UNUSED_PARAMETER(key);
277  UNUSED_PARAMETER(value);
278 }
279 
280 
281 /****************************************************************************/
int NUM_POINTS
GNEEdge & getEdgeTo() const
get the name of the edge the vehicles may reach when leaving "from"
void updateGeometry()
update pre-computed geometry information
void setKeepClear(bool keepClear)
set parameter keepClear
const NBEdge::Connection & getNBEdgeConnection() const
get Edge::NBConnection
GNELane * getToLane() const
get lane of the outgoing lane
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:150
GNEEdge & myFromEdge
incoming edge of this connection
int getFromLaneIndex() const
get lane index of the incoming lane
int toLane
The lane the connections yields in.
Definition: NBEdge.h:168
bool isValid(SumoXMLAttr key, const std::string &value)
NBConnection myNBConnection
NBConnection associated with this connection.
int getToLaneIndex() const
get lane index of the outgoing lane
GNEEdge & myToEdge
outcoming edge of this connection
Boundary getBoundary() const
Returns the street&#39;s geometry.
Stores the information about how to visualize structures.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
static void drawBoxLines(const PositionVector &geom, const std::vector< SUMOReal > &rots, const std::vector< SUMOReal > &lengths, SUMOReal width, int cornerDetail=0, SUMOReal offset=0)
Draws thick lines.
Definition: GLHelper.cpp:176
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:54
bool getKeepClear()
get parameter keepClear
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
std::vector< SUMOReal > myShapeRotations
GUIGlID getGlID() const
Returns the numerical id of the object.
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
bool myPass
if set, vehicles which pass this (lane-2-lane) connection) will not wait
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
std::vector< SUMOReal > myShapeLengths
The lengths of the shape parts.
PositionVector myShape
the shape of the edge
#define PI
Definition: polyfonts.c:61
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
bool getPass()
get parameter pass
NBNode * myJunction
junction in which this connection is placed
int fromLane
The lane the connections starts at.
Definition: NBEdge.h:164
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
bool myKeepClear
if set to false, vehicles which pass this (lane-2-lane) connection) will not worry about blocking the...
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
~GNEConnection()
Destructor.
GNEConnection(GNEEdge &from, int fromLane, GNEEdge &to, int toLane, bool pass, bool keepClear, SUMOReal contPos, bool uncontrolled, int tlIndex=NBConnection::InvalidTlIndex)
Constructor.
SUMOReal myContPos
if set to 0, no internal junction will be built for this connection. If set to a positive value...
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
GNELane * getFromLane() const
get lane of the incoming lane
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:54
NBEdge::Connection myConnection
NBEdge::Connection associated with this connection.
PositionVector computeInternalLaneShape(NBEdge *fromE, const NBEdge::Connection &con, int numPoints) const
Compute the shape for an internal lane.
Definition: NBNode.cpp:617
void setUncontrolled(bool uncontrolled)
set parameter uncontrolled
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
Definition: GNEEdge.cpp:424
void setPass(bool pass)
set parameter pass
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
The popup menu of a globject.
void setContPos(SUMOReal contPos)
set parameter ContPos
SUMOReal getContPos()
get parameter ContPos
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:232
static void drawLine(const Position &beg, SUMOReal rot, SUMOReal visLength)
Draws a thin line.
Definition: GLHelper.cpp:269
#define SUMOReal
Definition: config.h:213
bool getUncontrolled()
get parameter uncontrolled
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:225
const NBConnection & getNBConnection() const
get NBConnection
std::string getAttribute(SumoXMLAttr key) const
A window containing a gl-object&#39;s parameter.
GNEEdge & getEdgeFrom() const
get the name of the edge the vehicles leave
a junction
bool myUncontrolled
if set to true, This connection will not be TLS-controlled despite its node being controlled...