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 
26 #include <netedit/GNENet.h>
27 #include <netedit/GNEViewNet.h>
29 #include <netedit/GNEViewParent.h>
30 #include <cassert>
31 
32 #include "GNEChange_Connection.h"
33 
34 // ===========================================================================
35 // FOX-declarations
36 // ===========================================================================
37 FXIMPLEMENT_ABSTRACT(GNEChange_Connection, GNEChange, nullptr, 0)
38 
39 // ===========================================================================
40 // member method definitions
41 // ===========================================================================
42 
43 
44 GNEChange_Connection::GNEChange_Connection(GNEEdge* edge, NBEdge::Connection nbCon, bool selected, bool forward) :
45  GNEChange(edge->getNet(), forward),
46  myEdge(edge),
47  myNBEdgeConnection(nbCon),
48  mySelected(selected) {
49  assert(myEdge);
50 }
51 
52 
54  assert(myEdge);
55 }
56 
57 
58 void
60  if (myForward) {
61  // show extra information for tests
62  WRITE_DEBUG("Removing " + toString(SUMO_TAG_CONNECTION) + " '" +
64  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
65  // remove connection from edge
67  } else {
68  // show extra information for tests
69  std::string selected = mySelected ? ("a previously selected ") : ("");
70  WRITE_DEBUG("Adding " + selected + toString(SUMO_TAG_CONNECTION) + " '" +
72  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
73  // add connection into edge
75  }
76  // check if inspector frame has to be updated
77  if (myNet->getViewNet()->getViewParent()->getInspectorFrame()->shown()) {
79  }
80  // enable save netElements
81  myNet->requiereSaveNet(true);
82 }
83 
84 
85 void
87  if (myForward) {
88  // show extra information for tests
89  std::string selected = mySelected ? ("a previously selected ") : ("");
90  WRITE_DEBUG("Adding " + selected + toString(SUMO_TAG_CONNECTION) + " '" +
92  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
93  // add connection into edge
95  } else {
96  // show extra information for tests
97  WRITE_DEBUG("Removing " + toString(SUMO_TAG_CONNECTION) + " '" +
99  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
100  // remove connection from edge
102  }
103  // check if inspector frame has to be updated
104  if (myNet->getViewNet()->getViewParent()->getInspectorFrame()->shown()) {
106  }
107  // enable save netElements
108  myNet->requiereSaveNet(true);
109 }
110 
111 
112 FXString
114  if (myForward) {
115  return ("Undo create " + toString(SUMO_TAG_CONNECTION)).c_str();
116  } else {
117  return ("Undo delete " + toString(SUMO_TAG_CONNECTION)).c_str();
118  }
119 }
120 
121 
122 FXString
124  if (myForward) {
125  return ("Redo create " + toString(SUMO_TAG_CONNECTION)).c_str();
126  } else {
127  return ("Redo delete " + toString(SUMO_TAG_CONNECTION)).c_str();
128  }
129 }
GNEInspectorFrame * getInspectorFrame() const
get frame for GNE_MODE_INSPECT
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:42
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:2990
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:117
const std::string getID() const
function to support debugging
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:249
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:75
void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation=false)
adds a connection
Definition: GNEEdge.cpp:1469
void requiereSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:852
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:80
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:1493
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:586
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1745