Eclipse SUMO - Simulation of Urban MObility
GNEChange_Junction.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // A network change in which a single junction is created or deleted
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include <netedit/GNENet.h>
23 
24 #include "GNEChange_Junction.h"
25 
26 // ===========================================================================
27 // FOX-declarations
28 // ===========================================================================
29 FXIMPLEMENT_ABSTRACT(GNEChange_Junction, GNEChange, nullptr, 0)
30 
31 // ===========================================================================
32 // member method definitions
33 // ===========================================================================
34 
35 
36 GNEChange_Junction::GNEChange_Junction(GNEJunction* junction, bool forward):
38  GNEChange(Supermode::NETWORK, junction, forward, junction->isAttributeCarrierSelected()),
39  myJunction(junction) {
40  junction->incRef("GNEChange_Junction");
41 }
42 
43 
45  myJunction->decRef("GNEChange_Junction");
46  if (myJunction->unreferenced()) {
47  // show extra information for tests
48  WRITE_DEBUG("Deleting unreferenced " + myJunction->getTagStr() + " '" + myJunction->getID() + "' in GNEChange_Junction");
49  delete myJunction;
50  }
51 }
52 
53 
54 void
56  if (myForward) {
57  // show extra information for tests
58  WRITE_DEBUG("Removing " + myJunction->getTagStr() + " '" + myJunction->getID() + "' from " + toString(SUMO_TAG_NET));
59  // unselect if mySelectedElement is enabled
60  if (mySelectedElement) {
62  }
63  // add junction to net
65  } else {
66  // show extra information for tests
67  WRITE_DEBUG("Adding " + myJunction->getTagStr() + " '" + myJunction->getID() + "' into " + toString(SUMO_TAG_NET));
68  // select if mySelectedElement is enabled
69  if (mySelectedElement) {
71  }
72  // delete junction from net
74  }
75  // enable save networkElements
77 }
78 
79 
80 void
82  if (myForward) {
83  // show extra information for tests
84  WRITE_DEBUG("Adding " + myJunction->getTagStr() + " '" + myJunction->getID() + "' into " + toString(SUMO_TAG_NET));
85  // select if mySelectedElement is enabled
86  if (mySelectedElement) {
88  }
89  // add junction into net
91  } else {
92  // show extra information for tests
93  WRITE_DEBUG("Removing " + myJunction->getTagStr() + " '" + myJunction->getID() + "' from " + toString(SUMO_TAG_NET));
94  // unselect if mySelectedElement is enabled
95  if (mySelectedElement) {
97  }
98  // delete junction from net
100  }
101  // enable save networkElements
103 }
104 
105 
106 std::string
108  if (myForward) {
109  return (TL("Undo create junction '") + myJunction->getID() + "'");
110  } else {
111  return (TL("Undo delete junction '") + myJunction->getID() + "'");
112  }
113 }
114 
115 
116 std::string
118  if (myForward) {
119  return (TL("Redo create junction '") + myJunction->getID() + "'");
120  } else {
121  return (TL("Redo delete junction '") + myJunction->getID() + "'");
122  }
123 }
Supermode
@brie enum for supermodes
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:306
#define TL(string)
Definition: MsgHandler.h:315
@ SUMO_TAG_NET
root element of a network file
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
const std::string getID() const
get ID (all Attribute Carriers have one)
const std::string & getTagStr() const
get tag assigned to this object in string format
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
GNENet * getNet() const
get pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
std::string undoName() const
return undoName
void redo()
redo action
~GNEChange_Junction()
Destructor.
GNEJunction * myJunction
full information regarding the junction that is to be created/deleted
std::string redoName() const
get Redo name
void undo()
undo action
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:56
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag
Definition: GNEChange.h:212
const bool mySelectedElement
flag for check if element is selected
Definition: GNEChange.h:215
void deleteSingleJunction(GNEJunction *junction)
delete junction from container
void insertJunction(GNEJunction *junction)
insert junction in container
void requireSaveNetwork()
inform that network has to be saved
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition: GNENet.cpp:127
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:121
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced