Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEChange_TAZSourceSink.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_TAZSourceSink, GNEChange, nullptr, 0)
33
34// ===========================================================================
35// member method definitions
36// ===========================================================================
37
39 GNEChange(Supermode::NETWORK, sourceSink, forward, sourceSink->isAttributeCarrierSelected()),
40 mySourceSink(sourceSink) {
41 mySourceSink->incRef("GNEChange_TAZSourceSink");
42}
43
44
46 // only continue we have undo-redo mode enabled
47 if (mySourceSink->getNet()->getViewNet()->getViewParent()->getGNEAppWindows()->isUndoRedoAllowed()) {
48 mySourceSink->decRef("GNEChange_TAZSourceSink");
49 if (mySourceSink->unreferenced()) {
50 // make sure that sourceSink isn't in net before removing
51 if (mySourceSink->getNet()->getAttributeCarriers()->retrieveTAZSourceSink(mySourceSink, false)) {
52 // delete sourceSink from net
53 mySourceSink->getNet()->getAttributeCarriers()->deleteTAZSourceSink(mySourceSink);
54 }
55 delete mySourceSink;
56 }
57 }
58}
59
60
61void
63 if (myForward) {
64 // delete sourceSink from net
65 mySourceSink->getNet()->getAttributeCarriers()->deleteTAZSourceSink(mySourceSink);
66 // remove element from parent and children
68 } else {
69 // add element in parent and children
71 // insert sourceSink into net
72 mySourceSink->getNet()->getAttributeCarriers()->insertTAZSourceSink(mySourceSink);
73 }
74 // require always save sourceSinks
75 mySourceSink->getNet()->getSavingStatus()->requireSaveAdditionals();
76}
77
78
79void
81 if (myForward) {
82 // select if mySelectedElement is enabled
84 mySourceSink->selectAttributeCarrier();
85 }
86 // add element in parent and children
88 // insert sourceSink into net
89 mySourceSink->getNet()->getAttributeCarriers()->insertTAZSourceSink(mySourceSink);
90 } else {
91 // delete sourceSink from net
92 mySourceSink->getNet()->getAttributeCarriers()->deleteTAZSourceSink(mySourceSink);
93 // remove element from parent and children
95 }
96 // require always save sourceSinks
97 mySourceSink->getNet()->getSavingStatus()->requireSaveAdditionals();
98}
99
100
101std::string
103 if (myForward) {
104 return (TL("Undo create ") + mySourceSink->getTagStr() + " '" + mySourceSink->getID() + "'");
105 } else {
106 return (TL("Undo delete ") + mySourceSink->getTagStr() + " '" + mySourceSink->getID() + "'");
107 }
108}
109
110
111std::string
113 if (myForward) {
114 return (TL("Redo create ") + mySourceSink->getTagStr() + " '" + mySourceSink->getID() + "'");
115 } else {
116 return (TL("Redo delete ") + mySourceSink->getTagStr() + " '" + mySourceSink->getID() + "'");
117 }
118}
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
std::string undoName() const
get undo Name
GNEChange_TAZSourceSink(GNETAZSourceSink *sourceSink, bool forward)
Constructor for creating/deleting an sourceSink element.
GNETAZSourceSink * mySourceSink
full information regarding the sourceSink element that is to be created/deleted
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