SUMO - Simulation of Urban MObility
GNEAdditional.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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // A abstract class for representation of additional elements
18 /****************************************************************************/
19 #ifndef GNEAdditional_h
20 #define GNEAdditional_h
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <string>
33 #include <vector>
37 
38 #include "GNEAttributeCarrier.h"
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 
45 class GNEEdge;
46 class GNELane;
47 class GNENet;
48 class GNEViewNet;
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
54 
60 
61 public:
69  GNEAdditional(const std::string& id, GNEViewNet* viewNet, SumoXMLTag tag, GUIIcon icon, bool movable);
70 
79  GNEAdditional(const std::string& id, GNEViewNet* viewNet, SumoXMLTag tag, GUIIcon icon, bool movable, GNEAdditional* additionalParent);
80 
89  GNEAdditional(const std::string& id, GNEViewNet* viewNet, SumoXMLTag tag, GUIIcon icon, bool movable, std::vector<GNEEdge*> edgeChilds);
90 
99  GNEAdditional(const std::string& id, GNEViewNet* viewNet, SumoXMLTag tag, GUIIcon icon, bool movable, std::vector<GNELane*> laneChilds);
100 
102  ~GNEAdditional();
103 
107  virtual void writeAdditional(OutputDevice& device) const = 0;
108 
113  virtual void openAdditionalDialog();
114 
117 
121  virtual void moveGeometry(const Position& oldPos, const Position& offset) = 0;
122 
127  virtual void commitGeometryMoving(const Position& oldPos, GNEUndoList* undoList) = 0;
128 
130  virtual void updateGeometry() = 0;
131 
133  virtual Position getPositionInView() const = 0;
135 
137  GNEViewNet* getViewNet() const;
138 
140  PositionVector getShape() const;
141 
143  bool isAdditionalBlocked() const;
144 
145  // @brief Check if additional item is selected
146  bool isAdditionalSelected() const;
147 
148  // @brief get additional parent
150 
153 
155  void addAdditionalChild(GNEAdditional* additional);
156 
158  void removeAdditionalChild(GNEAdditional* additional);
159 
161  const std::vector<GNEAdditional*>& getAdditionalChilds() const;
162 
164  void addEdgeChild(GNEEdge* edge);
165 
167  void removeEdgeChild(GNEEdge* edge);
168 
170  const std::vector<GNEEdge*>& getEdgeChilds() const;
171 
173  void addLaneChild(GNELane* lane);
174 
176  void removeLaneChild(GNELane* lane);
177 
179  const std::vector<GNELane*>& getLaneChilds() const;
180 
182 
186  virtual const std::string& getParentName() const = 0;
187 
196 
205 
211 
216  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
218 
221  /* @brief method for getting the Attribute of an XML key
222  * @param[in] key The attribute key
223  * @return string with the value associated to key
224  */
225  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
226 
232  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
233 
239  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
241 
246  static bool isRouteValid(const std::vector<GNEEdge*>& edges, bool report);
247 
248 protected:
251 
256 
260  std::vector<double> myShapeRotations;
261 
263  std::vector<double> myShapeLengths;
265 
267  bool myBlocked;
268 
271 
273  std::vector<GNEAdditional*> myAdditionalChilds;
274 
276  std::vector<GNEEdge*> myEdgeChilds;
277 
279  std::vector<GNELane*> myLaneChilds;
280 
284  void setBlockIconRotation(GNELane* additionalLane = NULL);
285 
287  void drawLockIcon(double size = 0.5) const;
288 
291 
294 
298 
301 
303  const std::string& getAdditionalID() const;
304 
306  bool isValidAdditionalID(const std::string& newID) const;
307 
312  void changeAdditionalID(const std::string& newID);
313 
318  GNEEdge* changeEdge(GNEEdge* oldEdge, const std::string& newEdgeID);
319 
324  GNELane* changeLane(GNELane* oldLane, const std::string& newLaneID);
325 
330  void changeAdditionalParent(const std::string& newAdditionalParentID);
331 
333 
336 
338  void updateChildConnections();
339 
341  void drawChildConnections() const;
342 
344  std::vector<std::pair<Position, double> > mySymbolsPositionAndRotation;
346 
347 private:
349  bool myMovable;
350 
352  std::vector<std::vector<Position> > myChildConnectionPositions;
353 
355  GNEAdditional(const GNEAdditional&) = delete;
356 
358  GNEAdditional& operator=(const GNEAdditional&) = delete;
359 };
360 
361 #endif
void removeEdgeChild(GNEEdge *edge)
remove edge child
GNEAdditional(const std::string &id, GNEViewNet *viewNet, SumoXMLTag tag, GUIIcon icon, bool movable)
Constructor.
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their conrrespond attribute are valids
virtual void openAdditionalDialog()
open Additional Dialog
void addEdgeChild(GNEEdge *edge)
add edge child
SumoXMLTag
Numbers representing SUMO-XML - element names.
bool isAdditionalBlocked() const
Check if additional item is currently blocked (i.e. cannot be moved with mouse)
void removeAdditionalChild(GNEAdditional *additional)
remove additional child from this additional
const std::vector< GNEEdge * > & getEdgeChilds() const
get edge chidls
const std::string & getAdditionalID() const
returns Additional ID
const std::vector< GNELane * > & getLaneChilds() const
get lanes of VSS
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:42
Stores the information about how to visualize structures.
virtual const std::string & getParentName() const =0
Returns the name of the parent object (if any)
Dialog to edit sequences, parameters, etc.. of Additionals.
PositionVector getShape() const
Returns additional element&#39;s shape.
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes ...
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:91
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:53
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
std::vector< double > myShapeRotations
void changeAdditionalID(const std::string &newID)
change ID of additional
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
virtual std::string getAttribute(SumoXMLAttr key) const =0
This functions has to be implemented in all GNEAttributeCarriers.
virtual void commitGeometryMoving(const Position &oldPos, GNEUndoList *undoList)=0
commit geometry changes in the attributes of an element after use of moveGeometry(...)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
std::vector< std::vector< Position > > myChildConnectionPositions
Matrix with the Vertex&#39;s positions of connections between parents an their childs.
GNEAdditional * myAdditionalParent
pointer to Addititional parent
void drawChildConnections() const
draw connections between Parent and childrens
void drawLockIcon(double size=0.5) const
draw lock icon
bool myMovable
flag to check if this additional is movable
PositionVector myShape
The shape of the additional element.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
A list of positions.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
virtual void moveGeometry(const Position &oldPos, const Position &offset)=0
change the position of the element geometry without saving in undoList
std::vector< double > myShapeLengths
The lengths of the shape parts.
void updateChildConnections()
update Connection&#39;s geometry
~GNEAdditional()
Destructor.
Position myBlockIconOffset
The offSet of the block icon.
std::vector< GNEAdditional * > myAdditionalChilds
vector with the Additional childs
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:56
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which additional element is located.
bool myBlocked
boolean to check if additional element is blocked (i.e. cannot be moved with mouse) ...
GNEEdge * changeEdge(GNEEdge *oldEdge, const std::string &newEdgeID)
change edge of additional
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:59
GNEAdditional * getAdditionalParent() const
void setBlockIconRotation(GNELane *additionalLane=NULL)
std::vector< std::pair< Position, double > > mySymbolsPositionAndRotation
position and rotation of every simbol over lane
The popup menu of a globject.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
static bool isRouteValid(const std::vector< GNEEdge *> &edges, bool report)
check if a route is valid
void changeAdditionalParent(const std::string &newAdditionalParentID)
change additional parent of additional
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
bool isAdditionalSelected() const
virtual void updateGeometry()=0
update pre-computed geometry information
virtual void writeAdditional(OutputDevice &device) const =0
writte additional element into a xml file
GNEAdditional & operator=(const GNEAdditional &)=delete
Invalidated assignment operator.
void addAdditionalChild(GNEAdditional *additional)
add additional child to this additional
void removeLaneChild(GNELane *lane)
remove lane child
const std::vector< GNEAdditional * > & getAdditionalChilds() const
return vector of additionals that have as Parent this edge (For example, Calibrators) ...
A window containing a gl-object&#39;s parameter.
double myBlockIconRotation
The rotation of the block icon.
GNELane * changeLane(GNELane *oldLane, const std::string &newLaneID)
change lane of additional
void addLaneChild(GNELane *lane)
add lane child
Position myBlockIconPosition
position of the block icon
std::vector< GNELane * > myLaneChilds
vector with the lane childs of this additional
std::vector< GNEEdge * > myEdgeChilds
vector with the edge childs of this additional
virtual Position getPositionInView() const =0
Returns position of additional in view.