Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEMoveElementPlan.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
25#include <netedit/GNENet.h>
26#include <netedit/GNEUndoList.h>
27
28#include "GNEMoveElementPlan.h"
29
30// ===========================================================================
31// member method definitions
32// ===========================================================================
33
35 GNEMoveElement(planElement),
36 myPlanElement(planElement),
37 myArrivalPosition(departPos) {
38}
39
40
42
43
46 // get tag property
47 const auto tagProperty = myPlanElement->getTagProperty();
48 // only move personTrips defined over edges
49 if (tagProperty->planToEdge() || tagProperty->planConsecutiveEdges() || tagProperty->planEdge()) {
50 // get geometry end pos
52 // calculate circle width squared
54 // check if we clicked over a geometry end pos
55 if (myPlanElement->getNet()->getViewNet()->getPositionInformation().distanceSquaredTo2D(geometryEndPos) <= ((circleWidthSquared + 2))) {
56 // continue depending of parent edges
57 if (myPlanElement->getParentEdges().size() > 0) {
58 return new GNEMoveOperation(this, myPlanElement->getParentEdges().back()->getLaneByAllowedVClass(myPlanElement->getVClass()), myArrivalPosition, false);
59 } else {
60 return new GNEMoveOperation(this, myPlanElement->getParentDemandElements().at(1)->getParentEdges().back()->getLaneByAllowedVClass(myPlanElement->getVClass()), myArrivalPosition, false);
61 }
62 }
63 }
64 return nullptr;
65}
66
67
68std::string
72
73
74double
78
79
84
85
90
91
92void
93GNEMoveElementPlan::setMovingAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
94 myMovedElement->setCommonAttribute(key, value, undoList);
95}
96
97
98bool
99GNEMoveElementPlan::isMovingAttributeValid(SumoXMLAttr key, const std::string& value) const {
100 return myMovedElement->isCommonAttributeValid(key, value);
101}
102
103
104void
107}
108
109
110void
111GNEMoveElementPlan::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
112 // nothing to do here
113}
114
115
116void
118 // change both position
119 myArrivalPosition = moveResult.newLastPos;
120 // update geometry
122}
123
124
125void
127 undoList->begin(myPlanElement, TLF("arrivalPos of %", myPlanElement->getTagStr()));
128 // now adjust start position
130 undoList->end();
131}
132
133/****************************************************************************/
#define TLF(string,...)
Definition MsgHandler.h:306
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_ARRIVALPOS
@ GNE_ATTR_PLAN_GEOMETRY_ENDPOS
person/container geometry end position
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
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * getNet() const
get pointer to net
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
std::string getCommonAttribute(SumoXMLAttr key) const
Position getAttributePosition(SumoXMLAttr key) const override
virtual SUMOVehicleClass getVClass() const =0
obtain VClass related with this demand element
const GNEHierarchicalContainerParents< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
GNEAttributeCarrier * myMovedElement
pointer to element
bool isMovingAttributeValid(SumoXMLAttr key, const std::string &value) const override
check if the given moving attribute is valid
Position getMovingAttributePosition(SumoXMLAttr key) const override
get moving attribute position
PositionVector getMovingAttributePositionVector(SumoXMLAttr key) const override
get moving attribute positionVector
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
double getMovingAttributeDouble(SumoXMLAttr key) const override
get moving attribute double
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
void setMovingAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
set moving attribute (using undo-list)
GNEDemandElement * myPlanElement
planElement
~GNEMoveElementPlan()
Destructor.
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
double & myArrivalPosition
departPos
std::string getMovingAttribute(SumoXMLAttr key) const override
get moving attribute
GNEMoveElementPlan(GNEDemandElement *planElement, double &departPos)
Constructor.
static const double arrivalPositionDiameter
vehicle arrival position radius
double newFirstPos
new first position
double newLastPos
new last position
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2193
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...
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition Position.h:278
A list of positions.