Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[samples/light.git] / src / LIGHTGUI / LIGHTGUI_TextPrs.cxx
1 //  LIGHT : sample (no-corba-engine) SALOME module
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //  Author : Natalia DONIS
23 //  Date   : 01/09/2005
24 //  $Header$
25
26 #include <LIGHTGUI_TextPrs.hxx>
27
28 #include <Prs3d_Root.hxx>
29 #include <Graphic3d_Group.hxx>
30 #include <Graphic3d_Vertex.hxx>
31 #include <SelectMgr_Selection.hxx>
32 #include <SelectMgr_EntityOwner.hxx>
33 #include <Select3D_SensitivePoint.hxx>
34 //#include <Select3D_SensitiveSegment.hxx>
35
36 IMPLEMENT_STANDARD_HANDLE( LIGHTGUI_TextPrs, AIS_InteractiveObject )
37 IMPLEMENT_STANDARD_RTTIEXT( LIGHTGUI_TextPrs, AIS_InteractiveObject )
38
39 Standard_Integer aCharSize = 16;
40
41 LIGHTGUI_TextPrs::LIGHTGUI_TextPrs(  const char* theString, const gp_Pnt& thePos)
42 : myPos( thePos )
43 {
44     myString = new char[strlen( theString ) + 1];
45     strcpy( myString, theString );
46 }
47
48 LIGHTGUI_TextPrs::~LIGHTGUI_TextPrs()
49 {
50     delete myString;
51 }
52
53 void LIGHTGUI_TextPrs::Compute( const Handle(PrsMgr_PresentationManager3d)&,
54                                 const Handle(Prs3d_Presentation)& thePrs,
55                                 const Standard_Integer )
56 {
57   Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( thePrs );
58   aGroup->BeginPrimitives();
59   Graphic3d_Vertex aTextPos;
60   //  aTextPos.SetCoord( myPos.X(), aPos.Y(), aPos.Z() );
61   aTextPos.SetCoord( myPos.X(), myPos.Y(), myPos.Z() );
62   aGroup->Marker( aTextPos );
63   //  aGroup->Text( aNodeIter.Value().ToCString(), aTextPos, aCharSize );
64   aGroup->Text( myString, aTextPos, aCharSize );
65   aGroup->EndPrimitives();
66 }
67
68 void LIGHTGUI_TextPrs::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
69                                          const Standard_Integer )
70 {
71   Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
72   eown -> SelectBasics_EntityOwner::Set( aCharSize );
73   Handle(Select3D_SensitivePoint) seg = new Select3D_SensitivePoint(eown, myPos);
74   //  Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown, myPos, 
75   //                                myPos.Translated( gp_Vec( strlen( myString ) * aCharSize, 0, 0 ) ) );
76   theSelection->Add(seg);
77 }