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-2026 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
21#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 // make sure that element isn't in net before removing
53 // remove demand element of network
55 }
56 delete myDemandElement;
57 }
58 }
59}
60
61
62void
64 if (myForward) {
65 // unselect if mySelectedElement is enabled
68 }
69 // remove element from parent and children
71 // delete demand element from net
73 } else {
74 // select if mySelectedElement is enabled
77 }
78 // add element in parent and children
80 // insert demand element into net
82 }
83 // update vehicle type selector if demand element is a VType and vehicle type Frame is shown
86 }
87 // update stack labels for parent edges
88 const auto parentEdges = myParents.get<GNEEdge*>();
89 if (parentEdges.size() > 0) {
90 parentEdges.front()->updateVehicleStackLabels();
91 parentEdges.front()->updatePersonStackLabels();
92 parentEdges.front()->updateContainerStackLabels();
93 }
94 // update stack labels also for route elements
96 const auto firstRouteEdge = myParents.get<GNEDemandElement*>().at(1)->getParentEdges().front();
97 firstRouteEdge->updateVehicleStackLabels();
98 firstRouteEdge->updatePersonStackLabels();
99 firstRouteEdge->updateContainerStackLabels();
100 }
101 // require always save elements
103}
104
105
106void
108 if (myForward) {
109 // select if mySelectedElement is enabled
110 if (mySelectedElement) {
112 }
113 // add element in parent and children
115 // insert demand element into net
117 } else {
118 // unselect if mySelectedElement is enabled
119 if (mySelectedElement) {
121 }
122 // remove element from parent and children
124 // delete demand element from net
126 }
127 // update vehicle type selector if demand element is a VType and vehicle type Frame is shown
130 }
131 // update stack labels for parent edges
132 const auto parentEdges = myParents.get<GNEEdge*>();
133 if (parentEdges.size() > 0) {
134 parentEdges.front()->updateVehicleStackLabels();
135 parentEdges.front()->updatePersonStackLabels();
136 parentEdges.front()->updateContainerStackLabels();
137 }
138 // update stack labels also for route elements
140 const auto firstRouteEdge = myParents.get<GNEDemandElement*>().at(1)->getParentEdges().front();
141 firstRouteEdge->updateVehicleStackLabels();
142 firstRouteEdge->updatePersonStackLabels();
143 firstRouteEdge->updateContainerStackLabels();
144 }
145 // require always save elements
147}
148
149
150std::string
152 if (myForward) {
153 return (TL("Undo create ") + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "'");
154 } else {
155 return (TL("Undo delete ") + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "'");
156 }
157}
158
159
160std::string
162 if (myForward) {
163 return (TL("Redo create ") + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "'");
164 } else {
165 return (TL("Redo delete ") + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "'");
166 }
167}
Supermode
@brie enum for supermodes
@ DEMAND
Demand mode (Routes, Vehicles etc..)
#define TL(string)
Definition MsgHandler.h:304
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
const std::string getID() const override
get ID (all Attribute Carriers have one)
void unselectAttributeCarrier()
unselect attribute carrier using GUIGlobalSelection
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
GNENet * getNet() const
get pointer to net
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:180
const bool mySelectedElement
flag for check if element is selected
Definition GNEChange.h:183
void addElementInParentsAndChildren(T *element)
add given element in parents and children
Definition GNEChange.h:121
void removeElementFromParentsAndChildren(T *element)
remove given element from parents and children
Definition GNEChange.h:148
const GNEHierarchicalStructureParents myParents
Hierarchical container with parents.
Definition GNEChange.h:177
void updateVehicleStackLabels()
Definition GNEEdge.cpp:1590
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
const GNEHierarchicalContainerParents< ParentType > & get() 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:186
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:174
GNEApplicationWindow * getGNEApplicationWindow() const
get tag properties database
Definition GNENet.cpp:138
GNEViewParent * getViewParent() const
get view parent (used for simplify code)
Definition GNENet.cpp:150
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
bool vehicleRoute() const
plan parents
void refreshTypeSelector(const bool updateModuls)
refresh vehicle type selector
TypeSelector * getTypeSelector() const
get vehicle type selector
GNETypeFrame * getTypeFrame() const
get frame for DEMAND_TYPE