0030537: Visualization - wrapping text in font text formatter
[occt.git] / src / Prs3d / Prs3d_Text.cxx
... / ...
CommitLineData
1// Created on: 1993-09-14
2// Created by: Jean-Louis FRENKEL
3// Copyright (c) 1993-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#include <Prs3d_Text.hxx>
18
19#include <gp_Pnt.hxx>
20#include <Graphic3d_Group.hxx>
21#include <Graphic3d_Text.hxx>
22#include <Graphic3d_Vertex.hxx>
23#include <Prs3d_Presentation.hxx>
24#include <Prs3d_TextAspect.hxx>
25#include <TCollection_AsciiString.hxx>
26#include <TCollection_ExtendedString.hxx>
27
28// =======================================================================
29// function : Draw
30// purpose :
31// =======================================================================
32Handle(Graphic3d_Text) Prs3d_Text::Draw (const Handle(Graphic3d_Group)& theGroup,
33 const Handle(Prs3d_TextAspect)& theAspect,
34 const TCollection_ExtendedString& theText,
35 const gp_Pnt& theAttachmentPoint)
36{
37 theGroup->SetPrimitivesAspect (theAspect->Aspect());
38
39 Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theAspect->Height());
40 aText->SetText (theText.ToExtString());
41 aText->SetPosition (theAttachmentPoint);
42 aText->SetHorizontalAlignment (theAspect->HorizontalJustification());
43 aText->SetVerticalAlignment (theAspect->VerticalJustification());
44 theGroup->AddText (aText);
45 return aText;
46}
47
48// =======================================================================
49// function : Draw
50// purpose :
51// =======================================================================
52Handle(Graphic3d_Text) Prs3d_Text::Draw (const Handle(Graphic3d_Group)& theGroup,
53 const Handle(Prs3d_TextAspect)& theAspect,
54 const TCollection_ExtendedString& theText,
55 const gp_Ax2& theOrientation,
56 const Standard_Boolean theHasOwnAnchor)
57{
58 theGroup->SetPrimitivesAspect (theAspect->Aspect());
59
60 Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theAspect->Height());
61 aText->SetText (theText.ToExtString());
62 aText->SetOrientation (theOrientation);
63 aText->SetOwnAnchorPoint (theHasOwnAnchor);
64 aText->SetHorizontalAlignment (theAspect->HorizontalJustification());
65 aText->SetVerticalAlignment (theAspect->VerticalJustification());
66 theGroup->AddText (aText);
67 return aText;
68}