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-2020 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(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  // get tag (due POIs)
47  // make sure that shape are removed of ShapeContainer (net) AND grid
48  if (myShape->getNet()->retrieveShape(shapeTag, myShape->getID(), false) != nullptr) {
49  // show extra information for tests
50  WRITE_DEBUG("Removing " + myShape->getTagStr() + " '" + myShape->getID() + "' from net in ~GNEChange_Shape()");
51  // remove polygon from AttributeCarreirs
53  }
54  // show extra information for tests
55  WRITE_DEBUG("delete " + myShape->getTagStr() + " '" + myShape->getID() + "' in ~GNEChange_Shape()");
56  delete myShape;
57  }
58 }
59 
60 
61 void
63  if (myForward) {
64  // show extra information for tests
65  WRITE_DEBUG("Removing " + myShape->getTagStr() + " '" + myShape->getID() + "' from viewNet");
66  // unselect if mySelectedElement is enabled
67  if (mySelectedElement) {
69  }
70  // remove shape from net
72  // restore container
74  } else {
75  // show extra information for tests
76  WRITE_DEBUG("Adding " + myShape->getTagStr() + " '" + myShape->getID() + "' into viewNet");
77  // select if mySelectedElement is enabled
78  if (mySelectedElement) {
80  }
81  // Add shape in net
83  // restore container
85  }
86 }
87 
88 
89 void
91  if (myForward) {
92  // show extra information for tests
93  WRITE_DEBUG("Adding " + myShape->getTagStr() + " '" + myShape->getID() + "' into viewNet");
94  // select if mySelectedElement is enabled
95  if (mySelectedElement) {
97  }
98  // Add shape in net
100  // Add element in parents and children
102  } else {
103  // show extra information for tests
104  WRITE_DEBUG("Removing " + myShape->getTagStr() + " '" + myShape->getID() + "' from viewNet");
105  // unselect if mySelectedElement is enabled
106  if (mySelectedElement) {
108  }
109  // remove shape from net
111  // Remove element from parents and children
113  }
114 }
115 
116 
117 FXString
119  if (myForward) {
120  return ("Undo create " + myShape->getTagStr()).c_str();
121  } else {
122  return ("Undo delete " + myShape->getTagStr()).c_str();
123  }
124 }
125 
126 
127 FXString
129  if (myForward) {
130  return ("Redo create " + myShape->getTagStr()).c_str();
131  } else {
132  return ("Redo delete " + myShape->getTagStr()).c_str();
133  }
134 }
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:286
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ SUMO_TAG_POILANE
begin/end of the description of a Point of interest over Lane (used by Netedit)
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties & getTagProperty() const
get Tag Property assigned to this object
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.
FXString undoName() const
return undoName
void redo()
redo action
FXString redoName() const
get Redo name
void undo()
undo action
GNEShape * myShape
pointer to shape
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:65
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag
Definition: GNEChange.h:215
const bool mySelectedElement
flag for check if element is selected
Definition: GNEChange.h:218
void addElementInParentsAndChildren(T *element)
add given element into parents and children (only use in redo() function)
Definition: GNEChange.h:106
void removeElementFromParentsAndChildren(T *element)
remove given element from parents and children (only use in redo() function)
Definition: GNEChange.h:161
void restoreHierarchicalContainers()
restore container (only use in undo() function)
Definition: GNEChange.cpp:82
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
retrieve all attribute carriers of Net
Definition: GNENet.cpp:130
GNEShape * retrieveShape(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named shape.
Definition: GNENet.cpp:2944
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
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property