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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // A network change in which a single junction is created or deleted
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
24 #include <netedit/GNENet.h>
25 #include <netedit/GNEViewNet.h>
29 #include <netedit/GNEViewParent.h>
30 
31 #include "GNEChange_Crossing.h"
32 
33 
34 // ===========================================================================
35 // FOX-declarations
36 // ===========================================================================
37 FXIMPLEMENT_ABSTRACT(GNEChange_Crossing, GNEChange, nullptr, 0)
38 
39 // ===========================================================================
40 // member method definitions
41 // ===========================================================================
42 
43 
44 GNEChange_Crossing::GNEChange_Crossing(GNEJunction* junctionParent, const std::vector<NBEdge*>& edges,
45  double width, bool priority, int customTLIndex, int customTLIndex2, const PositionVector& customShape, bool selected, bool forward):
46  GNEChange(junctionParent->getNet(), forward),
47  myJunctionParent(junctionParent),
48  myEdges(edges),
49  myWidth(width),
50  myPriority(priority),
51  myCustomTLIndex(customTLIndex),
52  myCustomTLIndex2(customTLIndex2),
53  myCustomShape(customShape),
54  mySelected(selected) {
55  assert(myNet);
56 }
57 
58 
60  assert(myNet);
61 }
62 
63 
65  if (myForward) {
66  // show extra information for tests
67  WRITE_DEBUG("removing " + toString(SUMO_TAG_CROSSING) + " from " + toString(myJunctionParent->getTag()) + " '" + myJunctionParent->getID() + "'");
68  // remove crossing of NBNode
70  // rebuild GNECrossings
72  // Check if Flag "haveNetworkCrossings" has to be disabled
73  if ((myNet->netHasGNECrossings() == false) && (myNet->getNetBuilder()->haveNetworkCrossings())) {
74  // change flag of NetBuilder (For build GNECrossing)
76  // show extra information for tests
77  WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'true' to 'false'");
78  }
79  // Update view
80  myNet->getViewNet()->update();
81  } else {
82  // show extra information for tests
83  WRITE_DEBUG("Adding " + toString(SUMO_TAG_CROSSING) + " into " + toString(myJunctionParent->getTag()) + " '" + myJunctionParent->getID() + "'");
84  // add crossing of NBNode
86  // Check if Flag "haveNetworkCrossings" has to be enabled
87  if (myNet->getNetBuilder()->haveNetworkCrossings() == false) {
89  // show extra information for tests
90  WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'false' to 'true'");
91  }
92  // rebuild GNECrossings
94  // select if mySelected is enabled
95  if (mySelected) {
97  }
98  // Update view
99  myNet->getViewNet()->update();
100  }
101  // check if inspector frame has to be updated
102  if (myNet->getViewNet()->getViewParent()->getInspectorFrame()->shown()) {
104  }
105  // enable save netElements
106  myNet->requiereSaveNet(true);
107 }
108 
109 
111  if (myForward) {
112  // show extra information for tests
113  WRITE_DEBUG("Adding " + toString(SUMO_TAG_CROSSING) + " into " + toString(myJunctionParent->getTag()) + " '" + myJunctionParent->getID() + "'");
114  // add crossing of NBNode and update geometry
116  // Check if Flag "haveNetworkCrossings" has to be enabled
117  if (myNet->getNetBuilder()->haveNetworkCrossings() == false) {
119  // show extra information for tests
120  WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'false' to 'true'");
121  }
122  // rebuild GNECrossings
124  // select if mySelected is enabled
125  if (mySelected) {
127  }
128  // Update view
129  myNet->getViewNet()->update();
130  } else {
131  // show extra information for tests
132  WRITE_DEBUG("Removing " + toString(SUMO_TAG_CROSSING) + " from " + toString(myJunctionParent->getTag()) + " '" + myJunctionParent->getID() + "'");
133  // remove crossing of NBNode and update geometry
135  // rebuild GNECrossings
137  // Check if Flag "haveNetworkCrossings" has to be disabled
138  if ((myNet->netHasGNECrossings() == false) && (myNet->getNetBuilder()->haveNetworkCrossings())) {
139  // change flag of NetBuilder (For build GNECrossing)
141  // show extra information for tests
142  WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'true' to 'false'");
143  }
144  // Update view
145  myNet->getViewNet()->update();
146  }
147  // check if inspector frame has to be updated
148  if (myNet->getViewNet()->getViewParent()->getInspectorFrame()->shown()) {
150  }
151  // enable save netElements
152  myNet->requiereSaveNet(true);
153 }
154 
155 
156 FXString
158  if (myForward) {
159  return ("Undo create " + toString(SUMO_TAG_CROSSING)).c_str();
160  } else {
161  return ("Undo delete " + toString(SUMO_TAG_CROSSING)).c_str();
162  }
163 }
164 
165 
166 FXString
168  if (myForward) {
169  return ("Redo create " + toString(SUMO_TAG_CROSSING)).c_str();
170  } else {
171  return ("Redo delete " + toString(SUMO_TAG_CROSSING)).c_str();
172  }
173 }
void setHaveNetworkCrossings(bool value)
enable crossing in networks
Definition: NBNetBuilder.h:196
int myCustomTLIndex
custom index of GNECrossing
GNEInspectorFrame * getInspectorFrame() const
get frame for GNE_MODE_INSPECT
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:42
NBNetBuilder * getNetBuilder() const
get net builder
Definition: GNENet.cpp:1399
GNEViewParent * getViewParent() const
get the net object
The representation of a single edge during network building.
Definition: NBEdge.h:65
bool mySelected
flag to check if crossing is selected
PositionVector myCustomShape
priority of GNECrossing
void redo()
redo action
bool netHasGNECrossings() const
check if net has GNECrossings
Definition: GNENet.cpp:1382
void removeCrossing(const EdgeVector &edges)
remove a pedestrian crossing from this node (identified by its edges)
Definition: NBNode.cpp:2841
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
A list of positions.
GNEFrame::ACHierarchy * getACHierarchy() const
get ACHierarchy
void refreshACHierarchy()
refresh ACHierarchy
Definition: GNEFrame.cpp:117
const std::string getID() const
function to support debugging
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:249
void selectAttributeCarrier(bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
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:2829
GNEJunction * myJunctionParent
full information regarding the Junction in which GNECRossing is created
GNENet * myNet
the net to which operations shall be applied or which shall be informed about gui updates (we are not...
Definition: GNEChange.h:75
FXString undoName() const
return undoName
bool haveNetworkCrossings()
notify about style of loaded network (Without Crossings)
Definition: NBNetBuilder.h:191
~GNEChange_Crossing()
Destructor.
bool myPriority
priority of GNECrossing
void requiereSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:844
std::vector< NBEdge * > myEdges
vector to save all edges of GNECrossing
int myCustomTLIndex2
custom index of GNECrossing (reverse direction)
crossing between edges for pedestrians
void undo()
undo action
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:80
A definition of a pedestrian crossing.
Definition: NBNode.h:125
void rebuildGNECrossings(bool rebuildNBNodeCrossings=true)
rebuilds crossing objects for this junction
GNECrossing * retrieveGNECrossing(NBNode::Crossing *crossing, bool createIfNoExist=true)
get GNECrossing if exist, and if not create it if create is enabled
double myWidth
width of GNECrossing
NBNode * getNBNode() const
Return net build node.
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1737
FXString redoName() const
get Redo name
SumoXMLTag getTag() const
get XML Tag assigned to this object