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 
23 #include <netedit/GNENet.h>
27 #include <netedit/GNEViewParent.h>
28 #include <netbuild/NBNetBuilder.h>
29 
30 #include "GNEChange_Crossing.h"
31 
32 
33 // ===========================================================================
34 // FOX-declarations
35 // ===========================================================================
36 FXIMPLEMENT_ABSTRACT(GNEChange_Crossing, GNEChange, nullptr, 0)
37 
38 // ===========================================================================
39 // member method definitions
40 // ===========================================================================
41 
42 
43 GNEChange_Crossing::GNEChange_Crossing(GNEJunction* junctionParent, const std::vector<NBEdge*>& edges,
44  double width, bool priority, int customTLIndex, int customTLIndex2, const PositionVector& customShape, bool selected, bool forward):
45  GNEChange(junctionParent->getNet(), forward),
46  myJunctionParent(junctionParent),
47  myEdges(edges),
48  myWidth(width),
49  myPriority(priority),
50  myCustomTLIndex(customTLIndex),
51  myCustomTLIndex2(customTLIndex2),
52  myCustomShape(customShape),
53  mySelected(selected) {
54  assert(myNet);
55 }
56 
57 
58 GNEChange_Crossing::GNEChange_Crossing(GNEJunction* junctionParent, const NBNode::Crossing& crossing, bool forward):
59  GNEChange(junctionParent->getNet(), forward),
60  myJunctionParent(junctionParent),
61  myEdges(crossing.edges),
62  myWidth(crossing.width),
63  myPriority(crossing.priority),
64  myCustomTLIndex(crossing.customTLIndex),
65  myCustomTLIndex2(crossing.customTLIndex2),
66  myCustomShape(crossing.customShape),
67  mySelected(false) {
68  assert(myNet);
69 }
70 
71 
73  assert(myNet);
74 }
75 
76 
78  if (myForward) {
79  // show extra information for tests
80  WRITE_DEBUG("removing " + toString(SUMO_TAG_CROSSING) + " from " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
81  // remove crossing of NBNode
83  // rebuild GNECrossings
85  // Check if Flag "haveNetworkCrossings" has to be disabled
86  if ((myNet->netHasGNECrossings() == false) && (myNet->getNetBuilder()->haveNetworkCrossings())) {
87  // change flag of NetBuilder (For build GNECrossing)
89  // show extra information for tests
90  WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'true' to 'false'");
91  }
92  // Update view
93  myNet->getViewNet()->update();
94  } else {
95  // show extra information for tests
96  WRITE_DEBUG("Adding " + toString(SUMO_TAG_CROSSING) + " into " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
97  // add crossing of NBNode
99  // Check if Flag "haveNetworkCrossings" has to be enabled
100  if (myNet->getNetBuilder()->haveNetworkCrossings() == false) {
102  // show extra information for tests
103  WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'false' to 'true'");
104  }
105  // rebuild GNECrossings
107  // select if mySelected is enabled
108  if (mySelected) {
110  }
111  // Update view
112  myNet->getViewNet()->update();
113  }
114  // check if inspector frame has to be updated
115  if (myNet->getViewNet()->getViewParent()->getInspectorFrame()->shown()) {
117  }
118  // enable save netElements
119  myNet->requiereSaveNet(true);
120 }
121 
122 
124  if (myForward) {
125  // show extra information for tests
126  WRITE_DEBUG("Adding " + toString(SUMO_TAG_CROSSING) + " into " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
127  // add crossing of NBNode and update geometry
129  // Check if Flag "haveNetworkCrossings" has to be enabled
130  if (myNet->getNetBuilder()->haveNetworkCrossings() == false) {
132  // show extra information for tests
133  WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'false' to 'true'");
134  }
135  // rebuild GNECrossings
137  // select if mySelected is enabled
138  if (mySelected) {
140  }
141  // Update view
142  myNet->getViewNet()->update();
143  } else {
144  // show extra information for tests
145  WRITE_DEBUG("Removing " + toString(SUMO_TAG_CROSSING) + " from " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
146  // remove crossing of NBNode and update geometry
148  // rebuild GNECrossings
150  // Check if Flag "haveNetworkCrossings" has to be disabled
151  if ((myNet->netHasGNECrossings() == false) && (myNet->getNetBuilder()->haveNetworkCrossings())) {
152  // change flag of NetBuilder (For build GNECrossing)
154  // show extra information for tests
155  WRITE_DEBUG("Changed flag netBuilder::haveNetworkCrossings from 'true' to 'false'");
156  }
157  // Update view
158  myNet->getViewNet()->update();
159  }
160  // check if inspector frame has to be updated
161  if (myNet->getViewNet()->getViewParent()->getInspectorFrame()->shown()) {
163  }
164  // enable save netElements
165  myNet->requiereSaveNet(true);
166 }
167 
168 
169 FXString
171  if (myForward) {
172  return ("Undo create " + toString(SUMO_TAG_CROSSING)).c_str();
173  } else {
174  return ("Undo delete " + toString(SUMO_TAG_CROSSING)).c_str();
175  }
176 }
177 
178 
179 FXString
181  if (myForward) {
182  return ("Redo create " + toString(SUMO_TAG_CROSSING)).c_str();
183  } else {
184  return ("Redo delete " + toString(SUMO_TAG_CROSSING)).c_str();
185  }
186 }
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:43
NBNetBuilder * getNetBuilder() const
get net builder
Definition: GNENet.cpp:1392
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
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.
PositionVector myCustomShape
priority of GNECrossing
void redo()
redo action
bool netHasGNECrossings() const
check if net has GNECrossings
Definition: GNENet.cpp:1375
void removeCrossing(const EdgeVector &edges)
remove a pedestrian crossing from this node (identified by its edges)
Definition: NBNode.cpp:2933
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:594
const std::string getID() const
function to support debugging
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:248
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:2921
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:76
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
const std::string & getTagStr() const
get tag assigned to this object in string format
void requiereSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:837
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:81
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:1730
FXString redoName() const
get Redo name