Eclipse 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-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 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 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 
36 class GNEViewNet;
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
42 
48 
49 public:
54 
56  void clearGeometry();
57 
60 
63 
66 
69 
71  std::vector<PositionVector> multiShape;
72 
74  std::vector<double> shapeRotations;
75 
77  std::vector<double> shapeLengths;
78 
80  std::vector<std::vector<double> > multiShapeRotations;
81 
83  std::vector<std::vector<double> > multiShapeLengths;
84 
87  };
88 
107  GNEAdditional(const std::string& id, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement,
108  const std::vector<GNEEdge*>& edgeParents,
109  const std::vector<GNELane*>& laneParents,
110  const std::vector<GNEShape*>& shapeParents,
111  const std::vector<GNEAdditional*>& additionalParents,
112  const std::vector<GNEDemandElement*>& demandElementParents,
113  const std::vector<GNEEdge*>& edgeChildren,
114  const std::vector<GNELane*>& laneChildren,
115  const std::vector<GNEShape*>& shapeChildren,
116  const std::vector<GNEAdditional*>& additionalChildren,
117  const std::vector<GNEDemandElement*>& demandElementChildren);
118 
137  GNEAdditional(GNEAdditional* additionalParent, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement,
138  const std::vector<GNEEdge*>& edgeParents,
139  const std::vector<GNELane*>& laneParents,
140  const std::vector<GNEShape*>& shapeParents,
141  const std::vector<GNEAdditional*>& additionalParents,
142  const std::vector<GNEDemandElement*>& demandElementParents,
143  const std::vector<GNEEdge*>& edgeChildren,
144  const std::vector<GNELane*>& laneChildren,
145  const std::vector<GNEShape*>& shapeChildren,
146  const std::vector<GNEAdditional*>& additionalChildren,
147  const std::vector<GNEDemandElement*>& demandElementChildren);
148 
150  ~GNEAdditional();
151 
153  std::string generateChildID(SumoXMLTag childTag);
154 
157 
159  void setSpecialColor(const RGBColor* color);
160 
163 
166  void writeAdditional(OutputDevice& device) const;
167 
169  virtual bool isAdditionalValid() const;
170 
172  virtual std::string getAdditionalProblem() const;
173 
175  virtual void fixAdditionalProblem();
177 
182  virtual void openAdditionalDialog();
183 
187  void startGeometryMoving();
188 
190  void endGeometryMoving();
191 
195  virtual void moveGeometry(const Position& offset) = 0;
196 
200  virtual void commitGeometryMoving(GNEUndoList* undoList) = 0;
201 
203  virtual void updateGeometry() = 0;
204 
206  virtual Position getPositionInView() const = 0;
207 
209  virtual Boundary getCenteringBoundary() const = 0;
211 
213  GNEViewNet* getViewNet() const;
214 
216  PositionVector getShape() const;
217 
219  bool isAdditionalBlocked() const;
220 
223 
232 
241 
243  const std::string getOptionalName() const {
244  return myAdditionalName;
245  }
246 
251  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
253 
257  void selectAttributeCarrier(bool changeFlag = true);
258 
260  void unselectAttributeCarrier(bool changeFlag = true);
261 
263  bool isAttributeCarrierSelected() const;
264 
266  bool drawUsingSelectColor() const;
267 
268  /* @brief method for getting the Attribute of an XML key
269  * @param[in] key The attribute key
270  * @return string with the value associated to key
271  */
272  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
273 
279  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
280 
286  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
287 
288  /* @brief method for enabling attribute
289  * @param[in] key The attribute key
290  * @param[in] undoList The undoList on which to register changes
291  * @note only certain attributes can be enabled, and can produce the disabling of other attributes
292  */
293  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
294 
295  /* @brief method for check if the value for certain attribute is set
296  * @param[in] key The attribute key
297  */
298  bool isAttributeEnabled(SumoXMLAttr key) const;
299 
301  virtual std::string getPopUpID() const = 0;
302 
304  virtual std::string getHierarchyName() const = 0;
306 
309 
311  std::string getGenericParametersStr() const;
312 
314  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
315 
317  void setGenericParametersStr(const std::string& value);
318 
320 
321 protected:
322 
324  struct AdditionalMove {
327 
330 
333 
336  };
337 
339  struct BlockIcon {
341  BlockIcon(GNEAdditional* additional);
342 
344  void setRotation(GNELane* additionalLane = nullptr);
345 
347  void drawIcon(const GUIVisualizationSettings& s, const double exaggeration, const double size = 0.5) const;
348 
349  public:
352 
355 
357  double rotation;
358 
359  private:
362  };
363 
366 
369 
372 
374  std::string myAdditionalName;
375 
378 
381 
384 
386  void setDefaultValues();
387 
391  const std::string& getAdditionalID() const;
392 
394  bool isValidAdditionalID(const std::string& newID) const;
395 
397  bool isValidDetectorID(const std::string& newID) const;
398 
403  void changeAdditionalID(const std::string& newID);
404 
406 
407 private:
411  virtual bool checkAdditionalChildRestriction() const;
412 
414  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
415 
417  void setEnabledAttribute(const int enabledAttributes);
418 
420  GNEAdditional(const GNEAdditional&) = delete;
421 
423  GNEAdditional& operator=(const GNEAdditional&) = delete;
424 };
425 
426 #endif
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
virtual void fixAdditionalProblem()
fix additional problem (by default throw an exception, has to be reimplemented in children) ...
An special type of Attribute carrier that owns hierarchical elements.
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
PositionVector multiShapeUnified
multi shape unified
Definition: GNEAdditional.h:86
void calculateMultiShapeRotationsAndLengths()
calculate multi shape rotations and lenghts
std::vector< double > shapeRotations
The rotations of the single shape parts.
Definition: GNEAdditional.h:74
GUIGlObjectType
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
const std::string & getAdditionalID() const
std::string secondOriginalPosition
value for saving second original position over lane before moving
struct for pack all variables related with geometry of elemement
Definition: GNEAdditional.h:51
GNEAdditional * myAdditional
pointer to additional parent
Stores the information about how to visualize structures.
virtual Boundary getCenteringBoundary() const =0
Returns the boundary to which the view shall be centered in order to show the object.
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.
bool isAttributeEnabled(SumoXMLAttr key) const
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:46
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) ...
const RGBColor * mySpecialColor
pointer to special color (used for drawing Additional with a certain color, mainly used for selection...
virtual bool checkAdditionalChildRestriction() const
check restriction with the number of children
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const AdditionalGeometry & getAdditionalGeometry() const
obtain AdditionalGeometry
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
GNEAdditional(const std::string &id, GNEViewNet *viewNet, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement, const std::vector< GNEEdge *> &edgeParents, const std::vector< GNELane *> &laneParents, const std::vector< GNEShape *> &shapeParents, const std::vector< GNEAdditional *> &additionalParents, const std::vector< GNEDemandElement *> &demandElementParents, const std::vector< GNEEdge *> &edgeChildren, const std::vector< GNELane *> &laneChildren, const std::vector< GNEShape *> &shapeChildren, const std::vector< GNEAdditional *> &additionalChildren, const std::vector< GNEDemandElement *> &demandElementChildren)
Constructor.
double rotation
The rotation of the block icon.
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute) ...
std::vector< std::vector< double > > multiShapeRotations
The rotations of the multi-shape parts.
Definition: GNEAdditional.h:80
virtual std::string getAdditionalProblem() const
return a string with the current additional problem (by default empty, can be reimplemented in childr...
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
An special type of Attribute carrier that owns hierarchical elements.
struct for pack all variables and functions related with Block Icon
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
PositionVector shape
The shape of the additional element.
Definition: GNEAdditional.h:68
A list of positions.
std::string myAdditionalName
name of additional
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.
Definition: GNEAdditional.h:83
~GNEAdditional()
Destructor.
std::vector< PositionVector > multiShape
The multi-shape of the additional element (used by certain additionals)
Definition: GNEAdditional.h:71
void setSpecialColor(const RGBColor *color)
set special color
An upper class for objects with additional parameters.
Definition: Parameterised.h:43
bool myBlockMovement
boolean to check if additional element is blocked (i.e. cannot be moved with mouse) ...
void calculateShapeRotationsAndLengths()
calculate shape rotations and lenghts
std::vector< double > shapeLengths
The lengths of the single shape parts.
Definition: GNEAdditional.h:77
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which additional element is located.
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
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
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
const std::string getOptionalName() const
Returns the additional name.
virtual void moveGeometry(const Position &offset)=0
change the position of the element geometry without saving in undoList
virtual void updateGeometry()=0
update pre-computed geometry information
std::string firstOriginalLanePosition
value for saving first original position over lane before moving
GNEAdditional & operator=(const GNEAdditional &)=delete
Invalidated assignment operator.
void endGeometryMoving()
begin movement (used when user click over additional to start a movement, to avoid problems with prob...
struct for pack all variables related with additional move
void startGeometryMoving()
A window containing a gl-object&#39;s parameter.
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
void calculateMultiShapeUnified()
calculate multi shape unified
virtual Position getPositionInView() const =0
Returns position of additional in view.