Eclipse SUMO - Simulation of Urban MObility
GNEGenericData.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 data sets
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
31 #include <netedit/GNEPathManager.h>
36 #include <netbuild/NBVehicle.h>
37 #include <netbuild/NBEdge.h>
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 
43 class GNEViewNet;
44 class GNEDataInterval;
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
49 
55 
56 public:
71  GNEGenericData(const SumoXMLTag tag, const GUIGlObjectType type, GNEDataInterval* dataIntervalParent,
72  const std::map<std::string, std::string>& parameters,
73  const std::vector<GNEJunction*>& junctionParents,
74  const std::vector<GNEEdge*>& edgeParents,
75  const std::vector<GNELane*>& laneParents,
76  const std::vector<GNEAdditional*>& additionalParents,
77  const std::vector<GNEShape*>& shapeParents,
78  const std::vector<GNETAZElement*>& TAZElementParents,
79  const std::vector<GNEDemandElement*>& demandElementParents,
80  const std::vector<GNEGenericData*>& genericDataParents);
81 
83  virtual ~GNEGenericData();
84 
86  virtual const RGBColor& getColor() const = 0;
87 
89  virtual bool isGenericDataVisible() const = 0;
90 
92  const std::string& getID() const;
93 
96 
99 
100  // @brief draw attribute
101  void drawAttribute(const PositionVector& shape) const;
102 
104  virtual void updateGeometry() = 0;
105 
107  virtual Position getPositionInView() const = 0;
108 
111 
114  virtual void writeGenericData(OutputDevice& device) const = 0;
115 
117  virtual bool isGenericDataValid() const;
118 
120  virtual std::string getGenericDataProblem() const;
121 
123  virtual void fixGenericDataProblem();
125 
128 
136 
145 
150  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
151 
153  virtual double getExaggeration(const GUIVisualizationSettings& s) const = 0;
154 
156  virtual Boundary getCenteringBoundary() const = 0;
157 
159 
162 
164  virtual void computePathElement() = 0;
165 
172  virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const = 0;
173 
181  virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, const double offsetFront) const = 0;
182 
184  virtual GNELane* getFirstPathLane() const = 0;
185 
187  virtual GNELane* getLastPathLane() const = 0;
188 
190  double getPathElementDepartValue() const;
191 
194 
196  double getPathElementArrivalValue() const;
197 
200 
202 
205  /* @brief method for getting the Attribute of an XML key
206  * @param[in] key The attribute key
207  * @return string with the value associated to key
208  */
209  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
210 
211  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
212  * @param[in] key The attribute key
213  * @return double with the value associated to key
214  */
215  virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
216 
222  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
223 
229  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
230 
231  /* @brief method for enable attribute
232  * @param[in] key The attribute key
233  * @param[in] undoList The undoList on which to register changes
234  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
235  */
236  virtual void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList) = 0;
237 
238  /* @brief method for disable attribute
239  * @param[in] key The attribute key
240  * @param[in] undoList The undoList on which to register changes
241  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
242  */
243  virtual void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList) = 0;
244 
245  /* @brief method for check if the value for certain attribute is set
246  * @param[in] key The attribute key
247  */
248  virtual bool isAttributeEnabled(SumoXMLAttr key) const = 0;
249 
250  /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
251  * @param[in] key The attribute key
252  */
253  bool isAttributeComputed(SumoXMLAttr key) const;
254 
256  virtual std::string getPopUpID() const = 0;
257 
259  virtual std::string getHierarchyName() const = 0;
261 
263  const std::map<std::string, std::string>& getACParametersMap() const;
264 
265 protected:
268 
270  void drawFilteredAttribute(const GUIVisualizationSettings& s, const PositionVector& laneShape, const std::string& attribute) const;
271 
273  bool isVisibleInspectDeleteSelect() const;
274 
276  void replaceFirstParentEdge(const std::string& value);
277 
279  void replaceLastParentEdge(const std::string& value);
280 
282  void replaceFirstParentTAZElement(SumoXMLTag tag, const std::string& value);
283 
285  void replaceSecondParentTAZElement(SumoXMLTag tag, const std::string& value);
286 
287 private:
289  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
290 
292  virtual void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters) = 0;
293 
295  GNEGenericData(const GNEGenericData&) = delete;
296 
299 };
300 
301 /****************************************************************************/
302 
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.
An Element which don't belongs to GNENet but has influency in the simulation.
GNEGenericData(const SumoXMLTag tag, const GUIGlObjectType type, GNEDataInterval *dataIntervalParent, const std::map< std::string, std::string > &parameters, 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.
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
Position getPathElementDepartPos() const
get path element depart position
virtual GNELane * getFirstPathLane() const =0
get first path lane
virtual void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters)=0
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
virtual const RGBColor & getColor() const =0
get generic data color
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
virtual double getExaggeration(const GUIVisualizationSettings &s) const =0
return exaggeration asociated with this GLObject
virtual void computePathElement()=0
compute pathElement
void replaceSecondParentTAZElement(SumoXMLTag tag, const std::string &value)
replace the second parent TAZElement
virtual void writeGenericData(OutputDevice &device) const =0
writte data set element into a xml file
GNEGenericData(const GNEGenericData &)=delete
Invalidated copy constructor.
virtual bool isGenericDataVisible() const =0
check if current generic data is visible
double getPathElementDepartValue() const
get path element depart lane pos
virtual void fixGenericDataProblem()
fix data set problem (by default throw an exception, has to be reimplemented in children)
double getPathElementArrivalValue() const
get path element arrival lane pos
void drawAttribute(const PositionVector &shape) const
virtual GNELane * getLastPathLane() const =0
get last path lane
bool isAttributeComputed(SumoXMLAttr key) const
virtual void updateGeometry()=0
update pre-computed geometry information
void drawFilteredAttribute(const GUIVisualizationSettings &s, const PositionVector &laneShape, const std::string &attribute) const
draw filtered attribute
virtual void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *fromLane, const GNELane *toLane, const GNEPathManager::Segment *segment, const double offsetFront) const =0
Draws partial object (junction)
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform data set changes
virtual std::string getGenericDataProblem() const
return a string with the current data set problem (by default empty, can be reimplemented in children...
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
virtual ~GNEGenericData()
Destructor.
Position getPathElementArrivalPos() const
get path element arrival position
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
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 element position in view.
void replaceFirstParentTAZElement(SumoXMLTag tag, const std::string &value)
replace the first parent TAZElement
virtual void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)=0
virtual std::string getAttribute(SumoXMLAttr key) const =0
GNEDataInterval * myDataIntervalParent
dataInterval Parent
virtual Boundary getCenteringBoundary() const =0
virtual bool isGenericDataValid() const
check if current data set is valid to be writed into XML (by default true, can be reimplemented in ch...
virtual bool isAttributeEnabled(SumoXMLAttr key) const =0
virtual std::string getPopUpID() const =0
get PopPup ID (Used in AC Hierarchy)
bool isVisibleInspectDeleteSelect() const
check if attribute is visible in inspect, delete or select mode
virtual void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const =0
Draws partial object (lane)
GNEDataInterval * getDataIntervalParent() const
get data interval parent
virtual double getAttributeDouble(SumoXMLAttr key) const =0
const std::string & getID() const
get ID
virtual void setAttribute(SumoXMLAttr key, const std::string &value)=0
method for setting the attribute and nothing else (used in GNEChange_Attribute)
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
virtual std::string getHierarchyName() const =0
get Hierarchy Name (Used in AC Hierarchy)
GNEGenericData & operator=(const GNEGenericData &)=delete
Invalidated assignment operator.
virtual void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)=0
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
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
A list of positions.