Salome HOME
Display text in SOCC Viewer
authornds <nds@opencascade.com>
Wed, 14 Sep 2005 06:52:59 +0000 (06:52 +0000)
committernds <nds@opencascade.com>
Wed, 14 Sep 2005 06:52:59 +0000 (06:52 +0000)
src/LIGHTGUI/LIGHTGUI_TextPrs.cxx [new file with mode: 0644]
src/LIGHTGUI/LIGHTGUI_TextPrs.hxx [new file with mode: 0644]

diff --git a/src/LIGHTGUI/LIGHTGUI_TextPrs.cxx b/src/LIGHTGUI/LIGHTGUI_TextPrs.cxx
new file mode 100644 (file)
index 0000000..0d24f1f
--- /dev/null
@@ -0,0 +1,77 @@
+//  LIGHT : sample (no-corba-engine) SALOME module
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//  Author : Natalia DONIS
+//  Date   : 01/09/2005
+//  $Header$
+
+#include <LIGHTGUI_TextPrs.hxx>
+
+#include <Prs3d_Root.hxx>
+#include <Graphic3d_Group.hxx>
+#include <Graphic3d_Vertex.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <Select3D_SensitivePoint.hxx>
+//#include <Select3D_SensitiveSegment.hxx>
+
+IMPLEMENT_STANDARD_HANDLE( LIGHTGUI_TextPrs, AIS_InteractiveObject )
+IMPLEMENT_STANDARD_RTTIEXT( LIGHTGUI_TextPrs, AIS_InteractiveObject )
+
+Standard_Integer aCharSize = 16;
+
+LIGHTGUI_TextPrs::LIGHTGUI_TextPrs(  const char* theString, const gp_Pnt& thePos)
+: myPos( thePos )
+{
+    myString = new char[strlen( theString ) + 1];
+    strcpy( myString, theString );
+}
+
+LIGHTGUI_TextPrs::~LIGHTGUI_TextPrs()
+{
+    delete myString;
+}
+
+void LIGHTGUI_TextPrs::Compute( const Handle(PrsMgr_PresentationManager3d)&,
+                                const Handle(Prs3d_Presentation)& thePrs,
+                                const Standard_Integer )
+{
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( thePrs );
+  aGroup->BeginPrimitives();
+  Graphic3d_Vertex aTextPos;
+  //  aTextPos.SetCoord( myPos.X(), aPos.Y(), aPos.Z() );
+  aTextPos.SetCoord( myPos.X(), myPos.Y(), myPos.Z() );
+  aGroup->Marker( aTextPos );
+  //  aGroup->Text( aNodeIter.Value().ToCString(), aTextPos, aCharSize );
+  aGroup->Text( myString, aTextPos, aCharSize );
+  aGroup->EndPrimitives();
+}
+
+void LIGHTGUI_TextPrs::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
+                                         const Standard_Integer )
+{
+  Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
+  eown -> SelectBasics_EntityOwner::Set( aCharSize );
+  Handle(Select3D_SensitivePoint) seg = new Select3D_SensitivePoint(eown, myPos);
+  //  Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown, myPos, 
+  //                                myPos.Translated( gp_Vec( strlen( myString ) * aCharSize, 0, 0 ) ) );
+  theSelection->Add(seg);
+}
diff --git a/src/LIGHTGUI/LIGHTGUI_TextPrs.hxx b/src/LIGHTGUI/LIGHTGUI_TextPrs.hxx
new file mode 100644 (file)
index 0000000..8fc43b0
--- /dev/null
@@ -0,0 +1,62 @@
+//  LIGHT : sample (no-corba-engine) SALOME module
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//  Author : Julia DOROVSKIKH
+//  Date   : 01/01/2005
+//  $Header$
+
+#ifndef LIGHTGUI_TEXTPRS_H
+#define LIGHTGUI_TEXTPRS_H
+
+#include <AIS_InteractiveObject.hxx>
+#include <gp_Pnt.hxx>
+#include <PrsMgr_PresentationManager3d.hxx>
+#include <Prs3d_Presentation.hxx>
+
+#include <SelectMgr_Selection.hxx>
+
+#include <Standard_DefineHandle.hxx>
+
+class LIGHTGUI_TextPrs: public AIS_InteractiveObject
+{
+public:
+  Standard_EXPORT LIGHTGUI_TextPrs(  const char*, const gp_Pnt& );
+  Standard_EXPORT ~LIGHTGUI_TextPrs();
+
+private:
+  Standard_EXPORT void         Compute( const Handle(PrsMgr_PresentationManager3d)&,
+                                        const Handle(Prs3d_Presentation)&,
+                                        const Standard_Integer = 0 );
+
+  Standard_EXPORT virtual void ComputeSelection( const Handle(SelectMgr_Selection)&,
+                                                 const Standard_Integer );
+
+private:
+  char*               myString;
+  gp_Pnt             myPos;
+
+public:
+  DEFINE_STANDARD_RTTI(LIGHTGUI_TextPrs)
+};
+
+DEFINE_STANDARD_HANDLE(LIGHTGUI_TextPrs, AIS_InteractiveObject)
+
+#endif // LIGHTGUI_TEXTPRS_H