SUMO - Simulation of Urban MObility
GNEChange_Connection.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 connection is created or deleted
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
24 #include <netedit/GNENet.h>
26 #include <netedit/GNEViewParent.h>
27 
28 #include "GNEChange_Connection.h"
29 
30 // ===========================================================================
31 // FOX-declarations
32 // ===========================================================================
33 FXIMPLEMENT_ABSTRACT(GNEChange_Connection, GNEChange, nullptr, 0)
34 
35 // ===========================================================================
36 // member method definitions
37 // ===========================================================================
38 
39 
40 GNEChange_Connection::GNEChange_Connection(GNEEdge* edge, NBEdge::Connection nbCon, bool selected, bool forward) :
41  GNEChange(edge->getNet(), forward),
42  myEdge(edge),
43  myNBEdgeConnection(nbCon),
44  mySelected(selected) {
45  assert(myEdge);
46 }
47 
48 
50  assert(myEdge);
51 }
52 
53 
54 void
56  if (myForward) {
57  // show extra information for tests
58  WRITE_DEBUG("Removing " + toString(SUMO_TAG_CONNECTION) + " '" +
60  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
61  // remove connection from edge
63  } else {
64  // show extra information for tests
65  std::string selected = mySelected ? ("a previously selected ") : ("");
66  WRITE_DEBUG("Adding " + selected + toString(SUMO_TAG_CONNECTION) + " '" +
68  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
69  // add connection into edge
71  }
72  // check if inspector frame has to be updated
73  if (myNet->getViewNet()->getViewParent()->getInspectorFrame()->shown()) {
75  }
76  // enable save netElements
77  myNet->requiereSaveNet(true);
78 }
79 
80 
81 void
83  if (myForward) {
84  // show extra information for tests
85  std::string selected = mySelected ? ("a previously selected ") : ("");
86  WRITE_DEBUG("Adding " + selected + toString(SUMO_TAG_CONNECTION) + " '" +
88  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
89  // add connection into edge
91  } else {
92  // show extra information for tests
93  WRITE_DEBUG("Removing " + toString(SUMO_TAG_CONNECTION) + " '" +
95  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
96  // remove connection from edge
98  }
99  // check if inspector frame has to be updated
100  if (myNet->getViewNet()->getViewParent()->getInspectorFrame()->shown()) {
102  }
103  // enable save netElements
104  myNet->requiereSaveNet(true);
105 }
106 
107 
108 FXString
110  if (myForward) {
111  return ("Undo create " + toString(SUMO_TAG_CONNECTION)).c_str();
112  } else {
113  return ("Undo delete " + toString(SUMO_TAG_CONNECTION)).c_str();
114  }
115 }
116 
117 
118 FXString
120  if (myForward) {
121  return ("Redo create " + toString(SUMO_TAG_CONNECTION)).c_str();
122  } else {
123  return ("Redo delete " + toString(SUMO_TAG_CONNECTION)).c_str();
124  }
125 }
GNEInspectorFrame * getInspectorFrame() const
get frame for GNE_MODE_INSPECT
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:43
int toLane
The lane the connections yields in.
Definition: NBEdge.h:188
bool mySelected
flag to indicates if crossing was previously selected
NBEdge * toEdge
The edge the connections yields in.
Definition: NBEdge.h:185
connectio between two lanes
GNEViewParent * getViewParent() const
get the net object
The representation of a single edge during network building.
Definition: NBEdge.h:65
~GNEChange_Connection()
Destructor.
NBEdge::Connection myNBEdgeConnection
the data which must be copied because the original reference does not persist
FXString redoName() const
get Redo name
FXString undoName() const
return undoName
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
std::string getLaneID(int lane) const
get Lane ID (Secure)
Definition: NBEdge.cpp:3022
int fromLane
The lane the connections starts at.
Definition: NBEdge.h:182
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
begin/end of the description of an edge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
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
void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation=false)
adds a connection
Definition: GNEEdge.cpp:1463
void requiereSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:837
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:81
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:1499
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:613
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1730