Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEChange_GenericData.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 generic data set is created or deleted
19/****************************************************************************/
20
21// ===========================================================================
22// included modules
23// ===========================================================================
24#include <config.h>
25
26#include <netedit/GNENet.h>
27#include <netedit/GNEViewNet.h>
31
33
34// ===========================================================================
35// FOX-declarations
36// ===========================================================================
37FXIMPLEMENT_ABSTRACT(GNEChange_GenericData, GNEChange, nullptr, 0)
38
39// ===========================================================================
40// member method definitions
41// ===========================================================================
42
44 GNEChange(Supermode::DATA, genericData, forward, genericData->isAttributeCarrierSelected()),
45 myGenericData(genericData),
46 myDataSetParent(genericData->getDataIntervalParent()->getDataSetParent()),
47 myDataIntervalParent(genericData->getDataIntervalParent()) {
48 myGenericData->incRef("GNEChange_GenericData");
49}
50
51
53 // only continue we have undo-redo mode enabled
55 myGenericData->decRef("GNEChange_GenericData");
59 // show extra information for tests
60 WRITE_DEBUG("Deleting unreferenced " + myGenericData->getTagStr());
61 // delete generic data from interval parent
63 // delete generic data
64 delete myGenericData;
65 }
66 }
67}
68
69
70void
72 if (myForward) {
73 // show extra information for tests
74 WRITE_DEBUG("Removing " + myGenericData->getTagStr() + " '" + myGenericData->getID() + "' in GNEChange_GenericData");
75 // unselect if mySelectedElement is enabled
78 }
79 // delete generic data from interval parent
81 // restore container
83 } else {
84 // show extra information for tests
85 WRITE_DEBUG("Adding " + myGenericData->getTagStr() + " '" + myGenericData->getID() + "' in GNEChange_GenericData");
86 // select if mySelectedElement is enabled
89 }
90 // insert generic data into interval parent
92 // restore container
94 }
95 // require always save elements
97}
98
99
100void
102 if (myForward) {
103 // show extra information for tests
104 WRITE_DEBUG("Adding " + myGenericData->getTagStr() + " '" + myGenericData->getID() + "' in GNEChange_GenericData");
105 // select if mySelectedElement is enabled
106 if (mySelectedElement) {
108 }
109 // insert generic data into interval parent
111 // add genericData in parents and children
113 } else {
114 // show extra information for tests
115 WRITE_DEBUG("Removing " + myGenericData->getTagStr() + " '" + myGenericData->getID() + "' in GNEChange_GenericData");
116 // unselect if mySelectedElement is enabled
117 if (mySelectedElement) {
119 }
120 // delete generic data from interval parent
122 // remove genericData from parents and children
124 }
125 // require always save elements
127}
128
129
130std::string
132 if (myForward) {
133 return (TL("Undo create ") + myGenericData->getTagStr());
134 } else {
135 return (TL("Undo delete ") + myGenericData->getTagStr());
136 }
137}
138
139
140std::string
142 if (myForward) {
143 return (TL("Redo create ") + myGenericData->getTagStr());
144 } else {
145 return (TL("Redo delete ") + myGenericData->getTagStr());
146 }
147}
Supermode
@brie enum for supermodes
@ DATA
Data mode (edgeData, LaneData etc..)
#define WRITE_DEBUG(msg)
Definition MsgHandler.h:306
#define TL(string)
Definition MsgHandler.h:315
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
GNEGenericData * myGenericData
full information regarding the generic data set that is to be created/deleted
std::string redoName() const
get Redo name
GNEDataInterval * myDataIntervalParent
data interval parent
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
void removeGenericDataChild(GNEGenericData *genericData)
add generic data child
void addGenericDataChild(GNEGenericData *genericData)
add generic data child
An Element which don't belong to GNENet but has influence in the simulation.
GNEDataInterval * retrieveDataInterval(const GNEAttributeCarrier *AC, bool hardFail=true) const
Returns the data interval.
GNEGenericData * retrieveGenericData(const GUIGlObject *glObject, bool hardFail=true) const
Returns the generic data.
void requireSaveDataElements()
inform that data elements 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:2155
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