From decd43d9bcd6b3b1ac3ca86640ca2e2d1a137316 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 14 Sep 2005 06:52:59 +0000 Subject: [PATCH] Display text in SOCC Viewer --- src/LIGHTGUI/LIGHTGUI_TextPrs.cxx | 77 +++++++++++++++++++++++++++++++ src/LIGHTGUI/LIGHTGUI_TextPrs.hxx | 62 +++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 src/LIGHTGUI/LIGHTGUI_TextPrs.cxx create mode 100644 src/LIGHTGUI/LIGHTGUI_TextPrs.hxx diff --git a/src/LIGHTGUI/LIGHTGUI_TextPrs.cxx b/src/LIGHTGUI/LIGHTGUI_TextPrs.cxx new file mode 100644 index 0000000..0d24f1f --- /dev/null +++ b/src/LIGHTGUI/LIGHTGUI_TextPrs.cxx @@ -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 + +#include +#include +#include +#include +#include +#include +//#include + +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 index 0000000..8fc43b0 --- /dev/null +++ b/src/LIGHTGUI/LIGHTGUI_TextPrs.hxx @@ -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 +#include +#include +#include + +#include + +#include + +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 -- 2.39.2