Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNEInternalLane.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// A class for visualizing Inner Lanes (used when editing traffic lights)
19/****************************************************************************/
20
21#include <netedit/GNENet.h>
22#include <netedit/GNEViewNet.h>
28
29#include "GNEInternalLane.h"
30#include "GNEJunction.h"
31
32// ===========================================================================
33// FOX callback mapping
34// ===========================================================================
35FXIMPLEMENT(GNEInternalLane, FXDelegator, 0, 0)
36
37// ===========================================================================
38// static member definitions
39// ===========================================================================
40
41StringBijection<FXuint>::Entry GNEInternalLane::linkStateNamesValues[] = {
42 { "Green-Major", LINKSTATE_TL_GREEN_MAJOR },
43 { "Green-Minor", LINKSTATE_TL_GREEN_MINOR },
44 //{ "Yellow-Major", LINKSTATE_TL_YELLOW_MAJOR }, (should not be used)
45 { "Yellow", LINKSTATE_TL_YELLOW_MINOR },
46 { "Red", LINKSTATE_TL_RED },
47 { "Red-Yellow", LINKSTATE_TL_REDYELLOW },
48 { "Stop", LINKSTATE_STOP },
50 { "Off-Blinking", LINKSTATE_TL_OFF_BLINKING },
51};
52
55
56// ===========================================================================
57// method definitions
58// ===========================================================================
59
61 const std::string& id, const PositionVector& shape, int tlIndex, LinkState state) :
62 GNENetworkElement(junctionParent->getNet(), id, GNE_TAG_INTERNAL_LANE),
63 myJunctionParent(junctionParent),
64 myState(state),
65 myStateTarget(myState),
66 myEditor(editor),
67 myTlIndex(tlIndex),
68 myPopup(nullptr) {
69 // calculate internal lane geometry
71 // update centering boundary without updating grid
73 // vinculate this internal lane with their junction parent
75}
76
77
79 GNENetworkElement(nullptr, "dummyInternalLane", GNE_TAG_INTERNAL_LANE),
80 myJunctionParent(nullptr),
81 myState(0),
82 myEditor(0),
83 myTlIndex(0),
84 myPopup(nullptr) {
85}
86
87
89 // remove this internal lane from junction parent
91}
92
93
94void
96 // nothing to update
97}
98
99
104
105
106bool
108 return false;
109}
110
111
112bool
114 return false;
115}
116
117
118bool
120 // check opened popup
121 if (myNet->getViewNet()->getPopup()) {
122 return myNet->getViewNet()->getPopup()->getGLObject() == this;
123 }
124 return false;
125}
126
127
128bool
132
133
134bool
136 return false;
137}
138
139
140bool
142 return false;
143}
144
145
146bool
148 return false;
149}
150
151
152bool
154 return false;
155}
156
157
160 // internal lanes cannot be moved
161 return nullptr;
162}
163
164
165void
166GNEInternalLane::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undolist*/) {
167 // geometry points of internal lanes cannot be removed
168}
169
170
171long
172GNEInternalLane::onDefault(FXObject* obj, FXSelector sel, void* data) {
173 if (myEditor != nullptr) {
174 FXuint before = myState;
175 myStateTarget.handle(obj, sel, data);
176 if (myState != before) {
177 myEditor->handleChange(this);
178 }
179 // let GUISUMOAbstractView know about clicks so that the popup is properly destroyed
180 if (FXSELTYPE(sel) == SEL_COMMAND) {
181 if (myPopup != nullptr) {
183 myPopup = nullptr;
184 }
185 }
186 }
187 return 1;
188}
189
190
191void
193 // only draw if we're not selecting E1 detectors in TLS Mode
195 // get detail level
196 const auto d = s.getDetailLevel(1);
197 // draw geometry only if we'rent in drawForObjectUnderCursor mode
199 // get link state color
200 const auto linkStateColor = colorForLinksState(myState);
201 // push layer matrix
203 // translate to front
205 // move front again
206 glTranslated(0, 0, 0.5);
207 // set color
208 GLHelper::setColor(linkStateColor);
209 // draw geometry
212 // pop layer matrix
214 // draw edge name
215 if (s.internalEdgeName.show(this)) {
217 s.scale, s.angle);
218 }
219 // draw dotted contour
221 }
222 // calculate contour
224 s.connectionSettings.connectionWidth, 1, true, true, 0, nullptr, myJunctionParent);
225 }
226}
227
228
229void
231 // Internal lanes cannot be removed
232}
233
234
235void
239
240
241void
243 myState = state;
244 myOrigState = state;
245}
246
247
252
253
254int
256 return myTlIndex;
257}
258
259
262 myPopup = new GUIGLObjectPopupMenu(app, parent, this);
264 if ((myEditor != nullptr) && (myEditor->getViewNet()->getEditModes().isCurrentSupermodeNetwork())) {
265 const std::vector<std::string> names = LinkStateNames.getStrings();
266 for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
267 FXuint state = LinkStateNames.get(*it);
268 std::string origHint = ((LinkState)state == myOrigState ? " (original)" : "");
269 FXMenuRadio* mc = new FXMenuRadio(myPopup, (*it + origHint).c_str(), this, FXDataTarget::ID_OPTION + state);
270 mc->setSelBackColor(MFXUtils::getFXColor(colorForLinksState(state)));
271 mc->setBackColor(MFXUtils::getFXColor(colorForLinksState(state)));
272 }
273 }
274 return myPopup;
275}
276
277
280 // internal lanes don't have attributes
282 // close building
283 ret->closeBuilding();
284 return ret;
285}
286
287
292
293
294void
296 // nothing to update
297}
298
299
302 try {
304 } catch (ProcessError&) {
305 WRITE_WARNINGF(TL("invalid link state='%'"), toString(state));
306 return RGBColor::BLACK;
307 }
308}
309
310
311std::string
313 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
314}
315
316
319 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
320}
321
322
323void
324GNEInternalLane::setAttribute(SumoXMLAttr key, const std::string& /*value*/, GNEUndoList* /*undoList*/) {
325 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
326}
327
328
329bool
330GNEInternalLane::isValid(SumoXMLAttr key, const std::string& /*value*/) {
331 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
332}
333
334
335bool
337 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
338}
339
340
343 throw InvalidArgument(getTagStr() + " doesn't have parameters");
344}
345
346
347void
348GNEInternalLane::setAttribute(SumoXMLAttr key, const std::string& /*value*/) {
349 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
350}
351
352
353void
355 // internal lanes cannot be moved
356}
357
358
359void
360GNEInternalLane::commitMoveShape(const GNEMoveResult& /*moveResult*/, GNEUndoList* /*undoList*/) {
361 // internal lanes cannot be moved
362}
363
364/****************************************************************************/
@ GLO_TLLOGIC
a tl-logic
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:288
#define TL(string)
Definition MsgHandler.h:305
@ GNE_TAG_INTERNAL_LANE
internal lane
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
@ LINKSTATE_TL_REDYELLOW
The link has red light (must brake) but indicates upcoming green.
@ LINKSTATE_STOP
This is an uncontrolled, minor link, has to stop.
@ LINKSTATE_TL_GREEN_MAJOR
The link has green light, may pass.
@ LINKSTATE_TL_OFF_BLINKING
The link is controlled by a tls which is off and blinks, has to brake.
@ LINKSTATE_TL_YELLOW_MINOR
The link has yellow light, has to brake anyway.
@ LINKSTATE_TL_RED
The link has red light (must brake)
@ LINKSTATE_TL_GREEN_MINOR
The link has green light, has to brake.
@ LINKSTATE_TL_OFF_NOSIGNAL
The link is controlled by a tls which is off, not blinking, may pass.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition GLHelper.cpp:779
const std::string & getTagStr() const
get tag assigned to this object in string format
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
GNENet * myNet
pointer to net
void calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double layer, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset, const GNESegment *segment, const GUIGlObject *boundaryParent, const bool addToSelectedObjects=true) const
calculate contour extruded (used in elements formed by a central shape)
Boundary getContourBoundary() const
get contour boundary
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:154
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
void deleteGLObject()
delete element
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
GNEInternalLane()
FOX needs this.
bool checkDrawDeleteContourSmall() const
check if draw delete contour small (pink/white)
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
static RGBColor colorForLinksState(FXuint state)
return the color for each linkstate
LinkState myOrigState
the original state of the link (used for tracking modification)
PositionVector getAttributePositionVector(SumoXMLAttr key) const
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
void updateGeometry()
update pre-computed geometry information
std::string getAttribute(SumoXMLAttr key) const
FXuint myState
the state of the link (used for visualization)
LinkState getLinkState() const
whether link state has been modified
bool checkDrawSelectContour() const
check if draw select contour (blue)
FXDataTarget myStateTarget
int myTlIndex
the tl-index of this lane
GUIGLObjectPopupMenu * myPopup
the created popup
bool checkDrawFromContour() const
check if draw from contour (green)
bool checkDrawOverContour() const
check if draw over contour (orange)
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Position getPositionInView() const
Returns position of hierarchical element in view.
bool checkDrawToContour() const
check if draw from contour (magenta)
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
GNEMoveOperation * getMoveOperation()
get move operation
static StringBijection< FXuint >::Entry linkStateNamesValues[]
linkstates names values
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
GUIGeometry myInternalLaneGeometry
internal lane geometry
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
bool isValid(SumoXMLAttr key, const std::string &value)
static const StringBijection< FXuint > LinkStateNames
long names for link states
bool checkDrawMoveContour() const
check if draw move contour (red)
int getTLIndex() const
get Traffic Light index
const Parameterised::Map & getACParametersMap() const
get parameters map
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
void updateGLObject()
update GLObject (geometry, ID, etc.)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
~GNEInternalLane()
Destructor.
void setLinkState(LinkState state)
set the linkState (controls drawing color)
GNETLSEditorFrame * myEditor
the editor to inform about changes
bool isAttributeEnabled(SumoXMLAttr key) const
GNEJunction * myJunctionParent
pointer to junction parent
void addInternalLane(const GNEInternalLane *internalLane)
add internal lane
Position getPositionInView() const
Returns position of hierarchical element in view.
void removeInternalLane(const GNEInternalLane *internalLane)
remove internal lane
move operation
move result
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2194
GNEContour myNetworkElementContour
network element contour
void handleChange(GNEInternalLane *lane)
update phase definition for the current traffic light and phase
const GUIGlObject * getGUIGlObjectFront() const
get front GUIGLObject or a pointer to nullptr
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
const GNEViewNetHelper::ViewObjectsSelector & getViewObjectsSelector() const
get objects under cursor
bool selectingDetectorsTLSMode() const
check if we're selecting detectors in TLS mode
The popup menu of a globject.
GUISUMOAbstractView * getParentView()
return the real owner of this popup
GUIGlObject * getGLObject() const
The object that belongs to this popup-menu.
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
A window containing a gl-object's parameter.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
void destroyPopup()
destroys the popup
GUIGLObjectPopupMenu * getPopup() const
ge the current popup-menu
Stores the information about how to visualize structures.
GUIVisualizationTextSettings internalEdgeName
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationConnectionSettings connectionSettings
connection settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
static const RGBColor & getLinkColor(const LinkState &ls, bool realistic=false)
map from LinkState to color constants
double scale
information about a lane's width (temporary, used for a single view)
bool drawForViewObjectsHandler
whether drawing is performed for the purpose of selecting objects in view using ViewObjectsHandler
double angle
The current view rotation angle.
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition MFXUtils.cpp:145
std::map< std::string, std::string > Map
parameters map
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
Position getLineCenter() const
get line center
static const RGBColor BLACK
Definition RGBColor.h:196
std::vector< std::string > getStrings() const
get all strings
T get(const std::string &str) const
get key
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static const double connectionWidth
connection width
static const double segmentWidth
width of dotted contour segments
bool show(const GUIGlObject *o) const
whether to show the text