0031221: Visualization - selection filter in context
[occt.git] / src / AIS / AIS_TextLabel.hxx
CommitLineData
29e2c6d2 1// Created on: 2014-11-10
2// Copyright (c) 2014 OPEN CASCADE SAS
3//
4// This file is part of Open CASCADE Technology software library.
5//
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.
11//
12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
14
15#ifndef _AIS_TextLabel_HeaderFile
16#define _AIS_TextLabel_HeaderFile
17
18#include <AIS_InteractiveObject.hxx>
19
20#include <gp_Pnt.hxx>
ce01ec26 21#include <gp_Ax2.hxx>
29e2c6d2 22#include <Graphic3d_VerticalTextAlignment.hxx>
23#include <Graphic3d_HorizontalTextAlignment.hxx>
24#include <Font_FontAspect.hxx>
25#include <TCollection_ExtendedString.hxx>
26
60f7b225 27class Font_TextFormatter;
28
29e2c6d2 29//! Presentation of the text.
30class AIS_TextLabel : public AIS_InteractiveObject
31{
32public:
33
34 //! Default constructor
35 Standard_EXPORT AIS_TextLabel();
36
cc99be36 37 //! Return TRUE for supported display mode.
38 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
39
29e2c6d2 40 //! Setup color of entire text.
41 Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
42
85719f0e 43 //! Setup transparency within [0, 1] range.
44 Standard_EXPORT virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE;
45
46 //! Removes the transparency setting.
47 virtual void UnsetTransparency() Standard_OVERRIDE { SetTransparency (0.0); }
29e2c6d2 48
b6472664 49 //! Material has no effect for text label.
50 virtual void SetMaterial (const Graphic3d_MaterialAspect& ) Standard_OVERRIDE {}
51
29e2c6d2 52 //! Setup text.
53 Standard_EXPORT void SetText (const TCollection_ExtendedString& theText);
54
55 //! Setup position.
56 Standard_EXPORT void SetPosition (const gp_Pnt& thePosition);
57
58 //! Setup horizontal justification.
59 Standard_EXPORT void SetHJustification (const Graphic3d_HorizontalTextAlignment theHJust);
60
61 //! Setup vertical justification.
62 Standard_EXPORT void SetVJustification (const Graphic3d_VerticalTextAlignment theVJust);
63
64 //! Setup angle.
65 Standard_EXPORT void SetAngle (const Standard_Real theAngle);
66
67 //! Setup zoomable property.
68 Standard_EXPORT void SetZoomable (const Standard_Boolean theIsZoomable);
69
70 //! Setup height.
71 Standard_EXPORT void SetHeight (const Standard_Real theHeight);
72
73 //! Setup font aspect.
74 Standard_EXPORT void SetFontAspect (const Font_FontAspect theFontAspect);
75
76 //! Setup font.
77 Standard_EXPORT void SetFont (Standard_CString theFont);
78
ce01ec26 79 //! Setup label orientation in the model 3D space.
80 Standard_EXPORT void SetOrientation3D (const gp_Ax2& theOrientation);
81
82 //! Reset label orientation in the model 3D space.
83 Standard_EXPORT void UnsetOrientation3D ();
84
85 //! Returns position.
86 Standard_EXPORT const gp_Pnt& Position() const;
87
64943a51 88 //! Returns the label text.
89 const TCollection_ExtendedString& Text() const { return myText; }
90
91 //! Returns the font of the label text.
92 Standard_EXPORT const TCollection_AsciiString& FontName() const;
93
94 //! Returns the font aspect of the label text.
95 Standard_EXPORT Font_FontAspect FontAspect() const;
96
ce01ec26 97 //! Returns label orientation in the model 3D space.
98 Standard_EXPORT const gp_Ax2& Orientation3D() const;
99
100 //! Returns true if the current text placement mode uses text orientation in the model 3D space.
101 Standard_EXPORT Standard_Boolean HasOrientation3D() const;
102
3f1eb0ab 103 Standard_EXPORT void SetFlipping (const Standard_Boolean theIsFlipping);
104
105 Standard_EXPORT Standard_Boolean HasFlipping() const;
106
ab9e277f 107 //! Returns flag if text uses position as point of attach
108 Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchorPoint; }
109
110 //! Set flag if text uses position as point of attach
111 void SetOwnAnchorPoint (const Standard_Boolean theOwnAnchorPoint) { myHasOwnAnchorPoint = theOwnAnchorPoint; }
112
61b0191c 113 //! Define the display type of the text.
114 //!
115 //! TODT_NORMAL Default display. Text only.
116 //! TODT_SUBTITLE There is a subtitle under the text.
117 //! TODT_DEKALE The text is displayed with a 3D style.
118 //! TODT_BLEND The text is displayed in XOR.
119 //! TODT_DIMENSION Dimension line under text will be invisible.
120 Standard_EXPORT void SetDisplayType (const Aspect_TypeOfDisplayText theDisplayType);
121
122 //! Modifies the colour of the subtitle for the TODT_SUBTITLE TextDisplayType
123 //! and the colour of backgroubd for the TODT_DEKALE TextDisplayType.
124 Standard_EXPORT void SetColorSubTitle (const Quantity_Color& theColor);
125
60f7b225 126 //! Returns text presentation formatter; NULL by default, which means standard text formatter will be used.
127 const Handle(Font_TextFormatter)& TextFormatter() const { return myFormatter; }
128
129 //! Setup text formatter for presentation. It's empty by default.
130 void SetTextFormatter (const Handle(Font_TextFormatter)& theFormatter) { myFormatter = theFormatter; }
131
3e9c1d1e 132protected:
29e2c6d2 133
134 //! Compute
135 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
136 const Handle(Prs3d_Presentation)& thePresentation,
137 const Standard_Integer theMode) Standard_OVERRIDE;
138
139 //! Compute selection
140 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
141 const Standard_Integer theMode) Standard_OVERRIDE;
142
3e9c1d1e 143 //! Calculate label center, width and height
144 Standard_EXPORT Standard_Boolean calculateLabelParams (const gp_Pnt& thePosition,
145 gp_Pnt& theCenterOfLabel,
146 Standard_Real& theWidth,
147 Standard_Real& theHeight) const;
148
149 //! Calculate label transformation
150 Standard_EXPORT gp_Trsf calculateLabelTrsf (const gp_Pnt& thePosition,
151 gp_Pnt& theCenterOfLabel) const;
152
29e2c6d2 153protected:
154
60f7b225 155 Handle(Font_TextFormatter) myFormatter;
156
29e2c6d2 157 TCollection_ExtendedString myText;
ce01ec26 158 gp_Ax2 myOrientation3D;
159 Standard_Boolean myHasOrientation3D;
ab9e277f 160 Standard_Boolean myHasOwnAnchorPoint;
3f1eb0ab 161 Standard_Boolean myHasFlipping;
29e2c6d2 162
163public:
164
165 //! CASCADE RTTI
a3f6f591 166 DEFINE_STANDARD_RTTIEXT(AIS_TextLabel,AIS_InteractiveObject)
29e2c6d2 167
168};
169
170DEFINE_STANDARD_HANDLE(AIS_TextLabel, AIS_InteractiveObject)
171
172#endif // _AIS_TextLabel_HeaderFile