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 <Prs3d_Presentation.hxx> 23 #include <Prs3d_TextAspect.hxx> 24 #include <TCollection_AsciiString.hxx> 25 #include <TCollection_ExtendedString.hxx> 26 27 // ======================================================================= 28 // function : Draw 29 // purpose : 30 // ======================================================================= Handle(Graphic3d_Text)31Handle(Graphic3d_Text) Prs3d_Text::Draw (const Handle(Graphic3d_Group)& theGroup, 32 const Handle(Prs3d_TextAspect)& theAspect, 33 const TCollection_ExtendedString& theText, 34 const gp_Pnt& theAttachmentPoint) 35 { 36 theGroup->SetPrimitivesAspect (theAspect->Aspect()); 37 38 Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theAspect->Height()); 39 aText->SetText (theText.ToExtString()); 40 aText->SetPosition (theAttachmentPoint); 41 aText->SetHorizontalAlignment (theAspect->HorizontalJustification()); 42 aText->SetVerticalAlignment (theAspect->VerticalJustification()); 43 theGroup->AddText (aText); 44 return aText; 45 } 46 47 // ======================================================================= 48 // function : Draw 49 // purpose : 50 // ======================================================================= Handle(Graphic3d_Text)51Handle(Graphic3d_Text) Prs3d_Text::Draw (const Handle(Graphic3d_Group)& theGroup, 52 const Handle(Prs3d_TextAspect)& theAspect, 53 const TCollection_ExtendedString& theText, 54 const gp_Ax2& theOrientation, 55 const Standard_Boolean theHasOwnAnchor) 56 { 57 theGroup->SetPrimitivesAspect (theAspect->Aspect()); 58 59 Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theAspect->Height()); 60 aText->SetText (theText.ToExtString()); 61 aText->SetOrientation (theOrientation); 62 aText->SetOwnAnchorPoint (theHasOwnAnchor); 63 aText->SetHorizontalAlignment (theAspect->HorizontalJustification()); 64 aText->SetVerticalAlignment (theAspect->VerticalJustification()); 65 theGroup->AddText (aText); 66 return aText; 67 } 68