Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/additional/GNEPOI.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 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/PointOfInterest.h>
25
#include <utils/xml/CommonXMLStructure.h>
26
27
#include "GNEAdditional.h"
28
29
// ===========================================================================
30
// class declarations
31
// ===========================================================================
32
33
class GNELane;
34
35
// ===========================================================================
36
// class definitions
37
// ===========================================================================
38
39
class GNEPOI : public PointOfInterest, public GNEAdditional {
40
41
public:
42
/// @brief needed to avoid diamond problem between PointOfInterest and GNEAdditional
43
using GNEAdditional::getID;
44
45
/// @brief Constructor
46
GNEPOI(SumoXMLTag tag, GNENet* net);
47
48
/**@brief Constructor
49
* @param[in] id The name of the POI
50
* @param[in] net net in which this polygon is placed
51
* @param[in] filename file in which this element is stored
52
* @param[in] type The (abstract) type of the POI
53
* @param[in] color The color of the POI
54
* @param[in] lon The position X or Lon of the POI
55
* @param[in] lat The position Y or Lat 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, const std::string& filename, const std::string& type, const RGBColor& color, const double xLon,
67
const double yLat, const bool geo, const std::string& 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] filename 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, const std::string& filename, const std::string& type, const RGBColor& color, GNELane* lane,
89
const double posOverLane, const bool friendlyPos, const double posLat, const std::string& 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 get move operation
96
* @note returned GNEMoveOperation can be nullptr
97
*/
98
GNEMoveOperation* getMoveOperation() override;
99
100
/// @brief remove geometry point in the clicked position
101
void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) override;
102
103
/// @brief gererate a new ID for an element child
104
std::string generateChildID(SumoXMLTag childTag);
105
106
/// @brief get SUMOBaseObject with all POIattributes
107
CommonXMLStructure::SumoBaseObject* getSumoBaseObject() const;
108
109
/// @name inherited from GNEAdditional
110
/// @{
111
112
/// @brief update pre-computed geometry information
113
void updateGeometry() override;
114
115
/// @brief Returns position of shape in view
116
Position getPositionInView() const override;
117
118
/// @brief return exaggeration associated with this GLObject
119
double getExaggeration(const GUIVisualizationSettings& s) const override;
120
121
/// @brief update centering boundary (implies change in RTREE)
122
void updateCenteringBoundary(const bool updateGrid) override;
123
124
/// @brief split geometry
125
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement,
126
const GNENetworkElement* newElement, GNEUndoList* undoList) override;
127
128
/**@brief write additional element into a xml file
129
* @param[in] device device in which write parameters of additional element
130
*/
131
void writeAdditional(OutputDevice& device) const override;
132
133
/// @brief check if current additional is valid to be written into XML (must be reimplemented in all detector children)
134
bool isAdditionalValid() const override;
135
136
/// @brief return a string with the current additional problem (must be reimplemented in all detector children)
137
std::string getAdditionalProblem() const override;
138
139
/// @brief fix additional problem (must be reimplemented in all detector children)
140
void fixAdditionalProblem() override;
141
142
/// @brief Returns the numerical id of the object
143
GUIGlID getGlID() const;
144
145
/// @}
146
147
/// @name Function related with contour drawing
148
/// @{
149
150
/// @brief check if draw move contour (red)
151
bool checkDrawMoveContour() const override;
152
153
/// @}
154
155
/// @name inherited from GUIGlObject
156
/// @{
157
/**@brief Returns the name of the parent object
158
* @return This object's parent id
159
*/
160
std::string getParentName() const override;
161
162
/**@brief Returns an own popup-menu
163
*
164
* @param[in] app The application needed to build the popup-menu
165
* @param[in] parent The parent window needed to build the popup-menu
166
* @return The built popup-menu
167
* @see GUIGlObject::getPopUpMenu
168
*/
169
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
170
171
/**@brief Draws the object
172
* @param[in] s The settings for the current view (may influence drawing)
173
* @see GUIGlObject::drawGL
174
*/
175
void drawGL(const GUIVisualizationSettings& s) const override;
176
177
/// @}
178
179
/// @name inherited from GNEAttributeCarrier
180
/// @{
181
182
/**@brief method for getting the Attribute of an XML key
183
* @param[in] key The attribute key
184
* @return string with the value associated to key
185
*/
186
std::string getAttribute(SumoXMLAttr key) const override;
187
188
/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
189
* @param[in] key The attribute key
190
* @return double with the value associated to key
191
*/
192
double getAttributeDouble(SumoXMLAttr key) const override;
193
194
/// @brief get parameters map
195
const Parameterised::Map& getACParametersMap() const override;
196
197
/**@brief method for setting the attribute and letting the object perform additional changes
198
* @param[in] key The attribute key
199
* @param[in] value The new value
200
* @param[in] undoList The undoList on which to register changes
201
*/
202
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
203
204
/**@brief method for checking if the key and their correspond attribute are valids
205
* @param[in] key The attribute key
206
* @param[in] value The value associated to key key
207
* @return true if the value is valid, false in other case
208
*/
209
bool isValid(SumoXMLAttr key, const std::string& value) override;
210
211
/* @brief method for check if the value for certain attribute is set
212
* @param[in] key The attribute key
213
*/
214
bool isAttributeEnabled(SumoXMLAttr key) const override;
215
216
/// @}
217
218
/// @brief get PopPup ID (Used in AC Hierarchy)
219
std::string getPopUpID() const override;
220
221
/// @brief get Hierarchy Name (Used in AC Hierarchy)
222
std::string getHierarchyName() const override;
223
224
protected:
225
/// @brief shape width of POI
226
PositionVector myShapeWidth;
227
228
/// @brief shape height of POI
229
PositionVector myShapeHeight;
230
231
/// @brief variable used for moving contour up
232
GNEContour myMovingContourUp;
233
234
/// @brief variable used for moving contour down
235
GNEContour myMovingContourDown;
236
237
/// @brief variable used for moving contour left
238
GNEContour myMovingContourLeft;
239
240
/// @brief variable used for moving contour right
241
GNEContour myMovingContourRight;
242
243
private:
244
/// @brief draw POI
245
void drawPOI(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
246
const bool movingGeometryPoints) const;
247
248
/// @brief calculate contour
249
void calculatePOIContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
250
const double exaggeration, const bool movingGeometryPoints) const;
251
252
/// @brief set attribute after validation
253
void setAttribute(SumoXMLAttr key, const std::string& value) override;
254
255
/// @brief set move shape
256
void setMoveShape(const GNEMoveResult& moveResult) override;
257
258
/// @brief commit move shape
259
void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) override;
260
261
/// @brief Invalidated copy constructor.
262
GNEPOI(const GNEPOI&) = delete;
263
264
/// @brief Invalidated assignment operator.
265
GNEPOI& operator=(const GNEPOI&) = delete;
266
};
267
268