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 #include <AIS_TextLabel.hxx>
17 #include <Graphic3d_AspectText3d.hxx>
19 #include <Prs3d_Text.hxx>
20 #include <Prs3d_TextAspect.hxx>
22 #include <Select3D_SensitivePoint.hxx>
23 #include <SelectMgr_Selection.hxx>
24 #include <SelectMgr_EntityOwner.hxx>
26 IMPLEMENT_STANDARD_HANDLE (AIS_TextLabel, AIS_InteractiveObject)
27 IMPLEMENT_STANDARD_RTTIEXT(AIS_TextLabel, AIS_InteractiveObject)
29 //=======================================================================
30 //function : AIS_TextLabel
32 //=======================================================================
33 AIS_TextLabel::AIS_TextLabel()
35 myPosition (0.0, 0.0, 0.0),
37 myFontAspect (Font_FA_Regular)
39 myDrawer->SetTextAspect (new Prs3d_TextAspect());
44 //=======================================================================
47 //=======================================================================
48 void AIS_TextLabel::SetColor (const Quantity_Color& theColor)
50 hasOwnColor = Standard_True;
51 myOwnColor = theColor;
52 myDrawer->TextAspect()->SetColor (theColor);
55 //=======================================================================
58 //=======================================================================
59 void AIS_TextLabel::SetColor (const Quantity_NameOfColor theColor)
61 SetColor (Quantity_Color (theColor));
64 //=======================================================================
67 //=======================================================================
68 void AIS_TextLabel::SetText (const TCollection_ExtendedString& theText)
73 //=======================================================================
74 //function : SetPosition
76 //=======================================================================
77 void AIS_TextLabel::SetPosition (const gp_Pnt& thePosition)
79 myPosition = thePosition;
82 //=======================================================================
83 //function : SetHJustification
85 //=======================================================================
86 void AIS_TextLabel::SetHJustification (const Graphic3d_HorizontalTextAlignment theHJust)
88 myDrawer->TextAspect()->SetHorizontalJustification (theHJust);
91 //=======================================================================
92 //function : SetVJustification
93 //purpose : Setup vertical justification.
94 //=======================================================================
95 void AIS_TextLabel::SetVJustification (const Graphic3d_VerticalTextAlignment theVJust)
97 myDrawer->TextAspect()->SetVerticalJustification (theVJust);
100 //=======================================================================
101 //function : SetAngle
103 //=======================================================================
104 void AIS_TextLabel::SetAngle (const Standard_Real theAngle)
106 myDrawer->TextAspect()->Aspect()->SetTextAngle (theAngle * 180.0 / M_PI);
109 //=======================================================================
112 //=======================================================================
113 void AIS_TextLabel::SetZoomable (const Standard_Boolean theIsZoomable)
115 myDrawer->TextAspect()->Aspect()->SetTextZoomable (theIsZoomable);
118 //=======================================================================
119 //function : SetHeight
121 //=======================================================================
122 void AIS_TextLabel::SetHeight (const Standard_Real theHeight)
124 myDrawer->TextAspect()->SetHeight (theHeight);
127 //=======================================================================
128 //function : SetAngle
130 //=======================================================================
131 void AIS_TextLabel::SetFontAspect (const Font_FontAspect theFontAspect)
133 myDrawer->TextAspect()->Aspect()->SetTextFontAspect (theFontAspect);
136 //=======================================================================
139 //=======================================================================
140 void AIS_TextLabel::SetFont (Standard_CString theFont)
143 myDrawer->TextAspect()->SetFont (myFont.ToCString());
146 //=======================================================================
149 //=======================================================================
150 void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePrsMgr*/,
151 const Handle(Prs3d_Presentation)& thePrs,
152 const Standard_Integer theMode)
158 Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect();
159 Prs3d_Text::Draw (thePrs, anAsp, myText, myPosition);
165 //=======================================================================
166 //function : ComputeSelection
168 //=======================================================================
169 void AIS_TextLabel::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
170 const Standard_Integer theMode)
176 Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner (this, 10);
177 Handle(Select3D_SensitivePoint) aSensitivePoint = new Select3D_SensitivePoint (anEntityOwner, myPosition);
178 theSelection->Add (aSensitivePoint);