Eclipse SUMO - Simulation of Urban MObility
GNEChange_Crossing.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 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
65}
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 }
76 // remove crossing of NBNode
78 // rebuild GNECrossings
80 // clean walking areas
82 // Check if Flag "haveNetworkCrossings" has to be disabled
84 // change flag of NetBuilder (For build GNECrossing)
86 // show extra information for tests
87 WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'true' to 'false'");
88 }
89 } else {
90 // show extra information for tests
91 WRITE_DEBUG("Adding " + toString(SUMO_TAG_CROSSING) + " into " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
92 // add crossing of NBNode
94 // Check if Flag "haveNetworkCrossings" has to be enabled
97 // show extra information for tests
98 WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'false' to 'true'");
99 }
100 // rebuild GNECrossings
102 // clean walking areas
104 // select if mySelectedElement is enabled
105 if (mySelectedElement) {
107 }
108 }
109 // enable save networkElements
111}
112
113
115 if (myForward) {
116 // show extra information for tests
117 WRITE_DEBUG("Adding " + toString(SUMO_TAG_CROSSING) + " into " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
118 // add crossing of NBNode and update geometry
120 // Check if Flag "haveNetworkCrossings" has to be enabled
123 // show extra information for tests
124 WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'false' to 'true'");
125 }
126 // rebuild GNECrossings
128 // clean walking areas
130 // select if mySelectedElement is enabled
131 if (mySelectedElement) {
133 }
134 } else {
135 // show extra information for tests
136 WRITE_DEBUG("Removing " + toString(SUMO_TAG_CROSSING) + " from " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
137 // unselect if mySelectedElement is enabled
138 if (mySelectedElement) {
140 }
141 // remove crossing of NBNode and update geometry
143 // rebuild GNECrossings
145 // clean walking areas
147 // Check if Flag "haveNetworkCrossings" has to be disabled
149 // change flag of NetBuilder (For build GNECrossing)
151 // show extra information for tests
152 WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'true' to 'false'");
153 }
154 }
155 // enable save networkElements
157}
158
159
160std::string
162 if (myForward) {
163 return ("Undo create " + toString(SUMO_TAG_CROSSING));
164 } else {
165 return ("Undo delete " + toString(SUMO_TAG_CROSSING));
166 }
167}
168
169
170std::string
172 if (myForward) {
173 return ("Redo create " + toString(SUMO_TAG_CROSSING));
174 } else {
175 return ("Redo delete " + toString(SUMO_TAG_CROSSING));
176 }
177}
Supermode
@brie enum for supermodes
@ NETWORK
Network mode (Edges, junctions, etc..)
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:276
@ 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.
void redo()
redo action
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:60
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag
Definition: GNEChange.h:216
const bool mySelectedElement
flag for check if element is selected
Definition: GNEChange.h:219
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::set< GNECrossing * > & getCrossings() const
get crossings
NBNetBuilder * getNetBuilder() const
get net builder
Definition: GNENet.cpp:1394
void requireSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:1179
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:132
The representation of a single edge during network building.
Definition: NBEdge.h:92
bool haveNetworkCrossings()
notify about style of loaded network (Without Crossings)
Definition: NBNetBuilder.h:183
void setHaveNetworkCrossings(bool value)
enable crossing in networks
Definition: NBNetBuilder.h:188
A definition of a pedestrian crossing.
Definition: NBNode.h:129
void removeCrossing(const EdgeVector &edges)
remove a pedestrian crossing from this node (identified by its edges)
Definition: NBNode.cpp:3536
Crossing * getCrossing(const std::string &id) const
return the crossing with the given id
Definition: NBNode.cpp:3550
NBNode::Crossing * addCrossing(EdgeVector edges, double width, bool priority, int tlIndex=-1, int tlIndex2=-1, const PositionVector &customShape=PositionVector::EMPTY, bool fromSumoNet=false)
add a pedestrian crossing to this node
Definition: NBNode.cpp:3524
A list of positions.
Definition: json.hpp:4471