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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // A abstract class for representation of additional elements
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
25 #include <netedit/GNEGeometry.h>
26 #include <netedit/GNEMoveElement.h>
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 
35 class GNEViewNet;
36 class GNENetworkElement;
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
42 
48 
49 public:
66  GNEAdditional(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement,
67  const std::vector<GNEJunction*>& junctionParents,
68  const std::vector<GNEEdge*>& edgeParents,
69  const std::vector<GNELane*>& laneParents,
70  const std::vector<GNEAdditional*>& additionalParents,
71  const std::vector<GNEShape*>& shapeParents,
72  const std::vector<GNETAZElement*>& TAZElementParents,
73  const std::vector<GNEDemandElement*>& demandElementParents,
74  const std::vector<GNEGenericData*>& genericDataParents);
75 
91  GNEAdditional(GNENet* net, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement,
92  const std::vector<GNEJunction*>& junctionParents,
93  const std::vector<GNEEdge*>& edgeParents,
94  const std::vector<GNELane*>& laneParents,
95  const std::vector<GNEAdditional*>& additionalParents,
96  const std::vector<GNEShape*>& shapeParents,
97  const std::vector<GNETAZElement*>& TAZElementParents,
98  const std::vector<GNEDemandElement*>& demandElementParents,
99  const std::vector<GNEGenericData*>& genericDataParents);
100 
102  virtual ~GNEAdditional();
103 
107  virtual GNEMoveOperation* getMoveOperation(const double shapeOffset) = 0;
108 
110  void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
111 
113  const std::string& getID() const;
114 
117 
120 
123 
125  void setSpecialColor(const RGBColor* color);
126 
129 
132  void writeAdditional(OutputDevice& device) const;
133 
135  virtual bool isAdditionalValid() const;
136 
138  virtual std::string getAdditionalProblem() const;
139 
141  virtual void fixAdditionalProblem();
143 
148  virtual void openAdditionalDialog();
149 
151  virtual void updateGeometry() = 0;
152 
154  Position getPositionInView() const;
155 
158 
160  virtual void updateCenteringBoundary(const bool updateGrid) = 0;
161 
163  virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) = 0;
165 
167  bool isAdditionalBlocked() const;
168 
170  void updatePartialGeometry(const GNELane* lane);
171 
174 
183 
192 
194  const std::string& getOptionalAdditionalName() const;
195 
200  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
201 
208  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const double offsetFront) const;
209 
217  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const double offsetFront) const;
219 
222  /* @brief method for getting the Attribute of an XML key
223  * @param[in] key The attribute key
224  * @return string with the value associated to key
225  */
226  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
227 
228  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
229  * @param[in] key The attribute key
230  * @return double with the value associated to key
231  */
232  virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
233 
239  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
240 
246  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
247 
248  /* @brief method for enable attribute
249  * @param[in] key The attribute key
250  * @param[in] undoList The undoList on which to register changes
251  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
252  */
253  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
254 
255  /* @brief method for disable attribute
256  * @param[in] key The attribute key
257  * @param[in] undoList The undoList on which to register changes
258  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
259  */
260  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
261 
262  /* @brief method for check if the value for certain attribute is set
263  * @param[in] key The attribute key
264  */
265  virtual bool isAttributeEnabled(SumoXMLAttr key) const = 0;
266 
268  virtual std::string getPopUpID() const = 0;
269 
271  virtual std::string getHierarchyName() const = 0;
273 
275  const std::map<std::string, std::string>& getACParametersMap() const;
276 
277 protected:
280 
283 
286 
288  std::string myAdditionalName;
289 
292 
295 
297  void setDefaultValues();
298 
301 
303  bool isValidAdditionalID(const std::string& newID) const;
304 
306  bool isValidDetectorID(const std::string& newID) const;
307 
309 
311  void drawAdditionalID(const GUIVisualizationSettings& s) const;
312 
314  void drawAdditionalName(const GUIVisualizationSettings& s) const;
315 
317  void replaceAdditionalParentEdges(const std::string& value);
318 
320  void replaceAdditionalParentLanes(const std::string& value);
321 
323  void replaceAdditionalChildEdges(const std::string& value);
324 
326  void replaceAdditionalChildLanes(const std::string& value);
327 
329  void replaceAdditionalParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
330 
332  void replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
333 
335  void calculatePerpendicularLine(const double endLaneposition);
336 
337 private:
341  virtual bool checkChildAdditionalRestriction() const;
342 
344  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
345 
347  virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
348 
350  virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
351 
353  void setEnabledAttribute(const int enabledAttributes);
354 
356  GNEAdditional(const GNEAdditional&) = delete;
357 
360 };
361 
GUIGlObjectType
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
bool isAdditionalBlocked() const
Check if additional item is currently blocked (i.e. cannot be moved with mouse)
virtual void updateCenteringBoundary(const bool updateGrid)=0
update centering boundary (implies change in RTREE)
virtual bool isAttributeEnabled(SumoXMLAttr key) const =0
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
virtual void setMoveShape(const GNEMoveResult &moveResult)=0
set move shape
const std::string & getID() const
get ID
virtual std::string getAttribute(SumoXMLAttr key) const =0
virtual bool isAdditionalValid() const
check if current additional is valid to be writed into XML (by default true, can be reimplemented in ...
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
virtual void updateGeometry()=0
update pre-computed geometry information
void updatePartialGeometry(const GNELane *lane)
partial update pre-computed geometry information
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
void replaceAdditionalParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace additional parent
GNEGeometry::Geometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
virtual void openAdditionalDialog()
open Additional Dialog
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
void replaceAdditionalChildLanes(const std::string &value)
replace additional child lanes
void replaceAdditionalParentEdges(const std::string &value)
replace additional parent edges
virtual std::string getPopUpID() const =0
get PopPup ID (Used in AC Hierarchy)
void drawAdditionalID(const GUIVisualizationSettings &s) const
draw additional ID
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
bool myBlockMovement
boolean to check if additional element is blocked (i.e. cannot be moved with mouse)
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Position getPositionInView() const
Returns position of additional in view.
void calculatePerpendicularLine(const double endLaneposition)
calculate perpendicular line between lane parents
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
GNEAdditional(const GNEAdditional &)=delete
Invalidated copy constructor.
std::string myAdditionalName
name of additional
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
Boundary myBoundary
Additional Boundary.
virtual void fixAdditionalProblem()
fix additional problem (by default throw an exception, has to be reimplemented in children)
void setSpecialColor(const RGBColor *color)
set special color
const RGBColor * mySpecialColor
pointer to special color (used for drawing Additional with a certain color, mainly used for selection...
virtual void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)=0
commit move shape
virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)=0
split geometry
virtual void setAttribute(SumoXMLAttr key, const std::string &value)=0
method for setting the attribute and nothing else (used in GNEChange_Attribute)
virtual std::string getHierarchyName() const =0
get Hierarchy Name (Used in AC Hierarchy)
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 bool checkChildAdditionalRestriction() const
check restriction with the number of children
GNEGeometry::SegmentGeometry myAdditionalSegmentGeometry
segment geometry to be precomputed in updateGeometry(...) (used by E2Multilane)
const GNEGeometry::SegmentGeometry & getAdditionalSegmentGeometry() const
obtain additional segment geometry
void replaceAdditionalChildEdges(const std::string &value)
replace additional child edges
virtual double getAttributeDouble(SumoXMLAttr key) const =0
GNEAdditional(const std::string &id, GNENet *net, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement, const std::vector< GNEJunction * > &junctionParents, const std::vector< GNEEdge * > &edgeParents, const std::vector< GNELane * > &laneParents, const std::vector< GNEAdditional * > &additionalParents, const std::vector< GNEShape * > &shapeParents, const std::vector< GNETAZElement * > &TAZElementParents, const std::vector< GNEDemandElement * > &demandElementParents, const std::vector< GNEGenericData * > &genericDataParents)
Constructor.
GNEAdditional & operator=(const GNEAdditional &)=delete
Invalidated assignment operator.
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
virtual GNEMoveOperation * getMoveOperation(const double shapeOffset)=0
get move operation for the given shapeOffset
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
void writeAdditional(OutputDevice &device) const
writte additional element into a xml file
virtual ~GNEAdditional()
Destructor.
const std::string & getOptionalAdditionalName() const
Returns the additional name.
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their conrrespond attribute are valids
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position (Currently unused in shapes)
const GNEGeometry::Geometry & getAdditionalGeometry() const
obtain additional geometry
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
void setDefaultValues()
change all attributes of additional with their default values (note: this cannot be undo)
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const double offsetFront) const
Draws partial object (lane)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
virtual std::string getAdditionalProblem() const
return a string with the current additional problem (by default empty, can be reimplemented in childr...
class for NETEDIT geometries over lanes
Definition: GNEGeometry.h:76
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
move element
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
An special type of Attribute carrier that owns hierarchical elements.
The popup menu of a globject.
A window containing a gl-object's parameter.
Stores the information about how to visualize structures.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
An upper class for objects with additional parameters.
Definition: Parameterised.h:39
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
struct for pack all variables related with geometry of elemements divided in segments
Definition: GNEGeometry.h:261