Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/moving/GNEMoveElementLaneSingle.h
185790 views
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
/****************************************************************************/
14
/// @file GNEMoveElementLaneSingle.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Sep 2025
17
///
18
// Class used for elements that can be moved over a lane with only one position
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <utils/iodevices/OutputDevice.h>
24
25
#include "GNEMoveElement.h"
26
27
// ===========================================================================
28
// class definitions
29
// ===========================================================================
30
31
class GNEMoveElementLaneSingle : public GNEMoveElement {
32
33
public:
34
/// @brief move element lane double need access to set and commit shape
35
friend class GNEMoveElementLaneDouble;
36
37
// declare type of moving
38
struct PositionType {
39
static const std::string SINGLE; // Element has only one position
40
static const std::string STARPOS; // Element's start position
41
static const std::string ENDPOS; // Element's end position
42
};
43
44
/// @brief constructor
45
GNEMoveElementLaneSingle(GNEAttributeCarrier* element, SumoXMLAttr posAttr,
46
double& position, bool& friendlyPos,
47
const std::string& defaultBehavior);
48
49
//// @brief destructor
50
~GNEMoveElementLaneSingle();
51
52
/**@brief get move operation
53
* @note returned GNEMoveOperation can be nullptr
54
*/
55
GNEMoveOperation* getMoveOperation() override;
56
57
/// @name functions related with moving attributes
58
/// @{
59
60
/// @brief get moving attribute
61
std::string getMovingAttribute(SumoXMLAttr key) const override;
62
63
/// @brief get moving attribute double
64
double getMovingAttributeDouble(SumoXMLAttr key) const override;
65
66
/// @brief get moving attribute position
67
Position getMovingAttributePosition(SumoXMLAttr key) const override;
68
69
/// @brief get moving attribute positionVector
70
PositionVector getMovingAttributePositionVector(SumoXMLAttr key) const override;
71
72
/// @brief set moving attribute (using undo-list)
73
void setMovingAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
74
75
/// @brief check if the given moving attribute is valid
76
bool isMovingAttributeValid(SumoXMLAttr key, const std::string& value) const override;
77
78
/// @brief set moving attribute
79
void setMovingAttribute(SumoXMLAttr key, const std::string& value) override;
80
81
/// @}
82
83
/// @brief remove geometry point in the clicked position
84
void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) override;
85
86
/// @brief check if current moving element is valid to be written into XML
87
bool isMoveElementValid() const;
88
89
/// @brief return a string with the current moving problem
90
std::string getMovingProblem() const;
91
92
/// @brief fix moving problem
93
void fixMovingProblem();
94
95
/// @brief write move attributes
96
void writeMoveAttributes(OutputDevice& device) const;
97
98
/// @brief get fixed offset position over lane
99
double getFixedPositionOverLane(const bool adjustGeometryFactor) const;
100
101
private:
102
/// @brief pos attribute
103
SumoXMLAttr myPosAttr;
104
105
/// @brief position over lane
106
double& myPosOverLane;
107
108
/// @brief friendly position
109
bool& myFriendlyPos;
110
111
/// @brief default behavior
112
const std::string myPositionType;
113
114
/// @brief set move shape
115
void setMoveShape(const GNEMoveResult& moveResult) override;
116
117
/// @brief commit move shape
118
void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) override;
119
120
/// @brief Invalidated copy constructor.
121
GNEMoveElementLaneSingle(const GNEMoveElementLaneSingle&) = delete;
122
123
/// @brief Invalidated assignment operator.
124
GNEMoveElementLaneSingle& operator=(const GNEMoveElementLaneSingle&) = delete;
125
};
126
127