Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEChange_Junction.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 junction is created or deleted
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
26
27#include "GNEChange_Junction.h"
28
29// ===========================================================================
30// FOX-declarations
31// ===========================================================================
32FXIMPLEMENT_ABSTRACT(GNEChange_Junction, GNEChange, nullptr, 0)
33
34// ===========================================================================
35// member method definitions
36// ===========================================================================
37
38
39
41 GNEChange(Supermode::NETWORK, junction, forward, junction->isAttributeCarrierSelected()),
42 myJunction(junction) {
43 junction->incRef("GNEChange_Junction");
44}
45
46
48 // only continue we have undo-redo mode enabled
50 myJunction->decRef("GNEChange_Junction");
51 if (myJunction->unreferenced()) {
52 // show extra information for tests
53 WRITE_DEBUG("Deleting unreferenced " + myJunction->getTagStr() + " '" + myJunction->getID() + "' in GNEChange_Junction");
54 delete myJunction;
55 }
56 }
57}
58
59
60void
62 if (myForward) {
63 // show extra information for tests
64 WRITE_DEBUG("Removing " + myJunction->getTagStr() + " '" + myJunction->getID() + "' from " + toString(SUMO_TAG_NET));
65 // unselect if mySelectedElement is enabled
68 }
69 // add junction to net
71 } else {
72 // show extra information for tests
73 WRITE_DEBUG("Adding " + myJunction->getTagStr() + " '" + myJunction->getID() + "' into " + toString(SUMO_TAG_NET));
74 // select if mySelectedElement is enabled
77 }
78 // delete junction from net
80 }
81 // enable save networkElements
83}
84
85
86void
88 if (myForward) {
89 // show extra information for tests
90 WRITE_DEBUG("Adding " + myJunction->getTagStr() + " '" + myJunction->getID() + "' into " + toString(SUMO_TAG_NET));
91 // select if mySelectedElement is enabled
94 }
95 // add junction into net
97 } else {
98 // show extra information for tests
99 WRITE_DEBUG("Removing " + myJunction->getTagStr() + " '" + myJunction->getID() + "' from " + toString(SUMO_TAG_NET));
100 // unselect if mySelectedElement is enabled
101 if (mySelectedElement) {
103 }
104 // delete junction from net
106 }
107 // enable save networkElements
109}
110
111
112std::string
114 if (myForward) {
115 return (TL("Undo create junction '") + myJunction->getID() + "'");
116 } else {
117 return (TL("Undo delete junction '") + myJunction->getID() + "'");
118 }
119}
120
121
122std::string
124 if (myForward) {
125 return (TL("Redo create junction '") + myJunction->getID() + "'");
126 } else {
127 return (TL("Redo delete junction '") + myJunction->getID() + "'");
128 }
129}
Supermode
@brie enum for supermodes
@ NETWORK
Network mode (Edges, junctions, etc..)
#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
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
std::string undoName() const
return undoName
void redo()
redo action
~GNEChange_Junction()
Destructor.
GNEJunction * myJunction
full information regarding the junction that is to be created/deleted
std::string redoName() const
get Redo name
void undo()
undo action
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
const bool mySelectedElement
flag for check if element is selected
Definition GNEChange.h:215
void deleteSingleJunction(GNEJunction *junction)
delete junction from container
void insertJunction(GNEJunction *junction)
insert junction in container
void requireSaveNetwork()
inform that network has to be saved
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition GNENet.cpp:133
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:127
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2155
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced
GNEViewParent * getViewParent() const
get the net object
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows