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-2025 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
21#include <netedit/GNENet.h>
22#include <netedit/GNEViewNet.h>
25
27
28// ===========================================================================
29// FOX-declarations
30// ===========================================================================
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
47 if (myAdditional->getNet()->getViewNet()->getViewParent()->getGNEAppWindows()->isUndoRedoAllowed()) {
48 myAdditional->decRef("GNEChange_Additional");
49 if (myAdditional->unreferenced()) {
50 // make sure that additional isn't in net before removing
51 if (myAdditional->getNet()->getAttributeCarriers()->retrieveAdditional(myAdditional, false)) {
52 // delete additional from net
53 myAdditional->getNet()->getAttributeCarriers()->deleteAdditional(myAdditional);
54 }
55 delete myAdditional;
56 }
57 }
58}
59
60
61void
63 if (myForward) {
64 // unselect if mySelectedElement is enabled
66 myAdditional->unselectAttributeCarrier();
67 }
68 // delete additional from net
69 myAdditional->getNet()->getAttributeCarriers()->deleteAdditional(myAdditional);
70 // remove element from parent and children
72 } else {
73 // select if mySelectedElement is enabled
75 myAdditional->selectAttributeCarrier();
76 }
77 // add element in parent and children
79 // insert additional into net
80 myAdditional->getNet()->getAttributeCarriers()->insertAdditional(myAdditional);
81 }
82 // require always save additionals
83 myAdditional->getNet()->getSavingStatus()->requireSaveAdditionals();
84}
85
86
87void
89 if (myForward) {
90 // select if mySelectedElement is enabled
92 myAdditional->selectAttributeCarrier();
93 }
94 // add element in parent and children
96 // insert additional into net
97 myAdditional->getNet()->getAttributeCarriers()->insertAdditional(myAdditional);
98 } else {
99 // unselect if mySelectedElement is enabled
100 if (mySelectedElement) {
101 myAdditional->unselectAttributeCarrier();
102 }
103 // delete additional from net
104 myAdditional->getNet()->getAttributeCarriers()->deleteAdditional(myAdditional);
105 // remove element from parent and children
107 }
108 // require always save additionals
109 myAdditional->getNet()->getSavingStatus()->requireSaveAdditionals();
110}
111
112
113std::string
115 if (myForward) {
116 return (TL("Undo create ") + myAdditional->getTagStr() + " '" + myAdditional->getID() + "'");
117 } else {
118 return (TL("Undo delete ") + myAdditional->getTagStr() + " '" + myAdditional->getID() + "'");
119 }
120}
121
122
123std::string
125 if (myForward) {
126 return (TL("Redo create ") + myAdditional->getTagStr() + " '" + myAdditional->getID() + "'");
127 } else {
128 return (TL("Redo delete ") + myAdditional->getTagStr() + " '" + myAdditional->getID() + "'");
129 }
130}
Supermode
@brie enum for supermodes
@ NETWORK
Network mode (Edges, junctions, etc..).
#define TL(string)
Definition MsgHandler.h:304
std::string redoName() const
get Redo name
GNEAdditional * myAdditional
full information regarding the additional element that is to be created/deleted
GNEChange_Additional(GNEAdditional *additional, bool forward)
Constructor for creating/deleting an additional element.
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:180
const bool mySelectedElement
flag for check if element is selected
Definition GNEChange.h:183
GNEChange(Supermode supermode, bool forward, const bool selectedElement)
Constructor.
Definition GNEChange.cpp:34
void addElementInParentsAndChildren(T *element)
add given element in parents and children
Definition GNEChange.h:121
void removeElementFromParentsAndChildren(T *element)
remove given element from parents and children
Definition GNEChange.h:148