#ifndef _Graphic3d_AspectText3d_HeaderFile
#define _Graphic3d_AspectText3d_HeaderFile
-#include <Aspect_TypeOfStyleText.hxx>
-#include <Aspect_TypeOfDisplayText.hxx>
-#include <Graphic3d_AspectTextDefinitionError.hxx>
-#include <Graphic3d_ShaderProgram.hxx>
-#include <Font_FontAspect.hxx>
-#include <Font_NameOfFont.hxx>
-#include <Standard_Transient.hxx>
-#include <Standard.hxx>
-#include <Standard_Boolean.hxx>
-#include <Standard_Real.hxx>
-#include <Standard_Type.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <Quantity_ColorRGBA.hxx>
+#include <Graphic3d_Aspects.hxx>
-//! Creates and updates a group of attributes for
-//! text primitives. This group contains the color,
-//! font, expansion factor (height/width ratio), and
-//! inter-character space.
-//!
-//! NOTE: The font name is stored in the aspect instance
-//! so it is safe to pass it as const char* to OpenGl package
-//! without copying the string. However, the aspect should not
-//! be deleted until the text drawn using this aspect is no longer
-//! visible. The best practice is to keep the aspect in the object's drawer.
-class Graphic3d_AspectText3d : public Standard_Transient
+//! Creates and updates a group of attributes for text primitives.
+class Graphic3d_AspectText3d : public Graphic3d_Aspects
{
- DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectText3d, Standard_Transient)
+ DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectText3d, Graphic3d_Aspects)
public:
- //! Creates a context table for text primitives
- //! defined with the following default values:
- //!
- //! Color : NOC_YELLOW
- //! Font : NOF_ASCII_MONO
- //! Expansion factor : 1.
- //! Space between characters : 0.
- //! The style : TOST_NORMAL
- //! The display type : TODT_NORMAL
+ //! Creates a context table for text primitives defined with the following default values:
+ //! Color : Quantity_NOC_YELLOW
+ //! Font : Font_NOF_ASCII_MONO
+ //! The style : Aspect_TOST_NORMAL
+ //! The display type : Aspect_TODT_NORMAL
Standard_EXPORT Graphic3d_AspectText3d();
- //! Creates a context table for text primitives
- //! defined with the specified values.
- //! AFont may be to take means from User(example "Courier New")
- //! or Font name defined in Font_NameOfFont(example Font_NOF_ASCII_MONO)
- //! or use default font("Courier")
- Standard_EXPORT Graphic3d_AspectText3d (const Quantity_Color& theColor,
- const Standard_CString theFont,
- const Standard_Real theExpansionFactor,
- const Standard_Real theSpace,
- const Aspect_TypeOfStyleText theStyle = Aspect_TOST_NORMAL,
- const Aspect_TypeOfDisplayText theDisplayType = Aspect_TODT_NORMAL);
+ //! Creates a context table for text primitives defined with the specified values.
+ //! @param theColor [in] text color
+ //! @param theFont [in] font family name or alias like Font_NOF_ASCII_MONO
+ //! @param theExpansionFactor [in] deprecated parameter, has no effect
+ //! @param theSpace [in] deprecated parameter, has no effect
+ //! @param theStyle [in] font style
+ //! @param theDisplayType [in] display mode
+ Standard_EXPORT Graphic3d_AspectText3d (const Quantity_Color& theColor,
+ Standard_CString theFont,
+ Standard_Real theExpansionFactor,
+ Standard_Real theSpace,
+ Aspect_TypeOfStyleText theStyle = Aspect_TOST_NORMAL,
+ Aspect_TypeOfDisplayText theDisplayType = Aspect_TODT_NORMAL);
//! Return the text color.
- const Quantity_Color& Color() const { return myColor.GetRGB(); }
+ const Quantity_Color& Color() const { return myInteriorColor.GetRGB(); }
//! Return the text color.
- const Quantity_ColorRGBA& ColorRGBA() const { return myColor; }
+ const Quantity_ColorRGBA& ColorRGBA() const { return myInteriorColor; }
//! Modifies the color.
- void SetColor (const Quantity_Color& theColor) { myColor.SetRGB (theColor); }
+ void SetColor (const Quantity_Color& theColor) { myInteriorColor.SetRGB (theColor); }
//! Modifies the color.
- void SetColor (const Quantity_ColorRGBA& theColor) { myColor = theColor; }
+ void SetColor (const Quantity_ColorRGBA& theColor) { myInteriorColor = theColor; }
- //! Modifies the expansion factor (height/width ratio)
- //! If the factor is less than 1, the characters will
- //! be higher than they are wide.
- void SetExpansionFactor (const Standard_Real theFactor)
+ //! Return the font.
+ const TCollection_AsciiString& Font() const
{
- if (theFactor <= 0.0)
+ if (myTextFont.IsNull())
{
- throw Graphic3d_AspectTextDefinitionError("Bad value for TextScaleFactor");
+ static const TCollection_AsciiString anEmpty;
+ return anEmpty;
}
- myFactor = theFactor;
+ return myTextFont->String();
}
- //! Return the font.
- const TCollection_AsciiString& Font() const { return myFont; }
-
//! Modifies the font.
void SetFont (const TCollection_AsciiString& theFont)
{
- myFont = !theFont.IsEmpty() ? theFont : TCollection_AsciiString (Font_NOF_ASCII_MONO);
+ if (!theFont.IsEmpty())
+ {
+ myTextFont = new TCollection_HAsciiString (theFont);
+ }
+ else
+ {
+ myTextFont.Nullify();
+ }
}
//! Modifies the font.
SetFont (TCollection_AsciiString (theFont));
}
- //! Return the space between characters.
- Standard_Real Space() const { return mySpace; }
-
- //! Modifies the space between the characters.
- void SetSpace (const Standard_Real theSpace) { mySpace = theSpace; }
-
//! Return the text style.
- Aspect_TypeOfStyleText Style() const { return myStyle; }
+ Aspect_TypeOfStyleText Style() const { return myTextStyle; }
//! Modifies the style of the text.
- //! * TOST_NORMAL
- //! Default text. The text is displayed like any other graphic object.
- //! This text can be hidden by another object that is nearest from the point of view.
- //! * TOST_ANNOTATION
- //! The text is always visible.
- //! The text is displayed over the other object according to the priority.
- void SetStyle (const Aspect_TypeOfStyleText theStyle) { myStyle = theStyle; }
+ void SetStyle (Aspect_TypeOfStyleText theStyle) { myTextStyle = theStyle; }
//! Return display type.
- Aspect_TypeOfDisplayText DisplayType() const { return myDisplayType; }
+ Aspect_TypeOfDisplayText DisplayType() const { return myTextDisplayType; }
//! Define the display type of the text.
- //!
- //! TODT_NORMAL Default display. Text only.
- //! TODT_SUBTITLE There is a subtitle under the text.
- //! TODT_DEKALE The text is displayed with a 3D style.
- //! TODT_BLEND The text is displayed in XOR.
- //! TODT_DIMENSION Dimension line under text will be invisible.
- void SetDisplayType (const Aspect_TypeOfDisplayText theDisplayType) { myDisplayType = theDisplayType; }
-
- //! Return subtitle color.
- const Quantity_ColorRGBA& ColorSubTitleRGBA() const { return myColorSubTitle; }
-
- //! Return subtitle color.
- const Quantity_Color& ColorSubTitle() const { return myColorSubTitle.GetRGB(); }
-
- //! Modifies the color of the subtitle for the TODT_SUBTITLE TextDisplayType
- //! and the color of background for the TODT_DEKALE TextDisplayType.
- void SetColorSubTitle (const Quantity_Color& theColor) { myColorSubTitle.SetRGB (theColor); }
-
- //! Modifies the color of the subtitle for the TODT_SUBTITLE TextDisplayType
- //! and the color of background for the TODT_DEKALE TextDisplayType.
- void SetColorSubTitle (const Quantity_ColorRGBA& theColor) { myColorSubTitle = theColor; }
+ void SetDisplayType (Aspect_TypeOfDisplayText theDisplayType) { myTextDisplayType = theDisplayType; }
//! Returns TRUE when the Text Zoomable is on.
- bool GetTextZoomable() const { return myTextZoomable; }
-
- //! Turns usage of text zoomable on/off
- void SetTextZoomable (const bool theFlag) { myTextZoomable = theFlag; }
+ bool GetTextZoomable() const { return myIsTextZoomable; }
//! Returns Angle of degree
- Standard_Real GetTextAngle() const { return myTextAngle; }
+ Standard_ShortReal GetTextAngle() const { return myTextAngle; }
//! Turns usage of text rotated
- void SetTextAngle (const Standard_Real theAngle) { myTextAngle = theAngle; }
+ void SetTextAngle (const Standard_Real theAngle) { myTextAngle = (Standard_ShortReal )theAngle; }
//! Returns text FontAspect
Font_FontAspect GetTextFontAspect() const { return myTextFontAspect; }
- //! Turns usage of Aspect text
- void SetTextFontAspect (const Font_FontAspect theFontAspect) { myTextFontAspect = theFontAspect; }
-
- //! Return the shader program.
- const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; }
-
- //! Sets up OpenGL/GLSL shader program.
- void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; }
-
-public:
-
- //! Returns the current values of the group.
- Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
- void Values (Quantity_Color& theColor,
- Standard_CString& theFont,
- Standard_Real& theExpansionFactor,
- Standard_Real& theSpace) const
- {
- theColor = myColor.GetRGB();
- theFont = myFont.ToCString();
- theExpansionFactor = myFactor;
- theSpace = mySpace;
- }
-
- //! Returns the current values of the group.
- Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
- void Values (Quantity_Color& theColor,
- Standard_CString& theFont,
- Standard_Real& theExpansionFactor,
- Standard_Real& theSpace,
- Aspect_TypeOfStyleText& theStyle,
- Aspect_TypeOfDisplayText& theDisplayType,
- Quantity_Color& theColorSubTitle) const
- {
- theColor = myColor.GetRGB();
- theFont = myFont.ToCString();
- theExpansionFactor= myFactor;
- theSpace = mySpace;
- theStyle = myStyle;
- theDisplayType = myDisplayType;
- theColorSubTitle = myColorSubTitle.GetRGB();
- }
-
- //! Returns the current values of the group.
- Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
- void Values (Quantity_Color& theColor,
- Standard_CString& theFont,
- Standard_Real& theExpansionFactor,
- Standard_Real& theSpace,
- Aspect_TypeOfStyleText& theStyle,
- Aspect_TypeOfDisplayText& theDisplayType,
- Quantity_Color& theColorSubTitle,
- Standard_Boolean& theTextZoomable,
- Standard_Real& theTextAngle) const
- {
- theColor = myColor.GetRGB();
- theFont = myFont.ToCString();
- theExpansionFactor= myFactor;
- theSpace = mySpace;
- theStyle = myStyle;
- theDisplayType = myDisplayType;
- theColorSubTitle = myColorSubTitle.GetRGB();
-
- theTextZoomable = myTextZoomable;
- theTextAngle = myTextAngle;
- }
-
- //! Returns the current values of the group.
- Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
- void Values (Quantity_Color& theColor,
- Standard_CString& theFont,
- Standard_Real& theExpansionFactor,
- Standard_Real& theSpace,
- Aspect_TypeOfStyleText& theStyle,
- Aspect_TypeOfDisplayText& theDisplayType,
- Quantity_Color& theColorSubTitle,
- Standard_Boolean& theTextZoomable,
- Standard_Real& theTextAngle,
- Font_FontAspect& theTextFontAspect) const
- {
- theColor = myColor.GetRGB();
- theFont = myFont.ToCString();
- theExpansionFactor= myFactor;
- theSpace = mySpace;
- theStyle = myStyle;
- theDisplayType = myDisplayType;
- theColorSubTitle = myColorSubTitle.GetRGB();
-
- theTextZoomable = myTextZoomable;
- theTextAngle = myTextAngle;
- theTextFontAspect = myTextFontAspect;
- }
-
-protected:
-
- TCollection_AsciiString myFont;
- Quantity_ColorRGBA myColor;
- Standard_Real myFactor;
- Standard_Real mySpace;
- Aspect_TypeOfStyleText myStyle;
- Aspect_TypeOfDisplayText myDisplayType;
- Quantity_ColorRGBA myColorSubTitle;
- bool myTextZoomable;
- Standard_Real myTextAngle;
- Font_FontAspect myTextFontAspect;
- Handle(Graphic3d_ShaderProgram) myProgram;
-
};
-DEFINE_STANDARD_HANDLE(Graphic3d_AspectText3d, Standard_Transient)
+DEFINE_STANDARD_HANDLE(Graphic3d_AspectText3d, Graphic3d_Aspects)
#endif // _Graphic3d_AspectText3d_HeaderFile