Eclipse SUMO - Simulation of Urban MObility
GNERoute.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2016-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 // A class for visualizing routes in Netedit
16 /****************************************************************************/
17 #ifndef GNERoute_h
18 #define GNERoute_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 
26 
27 #include "GNEDemandElement.h"
28 #include "GNERouteHandler.h"
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class GNEEdge;
35 class GNEConnection;
36 class GNEVehicle;
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
41 
42 class GNERoute : public GNEDemandElement, public Parameterised {
43 
44 public:
45 
48  FXDECLARE(GNERoutePopupMenu)
49 
50  public:
58 
61 
63  long onCmdApplyDistance(FXObject*, FXSelector, void*);
64 
65  protected:
68  };
69 
73  GNERoute(GNEViewNet* viewNet);
74 
79  GNERoute(GNEViewNet* viewNet, const GNERouteHandler::RouteParameter& routeParameters);
80 
86  GNERoute(GNEViewNet* viewNet, GNEDemandElement* vehicleParent, const GNERouteHandler::RouteParameter& routeParameters);
87 
89  GNERoute(GNEDemandElement* route);
90 
92  ~GNERoute();
93 
97  void writeDemandElement(OutputDevice& device) const;
98 
100  bool isDemandElementValid() const;
101 
103  std::string getDemandElementProblem() const;
104 
107 
111  GNEEdge* getFromEdge() const;
112 
114  GNEEdge* getToEdge() const;
115 
117  SUMOVehicleClass getVClass() const;
118 
120  const RGBColor& getColor() const;
121 
123  void compute();
124 
126 
130  void startGeometryMoving();
131 
133  void endGeometryMoving();
134 
138  void moveGeometry(const Position& offset);
139 
143  void commitGeometryMoving(GNEUndoList* undoList);
144 
146  void updateGeometry();
147 
149  Position getPositionInView() const;
151 
154 
163 
167  std::string getParentName() const;
168 
173 
178  void drawGL(const GUIVisualizationSettings& s) const;
180 
184  void selectAttributeCarrier(bool changeFlag = true);
185 
187  void unselectAttributeCarrier(bool changeFlag = true);
188 
189  /* @brief method for getting the Attribute of an XML key
190  * @param[in] key The attribute key
191  * @return string with the value associated to key
192  */
193  std::string getAttribute(SumoXMLAttr key) const;
194 
195  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
196  * @param[in] key The attribute key
197  * @return double with the value associated to key
198  */
199  double getAttributeDouble(SumoXMLAttr key) const;
200 
201  /* @brief method for setting the attribute and letting the object perform additional changes
202  * @param[in] key The attribute key
203  * @param[in] value The new value
204  * @param[in] undoList The undoList on which to register changes
205  * @param[in] net optionally the GNENet to inform about gui updates
206  */
207  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
208 
209  /* @brief method for setting the attribute and letting the object perform additional changes
210  * @param[in] key The attribute key
211  * @param[in] value The new value
212  * @param[in] undoList The undoList on which to register changes
213  */
214  bool isValid(SumoXMLAttr key, const std::string& value);
215 
216  /* @brief method for enabling attribute
217  * @param[in] key The attribute key
218  * @param[in] undoList The undoList on which to register changes
219  * @note only certain attributes can be enabled, and can produce the disabling of other attributes
220  */
221  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
222 
223  /* @brief method for check if the value for certain attribute is set
224  * @param[in] key The attribute key
225  */
226  bool isAttributeEnabled(SumoXMLAttr key) const;
227 
229  std::string getPopUpID() const;
230 
232  std::string getHierarchyName() const;
234 
238  std::string getGenericParametersStr() const;
239 
241  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
242 
244  void setGenericParametersStr(const std::string& value);
245 
247 
248 protected:
251 
254 
255 private:
257  void setAttribute(SumoXMLAttr key, const std::string& value);
258 
260  void setEnabledAttribute(const int enabledAttributes);
261 
263  GNERoute(GNERoute*) = delete;
264 
266  GNERoute& operator=(GNERoute*) = delete;
267 };
268 
269 
270 #endif
271 
272 /****************************************************************************/
273 
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:134
GNERoute::compute
void compute()
compute demand element
Definition: GNERoute.cpp:235
GNEDemandElement
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEDemandElement.h:54
GNERoute::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNERoute.cpp:265
GNERoute::setEnabledAttribute
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNERoute.cpp:591
GNERoute::GNERoutePopupMenu::~GNERoutePopupMenu
~GNERoutePopupMenu()
Destructor.
Definition: GNERoute.cpp:58
Parameterised
An upper class for objects with additional parameters.
Definition: Parameterised.h:43
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
GNERoute::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNERoute.cpp:362
GNERoute::commitGeometryMoving
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(....
Definition: GNERoute.cpp:259
GNERoute::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
inherited from GNEAttributeCarrier
Definition: GNERoute.cpp:384
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
GNERoute::endGeometryMoving
void endGeometryMoving()
end geometry movement
Definition: GNERoute.cpp:247
GNERoute::moveGeometry
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNERoute.cpp:253
GNERoute::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNERoute.cpp:501
GUIGLObjectPopupMenu.h
GNERoute
Definition: GNERoute.h:42
GNERoute::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNERoute.cpp:459
GNERoute::getAttributeDouble
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNERoute.cpp:434
GNEViewNet
Definition: GNEViewNet.h:43
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:48
GNERoute::getPositionInView
Position getPositionInView() const
Returns position of additional in view.
Definition: GNERoute.cpp:350
GNERoute::fixDemandElementProblem
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNERoute.cpp:205
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
GNERoute::myVClass
SUMOVehicleClass myVClass
SUMOVehicleClass (Only used for drawing)
Definition: GNERoute.h:253
GNERoute::writeDemandElement
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNERoute.cpp:147
GNERoute::GNERoutePopupMenu::GNERoutePopupMenu
GNERoutePopupMenu()
default constructor needed by FOX
Definition: GNERoute.h:67
GNERouteHandler::RouteParameter
struct for saving route parameters
Definition: GNERouteHandler.h:54
RGBColor
Definition: RGBColor.h:40
GNERoute::startGeometryMoving
void startGeometryMoving()
Definition: GNERoute.cpp:241
GNERoute::GNERoutePopupMenu::onCmdApplyDistance
long onCmdApplyDistance(FXObject *, FXSelector, void *)
Called to modify edge distance values along the route.
Definition: GNERoute.cpp:62
GNEDemandElement.h
GNERoute::getFromEdge
GNEEdge * getFromEdge() const
Definition: GNERoute.cpp:211
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GNERoute::getToEdge
GNEEdge * getToEdge() const
obtain to edge of this demand element
Definition: GNERoute.cpp:217
GNERoute::isDemandElementValid
bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNERoute.cpp:169
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GNERoute::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNERoute.cpp:415
GUIGlObject
Definition: GUIGlObject.h:66
GNERoute::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNERoute.cpp:399
GNERoute::getDemandElementProblem
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNERoute.cpp:188
GNERoute::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNERoute.cpp:489
GUIMainWindow
Definition: GUIMainWindow.h:47
GNERoute::myColor
RGBColor myColor
route color
Definition: GNERoute.h:250
GNERoute::getGenericParametersStr
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNERoute.cpp:507
GNERoute::getParentName
std::string getParentName() const
Returns the name of the parent object.
Definition: GNERoute.cpp:356
GNERoute::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
Definition: GNERoute.cpp:440
GNERoute::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNERoute.cpp:495
GNERoute::~GNERoute
~GNERoute()
destructor
Definition: GNERoute.cpp:116
GNEVehicle
Definition: GNEVehicle.h:36
GNERoute::enableAttribute
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERoute.cpp:483
GNEConnection
Definition: GNEConnection.h:38
GNERoute::GNERoutePopupMenu
class used in GUIGLObjectPopupMenu for routes
Definition: GNERoute.h:47
GNERoute::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNERoute.cpp:378
GNERoute::operator=
GNERoute & operator=(GNERoute *)=delete
Invalidated assignment operator.
GNEUndoList
Definition: GNEUndoList.h:49
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
GNERoute::setGenericParametersStr
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNERoute.cpp:533
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:373
GNERoute::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNERoute.cpp:120
GNERoute::GNERoute
GNERoute(GNEViewNet *viewNet)
default constructor
Definition: GNERoute.cpp:80
GNERoute::getGenericParameters
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
Definition: GNERoute.cpp:522
GNERoute::getVClass
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition: GNERoute.cpp:223
GNERouteHandler.h
GNERoute::getColor
const RGBColor & getColor() const
get color
Definition: GNERoute.cpp:229