SUMO - Simulation of Urban MObility
GNEDetector.h
Go to the documentation of this file.
1 /****************************************************************************/
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software; you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation; either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef GNEDetector_h
21 #define GNEDetector_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "GNEAdditional.h"
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class GNEAdditional;
39 class GNEViewNet;
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
48 class GNEDetector : public GNEAdditional {
49 public:
60  GNEDetector(const std::string& id, GNEViewNet* viewNet, SumoXMLTag tag, GUIIcon icon, GNELane* lane, double posOverLane, double freq, const std::string& filename);
61 
63  ~GNEDetector();
64 
66  virtual void updateGeometry() = 0;
67 
69  virtual Position getPositionInView() const = 0;
70 
72  void moveAdditionalGeometry(double offsetx, double offsety);
73 
75  void commmitAdditionalGeometryMoved(double oldPosx, double, GNEUndoList* undoList);
76 
81  virtual void writeAdditional(OutputDevice& device) const = 0;
82 
84  double getPositionOverLane() const;
85 
87  double getFrequency() const;
88 
90  std::string getFilename() const;
91 
96  void setPositionOverLane(double pos);
97 
102  void setFrequency(const double freq);
103 
107  void setFilename(std::string filename);
108 
113  const std::string& getParentName() const;
114 
119  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
121 
124  /* @brief method for getting the Attribute of an XML key
125  * @param[in] key The attribute key
126  * @return string with the value associated to key
127  */
128  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
129 
130  /* @brief method for setting the attribute and letting the object perform additional changes
131  * @param[in] key The attribute key
132  * @param[in] value The new value
133  * @param[in] undoList The undoList on which to register changes
134  */
135  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
136 
137  /* @brief method for checking if the key and their conrrespond attribute are valids
138  * @param[in] key The attribute key
139  * @param[in] value The value asociated to key key
140  * @return true if the value is valid, false in other case
141  */
142  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
144 
145 protected:
147  double myFreq;
148 
150  std::string myFilename;
151 
155  void drawDetectorIcon(const int GNELogoID, double sizex = 0.5, double sizey = 0.5) const;
156 
160 
161 private:
163  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
164 
166  const Position& getPosition() const;
167 
169  void setPosition(const Position& pos);
170 };
171 
172 #endif
173 
174 /****************************************************************************/
void commmitAdditionalGeometryMoved(double oldPosx, double, GNEUndoList *undoList)
updated geometry changes in the attributes of additional
Definition: GNEDetector.cpp:97
SumoXMLTag
Numbers representing SUMO-XML - element names.
virtual void writeAdditional(OutputDevice &device) const =0
writte additional element into a xml file
double getPositionOverLane() const
Returns the position of the detector over lane.
std::string getFilename() const
returns the path to the output file
void setFilename(std::string filename)
Set a new filename in detector.
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:43
Stores the information about how to visualize structures.
double myFreq
The aggregation period the values the detector collects shall be summed up.
Definition: GNEDetector.h:147
void setPosition(const Position &pos)
Invalidate set new position in the view.
const std::string & getParentName() const
Returns the name of the parent object (if any)
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:54
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes ...
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
virtual Position getPositionInView() const =0
Returns position of additional in view.
~GNEDetector()
Destructor.
Definition: GNEDetector.cpp:71
GNEDetector(const std::string &id, GNEViewNet *viewNet, SumoXMLTag tag, GUIIcon icon, GNELane *lane, double posOverLane, double freq, const std::string &filename)
Constructor.
Definition: GNEDetector.cpp:62
void setPositionOverLane(double pos)
Set a new position of detector over lane.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
virtual void updateGeometry()=0
update pre-computed geometry information
Position myDetectorLogoOffset
The position of detector.
Definition: GNEDetector.h:158
std::string myFilename
The path to the output file.
Definition: GNEDetector.h:150
void drawDetectorIcon(const int GNELogoID, double sizex=0.5, double sizey=0.5) const
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
double getFrequency() const
returns the aggregation period the values the detector collects shall be summed up.
void setFrequency(const double freq)
Set a new frequency in detector.
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:62
void moveAdditionalGeometry(double offsetx, double offsety)
change the position of the additional geometry
Definition: GNEDetector.cpp:76
const Position & getPosition() const
Invalidate return position of additional.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their conrrespond attribute are valids
virtual std::string getAttribute(SumoXMLAttr key) const =0