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-2018 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 abstract class for representation of additional elements
16 /****************************************************************************/
17 #ifndef GNEAdditional_h
18 #define GNEAdditional_h
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 
24 #include <config.h>
25 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 
35 class GNEEdge;
36 class GNELane;
37 class GNEViewNet;
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
43 
49 
50 public:
59  GNEAdditional(const std::string& id, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement);
60 
69  GNEAdditional(GNEAdditional* singleAdditionalParent, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement);
70 
80  GNEAdditional(GNEAdditional* firstAdditionalParent, GNEAdditional* secondAdditionalParent, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement);
81 
91  GNEAdditional(const std::string& id, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement, std::vector<GNEEdge*> edgeChilds);
92 
102  GNEAdditional(const std::string& id, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement, std::vector<GNELane*> laneChilds);
103 
105  ~GNEAdditional();
106 
109 
112  void writeAdditional(OutputDevice& device) const;
113 
115  virtual bool isAdditionalValid() const;
116 
118  virtual std::string getAdditionalProblem() const;
119 
121  virtual void fixAdditionalProblem();
123 
128  virtual void openAdditionalDialog();
129 
133  void startGeometryMoving();
134 
136  void endGeometryMoving();
137 
141  virtual void moveGeometry(const Position& offset) = 0;
142 
146  virtual void commitGeometryMoving(GNEUndoList* undoList) = 0;
147 
149  virtual void updateGeometry(bool updateGrid) = 0;
150 
152  virtual Position getPositionInView() const = 0;
154 
156  GNEViewNet* getViewNet() const;
157 
159  PositionVector getShape() const;
160 
162  bool isAdditionalBlocked() const;
163 
164  // @brief get first additional parent
166 
167  // @brief get second additional parent
169 
171  std::string generateAdditionalChildID(SumoXMLTag childTag);
172 
175 
177  void addAdditionalChild(GNEAdditional* additional);
178 
180  void removeAdditionalChild(GNEAdditional* additional);
181 
183  const std::vector<GNEAdditional*>& getAdditionalChilds() const;
184 
186  void sortAdditionalChilds();
187 
190 
192  void addEdgeChild(GNEEdge* edge);
193 
195  void removeEdgeChild(GNEEdge* edge);
196 
198  const std::vector<GNEEdge*>& getEdgeChilds() const;
199 
201  void addLaneChild(GNELane* lane);
202 
204  void removeLaneChild(GNELane* lane);
205 
207  const std::vector<GNELane*>& getLaneChilds() const;
208 
210 
213 
222 
231 
236 
241  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
243 
247  void selectAttributeCarrier(bool changeFlag = true);
248 
250  void unselectAttributeCarrier(bool changeFlag = true);
251 
253  bool isAttributeCarrierSelected() const;
254 
255  /* @brief method for getting the Attribute of an XML key
256  * @param[in] key The attribute key
257  * @return string with the value associated to key
258  */
259  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
260 
266  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
267 
273  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
274 
276  virtual std::string getPopUpID() const = 0;
277 
279  virtual std::string getHierarchyName() const = 0;
281 
284 
286  std::string getGenericParametersStr() const;
287 
289  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
290 
292  void setGenericParametersStr(const std::string& value);
293 
295 
300  static bool isRouteValid(const std::vector<GNEEdge*>& edges, bool report);
301 
303  virtual void updateAdditionalParent();
304 
305 protected:
310 
312  void clearGeometry();
313 
316 
319 
322 
325 
327  std::vector<PositionVector> multiShape;
328 
330  std::vector<double> shapeRotations;
331 
333  std::vector<double> shapeLengths;
334 
336  std::vector<std::vector<double> > multiShapeRotations;
337 
339  std::vector<std::vector<double> > multiShapeLengths;
340 
343  };
344 
346  struct AdditionalMove {
349 
352 
355 
358  };
359 
361  struct BlockIcon {
363  BlockIcon(GNEAdditional *additional);
364 
366  void setRotation(GNELane* additionalLane = nullptr);
367 
369  void draw(double size = 0.5) const;
370 
371  private:
374 
375  public:
378 
381 
383  double rotation;
384  };
385 
389  ChildConnections(GNEAdditional *additional);
390 
392  void update();
393 
395  void draw() const;
396 
398  std::vector<std::pair<Position, double> > symbolsPositionAndRotation;
399 
401  std::vector<PositionVector> connectionPositions;
402 
403  private:
406  };
407 
410 
413 
416 
418  std::string myAdditionalName;
419 
422 
425 
428 
430  std::vector<GNEAdditional*> myAdditionalChilds;
431 
433  std::vector<GNEEdge*> myEdgeChilds;
434 
436  std::vector<GNELane*> myLaneChilds;
437 
440 
443 
445  void setDefaultValues();
446 
449 
451  const std::string& getAdditionalID() const;
452 
454  bool isValidAdditionalID(const std::string& newID) const;
455 
457  bool isValidDetectorID(const std::string& newID) const;
458 
463  void changeAdditionalID(const std::string& newID);
464 
469  GNEEdge* changeEdge(GNEEdge* oldEdge, const std::string& newEdgeID);
470 
475  GNELane* changeLane(GNELane* oldLane, const std::string& newLaneID);
476 
481  void changeFirstAdditionalParent(const std::string& newAdditionalParentID);
482 
487  void changeSecondAdditionalParent(const std::string& newAdditionalParentID);
489 
490 private:
494  virtual bool checkAdditionalChildRestriction() const;
495 
497  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
498 
500  void mouseOverObject(const GUIVisualizationSettings& s) const;
501 
503  GNEAdditional(const GNEAdditional&) = delete;
504 
506  GNEAdditional& operator=(const GNEAdditional&) = delete;
507 };
508 
509 #endif
void removeEdgeChild(GNEEdge *edge)
remove edge child
virtual std::string getPopUpID() const =0
get PopPup ID (Used in AC Hierarchy)
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
virtual void fixAdditionalProblem()
fix additional problem (by default throw an exception, has to be reimplemented in childs) ...
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 writeAdditional(OutputDevice &device) const
writte additional element into a xml file
void removeAdditionalChild(GNEAdditional *additional)
remove additional child from this additional
PositionVector multiShapeUnified
multi shape unified
void calculateMultiShapeRotationsAndLengths()
calculate multi shape rotations and lenghts
std::vector< double > shapeRotations
The rotations of the single shape parts.
GUIGlObjectType
const std::vector< GNEEdge * > & getEdgeChilds() const
get edge chidls
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
const std::string & getAdditionalID() const
returns Additional ID
const std::vector< GNELane * > & getLaneChilds() const
get lanes of VSS
void changeFirstAdditionalParent(const std::string &newAdditionalParentID)
change first additional parent of additional
std::string secondOriginalPosition
value for saving second original position over lane before moving
GNEAdditional(const std::string &id, GNEViewNet *viewNet, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement)
Constructor.
struct for pack all variables related with geometry of elemement
GNEAdditional * myAdditional
pointer to additional parent
Stores the information about how to visualize structures.
Position offset
The offSet of the block icon.
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
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.
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Position position
position of the block icon
BlockIcon myBlockIcon
variable BlockIcon
void clearGeometry()
reset geometry
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:47
Position originalViewPosition
value for saving first original position over lane before moving
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void setDefaultValues()
change all attributes of additional with their default values (note: this cannot be undo) ...
virtual bool checkAdditionalChildRestriction() const
check restriction with the number of childs
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
virtual bool isAdditionalValid() const
check if current additional is valid to be writed into XML (by default true, can be reimplemented in ...
void changeAdditionalID(const std::string &newID)
change ID of additional
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
virtual std::string getAttribute(SumoXMLAttr key) const =0
std::vector< std::pair< Position, double > > symbolsPositionAndRotation
position and rotation of every symbol over lane
double rotation
The rotation of the block icon.
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
std::vector< std::vector< double > > multiShapeRotations
The rotations of the multi-shape parts.
virtual std::string getAdditionalProblem() const
return a string with the current additional problem (by default empty, can be reimplemented in childs...
virtual std::string getHierarchyName() const =0
get Hierarchy Name (Used in AC Hierarchy)
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
AdditionalMove myMove
variable AdditionalMove
struct for pack all variables and functions related with Block Icon
GNEAdditional * getSecondAdditionalParent() const
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
PositionVector shape
The shape of the additional element.
A list of positions.
std::string myAdditionalName
name of additional
std::vector< PositionVector > connectionPositions
Matrix with the Vertex&#39;s positions of connections between parents an their childs.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
void selectAttributeCarrier(bool changeFlag=true)
std::vector< std::vector< double > > multiShapeLengths
The lengths of the multi-shape shape parts.
ChildConnections myChildConnections
variable ChildConnections
void sortAdditionalChilds()
sort childs (used by Rerouters and VSS)
~GNEAdditional()
Destructor.
std::vector< PositionVector > multiShape
The multi-shape of the additional element (used by certain additionals)
An upper class for objects with additional parameters.
Definition: Parameterised.h:44
virtual void updateGeometry(bool updateGrid)=0
update pre-computed geometry information
bool myBlockMovement
boolean to check if additional element is blocked (i.e. cannot be moved with mouse) ...
std::vector< GNEAdditional * > myAdditionalChilds
vector with the Additional childs
void calculateShapeRotationsAndLengths()
calculate shape rotations and lenghts
std::vector< double > shapeLengths
The lengths of the single shape parts.
GNEAdditional * getFirstAdditionalParent() const
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
void changeSecondAdditionalParent(const std::string &newAdditionalParentID)
change second additional parent of additional
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which additional element is located.
virtual void updateAdditionalParent()
update parent after add or remove a child (can be reimplemented, for example used for stadistics) ...
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:48
AdditionalGeometry myGeometry
geometry to be precomputed in updateGeometry(...)
virtual void commitGeometryMoving(GNEUndoList *undoList)=0
commit geometry changes in the attributes of an element after use of moveGeometry(...)
Boundary movingGeometryBoundary
boundary used during moving of elements (to avoid insertion in RTREE
The popup menu of a globject.
std::string getGenericParametersStr() const
return generic parameters in string format
std::string generateAdditionalChildID(SumoXMLTag childTag)
gererate a new ID for an additional child
struct for pack all variables and functions relative to connections between Additionals and their chi...
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
static bool isRouteValid(const std::vector< GNEEdge *> &edges, bool report)
check if a route is valid
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
virtual void moveGeometry(const Position &offset)=0
change the position of the element geometry without saving in undoList
void mouseOverObject(const GUIVisualizationSettings &s) const
method for check if mouse is over objects
std::string firstOriginalLanePosition
value for saving first original position over lane before moving
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
void endGeometryMoving()
begin movement (used when user click over additional to start a movement, to avoid problems with prob...
bool checkAdditionalChildsOverlapping() const
check if childs are overlapped (Used by Rerouters)
const std::vector< GNEAdditional * > & getAdditionalChilds() const
return vector of additionals that have as Parent this edge (For example, Calibrators) ...
struct for pack all variables related with additional move
void startGeometryMoving()
A window containing a gl-object&#39;s parameter.
GNEAdditional * myAdditional
pointer to additional parent
GNEAdditional * myFirstAdditionalParent
pointer to first Additional parent
GNELane * changeLane(GNELane *oldLane, const std::string &newLaneID)
change lane of additional
void addLaneChild(GNELane *lane)
add lane child
std::vector< GNELane * > myLaneChilds
vector with the lane childs of this additional
void calculateMultiShapeUnified()
calculate multi shape unified
GNEAdditional * mySecondAdditionalParent
pointer to second Additional parent
std::vector< GNEEdge * > myEdgeChilds
vector with the edge childs of this additional
virtual Position getPositionInView() const =0
Returns position of additional in view.