/**************************************************************************** ** Copyright (c) 2021, Fougue Ltd. ** All rights reserved. ** See license at https://github.com/fougue/mayo/blob/master/LICENSE.txt ****************************************************************************/ #pragma once #include "../base/tkernel_utils.h" #include #include #include #include #include #include #include #include #include #include #include #if OCC_VERSION_HEX < OCC_VERSION_CHECK(7, 5, 0) # include #endif namespace Mayo { class AIS_Text : public AIS_InteractiveObject { public: AIS_Text() = default; AIS_Text(const TCollection_ExtendedString& text, const gp_Pnt& pos); OccHandle presentationTextAspect(unsigned i = 0) const; OccHandle graphicTextAspect(unsigned i = 0) const; void setDefaultColor(const Quantity_Color& c); void setDefaultFont(const char* fontName); void setDefaultTextBackgroundColor(const Quantity_Color& c); void setDefaultTextDisplayMode(Aspect_TypeOfDisplayText mode); void setDefaultTextStyle(Aspect_TypeOfStyleText style); gp_Pnt position(unsigned i = 0) const; void setPosition(const gp_Pnt& pos, unsigned i = 0); TCollection_ExtendedString text(unsigned i = 0) const; void setText(const TCollection_ExtendedString& v, unsigned i = 0); bool isValidTextIndex(unsigned i) const; void setTextBackgroundColor(const Quantity_Color& color, unsigned i = 0); void setTextDisplayMode(Aspect_TypeOfDisplayText mode, unsigned i = 0); void setTextStyle(Aspect_TypeOfStyleText style, unsigned i = 0); unsigned textCount() const; void addText(const TCollection_ExtendedString& text, const gp_Pnt& pos); void ComputeSelection(const OccHandle& sel, const int mode) override; protected: void Compute( const OccHandle& pm, const OccHandle& pres, const int mode) override; #if OCC_VERSION_HEX < OCC_VERSION_CHECK(7, 5, 0) void Compute(const OccHandle&, const OccHandle&) override {} #endif private: struct TextProperties { TextProperties(); bool operator==(const TextProperties& other) const; const char* m_font = nullptr; gp_Pnt m_position; TCollection_ExtendedString m_text; OccHandle m_aspect; }; const char* m_defaultFont = "Courrier"; Quantity_Color m_defaultColor = Quantity_NOC_YELLOW; Quantity_Color m_defaultTextBackgroundColor = Quantity_NOC_GREEN; Aspect_TypeOfDisplayText m_defaultTextDisplayMode = Aspect_TODT_NORMAL; Aspect_TypeOfStyleText m_defaultTextStyle = Aspect_TOST_NORMAL; std::vector m_textProps; }; } // namespace Mayo