SUMO - Simulation of Urban MObility
GNEChange_Connection.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A network change in which a single connection is created or deleted
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
31 #include <cassert>
32 
33 #include "GNEChange_Connection.h"
34 #include "GNEConnection.h"
35 #include "GNEEdge.h"
36 #include "GNENet.h"
37 #include "GNEViewNet.h"
38 
39 
40 // ===========================================================================
41 // FOX-declarations
42 // ===========================================================================
43 FXIMPLEMENT_ABSTRACT(GNEChange_Connection, GNEChange, NULL, 0)
44 
45 // ===========================================================================
46 // member method definitions
47 // ===========================================================================
48 
49 
50 GNEChange_Connection::GNEChange_Connection(GNEEdge* edge, NBEdge::Connection nbCon, bool selected, bool forward) :
51  GNEChange(edge->getNet(), forward),
52  myEdge(edge),
53  myNBEdgeConnection(nbCon),
54  mySelected(selected) {
55  assert(myEdge);
56 }
57 
58 
60  assert(myEdge);
61 }
62 
63 
64 void
66  if (myForward) {
67  // show extra information for tests
68  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
69  WRITE_WARNING("Removing " + toString(SUMO_TAG_CONNECTION) + " '" +
71  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
72  }
73  // remove connection from edge
75  } else {
76  // show extra information for tests
77  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
78  std::string selected = mySelected ? ("a previously selected ") : ("");
79  WRITE_WARNING("Adding " + selected + toString(SUMO_TAG_CONNECTION) + " '" +
81  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
82  }
83  // add connection into edge
85  }
86 }
87 
88 
89 void
91  if (myForward) {
92  // show extra information for tests
93  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
94  std::string selected = mySelected ? ("a previously selected ") : ("");
95  WRITE_WARNING("Adding " + selected + toString(SUMO_TAG_CONNECTION) + " '" +
97  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
98  }
99  // add connection into edge
101  } else {
102  // show extra information for tests
103  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
104  WRITE_WARNING("Removing " + toString(SUMO_TAG_CONNECTION) + " '" +
106  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
107  }
108  // remove connection from edge
110  }
111 }
112 
113 
114 FXString
116  if (myForward) {
117  return ("Undo create " + toString(SUMO_TAG_CONNECTION)).c_str();
118  } else {
119  return ("Undo delete " + toString(SUMO_TAG_CONNECTION)).c_str();
120  }
121 }
122 
123 
124 FXString
126  if (myForward) {
127  return ("Redo create " + toString(SUMO_TAG_CONNECTION)).c_str();
128  } else {
129  return ("Redo delete " + toString(SUMO_TAG_CONNECTION)).c_str();
130  }
131 }
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:49
int toLane
The lane the connections yields in.
Definition: NBEdge.h:191
bool mySelected
flag to indicates if crossing was previously selected
NBEdge * toEdge
The edge the connections yields in.
Definition: NBEdge.h:188
connectio between two lanes
The representation of a single edge during network building.
Definition: NBEdge.h:71
~GNEChange_Connection()
Destructor.
NBEdge::Connection myNBEdgeConnection
the data which must be copied because the original reference does not persist
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
int fromLane
The lane the connections starts at.
Definition: NBEdge.h:185
FXString undoName() const
return undoName
const std::string getID() const
function to support debugging
begin/end of the description of an edge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:58
void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation=false)
adds a connection
Definition: GNEEdge.cpp:1106
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:87
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:1127
std::string getLaneID(int lane) const
get Lane ID (Secure)
Definition: NBEdge.cpp:2746
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:306
FXString redoName() const
get Redo name