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-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 data sets
19 /****************************************************************************/
20 #pragma once
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
30 #include <netedit/GNEGeometry.h>
35 #include <netbuild/NBVehicle.h>
36 #include <netbuild/NBEdge.h>
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 
42 class GNEViewNet;
43 class GNEDataInterval;
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
48 
54 
55 public:
70  GNEGenericData(const SumoXMLTag tag, const GUIGlObjectType type, GNEDataInterval* dataIntervalParent,
71  const std::map<std::string, std::string>& parameters,
72  const std::vector<GNEJunction*>& junctionParents,
73  const std::vector<GNEEdge*>& edgeParents,
74  const std::vector<GNELane*>& laneParents,
75  const std::vector<GNEAdditional*>& additionalParents,
76  const std::vector<GNEShape*>& shapeParents,
77  const std::vector<GNETAZElement*>& TAZElementParents,
78  const std::vector<GNEDemandElement*>& demandElementParents,
79  const std::vector<GNEGenericData*>& genericDataParents);
80 
82  virtual ~GNEGenericData();
83 
85  virtual const RGBColor& getColor() const = 0;
86 
88  virtual bool isGenericDataVisible() const = 0;
89 
91  const std::string& getID() const;
92 
95 
98 
99  // @brief draw attribute
100  void drawAttribute(const PositionVector& shape) const;
101 
103  virtual void updateGeometry() = 0;
104 
106  virtual Position getPositionInView() const = 0;
107 
110 
113  virtual void writeGenericData(OutputDevice& device) const = 0;
114 
116  virtual bool isGenericDataValid() const;
117 
119  virtual std::string getGenericDataProblem() const;
120 
122  virtual void fixGenericDataProblem();
124 
127 
135 
144 
149  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
150 
156  virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const double offsetFront) const = 0;
157 
164  virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const double offsetFront) const = 0;
165 
167  virtual Boundary getCenteringBoundary() const = 0;
169 
172  /* @brief method for getting the Attribute of an XML key
173  * @param[in] key The attribute key
174  * @return string with the value associated to key
175  */
176  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
177 
178  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
179  * @param[in] key The attribute key
180  * @return double with the value associated to key
181  */
182  virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
183 
189  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
190 
196  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
197 
198  /* @brief method for enable attribute
199  * @param[in] key The attribute key
200  * @param[in] undoList The undoList on which to register changes
201  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
202  */
203  virtual void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList) = 0;
204 
205  /* @brief method for disable attribute
206  * @param[in] key The attribute key
207  * @param[in] undoList The undoList on which to register changes
208  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
209  */
210  virtual void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList) = 0;
211 
212  /* @brief method for check if the value for certain attribute is set
213  * @param[in] key The attribute key
214  */
215  virtual bool isAttributeEnabled(SumoXMLAttr key) const = 0;
216 
218  virtual std::string getPopUpID() const = 0;
219 
221  virtual std::string getHierarchyName() const = 0;
223 
225  const std::map<std::string, std::string>& getACParametersMap() const;
226 
227 protected:
230 
232  void drawFilteredAttribute(const GUIVisualizationSettings& s, const PositionVector& laneShape, const std::string& attribute) const;
233 
235  bool isVisibleInspectDeleteSelect() const;
236 
238  void replaceFirstParentEdge(const std::string& value);
239 
241  void replaceLastParentEdge(const std::string& value);
242 
244  void replaceFirstParentTAZElement(SumoXMLTag tag, const std::string& value);
245 
247  void replaceLastParentTAZElement(SumoXMLTag tag, const std::string& value);
248 
249 private:
251  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
252 
254  virtual void setEnabledAttribute(const int enabledAttributes) = 0;
255 
257  GNEGenericData(const GNEGenericData&) = delete;
258 
261 };
262 
263 /****************************************************************************/
264 
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.
virtual const RGBColor & getColor() const =0
get generic data color
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
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
virtual void fixGenericDataProblem()
fix data set problem (by default throw an exception, has to be reimplemented in children)
virtual void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const double offsetFront) const =0
Draws partial object (lane)
void drawAttribute(const PositionVector &shape) 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 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.
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 void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *fromLane, const GNELane *toLane, const double offsetFront) const =0
Draws partial object (junction)
virtual Boundary getCenteringBoundary() const =0
void replaceLastParentTAZElement(SumoXMLTag tag, const std::string &value)
replace the last parent TAZElement
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
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 setEnabledAttribute(const int enabledAttributes)=0
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
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:45
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
A list of positions.