Eclipse SUMO - Simulation of Urban MObility
GNEChange_EdgeType.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 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 edgeType is created or deleted
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include <netedit/GNENet.h>
23 #include <netedit/GNEViewNet.h>
24 #include <netedit/GNEViewParent.h>
27 
28 #include "GNEChange_EdgeType.h"
29 
30 // ===========================================================================
31 // FOX-declarations
32 // ===========================================================================
33 FXIMPLEMENT_ABSTRACT(GNEChange_EdgeType, GNEChange, nullptr, 0)
34 
35 // ===========================================================================
36 // member method definitions
37 // ===========================================================================
38 
39 
40 GNEChange_EdgeType::GNEChange_EdgeType(GNEEdgeType* edgeType, bool forward):
42  GNEChange(Supermode::NETWORK, edgeType, forward, edgeType->isAttributeCarrierSelected()),
43  myEdgeType(edgeType) {
44  edgeType->incRef("GNEChange_EdgeType");
45 }
46 
47 
49  myEdgeType->decRef("GNEChange_EdgeType");
50  if (myEdgeType->unreferenced()) {
51  // show extra information for tests
52  WRITE_DEBUG("Deleting unreferenced " + myEdgeType->getTagStr() + " '" + myEdgeType->getID() + "' GNEChange_EdgeType");
53  // make sure that edgeType isn't in net before removing
55  // delete edgeType from net
57  }
58  // delete edgeType
59  delete myEdgeType;
60  }
61 }
62 
63 
64 void
66  if (myForward) {
67  // show extra information for tests
68  WRITE_DEBUG("Removing " + myEdgeType->getTagStr() + " '" + myEdgeType->getID() + "' from " + toString(SUMO_TAG_NET));
69  // delete edgeType from net
71  } else {
72  // show extra information for tests
73  WRITE_DEBUG("Adding " + myEdgeType->getTagStr() + " '" + myEdgeType->getID() + "' into " + toString(SUMO_TAG_NET));
74  // insert edgeType into net
76  }
77  // refresh create edge frame
78  if (myEdgeType->getNet()->getViewNet()->getViewParent()->getCreateEdgeFrame()->shown()) {
80  }
81  // enable save networkElements
83 }
84 
85 
86 void
88  if (myForward) {
89  // show extra information for tests
90  WRITE_DEBUG("Adding " + myEdgeType->getTagStr() + " '" + myEdgeType->getID() + "' into " + toString(SUMO_TAG_NET));
91  // insert edgeType into net
93  } else {
94  // show extra information for tests
95  WRITE_DEBUG("Removing " + myEdgeType->getTagStr() + " '" + myEdgeType->getID() + "' from " + toString(SUMO_TAG_NET));
96  // delete edgeType from net
98  }
99  // refresh create edge frame
100  if (myEdgeType->getNet()->getViewNet()->getViewParent()->getCreateEdgeFrame()->shown()) {
102  }
103  // enable save networkElements
105 }
106 
107 
108 std::string
110  if (myForward) {
111  return TL("Undo create edgeType '") + myEdgeType->getID() + "'";
112  } else {
113  return TL("Undo delete edgeType '") + myEdgeType->getID() + "'";
114  }
115 }
116 
117 
118 std::string
120  if (myForward) {
121  return TL("Redo create edgeType '") + myEdgeType->getID() + "'";
122  } else {
123  return TL("Redo delete edgeType '") + myEdgeType->getID() + "'";
124  }
125 }
Supermode
@brie enum for supermodes
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:306
#define TL(string)
Definition: MsgHandler.h:315
@ SUMO_TAG_NET
root element of a network file
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
const std::string getID() const
get ID (all Attribute Carriers have one)
const std::string & getTagStr() const
get tag assigned to this object in string format
GNENet * getNet() const
get pointer to net
GNEEdgeType * myEdgeType
full information regarding the edgeType that is to be created/deleted
std::string undoName() const
return undoName
void redo()
redo action
void undo()
undo action
~GNEChange_EdgeType()
Destructor.
std::string redoName() const
get Redo name
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:56
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag
Definition: GNEChange.h:212
void refreshEdgeTypeSelector()
refresh edge type selector
EdgeTypeSelector * getEdgeTypeSelector() const
get edgeType selector
void deleteEdgeType(GNEEdgeType *edgeType)
delete edge type from container
GNEEdgeType * retrieveEdgeType(const std::string &id, bool hardFail=true) const
get edge type by id
void insertEdgeType(GNEEdgeType *edgeType)
insert edge type in container
void requireSaveNetwork()
inform that network has to be saved
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition: GNENet.cpp:127
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:121
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2056
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced
GNEViewParent * getViewParent() const
get the net object
GNECreateEdgeFrame * getCreateEdgeFrame() const
get frame for NETWORK_CREATEEDGE