Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEChange_Additional.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 busStop is created or deleted
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
26
28
29// ===========================================================================
30// FOX-declarations
31// ===========================================================================
32FXIMPLEMENT_ABSTRACT(GNEChange_Additional, GNEChange, nullptr, 0)
33
34// ===========================================================================
35// member method definitions
36// ===========================================================================
37
39 GNEChange(Supermode::NETWORK, additional, forward, additional->isAttributeCarrierSelected()),
40 myAdditional(additional) {
41 myAdditional->incRef("GNEChange_Additional");
42}
43
44
46 // only continue we have undo-redo mode enabled
48 myAdditional->decRef("GNEChange_Additional");
50 // show extra information for tests
51 WRITE_DEBUG("Deleting unreferenced " + myAdditional->getTagStr());
52 // make sure that additional isn't in net before removing
54 // delete additional from net
56 }
57 delete myAdditional;
58 }
59 }
60}
61
62
63void
65 if (myForward) {
66 // show extra information for tests
67 WRITE_DEBUG("Removing " + myAdditional->getTagStr() + " '" + myAdditional->getID() + "' in GNEChange_Additional");
68 // unselect if mySelectedElement is enabled
71 }
72 // delete additional from net
74 // restore container
76 } else {
77 // show extra information for tests
78 WRITE_DEBUG("Adding " + myAdditional->getTagStr() + " '" + myAdditional->getID() + "' in GNEChange_Additional");
79 // select if mySelectedElement is enabled
82 }
83 // insert additional into net
85 // restore container
87 }
88 // require always save additionals
90}
91
92
93void
95 if (myForward) {
96 // show extra information for tests
97 WRITE_DEBUG("Adding " + myAdditional->getTagStr() + " '" + myAdditional->getID() + "' in GNEChange_Additional");
98 // select if mySelectedElement is enabled
101 }
102 // insert additional into net
104 // add additional in parent elements
106 } else {
107 // show extra information for tests
108 WRITE_DEBUG("Removing " + myAdditional->getTagStr() + " '" + myAdditional->getID() + "' in GNEChange_Additional");
109 // unselect if mySelectedElement is enabled
110 if (mySelectedElement) {
112 }
113 // delete additional from net
115 // remove additional from parents and children
117 }
118 // require always save additionals
120}
121
122
123std::string
125 if (myForward) {
126 return (TL("Undo create ") + myAdditional->getTagStr() + " '" + myAdditional->getID() + "'");
127 } else {
128 return (TL("Undo delete ") + myAdditional->getTagStr() + " '" + myAdditional->getID() + "'");
129 }
130}
131
132
133std::string
135 if (myForward) {
136 return (TL("Redo create ") + myAdditional->getTagStr() + " '" + myAdditional->getID() + "'");
137 } else {
138 return (TL("Redo delete ") + myAdditional->getTagStr() + " '" + myAdditional->getID() + "'");
139 }
140}
Supermode
@brie enum for supermodes
@ NETWORK
Network mode (Edges, junctions, etc..)
#define WRITE_DEBUG(msg)
Definition MsgHandler.h:306
#define TL(string)
Definition MsgHandler.h:315
An Element which don't belong to GNENet but has influence in the simulation.
const std::string getID() const
get ID (all Attribute Carriers have one)
void selectAttributeCarrier()
select attribute carrier using GUIGlobalSelection
void unselectAttributeCarrier()
unselect attribute carrier using GUIGlobalSelection
const std::string & getTagStr() const
get tag assigned to this object in string format
GNENet * getNet() const
get pointer to net
std::string redoName() const
get Redo name
GNEAdditional * myAdditional
full information regarding the additional element that is to be created/deleted
std::string undoName() const
return undoName
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 addElementInParentsAndChildren(T *element)
add given element into parents and children (only use in redo() function)
Definition GNEChange.h:124
void removeElementFromParentsAndChildren(T *element)
remove given element from parents and children (only use in redo() function)
Definition GNEChange.h:167
void restoreHierarchicalContainers()
restore container (only use in undo() function)
Definition GNEChange.cpp:94
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
void deleteAdditional(GNEAdditional *additional)
delete additional element of container
void insertAdditional(GNEAdditional *additional)
Insert a additional element in container.
void requireSaveAdditionals()
inform that additionals has to be saved
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition GNENet.cpp:133
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:127
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2163
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced
GNEViewParent * getViewParent() const
get the net object
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows