Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/demand/GNEPerson.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 GNEPerson.h
15
/// @author Pablo Alvarez Lopez
16
/// @date May 2019
17
///
18
// Representation of persons in netedit
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
#include <netedit/elements/GNEContour.h>
23
#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
24
25
#include "GNEDemandElement.h"
26
#include "GNEDemandElementFlow.h"
27
28
// ===========================================================================
29
// class declaration
30
// ===========================================================================
31
32
class GNEMoveElementPlanParent;
33
34
// ===========================================================================
35
// class definitions
36
// ===========================================================================
37
38
class GNEPerson : public GNEDemandElement, public GNEDemandElementFlow {
39
40
public:
41
/// @brief class used in GUIGLObjectPopupMenu for person transformations
42
class GNEPersonPopupMenu : public GUIGLObjectPopupMenu {
43
FXDECLARE(GNEPersonPopupMenu)
44
45
public:
46
/** @brief Constructor
47
* @param[in] person GNEPerson to be transformed
48
* @param[in] app The main window for instantiation of other windows
49
* @param[in] parent The parent view for changing it
50
*/
51
GNEPersonPopupMenu(GNEPerson* person, GUIMainWindow& app, GUISUMOAbstractView& parent);
52
53
/// @brief Destructor
54
~GNEPersonPopupMenu();
55
56
/// @brief Called to transform the current person to another person type
57
long onCmdTransform(FXObject* obj, FXSelector, void*);
58
59
protected:
60
FOX_CONSTRUCTOR(GNEPersonPopupMenu)
61
62
private:
63
/// @brief current person
64
GNEPerson* myPerson;
65
66
/// @brief menu command for transform to person
67
FXMenuCommand* myTransformToPerson;
68
69
/// @brief menu command for transform to personFlow
70
FXMenuCommand* myTransformToPersonFlow;
71
};
72
73
/// @brief class used in GUIGLObjectPopupMenu for single person transformations
74
class GNESelectedPersonsPopupMenu : public GUIGLObjectPopupMenu {
75
FXDECLARE(GNESelectedPersonsPopupMenu)
76
77
public:
78
/** @brief Constructor
79
* @param[in] person clicked GNEPerson
80
* @param[in] selectedPerson vector with selected GNEPerson
81
* @param[in] app The main window for instantiation of other windows
82
* @param[in] parent The parent view for changing it
83
*/
84
GNESelectedPersonsPopupMenu(GNEPerson* person, const std::vector<GNEPerson*>& selectedPerson, GUIMainWindow& app, GUISUMOAbstractView& parent);
85
86
/// @brief Destructor
87
~GNESelectedPersonsPopupMenu();
88
89
/// @brief Called to transform the current person to another person type
90
long onCmdTransform(FXObject* obj, FXSelector, void*);
91
92
protected:
93
FOX_CONSTRUCTOR(GNESelectedPersonsPopupMenu)
94
95
private:
96
/// @brief tag of clicked person
97
SumoXMLTag myPersonTag;
98
99
/// @brief current selected persons
100
std::vector<GNEPerson*> mySelectedPersons;
101
102
/// @brief menu command for transform to person
103
FXMenuCommand* myTransformToPerson;
104
105
/// @brief menu command for transform to personFlow
106
FXMenuCommand* myTransformToPersonFlow;
107
};
108
109
/// @brief default constructor
110
GNEPerson(SumoXMLTag tag, GNENet* net);
111
112
/// @brief constructor for persons
113
GNEPerson(SumoXMLTag tag, GNENet* net, FileBucket* fileBucket, GNEDemandElement* pType,
114
const SUMOVehicleParameter& personparameters);
115
116
/// @brief destructor
117
~GNEPerson();
118
119
/// @brief methods to retrieve the elements linked to this person
120
/// @{
121
122
/// @brief get GNEMoveElement associated with this person
123
GNEMoveElement* getMoveElement() const override;
124
125
/// @brief get parameters associated with this person
126
Parameterised* getParameters() override;
127
128
/// @brief get parameters associated with this person (constant)
129
const Parameterised* getParameters() const override;
130
131
/// @}
132
133
/**@brief write demand element element into a xml file
134
* @param[in] device device in which write parameters of demand element element
135
*/
136
void writeDemandElement(OutputDevice& device) const override;
137
138
/// @brief check if current demand element is valid to be written into XML (by default true, can be reimplemented in children)
139
Problem isDemandElementValid() const override;
140
141
/// @brief return a string with the current demand element problem (by default empty, can be reimplemented in children)
142
std::string getDemandElementProblem() const override;
143
144
/// @brief fix demand element problem (by default throw an exception, has to be reimplemented in children)
145
void fixDemandElementProblem() override;
146
147
/// @name members and functions relative to elements common to all demand elements
148
/// @{
149
/// @brief obtain VClass related with this demand element
150
SUMOVehicleClass getVClass() const override;
151
152
/// @brief get color
153
const RGBColor& getColor() const override;
154
155
/// @}
156
157
/// @name Functions related with geometry of element
158
/// @{
159
/// @brief update pre-computed geometry information
160
void updateGeometry() override;
161
162
/// @brief Returns position of demand element in view
163
Position getPositionInView() const override;
164
/// @}
165
166
/// @name inherited from GUIGlObject
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 Returns the name of the parent object
178
* @return This object's parent id
179
*/
180
std::string getParentName() const override;
181
182
/// @brief return exaggeration associated with this GLObject
183
double getExaggeration(const GUIVisualizationSettings& s) const override;
184
185
/**@brief Returns the boundary to which the view shall be centered in order to show the object
186
* @return The boundary the object is within
187
*/
188
Boundary getCenteringBoundary() const override;
189
190
/// @brief split geometry
191
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) override;
192
193
/**@brief Draws the object
194
* @param[in] s The settings for the current view (may influence drawing)
195
* @see GUIGlObject::drawGL
196
*/
197
void drawGL(const GUIVisualizationSettings& s) const override;
198
199
/// @}
200
201
/// @name inherited from GNEPathElement
202
/// @{
203
204
/// @brief compute pathElement
205
void computePathElement() override;
206
207
/**@brief Draws partial object over lane
208
* @param[in] s The settings for the current view (may influence drawing)
209
* @param[in] segment lane segment
210
* @param[in] offsetFront front offset
211
*/
212
void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;
213
214
/**@brief Draws partial object over junction
215
* @param[in] s The settings for the current view (may influence drawing)
216
* @param[in] segment junction segment
217
* @param[in] offsetFront front offset
218
*/
219
void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;
220
221
/// @brief get first path lane
222
GNELane* getFirstPathLane() const override;
223
224
/// @brief get last path lane
225
GNELane* getLastPathLane() const override;
226
/// @}
227
228
/// @brief inherited from GNEAttributeCarrier
229
/// @{
230
/* @brief method for getting the Attribute of an XML key
231
* @param[in] key The attribute key
232
* @return string with the value associated to key
233
*/
234
std::string getAttribute(SumoXMLAttr key) const override;
235
236
/* @brief method for getting the Attribute of an XML key in double format
237
* @param[in] key The attribute key
238
* @return double with the value associated to key
239
*/
240
double getAttributeDouble(SumoXMLAttr key) const override;
241
242
/* @brief method for getting the Attribute of an XML key in position format
243
* @param[in] key The attribute key
244
* @return position with the value associated to key
245
*/
246
Position getAttributePosition(SumoXMLAttr key) const override;
247
248
/* @brief method for setting the attribute and letting the object perform demand element changes
249
* @param[in] key The attribute key
250
* @param[in] value The new value
251
* @param[in] undoList The undoList on which to register changes
252
* @param[in] net optionally the GNENet to inform about gui updates
253
*/
254
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
255
256
/* @brief method for setting the attribute and letting the object perform demand element changes
257
* @param[in] key The attribute key
258
* @param[in] value The new value
259
* @param[in] undoList The undoList on which to register changes
260
*/
261
bool isValid(SumoXMLAttr key, const std::string& value) override;
262
263
/* @brief method for enable attribute
264
* @param[in] key The attribute key
265
* @param[in] undoList The undoList on which to register changes
266
* @note certain attributes can be only enabled, and can produce the disabling of other attributes
267
*/
268
void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList) override;
269
270
/* @brief method for disable attribute
271
* @param[in] key The attribute key
272
* @param[in] undoList The undoList on which to register changes
273
* @note certain attributes can be only enabled, and can produce the disabling of other attributes
274
*/
275
void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList) override;
276
277
/* @brief method for check if the value for certain attribute is set
278
* @param[in] key The attribute key
279
*/
280
bool isAttributeEnabled(SumoXMLAttr key) const override;
281
282
/// @brief get PopPup ID (Used in AC Hierarchy)
283
std::string getPopUpID() const override;
284
285
/// @brief get Hierarchy Name (Used in AC Hierarchy)
286
std::string getHierarchyName() const override;
287
/// @}
288
289
protected:
290
/// @brief move element plan parent
291
GNEMoveElementPlanParent* myMoveElementPlanParent = nullptr;
292
293
/// @brief variable used for contours
294
GNEContour myPersonContour;
295
296
/// @brief get drawing color
297
RGBColor getDrawingColor(const GUIVisualizationSettings& s) const;
298
299
private:
300
// @brief struct used for calculating person plan geometry segments
301
struct personPlanSegment {
302
/// @brief parameter constructor
303
personPlanSegment(GNEDemandElement* _personPlan);
304
305
/// @brief person plan
306
const GNEDemandElement* personPlan;
307
308
/// @brief edge
309
GNEEdge* edge;
310
311
/// @brief busStops placed in this segment
312
std::vector<GNEAdditional*> busStops;
313
314
/// @brief stops placed in this segment
315
std::vector<GNEDemandElement*> stops;
316
317
/// @brief arrival position
318
double arrivalPos;
319
320
private:
321
/// @brief constructor
322
personPlanSegment();
323
};
324
325
/// @brief method for setting the attribute and nothing else
326
void setAttribute(SumoXMLAttr key, const std::string& value) override;
327
328
/// @brief method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
329
void toggleAttribute(SumoXMLAttr key, const bool value) override;
330
331
/// @brief Invalidated copy constructor.
332
GNEPerson(const GNEPerson&) = delete;
333
334
/// @brief Invalidated assignment operator
335
GNEPerson& operator=(const GNEPerson&) = delete;
336
};
337
338