1 // Created on: 2014-11-10
2 // Copyright (c) 2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _AIS_TextLabel_HeaderFile
16 #define _AIS_TextLabel_HeaderFile
18 #include <AIS_InteractiveObject.hxx>
22 #include <Graphic3d_VerticalTextAlignment.hxx>
23 #include <Graphic3d_HorizontalTextAlignment.hxx>
24 #include <Font_FontAspect.hxx>
25 #include <TCollection_ExtendedString.hxx>
27 //! Presentation of the text.
28 class AIS_TextLabel : public AIS_InteractiveObject
32 //! Default constructor
33 Standard_EXPORT AIS_TextLabel();
35 //! Return TRUE for supported display mode.
36 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
38 //! Setup color of entire text.
39 Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
41 //! Setup transparency within [0, 1] range.
42 Standard_EXPORT virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE;
44 //! Removes the transparency setting.
45 virtual void UnsetTransparency() Standard_OVERRIDE { SetTransparency (0.0); }
47 //! Material has no effect for text label.
48 virtual void SetMaterial (const Graphic3d_MaterialAspect& ) Standard_OVERRIDE {}
51 Standard_EXPORT void SetText (const TCollection_ExtendedString& theText);
54 Standard_EXPORT void SetPosition (const gp_Pnt& thePosition);
56 //! Setup horizontal justification.
57 Standard_EXPORT void SetHJustification (const Graphic3d_HorizontalTextAlignment theHJust);
59 //! Setup vertical justification.
60 Standard_EXPORT void SetVJustification (const Graphic3d_VerticalTextAlignment theVJust);
63 Standard_EXPORT void SetAngle (const Standard_Real theAngle);
65 //! Setup zoomable property.
66 Standard_EXPORT void SetZoomable (const Standard_Boolean theIsZoomable);
69 Standard_EXPORT void SetHeight (const Standard_Real theHeight);
71 //! Setup font aspect.
72 Standard_EXPORT void SetFontAspect (const Font_FontAspect theFontAspect);
75 Standard_EXPORT void SetFont (Standard_CString theFont);
77 //! Setup label orientation in the model 3D space.
78 Standard_EXPORT void SetOrientation3D (const gp_Ax2& theOrientation);
80 //! Reset label orientation in the model 3D space.
81 Standard_EXPORT void UnsetOrientation3D ();
84 Standard_EXPORT const gp_Pnt& Position() const;
86 //! Returns the label text.
87 const TCollection_ExtendedString& Text() const { return myText; }
89 //! Returns the font of the label text.
90 Standard_EXPORT const TCollection_AsciiString& FontName() const;
92 //! Returns the font aspect of the label text.
93 Standard_EXPORT Font_FontAspect FontAspect() const;
95 //! Returns label orientation in the model 3D space.
96 Standard_EXPORT const gp_Ax2& Orientation3D() const;
98 //! Returns true if the current text placement mode uses text orientation in the model 3D space.
99 Standard_EXPORT Standard_Boolean HasOrientation3D() const;
101 Standard_EXPORT void SetFlipping (const Standard_Boolean theIsFlipping);
103 Standard_EXPORT Standard_Boolean HasFlipping() const;
105 //! Returns flag if text uses position as point of attach
106 Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchorPoint; }
108 //! Set flag if text uses position as point of attach
109 void SetOwnAnchorPoint (const Standard_Boolean theOwnAnchorPoint) { myHasOwnAnchorPoint = theOwnAnchorPoint; }
111 //! Define the display type of the text.
113 //! TODT_NORMAL Default display. Text only.
114 //! TODT_SUBTITLE There is a subtitle under the text.
115 //! TODT_DEKALE The text is displayed with a 3D style.
116 //! TODT_BLEND The text is displayed in XOR.
117 //! TODT_DIMENSION Dimension line under text will be invisible.
118 Standard_EXPORT void SetDisplayType (const Aspect_TypeOfDisplayText theDisplayType);
120 //! Modifies the colour of the subtitle for the TODT_SUBTITLE TextDisplayType
121 //! and the colour of backgroubd for the TODT_DEKALE TextDisplayType.
122 Standard_EXPORT void SetColorSubTitle (const Quantity_Color& theColor);
127 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
128 const Handle(Prs3d_Presentation)& thePresentation,
129 const Standard_Integer theMode) Standard_OVERRIDE;
131 //! Compute selection
132 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
133 const Standard_Integer theMode) Standard_OVERRIDE;
135 //! Calculate label center, width and height
136 Standard_EXPORT Standard_Boolean calculateLabelParams (const gp_Pnt& thePosition,
137 gp_Pnt& theCenterOfLabel,
138 Standard_Real& theWidth,
139 Standard_Real& theHeight) const;
141 //! Calculate label transformation
142 Standard_EXPORT gp_Trsf calculateLabelTrsf (const gp_Pnt& thePosition,
143 gp_Pnt& theCenterOfLabel) const;
147 TCollection_ExtendedString myText;
148 gp_Ax2 myOrientation3D;
149 Standard_Boolean myHasOrientation3D;
150 Standard_Boolean myHasOwnAnchorPoint;
151 Standard_Boolean myHasFlipping;
156 DEFINE_STANDARD_RTTIEXT(AIS_TextLabel,AIS_InteractiveObject)
160 DEFINE_STANDARD_HANDLE(AIS_TextLabel, AIS_InteractiveObject)
162 #endif // _AIS_TextLabel_HeaderFile