Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/additional/GNEPOI.h
193964 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2026 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 GNEPOI.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Jun 2017
17
///
18
// A class for visualizing and editing POIS in netedit (adapted from
19
// GUIPointOfInterest and NLHandler)
20
/****************************************************************************/
21
#pragma once
22
#include <config.h>
23
24
#include <utils/shapes/Shape.h>
25
#include <utils/xml/CommonXMLStructure.h>
26
27
#include "GNEAdditional.h"
28
29
// ===========================================================================
30
// class declaration
31
// ===========================================================================
32
33
class GNEMoveElementLaneSingle;
34
class GNEMoveElementViewResizable;
35
36
// ===========================================================================
37
// class definitions
38
// ===========================================================================
39
40
class GNEPOI : public Shape, public GNEAdditional, public Parameterised {
41
42
public:
43
// avoid diamond problem
44
using GNEAttributeCarrier::getID;
45
46
/// @brief Constructor
47
GNEPOI(SumoXMLTag tag, GNENet* net);
48
49
/**@brief Constructor
50
* @param[in] id The name of the POI
51
* @param[in] net net in which this polygon is placed
52
* @param[in] fileBucket file in which this element is stored
53
* @param[in] type The (abstract) type of the POI
54
* @param[in] color The color of the POI
55
* @param[in] pos The position X or Lon of the POI
56
* @param[in[ geo use GEO coordinates (lon/lat)
57
* @param[in] icon the POI icon
58
* @param[in] layer The layer of the POI
59
* @param[in] angle The rotation of the POI
60
* @param[in] imgFile The raster image of the shape
61
* @param[in] width The width of the POI image
62
* @param[in] height The height of the POI image
63
* @param[in] name POI's name
64
* @param[in] parameters generic parameters
65
*/
66
GNEPOI(const std::string& id, GNENet* net, FileBucket* fileBucket, const std::string& type, const RGBColor& color,
67
const Position& pos, const bool geo, POIIcon icon, const double layer, const double angle, const std::string& imgFile,
68
const double width, const double height, const std::string& name, const Parameterised::Map& parameters);
69
70
/**@brief Constructor
71
* @param[in] id The name of the POI
72
* @param[in] net net in which this polygon is placed
73
* @param[in] fileBucket file in which this element is stored
74
* @param[in] type The (abstract) type of the POI
75
* @param[in] color The color of the POI
76
* @param[in] icon the POI icon
77
* @param[in] layer The layer of the POI
78
* @param[in] angle The rotation of the POI
79
* @param[in] imgFile The raster image of the shape
80
* @param[in] lane lane in which this POILane is placed
81
* @param[in] posOverLane Position over lane in which this POILane is placed
82
* @param[in] posLat Lateral position over lane
83
* @param[in] width The width of the POI image
84
* @param[in] height The height of the POI image
85
* @param[in] name POI's name
86
* @param[in] parameters generic parameters
87
*/
88
GNEPOI(const std::string& id, GNENet* net, FileBucket* fileBucket, const std::string& type, const RGBColor& color, GNELane* lane,
89
const double posOverLane, const bool friendlyPos, const double posLat, POIIcon icon, const double layer, const double angle,
90
const std::string& imgFile, const double width, const double height, const std::string& name, const Parameterised::Map& parameters);
91
92
/// @brief Destructor
93
~GNEPOI();
94
95
/// @brief methods to retrieve the elements linked to this POI
96
/// @{
97
98
/// @brief get GNEMoveElement associated with this POI
99
GNEMoveElement* getMoveElement() const override;
100
101
/// @brief get parameters associated with this POI
102
Parameterised* getParameters() override;
103
104
/// @brief get parameters associated with this POI (constant)
105
const Parameterised* getParameters() const override;
106
107
/// @}
108
109
/// @brief gererate a new ID for an element child
110
std::string generateChildID(SumoXMLTag childTag);
111
112
/// @brief get SUMOBaseObject with all POIattributes
113
CommonXMLStructure::SumoBaseObject* getSumoBaseObject() const;
114
115
/// @name inherited from GNEAdditional
116
/// @{
117
118
/// @brief update pre-computed geometry information
119
void updateGeometry() override;
120
121
/// @brief Returns position of shape in view
122
Position getPositionInView() const override;
123
124
/// @brief return exaggeration associated with this GLObject
125
double getExaggeration(const GUIVisualizationSettings& s) const override;
126
127
/// @brief update centering boundary (implies change in RTREE)
128
void updateCenteringBoundary(const bool updateGrid) override;
129
130
/// @brief split geometry
131
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement,
132
const GNENetworkElement* newElement, GNEUndoList* undoList) override;
133
134
/**@brief write additional element into a xml file
135
* @param[in] device device in which write parameters of additional element
136
*/
137
void writeAdditional(OutputDevice& device) const override;
138
139
/// @brief check if current additional is valid to be written into XML (must be reimplemented in all detector children)
140
bool isAdditionalValid() const override;
141
142
/// @brief return a string with the current additional problem (must be reimplemented in all detector children)
143
std::string getAdditionalProblem() const override;
144
145
/// @brief fix additional problem (must be reimplemented in all detector children)
146
void fixAdditionalProblem() override;
147
148
/// @brief Returns the numerical id of the object
149
GUIGlID getGlID() const;
150
151
/// @}
152
153
/// @name Function related with contour drawing
154
/// @{
155
156
/// @brief check if draw move contour (red)
157
bool checkDrawMoveContour() const override;
158
159
/// @}
160
161
/// @name inherited from GUIGlObject
162
/// @{
163
/**@brief Returns the name of the parent object
164
* @return This object's parent id
165
*/
166
std::string getParentName() const override;
167
168
/**@brief Returns an own popup-menu
169
*
170
* @param[in] app The application needed to build the popup-menu
171
* @param[in] parent The parent window needed to build the popup-menu
172
* @return The built popup-menu
173
* @see GUIGlObject::getPopUpMenu
174
*/
175
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
176
177
/**@brief Draws the object
178
* @param[in] s The settings for the current view (may influence drawing)
179
* @see GUIGlObject::drawGL
180
*/
181
void drawGL(const GUIVisualizationSettings& s) const override;
182
183
/// @}
184
185
/// @name inherited from GNEAttributeCarrier
186
/// @{
187
188
/**@brief method for getting the Attribute of an XML key
189
* @param[in] key The attribute key
190
* @return string with the value associated to key
191
*/
192
std::string getAttribute(SumoXMLAttr key) const override;
193
194
/* @brief method for getting the Attribute of an XML key in double format
195
* @param[in] key The attribute key
196
* @return double with the value associated to key
197
*/
198
double getAttributeDouble(SumoXMLAttr key) const override;
199
200
/* @brief method for getting the Attribute of an XML key in position format
201
* @param[in] key The attribute key
202
* @return position with the value associated to key
203
*/
204
Position getAttributePosition(SumoXMLAttr key) const override;
205
206
/* @brief method for getting the Attribute of an XML key in positionVector format
207
* @param[in] key The attribute key
208
* @return positionVector with the value associated to key
209
*/
210
PositionVector getAttributePositionVector(SumoXMLAttr key) const override;
211
212
/**@brief method for setting the attribute and letting the object perform additional changes
213
* @param[in] key The attribute key
214
* @param[in] value The new value
215
* @param[in] undoList The undoList on which to register changes
216
*/
217
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
218
219
/**@brief method for checking if the key and their correspond attribute are valids
220
* @param[in] key The attribute key
221
* @param[in] value The value associated to key key
222
* @return true if the value is valid, false in other case
223
*/
224
bool isValid(SumoXMLAttr key, const std::string& value) override;
225
226
/* @brief method for check if the value for certain attribute is set
227
* @param[in] key The attribute key
228
*/
229
bool isAttributeEnabled(SumoXMLAttr key) const override;
230
231
/// @}
232
233
/// @brief get PopPup ID (Used in AC Hierarchy)
234
std::string getPopUpID() const override;
235
236
/// @brief get Hierarchy Name (Used in AC Hierarchy)
237
std::string getHierarchyName() const override;
238
239
protected:
240
/// @brief position over view
241
Position myPosOverView;
242
243
/// @brief position over lane
244
double myPosOverLane = 0;
245
246
/// @brief friendly position
247
bool myFriendlyPos = false;
248
249
/// @brief width
250
double myWidth = 0;
251
252
/// @brief height
253
double myHeight = 0;
254
255
/// @brief lateral position;
256
double myPosLat = 0;
257
258
/// @brief POI icon
259
POIIcon myPOIIcon = POIIcon::NONE;
260
261
/// @brief move element over single lane
262
GNEMoveElementLaneSingle* myMoveElementLaneSingle = nullptr;
263
264
/// @brief move element view resizable
265
GNEMoveElementViewResizable* myMoveElementViewResizable = nullptr;
266
267
private:
268
/// @brief draw POI
269
void drawPOI(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
270
const bool movingGeometryPoints) const;
271
272
/// @brief calculate contour
273
void calculatePOIContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
274
const double exaggeration, const bool movingGeometryPoints) const;
275
276
/// @brief set attribute after validation
277
void setAttribute(SumoXMLAttr key, const std::string& value) override;
278
279
/// @brief Invalidated copy constructor.
280
GNEPOI(const GNEPOI&) = delete;
281
282
/// @brief Invalidated assignment operator.
283
GNEPOI& operator=(const GNEPOI&) = delete;
284
};
285
286