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-2024 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#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
29
30#include "GNEInternalLane.h"
31#include "GNEJunction.h"
32
33// ===========================================================================
34// FOX callback mapping
35// ===========================================================================
36FXIMPLEMENT(GNEInternalLane, FXDelegator, 0, 0)
37
38// ===========================================================================
39// static member definitions
40// ===========================================================================
41
42StringBijection<FXuint>::Entry GNEInternalLane::linkStateNamesValues[] = {
43 { "Green-Major", LINKSTATE_TL_GREEN_MAJOR },
44 { "Green-Minor", LINKSTATE_TL_GREEN_MINOR },
45 //{ "Yellow-Major", LINKSTATE_TL_YELLOW_MAJOR }, (should not be used)
46 { "Yellow", LINKSTATE_TL_YELLOW_MINOR },
47 { "Red", LINKSTATE_TL_RED },
48 { "Red-Yellow", LINKSTATE_TL_REDYELLOW },
49 { "Stop", LINKSTATE_STOP },
51 { "Off-Blinking", LINKSTATE_TL_OFF_BLINKING },
52};
53
56
57// ===========================================================================
58// method definitions
59// ===========================================================================
60
62 const std::string& id, const PositionVector& shape, int tlIndex, LinkState state) :
63 GNENetworkElement(junctionParent->getNet(), id, GLO_TLLOGIC, GNE_TAG_INTERNAL_LANE,
64 GUIIconSubSys::getIcon(GUIIcon::LANE), {}, {}, {}, {}, {}, {}),
65 myJunctionParent(junctionParent),
66 myState(state),
67 myStateTarget(myState),
68 myEditor(editor),
69 myTlIndex(tlIndex),
70myPopup(nullptr) {
71 // calculate internal lane geometry
72 myInternalLaneGeometry.updateGeometry(shape);
73 // update centering boundary without updating grid
74 updateCenteringBoundary(false);
75 // vinculate this internal lane with their junction parent
76 myJunctionParent->addInternalLane(this);
77}
78
79
81 GNENetworkElement(nullptr, "dummyInternalLane", GLO_TLLOGIC, GNE_TAG_INTERNAL_LANE,
82 GUIIconSubSys::getIcon(GUIIcon::LANE), {}, {}, {}, {}, {}, {}),
83myJunctionParent(nullptr),
84myState(0),
85myEditor(0),
86myTlIndex(0),
87myPopup(nullptr) {
88}
89
90
92 // remove this internal lane from junction parent
94}
95
96
97void
99 // nothing to update
100}
101
102
107
108
109bool
111 return false;
112}
113
114
115bool
117 return false;
118}
119
120
121bool
123 return false;
124}
125
126
127bool
131
132
133bool
135 return false;
136}
137
138
139bool
141 return false;
142}
143
144
145bool
147 return false;
148}
149
150
153 // internal lanes cannot be moved
154 return nullptr;
155}
156
157
158void
159GNEInternalLane::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undolist*/) {
160 // geometry points of internal lanes cannot be removed
161}
162
163
164long
165GNEInternalLane::onDefault(FXObject* obj, FXSelector sel, void* data) {
166 if (myEditor != nullptr) {
167 FXuint before = myState;
168 myStateTarget.handle(obj, sel, data);
169 if (myState != before) {
170 myEditor->handleChange(this);
171 }
172 // let GUISUMOAbstractView know about clicks so that the popup is properly destroyed
173 if (FXSELTYPE(sel) == SEL_COMMAND) {
174 if (myPopup != nullptr) {
176 myPopup = nullptr;
177 }
178 }
179 }
180 return 1;
181}
182
183
184void
186 // only draw if we're not selecting E1 detectors in TLS Mode
188 // get detail level
189 const auto d = s.getDetailLevel(1);
190 // draw geometry only if we'rent in drawForObjectUnderCursor mode
192 // get link state color
193 const auto linkStateColor = colorForLinksState(myState);
194 // push layer matrix
196 // translate to front
198 // move front again
199 glTranslated(0, 0, 0.5);
200 // set color
201 GLHelper::setColor(linkStateColor);
202 // draw geometry
205 // pop layer matrix
207 // draw edge name
208 if (s.internalEdgeName.show(this)) {
210 s.scale, s.angle);
211 }
212 // draw dotted contour
214 }
215 // calculate contour
217 s.connectionSettings.connectionWidth, 1, true, true, 0, nullptr);
218 }
219}
220
221
222void
224 // Internal lanes cannot be removed
225}
226
227
228void
232
233
234void
236 myState = state;
237 myOrigState = state;
238}
239
240
245
246
247int
249 return myTlIndex;
250}
251
252
255 myPopup = new GUIGLObjectPopupMenu(app, parent, *this);
257 if ((myEditor != nullptr) && (myEditor->getViewNet()->getEditModes().isCurrentSupermodeNetwork())) {
258 const std::vector<std::string> names = LinkStateNames.getStrings();
259 for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
260 FXuint state = LinkStateNames.get(*it);
261 std::string origHint = ((LinkState)state == myOrigState ? " (original)" : "");
262 FXMenuRadio* mc = new FXMenuRadio(myPopup, (*it + origHint).c_str(), this, FXDataTarget::ID_OPTION + state);
263 mc->setSelBackColor(MFXUtils::getFXColor(colorForLinksState(state)));
264 mc->setBackColor(MFXUtils::getFXColor(colorForLinksState(state)));
265 }
266 }
267 return myPopup;
268}
269
270
273 // internal lanes don't have attributes
275 // close building
276 ret->closeBuilding();
277 return ret;
278}
279
280
285
286
287void
289 // nothing to update
290}
291
292
295 try {
297 } catch (ProcessError&) {
298 WRITE_WARNINGF(TL("invalid link state='%'"), toString(state));
299 return RGBColor::BLACK;
300 }
301}
302
303
304std::string
306 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
307}
308
309
312 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
313}
314
315
316void
317GNEInternalLane::setAttribute(SumoXMLAttr key, const std::string& /*value*/, GNEUndoList* /*undoList*/) {
318 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
319}
320
321
322bool
323GNEInternalLane::isValid(SumoXMLAttr key, const std::string& /*value*/) {
324 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
325}
326
327
328bool
330 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
331}
332
333
336 throw InvalidArgument(getTagStr() + " doesn't have parameters");
337}
338
339
340void
341GNEInternalLane::setAttribute(SumoXMLAttr key, const std::string& /*value*/) {
342 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
343}
344
345
346void
348 // internal lanes cannot be moved
349}
350
351
352void
353GNEInternalLane::commitMoveShape(const GNEMoveResult& /*moveResult*/, GNEUndoList* /*undoList*/) {
354 // internal lanes cannot be moved
355}
356
357/****************************************************************************/
@ GLO_TLLOGIC
a tl-logic
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:296
#define TL(string)
Definition MsgHandler.h:315
@ 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:654
static void popMatrix()
pop matrix
Definition GLHelper.cpp:130
static void pushMatrix()
push matrix
Definition GLHelper.cpp:117
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:787
const std::string & getTagStr() const
get tag assigned to this object in string format
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
calculate contour extruded (used in elements formed by a central shape)
void 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...)
Boundary getContourBoundary() const
get contour boundary
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:150
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.
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
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:2155
GNEContour myNetworkElementContour
network element contour
virtual void updateGeometry()=0
update pre-computed geometry information
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
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
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
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.
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
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:112
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:193
std::vector< std::string > getStrings() const
T get(const std::string &str) const
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