Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-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 something is changed (for undo/redo)
19/****************************************************************************/
20
21#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
26
28
29// ===========================================================================
30// FOX-declarations
31// ===========================================================================
32
33FXIMPLEMENT_ABSTRACT(GNEChange_ToggleAttribute, GNEChange, nullptr, 0)
34
35// ===========================================================================
36// member method definitions
37// ===========================================================================
38
40 GNEChange(ac->getTagProperty()->getSupermode(), true, false),
41 myAC(ac),
42 myKey(key),
43 myOrigValue(ac->isAttributeEnabled(key)),
44 myNewValue(value) {
45 myAC->incRef("GNEChange_ToggleAttribute " + myAC->getTagProperty()->getTagStr());
46}
47
48
50 // only continue we have undo-redo mode enabled
52 // decrease reference
53 myAC->decRef("GNEChange_ToggleAttribute " + myAC->getTagProperty()->getTagStr());
54 // remove if is unreferenced
55 if (myAC->unreferenced()) {
56 // delete AC
57 delete myAC;
58 }
59 }
60}
61
62
63void
65 // set original value
67 // check if networkElements, additional or shapes has to be saved
70 } else if (myAC->getTagProperty()->isAdditionalElement()) {
72 } else if (myAC->getTagProperty()->isDemandElement()) {
74 } else if (myAC->getTagProperty()->isDataElement()) {
76 } else if (myAC->getTagProperty()->isMeanData()) {
78 }
79}
80
81
82void
84 // set new attributes
86 // check if networkElements, additional or shapes has to be saved
89 } else if (myAC->getTagProperty()->isAdditionalElement()) {
91 } else if (myAC->getTagProperty()->isDemandElement()) {
93 } else if (myAC->getTagProperty()->isDataElement()) {
95 } else if (myAC->getTagProperty()->isMeanData()) {
97 }
98}
99
100
101std::string
103 return (TLF("Undo toggle % attribute in '%'", myAC->getTagStr(), myAC->getID()));
104}
105
106
107std::string
109 return (TLF("Redo toggle % attribute in '%'", myAC->getTagStr(), myAC->getID()));
110}
111
112/****************************************************************************/
#define TLF(string,...)
Definition MsgHandler.h:307
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:164
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2194
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
network elements
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