Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEChange_DemandElement.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 busStop is created or deleted
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
27
29
30// ===========================================================================
31// FOX-declarations
32// ===========================================================================
33FXIMPLEMENT_ABSTRACT(GNEChange_DemandElement, GNEChange, nullptr, 0)
34
35// ===========================================================================
36// member method definitions
37// ===========================================================================
38
40 GNEChange(Supermode::DEMAND, demandElement, forward, demandElement->isAttributeCarrierSelected()),
41 myDemandElement(demandElement) {
42 myDemandElement->incRef("GNEChange_DemandElement");
43}
44
45
47 // only continue we have undo-redo mode enabled
49 myDemandElement->decRef("GNEChange_DemandElement");
51 // show extra information for tests
52 WRITE_DEBUG("Deleting unreferenced " + myDemandElement->getTagStr());
53 // make sure that element isn't in net before removing
55 // remove demand element of network
57 }
58 delete myDemandElement;
59 }
60 }
61}
62
63
64void
66 if (myForward) {
67 // show extra information for tests
68 WRITE_DEBUG("Removing " + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "' in GNEChange_DemandElement");
69 // unselect if mySelectedElement is enabled
72 }
73 // delete demand element from net
75 // restore container
77 } else {
78 // show extra information for tests
79 WRITE_DEBUG("Adding " + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "' in GNEChange_DemandElement");
80 // select if mySelectedElement is enabled
83 }
84 // insert demand element into net
86 // restore container
88 }
89 // update vehicle type selector if demand element is a VType and vehicle type Frame is shown
92 }
93 // update stack labels
94 const auto parentEdges = myOriginalHierarchicalContainer.getParents<std::vector<GNEEdge*> >();
95 if (parentEdges.size() > 0) {
96 parentEdges.front()->updateVehicleStackLabels();
97 parentEdges.front()->updatePersonStackLabels();
98 parentEdges.front()->updateContainerStackLabels();
99 }
100 // require always save elements
102}
103
104
105void
107 if (myForward) {
108 // show extra information for tests
109 WRITE_DEBUG("Adding " + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "' in GNEChange_DemandElement");
110 // select if mySelectedElement is enabled
111 if (mySelectedElement) {
113 }
114 // insert demand element into net
116 // add demand element in parents and children
118 } else {
119 // show extra information for tests
120 WRITE_DEBUG("Removing " + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "' in GNEChange_DemandElement");
121 // unselect if mySelectedElement is enabled
122 if (mySelectedElement) {
124 }
125 // delete demand element from net
127 // remove demand element from parents and children
129 }
130 // update vehicle type selector if demand element is a VType and vehicle type Frame is shown
133 }
134 // update stack labels
135 const auto parentEdges = myOriginalHierarchicalContainer.getParents<std::vector<GNEEdge*> >();
136 if (parentEdges.size() > 0) {
137 parentEdges.front()->updateVehicleStackLabels();
138 parentEdges.front()->updatePersonStackLabels();
139 parentEdges.front()->updateContainerStackLabels();
140 }
141 // require always save elements
143}
144
145
146std::string
148 if (myForward) {
149 return (TL("Undo create ") + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "'");
150 } else {
151 return (TL("Undo delete ") + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "'");
152 }
153}
154
155
156std::string
158 if (myForward) {
159 return (TL("Redo create ") + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "'");
160 } else {
161 return (TL("Redo delete ") + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "'");
162 }
163}
Supermode
@brie enum for supermodes
@ DEMAND
Demand mode (Routes, Vehicles etc..)
#define WRITE_DEBUG(msg)
Definition MsgHandler.h:306
#define TL(string)
Definition MsgHandler.h:315
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
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
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
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 redoName() const
get Redo name
std::string undoName() const
return undoName
GNEDemandElement * myDemandElement
full information regarding the demand element element that is to be created/deleted
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 addElementInParentsAndChildren(T *element)
add given element into parents and children (only use in redo() function)
Definition GNEChange.h:124
void removeElementFromParentsAndChildren(T *element)
remove given element from parents and children (only use in redo() function)
Definition GNEChange.h:167
void restoreHierarchicalContainers()
restore container (only use in undo() function)
Definition GNEChange.cpp:94
const GNEHierarchicalContainer myOriginalHierarchicalContainer
Hierarchical container with parent and children.
Definition GNEChange.h:218
const T & getParents() const
get parents
void deleteDemandElement(GNEDemandElement *demandElement, const bool updateFrames)
delete demand element of container
void insertDemandElement(GNEDemandElement *demandElement)
Insert a demand element in container.
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
void requireSaveDemandElements()
inform that demand elements has to be saved
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition GNENet.cpp:131
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:125
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2147
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
void refreshTypeSelector(const bool updateModuls)
refresh vehicle type selector
TypeSelector * getTypeSelector() const
get vehicle type selector
GNEViewParent * getViewParent() const
get the net object
GNETypeFrame * getTypeFrame() const
get frame for DEMAND_TYPE
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows