Eclipse SUMO - Simulation of Urban MObility
GNEChange_Shape.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-2022 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 single poly is created or deleted
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include <netedit/GNENet.h>
23 
24 #include "GNEChange_Shape.h"
25 
26 // ===========================================================================
27 // FOX-declarations
28 // ===========================================================================
29 FXIMPLEMENT_ABSTRACT(GNEChange_Shape, GNEChange, nullptr, 0)
30 
31 // ===========================================================================
32 // member method definitions
33 // ===========================================================================
34 
35 GNEChange_Shape::GNEChange_Shape(GNEShape* shape, bool forward) :
36  GNEChange(Supermode::NETWORK, shape, forward, shape->isAttributeCarrierSelected()),
37  myShape(shape) {
38  myShape->incRef("GNEChange_Shape");
39 }
40 
41 
43  myShape->decRef("GNEChange_Shape");
44  if (myShape->unreferenced()) {
45  // make sure that shape are removed of ShapeContainer (net) AND grid
46  if (myShape->getNet()->getAttributeCarriers()->retrieveShape(myShape, false) != nullptr) {
47  // show extra information for tests
48  WRITE_DEBUG("Removing " + myShape->getTagStr() + " '" + myShape->getID() + "' from net in ~GNEChange_Shape()");
49  // remove polygon from AttributeCarreirs
51  }
52  // show extra information for tests
53  WRITE_DEBUG("delete " + myShape->getTagStr() + " '" + myShape->getID() + "' in ~GNEChange_Shape()");
54  delete myShape;
55  }
56 }
57 
58 
59 void
61  if (myForward) {
62  // show extra information for tests
63  WRITE_DEBUG("Removing " + myShape->getTagStr() + " '" + myShape->getID() + "' from viewNet");
64  // unselect if mySelectedElement is enabled
65  if (mySelectedElement) {
67  }
68  // remove shape from net
70  // restore container
72  } else {
73  // show extra information for tests
74  WRITE_DEBUG("Adding " + myShape->getTagStr() + " '" + myShape->getID() + "' into viewNet");
75  // select if mySelectedElement is enabled
76  if (mySelectedElement) {
78  }
79  // Add shape in net
81  // restore container
83  }
84 }
85 
86 
87 void
89  if (myForward) {
90  // show extra information for tests
91  WRITE_DEBUG("Adding " + myShape->getTagStr() + " '" + myShape->getID() + "' into viewNet");
92  // select if mySelectedElement is enabled
93  if (mySelectedElement) {
95  }
96  // Add shape in net
98  // Add element in parents and children
100  } else {
101  // show extra information for tests
102  WRITE_DEBUG("Removing " + myShape->getTagStr() + " '" + myShape->getID() + "' from viewNet");
103  // unselect if mySelectedElement is enabled
104  if (mySelectedElement) {
106  }
107  // remove shape from net
109  // Remove element from parents and children
111  }
112 }
113 
114 
115 std::string
117  if (myForward) {
118  return ("Undo create " + myShape->getTagStr());
119  } else {
120  return ("Undo delete " + myShape->getTagStr());
121  }
122 }
123 
124 
125 std::string
127  if (myForward) {
128  return ("Redo create " + myShape->getTagStr());
129  } else {
130  return ("Redo delete " + myShape->getTagStr());
131  }
132 }
Supermode
@brie enum for supermodes
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:290
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
~GNEChange_Shape()
Destructor.
void redo()
redo action
std::string redoName() const
get Redo name
void undo()
undo action
GNEShape * myShape
pointer to shape
std::string undoName() const
return undoName
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:64
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag
Definition: GNEChange.h:244
const bool mySelectedElement
flag for check if element is selected
Definition: GNEChange.h:247
void addElementInParentsAndChildren(T *element)
add given element into parents and children (only use in redo() function)
Definition: GNEChange.h:132
void removeElementFromParentsAndChildren(T *element)
remove given element from parents and children (only use in redo() function)
Definition: GNEChange.h:187
void restoreHierarchicalContainers()
restore container (only use in undo() function)
Definition: GNEChange.cpp:94
GNEShape * retrieveShape(SumoXMLTag, const std::string &id, bool hardFail=true) const
Returns the named shape.
void deleteShape(GNEShape *shape)
delete shape element of GNENet container
void insertShape(GNEShape *shape)
Insert a shape element int GNENet container.
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:125
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced
const std::string & getID() const
get ID (all shapes have one)
Definition: GNEShape.cpp:53