SUMO - Simulation of Urban MObility
GNEChange_Poly.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A network change in which a single poly is created or deleted
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
31 #include <utils/common/RGBColor.h>
33 
34 #include "GNEChange_Poly.h"
35 #include "GNEPoly.h"
36 #include "GNENet.h"
37 #include "GNEViewNet.h"
38 
39 
40 // ===========================================================================
41 // FOX-declarations
42 // ===========================================================================
43 FXIMPLEMENT_ABSTRACT(GNEChange_Poly, GNEChange, NULL, 0)
44 
45 // ===========================================================================
46 // member method definitions
47 // ===========================================================================
48 
49 
50 GNEChange_Poly::GNEChange_Poly(GNENet* net, GNEPoly* poly, bool forward) :
52  GNEChange(net, forward),
53  myPoly(poly) {
54  myPoly->incRef("GNEChange_Poly");
55  assert(myNet);
56 }
57 
58 
60  assert(myPoly);
61  myPoly->decRef("GNEChange_Poly");
62  if (myPoly->unreferenced()) {
63  // show extra information for tests
64  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
65  WRITE_WARNING("Removing " + toString(SUMO_TAG_POLY) + " '" + myPoly->getID() + "' from net");
66  }
67  // remove polygon of net
68  if (myNet->removePolygon(myPoly->getID()) == false) {
69  WRITE_ERROR("Trying to remove non-inserted ''" + myPoly->getID() + "' from net");
70  }
71  }
72 }
73 
74 
75 void
77  if (myForward) {
78  // show extra information for tests
79  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
80  WRITE_WARNING("Removing " + toString(SUMO_TAG_POLY) + " '" + myPoly->getID() + "' from viewNet");
81  }
82  // remove polygon of net
84  } else {
85  // show extra information for tests
86  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
87  WRITE_WARNING("Adding " + toString(SUMO_TAG_POLY) + " '" + myPoly->getID() + "' into viewNet");
88  }
89  // Add polygon to view
91  }
92  // Requiere always save shapes
94 }
95 
96 
97 void
99  if (myForward) {
100  // show extra information for tests
101  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
102  WRITE_WARNING("Adding " + toString(SUMO_TAG_POLY) + " '" + myPoly->getID() + "' into viewNet");
103  }
104  // Add polygon to view
106  } else {
107  // show extra information for tests
108  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
109  WRITE_WARNING("Removing " + toString(SUMO_TAG_POLY) + " '" + myPoly->getID() + "' from viewNet");
110  }
111  // delete poly from view
113  }
114  // Requiere always save shapes
116 }
117 
118 
119 FXString
121  if (myForward) {
122  return ("Undo create " + toString(SUMO_TAG_POLY)).c_str();
123  } else {
124  return ("Undo delete " + toString(SUMO_TAG_POLY)).c_str();
125  }
126 }
127 
128 
129 FXString
131  if (myForward) {
132  return ("Redo create " + toString(SUMO_TAG_POLY)).c_str();
133  } else {
134  return ("Redo delete " + toString(SUMO_TAG_POLY)).c_str();
135  }
136 }
GNEPoly * myPoly
pointer to polygon
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:49
void removePolygonOfView(GNEPoly *p)
remove polygon of view net
Definition: GNENet.cpp:1872
bool removePolygon(const std::string &id)
Removes a polygon from the container.
Definition: GNENet.cpp:1847
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:92
void redo()
redo action
FXString undoName() const
return undoName
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
void insertPolygonInView(GNEPoly *p)
insert created polygon in view net
Definition: GNENet.cpp:1858
FXString redoName() const
get Redo name
const std::string getID() const
function to support debugging
void decRef(const std::string &debugMsg="")
Decrease reference.
~GNEChange_Poly()
Destructor.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
GNENet * myNet
the net to which operations shall be applied or which shall be informed about gui updates (we are not...
Definition: GNEChange.h:82
void undo()
undo action
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:87
void requiereSaveShapes()
inform that shapes has to be saved
Definition: GNENet.cpp:1247
bool unreferenced()
check if object ins&#39;t referenced
begin/end of the description of a polygon