Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-2025 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 // delete demand element from net
71 // remove element from parent and children
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
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 // require always save elements
96}
97
98
99void
101 if (myForward) {
102 // select if mySelectedElement is enabled
103 if (mySelectedElement) {
105 }
106 // add element in parent and children
108 // insert demand element into net
110 } else {
111 // unselect if mySelectedElement is enabled
112 if (mySelectedElement) {
114 }
115 // delete demand element from net
117 // remove element from parent and children
119 }
120 // update vehicle type selector if demand element is a VType and vehicle type Frame is shown
123 }
124 // update stack labels
125 const auto parentEdges = myParents.get<GNEEdge*>();
126 if (parentEdges.size() > 0) {
127 parentEdges.front()->updateVehicleStackLabels();
128 parentEdges.front()->updatePersonStackLabels();
129 parentEdges.front()->updateContainerStackLabels();
130 }
131 // require always save elements
133}
134
135
136std::string
138 if (myForward) {
139 return (TL("Undo create ") + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "'");
140 } else {
141 return (TL("Undo delete ") + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "'");
142 }
143}
144
145
146std::string
148 if (myForward) {
149 return (TL("Redo create ") + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "'");
150 } else {
151 return (TL("Redo delete ") + myDemandElement->getTagStr() + " '" + myDemandElement->getID() + "'");
152 }
153}
Supermode
@brie enum for supermodes
@ DEMAND
Demand mode (Routes, Vehicles etc..)
#define TL(string)
Definition MsgHandler.h:305
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
const std::string getID() const
get ID (all Attribute Carriers have one)
void selectAttributeCarrier()
select attribute carrier using GUIGlobalSelection
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
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
void updateVehicleStackLabels()
Definition GNEEdge.cpp:1633
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:164
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:146
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2194
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