Eclipse SUMO - Simulation of Urban MObility
GNEChange_EnableAttribute.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // A network change in which something is changed (for undo/redo)
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 #include <netedit/GNENet.h>
25 
27 
28 // ===========================================================================
29 // FOX-declarations
30 // ===========================================================================
31 FXIMPLEMENT_ABSTRACT(GNEChange_EnableAttribute, GNEChange, nullptr, 0)
32 
33 // ===========================================================================
34 // member method definitions
35 // ===========================================================================
36 
37 GNEChange_EnableAttribute::GNEChange_EnableAttribute(GNEAttributeCarrier* ac, GNENet* net, const int originalAttributes, const int newAttributes) :
38  GNEChange(net, true),
39  myAC(ac),
40  myOriginalAttributes(originalAttributes),
41  myNewAttributes(newAttributes) {
42  myAC->incRef("GNEChange_EnableAttribute " + myAC->getTagProperty().getTagStr());
43 }
44 
45 
47  // decrease reference
48  myAC->decRef("GNEChange_EnableAttribute " + myAC->getTagProperty().getTagStr());
49  // remove if is unreferenced
50  if (myAC->unreferenced()) {
51  // show extra information for tests
52  WRITE_DEBUG("Deleting unreferenced " + myAC->getTagStr() + " '" + myAC->getID() + "' in GNEChange_EnableAttribute");
53  // Check if attribute carrier is a shape
54  if (myAC->getTagProperty().isShape()) {
55  // remove shape using specific functions
60  }
61  } else {
62  delete myAC;
63  }
64  }
65 }
66 
67 
68 void
70  // show extra information for tests
71  WRITE_DEBUG("Setting previous attribute into " + myAC->getTagStr() + " '" + myAC->getID() + "'");
72  // set original attributes
74  // check if netElements, additional or shapes has to be saved
75  if (myAC->getTagProperty().isNetElement()) {
76  myNet->requiereSaveNet(true);
77  } else if (myAC->getTagProperty().isAdditional() || myAC->getTagProperty().isShape()) {
79  } else if (myAC->getTagProperty().isDemandElement()) {
81  }
82 }
83 
84 
85 void
87  // show extra information for tests
88  WRITE_DEBUG("Setting new attribute into " + myAC->getTagStr() + " '" + myAC->getID() + "'");
89  // set new attributes
91  // check if netElements, additional or shapes has to be saved
92  if (myAC->getTagProperty().isNetElement()) {
93  myNet->requiereSaveNet(true);
94  } else if (myAC->getTagProperty().isAdditional() || myAC->getTagProperty().isShape()) {
96  } else if (myAC->getTagProperty().isDemandElement()) {
98  }
99 }
100 
101 
102 FXString
104  return ("Undo change " + myAC->getTagStr() + " attribute").c_str();
105 }
106 
107 
108 FXString
110  return ("Redo change " + myAC->getTagStr() + " attribute").c_str();
111 }
112 
113 
114 /****************************************************************************/
GNEReferenceCounter::unreferenced
bool unreferenced()
check if object ins't referenced
Definition: GNEReferenceCounter.h:79
GNEAttributeCarrier::getID
const std::string getID() const
function to support debugging
Definition: GNEAttributeCarrier.cpp:1187
GNEAttributeCarrier::TagProperties::isAdditional
bool isAdditional() const
return true if tag correspond to an additional
Definition: GNEAttributeCarrier.cpp:696
SUMO_TAG_POLY
begin/end of the description of a polygon
Definition: SUMOXMLDefinitions.h:58
GNEAttributeCarrier::TagProperties::getTagStr
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
Definition: GNEAttributeCarrier.cpp:527
GNEChange_EnableAttribute::redoName
FXString redoName() const
get Redo name
Definition: GNEChange_EnableAttribute.cpp:109
GNENet::requiereSaveNet
void requiereSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:933
GNEChange_EnableAttribute::redo
void redo()
redo action
Definition: GNEChange_EnableAttribute.cpp:86
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:78
GNEAttributeCarrier::TagProperties::isNetElement
bool isNetElement() const
return true if tag correspond to a netElement
Definition: GNEAttributeCarrier.cpp:690
SUMO_TAG_POI
begin/end of the description of a Point of interest
Definition: SUMOXMLDefinitions.h:54
GNEAttributeCarrier::TagProperties::isShape
bool isShape() const
return true if tag correspond to a shape
Definition: GNEAttributeCarrier.cpp:701
GNEChange_EnableAttribute::undoName
FXString undoName() const
return undoName
Definition: GNEChange_EnableAttribute.cpp:103
GNEChange_EnableAttribute::myOriginalAttributes
const int myOriginalAttributes
original attributes
Definition: GNEChange_EnableAttribute.h:82
GNEAttributeCarrier::TagProperties::getTag
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
Definition: GNEAttributeCarrier.cpp:521
GNEAttributeCarrier::setEnabledAttribute
virtual void setEnabledAttribute(const int enabledAttributes)=0
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
GNEAttributeCarrier::getTagProperty
const TagProperties & getTagProperty() const
get Tag Property assigned to this object
Definition: GNEAttributeCarrier.cpp:1171
GNENet::requiereSaveAdditionals
void requiereSaveAdditionals(bool value)
inform that additionals has to be saved
Definition: GNENet.cpp:2186
SUMO_TAG_POILANE
begin/end of the description of a Point of interest over Lane (used by Netedit)
Definition: SUMOXMLDefinitions.h:56
GNEAttributeCarrier::TagProperties::isDemandElement
bool isDemandElement() const
return true if tag correspond to a demand element
Definition: GNEAttributeCarrier.cpp:713
GNENetElement.h
GNENet::requiereSaveDemandElements
void requiereSaveDemandElements(bool value)
inform that demand elements has to be saved
Definition: GNENet.cpp:2342
GNEChange_EnableAttribute::~GNEChange_EnableAttribute
~GNEChange_EnableAttribute()
Destructor.
Definition: GNEChange_EnableAttribute.cpp:46
GNEChange_EnableAttribute
the function-object for an editing operation (abstract base)
Definition: GNEChange_EnableAttribute.h:45
GNEChange::myNet
GNENet * myNet
the net to which operations shall be applied or which shall be informed about gui updates (we are not...
Definition: GNEChange.h:76
GNEReferenceCounter::decRef
void decRef(const std::string &debugMsg="")
Decrease reference.
Definition: GNEReferenceCounter.h:53
GNEChange_EnableAttribute::myAC
GNEAttributeCarrier * myAC
the net to which all operations shall be applied
Definition: GNEChange_EnableAttribute.h:79
GNEChange_EnableAttribute.h
GNEChange_EnableAttribute::undo
void undo()
undo action
Definition: GNEChange_EnableAttribute.cpp:69
GNEChange_EnableAttribute::myNewAttributes
const int myNewAttributes
original attributes
Definition: GNEChange_EnableAttribute.h:85
ShapeContainer::removePolygon
virtual bool removePolygon(const std::string &id, bool useLock=true)
Removes a polygon from the container.
Definition: ShapeContainer.cpp:154
config.h
ShapeContainer::removePOI
virtual bool removePOI(const std::string &id)
Removes a PoI from the container.
Definition: ShapeContainer.cpp:164
GNEAttributeCarrier::getTagStr
const std::string & getTagStr() const
get tag assigned to this object in string format
Definition: GNEAttributeCarrier.cpp:1165
GNEChange
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:43
WRITE_DEBUG
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:246
GNEAttributeCarrier
Definition: GNEAttributeCarrier.h:54
GNENet.h