Eclipse SUMO - Simulation of Urban MObility
GNEPerson.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // Representation of persons in NETEDIT
16 /****************************************************************************/
17 #ifndef GNEPerson_h
18 #define GNEPerson_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 
27 
28 
29 #include "GNEDemandElement.h"
30 
31 // ===========================================================================
32 // class definitions
33 // ===========================================================================
38 
39 public:
42  FXDECLARE(GNEPersonPopupMenu)
43 
44  public:
51 
54 
56  long onCmdTransform(FXObject* obj, FXSelector, void*);
57 
58  protected:
61 
62  private:
65 
67  FXMenuCommand* myTransformToPerson;
68 
70  FXMenuCommand* myTransformToPersonFlow;
71  };
72 
76 
77  public:
84  GNESelectedPersonsPopupMenu(GNEPerson* person, const std::vector<GNEPerson*>& selectedPerson, GUIMainWindow& app, GUISUMOAbstractView& parent);
85 
88 
90  long onCmdTransform(FXObject* obj, FXSelector, void*);
91 
92  protected:
95 
96  private:
99 
101  std::vector<GNEPerson*> mySelectedPersons;
102 
104  FXMenuCommand* myTransformToPerson;
105 
107  FXMenuCommand* myTransformToPersonFlow;
108  };
109 
111  GNEPerson(SumoXMLTag tag, GNEViewNet* viewNet, GNEDemandElement* pType, const SUMOVehicleParameter& personparameters);
112 
114  ~GNEPerson();
115 
120  std::string getBegin() const;
121 
125  void writeDemandElement(OutputDevice& device) const;
126 
128  bool isDemandElementValid() const;
129 
131  std::string getDemandElementProblem() const;
132 
135 
139  GNEEdge* getFromEdge() const;
140 
142  GNEEdge* getToEdge() const;
143 
145  SUMOVehicleClass getVClass() const;
146 
148  const RGBColor& getColor() const;
149 
151  void compute();
152 
154 
158  void startGeometryMoving();
159 
161  void endGeometryMoving();
162 
166  void moveGeometry(const Position& offset);
167 
171  void commitGeometryMoving(GNEUndoList* undoList);
172 
174  void updateGeometry();
175 
177  Position getPositionInView() const;
179 
182 
190 
194  std::string getParentName() const;
195 
200 
205  void drawGL(const GUIVisualizationSettings& s) const;
207 
211  void selectAttributeCarrier(bool changeFlag = true);
212 
214  void unselectAttributeCarrier(bool changeFlag = true);
215 
216  /* @brief method for getting the Attribute of an XML key
217  * @param[in] key The attribute key
218  * @return string with the value associated to key
219  */
220  std::string getAttribute(SumoXMLAttr key) const;
221 
222  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
223  * @param[in] key The attribute key
224  * @return double with the value associated to key
225  */
226  double getAttributeDouble(SumoXMLAttr key) const;
227 
228  /* @brief method for setting the attribute and letting the object perform demand element changes
229  * @param[in] key The attribute key
230  * @param[in] value The new value
231  * @param[in] undoList The undoList on which to register changes
232  * @param[in] net optionally the GNENet to inform about gui updates
233  */
234  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
235 
236  /* @brief method for setting the attribute and letting the object perform demand element changes
237  * @param[in] key The attribute key
238  * @param[in] value The new value
239  * @param[in] undoList The undoList on which to register changes
240  */
241  bool isValid(SumoXMLAttr key, const std::string& value);
242 
243  /* @brief method for enabling attribute
244  * @param[in] key The attribute key
245  * @param[in] undoList The undoList on which to register changes
246  * @note only certain attributes can be enabled, and can produce the disabling of other attributes
247  */
248  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
249 
250  /* @brief method for check if the value for certain attribute is set
251  * @param[in] key The attribute key
252  */
253  bool isAttributeEnabled(SumoXMLAttr key) const;
254 
256  std::string getPopUpID() const;
257 
259  std::string getHierarchyName() const;
261 
265  std::string getGenericParametersStr() const;
266 
268  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
269 
271  void setGenericParametersStr(const std::string& value);
272 
274 
275 protected:
277  void setColor(const GUIVisualizationSettings& s) const;
278 
280  bool setFunctionalColor(int activeScheme) const;
281 
282 private:
283  // @brief struct used for calculating person plan geometry segments
286  personPlanSegment(GNEDemandElement* _personPlan);
287 
290 
293 
295  std::vector<GNEAdditional*> busStops;
296 
298  std::vector<GNEDemandElement*> stops;
299 
301  double arrivalPos;
302 
303  private:
306  };
307 
309  void setAttribute(SumoXMLAttr key, const std::string& value);
310 
312  void setEnabledAttribute(const int enabledAttributes);
313 
315  void calculateSmoothPersonPlanConnection(const GNEDemandElement* personPlanElement, const GNEEdge* edgeFrom, const GNEEdge* edgeTo);
316 
318  std::pair<PositionVector, PositionVector> calculatePersonPlanConnectionBusStop(GNELane* previousLane, GNEAdditional* busStop, GNELane* nextLane);
319 
321  std::pair<PositionVector, PositionVector> calculatePersonPlanConnectionStop(GNELane* previousLane, GNEDemandElement* stop, GNELane* nextLane);
322 
324  std::pair<PositionVector, PositionVector> calculatePersonPlanConnectionArrivalPos(GNELane* previousLane, double arrivalPosPersonPlan, GNELane* nextLane);
325 
327  GNEPerson(const GNEPerson&) = delete;
328 
330  GNEPerson& operator=(const GNEPerson&) = delete;
331 };
332 
333 #endif
334 /****************************************************************************/
std::pair< PositionVector, PositionVector > calculatePersonPlanConnectionArrivalPos(GNELane *previousLane, double arrivalPosPersonPlan, GNELane *nextLane)
return two shapes used for calculate person plan conections between arrival position ...
Definition: GNEPerson.cpp:1240
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNEPerson.cpp:633
bool setFunctionalColor(int activeScheme) const
sets the color according to the current scheme index and some vehicle function
Definition: GNEPerson.cpp:947
SumoXMLTag
Numbers representing SUMO-XML - element names.
std::pair< PositionVector, PositionVector > calculatePersonPlanConnectionStop(GNELane *previousLane, GNEDemandElement *stop, GNELane *nextLane)
return two shapes used for calculate person plan conections between stops
Definition: GNEPerson.cpp:1207
std::vector< GNEAdditional * > busStops
busStops placed in this segment
Definition: GNEPerson.h:295
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNEPerson.cpp:1021
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
Definition: GNEPerson.cpp:1010
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEPerson.cpp:560
FXMenuCommand * myTransformToPersonFlow
menu command for transform to personFlow
Definition: GNEPerson.h:107
Stores the information about how to visualize structures.
void endGeometryMoving()
end geometry movement
Definition: GNEPerson.cpp:304
~GNEPerson()
destructor
Definition: GNEPerson.cpp:181
FXMenuCommand * myTransformToPersonFlow
menu command for transform to personFlow
Definition: GNEPerson.h:70
GNESelectedPersonsPopupMenu()
default constructor needed by FOX
Definition: GNEPerson.h:94
std::vector< GNEPerson * > mySelectedPersons
current selected persons
Definition: GNEPerson.h:101
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
GNEPersonPopupMenu()
default constructor needed by FOX
Definition: GNEPerson.h:60
class used in GUIGLObjectPopupMenu for single person transformations
Definition: GNEPerson.h:74
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEPerson.cpp:534
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNEPerson.cpp:697
void selectAttributeCarrier(bool changeFlag=true)
inherited from GNEAttributeCarrier
Definition: GNEPerson.cpp:618
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNEPerson.cpp:995
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEPerson.cpp:903
class used in GUIGLObjectPopupMenu for person transformations
Definition: GNEPerson.h:41
const RGBColor & getColor() const
get color
Definition: GNEPerson.cpp:286
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GNEPerson.cpp:938
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEPerson.cpp:733
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GNEEdge * getToEdge() const
obtain to edge of this demand element
Definition: GNEPerson.cpp:274
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEPerson.cpp:649
void startGeometryMoving()
Definition: GNEPerson.cpp:298
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEPerson.cpp:822
GNEPerson & operator=(const GNEPerson &)=delete
Invalidated assignment operator.
void updateGeometry()
update pre-computed geometry information
Definition: GNEPerson.cpp:322
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNEPerson.cpp:255
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute) ...
Definition: GNEPerson.cpp:1146
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current person to another person type.
Definition: GNEPerson.cpp:105
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
Position getPositionInView() const
Returns position of demand element in view.
Definition: GNEPerson.cpp:508
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEPerson.cpp:547
Structure representing possible vehicle parameter.
bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNEPerson.cpp:248
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEPerson.cpp:884
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes ...
Definition: GNEPerson.cpp:703
std::vector< GNEDemandElement * > stops
stops placed in this segment
Definition: GNEPerson.h:298
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEPerson.cpp:909
SumoXMLTag myPersonTag
tag of clicked person
Definition: GNEPerson.h:98
double arrivalPos
arrival position
Definition: GNEPerson.h:301
SumoXMLTag tag
The vehicle tag.
The popup menu of a globject.
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children) ...
Definition: GNEPerson.cpp:262
~GNEPersonPopupMenu()
Destructor.
Definition: GNEPerson.cpp:101
GNEPerson(SumoXMLTag tag, GNEViewNet *viewNet, GNEDemandElement *pType, const SUMOVehicleParameter &personparameters)
constructor for persons
Definition: GNEPerson.cpp:172
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
GNEEdge * getFromEdge() const
Definition: GNEPerson.cpp:268
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNEPerson.cpp:204
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition: GNEPerson.cpp:280
void compute()
compute demand element
Definition: GNEPerson.cpp:292
void calculateSmoothPersonPlanConnection(const GNEDemandElement *personPlanElement, const GNEEdge *edgeFrom, const GNEEdge *edgeTo)
calculate smooth shape between personPlans
Definition: GNEPerson.cpp:1152
FXMenuCommand * myTransformToPerson
menu command for transform to person
Definition: GNEPerson.h:67
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(...)
Definition: GNEPerson.cpp:316
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEPerson.cpp:541
FXMenuCommand * myTransformToPerson
menu command for transform to person
Definition: GNEPerson.h:104
const GNEDemandElement * personPlan
person plan
Definition: GNEPerson.h:289
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNEPerson.cpp:310
GNEPerson * myPerson
current person
Definition: GNEPerson.h:64
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
std::pair< PositionVector, PositionVector > calculatePersonPlanConnectionBusStop(GNELane *previousLane, GNEAdditional *busStop, GNELane *nextLane)
return two shapes used for calculate person plan conections between busStops
Definition: GNEPerson.cpp:1173
std::string getBegin() const
get begin time of demand element
Definition: GNEPerson.cpp:185