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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // A network change in which a single poly is created or deleted
18 /****************************************************************************/
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #ifdef _MSC_VER
24 #include <windows_config.h>
25 #else
26 #include <config.h>
27 #endif
28 
30 #include <utils/common/RGBColor.h>
32 
33 #include "GNEChange_Shape.h"
34 #include "GNEShape.h"
35 #include "GNEViewNet.h"
36 #include "GNENet.h"
37 
38 
39 // ===========================================================================
40 // FOX-declarations
41 // ===========================================================================
42 FXIMPLEMENT_ABSTRACT(GNEChange_Shape, GNEChange, NULL, 0)
43 
44 // ===========================================================================
45 // member method definitions
46 // ===========================================================================
47 
48 GNEChange_Shape::GNEChange_Shape(GNEShape* shape, bool forward) :
49  GNEChange(shape->getNet(), forward),
50  myShape(shape) {
51  assert(myNet);
52  myShape->incRef("GNEChange_Shape");
53 }
54 
55 
57  assert(myShape);
58  myShape->decRef("GNEChange_Shape");
59  if (myShape->unreferenced()) {
60  // show extra information for tests
61  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
62  WRITE_WARNING("Removing " + toString(myShape->getTag()) + " '" + myShape->getID() + "' from net");
63  }
64  // make sure that shape are removed of ShapeContainer
65  if (myShape->getTag() == SUMO_TAG_POLY) {
67  } else {
69  }
70  }
71 }
72 
73 
74 void
76  if (myForward) {
77  // show extra information for tests
78  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
79  WRITE_WARNING("Removing " + toString(myShape->getTag()) + " '" + myShape->getID() + "' from viewNet");
80  }
81  // remove shape from net
83  } else {
84  // show extra information for tests
85  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
86  WRITE_WARNING("Adding " + toString(myShape->getTag()) + " '" + myShape->getID() + "' into viewNet");
87  }
88  // Add shape in net
90  }
91 }
92 
93 
94 void
96  if (myForward) {
97  // show extra information for tests
98  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
99  WRITE_WARNING("Adding " + toString(myShape->getTag()) + " '" + myShape->getID() + "' into viewNet");
100  }
101  // Add shape in net
103  } else {
104  // show extra information for tests
105  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
106  WRITE_WARNING("Removing " + toString(myShape->getTag()) + " '" + myShape->getID() + "' from viewNet");
107  }
108  // remove shape from net
110  }
111 }
112 
113 
114 FXString
116  if (myForward) {
117  return ("Undo create " + toString(myShape->getTag())).c_str();
118  } else {
119  return ("Undo delete " + toString(myShape->getTag())).c_str();
120  }
121 }
122 
123 
124 FXString
126  if (myForward) {
127  return ("Redo create " + toString(myShape->getTag())).c_str();
128  } else {
129  return ("Redo delete " + toString(myShape->getTag())).c_str();
130  }
131 }
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:48
void redo()
redo action
FXString redoName() const
get Redo name
void removeShape(GNEShape *shape)
remove created shape (but NOT delete)
Definition: GNENet.cpp:2252
POIs myPOIs
stored POIs
GNEShape * myShape
pointer to shape
Polygons myPolygons
stored Polygons
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
void insertShape(GNEShape *shape)
insert shape
Definition: GNENet.cpp:2233
FXString undoName() const
return undoName
const std::string getID() const
function to support debugging
~GNEChange_Shape()
Destructor.
void decRef(const std::string &debugMsg="")
Decrease reference.
GNENet * myNet
the net to which operations shall be applied or which shall be informed about gui updates (we are not...
Definition: GNEChange.h:81
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:86
bool remove(const std::string &id, const bool del=true)
Removes an item.
void undo()
undo action
bool unreferenced()
check if object ins&#39;t referenced
begin/end of the description of a polygon
SumoXMLTag getTag() const
get XML Tag assigned to this object