Path: blob/main/src/utils/gui/settings/GUISettingsHandler.h
193674 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 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}136137std::vector<std::string> getTrackers() {138return myTrackers;139}140141const std::string& getSettingName() const {142return mySettings.name;143}144145private:146/// @brief The settings to fill147GUIVisualizationSettings mySettings;148149/// @brief names of all loaded settings150std::vector<std::string> myLoadedSettingNames;151152/// @brief The view type (osg, opengl, default) loaded153std::string myViewType;154155/// @brief The delay loaded156double myDelay;157158/// @brief The viewport loaded, zoom is stored in z coordinate159Position myLookFrom;160161/// @brief The point to look at, only needed for osg view162Position myLookAt;163164/// @brief Whether the Z coordinate is set in 3D view165bool myZCoordSet;166167/// @brief View rotation168double myRotation;169170/// @brief Zoom level171double myZoom;172173/// @brief mappig of time steps to filenames for potential snapshots174std::map<SUMOTime, std::vector<std::string> > mySnapshots;175176/// @brief The decals list to fill177std::vector<GUISUMOAbstractView::Decal> myDecals;178179/// @brief The last color scheme category (edges or vehicles)180int myCurrentColorer;181182/// @brief The current color scheme183GUIColorScheme* myCurrentScheme;184185/// @brief The current scaling scheme186GUIScaleScheme* myCurrentScaleScheme;187188/// @brief The parsed breakpoints189std::vector<SUMOTime> myBreakpoints;190191/// @brief The parsed event distributions192std::map<std::string, RandomDistributor<std::string> > myEventDistributions;193double myJamSoundTime;194195/// @brief list of tlsIDs to open trackers for196std::vector<std::string> myTrackers;197198private:199/// @brief parse color attribute200RGBColor parseColor(const SUMOSAXAttributes& attrs, const std::string attribute, const RGBColor& defaultValue) const;201202/// @brief parse attributes for textSettings203GUIVisualizationTextSettings parseTextSettings(204const std::string& prefix, const SUMOSAXAttributes& attrs,205GUIVisualizationTextSettings defaults);206207/// @brief parse attributes for sizeSettings208GUIVisualizationSizeSettings parseSizeSettings(209const std::string& prefix, const SUMOSAXAttributes& attrs,210GUIVisualizationSizeSettings defaults);211212/// @brief parse attributes for rainbowSettings213GUIVisualizationRainbowSettings parseRainbowSettings(214const std::string& prefix, const SUMOSAXAttributes& attrs,215GUIVisualizationRainbowSettings defaults);216};217218219