SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GNEDetector.h
Go to the documentation of this file.
1 /****************************************************************************/
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10 // Copyright (C) 2001-2013 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:
61  GNEDetector(const std::string& id, GNEViewNet* viewNet, SumoXMLTag tag, GNELane* lane, SUMOReal posOverLane, int freq, const std::string& filename, bool blocked = false, GNEAdditionalSet* parent = NULL);
62 
64  ~GNEDetector();
65 
67  virtual void updateGeometry() = 0;
68 
70  virtual Position getPositionInView() const = 0;
71 
73  void moveAdditionalGeometry(SUMOReal offsetx, SUMOReal offsety);
74 
77 
82  virtual void writeAdditional(OutputDevice& device, const std::string& currentDirectory) = 0;
83 
86 
88  int getFrequency() const;
89 
91  std::string getFilename() const;
92 
97  void setPositionOverLane(SUMOReal pos);
98 
103  void setFrequency(int freq);
104 
108  void setFilename(std::string filename);
109 
114  const std::string& getParentName() const;
115 
120  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
122 
125  /* @brief method for getting the Attribute of an XML key
126  * @param[in] key The attribute key
127  * @return string with the value associated to key
128  */
129  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
130 
131  /* @brief method for setting the attribute and letting the object perform additional changes
132  * @param[in] key The attribute key
133  * @param[in] value The new value
134  * @param[in] undoList The undoList on which to register changes
135  */
136  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
137 
138  /* @brief method for checking if the key and their conrrespond attribute are valids
139  * @param[in] key The attribute key
140  * @param[in] value The value asociated to key key
141  * @return true if the value is valid, false in other case
142  */
143  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
145 
146 protected:
148  int myFreq;
149 
151  std::string myFilename;
152 
156  void drawDetectorIcon(const int GNELogoID, SUMOReal sizex = 0.5, SUMOReal sizey = 0.5) const;
157 
161 
162 private:
164  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
165 
167  const Position& getPosition() const;
168 
170  void setPosition(const Position& pos);
171 };
172 
173 #endif
174 
175 /****************************************************************************/
SumoXMLTag
Numbers representing SUMO-XML - element names.
void setFilename(std::string filename)
Set a new filename in detector.
Stores the information about how to visualize structures.
void commmitAdditionalGeometryMoved(SUMOReal oldPosx, SUMOReal, GNEUndoList *undoList)
updated geometry changes in the attributes of additional
void setPosition(const Position &pos)
Invalidate set new position in the view.
GNEDetector(const std::string &id, GNEViewNet *viewNet, SumoXMLTag tag, GNELane *lane, SUMOReal posOverLane, int freq, const std::string &filename, bool blocked=false, GNEAdditionalSet *parent=NULL)
Constructor.
Definition: GNEDetector.cpp:66
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:55
void setFrequency(int freq)
Set a new frequency in detector.
std::string getFilename() const
returns the path to the output file
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:75
An Element wich group additionalSet elements.
void setPositionOverLane(SUMOReal pos)
Set a new position of detector over lane.
void drawDetectorIcon(const int GNELogoID, SUMOReal sizex=0.5, SUMOReal sizey=0.5) const
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
virtual void updateGeometry()=0
update pre-computed geometry information
int getFrequency() const
returns the aggregation period the values the detector collects shall be summed up.
Position myDetectorLogoOffset
The position of detector.
Definition: GNEDetector.h:159
const std::string & getParentName() const
Returns the name of the parent object (if any)
std::string myFilename
The path to the output file.
Definition: GNEDetector.h:151
SUMOReal getPositionOverLane() const
Returns the position of the detector over lane.
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:63
void moveAdditionalGeometry(SUMOReal offsetx, SUMOReal offsety)
change the position of the additional geometry
Definition: GNEDetector.cpp:80
const Position & getPosition() const
Invalidate return position of additional.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:214
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their conrrespond attribute are valids
virtual void writeAdditional(OutputDevice &device, const std::string &currentDirectory)=0
writte additional element into a xml file
int myFreq
The aggregation period the values the detector collects shall be summed up.
Definition: GNEDetector.h:148
virtual std::string getAttribute(SumoXMLAttr key) const =0