Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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>
26
27#include "GNEInternalLane.h"
28
29// ===========================================================================
30// FOX callback mapping
31// ===========================================================================
32
33FXIMPLEMENT(GNEInternalLane, FXDelegator, 0, 0)
34
35// ===========================================================================
36// static member definitions
37// ===========================================================================
38
39StringBijection<FXuint>::Entry GNEInternalLane::linkStateNamesValues[] = {
40 { "Green-Major", LINKSTATE_TL_GREEN_MAJOR },
41 { "Green-Minor", LINKSTATE_TL_GREEN_MINOR },
42 //{ "Yellow-Major", LINKSTATE_TL_YELLOW_MAJOR }, (should not be used)
43 { "Yellow", LINKSTATE_TL_YELLOW_MINOR },
44 { "Red", LINKSTATE_TL_RED },
45 { "Red-Yellow", LINKSTATE_TL_REDYELLOW },
46 { "Stop", LINKSTATE_STOP },
48 { "Off-Blinking", LINKSTATE_TL_OFF_BLINKING },
49};
50
53
54// ===========================================================================
55// method definitions
56// ===========================================================================
57
59 const std::string& id, const PositionVector& shape, int tlIndex, LinkState state) :
60 GNENetworkElement(junctionParent->getNet(), id, GNE_TAG_INTERNAL_LANE),
61 myJunctionParent(junctionParent),
62 myState(state),
63 myStateTarget(myState),
64 myEditor(editor),
65 myTlIndex(tlIndex),
66 myPopup(nullptr) {
67 // calculate internal lane geometry
69 // update centering boundary without updating grid
71 // vinculate this internal lane with their junction parent
73}
74
75
77 GNENetworkElement(nullptr, "dummyInternalLane", GNE_TAG_INTERNAL_LANE),
78 myJunctionParent(nullptr),
79 myState(0),
80 myEditor(0),
81 myTlIndex(0),
82 myPopup(nullptr) {
83}
84
85
87 // remove this internal lane from junction parent
89}
90
91
94 return nullptr;
95}
96
97
100 return nullptr;
101}
102
103
104const Parameterised*
106 return nullptr;
107}
108
109
110void
112 // nothing to update
113}
114
115
120
121
122bool
124 return false;
125}
126
127
128bool
130 return false;
131}
132
133
134bool
136 // check opened popup
137 if (myNet->getViewNet()->getPopup()) {
138 return myNet->getViewNet()->getPopup()->getGLObject() == this;
139 }
140 return false;
141}
142
143
144bool
148
149
150bool
152 return false;
153}
154
155
156bool
158 return false;
159}
160
161
162bool
164 return false;
165}
166
167
168bool
170 return false;
171}
172
173
174long
175GNEInternalLane::onDefault(FXObject* obj, FXSelector sel, void* data) {
176 if (myEditor != nullptr) {
177 FXuint before = myState;
178 myStateTarget.handle(obj, sel, data);
179 if (myState != before) {
180 myEditor->handleChange(this);
181 }
182 // let GUISUMOAbstractView know about clicks so that the popup is properly destroyed
183 if (FXSELTYPE(sel) == SEL_COMMAND) {
184 if (myPopup != nullptr) {
186 myPopup = nullptr;
187 }
188 }
189 }
190 return 1;
191}
192
193
194void
196 // only draw if we're not selecting E1 detectors in TLS Mode
198 // get detail level
199 const auto d = s.getDetailLevel(1);
200 // draw geometry only if we'rent in drawForObjectUnderCursor mode
202 // get link state color
203 const auto linkStateColor = colorForLinksState(myState);
204 // push layer matrix
206 // translate to front
208 // move front again
209 glTranslated(0, 0, 0.5);
210 // set color
211 GLHelper::setColor(linkStateColor);
212 // draw geometry
215 // pop layer matrix
217 // draw dotted contour
219 }
220 // calculate contour
222 s.connectionSettings.connectionWidth, 1, true, true, 0, nullptr, myJunctionParent);
223 }
224}
225
226
227void
229 // Internal lanes cannot be removed
230}
231
232
233void
237
238
239void
241 myState = state;
242 myOrigState = state;
243}
244
245
250
251
252int
254 return myTlIndex;
255}
256
257
260 myPopup = new GUIGLObjectPopupMenu(app, parent, this);
262 if ((myEditor != nullptr) && (myEditor->getViewNet()->getEditModes().isCurrentSupermodeNetwork())) {
263 const std::vector<std::string> names = LinkStateNames.getStrings();
264 for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
265 FXuint state = LinkStateNames.get(*it);
266 std::string origHint = ((LinkState)state == myOrigState ? " (original)" : "");
267 FXMenuRadio* mc = new FXMenuRadio(myPopup, (*it + origHint).c_str(), this, FXDataTarget::ID_OPTION + state);
268 mc->setSelBackColor(MFXUtils::getFXColor(colorForLinksState(state)));
269 mc->setBackColor(MFXUtils::getFXColor(colorForLinksState(state)));
270 }
271 }
272 return myPopup;
273}
274
275
278 // internal lanes don't have attributes
280 // close building
281 ret->closeBuilding();
282 return ret;
283}
284
285
290
291
292void
294 // nothing to update
295}
296
297
300 try {
302 } catch (ProcessError&) {
303 WRITE_WARNINGF(TL("invalid link state='%'"), toString(state));
304 return RGBColor::BLACK;
305 }
306}
307
308
309std::string
313
314
315double
319
320
325
326
331
332
333void
334GNEInternalLane::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
335 setCommonAttribute(key, value, undoList);
336}
337
338
339bool
340GNEInternalLane::isValid(SumoXMLAttr key, const std::string& value) {
341 return isCommonAttributeValid(key, value);
342}
343
344
345void
346GNEInternalLane::setAttribute(SumoXMLAttr key, const std::string& value) {
347 setCommonAttribute(key, value);
348}
349
350/****************************************************************************/
@ GLO_TLLOGIC
a tl-logic
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define TL(string)
Definition MsgHandler.h:304
@ 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
double getCommonAttributeDouble(SumoXMLAttr key) const
PositionVector getCommonAttributePositionVector(SumoXMLAttr key) const
void setCommonAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
Position getCommonAttributePosition(SumoXMLAttr key) const
GNENet * myNet
pointer to net
bool isCommonAttributeValid(SumoXMLAttr key, const std::string &value) const
std::string getCommonAttribute(SumoXMLAttr key) const
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:145
bool checkDrawOverContour() const override
check if draw over contour (orange)
void updateGeometry() override
update pre-computed geometry information
Parameterised * getParameters() override
get parameters associated with this internalLane
GNEInternalLane()
FOX needs this.
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
bool checkDrawDeleteContour() const override
check if draw delete contour (pink/white)
static RGBColor colorForLinksState(FXuint state)
return the color for each linkstate
LinkState myOrigState
the original state of the link (used for tracking modification)
bool checkDrawSelectContour() const override
check if draw select contour (blue)
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
bool checkDrawMoveContour() const override
check if draw move contour (red)
FXuint myState
the state of the link (used for visualization)
double getAttributeDouble(SumoXMLAttr key) const override
LinkState getLinkState() const
whether link state has been modified
FXDataTarget myStateTarget
int myTlIndex
the tl-index of this lane
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this internalLane
GUIGLObjectPopupMenu * myPopup
the created popup
Position getPositionInView() const
Returns position of hierarchical element in view.
bool checkDrawDeleteContourSmall() const override
check if draw delete contour small (pink/white)
static StringBijection< FXuint >::Entry linkStateNamesValues[]
linkstates names values
bool checkDrawToContour() const override
check if draw from contour (magenta)
std::string getAttribute(SumoXMLAttr key) const override
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
void updateGLObject() override
update GLObject (geometry, ID, etc.)
long onDefault(FXObject *, FXSelector, void *) override
multiplexes message to two targets
GUIGeometry myInternalLaneGeometry
internal lane geometry
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
static const StringBijection< FXuint > LinkStateNames
long names for link states
int getTLIndex() const
get Traffic Light index
bool checkDrawRelatedContour() const override
check if draw related contour (cyan)
void deleteGLObject() override
delete element
Position getAttributePosition(SumoXMLAttr key) const override
bool isValid(SumoXMLAttr key, const std::string &value) override
~GNEInternalLane()
Destructor.
bool checkDrawFromContour() const override
check if draw from contour (green)
void setLinkState(LinkState state)
set the linkState (controls drawing color)
GNETLSEditorFrame * myEditor
the editor to inform about changes
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
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2193
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
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.
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
bool drawForViewObjectsHandler
whether drawing is performed for the purpose of selecting objects in view using ViewObjectsHandler
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition MFXUtils.cpp:145
An upper class for objects with additional parameters.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
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