0030537: Visualization - wrapping text in font text formatter
[occt.git] / src / Prs3d / Prs3d_Text.cxx
CommitLineData
b311480e 1// Created on: 1993-09-14
2// Created by: Jean-Louis FRENKEL
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
4ad142d9 17#include <Prs3d_Text.hxx>
42cf5bc1 18
19#include <gp_Pnt.hxx>
20#include <Graphic3d_Group.hxx>
8ed07085 21#include <Graphic3d_Text.hxx>
7fd59977 22#include <Graphic3d_Vertex.hxx>
42cf5bc1 23#include <Prs3d_Presentation.hxx>
7fd59977 24#include <Prs3d_TextAspect.hxx>
25#include <TCollection_AsciiString.hxx>
42cf5bc1 26#include <TCollection_ExtendedString.hxx>
7fd59977 27
4ad142d9 28// =======================================================================
29// function : Draw
30// purpose :
31// =======================================================================
60f7b225 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)
4ad142d9 36{
4ad142d9 37 theGroup->SetPrimitivesAspect (theAspect->Aspect());
8ed07085 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);
60f7b225 45 return aText;
7fd59977 46}
47
ce01ec26 48// =======================================================================
49// function : Draw
50// purpose :
51// =======================================================================
60f7b225 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)
ce01ec26 57{
4ad142d9 58 theGroup->SetPrimitivesAspect (theAspect->Aspect());
8ed07085 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);
60f7b225 67 return aText;
ce01ec26 68}