Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/additional/GNEOverheadWire.h
169684 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 GNEOverheadWire.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Nov 2015
17
///
18
//
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include "GNEAdditional.h"
24
25
// ===========================================================================
26
// class definitions
27
// ===========================================================================
28
29
class GNEOverheadWire : public GNEAdditional, public Parameterised {
30
31
public:
32
/// @brief default Constructor
33
GNEOverheadWire(GNENet* net);
34
35
/**@brief Constructor for Multi-Lane detectors
36
* @param[in] id The name of the overhead wire
37
* @param[in] net net in which this polygon is placed
38
* @param[in] filename file in which this element is stored
39
* @param[in] lanes vector of lanes Lane of this OverheadWire belongs
40
* @param[in] lane Lane over which the segment is placed
41
* @param[in] substationId Substation to which the circuit is connected
42
* @param[in] laneIDs list of consecutive lanes of the circuit
43
* @param[in] startPos Starting position in the specified lane
44
* @param[in] endPos Ending position in the specified lane
45
* @param[in] friendlyPos enable or disable friendly position
46
* @param[in] forbiddenInnerLanes Inner lanes, where placing of overhead wire is restricted
47
* @param[in] parameters generic parameters
48
*/
49
GNEOverheadWire(const std::string& id, GNENet* net, const std::string& filename, std::vector<GNELane*> lanes, GNEAdditional* substation,
50
const double startPos, const double endPos, const bool friendlyPos,
51
const std::vector<std::string>& forbiddenInnerLanes, const Parameterised::Map& parameters);
52
53
/// @brief Destructor
54
~GNEOverheadWire();
55
56
/**@brief get move operation
57
* @note returned GNEMoveOperation can be nullptr
58
*/
59
GNEMoveOperation* getMoveOperation();
60
61
/// @name members and functions relative to write additionals into XML
62
/// @{
63
64
/**@brief write additional element into a xml file
65
* @param[in] device device in which write parameters of additional element
66
*/
67
void writeAdditional(OutputDevice& device) const;
68
69
/// @brief check if current additional is valid to be written into XML
70
bool isAdditionalValid() const;
71
72
/// @brief return a string with the current additional problem
73
std::string getAdditionalProblem() const;
74
75
/// @brief fix additional problem
76
void fixAdditionalProblem();
77
78
/// @}
79
80
/// @name Function related with contour drawing
81
/// @{
82
83
/// @brief check if draw move contour (red)
84
bool checkDrawMoveContour() const;
85
86
/// @}
87
88
/// @brief update pre-computed geometry information
89
void updateGeometry();
90
91
/// @brief Returns position of additional in view
92
Position getPositionInView() const;
93
94
/// @brief update centering boundary (implies change in RTREE)
95
void updateCenteringBoundary(const bool updateGrid);
96
97
/// @brief split geometry
98
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
99
100
/// @name inherited from GUIGlObject
101
/// @{
102
103
/**@brief Draws the object
104
* @param[in] s The settings for the current view (may influence drawing)
105
* @see GUIGlObject::drawGL
106
*/
107
void drawGL(const GUIVisualizationSettings& s) const;
108
109
/// @}
110
111
/// @name inherited from GNEPathElement
112
/// @{
113
114
/// @brief compute pathElement
115
void computePathElement();
116
117
/**@brief Draws partial object over lane
118
* @param[in] s The settings for the current view (may influence drawing)
119
* @param[in] segment lane segment
120
* @param[in] offsetFront front offset
121
*/
122
void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const;
123
124
/**@brief Draws partial object over junction
125
* @param[in] s The settings for the current view (may influence drawing)
126
* @param[in] segment junction segment
127
* @param[in] offsetFront front offset
128
*/
129
void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const;
130
131
/// @}
132
133
/// @name inherited from GNEAttributeCarrier
134
/// @{
135
136
/* @brief method for getting the Attribute of an XML key
137
* @param[in] key The attribute key
138
* @return string with the value associated to key
139
*/
140
std::string getAttribute(SumoXMLAttr key) const;
141
142
/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
143
* @param[in] key The attribute key
144
* @return double with the value associated to key
145
*/
146
double getAttributeDouble(SumoXMLAttr key) const;
147
148
/// @brief get parameters map
149
const Parameterised::Map& getACParametersMap() const;
150
151
/* @brief method for setting the attribute and letting the object perform additional changes
152
* @param[in] key The attribute key
153
* @param[in] value The new value
154
* @param[in] undoList The undoList on which to register changes
155
*/
156
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
157
158
/* @brief method for checking if the key and their correspond attribute are valids
159
* @param[in] key The attribute key
160
* @param[in] value The value associated to key key
161
* @return true if the value is valid, false in other case
162
*/
163
bool isValid(SumoXMLAttr key, const std::string& value);
164
165
/// @brief get PopPup ID (Used in AC Hierarchy)
166
std::string getPopUpID() const;
167
168
/// @brief get Hierarchy Name (Used in AC Hierarchy)
169
std::string getHierarchyName() const;
170
171
/// @}
172
173
protected:
174
/// @brief start position over lane
175
double myStartPos = 0;
176
177
/// @brief end position over lane
178
double myEndPos = 0;
179
180
/// @brief friendly position
181
bool myFriendlyPosition = false;
182
183
/// @brief forbidden inner lanes
184
std::vector<std::string> myForbiddenInnerLanes;
185
186
private:
187
/// @brief set attribute after validation
188
void setAttribute(SumoXMLAttr key, const std::string& value);
189
190
/// @brief set move shape
191
void setMoveShape(const GNEMoveResult& moveResult);
192
193
/// @brief commit move shape
194
void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
195
196
/// @brief get start position over lane that is applicable to the shape
197
double getStartGeometryPositionOverLane() const;
198
199
/// @brief get end position over lane that is applicable to the shape
200
double getEndGeometryPositionOverLane() const;
201
202
/// @brief Invalidated copy constructor.
203
GNEOverheadWire(const GNEOverheadWire&) = delete;
204
205
/// @brief Invalidated assignment operator.
206
GNEOverheadWire& operator=(const GNEOverheadWire&) = delete;
207
};
208
209