Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEMoveElementPlanParent.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// Class used for elements that can be moved over a edge with two positions
19/****************************************************************************/
20
29#include <netedit/GNENet.h>
31#include <netedit/GNEUndoList.h>
32#include <netedit/GNEViewNet.h>
40
42
43// ===========================================================================
44// member method definitions
45// ===========================================================================
46
48 double& departPos, DepartPosDefinition& departPosProcedure) :
49 GNEMoveElement(planParent),
50 myPlanParent(planParent),
51 myDepartPos(departPos),
52 myDepartPosProcedure(departPosProcedure) {
53}
54
55
57
58
61 const auto firstContainerPlan = myPlanParent->getChildDemandElements().front();
62 // check first person plan
63 if (firstContainerPlan->getTagProperty()->isPlanStopPerson()) {
64 return nullptr;
65 } else if (firstContainerPlan->getParentEdges().size() > 0) {
66 // get lane
67 const GNELane* lane = firstContainerPlan->getParentEdges().front()->getLaneByAllowedVClass(myPlanParent->getVClass());
68 // declare departPos
69 double posOverLane = 0;
70 if (GNEAttributeCarrier::canParse<double>(myPlanParent->getAttribute(SUMO_ATTR_DEPARTPOS))) {
71 posOverLane = GNEAttributeCarrier::parse<double>(myPlanParent->getAttribute(SUMO_ATTR_DEPARTPOS));
72 }
73 // return move operation
74 return new GNEMoveOperation(this, lane, posOverLane, false);
75 } else {
76 return nullptr;
77 }
78}
79
80
81std::string
85
86
87double
91
92
97
98
103
104
105void
107 myMovedElement->setCommonAttribute(key, value, undoList);
108}
109
110
111bool
113 return myMovedElement->isCommonAttributeValid(key, value);
114}
115
116
117void
121
122
123void
124GNEMoveElementPlanParent::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
125 // nothing to do here
126}
127
128
129void
131 // change departPos
133 myDepartPos = moveResult.newFirstPos;
134 // update geometry
136}
137
138
139void
141 undoList->begin(myPlanParent, TLF("departPos of %", myPlanParent->getTagStr()));
142 // now set departPos
144 undoList->end();
145}
146
147/****************************************************************************/
#define TLF(string,...)
Definition MsgHandler.h:306
DepartPosDefinition
Possible ways to choose the departure position.
@ GIVEN
The position is given.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_DEPARTPOS
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
double getCommonAttributeDouble(SumoXMLAttr key) const
PositionVector getCommonAttributePositionVector(SumoXMLAttr key) const
void setCommonAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
const std::string & getTagStr() const
get tag assigned to this object in string format
Position getCommonAttributePosition(SumoXMLAttr key) const
bool isCommonAttributeValid(SumoXMLAttr key, const std::string &value) const
virtual void updateGeometry()=0
update pre-computed geometry information
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
virtual std::string getAttribute(SumoXMLAttr key) const =0
std::string getCommonAttribute(SumoXMLAttr key) const
virtual SUMOVehicleClass getVClass() const =0
obtain VClass related with this demand element
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
GNEAttributeCarrier * myMovedElement
pointer to element
Position getMovingAttributePosition(SumoXMLAttr key) const override
get moving attribute position
GNEMoveElementPlanParent(GNEDemandElement *planParent, double &departPos, DepartPosDefinition &departPosProcedure)
Constructor.
GNEMoveOperation * getMoveOperation()
get edge movable move operation for elements with
double getMovingAttributeDouble(SumoXMLAttr key) const override
get moving attribute double
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
PositionVector getMovingAttributePositionVector(SumoXMLAttr key) const override
get moving attribute positionVector
void setMovingAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
set moving attribute (using undo-list)
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
GNEDemandElement * myPlanParent
planParent
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
std::string getMovingAttribute(SumoXMLAttr key) const override
get moving attribute
DepartPosDefinition & myDepartPosProcedure
arrivalPos
bool isMovingAttributeValid(SumoXMLAttr key, const std::string &value) const override
check if the given moving attribute is valid
double newFirstPos
new first position
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.