Path: blob/main/src/utils/gui/settings/GUISettingsHandler.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 GUISettingsHandler.h14/// @author Michael Behrisch15/// @author Daniel Krajzewicz16/// @author Jakob Erdmann17/// @date Fri, 24. Apr 200918///19// The handler for parsing gui settings from xml.20/****************************************************************************/21#pragma once22#include <config.h>2324#include <utils/xml/SUMOSAXHandler.h>25#include <utils/distribution/RandomDistributor.h>262728// ===========================================================================29// class declarations30// ===========================================================================31class GUISUMOAbstractView;32class Position;333435// ===========================================================================36// class definitions37// ===========================================================================38/** @class GUISettingsHandler39* @brief An XML-handler for visualisation schemes40*/41class GUISettingsHandler : public SUMOSAXHandler {42public:43/** @brief Constructor44* @param[in] file the file to parse45*/46GUISettingsHandler(const std::string& content, bool isFile = true, bool netedit = false);474849/// @brief Destructor50~GUISettingsHandler();51525354/// @name inherited from GenericSAXHandler55//@{5657/** @brief Called on the opening of a tag58* @param[in] element ID of the currently opened element59* @param[in] attrs Attributes within the currently opened element60* @exception ProcessError If something fails61* @see GenericSAXHandler::myStartElement62*/63void myStartElement(int element, const SUMOSAXAttributes& attrs);6465/** @brief Called when a closing tag occurs66*67* @param[in] element ID of the currently opened element68* @exception ProcessError If something fails69* @see GenericSAXHandler::myEndElement70*/71void myEndElement(int element);72//@}73747576/** @brief Adds the parsed settings to the global list of settings77* @return the names of the parsed settings78*/79const std::vector<std::string>& addSettings(GUISUMOAbstractView* view = 0) const;808182/** @brief Sets the viewport which has been parsed83* @param[in] parent the view for which the viewport has to be set84*/85void applyViewport(GUISUMOAbstractView* view) const;868788/** @brief Makes a snapshot if it has been parsed89* @param[in] parent the view which needs to be shot90* @todo Please describe why the snapshots are only set if no other existed before (see code)91*/92void setSnapshots(GUISUMOAbstractView* view) const;939495/** @brief Returns whether any decals have been parsed96* @return whether decals have been parsed97*/98bool hasDecals() const;99100101/** @brief Returns the parsed decals102* @return the parsed decals103*/104const std::vector<GUISUMOAbstractView::Decal>& getDecals() const;105106107/** @brief Returns the parsed delay108* @return the parsed delay109*/110double getDelay() const;111112113/** @brief Returns the parsed breakpoints114* @return the parsed breakpoints115*/116const std::vector<SUMOTime>& getBreakpoints() const {117return myBreakpoints;118}119120121/// @brief loads breakpoints from the specified file122static std::vector<SUMOTime> loadBreakpoints(const std::string& file);123124125/** @brief Returns the parsed view type126* @return the parsed view type127*/128const std::string& getViewType() const {129return myViewType;130}131132RandomDistributor<std::string> getEventDistribution(const std::string& id);133double getJamSoundTime() {134return myJamSoundTime;135}136137const std::string& getSettingName() const {138return mySettings.name;139}140141private:142/// @brief The settings to fill143GUIVisualizationSettings mySettings;144145/// @brief names of all loaded settings146std::vector<std::string> myLoadedSettingNames;147148/// @brief The view type (osg, opengl, default) loaded149std::string myViewType;150151/// @brief The delay loaded152double myDelay;153154/// @brief The viewport loaded, zoom is stored in z coordinate155Position myLookFrom;156157/// @brief The point to look at, only needed for osg view158Position myLookAt;159160/// @brief Whether the Z coordinate is set in 3D view161bool myZCoordSet;162163/// @brief View rotation164double myRotation;165166/// @brief Zoom level167double myZoom;168169/// @brief mappig of time steps to filenames for potential snapshots170std::map<SUMOTime, std::vector<std::string> > mySnapshots;171172/// @brief The decals list to fill173std::vector<GUISUMOAbstractView::Decal> myDecals;174175/// @brief The last color scheme category (edges or vehicles)176int myCurrentColorer;177178/// @brief The current color scheme179GUIColorScheme* myCurrentScheme;180181/// @brief The current scaling scheme182GUIScaleScheme* myCurrentScaleScheme;183184/// @brief The parsed breakpoints185std::vector<SUMOTime> myBreakpoints;186187/// @brief The parsed event distributions188std::map<std::string, RandomDistributor<std::string> > myEventDistributions;189double myJamSoundTime;190191private:192/// @brief parse color attribute193RGBColor parseColor(const SUMOSAXAttributes& attrs, const std::string attribute, const RGBColor& defaultValue) const;194195/// @brief parse attributes for textSettings196GUIVisualizationTextSettings parseTextSettings(197const std::string& prefix, const SUMOSAXAttributes& attrs,198GUIVisualizationTextSettings defaults);199200/// @brief parse attributes for sizeSettings201GUIVisualizationSizeSettings parseSizeSettings(202const std::string& prefix, const SUMOSAXAttributes& attrs,203GUIVisualizationSizeSettings defaults);204205/// @brief parse attributes for rainbowSettings206GUIVisualizationRainbowSettings parseRainbowSettings(207const std::string& prefix, const SUMOSAXAttributes& attrs,208GUIVisualizationRainbowSettings defaults);209};210211212