-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
GNEPerson.h
328 lines (256 loc) · 12.3 KB
/
GNEPerson.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/****************************************************************************/
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
// Copyright (C) 2001-2023 German Aerospace Center (DLR) and others.
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0/
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License 2.0 are satisfied: GNU General Public License, version 2
// or later which is available at
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
/****************************************************************************/
/// @file GNEPerson.h
/// @author Pablo Alvarez Lopez
/// @date May 2019
///
// Representation of persons in netedit
/****************************************************************************/
#pragma once
#include <config.h>
#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
#include "GNEDemandElement.h"
#include "GNEDemandElementFlow.h"
// ===========================================================================
// class definitions
// ===========================================================================
class GNEPerson : public GNEDemandElement, public GNEDemandElementFlow {
public:
/// @brief class used in GUIGLObjectPopupMenu for person transformations
class GNEPersonPopupMenu : public GUIGLObjectPopupMenu {
FXDECLARE(GNEPersonPopupMenu)
public:
/** @brief Constructor
* @param[in] person GNEPerson to be transformed
* @param[in] app The main window for instantiation of other windows
* @param[in] parent The parent view for changing it
*/
GNEPersonPopupMenu(GNEPerson* person, GUIMainWindow& app, GUISUMOAbstractView& parent);
/// @brief Destructor
~GNEPersonPopupMenu();
/// @brief Called to transform the current person to another person type
long onCmdTransform(FXObject* obj, FXSelector, void*);
protected:
FOX_CONSTRUCTOR(GNEPersonPopupMenu)
private:
/// @brief current person
GNEPerson* myPerson;
/// @brief menu command for transform to person
FXMenuCommand* myTransformToPerson;
/// @brief menu command for transform to personFlow
FXMenuCommand* myTransformToPersonFlow;
};
/// @brief class used in GUIGLObjectPopupMenu for single person transformations
class GNESelectedPersonsPopupMenu : public GUIGLObjectPopupMenu {
FXDECLARE(GNESelectedPersonsPopupMenu)
public:
/** @brief Constructor
* @param[in] person clicked GNEPerson
* @param[in] selectedPerson vector with selected GNEPerson
* @param[in] app The main window for instantiation of other windows
* @param[in] parent The parent view for changing it
*/
GNESelectedPersonsPopupMenu(GNEPerson* person, const std::vector<GNEPerson*>& selectedPerson, GUIMainWindow& app, GUISUMOAbstractView& parent);
/// @brief Destructor
~GNESelectedPersonsPopupMenu();
/// @brief Called to transform the current person to another person type
long onCmdTransform(FXObject* obj, FXSelector, void*);
protected:
FOX_CONSTRUCTOR(GNESelectedPersonsPopupMenu)
private:
/// @brief tag of clicked person
SumoXMLTag myPersonTag;
/// @brief current selected persons
std::vector<GNEPerson*> mySelectedPersons;
/// @brief menu command for transform to person
FXMenuCommand* myTransformToPerson;
/// @brief menu command for transform to personFlow
FXMenuCommand* myTransformToPersonFlow;
};
/// @brief default constructor
GNEPerson(SumoXMLTag tag, GNENet* net);
/// @brief constructor for persons
GNEPerson(SumoXMLTag tag, GNENet* net, GNEDemandElement* pType, const SUMOVehicleParameter& personparameters);
/// @brief destructor
~GNEPerson();
/**@brief get move operation
* @note returned GNEMoveOperation can be nullptr
*/
GNEMoveOperation* getMoveOperation();
/**@brief write demand element element into a xml file
* @param[in] device device in which write parameters of demand element element
*/
void writeDemandElement(OutputDevice& device) const;
/// @brief check if current demand element is valid to be written into XML (by default true, can be reimplemented in children)
Problem isDemandElementValid() const;
/// @brief return a string with the current demand element problem (by default empty, can be reimplemented in children)
std::string getDemandElementProblem() const;
/// @brief fix demand element problem (by default throw an exception, has to be reimplemented in children)
void fixDemandElementProblem();
/// @name members and functions relative to elements common to all demand elements
/// @{
/// @brief obtain VClass related with this demand element
SUMOVehicleClass getVClass() const;
/// @brief get color
const RGBColor& getColor() const;
/// @}
/// @name Functions related with geometry of element
/// @{
/// @brief update pre-computed geometry information
void updateGeometry();
/// @brief Returns position of demand element in view
Position getPositionInView() const;
/// @}
/// @name inherited from GUIGlObject
/// @{
/**@brief Returns an own popup-menu
*
* @param[in] app The application needed to build the popup-menu
* @param[in] parent The parent window needed to build the popup-menu
* @return The built popup-menu
* @see GUIGlObject::getPopUpMenu
*/
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent);
/**@brief Returns the name of the parent object
* @return This object's parent id
*/
std::string getParentName() const;
/// @brief return exaggeration associated with this GLObject
double getExaggeration(const GUIVisualizationSettings& s) const;
/**@brief Returns the boundary to which the view shall be centered in order to show the object
* @return The boundary the object is within
*/
Boundary getCenteringBoundary() const;
/// @brief split geometry
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
/**@brief Draws the object
* @param[in] s The settings for the current view (may influence drawing)
* @see GUIGlObject::drawGL
*/
void drawGL(const GUIVisualizationSettings& s) const;
/// @}
/// @name inherited from GNEPathManager::PathElement
/// @{
/// @brief compute pathElement
void computePathElement();
/**@brief Draws partial object
* @param[in] s The settings for the current view (may influence drawing)
* @param[in] lane lane in which draw partial
* @param[in] segment PathManager segment (used for segment options)
* @param[in] offsetFront extra front offset (used for drawing partial gl above other elements)
*/
void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const;
/**@brief Draws partial object (junction)
* @param[in] s The settings for the current view (may influence drawing)
* @param[in] fromLane from GNELane
* @param[in] toLane to GNELane
* @param[in] segment PathManager segment (used for segment options)
* @param[in] offsetFront extra front offset (used for drawing partial gl above other elements)
*/
void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, const double offsetFront) const;
/// @brief get first path lane
GNELane* getFirstPathLane() const;
/// @brief get last path lane
GNELane* getLastPathLane() const;
/// @}
/// @brief inherited from GNEAttributeCarrier
/// @{
/* @brief method for getting the Attribute of an XML key
* @param[in] key The attribute key
* @return string with the value associated to key
*/
std::string getAttribute(SumoXMLAttr key) const;
/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
* @param[in] key The attribute key
* @return double with the value associated to key
*/
double getAttributeDouble(SumoXMLAttr key) const;
/* @brief method for getting the Attribute of an XML key in Position format (used in person plans)
* @param[in] key The attribute key
* @return double with the value associated to key
*/
Position getAttributePosition(SumoXMLAttr key) const;
/* @brief method for setting the attribute and letting the object perform demand element changes
* @param[in] key The attribute key
* @param[in] value The new value
* @param[in] undoList The undoList on which to register changes
* @param[in] net optionally the GNENet to inform about gui updates
*/
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
/* @brief method for setting the attribute and letting the object perform demand element changes
* @param[in] key The attribute key
* @param[in] value The new value
* @param[in] undoList The undoList on which to register changes
*/
bool isValid(SumoXMLAttr key, const std::string& value);
/* @brief method for enable attribute
* @param[in] key The attribute key
* @param[in] undoList The undoList on which to register changes
* @note certain attributes can be only enabled, and can produce the disabling of other attributes
*/
void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
/* @brief method for disable attribute
* @param[in] key The attribute key
* @param[in] undoList The undoList on which to register changes
* @note certain attributes can be only enabled, and can produce the disabling of other attributes
*/
void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
/* @brief method for check if the value for certain attribute is set
* @param[in] key The attribute key
*/
bool isAttributeEnabled(SumoXMLAttr key) const;
/// @brief get PopPup ID (Used in AC Hierarchy)
std::string getPopUpID() const;
/// @brief get Hierarchy Name (Used in AC Hierarchy)
std::string getHierarchyName() const;
/// @}
/// @brief get parameters map
const Parameterised::Map& getACParametersMap() const;
protected:
/// @brief sets the color according to the currente settings
RGBColor setColor(const GUIVisualizationSettings& s) const;
/// @brief sets the color according to the current scheme index and some vehicle function
bool setFunctionalColor(int activeScheme) const;
private:
// @brief struct used for calculating person plan geometry segments
struct personPlanSegment {
/// @brief parameter constructor
personPlanSegment(GNEDemandElement* _personPlan);
/// @brief person plan
const GNEDemandElement* personPlan;
/// @brief edge
GNEEdge* edge;
/// @brief busStops placed in this segment
std::vector<GNEAdditional*> busStops;
/// @brief stops placed in this segment
std::vector<GNEDemandElement*> stops;
/// @brief arrival position
double arrivalPos;
private:
/// @brief constructor
personPlanSegment();
};
/// @brief method for setting the attribute and nothing else
void setAttribute(SumoXMLAttr key, const std::string& value);
/// @brief method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
void toggleAttribute(SumoXMLAttr key, const bool value);
/// @brief set move shape
void setMoveShape(const GNEMoveResult& moveResult);
/// @brief commit move shape
void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
/// @brief Invalidated copy constructor.
GNEPerson(const GNEPerson&) = delete;
/// @brief Invalidated assignment operator
GNEPerson& operator=(const GNEPerson&) = delete;
};