Eclipse SUMO - Simulation of Urban MObility
GNEInternalLane.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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}
76
77
79 GNENetworkElement(nullptr, "dummyInternalLane", GLO_TLLOGIC, GNE_TAG_INTERNAL_LANE,
80 GUIIconSubSys::getIcon(GUIIcon::LANE), {}, {}, {}, {}, {}, {}),
81myJunctionParent(nullptr),
82myState(0),
83myEditor(0),
84myTlIndex(0),
85myPopup(nullptr) {
86}
87
88
90
91
92void
94 // nothing to update
95}
96
97
101}
102
103
106 // internal lanes cannot be moved
107 return nullptr;
108}
109
110
111void
112GNEInternalLane::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undolist*/) {
113 // geometry points of internal lanes cannot be removed
114}
115
116
117long
118GNEInternalLane::onDefault(FXObject* obj, FXSelector sel, void* data) {
119 if (myEditor != nullptr) {
120 FXuint before = myState;
121 myStateTarget.handle(obj, sel, data);
122 if (myState != before) {
123 myEditor->handleChange(this);
124 }
125 // let GUISUMOAbstractView know about clicks so that the popup is properly destroyed
126 if (FXSELTYPE(sel) == SEL_COMMAND) {
127 if (myPopup != nullptr) {
129 myPopup = nullptr;
130 }
131 }
132 }
133 return 1;
134}
135
136
137void
139 // only draw if we're not selecting E1 detectors in TLS Mode
141 // push name
143 // push layer matrix
145 // translate to front
147 // move front again
148 glTranslated(0, 0, 0.5);
149 // set color
151 // draw lane checking whether it is not too small
152 if (s.scale < 1.) {
154 } else {
156 }
157 // pop layer matrix
159 // pop name
161 }
162}
163
164
165void
167 // Internal lanes cannot be removed
168}
169
170
171void
174}
175
176
177void
179 myState = state;
180 myOrigState = state;
181}
182
183
186 return (LinkState)myState;
187}
188
189
190int
192 return myTlIndex;
193}
194
195
198 myPopup = new GUIGLObjectPopupMenu(app, parent, *this);
200 if ((myEditor != nullptr) && (myEditor->getViewNet()->getEditModes().isCurrentSupermodeNetwork())) {
201 const std::vector<std::string> names = LinkStateNames.getStrings();
202 for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
203 FXuint state = LinkStateNames.get(*it);
204 std::string origHint = ((LinkState)state == myOrigState ? " (original)" : "");
205 FXMenuRadio* mc = new FXMenuRadio(myPopup, (*it + origHint).c_str(), this, FXDataTarget::ID_OPTION + state);
206 mc->setSelBackColor(MFXUtils::getFXColor(colorForLinksState(state)));
207 mc->setBackColor(MFXUtils::getFXColor(colorForLinksState(state)));
208 }
209 }
210 return myPopup;
211}
212
213
216 // internal lanes don't have attributes
218 // close building
219 ret->closeBuilding();
220 return ret;
221}
222
223
224double
226 return 1;
227}
228
229
230void
233 myBoundary.grow(10);
234}
235
236
239 try {
241 } catch (ProcessError&) {
242 WRITE_WARNING("invalid link state='" + toString(state) + "'");
243 return RGBColor::BLACK;
244 }
245}
246
247
248std::string
250 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
251}
252
253
254void
255GNEInternalLane::setAttribute(SumoXMLAttr key, const std::string& /*value*/, GNEUndoList* /*undoList*/) {
256 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
257}
258
259
260bool
261GNEInternalLane::isValid(SumoXMLAttr key, const std::string& /*value*/) {
262 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
263}
264
265
266bool
268 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
269}
270
271
274 throw InvalidArgument(getTagStr() + " doesn't have parameters");
275}
276
277
278void
279GNEInternalLane::setAttribute(SumoXMLAttr key, const std::string& /*value*/) {
280 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
281}
282
283
284void
286 // internal lanes cannot be moved
287}
288
289
290void
291GNEInternalLane::commitMoveShape(const GNEMoveResult& /*moveResult*/, GNEUndoList* /*undoList*/) {
292 // internal lanes cannot be moved
293}
294
295/****************************************************************************/
@ GLO_TLLOGIC
a tl-logic
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:265
@ GNE_TAG_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
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:300
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:421
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:583
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:139
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static void popName()
pop Name
Definition: GLHelper.cpp:148
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
const std::string & getTagStr() const
get tag assigned to this object in string format
GNENet * myNet
pointer to net
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)
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
const GNEJunction * myJunctionParent
pointer to junction parent
FXuint myState
the state of the link (used for visualization)
LinkState getLinkState() const
whether link state has been modified
FXDataTarget myStateTarget
int myTlIndex
the tl-index of this lane
GUIGLObjectPopupMenu * myPopup
the created popup
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.
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
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
GUIGeometry myInternalLaneGeometry
internal lane geometry
bool isValid(SumoXMLAttr key, const std::string &value)
static const StringBijection< FXuint > LinkStateNames
long names for link states
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.)
~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
Position getPositionInView() const
Returns position of hierarchical element in view.
move operation
move result
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1987
virtual void updateGeometry()=0
update pre-computed geometry information
Boundary myBoundary
object boundary
void handleChange(GNEInternalLane *lane)
update phase definition for the current traffic light and phase
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:632
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
bool selectingDetectorsTLSMode() const
check if we're selecting detectors in TLS mode
Definition: GNEViewNet.cpp:874
The popup menu of a globject.
GUISUMOAbstractView * getParentView()
return the real owner of this popup
static void drawGeometry(const GUIVisualizationSettings &s, const Position &mousePos, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
const PositionVector & getShape() const
The shape of the additional element.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:102
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
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Stores the information about how to visualize structures.
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)
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:112
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
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