LCOV - code coverage report
Current view: top level - src/utils/gui/settings - GUISettingsHandler.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 2 2
Test Date: 2026-08-23 15:49:09 Functions: - 0 0

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    GUISettingsHandler.h
      15              : /// @author  Michael Behrisch
      16              : /// @author  Daniel Krajzewicz
      17              : /// @author  Jakob Erdmann
      18              : /// @date    Fri, 24. Apr 2009
      19              : ///
      20              : // The handler for parsing gui settings from xml.
      21              : /****************************************************************************/
      22              : #pragma once
      23              : #include <config.h>
      24              : 
      25              : #include <utils/xml/SUMOSAXHandler.h>
      26              : #include <utils/distribution/RandomDistributor.h>
      27              : 
      28              : 
      29              : // ===========================================================================
      30              : // class declarations
      31              : // ===========================================================================
      32              : class GUISUMOAbstractView;
      33              : class Position;
      34              : 
      35              : 
      36              : // ===========================================================================
      37              : // class definitions
      38              : // ===========================================================================
      39              : /** @class GUISettingsHandler
      40              :  * @brief An XML-handler for visualisation schemes
      41              :  */
      42              : class GUISettingsHandler : public SUMOSAXHandler {
      43              : public:
      44              :     /** @brief Constructor
      45              :      * @param[in] file the file to parse
      46              :      */
      47              :     GUISettingsHandler(FXApp* app, const std::string& content, bool isFile = true, bool netedit = false);
      48              : 
      49              : 
      50              :     /// @brief Destructor
      51              :     ~GUISettingsHandler();
      52              : 
      53              : 
      54              :     /// @name inherited from GenericSAXHandler
      55              :     //@{
      56              : 
      57              :     /** @brief Called on the opening of a tag
      58              :      * @param[in] element ID of the currently opened element
      59              :      * @param[in] attrs Attributes within the currently opened element
      60              :      * @exception ProcessError If something fails
      61              :      * @see GenericSAXHandler::myStartElement
      62              :      */
      63              :     void myStartElement(int element, const SUMOSAXAttributes& attrs);
      64              : 
      65              :     /** @brief Called when a closing tag occurs
      66              :      *
      67              :      * @param[in] element ID of the currently opened element
      68              :      * @exception ProcessError If something fails
      69              :      * @see GenericSAXHandler::myEndElement
      70              :      */
      71              :     void myEndElement(int element);
      72              :     //@}
      73              : 
      74              : 
      75              : 
      76              :     /** @brief Adds the parsed settings to the global list of settings
      77              :      * @return the names of the parsed settings
      78              :      */
      79              :     const std::vector<std::string>& addSettings(GUISUMOAbstractView* view = 0) const;
      80              : 
      81              : 
      82              :     /** @brief Sets the viewport which has been parsed
      83              :      * @param[in] parent the view for which the viewport has to be set
      84              :      */
      85              :     void applyViewport(GUISUMOAbstractView* view) const;
      86              : 
      87              : 
      88              :     /** @brief Makes a snapshot if it has been parsed
      89              :      * @param[in] parent the view which needs to be shot
      90              :      * @todo Please describe why the snapshots are only set if no other existed before (see code)
      91              :      */
      92              :     void setSnapshots(GUISUMOAbstractView* view) const;
      93              : 
      94              : 
      95              :     /** @brief Returns whether any decals have been parsed
      96              :      * @return whether decals have been parsed
      97              :      */
      98              :     bool hasDecals() const;
      99              : 
     100              : 
     101              :     /** @brief Returns the parsed decals
     102              :      * @return the parsed decals
     103              :      */
     104              :     const std::vector<GUISUMOAbstractView::Decal>& getDecals() const;
     105              : 
     106              : 
     107              :     /** @brief Returns the parsed delay
     108              :      * @return the parsed delay
     109              :      */
     110              :     double getDelay() const;
     111              : 
     112              : 
     113              :     /** @brief Returns the parsed breakpoints
     114              :      * @return the parsed breakpoints
     115              :      */
     116              :     const std::vector<SUMOTime>& getBreakpoints() const {
     117              :         return myBreakpoints;
     118              :     }
     119              : 
     120              : 
     121              :     /// @brief loads breakpoints from the specified file
     122              :     static std::vector<SUMOTime> loadBreakpoints(const std::string& file);
     123              : 
     124              : 
     125              :     /** @brief Returns the parsed view type
     126              :      * @return the parsed view type
     127              :      */
     128              :     const std::string& getViewType() const {
     129              :         return myViewType;
     130              :     }
     131              : 
     132              :     RandomDistributor<std::string> getEventDistribution(const std::string& id);
     133              :     double getJamSoundTime() {
     134           37 :         return myJamSoundTime;
     135              :     }
     136              : 
     137              :     std::vector<std::string> getTrackers() {
     138           37 :         return myTrackers;
     139              :     }
     140              : 
     141              :     const std::string& getSettingName() const {
     142              :         return mySettings.name;
     143              :     }
     144              : 
     145              : private:
     146              :     /// @brief pointer to App
     147              :     FXApp* myApp;
     148              : 
     149              :     /// @brief The settings to fill
     150              :     GUIVisualizationSettings mySettings;
     151              : 
     152              :     /// @brief names of all loaded settings
     153              :     std::vector<std::string> myLoadedSettingNames;
     154              : 
     155              :     /// @brief The view type (osg, opengl, default) loaded
     156              :     std::string myViewType;
     157              : 
     158              :     /// @brief The delay loaded
     159              :     double myDelay;
     160              : 
     161              :     /// @brief The viewport loaded, zoom is stored in z coordinate
     162              :     Position myLookFrom;
     163              : 
     164              :     /// @brief The point to look at, only needed for osg view
     165              :     Position myLookAt;
     166              : 
     167              :     /// @brief Whether the Z coordinate is set in 3D view
     168              :     bool myZCoordSet;
     169              : 
     170              :     /// @brief View rotation
     171              :     double myRotation;
     172              : 
     173              :     /// @brief Zoom level
     174              :     double myZoom;
     175              : 
     176              :     /// @brief mappig of time steps to filenames for potential snapshots
     177              :     std::map<SUMOTime, std::vector<std::string> > mySnapshots;
     178              : 
     179              :     /// @brief The decals list to fill
     180              :     std::vector<GUISUMOAbstractView::Decal> myDecals;
     181              : 
     182              :     /// @brief The last color scheme category (edges or vehicles)
     183              :     int myCurrentColorer;
     184              : 
     185              :     /// @brief The current color scheme
     186              :     GUIColorScheme* myCurrentScheme;
     187              : 
     188              :     /// @brief The current scaling scheme
     189              :     GUIScaleScheme* myCurrentScaleScheme;
     190              : 
     191              :     /// @brief The parsed breakpoints
     192              :     std::vector<SUMOTime> myBreakpoints;
     193              : 
     194              :     /// @brief The parsed event distributions
     195              :     std::map<std::string, RandomDistributor<std::string> > myEventDistributions;
     196              :     double myJamSoundTime;
     197              : 
     198              :     /// @brief list of tlsIDs to open trackers for
     199              :     std::vector<std::string> myTrackers;
     200              : 
     201              : private:
     202              :     /// @brief parse color attribute
     203              :     RGBColor parseColor(const SUMOSAXAttributes& attrs, const std::string attribute, const RGBColor& defaultValue) const;
     204              : 
     205              :     /// @brief parse attributes for textSettings
     206              :     GUIVisualizationTextSettings parseTextSettings(
     207              :         const std::string& prefix, const SUMOSAXAttributes& attrs,
     208              :         GUIVisualizationTextSettings defaults);
     209              : 
     210              :     /// @brief parse attributes for sizeSettings
     211              :     GUIVisualizationSizeSettings parseSizeSettings(
     212              :         const std::string& prefix, const SUMOSAXAttributes& attrs,
     213              :         GUIVisualizationSizeSettings defaults);
     214              : 
     215              :     /// @brief parse attributes for rainbowSettings
     216              :     GUIVisualizationRainbowSettings parseRainbowSettings(
     217              :         const std::string& prefix, const SUMOSAXAttributes& attrs,
     218              :         GUIVisualizationRainbowSettings defaults);
     219              : };
        

Generated by: LCOV version 2.0-1