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#include <config.h>
21
30#include <netedit/GNENet.h>
32#include <netedit/GNEUndoList.h>
33#include <netedit/GNEViewNet.h>
41
43
44// ===========================================================================
45// member method definitions
46// ===========================================================================
47
49 double& departPos, DepartPosDefinition& departPosProcedure) :
50 GNEMoveElement(planParent),
51 myPlanParent(planParent),
52 myDepartPos(departPos),
53 myDepartPosProcedure(departPosProcedure) {
54}
55
56
58
59
62 const auto firstContainerPlan = myPlanParent->getChildDemandElements().front();
63 // check first person plan
64 if (firstContainerPlan->getTagProperty()->isPlanStopPerson()) {
65 return nullptr;
66 } else if (firstContainerPlan->getParentEdges().size() > 0) {
67 // get lane
68 const GNELane* lane = firstContainerPlan->getParentEdges().front()->getLaneByAllowedVClass(myPlanParent->getVClass());
69 // declare departPos
70 double posOverLane = 0;
71 if (GNEAttributeCarrier::canParse<double>(myPlanParent->getAttribute(SUMO_ATTR_DEPARTPOS))) {
72 posOverLane = GNEAttributeCarrier::parse<double>(myPlanParent->getAttribute(SUMO_ATTR_DEPARTPOS));
73 }
74 // return move operation
75 return new GNEMoveOperation(this, lane, posOverLane, false);
76 } else {
77 return nullptr;
78 }
79}
80
81
82std::string
86
87
88double
92
93
98
99
104
105
106void
108 myMovedElement->setCommonAttribute(key, value, undoList);
109}
110
111
112bool
114 return myMovedElement->isCommonAttributeValid(key, value);
115}
116
117
118void
122
123
124void
125GNEMoveElementPlanParent::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
126 // nothing to do here
127}
128
129
130void
132 // change departPos
134 myDepartPos = moveResult.newFirstPos;
135 // update geometry
137}
138
139
140void
142 undoList->begin(myPlanParent, TLF("departPos of %", myPlanParent->getTagStr()));
143 // now set departPos
145 undoList->end();
146}
147
148/****************************************************************************/
#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.
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
GNEMoveOperation * getMoveOperation() override
get edge movable move operation for elements with
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.