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
24#include <netedit/GNENet.h>
25#include <netedit/GNEUndoList.h>
26
27#include "GNEMoveElementPlan.h"
28
29// ===========================================================================
30// member method definitions
31// ===========================================================================
32
34 GNEMoveElement(planElement),
35 myPlanElement(planElement),
36 myArrivalPosition(departPos) {
37}
38
39
41
42
45 // get tag property
46 const auto tagProperty = myPlanElement->getTagProperty();
47 // only move personTrips defined over edges
48 if (tagProperty->planToEdge() || tagProperty->planConsecutiveEdges() || tagProperty->planEdge()) {
49 // get geometry end pos
51 // calculate circle width squared
53 // check if we clicked over a geometry end pos
54 if (myPlanElement->getNet()->getViewNet()->getPositionInformation().distanceSquaredTo2D(geometryEndPos) <= ((circleWidthSquared + 2))) {
55 // continue depending of parent edges
56 if (myPlanElement->getParentEdges().size() > 0) {
57 return new GNEMoveOperation(this, myPlanElement->getParentEdges().back()->getLaneByAllowedVClass(myPlanElement->getVClass()), myArrivalPosition, false);
58 } else {
59 return new GNEMoveOperation(this, myPlanElement->getParentDemandElements().at(1)->getParentEdges().back()->getLaneByAllowedVClass(myPlanElement->getVClass()), myArrivalPosition, false);
60 }
61 }
62 }
63 return nullptr;
64}
65
66
67std::string
71
72
73double
77
78
83
84
89
90
91void
92GNEMoveElementPlan::setMovingAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
93 myMovedElement->setCommonAttribute(key, value, undoList);
94}
95
96
97bool
98GNEMoveElementPlan::isMovingAttributeValid(SumoXMLAttr key, const std::string& value) const {
99 return myMovedElement->isCommonAttributeValid(key, value);
100}
101
102
103void
106}
107
108
109void
110GNEMoveElementPlan::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
111 // nothing to do here
112}
113
114
115void
117 // change both position
118 myArrivalPosition = moveResult.newLastPos;
119 // update geometry
121}
122
123
124void
126 undoList->begin(myPlanElement, TLF("arrivalPos of %", myPlanElement->getTagStr()));
127 // now adjust start position
129 undoList->end();
130}
131
132/****************************************************************************/
#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
GNEMoveOperation * getMoveOperation()
get edge movable move operation for elements with
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
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.