Line data Source code
1 : /****************************************************************************/ 2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3 : // Copyright (C) 2005-2024 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 PCTypeMap.h 15 : /// @author Daniel Krajzewicz 16 : /// @author Michael Behrisch 17 : /// @author Jakob Erdmann 18 : /// @date Mon, 05 Dec 2005 19 : /// 20 : // A storage for type mappings 21 : /****************************************************************************/ 22 : #pragma once 23 : #include <config.h> 24 : 25 : #include "utils/common/RGBColor.h" 26 : #include <string> 27 : #include <map> 28 : 29 : 30 : // =========================================================================== 31 : // class declarations 32 : // =========================================================================== 33 : class OptionsCont; 34 : 35 : /** 36 : * @class PCTypeMap 37 : * @brief A storage for type mappings 38 : * 39 : * This class holds the mappings between names of read polygon/poi types and the 40 : * values (color, new type name etc.) that shall be assigned to them. 41 : */ 42 : class PCTypeMap { 43 : 44 : public: 45 : /// @brief Constructor. The default type is constructed based on the given options 46 : PCTypeMap(const OptionsCont& oc); 47 : 48 : /// @brief Destructor 49 : ~PCTypeMap(); 50 : 51 : enum Filltype { 52 : NOFILL = 0, 53 : FILL = 1, 54 : FORCE = 2 55 : }; 56 : 57 : /** 58 : * @struct TypeDef 59 : * @brief A single definition of values that shall be used for a given type 60 : */ 61 : struct TypeDef { 62 : /// @brief The new type id to use 63 : std::string id; 64 : /// @brief The color to use 65 : RGBColor color; 66 : /// @brief The prefix to use 67 : std::string prefix; 68 : /// @brief the icon to use 69 : std::string icon; 70 : /// @brief The layer to use 71 : double layer; 72 : /// @brief The angle to use 73 : double angle; 74 : /// @brief The image file to use 75 : std::string imgFile; 76 : /// @brief Information whether polygons of this type shall be discarded 77 : bool discard; 78 : /// @brief Information whether polygons of this type can be filled 79 : Filltype allowFill; 80 : }; 81 : 82 : /** @brief Adds a type definition 83 : * 84 : * @param[in] id The original id of the type 85 : * @param[in] newid The new id (name) of the type 86 : * @param[in] color The color to set for imported objects of this type 87 : * @param[in] prefix The prefix to prepend to the read names of this type's objects 88 : * @param[in] layer The layer number to set for this type's objects 89 : * @param[in] icon The icon for this type's objects 90 : * @param[in] angle The angle to rotate this type's objects 91 : * @param[in] imgFile The image file used as texture for objects of this type 92 : * @param[in] discard Whether objects of this type shall be discarded 93 : * @param[in] allowFill Whether objects of this type may be filled 94 : * @return Whether the type could been added (was not known before) 95 : */ 96 : bool add(const std::string& id, const std::string& newid, const std::string& color, 97 : const std::string& prefix, const std::string& icon, double layer, 98 : double angle, const std::string& imgFile, bool discard, Filltype allowFill); 99 : 100 : /** @brief Returns a type definition 101 : * 102 : * This type definition MUST have been added otherwise the further process 103 : * is undefined. 104 : * @param[in] id The id of the type to get the definitions of 105 : * @return Definition of the named type 106 : */ 107 : const TypeDef& get(const std::string& id); 108 : 109 : /** @brief Returns the information whether the named type is known 110 : * @param[in] id The id of the type 111 : * @return Whether a definition of the named type was added before 112 : */ 113 : bool has(const std::string& id); 114 : 115 : /// @brief get the default type according to the given options 116 : const TypeDef& getDefault() { 117 23050 : return myDefaultType; 118 : } 119 : 120 : /// @brief retrieve all known types 121 : const std::map<std::string, TypeDef>& getTypes() const { 122 : return myTypes; 123 : } 124 : 125 : protected: 126 : /// @brief A map of type names to type definitions 127 : std::map<std::string, TypeDef> myTypes; 128 : 129 : TypeDef myDefaultType; 130 : 131 : };