1 // Copyright (C) 2005-2013 OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // LIGHT : sample (no-corba-engine) SALOME module
21 // File : LIGHTGUI_TextPrs.cxx
22 // Author : Natalia DONIS
24 #include "LIGHTGUI_TextPrs.hxx"
26 #include <Prs3d_Root.hxx>
27 #include <Graphic3d_Group.hxx>
28 #include <Graphic3d_Vertex.hxx>
29 #include <SelectMgr_Selection.hxx>
30 #include <SelectMgr_EntityOwner.hxx>
31 #include <Select3D_SensitivePoint.hxx>
33 #include <Basics_OCCTVersion.hxx>
36 \class LIGHTGUI_TextPrs
37 \brief Presentation object for the string line.
40 IMPLEMENT_STANDARD_HANDLE( LIGHTGUI_TextPrs, AIS_InteractiveObject )
41 IMPLEMENT_STANDARD_RTTIEXT( LIGHTGUI_TextPrs, AIS_InteractiveObject )
43 const Standard_Integer aCharSize = 16;
47 \param theString text string
48 \param thePos text position in the viewer
50 LIGHTGUI_TextPrs::LIGHTGUI_TextPrs( const char* theString, const gp_Pnt& thePos )
53 myString = new char[strlen( theString ) + 1];
54 strcpy( myString, theString );
60 LIGHTGUI_TextPrs::~LIGHTGUI_TextPrs()
66 \brief Get presentation text size.
68 int LIGHTGUI_TextPrs::TextSize()
74 \brief Compute the presentation.
75 \param prsMgr presentation manager (not used)
76 \param thePrs presentation
77 \param mode display mode
79 void LIGHTGUI_TextPrs::Compute( const Handle(PrsMgr_PresentationManager3d)& /*prsMgr*/,
80 const Handle(Prs3d_Presentation)& thePrs,
81 const Standard_Integer /*mode*/ )
83 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( thePrs );
84 #if OCC_VERSION_LARGE <= 0x060504
85 aGroup->BeginPrimitives();
87 Graphic3d_Vertex aTextPos;
88 // aTextPos.SetCoord( myPos.X(), aPos.Y(), aPos.Z() );
89 aTextPos.SetCoord( myPos.X(), myPos.Y(), myPos.Z() );
90 aGroup->Marker( aTextPos );
91 // aGroup->Text( aNodeIter.Value().ToCString(), aTextPos, aCharSize );
92 aGroup->Text( myString, aTextPos, aCharSize );
93 #if OCC_VERSION_LARGE <= 0x060504
94 aGroup->EndPrimitives();
99 \brief Compute selection of the presentation.
100 \param theSelection current selection object
101 \param mode display mode
103 void LIGHTGUI_TextPrs::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
104 const Standard_Integer /*mode*/ )
106 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
107 eown -> SelectBasics_EntityOwner::Set( aCharSize );
108 Handle(Select3D_SensitivePoint) seg = new Select3D_SensitivePoint(eown, myPos);
109 // Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown, myPos,
110 // myPos.Translated( gp_Vec( strlen( myString ) * aCharSize, 0, 0 ) ) );
111 theSelection->Add(seg);