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-2022 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/GNEPathManager.h>
26 #include <netedit/GNEMoveElement.h>
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 
36 class GNEViewNet;
37 class GNENetworkElement;
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
43 
49 
50 public:
67  GNEAdditional(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName,
68  const std::vector<GNEJunction*>& junctionParents,
69  const std::vector<GNEEdge*>& edgeParents,
70  const std::vector<GNELane*>& laneParents,
71  const std::vector<GNEAdditional*>& additionalParents,
72  const std::vector<GNEShape*>& shapeParents,
73  const std::vector<GNETAZElement*>& TAZElementParents,
74  const std::vector<GNEDemandElement*>& demandElementParents,
75  const std::vector<GNEGenericData*>& genericDataParents,
76  const std::map<std::string, std::string>& parameters);
77 
93  GNEAdditional(GNENet* net, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName,
94  const std::vector<GNEJunction*>& junctionParents,
95  const std::vector<GNEEdge*>& edgeParents,
96  const std::vector<GNELane*>& laneParents,
97  const std::vector<GNEAdditional*>& additionalParents,
98  const std::vector<GNEShape*>& shapeParents,
99  const std::vector<GNETAZElement*>& TAZElementParents,
100  const std::vector<GNEDemandElement*>& demandElementParents,
101  const std::vector<GNEGenericData*>& genericDataParents,
102  const std::map<std::string, std::string>& parameters);
103 
105  ~GNEAdditional();
106 
111 
113  void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
114 
116  const std::string& getID() const;
117 
120 
122  const GUIGeometry& getAdditionalGeometry() const;
123 
125  void setSpecialColor(const RGBColor* color);
126 
129 
132  virtual void writeAdditional(OutputDevice& device) const = 0;
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  virtual Position getPositionInView() const = 0;
155 
157  double getExaggeration(const GUIVisualizationSettings& s) const;
158 
161 
163  virtual void updateCenteringBoundary(const bool updateGrid) = 0;
164 
166  virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) = 0;
168 
171 
180 
189 
191  const std::string& getOptionalAdditionalName() const;
192 
197  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
198 
200 
203 
205  void computePathElement();
206 
213  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const;
214 
222  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, const double offsetFront) const;
223 
225  GNELane* getFirstPathLane() const;
226 
228  GNELane* getLastPathLane() const;
229 
231  double getPathElementDepartValue() const;
232 
235 
237  double getPathElementArrivalValue() const;
238 
241 
243 
246  /* @brief method for getting the Attribute of an XML key
247  * @param[in] key The attribute key
248  * @return string with the value associated to key
249  */
250  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
251 
252  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
253  * @param[in] key The attribute key
254  * @return double with the value associated to key
255  */
256  virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
257 
263  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
264 
270  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
271 
272  /* @brief method for enable attribute
273  * @param[in] key The attribute key
274  * @param[in] undoList The undoList on which to register changes
275  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
276  */
277  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
278 
279  /* @brief method for disable attribute
280  * @param[in] key The attribute key
281  * @param[in] undoList The undoList on which to register changes
282  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
283  */
284  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
285 
286  /* @brief method for check if the value for certain attribute is set
287  * @param[in] key The attribute key
288  */
289  virtual bool isAttributeEnabled(SumoXMLAttr key) const = 0;
290 
291  /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
292  * @param[in] key The attribute key
293  */
294  bool isAttributeComputed(SumoXMLAttr key) const;
295 
297  virtual std::string getPopUpID() const = 0;
298 
300  virtual std::string getHierarchyName() const = 0;
302 
304  const std::map<std::string, std::string>& getACParametersMap() const;
305 
307  void drawParentChildLines(const GUIVisualizationSettings& s, const RGBColor& color, const bool onlySymbols = false) const;
308 
310  static void drawUpGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor);
311 
313  static void drawDownGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor);
314 
316  static void drawLeftGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor);
317 
319  static void drawRightGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor);
320 
322  int getDrawPositionIndex() const;
323 
324 protected:
327 
330 
332  std::string myAdditionalName;
333 
335  const RGBColor* mySpecialColor = nullptr;
336 
339 
341  bool isValidAdditionalID(const std::string& newID) const;
342 
344  bool isValidDetectorID(const std::string& newID) const;
345 
347 
349  void drawAdditionalID(const GUIVisualizationSettings& s) const;
350 
352  void drawAdditionalName(const GUIVisualizationSettings& s) const;
353 
355  void replaceAdditionalParentEdges(const std::string& value);
356 
358  void replaceAdditionalParentLanes(const std::string& value);
359 
361  void replaceAdditionalChildEdges(const std::string& value);
362 
364  void replaceAdditionalChildLanes(const std::string& value);
365 
367  void replaceAdditionalParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
368 
370  void replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
371 
373  void shiftLaneIndex();
374 
376  void calculatePerpendicularLine(const double endLaneposition);
377 
379  void drawSquaredAdditional(const GUIVisualizationSettings& s, const Position& pos, const double size, GUITexture texture, GUITexture selectedTexture) const;
380 
382  void drawListedAddtional(const GUIVisualizationSettings& s, const Position& parentPosition, const int offsetX, const int extraOffsetY,
383  const RGBColor baseCol, const RGBColor textCol, GUITexture texture, const std::string text) const;
384 
385 private:
389  virtual bool checkChildAdditionalRestriction() const;
390 
392  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
393 
395  virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
396 
398  virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
399 
401  virtual void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters);
402 
404  static void drawSemiCircleGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor,
405  const double fromAngle, const double toAngle);
406 
408  std::string adjustListedAdditionalText(const std::string& text) const;
409 
411  GNEAdditional(const GNEAdditional&) = delete;
412 
415 };
416 
GUIGlObjectType
GUITexture
An enumeration of gifs used by the gui applications.
Definition: GUITextures.h:31
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:48
virtual void updateCenteringBoundary(const bool updateGrid)=0
update centering boundary (implies change in RTREE)
virtual GNEMoveOperation * getMoveOperation()=0
get move operation
virtual bool isAttributeEnabled(SumoXMLAttr key) const =0
static void drawRightGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor)
draw right geometry point
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
GNELane * getLastPathLane() const
get last path lane
virtual bool isAdditionalValid() const
check if current additional is valid to be writed into XML (by default true, can be reimplemented in ...
static void drawDownGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor)
draw down geometry point
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
virtual void updateGeometry()=0
update pre-computed geometry information
virtual void writeAdditional(OutputDevice &device) const =0
writte additional element into a xml file
double getPathElementArrivalValue() const
get path element arrival lane pos
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
void replaceAdditionalParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace additional parent
std::string adjustListedAdditionalText(const std::string &text) const
adjust listed addtitional text
virtual void openAdditionalDialog()
open Additional Dialog
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
void replaceAdditionalChildLanes(const std::string &value)
replace additional child lanes
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
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
GNELane * getFirstPathLane() const
get first path lane
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
void shiftLaneIndex()
shift lane index
double getPathElementDepartValue() const
get path element depart lane pos
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
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
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
static void drawSemiCircleGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor, const double fromAngle, const double toAngle)
draw geometry point
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)
GNEAdditional(const std::string &id, GNENet *net, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, 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, const std::map< std::string, std::string > &parameters)
Constructor.
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
void drawSquaredAdditional(const GUIVisualizationSettings &s, const Position &pos, const double size, GUITexture texture, GUITexture selectedTexture) const
draw squared additional
virtual bool checkChildAdditionalRestriction() const
check restriction with the number of children
void replaceAdditionalChildEdges(const std::string &value)
replace additional child edges
void drawListedAddtional(const GUIVisualizationSettings &s, const Position &parentPosition, const int offsetX, const int extraOffsetY, const RGBColor baseCol, const RGBColor textCol, GUITexture texture, const std::string text) const
draw listed additional
virtual double getAttributeDouble(SumoXMLAttr key) const =0
void computePathElement()
compute pathElement
Position getPathElementDepartPos() const
get path element depart position
GNEAdditional & operator=(const GNEAdditional &)=delete
Invalidated assignment operator.
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
int getDrawPositionIndex() const
get draw position index (used in rerouters and VSS)
const GUIGeometry & getAdditionalGeometry() const
obtain additional geometry
Boundary myAdditionalBoundary
Additional Boundary.
virtual void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters)
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
~GNEAdditional()
Destructor.
const std::string & getOptionalAdditionalName() const
Returns the additional name.
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object (lane)
bool isAttributeComputed(SumoXMLAttr key) const
Position getPathElementArrivalPos() const
get path element arrival position
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their conrrespond attribute are valids
virtual Position getPositionInView() const =0
Returns position of additional in view.
static void drawUpGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor)
draw up geometry point
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position (Currently unused in shapes)
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
void drawParentChildLines(const GUIVisualizationSettings &s, const RGBColor &color, const bool onlySymbols=false) const
draw parent and child lines
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...
static void drawLeftGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor)
draw left geometry point
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
move element
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
class used for path 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:61
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37