Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEChange_ToggleAttribute.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 something is changed (for undo/redo)
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_ToggleAttribute, GNEChange, nullptr, 0)
33
34// ===========================================================================
35// member method definitions
36// ===========================================================================
37
39 GNEChange(ac->getTagProperty().getSupermode(), true, false),
40 myAC(ac),
41 myKey(key),
42 myOrigValue(ac->isAttributeEnabled(key)),
43 myNewValue(value) {
44 myAC->incRef("GNEChange_ToggleAttribute " + myAC->getTagProperty().getTagStr());
45}
46
47
49 // only continue we have undo-redo mode enabled
51 // decrease reference
52 myAC->decRef("GNEChange_ToggleAttribute " + myAC->getTagProperty().getTagStr());
53 // remove if is unreferenced
54 if (myAC->unreferenced()) {
55 // show extra information for tests
56 WRITE_DEBUG("Deleting unreferenced " + myAC->getTagStr() + " '" + myAC->getID() + "' in GNEChange_ToggleAttribute");
57 // delete AC
58 delete myAC;
59 }
60 }
61}
62
63
64void
66 // show extra information for tests
67 WRITE_DEBUG("Toggle attribute into " + myAC->getTagStr() + " '" + myAC->getID() + "'");
68 // set original value
70 // check if networkElements, additional or shapes has to be saved
73 } else if (myAC->getTagProperty().isAdditionalElement()) {
75 } else if (myAC->getTagProperty().isDemandElement()) {
77 } else if (myAC->getTagProperty().isDataElement()) {
79 } else if (myAC->getTagProperty().isMeanData()) {
81 }
82}
83
84
85void
87 // show extra information for tests
88 WRITE_DEBUG("Toggle attribute into " + myAC->getTagStr() + " '" + myAC->getID() + "'");
89 // set new attributes
91 // check if networkElements, additional or shapes has to be saved
94 } else if (myAC->getTagProperty().isAdditionalElement()) {
96 } else if (myAC->getTagProperty().isDemandElement()) {
98 } else if (myAC->getTagProperty().isDataElement()) {
100 } else if (myAC->getTagProperty().isMeanData()) {
102 }
103}
104
105
106std::string
108 return (TLF("Undo toggle % attribute in '%'", myAC->getTagStr(), myAC->getID()));
109}
110
111
112std::string
114 return (TLF("Redo toggle % attribute in '%'", myAC->getTagStr(), myAC->getID()));
115}
116
117/****************************************************************************/
#define WRITE_DEBUG(msg)
Definition MsgHandler.h:306
#define TLF(string,...)
Definition MsgHandler.h:317
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
const std::string getID() const
get ID (all Attribute Carriers have one)
virtual void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
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
the function-object for an editing operation (abstract base)
const bool myOrigValue
the original value
GNEAttributeCarrier * myAC
the net to which all operations shall be applied
std::string redoName() const
get Redo name
std::string undoName() const
return undoName
const bool myNewValue
the new value
const SumoXMLAttr myKey
The attribute name.
the function-object for an editing operation (abstract base)
Definition GNEChange.h:56
void requireSaveNetwork()
inform that network has to be saved
void requireSaveMeanDatas()
inform that mean data elements has to be saved
void requireSaveAdditionals()
inform that additionals has to be saved
void requireSaveDataElements()
inform that data elements has to be saved
void requireSaveDemandElements()
inform that demand elements has to be saved
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition GNENet.cpp:131
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2147
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced
bool isMeanData() const
return true if tag correspond to a mean data element
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
bool isNetworkElement() const
element sets
bool isDataElement() const
return true if tag correspond to a data element
bool isDemandElement() const
return true if tag correspond to a demand element
bool isAdditionalElement() const
return true if tag correspond to an additional element (note: this include TAZ, shapes and wires)
GNEViewParent * getViewParent() const
get the net object
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows