src/model/RenderingColor.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #ifndef MODEL_RENDERINGCOLOR_HPP | ||
| 7 | #define MODEL_RENDERINGCOLOR_HPP | ||
| 8 | |||
| 9 | #include "ModelAPI.hpp" | ||
| 10 | #include "ResourceObject.hpp" | ||
| 11 | |||
| 12 | namespace openstudio { | ||
| 13 | namespace model { | ||
| 14 | |||
| 15 | namespace detail { | ||
| 16 | |||
| 17 | class RenderingColor_Impl; | ||
| 18 | |||
| 19 | } // namespace detail | ||
| 20 | |||
| 21 | class MODEL_API ColorRGB | ||
| 22 | { | ||
| 23 | public: | ||
| 24 | /// Integer components of RGB color from 0-255 | ||
| 25 | ColorRGB(int r, int g, int b); | ||
| 26 | int red() const; | ||
| 27 | int green() const; | ||
| 28 | int blue() const; | ||
| 29 | |||
| 30 | private: | ||
| 31 | int m_red; | ||
| 32 | int m_green; | ||
| 33 | int m_blue; | ||
| 34 | }; | ||
| 35 | |||
| 36 | /** RenderingColor is a ResourceObject that wraps the OpenStudio IDD object 'OS_Rendering_Color'. */ | ||
| 37 | class MODEL_API RenderingColor : public ResourceObject | ||
| 38 | { | ||
| 39 | public: | ||
| 40 | /** @name Constructors and Destructors */ | ||
| 41 | //@{ | ||
| 42 | |||
| 43 | explicit RenderingColor(const Model& model); | ||
| 44 | |||
| 45 | 28899 | virtual ~RenderingColor() override = default; | |
| 46 | // Default the copy and move operators because the virtual dtor is explicit | ||
| 47 | 1495 | RenderingColor(const RenderingColor& other) = default; | |
| 48 | 17569 | RenderingColor(RenderingColor&& other) = default; | |
| 49 | ✗ | RenderingColor& operator=(const RenderingColor&) = default; | |
| 50 | 4 | RenderingColor& operator=(RenderingColor&&) = default; | |
| 51 | |||
| 52 | static boost::optional<RenderingColor> fromColorString(const std::string& s, const Model& model); | ||
| 53 | |||
| 54 | //@} | ||
| 55 | /** @name Static Methods */ | ||
| 56 | //@{ | ||
| 57 | |||
| 58 | static ColorRGB randomColor(); | ||
| 59 | |||
| 60 | static IddObjectType iddObjectType(); | ||
| 61 | |||
| 62 | //@} | ||
| 63 | /** @name Getters */ | ||
| 64 | //@{ | ||
| 65 | |||
| 66 | int renderingRedValue() const; | ||
| 67 | |||
| 68 | int renderingGreenValue() const; | ||
| 69 | |||
| 70 | int renderingBlueValue() const; | ||
| 71 | |||
| 72 | int renderingAlphaValue() const; | ||
| 73 | |||
| 74 | bool isRenderingAlphaValueDefaulted() const; | ||
| 75 | |||
| 76 | //@} | ||
| 77 | /** @name Setters */ | ||
| 78 | //@{ | ||
| 79 | |||
| 80 | bool setRenderingRedValue(int renderingRedValue); | ||
| 81 | |||
| 82 | bool setRenderingGreenValue(int renderingGreenValue); | ||
| 83 | |||
| 84 | bool setRenderingBlueValue(int renderingBlueValue); | ||
| 85 | |||
| 86 | bool setRenderingAlphaValue(int renderingAlphaValue); | ||
| 87 | |||
| 88 | void resetRenderingAlphaValue(); | ||
| 89 | |||
| 90 | //@} | ||
| 91 | |||
| 92 | std::string colorString() const; | ||
| 93 | |||
| 94 | protected: | ||
| 95 | /// @cond | ||
| 96 | using ImplType = detail::RenderingColor_Impl; | ||
| 97 | |||
| 98 | friend class Model; | ||
| 99 | friend class openstudio::IdfObject; | ||
| 100 | |||
| 101 | explicit RenderingColor(std::shared_ptr<detail::RenderingColor_Impl> impl); | ||
| 102 | |||
| 103 | /// @endcond | ||
| 104 | private: | ||
| 105 | REGISTER_LOGGER("openstudio.model.RenderingColor"); | ||
| 106 | }; | ||
| 107 | |||
| 108 | /** \relates RenderingColor*/ | ||
| 109 | using OptionalRenderingColor = boost::optional<RenderingColor>; | ||
| 110 | |||
| 111 | /** \relates RenderingColor*/ | ||
| 112 | using RenderingColorVector = std::vector<RenderingColor>; | ||
| 113 | |||
| 114 | } // namespace model | ||
| 115 | } // namespace openstudio | ||
| 116 | |||
| 117 | #endif // MODEL_RENDERINGCOLOR_HPP | ||
| 118 |