From 96407303b7ea789f211978f0282d55bc7afa00a8 Mon Sep 17 00:00:00 2001 From: apl Date: Tue, 18 Oct 2016 16:55:34 +0300 Subject: [PATCH] Store annotation data on AttributeParameter. --- src/GEOMGUI/CMakeLists.txt | 4 +- src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx | 425 ++++++++++++++++++++ src/GEOMGUI/GEOMGUI_AnnotationAttrs.h | 199 +++++++++ src/GEOMGUI/GEOMGUI_ShapeAnnotations.cxx | 352 ---------------- src/GEOMGUI/GEOMGUI_ShapeAnnotations.h | 282 ------------- src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx | 6 +- src/GEOMGUI/GEOM_Displayer.cxx | 24 +- src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx | 48 ++- src/MeasureGUI/MeasureGUI_AnnotationDlg.h | 4 +- 9 files changed, 665 insertions(+), 679 deletions(-) create mode 100755 src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx create mode 100755 src/GEOMGUI/GEOMGUI_AnnotationAttrs.h delete mode 100755 src/GEOMGUI/GEOMGUI_ShapeAnnotations.cxx delete mode 100755 src/GEOMGUI/GEOMGUI_ShapeAnnotations.h mode change 100644 => 100755 src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx mode change 100644 => 100755 src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx mode change 100644 => 100755 src/MeasureGUI/MeasureGUI_AnnotationDlg.h diff --git a/src/GEOMGUI/CMakeLists.txt b/src/GEOMGUI/CMakeLists.txt index c850545b6..b58d082b5 100755 --- a/src/GEOMGUI/CMakeLists.txt +++ b/src/GEOMGUI/CMakeLists.txt @@ -77,7 +77,7 @@ SET(GEOMGUI_HEADERS GEOMGUI_TextTreeWdg.h GEOMGUI_VisualProperties.h GEOMGUI_DimensionProperty.h - GEOMGUI_ShapeAnnotations.h + GEOMGUI_AnnotationAttrs.h ) # header files / to be processed by moc @@ -118,7 +118,7 @@ SET(GEOMGUI_SOURCES GEOMGUI_CreationInfoWdg.cxx GEOMGUI_TextTreeWdg.cxx GEOMGUI_DimensionProperty.cxx - GEOMGUI_ShapeAnnotations.cxx + GEOMGUI_AnnotationAttrs.cxx ${_moc_SOURCES} ${_rcc_SOURCES} ) diff --git a/src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx b/src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx new file mode 100755 index 000000000..224f96f8b --- /dev/null +++ b/src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx @@ -0,0 +1,425 @@ +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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, or (at your option) any later version. +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File : GEOMGUI_AnnotationAttr.cxx +// Author : Anton POLETAEV, Open CASCADE S.A.S. +// + +// SALOME includes +#include +#include +#include + +// OCCT includes +#include + +// STL includes +#include +#include + +IMPLEMENT_STANDARD_RTTIEXT( GEOMGUI_AnnotationAttrs, Standard_Transient ) + +namespace +{ + static const std::string PARAMETER_COUNT = "GEOMGUI_AnnotationAttrs_Count"; + + std::string PARAMETER_I( const std::string& s, const int i ) { + return std::string( s ) + std::to_string( i ); + } + std::string PARAMETER_IS_VISIBLE( const int i ) { + return PARAMETER_I( "GEOMGUI_AnnotationAttrs_IsVisible", i ); + } + std::string PARAMETER_IS_2D( const int i ) { + return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Is2D", i ); + } + std::string PARAMETER_NAME( const int i ) { + return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Name", i ); + } + std::string PARAMETER_TEXT( const int i ) { + return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Text", i ); + } + std::string PARAMETER_POSITION( const int i ) { + return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Position", i ); + } + std::string PARAMETER_ATTACH( const int i ) { + return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Attach", i ); + } + std::string PARAMETER_SHAPE( const int i ) { + return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Shape", i ); + } +} + +//================================================================================= +// function : FindAttributes +// purpose : +//================================================================================= +Handle(GEOMGUI_AnnotationAttrs) GEOMGUI_AnnotationAttrs::FindAttributes( const _PTR(SObject)& theObject ) +{ + _PTR(GenericAttribute) aGenericAttr; + _PTR(AttributeParameter) aParameterMap; + + if ( !theObject->FindAttribute( aGenericAttr, "AttributeParameter" ) ) + { + return Handle(GEOMGUI_AnnotationAttrs)(); + } + + aParameterMap = aGenericAttr; + + if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) ) + { + return Handle(GEOMGUI_AnnotationAttrs)(); + } + + return new GEOMGUI_AnnotationAttrs( theObject, aParameterMap ); +} + +//================================================================================= +// function : FindOrCreateAttributes +// purpose : +//================================================================================= +Handle(GEOMGUI_AnnotationAttrs) GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( + const _PTR(SObject)& theObject, SalomeApp_Study* theStudy ) +{ + _PTR(StudyBuilder) aBuilder = theStudy->studyDS()->NewBuilder(); + _PTR(AttributeParameter) aParameterMap = aBuilder->FindOrCreateAttribute( theObject, "AttributeParameter" ); + if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) ) + { + aParameterMap->SetInt( PARAMETER_COUNT, 0 ); + } + + return new GEOMGUI_AnnotationAttrs( theObject, aParameterMap ); +} + +//================================================================================= +// function : Remove +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::Remove( const _PTR(SObject)& theObject ) +{ + _PTR(GenericAttribute) aGenericAttr; + _PTR(AttributeParameter) aParameterMap; + + if ( !theObject->FindAttribute( aGenericAttr, "AttributeParameter" ) ) + { + return; + } + + aParameterMap = aGenericAttr; + + if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) ) + { + return; + } + + const int aParamCount = aParameterMap->GetInt( PARAMETER_COUNT ); + + for ( int anI = 0; anI < aParamCount; ++anI ) + { + aParameterMap->RemoveID( PARAMETER_IS_VISIBLE( anI ), PT_BOOLEAN ); + aParameterMap->RemoveID( PARAMETER_IS_2D( anI ), PT_BOOLEAN ); + aParameterMap->RemoveID( PARAMETER_NAME( anI ), PT_STRING ); + aParameterMap->RemoveID( PARAMETER_TEXT( anI ), PT_STRING ); + aParameterMap->RemoveID( PARAMETER_POSITION( anI ), PT_REALARRAY ); + aParameterMap->RemoveID( PARAMETER_ATTACH( anI ), PT_REALARRAY ); + aParameterMap->RemoveID( PARAMETER_SHAPE( anI ), PT_INTARRAY ); + } + + aParameterMap->RemoveID( PARAMETER_COUNT, PT_INTEGER ); +} + +//================================================================================= +// function : SetCount +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::SetCount( const int theCount ) const +{ + const int aCount = this->GetCount(); + + if ( aCount < theCount ) + { + // set default values + for ( int anI = aCount; anI < theCount; ++anI ) + { + myParameterMap->SetBool( PARAMETER_IS_VISIBLE( anI ), true ); + myParameterMap->SetBool( PARAMETER_IS_2D( anI ), false ); + myParameterMap->SetString( PARAMETER_NAME( anI ), std::string() ); + myParameterMap->SetString( PARAMETER_TEXT( anI ), std::string() ); + myParameterMap->SetRealArray( PARAMETER_POSITION( anI ), std::vector(3, 0.0) ); + myParameterMap->SetRealArray( PARAMETER_ATTACH( anI ), std::vector(3, 0.0) ); + myParameterMap->SetIntArray( PARAMETER_SHAPE( anI ), std::vector(2, 0) ); + } + } + else + { + // remove exceeding values + for ( int anI = theCount; anI < aCount; ++anI ) + { + myParameterMap->RemoveID( PARAMETER_IS_VISIBLE( anI ), PT_BOOLEAN ); + myParameterMap->RemoveID( PARAMETER_IS_2D( anI ), PT_BOOLEAN ); + myParameterMap->RemoveID( PARAMETER_NAME( anI ), PT_STRING ); + myParameterMap->RemoveID( PARAMETER_TEXT( anI ), PT_STRING ); + myParameterMap->RemoveID( PARAMETER_POSITION( anI ), PT_REALARRAY ); + myParameterMap->RemoveID( PARAMETER_ATTACH( anI ), PT_REALARRAY ); + myParameterMap->RemoveID( PARAMETER_SHAPE( anI ), PT_INTARRAY ); + } + } + + myParameterMap->SetInt( PARAMETER_COUNT, theCount ); +} + +//================================================================================= +// function : GetCount +// purpose : +//================================================================================= +int GEOMGUI_AnnotationAttrs::GetCount() const +{ + return myParameterMap->GetInt( PARAMETER_COUNT ); +} + +//================================================================================= +// function : SetName +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::SetName( const int theIndex, const QString& theName ) +{ + myParameterMap->SetString( PARAMETER_NAME( theIndex ), theName.toStdString() ); +} + +//================================================================================= +// function : GetName +// purpose : +//================================================================================= +QString GEOMGUI_AnnotationAttrs::GetName( const int theIndex ) const +{ + return QString::fromStdString( myParameterMap->GetString( PARAMETER_NAME( theIndex ) ) ); +} + +//================================================================================= +// function : SetVisible +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::SetIsVisible( const int theIndex, const bool theIsVisible ) +{ + myParameterMap->SetBool( PARAMETER_IS_VISIBLE( theIndex ), theIsVisible ); +} + +//================================================================================= +// function : GetIsVisible +// purpose : +//================================================================================= +bool GEOMGUI_AnnotationAttrs::GetIsVisible( const int theIndex ) const +{ + return myParameterMap->GetBool( PARAMETER_IS_VISIBLE( theIndex ) ); +} + +//================================================================================= +// function : SetText +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::SetText( const int theIndex, const QString& theText ) +{ + myParameterMap->SetString( PARAMETER_TEXT( theIndex ), theText.toStdString() ); +} + +//================================================================================= +// function : GetText +// purpose : +//================================================================================= +QString GEOMGUI_AnnotationAttrs::GetText( const int theIndex ) const +{ + return QString::fromStdString( myParameterMap->GetString( PARAMETER_TEXT( theIndex ) ) ); +} + +//================================================================================= +// function : SetIsScreenFixed +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::SetIsScreenFixed( const int theIndex, const bool theIsScreenFixed ) +{ + myParameterMap->SetBool( PARAMETER_IS_2D( theIndex ), theIsScreenFixed ); +} + +//================================================================================= +// function : GetIsScreenFixed +// purpose : +//================================================================================= +bool GEOMGUI_AnnotationAttrs::GetIsScreenFixed( const int theIndex ) const +{ + return myParameterMap->GetBool( PARAMETER_IS_2D( theIndex ) ); +} + +//================================================================================= +// function : SetPosition +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::SetPosition( const int theIndex, const gp_Pnt& thePosition ) +{ + std::vector aCoords( 3 ); + + aCoords[0] = thePosition.X(); + aCoords[1] = thePosition.Y(); + aCoords[2] = thePosition.Z(); + + myParameterMap->SetRealArray( PARAMETER_POSITION( theIndex ), aCoords ); +} + +//================================================================================= +// function : GetPosition +// purpose : +//================================================================================= +gp_Pnt GEOMGUI_AnnotationAttrs::GetPosition( const int theIndex ) const +{ + std::vector aCoords = + myParameterMap->GetRealArray( PARAMETER_POSITION( theIndex ) ); + + return gp_Pnt( aCoords[0], aCoords[1], aCoords[2] ); +} + +//================================================================================= +// function : SetAttach +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::SetAttach( const int theIndex, const gp_Pnt& theAttach ) +{ + std::vector aCoords( 3 ); + + aCoords[0] = theAttach.X(); + aCoords[1] = theAttach.Y(); + aCoords[2] = theAttach.Z(); + + myParameterMap->SetRealArray( PARAMETER_ATTACH( theIndex ), aCoords ); +} + +//================================================================================= +// function : GetAttach +// purpose : +//================================================================================= +gp_Pnt GEOMGUI_AnnotationAttrs::GetAttach( const int theIndex ) const +{ + std::vector aCoords = + myParameterMap->GetRealArray( PARAMETER_ATTACH( theIndex ) ); + + return gp_Pnt( aCoords[0], aCoords[1], aCoords[2] ); +} + +//================================================================================= +// function : SetShapeSel +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::SetShapeSel( const int theIndex, const int theShapeType, const int theSubIdx ) +{ + std::vector aSelection( 2 ); + + aSelection[0] = theShapeType; + aSelection[1] = theSubIdx; + + myParameterMap->SetIntArray( PARAMETER_SHAPE( theIndex ), aSelection ); +} + +//================================================================================= +// function : GetShapeSel +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::GetShapeSel( const int theIndex, int& theShapeType, int& theSubIdx ) const +{ + std::vector aSelection = + myParameterMap->GetIntArray( PARAMETER_SHAPE( theIndex ) ); + + theShapeType = aSelection[0]; + theSubIdx = aSelection[1]; +} + +//================================================================================= +// function : Append +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::Append( const Properties& theProps ) +{ + const int aCount = this->GetCount(); + this->SetCount( aCount + 1 ); + this->SetProperties( aCount, theProps ); +} + +//================================================================================= +// function : SetProperties +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::SetProperties( const int theIndex, const Properties& theProps ) +{ + this->SetName( theIndex, theProps.Name ); + this->SetText( theIndex, theProps.Text ); + this->SetIsVisible( theIndex, theProps.IsVisible ); + this->SetIsScreenFixed( theIndex, theProps.IsScreenFixed ); + this->SetPosition( theIndex, theProps.Position ); + this->SetAttach( theIndex, theProps.Attach ); + this->SetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex ); +} + +//================================================================================= +// function : GetProperties +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::GetProperties( const int theIndex, Properties& theProps ) const +{ + theProps.Name = this->GetName( theIndex ); + theProps.Text = this->GetText( theIndex ); + theProps.IsVisible = this->GetIsVisible( theIndex ); + theProps.IsScreenFixed = this->GetIsScreenFixed( theIndex ); + theProps.Position = this->GetPosition( theIndex ); + theProps.Attach = this->GetAttach( theIndex ); + + this->GetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex ); +} + +//================================================================================= +// function : SetupPresentation +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation, + const Properties& theProps, + const gp_Ax3& theLCS ) +{ + gp_Trsf aToLCS; + aToLCS.SetTransformation( theLCS, gp_Ax3() ); + + TCollection_ExtendedString aText; + for (int i = 0; i < (int)theProps.Text.length(); i++ ) + aText.Insert( i + 1, theProps.Text[ i ].unicode() ); + // + thePresentation->SetText( aText ); + thePresentation->SetScreenFixed( theProps.IsScreenFixed ); + thePresentation->SetPosition( theProps.Position ); + thePresentation->SetAttachPoint( theProps.Attach.Transformed( aToLCS ) ); +} + +//================================================================================= +// function : SetupPresentation +// purpose : +//================================================================================= +void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation, + const int theIndex, + const gp_Ax3& theLCS ) +{ + Properties aProps; + this->GetProperties( theIndex, aProps ); + this->SetupPresentation( thePresentation, aProps, theLCS ); +} diff --git a/src/GEOMGUI/GEOMGUI_AnnotationAttrs.h b/src/GEOMGUI/GEOMGUI_AnnotationAttrs.h new file mode 100755 index 000000000..ff74191a3 --- /dev/null +++ b/src/GEOMGUI/GEOMGUI_AnnotationAttrs.h @@ -0,0 +1,199 @@ +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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, or (at your option) any later version. +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File : GEOMGUI_AnnotationAttrs.h +// Author : Anton POLETAEV, Open CASCADE S.A.S. +// + +#ifndef GEOMGUI_ANNOTATIONATTRS_H +#define GEOMGUI_ANNOTATIONATTRS_H + +// SALOME GUI includes +#include + +// OCCT includes +#include +#include + +// Qt, STL includes +#include + +class GEOM_Annotation; +class gp_Ax3; + +/*! + * \brief Attribute-style helper tool to manage shape annotation data of an object. + */ +class GEOMGUI_AnnotationAttrs : public Standard_Transient +{ +public: + + DEFINE_STANDARD_RTTIEXT( GEOMGUI_AnnotationAttrs, Standard_Transient ) + + //! Find annotation data defined for an object. + Standard_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindAttributes( const _PTR(SObject)& theObject ); + + //! Find or create annotation data fields for an object. + Standard_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindOrCreateAttributes( const _PTR(SObject)& theObject, + SalomeApp_Study* theStudy ); + + //! Remove annotation data fields for an object. + Standard_EXPORT static void Remove( const _PTR(SObject)& theObject ); + +public: + + /*! + * \ brief Structure representing visual properties of the shape annotation. + */ + struct Properties + { + QString Name; //!< Application name of annotation. + QString Text; //!< Displayed annotation text. + bool IsVisible; //!< Application visibility flag of annotation. + bool IsScreenFixed; //!< Fixed screen mode flag. + gp_Pnt Position; //!< Position of the annotation. + gp_Pnt Attach; //!< Attachment point of the annotation. + int ShapeIndex; //!< Index of the annotated subshape. + int ShapeType; //!< Type of the annotated subshape. + }; + + //! Setup parameters of the annotation presentation with the properties given. + //! @param thePresentation [in] the presentation to setup. + //! @param theProps [in] the set of properties. + //! @param theLCS [in] the local coordinate system of the shape. + Standard_EXPORT static void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation, + const Properties& theProps, + const gp_Ax3& theLCS ); + + //! Setup parameters of the annotation presentation with the properties of a definition. + //! @param thePresentation [in] the presentation to setup. + //! @param theIndex [in] the index of the annotation definition. + //! @param theLCS [in] the local coordinate system of the shape. + Standard_EXPORT void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation, + const int theIndex, + const gp_Ax3& theLCS ); + +public: + + //! Changes count of annotation definitions stored on the object. + //! If the count is decreased the extra annotation definitions are + //! cleared out from the attribute. + //! @param theNumber [in] the new number of annotation definitions. + Standard_EXPORT void SetCount( const int theCount ) const; + + //! Returns number of annotation definitions stored on the object. + Standard_EXPORT int GetCount() const; + + //! Sets application name property of an annotation definition. + //! @param theIndex [in] the index of the annotation definition. + //! @param theName [in] the new application name. + Standard_EXPORT void SetName( const int theIndex, const QString& theName ); + + //! Returns application name of an annotation definition. + //! @param theIndex [in] the index of the annotation definition. + Standard_EXPORT QString GetName( const int theIndex ) const; + + //! Sets application visibility state of an annotation definition. + //! @param theIndex [in] the index of the annotation definition. + //! @param theIsVisible [in] the visibility state. + Standard_EXPORT void SetIsVisible( const int theIndex, const bool theIsVisible ); + + //! Returns applicationb visibility state of an annotaion definition. + Standard_EXPORT bool GetIsVisible( const int theIndex ) const; + + //! Sets annotation label's text. + //! @param theIndex [in] the index of the annotation definition. + //! @param theText [in] the text string. + Standard_EXPORT void SetText( const int theIndex, const QString& theText ); + + //! Returns annotation label's text. + Standard_EXPORT QString GetText( const int theIndex ) const; + + //! Sets screen fixed flag of the annotation definition. + //! @param theIndex [in] the index of the annotation definition. + //! @param theIsScreenFixed [in] the presentation flag. + Standard_EXPORT void SetIsScreenFixed( const int theIndex, const bool theIsScreenFixed ); + + //! Returns screen fixed flag of the annotation definition. + Standard_EXPORT bool GetIsScreenFixed( const int theIndex ) const; + + //! Sets position of the annotation definition. + //! @param theIndex [in] the index of the annotation definition. + //! @param thePosition [in] the position of the annotation label. + Standard_EXPORT void SetPosition( const int theIndex, const gp_Pnt& thePosition ); + + //! Returns position of the annotation definition. + Standard_EXPORT gp_Pnt GetPosition( const int theIndex ) const; + + //! Sets attach point of the annotation definition. + //! @param theIndex [in] the index of the annotation definition. + //! @param theAttach [in] the attach point of the annotation. + Standard_EXPORT void SetAttach( const int theIndex, const gp_Pnt& theAttach ); + + //! Returns attach point of the annotation definition. + Standard_EXPORT gp_Pnt GetAttach( const int theIndex ) const; + + //! Sets shape selection arguments. + //! @param theIndex [in] the index of the annotation definition. + //! @param theShapeType, theSubIdx [in] the type of the selected shape and the sub-shape index. + Standard_EXPORT void SetShapeSel( const int theIndex, const int theShapeType, const int theSubIdx ); + + //! Returns shape selection arguments. + //! @param theIndex [in] the index of the annotation definition. + //! @param theShapeType, theSubIdx [out] the type of the selected shape and the sub-shape index. + Standard_EXPORT void GetShapeSel( const int theIndex, int& theShapeType, int& theSubIdx ) const; + +public: + + //! Appends new annotation definition with the given properties. + Standard_EXPORT void Append( const Properties& theProps ); + + //! Sets complete properties of an annotation definition. + //! @param theIndex [in] the index of the annotation definition. + //! @param theProps [in] the structure containing the properties. + Standard_EXPORT void SetProperties( const int theIndex, const Properties& theProps ); + + //! Returns complete properties of an annotation definition. + //! @param theIndex [in] the index of the annotation definition. + //! @param theProps [out] the structure containing the properties. + Standard_EXPORT void GetProperties( const int theIndex, Properties& theProps ) const; + +private: + + GEOMGUI_AnnotationAttrs( const _PTR(SObject)& theObject, + const _PTR(AttributeParameter)& theParameter ) + : myObj( theObject ), + myParameterMap( theParameter ) {} + + GEOMGUI_AnnotationAttrs( const GEOMGUI_AnnotationAttrs& theOther ) {} + + void operator=( const GEOMGUI_AnnotationAttrs& theOther ) {} + +private: + + _PTR(SObject) myObj; + _PTR(AttributeParameter) myParameterMap; +}; + +DEFINE_STANDARD_HANDLE( GEOMGUI_AnnotationAttrs, Standard_Transient ) + +#endif diff --git a/src/GEOMGUI/GEOMGUI_ShapeAnnotations.cxx b/src/GEOMGUI/GEOMGUI_ShapeAnnotations.cxx deleted file mode 100755 index 89c66f36f..000000000 --- a/src/GEOMGUI/GEOMGUI_ShapeAnnotations.cxx +++ /dev/null @@ -1,352 +0,0 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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, or (at your option) any later version. -// -// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : GEOMGUI_ShapeAnnotations.cxx -// Author : Anton POLETAEV, Open CASCADE S.A.S. -// - -#include -#include - -// OCCT includes -#include -#include - -#include - -// REGEXP pattern for converting array of entries into plain text string. -// The pattern has the following structure: -// ENTRY: { text[string] : visibility[bool] : screen fixed[bool] : position[xyz] : attach[xyz] } -namespace -{ - static const QString PATTERN_ITEM_GROUP = "\\{ (Text=(?::{2,}|.)*:(?!:)Visible=.*:Screen=.*:Position=\\{(.*):(.*):(.*)\\}:Attach=\\{(.*):(.*):(.*)\\}:ShapeIdx=.*:ShapeType=.*) \\}"; - static const QString PATTERN_ITEM = "Text=((?::{2,}|.)*):(?!:)Visible=(\\d{1}):Screen=(\\d{1}):Position=\\{(.*):(.*):(.*)\\}:Attach=\\{(.*):(.*):(.*)\\}:ShapeIdx=(\\d{1,*}):ShapeType=(\\d{1})"; - static QString toPattern (const QString& theText, - const bool theIsVisible, - const bool theIsFixed, - const gp_Pnt& thePosition, - const gp_Pnt& theAttach, - const int theShapeIndex, - const int theShapeType) - { - return QString( "{ Text=" ) + theText + - QString( ":" ) + QString( "Visible=" ) + QString::number( theIsVisible ? 1 : 0 ) + - QString( ":" ) + QString( "Screen=" ) + QString::number( theIsFixed ? 1 : 0 ) + - QString( ":" ) + QString( "Position={" ) + - QString::number( thePosition.X() ) + QString( ":" ) + - QString::number( thePosition.Y() ) + QString( ":" ) + - QString::number( thePosition.Z() ) + QString( "}" ) + - QString( ":" ) + QString( "Attach={" ) + - QString::number( theAttach.X() ) + QString( ":" ) + - QString::number( theAttach.Y() ) + QString( ":" ) + - QString::number( theAttach.Z() ) + QString( "}" ) + - QString( ":" ) + QString( "ShapeIdx=" ) + QString::number( theShapeIndex ) + - QString( ":" ) + QString( "ShapeType=" ) + QString::number( theShapeType ) + - QString( " }" ); - } -}; - -//================================================================================= -// function : ToPresentation -// purpose : -//================================================================================= -void GEOMGUI_ShapeAnnotations::ShapeAnnotation::ToPresentation( - const Handle(GEOM_Annotation)& theShapeAnnotation, - const gp_Ax3& theLCS ) const -{ - gp_Trsf aToLCS; - aToLCS.SetTransformation( theLCS, gp_Ax3() ); - - // - TCollection_ExtendedString aText; - for (int i = 0; i < (int)Text.length(); i++ ) - aText.Insert( i + 1, Text[ i ].unicode() ); - // - theShapeAnnotation->SetScreenFixed( IsScreenFixed ); - theShapeAnnotation->SetText( aText ); - theShapeAnnotation->SetPosition( Position ); - theShapeAnnotation->SetAttachPoint( Attach.Transformed( aToLCS ) ); -} - - -//================================================================================= -// function : Constructor -// purpose : -//================================================================================= -GEOMGUI_ShapeAnnotations::GEOMGUI_ShapeAnnotations() -{ -} - -//================================================================================= -// function : Copy constructor -// purpose : -//================================================================================= -GEOMGUI_ShapeAnnotations::GEOMGUI_ShapeAnnotations( const GEOMGUI_ShapeAnnotations& theOther ) -{ - myAnnotations = theOther.myAnnotations; -} - -//================================================================================= -// function : Init constructor -// purpose : -//================================================================================= -GEOMGUI_ShapeAnnotations::GEOMGUI_ShapeAnnotations( SalomeApp_Study* theStudy, const std::string& theEntry ) -{ - LoadFromAttribute( theStudy, theEntry ); -} - -//================================================================================= -// function : Init constructor -// purpose : -//================================================================================= -GEOMGUI_ShapeAnnotations::GEOMGUI_ShapeAnnotations( const QString& theProperty ) -{ - QRegExp aRegExpItemGroups( PATTERN_ITEM_GROUP ); - QRegExp aRegExpItem( "^" + PATTERN_ITEM + "$" ); - aRegExpItemGroups.setMinimal( true ); - aRegExpItem.setMinimal( true ); - - int aPos = 0; - while ( ( aPos = aRegExpItemGroups.indexIn( theProperty, aPos ) ) != -1 ) - { - aPos += aRegExpItemGroups.matchedLength(); - - QString aStrItem = aRegExpItemGroups.cap(1); - - if ( aRegExpItem.indexIn( aStrItem ) < 0 ) - { - continue; - } - - QString aStrName = "Annotation_X"; // TODO - QString aStrText = aRegExpItem.cap( 1 ); - QString aStrVisible = aRegExpItem.cap( 2 ); - QString aStrFixed = aRegExpItem.cap( 3 ); - QString aStrPosX = aRegExpItem.cap( 4 ); - QString aStrPosY = aRegExpItem.cap( 5 ); - QString aStrPosZ = aRegExpItem.cap( 6 ); - QString aStrAttX = aRegExpItem.cap( 7 ); - QString aStrAttY = aRegExpItem.cap( 8 ); - QString aStrAttZ = aRegExpItem.cap( 9 ); - QString aStrShapeIdx = aRegExpItem.cap( 10 ); - QString aStrShapeType = aRegExpItem.cap( 11 ); - aStrText.replace( "::", ":" ); - - ShapeAnnotation aEntry; - aEntry.Name = aStrName; - aEntry.Text = aStrText; - aEntry.IsVisible = aStrVisible.toInt() != 0; - aEntry.IsScreenFixed = aStrFixed.toInt() != 0; - aEntry.Position.SetX( aStrPosX.toDouble() ); - aEntry.Position.SetY( aStrPosY.toDouble() ); - aEntry.Position.SetZ( aStrPosZ.toDouble() ); - aEntry.Attach.SetX( aStrAttX.toDouble() ); - aEntry.Attach.SetY( aStrAttY.toDouble() ); - aEntry.Attach.SetZ( aStrAttZ.toDouble() ); - aEntry.ShapeIndex = aStrShapeIdx.toInt(); - aEntry.ShapeType = aStrShapeType.toInt(); - - myAnnotations.append( aEntry ); - } -} - -//================================================================================= -// function : Destructor -// purpose : -//================================================================================= -GEOMGUI_ShapeAnnotations::~GEOMGUI_ShapeAnnotations() -{ -} - -//================================================================================= -// function : operator QVariant() -// purpose : -//================================================================================= -GEOMGUI_ShapeAnnotations::operator QVariant() const -{ - QVariant aQVariant; - aQVariant.setValue( *this ); - return aQVariant; -} - -//================================================================================= -// function : operator QString() -// purpose : -//================================================================================= -GEOMGUI_ShapeAnnotations::operator QString() const -{ - QStringList anItems; - - for ( int i = 0; i < myAnnotations.size(); ++i ) - { - const ShapeAnnotation& aEntry = myAnnotations[i]; - // - anItems.append( toPattern( aEntry.Text, - aEntry.IsVisible, - aEntry.IsScreenFixed, - aEntry.Position, - aEntry.Attach, - aEntry.ShapeIndex, - aEntry.ShapeType ) ); - } - - return anItems.join( ":" ); -} - -//================================================================================= -// function : operator == -// purpose : -//================================================================================= -bool GEOMGUI_ShapeAnnotations::operator == (const GEOMGUI_ShapeAnnotations& theOther) const -{ - if ( myAnnotations.size() != theOther.myAnnotations.size() ) - { - return false; - } - - for ( int i = 0; i < myAnnotations.size(); ++i ) - { - if ( myAnnotations[i] != theOther.myAnnotations[i] ) - { - return false; - } - } - - return true; -} - -//================================================================================= -// function : FromPresentation -// purpose : -//================================================================================= -void GEOMGUI_ShapeAnnotations::FromPresentation( const int theIndex, - const Handle(GEOM_Annotation)& theShapeAnnotation, - const gp_Ax3& theLCS ) -{ - gp_Trsf aFromLCS; - aFromLCS.SetTransformation( gp_Ax3(), theLCS ); - // - ShapeAnnotation& aChangeEntry = myAnnotations[theIndex]; - aChangeEntry.IsScreenFixed = theShapeAnnotation->GetIsScreenFixed(); - aChangeEntry.Name = "Annotation_X"; /// TODO - aChangeEntry.Text = QString( (QChar*) theShapeAnnotation->GetText().ToExtString(), theShapeAnnotation->GetText().Length() ); - aChangeEntry.Attach = theShapeAnnotation->GetAttachPoint().Transformed( aFromLCS ); - aChangeEntry.Position = theShapeAnnotation->GetPosition(); -} - -//================================================================================= -// function : ToPresentation -// purpose : -//================================================================================= -void GEOMGUI_ShapeAnnotations::ToPresentation( const int theIndex, - const Handle(GEOM_Annotation)& theShapeAnnotation, - const gp_Ax3& theLCS ) -{ - myAnnotations[theIndex].ToPresentation(theShapeAnnotation, theLCS); -} - -//================================================================================= -// function : LoadFromAttribute -// purpose : -//================================================================================= -void GEOMGUI_ShapeAnnotations::LoadFromAttribute( SalomeApp_Study* theStudy, const std::string& theEntry ) -{ - Clear(); - - _PTR(SObject) aSObj = theStudy->studyDS()->FindObjectID( theEntry ); - if ( !aSObj ) - { - return; - } - - _PTR(StudyBuilder) aBuilder = theStudy->studyDS()->NewBuilder(); - - _PTR(GenericAttribute) aSeekAtt; - _PTR(AttributeTableOfReal) aDataAtt; - - if ( !aSObj->FindAttribute( aSeekAtt, "AttributeTableOfReal" ) ) - { - return; - } - - aDataAtt = aSeekAtt; - - for ( int i = 1; i <= aDataAtt->GetNbColumns(); ++i ) - { - std::vector aPropertyArray = aDataAtt->GetColumn( i ); - - ShapeAnnotation aEntry; - aEntry.Text = aDataAtt->GetColumnTitle( i ).c_str(); - aEntry.IsVisible = static_cast( aPropertyArray[i++] ); - aEntry.IsScreenFixed = static_cast( aPropertyArray[i++] ); - aEntry.Position.SetX( static_cast( aPropertyArray[i++] ) ); - aEntry.Position.SetY( static_cast( aPropertyArray[i++] ) ); - aEntry.Position.SetZ( static_cast( aPropertyArray[i++] ) ); - aEntry.Attach.SetX( static_cast( aPropertyArray[i++] ) ); - aEntry.Attach.SetY( static_cast( aPropertyArray[i++] ) ); - aEntry.Attach.SetZ( static_cast( aPropertyArray[i++] ) ); - aEntry.ShapeIndex = static_cast( aPropertyArray[i++] ); - aEntry.ShapeType = static_cast( aPropertyArray[i++] ); - - myAnnotations.append( aEntry ); - } -} - -//================================================================================= -// function : SaveToAttribute -// purpose : -//================================================================================= -void GEOMGUI_ShapeAnnotations::SaveToAttribute( SalomeApp_Study *theStudy, const std::string &theEntry ) -{ - _PTR(SObject) aSObj = theStudy->studyDS()->FindObjectID( theEntry ); - if ( !aSObj ) - { - return; - } - - _PTR(StudyBuilder) aBuilder = theStudy->studyDS()->NewBuilder(); - - _PTR(AttributeTableOfReal) aDataAtt; - - aDataAtt = aBuilder->FindOrCreateAttribute( aSObj, "AttributeTableOfReal" ); - aDataAtt->SetNbColumns( 0 ); - - for ( int i = 0; i < myAnnotations.size(); ++i ) - { - const ShapeAnnotation& aEntry = myAnnotations[i]; - - std::vector aPropertyArray; - aPropertyArray.push_back( static_cast(aEntry.IsVisible) ); - aPropertyArray.push_back( static_cast(aEntry.IsScreenFixed) ); - aPropertyArray.push_back( aEntry.Position.X() ); - aPropertyArray.push_back( aEntry.Position.Y() ); - aPropertyArray.push_back( aEntry.Position.Z() ); - aPropertyArray.push_back( aEntry.Attach.X() ); - aPropertyArray.push_back( aEntry.Attach.Y() ); - aPropertyArray.push_back( aEntry.Attach.Z() ); - aPropertyArray.push_back( static_cast( aEntry.ShapeIndex ) ); - aPropertyArray.push_back( static_cast( aEntry.ShapeType ) ); - - aDataAtt->AddColumn( aPropertyArray ); - aDataAtt->SetColumnTitle( i + 1, aEntry.Text.toStdString() ); - } -} diff --git a/src/GEOMGUI/GEOMGUI_ShapeAnnotations.h b/src/GEOMGUI/GEOMGUI_ShapeAnnotations.h deleted file mode 100755 index a86693195..000000000 --- a/src/GEOMGUI/GEOMGUI_ShapeAnnotations.h +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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, or (at your option) any later version. -// -// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : GEOMGUI_ShapeAnnotations.h -// Author : Anton POLETAEV, Open CASCADE S.A.S. -// - -#ifndef GEOMGUI_SHAPEANNOTATIONS_H -#define GEOMGUI_SHAPEANNOTATIONS_H - -#include - -// OCCT includes -#include -#include -#include -#include - -#include -#include -#include - -class SalomeApp_Study; -class GEOM_Annotation; - -class GEOMGUI_ShapeAnnotations; -typedef QSharedPointer ShapeAnnotationsPtr; - -/*! - * \brief Algorithms to translate and manitain list of shape annotation properties. - * - * Shape annotation presentations are store in relative coordinate system (LCS). - * To ensure that dimension is bound to the equal shape irrespectively of its location - * transformation. - */ -class Standard_EXPORT GEOMGUI_ShapeAnnotations : public GEOMGUI_VisualProperties -{ -public: - - /*! - * \ brief Structure representing properties of the shape annotation entry. - */ - struct ShapeAnnotation - { - QString Name; // annotation name label - QString Text; // annotation text label - bool IsVisible; // visibility of annotation - bool IsScreenFixed; // fixed screen mode flag - gp_Pnt Position; // position of the annotation - gp_Pnt Attach; // attachment point of the annotation - int ShapeIndex; // index of the annotated subshape - int ShapeType; // type of the annotated subshape - - /*! - * \brief Update presentation properties using the annotation record definition. - * \param theShapeAnnotation [in] the explicit definition of the annotation. - */ - void ToPresentation( const Handle(GEOM_Annotation)& theShapeAnnotation, - const gp_Ax3& theLCS ) const; - - bool operator == (const ShapeAnnotation& theOther) const - { - return Name == theOther.Name - && Text == theOther.Text - && IsVisible == theOther.IsVisible - && IsScreenFixed == theOther.IsScreenFixed - && Position.IsEqual (theOther.Position, 0.0) - && Attach.IsEqual (theOther.Attach, 0.0) - && ShapeIndex == theOther.ShapeIndex - && ShapeType == theOther.ShapeType; - } - - bool operator != (const ShapeAnnotation& theOther) const - { - return !(operator == (theOther)); - } - }; - -public: - - /*! - * \brief Constructor. Inits empty property. - */ - GEOMGUI_ShapeAnnotations(); - - /*! - * \brief Copy constructor. - */ - GEOMGUI_ShapeAnnotations( const GEOMGUI_ShapeAnnotations& theOther ); - - /*! - * \brief Constructor. Inits property from attribute. - */ - GEOMGUI_ShapeAnnotations( SalomeApp_Study* theStudy, const std::string& theEntry ); - - /*! - * \brief Constructor. Inits property from formatted QString. - */ - GEOMGUI_ShapeAnnotations( const QString& theProperty ); - - /*! - * \brief Destructor. - */ - ~GEOMGUI_ShapeAnnotations(); - - /*! - * \brief Overload QVariant cast operator. - */ - operator QVariant() const; - - /*! - * \brief Overload QString cast operator. - */ - operator QString() const; - - /*! - * \brief Overload comparsion. - */ - bool operator == (const GEOMGUI_ShapeAnnotations &theOther) const; - - /*! - * \brief Overload comparsion. - */ - bool operator != (const GEOMGUI_ShapeAnnotations &theOther) const - { - return !(operator == (theOther)); - } - -public: - - /*! - * \brief Adds new shape annotation entry using explicit definition. - * \param theShapeAnnotation [in] the explicit definition of the annotation. - * \param theLCS [in] the local coordinate system of parent object. - */ - void Add( const ShapeAnnotation& theShapeAnnotation ) - { - myAnnotations.append( theShapeAnnotation ); - } - - /*! - * \brief Update entry data using the explicit definition. - * \param theIndex [in] the index of the dimension record. - * \param theShapeAnnotation [in] the explicit definition of the annotation. - */ - void SetValues( const int theIndex, const ShapeAnnotation& theShapeAnnotation ) - { - myAnnotations[theIndex] = theShapeAnnotation; - } - - /*! - * \brief Sets annotation's entry data using the properties of interactive presentation. - * \param theIndex [in] the index of the record. - * \param theShapeAnnotation [in] the interactive presnetation. - * \param theLCS [in] the local coordinate system of parent object. - */ - void FromPresentation( const int theIndex, - const Handle(GEOM_Annotation)& theShapeAnnotation, - const gp_Ax3& theLCS ); - - /*! - * \brief Update presentation properties using the annotation record definition. - * \param theIndex [in] the index of the dimension record. - * \param theShapeAnnotation [in] the explicit definition of the annotation. - */ - void ToPresentation( const int theIndex, - const Handle(GEOM_Annotation)& theShapeAnnotation, - const gp_Ax3& theLCS ); - - /*! - * \brief Get explicit definition of an annotation by index. - * \param theIndex [in] the index of the entry. - */ - const ShapeAnnotation& Get( const int theIndex ) const { return myAnnotations[theIndex]; } - - /*! - * \brief Returns mutable reference on the annotation entry. - * \param theIndex [in] the index of annotation entry. - */ - ShapeAnnotation& Change( const int theIndex ) { return myAnnotations[theIndex]; } - - /*! - * \brief Removes entry by its index. - * \param theIndex [in] the index of annotation entry. - */ - void Remove( const int theIndex ) { myAnnotations.remove( theIndex ); } - - /*! - * \brief Clears property data. - */ - void Clear() { myAnnotations.clear(); } - - /*! - * \brief Returns number of shape annotation records. - */ - virtual int GetNumber() const { return myAnnotations.size(); }; - - /*! - * \brief Returns visibility state of dimension record by its index. - * - * \param theIndex [in] the index of the dimension record. - */ - virtual bool IsVisible( const int theIndex ) const - { - return myAnnotations[theIndex].IsVisible; - } - - /*! - * \brief Changes visibility state of the dimension record. - * - * \param theIndex [in] the index of the dimension record. - * \param theIsVisible [in] the new visibility state. - */ - virtual void SetVisible( const int theIndex, const bool theIsVisible ) - { - myAnnotations[theIndex].IsVisible = theIsVisible; - } - - /*! - * \brief Returns name of dimension record by its index. - * - * \param theIndex [in] the index of the dimension record. - */ - virtual QString GetName( const int theIndex ) const - { - return myAnnotations[theIndex].Name; - } - - /*! - * \brief Changes name of dimension record. - * - * \param theIndex [in] the index of the dimension record. - * \param theName [in] the new name. - */ - virtual void SetName( const int theIndex, const QString& theName ) - { - myAnnotations[theIndex].Name = theName; - } - -public: - - /*! - * \brief Loads properties data from attribute. - * \param theStudy [in] the study. - * \param theEntry [in] the entry of GEOM object to operate with. - */ - virtual void LoadFromAttribute( SalomeApp_Study* theStudy, const std::string& theEntry ); - - /*! - * \brief Saves properties data to attribute. - * \param theStudy [in] the study. - * \param theEntry [in] the entry of GEOM object to operate with. - */ - virtual void SaveToAttribute( SalomeApp_Study* theStudy, const std::string& theEntry ); - -private: - - QVector myAnnotations; -}; - -Q_DECLARE_METATYPE(GEOMGUI_ShapeAnnotations); - -#endif diff --git a/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx b/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx old mode 100644 new mode 100755 index 1b0a9ed0b..386767414 --- a/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx +++ b/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx @@ -22,7 +22,7 @@ #include "GEOMGUI_TextTreeWdg.h" #include "GEOMGUI_DimensionProperty.h" -#include "GEOMGUI_ShapeAnnotations.h" +//#include "GEOMGUI_ShapeAnnotations.h" #include "GeometryGUI.h" #include "GeometryGUI_Operations.h" #include @@ -179,7 +179,7 @@ void GEOMGUI_TextTreeWdg::updateBranch( const QString& theEntry ) fillBranch( Geometry, theEntry ); // annotation property branch - fillBranch(AnnotationShape, theEntry); + // fillBranch(AnnotationShape, theEntry); } void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QString& theEntry ) @@ -252,7 +252,7 @@ VisualPropertiesPtr GEOMGUI_TextTreeWdg::getVisualProperty( const BranchType& th aProp = QSharedPointer( new GEOMGUI_DimensionProperty() ); } else { - aProp = QSharedPointer( new GEOMGUI_ShapeAnnotations() ); + //aProp = QSharedPointer( new GEOMGUI_ShapeAnnotations() ); } return aProp; diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 6e494dfe8..371ddf646 100755 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -46,7 +46,7 @@ #include #include -#include +#include #include @@ -1411,27 +1411,25 @@ void GEOM_Displayer::updateShapeAnnotations( const Handle(SALOME_InteractiveObje const int aLineStyle = aResMgr->integerValue( "Geometry", "shape_annotation_line_style", 0 ); const bool isAutoHide = aResMgr->booleanValue( "Geometry", "shape_annotation_autohide", false ); - QVariant aProperty = aStudy->getObjectProperty( GEOM::sharedPropertiesId(), - theIO->getEntry(), - GEOM::propertyName( GEOM::ShapeAnnotations ), - QVariant() ); + _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theIO->getEntry() ); - GEOMGUI_ShapeAnnotations aAnnotationList; + const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj ); - if ( aProperty.isValid() && aProperty.canConvert() ) + if ( !aShapeAnnotations.IsNull() ) { - aAnnotationList = aProperty.value(); + gp_Trsf aToLCS; + aToLCS.SetTransformation( theShapeLCS, gp_Ax3() ); - for ( int anI = 0; anI < aAnnotationList.GetNumber(); ++anI ) + for ( int anI = 0; anI < aShapeAnnotations->GetCount(); ++anI ) { - if ( !aAnnotationList.Get( anI ).IsVisible ) + if ( !aShapeAnnotations->GetIsVisible( anI ) ) { continue; } - Handle(GEOM_Annotation) aPresentation = new GEOM_Annotation(); - - aAnnotationList.ToPresentation ( anI, aPresentation, theShapeLCS ); + Handle(GEOM_Annotation) aPresentation = new GEOM_Annotation(); + + aShapeAnnotations->SetupPresentation( aPresentation, anI, theShapeLCS ); aPresentation->SetOwner( theIO ); diff --git a/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx b/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx old mode 100644 new mode 100755 index 3bf932f86..1e2f31a66 --- a/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx @@ -351,12 +351,16 @@ bool MeasureGUI_AnnotationDlg::ClickOnApply() setIsDisplayResult( true ); } - /*if ( myIsCreation ) - { - myAnnotation = GEOM::GEOM_Field::_nil(); + if ( !myShape->_is_nil() ) { + redisplay( myShape.get() ); + } + + if ( myIsCreation ) { + if ( !isApplyAndClose() ) - Init(); - }*/ + Init(); + } + return true; } @@ -579,26 +583,20 @@ bool MeasureGUI_AnnotationDlg::execute() return false; if ( myIsCreation ) { + SalomeApp_Study* aStudy = getStudy(); - GEOMGUI_ShapeAnnotations aProp = - aStudy->getObjectProperty( GEOM::sharedPropertiesId(), - myShape->GetStudyEntry(), - GEOM::propertyName( GEOM::ShapeAnnotations ), - QVariant() ) - .value(); - // append new dimension record to data - int aPropId = aProp.GetNumber() - 1; - myAnnotationProperties.Name = getNewObjectName(); // update here as we do not listen name modification - myAnnotationProperties.IsVisible = true; // initially created annotation is hidden - aProp.Add( myAnnotationProperties ); - - // store modified property data - aStudy->setObjectProperty( GEOM::sharedPropertiesId(), - myShape->GetStudyEntry(), GEOM::propertyName( GEOM::ShapeAnnotations ), - aProp ); - aProp.SaveToAttribute( aStudy, myShape->GetStudyEntry() ); - myGeomGUI->emitDimensionsUpdated( QString( myShape->GetStudyEntry() ) ); + _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( myShape->GetStudyEntry() ); + + Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = + GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( aSObj, aStudy ); + + myAnnotationProperties.Name = getNewObjectName(); // update here as we do not listen name modification + myAnnotationProperties.IsVisible = true; // initially created annotation is hidden + + aShapeAnnotations->Append( myAnnotationProperties ); + + /* myGeomGUI->emitDimensionsUpdated( QString( myShape->GetStudyEntry() ) ); */ } else { /*SalomeApp_Study* aStudy = getStudy(); @@ -644,7 +642,7 @@ SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs() TopoDS_Shape aShape; GEOMBase::GetShape( myShape.get(), aShape ); gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() ); - myAnnotationProperties.ToPresentation( aPresentation, aShapeLCS ); + GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, myAnnotationProperties, aShapeLCS ); // add Prs to preview SUIT_ViewWindow* vw = @@ -672,7 +670,7 @@ void MeasureGUI_AnnotationDlg::updateSubShapeEnableState() } //================================================================================= -// function : buildPrs +// function : redisplayPreview // purpose : creates annotation presentation object and corresponded SALOME presentation //================================================================================= void MeasureGUI_AnnotationDlg::redisplayPreview() diff --git a/src/MeasureGUI/MeasureGUI_AnnotationDlg.h b/src/MeasureGUI/MeasureGUI_AnnotationDlg.h old mode 100644 new mode 100755 index c07d3ed02..df2a12283 --- a/src/MeasureGUI/MeasureGUI_AnnotationDlg.h +++ b/src/MeasureGUI/MeasureGUI_AnnotationDlg.h @@ -29,7 +29,7 @@ #include #include -#include +#include #include //#include @@ -94,7 +94,7 @@ private: private: TopAbs_ShapeEnum mySelectionMode; - GEOMGUI_ShapeAnnotations::ShapeAnnotation myAnnotationProperties; + GEOMGUI_AnnotationAttrs::Properties myAnnotationProperties; /// an index of edited annotation in the list shape annotations, -1 in create operation bool myIsCreation; GEOM::GeomObjPtr myShape; -- 2.39.2