Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEChange_MeanData.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 mean 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
32#include "GNEChange_MeanData.h"
33
34// ===========================================================================
35// FOX-declarations
36// ===========================================================================
37FXIMPLEMENT_ABSTRACT(GNEChange_MeanData, GNEChange, nullptr, 0)
38
39// ===========================================================================
40// member method definitions
41// ===========================================================================
42
44 GNEChange(Supermode::DATA, meanData, forward, meanData->isAttributeCarrierSelected()),
45 myMeanData(meanData) {
46 myMeanData->incRef("GNEChange_MeanData");
47}
48
49
51 // only continue we have undo-redo mode enabled
53 myMeanData->decRef("GNEChange_MeanData");
54 if (myMeanData->unreferenced()) {
55 // show extra information for tests
56 WRITE_DEBUG("Deleting unreferenced " + myMeanData->getTagStr());
57 // make sure that MeanData isn't in net before removing
59 // delete MeanData from net
61 }
62 // delete mean data
63 delete myMeanData;
64 }
65 }
66}
67
68
69void
71 if (myForward) {
72 // show extra information for tests
73 WRITE_DEBUG("Removing " + myMeanData->getTagStr() + " '" + myMeanData->getID() + "' in GNEChange_MeanData");
74 // unselect if mySelectedElement is enabled
77 }
78 // delete meanData from net
80 } else {
81 // show extra information for tests
82 WRITE_DEBUG("Adding " + myMeanData->getTagStr() + " '" + myMeanData->getID() + "' in GNEChange_MeanData");
83 // select if mySelectedElement is enabled
86 }
87 // insert meanData into net
89 }
90 // require always save elements
92}
93
94
95void
97 if (myForward) {
98 // show extra information for tests
99 WRITE_DEBUG("Adding " + myMeanData->getTagStr() + " '" + myMeanData->getID() + "' in GNEChange_MeanData");
100 // select if mySelectedElement is enabled
101 if (mySelectedElement) {
103 }
104 // insert meanData into net
106 } else {
107 // show extra information for tests
108 WRITE_DEBUG("Removing " + myMeanData->getTagStr() + " '" + myMeanData->getID() + "' in GNEChange_MeanData");
109 // unselect if mySelectedElement is enabled
110 if (mySelectedElement) {
112 }
113 // delete meanData from net
115 }
116 // require always save elements
118}
119
120
121std::string
123 if (myForward) {
124 return (TL("Undo create ") + myMeanData->getTagStr());
125 } else {
126 return (TL("Undo delete ") + myMeanData->getTagStr());
127 }
128}
129
130
131std::string
133 if (myForward) {
134 return (TL("Redo create ") + myMeanData->getTagStr());
135 } else {
136 return (TL("Redo delete ") + myMeanData->getTagStr());
137 }
138}
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)
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
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * getNet() const
get pointer to net
GNEMeanData * myMeanData
full information regarding the mean data set that is to be created/deleted
void undo()
undo action
std::string undoName() const
return undoName
~GNEChange_MeanData()
Destructor.
std::string redoName() const
get Redo name
void redo()
redo 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
An Element which don't belong to GNENet but has influence in the simulation.
Definition GNEMeanData.h:33
GNEMeanData * retrieveMeanData(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named meanData.
void insertMeanData(GNEMeanData *meanData)
Insert a meanData element in container.
void deleteMeanData(GNEMeanData *meanData)
delete meanData element of container
void requireSaveMeanDatas()
inform that mean 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:2163
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
GNEViewParent * getViewParent() const
get the net object
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows