Path: blob/main/src/netedit/elements/additional/GNEDetector.h
194645 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GNEDetector.h14/// @author Pablo Alvarez Lopez15/// @date Nov 201516///17// A abstract class to define common parameters of detectors placed over lanes18/****************************************************************************/19#pragma once20#include <config.h>2122#include "GNEAdditional.h"2324// ===========================================================================25// class definitions26// ===========================================================================2728class GNEDetector : public GNEAdditional, public Parameterised {2930public:31/**@brief Default constructor32* @param[in] net pointer to GNENet of this additional element belongs33* @param[in] tag Type of xml tag that define the detector (SUMO_TAG_INDUCTION_LOOP, SUMO_TAG_LANE_AREA_DETECTOR, etc...)34*/35GNEDetector(GNENet* net, SumoXMLTag tag);3637/**@brief Constructor38* @param[in] id Gl-id of the detector (Must be unique)39* @param[in] net pointer to GNENet of this additional element belongs40* @param[in] fileBucket file in which this element is stored41* @param[in] tag Type of xml tag that define the detector (SUMO_TAG_INDUCTION_LOOP, SUMO_TAG_LANE_AREA_DETECTOR, etc...)42* @param[in] period the aggregation period the values the detector collects shall be summed up.43* @param[in] vehicleTypes space separated list of vehicle type ids to consider44* @param[in] nextEdges list of edge ids that must all be part of the future route of the vehicle to qualify for detection45* @param[in] detectPersons detect persons instead of vehicles (pedestrians or passengers)46* @param[in] outputFilename The path to the output file.47* @param[in] name detector name48* @param[in] parameters generic parameters49*/50GNEDetector(const std::string& id, GNENet* net, FileBucket* fileBucket, SumoXMLTag tag, const SUMOTime period,51const std::string& outputFilename, const std::vector<std::string>& vehicleTypes,52const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name,53const Parameterised::Map& parameters);5455/**@brief Constructor56* @param[in] additionalParent parent additional of this detector (ID will be generated automatically)57* @param[in] tag Type of xml tag that define the detector (SUMO_TAG_INDUCTION_LOOP, SUMO_TAG_LANE_AREA_DETECTOR, etc...)58* @param[in] pos position of the detector on the lane59* @param[in] period the aggregation period the values the detector collects shall be summed up.60* @param[in] parentLanes vector of parent lanes61* @param[in] outputFilename The path to the output file.62* @param[in] name detector name63* @param[in] parameters generic parameters64*/65GNEDetector(GNEAdditional* additionalParent, SumoXMLTag tag, const SUMOTime period, const std::string& outputFilename,66const std::string& name, const Parameterised::Map& parameters);6768/// @brief Destructor69~GNEDetector();7071/// @brief methods to retrieve the elements linked to this detector72/// @{7374/// @brief get parameters associated with this detector75Parameterised* getParameters() override;7677/// @brief get parameters associated with this detector (constant)78const Parameterised* getParameters() const override;7980/// @}8182/// @name Function related with contour drawing83/// @{8485/// @brief check if draw move contour (red)86bool checkDrawMoveContour() const override;8788/// @}8990/// @name Functions related with geometry of element91/// @{9293/// @brief Returns position of additional in view94Position getPositionInView() const override;9596/// @brief update centering boundary (implies change in RTREE)97void updateCenteringBoundary(const bool updateGrid) override;9899/// @brief split geometry100void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) override;101102/// @}103104/// @name inherited from GUIGLObject105/// @{106107/**@brief Returns the name of the parent object108* @return This object's parent id109*/110std::string getParentName() const override;111112/// @}113114/// @name inherited from GNEAttributeCarrier115/// @{116117/* @brief method for getting the Attribute of an XML key in positionVector format118* @param[in] key The attribute key119* @return positionVector with the value associated to key120*/121PositionVector getAttributePositionVector(SumoXMLAttr key) const override;122123/// @brief get PopPup ID (Used in AC Hierarchy)124std::string getPopUpID() const override;125126/// @brief get Hierarchy Name (Used in AC Hierarchy)127std::string getHierarchyName() const override;128129/// @}130131protected:132/// @brief The aggregation period the values the detector collects shall be summed up.133SUMOTime myPeriod = 0;134135/// @brief The path to the output file136std::string myOutputFilename;137138/// @brief attribute vehicle types139std::vector<std::string> myVehicleTypes;140141/// @brief next edges142std::vector<std::string> myNextEdges;143144/// @brief detect persons145std::string myDetectPersons;146147/* @brief method for getting the Attribute of an XML key148* @param[in] key The attribute key149* @return string with the value associated to key150*/151std::string getDetectorAttribute(SumoXMLAttr key) const;152153/* @brief method for getting the Attribute of an XML key in double format154* @param[in] key The attribute key155* @return double with the value associated to key156*/157double getDetectorAttributeDouble(SumoXMLAttr key) const;158159/* @brief method for getting the Attribute of an XML key in position format160* @param[in] key The attribute key161* @return position with the value associated to key162*/163Position getDetectorAttributePosition(SumoXMLAttr key) const;164165/* @brief method for setting the attribute and letting the object perform additional changes166* @param[in] key The attribute key167* @param[in] value The new value168* @param[in] undoList The undoList on which to register changes169*/170void setDetectorAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);171172/* @brief method for checking if the key and their conrrespond attribute are valids173* @param[in] key The attribute key174* @param[in] value The value associated to key key175* @return true if the value is valid, false in other case176*/177bool isDetectorValid(SumoXMLAttr key, const std::string& value);178179/**@brief write additional element into a xml file180* @param[in] device device in which write parameters of additional element181*/182void writeDetectorValues(OutputDevice& device) const;183184/// @brief set attribute after validation185void setDetectorAttribute(SumoXMLAttr key, const std::string& value);186187/// @brief draw E1 shape188void drawE1Shape(const GUIVisualizationSettings::Detail d, const double exaggeration,189const RGBColor& mainColor, const RGBColor& secondColor) const;190191/// @brief draw E1 detector Logo192void drawE1DetectorLogo(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,193const double exaggeration, const std::string& logo, const RGBColor& textColor) const;194195/// @brief draw E2 detector Logo196void drawE2DetectorLogo(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,197const double exaggeration, const std::string& logo, const RGBColor& textColor) const;198199private:200/// @brief Invalidate return position of additional201const Position& getPosition() const = delete;202203/// @brief Invalidate set new position in the view204void setPosition(const Position& pos) = delete;205};206207208