Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEChange_Crossing.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 network change in which a single junction is created or deleted
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
25
26#include "GNEChange_Crossing.h"
27
28
29// ===========================================================================
30// FOX-declarations
31// ===========================================================================
32FXIMPLEMENT_ABSTRACT(GNEChange_Crossing, GNEChange, nullptr, 0)
33
34// ===========================================================================
35// member method definitions
36// ===========================================================================
37
38
39GNEChange_Crossing::GNEChange_Crossing(GNEJunction* junctionParent, const std::vector<NBEdge*>& edges,
40 double width, bool priority, int customTLIndex, int customTLIndex2, const PositionVector& customShape, bool selected, bool forward):
41 GNEChange(Supermode::NETWORK, junctionParent, forward, selected),
42 myJunctionParent(junctionParent),
43 myEdges(edges),
44 myWidth(width),
45 myPriority(priority),
46 myCustomTLIndex(customTLIndex),
47 myCustomTLIndex2(customTLIndex2),
48 myCustomShape(customShape) {
49}
50
51
52GNEChange_Crossing::GNEChange_Crossing(GNEJunction* junctionParent, const NBNode::Crossing& crossing, bool forward):
53 GNEChange(Supermode::NETWORK, forward, false),
54 myJunctionParent(junctionParent),
55 myEdges(crossing.edges),
56 myWidth(crossing.width),
57 myPriority(crossing.priority),
58 myCustomTLIndex(crossing.customTLIndex),
59 myCustomTLIndex2(crossing.customTLIndex2),
60 myCustomShape(crossing.customShape) {
61}
62
63
66
67
69 if (myForward) {
70 // show extra information for tests
71 WRITE_DEBUG("removing " + toString(SUMO_TAG_CROSSING) + " from " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
72 // unselect if mySelectedElement is enabled
75 if (crossing) {
76 crossing->unselectAttributeCarrier();
77 } else {
78#ifdef _DEBUG
79 WRITE_WARNINGF("Unable to deselect crossing at junction '%' after undo", myJunctionParent->getID());
80#endif
81 }
82 }
83 // remove crossing of NBNode
85 // rebuild GNECrossings
87 // clean walking areas
89 // Check if Flag "haveNetworkCrossings" has to be disabled
91 // change flag of NetBuilder (For build GNECrossing)
93 // show extra information for tests
94 WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'true' to 'false'");
95 }
96 } else {
97 // show extra information for tests
98 WRITE_DEBUG("Adding " + toString(SUMO_TAG_CROSSING) + " into " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
99 // add crossing of NBNode
101 // Check if Flag "haveNetworkCrossings" has to be enabled
104 // show extra information for tests
105 WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'false' to 'true'");
106 }
107 // rebuild GNECrossings
109 // clean walking areas
111 // select if mySelectedElement is enabled
112 if (mySelectedElement) {
113 if (mySelectedElement) {
114 GNECrossing* crossing = myJunctionParent->retrieveGNECrossing(c, false);
115 if (crossing) {
116 crossing->selectAttributeCarrier();
117 } else {
118#ifdef _DEBUG
119 WRITE_WARNINGF("Unable to select crossing at junction '%' after undo", myJunctionParent->getID());
120#endif
121 }
122 }
123 }
124 }
125 // enable save networkElements
127}
128
129
131 if (myForward) {
132 // show extra information for tests
133 WRITE_DEBUG("Adding " + toString(SUMO_TAG_CROSSING) + " into " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
134 // add crossing of NBNode and update geometry
136 // Check if Flag "haveNetworkCrossings" has to be enabled
139 // show extra information for tests
140 WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'false' to 'true'");
141 }
142 // rebuild GNECrossings
144 // clean walking areas
146 // select if mySelectedElement is enabled
147 if (mySelectedElement) {
148 if (mySelectedElement) {
149 GNECrossing* crossing = myJunctionParent->retrieveGNECrossing(c, false);
150 if (crossing) {
151 crossing->selectAttributeCarrier();
152 } else {
153#ifdef _DEBUG
154 WRITE_WARNINGF("Unable to select crossing at junction '%' after undo", myJunctionParent->getID());
155#endif
156 }
157 }
158 }
159 } else {
160 // show extra information for tests
161 WRITE_DEBUG("Removing " + toString(SUMO_TAG_CROSSING) + " from " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
162 // unselect if mySelectedElement is enabled
163 if (mySelectedElement) {
165 if (crossing) {
166 crossing->unselectAttributeCarrier();
167 } else {
168#ifdef _DEBUG
169 WRITE_WARNINGF("Unable to deselect crossing at junction '%' after undo", myJunctionParent->getID());
170#endif
171 }
172 }
173 // remove crossing of NBNode and update geometry
175 // rebuild GNECrossings
177 // clean walking areas
179 // Check if Flag "haveNetworkCrossings" has to be disabled
181 // change flag of NetBuilder (For build GNECrossing)
183 // show extra information for tests
184 WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'true' to 'false'");
185 }
186 }
187 // enable save networkElements
189}
190
191
192std::string
194 if (myForward) {
195 return TL("Undo create crossing");
196 } else {
197 return TL("Undo delete crossing");
198 }
199}
200
201
202std::string
204 if (myForward) {
205 return TL("Redo create crossing");
206 } else {
207 return TL("Redo delete crossing");
208 }
209}
Supermode
@brie enum for supermodes
@ NETWORK
Network mode (Edges, junctions, etc..)
#define WRITE_DEBUG(msg)
Definition MsgHandler.h:306
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:296
#define TL(string)
Definition MsgHandler.h:315
@ SUMO_TAG_CROSSING
crossing between edges for pedestrians
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
const std::string getID() const
get ID (all Attribute Carriers have one)
const std::string & getTagStr() const
get tag assigned to this object in string format
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
GNENet * getNet() const
get pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
double myWidth
width of GNECrossing
int myCustomTLIndex
custom index of GNECrossing
bool myPriority
priority of GNECrossing
~GNEChange_Crossing()
Destructor.
std::vector< NBEdge * > myEdges
vector to save all edges of GNECrossing
PositionVector myCustomShape
priority of GNECrossing
std::string undoName() const
return undoName
GNEChange_Crossing(GNEJunction *junctionParent, const std::vector< NBEdge * > &edges, double width, bool priority, int customTLIndex, int customTLIndex2, const PositionVector &customShape, bool selected, bool forward)
Constructor for creating/deleting an crossing.
void undo()
undo action
std::string redoName() const
get Redo name
GNEJunction * myJunctionParent
full information regarding the Junction in which GNECRossing is created
int myCustomTLIndex2
custom index of GNECrossing (reverse direction)
the function-object for an editing operation (abstract base)
Definition GNEChange.h:56
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag
Definition GNEChange.h:212
const bool mySelectedElement
flag for check if element is selected
Definition GNEChange.h:215
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition GNECrossing.h:44
void clearWalkingAreas()
clear walking areas
GNECrossing * retrieveGNECrossing(NBNode::Crossing *NBNodeCrossing, bool createIfNoExist=true)
get GNECrossing if exist, and if not create it if create is enabled
NBNode * getNBNode() const
Return net build node.
void rebuildGNECrossings(bool rebuildNBNodeCrossings=true)
rebuilds crossing objects for this junction
const std::unordered_map< const GUIGlObject *, GNECrossing * > & getCrossings() const
get crossings
void requireSaveNetwork()
inform that network has to be saved
NBNetBuilder * getNetBuilder() const
get net builder
Definition GNENet.cpp:1559
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition GNENet.cpp:133
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:127
The representation of a single edge during network building.
Definition NBEdge.h:92
bool haveNetworkCrossings()
notify about style of loaded network (Without Crossings)
void setHaveNetworkCrossings(bool value)
enable crossing in networks
A definition of a pedestrian crossing.
Definition NBNode.h:135
void removeCrossing(const EdgeVector &edges)
remove a pedestrian crossing from this node (identified by its edges)
Definition NBNode.cpp:3854
NBNode::Crossing * addCrossing(EdgeVector edges, double width, bool priority, int tlIndex=-1, int tlIndex2=-1, const PositionVector &customShape=PositionVector::EMPTY, bool fromSumoNet=false, const Parameterised *params=nullptr)
add a pedestrian crossing to this node
Definition NBNode.cpp:3839
Crossing * getCrossing(const std::string &id) const
return the crossing with the given id
Definition NBNode.cpp:3868
A list of positions.
Definition json.hpp:4471