Path: blob/main/src/netedit/elements/additional/GNECalibrator.h
169684 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 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 GNECalibrator.h14/// @author Pablo Alvarez Lopez15/// @date Nov 201516///17// Calibrator over edge or lane18/****************************************************************************/19#pragma once20#include <config.h>2122#include "GNEAdditional.h"2324// ===========================================================================25// class declaration26// ===========================================================================2728class GNERouteProbe;29class GNECalibratorFlow;30class GNERoute;3132// ===========================================================================33// class definitions34// ===========================================================================3536class GNECalibrator : public GNEAdditional, public Parameterised {3738public:39/// @brief Default constructor40GNECalibrator(SumoXMLTag tag, GNENet* net);4142/**@brief Constructor using edge43* @param[in] id The storage of gl-ids to get the one for this lane representation from44* @param[in] net pointer to GNENet of this additional element belongs45* @param[in] filename file in which this element is stored46* @param[in] edge Edge of this calibrator belongs47* @param[in] pos position of the calibrator on the edge (Currently not used)48* @param[in] frequency the aggregation interval in which to calibrate the flows49* @param[in] name Calibrator name50* @param[in] output The output file for writing calibrator information51* @param[in] jamThreshold A threshold value to detect and clear unexpected jamming52* @param[in] vTypes space separated list of vehicle type ids to consider53* @param[in] parameters generic parameters54*/55GNECalibrator(const std::string& id, GNENet* net, const std::string& filename, GNEEdge* edge, double pos, SUMOTime frequency, const std::string& name,56const std::string& output, const double jamThreshold, const std::vector<std::string>& vTypes, const Parameterised::Map& parameters);5758/**@brief Constructor using edge and routeProbe59* @param[in] id The storage of gl-ids to get the one for this lane representation from60* @param[in] net pointer to GNENet of this additional element belongs61* @param[in] filename file in which this element is stored62* @param[in] edge Edge of this calibrator belongs63* @param[in] pos position of the calibrator on the edge (Currently not used)64* @param[in] frequency the aggregation interval in which to calibrate the flows65* @param[in] name Calibrator name66* @param[in] output The output file for writing calibrator information67* @param[in] routeProbe route probe vinculated with this calibrator68* @param[in] jamThreshold A threshold value to detect and clear unexpected jamming69* @param[in] vTypes space separated list of vehicle type ids to consider70* @param[in] parameters generic parameters71*/72GNECalibrator(const std::string& id, GNENet* net, const std::string& filename, GNEEdge* edge, double pos, SUMOTime frequency, const std::string& name,73const std::string& output, GNEAdditional* routeProbe, const double jamThreshold, const std::vector<std::string>& vTypes, const Parameterised::Map& parameters);7475/**@brief Constructor using lane76* @param[in] id The storage of gl-ids to get the one for this lane representation from77* @param[in] net pointer to GNENet of this additional element belongs78* @param[in] filename file in which this element is stored79* @param[in] lane Lane of this calibrator belongs80* @param[in] pos position of the calibrator on the edge (Currently not used)81* @param[in] frequency the aggregation interval in which to calibrate the flows82* @param[in] name Calibrator name83* @param[in] output The output file for writing calibrator information84* @param[in] jamThreshold A threshold value to detect and clear unexpected jamming85* @param[in] vTypes space separated list of vehicle type ids to consider86* @param[in] parameters generic parameters87*/88GNECalibrator(const std::string& id, GNENet* net, const std::string& filename, GNELane* lane, double pos, SUMOTime frequency, const std::string& name,89const std::string& output, const double jamThreshold, const std::vector<std::string>& vTypes, const Parameterised::Map& parameters);9091/**@brief Constructor using lane and routeProbe92* @param[in] id The storage of gl-ids to get the one for this lane representation from93* @param[in] net pointer to GNENet of this additional element belongs94* @param[in] filename file in which this element is stored95* @param[in] lane Lane of this calibrator belongs96* @param[in] pos position of the calibrator on the edge (Currently not used)97* @param[in] frequency the aggregation interval in which to calibrate the flows98* @param[in] name Calibrator name99* @param[in] routeProbe route probe vinculated with this calibrator100* @param[in] output The output file for writing calibrator information101* @param[in] jamThreshold A threshold value to detect and clear unexpected jamming102* @param[in] vTypes space separated list of vehicle type ids to consider103* @param[in] parameters generic parameters104*/105GNECalibrator(const std::string& id, GNENet* net, const std::string& filename, GNELane* lane, double pos, SUMOTime frequency, const std::string& name,106const std::string& output, GNEAdditional* routeProbe, const double jamThreshold, const std::vector<std::string>& vTypes, const Parameterised::Map& parameters);107108/// @brief Destructor109~GNECalibrator();110111/**@brief get move operation112* @note returned GNEMoveOperation can be nullptr113*/114GNEMoveOperation* getMoveOperation();115116/// @name members and functions relative to write additionals into XML117/// @{118119/**@brief write additional element into a xml file120* @param[in] device device in which write parameters of additional element121*/122void writeAdditional(OutputDevice& device) const;123124/// @brief check if current additional is valid to be written into XML (must be reimplemented in all detector children)125bool isAdditionalValid() const;126127/// @brief return a string with the current additional problem (must be reimplemented in all detector children)128std::string getAdditionalProblem() const;129130/// @brief fix additional problem (must be reimplemented in all detector children)131void fixAdditionalProblem();132133/// @}134135/// @name Function related with contour drawing136/// @{137138/// @brief check if draw move contour (red)139bool checkDrawMoveContour() const;140141/// @}142143/// @brief open Calibrator Dialog144void openAdditionalDialog();145146/// @name Functions related with geometry of element147/// @{148149/// @brief update pre-computed geometry information150void updateGeometry();151152/// @brief Returns position of additional in view153Position getPositionInView() const;154155/// @brief update centering boundary (implies change in RTREE)156void updateCenteringBoundary(const bool updateGrid);157158/// @brief split geometry159void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);160161/// @}162163/// @name inherited from GUIGlObject164/// @{165166/**@brief Returns the name of the parent object167* @return This object's parent id168*/169std::string getParentName() const;170171/**@brief Draws the object172* @param[in] s The settings for the current view (may influence drawing)173* @see GUIGlObject::drawGL174*/175void drawGL(const GUIVisualizationSettings& s) const;176177/// @}178179/// @name inherited from GNEAttributeCarrier180/// @{181182/* @brief method for getting the Attribute of an XML key183* @param[in] key The attribute key184* @return string with the value associated to key185*/186std::string getAttribute(SumoXMLAttr key) const;187188/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)189* @param[in] key The attribute key190* @return double with the value associated to key191*/192double getAttributeDouble(SumoXMLAttr key) const;193194/// @brief get parameters map195const Parameterised::Map& getACParametersMap() const;196197/* @brief method for setting the attribute and letting the object perform additional changes198* @param[in] key The attribute key199* @param[in] value The new value200* @param[in] undoList The undoList on which to register changes201*/202void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);203204/* @brief method for checking if the key and their correspond attribute are valids205* @param[in] key The attribute key206* @param[in] value The value associated to key key207* @return true if the value is valid, false in other case208*/209bool isValid(SumoXMLAttr key, const std::string& value);210211/// @brief get PopPup ID (Used in AC Hierarchy)212std::string getPopUpID() const;213214/// @brief get Hierarchy Name (Used in AC Hierarchy)215std::string getHierarchyName() const;216217/// @}218219protected:220/// @brief position over Lane221double myPositionOverLane = 0;222223/// @brief Frequency of calibrator224SUMOTime myFrequency = 0;225226/// @brief output of calibrator227std::string myOutput;228229/// @brief jamThreshold230double myJamThreshold = 0;231232/// @brief vTypes233std::vector<std::string> myVTypes;234235/// @brief extra calibrator geometries236std::vector<GUIGeometry> myEdgeCalibratorGeometries;237238/// @brief calibrator contours239std::vector<GNEContour*>* myCalibratorContours;240241private:242/// @brief draw calibrator symbol243void drawCalibratorSymbol(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,244const double exaggeration, const Position& pos, const double rot,245const int symbolIndex) const;246247/// @brief set attribute after validation248void setAttribute(SumoXMLAttr key, const std::string& value);249250/// @brief set move shape251void setMoveShape(const GNEMoveResult& moveResult);252253/// @brief commit move shape254void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);255256/// @brief Invalidated copy constructor.257GNECalibrator(const GNECalibrator&) = delete;258259/// @brief Invalidated assignment operator.260GNECalibrator& operator=(const GNECalibrator&) = delete;261};262263264