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-2020 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>
24 #include <netbuild/NBNetBuilder.h>
25 
26 #include "GNEChange_Crossing.h"
27 
28 
29 // ===========================================================================
30 // FOX-declarations
31 // ===========================================================================
32 FXIMPLEMENT_ABSTRACT(GNEChange_Crossing, GNEChange, nullptr, 0)
33 
34 // ===========================================================================
35 // member method definitions
36 // ===========================================================================
37 
38 
39 GNEChange_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(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 
52 GNEChange_Crossing::GNEChange_Crossing(GNEJunction* junctionParent, const NBNode::Crossing& crossing, bool forward):
53  GNEChange(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
73  if (mySelectedElement) {
75  }
76  // remove crossing of NBNode
78  // rebuild GNECrossings
80  // Check if Flag "haveNetworkCrossings" has to be disabled
82  // change flag of NetBuilder (For build GNECrossing)
84  // show extra information for tests
85  WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'true' to 'false'");
86  }
87  } else {
88  // show extra information for tests
89  WRITE_DEBUG("Adding " + toString(SUMO_TAG_CROSSING) + " into " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
90  // add crossing of NBNode
92  // Check if Flag "haveNetworkCrossings" has to be enabled
95  // show extra information for tests
96  WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'false' to 'true'");
97  }
98  // rebuild GNECrossings
100  // select if mySelectedElement is enabled
101  if (mySelectedElement) {
103  }
104  }
105  // enable save networkElements
107 }
108 
109 
111  if (myForward) {
112  // show extra information for tests
113  WRITE_DEBUG("Adding " + toString(SUMO_TAG_CROSSING) + " into " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
114  // add crossing of NBNode and update geometry
116  // Check if Flag "haveNetworkCrossings" has to be enabled
119  // show extra information for tests
120  WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'false' to 'true'");
121  }
122  // rebuild GNECrossings
124  // select if mySelectedElement is enabled
125  if (mySelectedElement) {
127  }
128  } else {
129  // show extra information for tests
130  WRITE_DEBUG("Removing " + toString(SUMO_TAG_CROSSING) + " from " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
131  // unselect if mySelectedElement is enabled
132  if (mySelectedElement) {
134  }
135  // remove crossing of NBNode and update geometry
137  // rebuild GNECrossings
139  // Check if Flag "haveNetworkCrossings" has to be disabled
141  // change flag of NetBuilder (For build GNECrossing)
143  // show extra information for tests
144  WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'true' to 'false'");
145  }
146  }
147  // enable save networkElements
149 }
150 
151 
152 FXString
154  if (myForward) {
155  return ("Undo create " + toString(SUMO_TAG_CROSSING)).c_str();
156  } else {
157  return ("Undo delete " + toString(SUMO_TAG_CROSSING)).c_str();
158  }
159 }
160 
161 
162 FXString
164  if (myForward) {
165  return ("Redo create " + toString(SUMO_TAG_CROSSING)).c_str();
166  } else {
167  return ("Redo delete " + toString(SUMO_TAG_CROSSING)).c_str();
168  }
169 }
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:286
@ SUMO_TAG_CROSSING
crossing between edges for pedestrians
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
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.
FXString redoName() const
get Redo name
void redo()
redo action
std::vector< NBEdge * > myEdges
vector to save all edges of GNECrossing
PositionVector myCustomShape
priority of GNECrossing
FXString 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
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:65
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag
Definition: GNEChange.h:215
const bool mySelectedElement
flag for check if element is selected
Definition: GNEChange.h:218
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
NBNetBuilder * getNetBuilder() const
get net builder
Definition: GNENet.cpp:1738
void requireSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:1047
bool netHasGNECrossings() const
check if net has GNECrossings
Definition: GNENet.cpp:1721
const std::string & getID() const
get ID
The representation of a single edge during network building.
Definition: NBEdge.h:91
bool haveNetworkCrossings()
notify about style of loaded network (Without Crossings)
Definition: NBNetBuilder.h:193
void setHaveNetworkCrossings(bool value)
enable crossing in networks
Definition: NBNetBuilder.h:198
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:3256
Crossing * getCrossing(const std::string &id) const
return the crossing with the given id
Definition: NBNode.cpp:3270
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:3244
A list of positions.