GEOM_GEOMGUI.hxx
GEOMGUI_CreationInfoWdg.h
GEOMGUI_TextTreeWdg.h
- GEOMGUI_VisualProperties.h
GEOMGUI_DimensionProperty.h
GEOMGUI_AnnotationAttrs.h
)
-// 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 <GEOMGUI_AnnotationAttrs.h>
-#include <GEOM_Annotation.hxx>
-#include <SALOMEDSImpl_AttributeParameter.hxx>
-
-// OCCT includes
-#include <gp_Ax3.hxx>
-
-// STL includes
-#include <string>
-#include <vector>
-
-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<double>(3, 0.0) );
- myParameterMap->SetRealArray( PARAMETER_ATTACH( anI ), std::vector<double>(3, 0.0) );
- myParameterMap->SetIntArray( PARAMETER_SHAPE( anI ), std::vector<int>(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<double> 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<double> 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<double> 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<double> 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<int> 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<int> 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 )
-{
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File : GEOMGUI_AnnotationAttr.cxx\r
+// Author : Anton POLETAEV, Open CASCADE S.A.S.\r
+//\r
+\r
+// SALOME includes\r
+#include <GEOMGUI_AnnotationAttrs.h>\r
+#include <GEOM_Annotation.hxx>\r
+#include <SALOMEDSImpl_AttributeParameter.hxx>\r
+\r
+// OCCT includes\r
+#include <gp_Ax3.hxx>\r
+\r
+// STL includes\r
+#include <string>\r
+#include <vector>\r
+\r
+IMPLEMENT_STANDARD_RTTIEXT( GEOMGUI_AnnotationAttrs, Standard_Transient )\r
+\r
+namespace\r
+{\r
+ static const std::string PARAMETER_COUNT = "GEOMGUI_AnnotationAttrs_Count";\r
+\r
+ std::string PARAMETER_I( const std::string& s, const int i ) {\r
+ return std::string( s ) + std::to_string( i );\r
+ }\r
+ std::string PARAMETER_IS_VISIBLE( const int i ) {\r
+ return PARAMETER_I( "GEOMGUI_AnnotationAttrs_IsVisible", i );\r
+ }\r
+ std::string PARAMETER_IS_2D( const int i ) {\r
+ return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Is2D", i );\r
+ }\r
+ std::string PARAMETER_NAME( const int i ) {\r
+ return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Name", i );\r
+ }\r
+ std::string PARAMETER_TEXT( const int i ) {\r
+ return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Text", i );\r
+ }\r
+ std::string PARAMETER_POSITION( const int i ) {\r
+ return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Position", i );\r
+ }\r
+ std::string PARAMETER_ATTACH( const int i ) {\r
+ return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Attach", i );\r
+ }\r
+ std::string PARAMETER_SHAPE( const int i ) {\r
+ return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Shape", i );\r
+ }\r
+}\r
+\r
+//=================================================================================\r
+// function : FindAttributes\r
+// purpose : \r
+//=================================================================================\r
+Handle(GEOMGUI_AnnotationAttrs) GEOMGUI_AnnotationAttrs::FindAttributes( const _PTR(SObject)& theObject )\r
+{\r
+ _PTR(GenericAttribute) aGenericAttr;\r
+ _PTR(AttributeParameter) aParameterMap;\r
+\r
+ if ( !theObject->FindAttribute( aGenericAttr, "AttributeParameter" ) )\r
+ {\r
+ return Handle(GEOMGUI_AnnotationAttrs)();\r
+ }\r
+\r
+ aParameterMap = aGenericAttr;\r
+\r
+ if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) )\r
+ {\r
+ return Handle(GEOMGUI_AnnotationAttrs)();\r
+ }\r
+\r
+ return new GEOMGUI_AnnotationAttrs( theObject, aParameterMap );\r
+}\r
+\r
+//=================================================================================\r
+// function : FindOrCreateAttributes\r
+// purpose : \r
+//=================================================================================\r
+Handle(GEOMGUI_AnnotationAttrs) GEOMGUI_AnnotationAttrs::FindOrCreateAttributes(\r
+ const _PTR(SObject)& theObject, SalomeApp_Study* theStudy )\r
+{\r
+ _PTR(StudyBuilder) aBuilder = theStudy->studyDS()->NewBuilder();\r
+ _PTR(AttributeParameter) aParameterMap = aBuilder->FindOrCreateAttribute( theObject, "AttributeParameter" );\r
+ if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) )\r
+ {\r
+ aParameterMap->SetInt( PARAMETER_COUNT, 0 );\r
+ }\r
+\r
+ return new GEOMGUI_AnnotationAttrs( theObject, aParameterMap );\r
+}\r
+\r
+//=================================================================================\r
+// function : Remove\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::Remove( const _PTR(SObject)& theObject )\r
+{\r
+ _PTR(GenericAttribute) aGenericAttr;\r
+ _PTR(AttributeParameter) aParameterMap;\r
+\r
+ if ( !theObject->FindAttribute( aGenericAttr, "AttributeParameter" ) )\r
+ {\r
+ return;\r
+ }\r
+\r
+ aParameterMap = aGenericAttr;\r
+\r
+ if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) )\r
+ {\r
+ return;\r
+ }\r
+\r
+ const int aParamCount = aParameterMap->GetInt( PARAMETER_COUNT );\r
+\r
+ for ( int anI = 0; anI < aParamCount; ++anI )\r
+ {\r
+ aParameterMap->RemoveID( PARAMETER_IS_VISIBLE( anI ), PT_BOOLEAN );\r
+ aParameterMap->RemoveID( PARAMETER_IS_2D( anI ), PT_BOOLEAN );\r
+ aParameterMap->RemoveID( PARAMETER_NAME( anI ), PT_STRING );\r
+ aParameterMap->RemoveID( PARAMETER_TEXT( anI ), PT_STRING );\r
+ aParameterMap->RemoveID( PARAMETER_POSITION( anI ), PT_REALARRAY );\r
+ aParameterMap->RemoveID( PARAMETER_ATTACH( anI ), PT_REALARRAY );\r
+ aParameterMap->RemoveID( PARAMETER_SHAPE( anI ), PT_INTARRAY );\r
+ }\r
+\r
+ aParameterMap->RemoveID( PARAMETER_COUNT, PT_INTEGER );\r
+}\r
+\r
+//=================================================================================\r
+// function : SetNbAnnotation\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::SetNbAnnotation( const int theCount ) const\r
+{\r
+ const int aCount = this->GetNbAnnotation();\r
+\r
+ if ( aCount < theCount )\r
+ {\r
+ // set default values\r
+ for ( int anI = aCount; anI < theCount; ++anI )\r
+ {\r
+ myParameterMap->SetBool( PARAMETER_IS_VISIBLE( anI ), true );\r
+ myParameterMap->SetBool( PARAMETER_IS_2D( anI ), false );\r
+ myParameterMap->SetString( PARAMETER_NAME( anI ), std::string() );\r
+ myParameterMap->SetString( PARAMETER_TEXT( anI ), std::string() );\r
+ myParameterMap->SetRealArray( PARAMETER_POSITION( anI ), std::vector<double>(3, 0.0) );\r
+ myParameterMap->SetRealArray( PARAMETER_ATTACH( anI ), std::vector<double>(3, 0.0) );\r
+ myParameterMap->SetIntArray( PARAMETER_SHAPE( anI ), std::vector<int>(2, 0) );\r
+ }\r
+ }\r
+ else\r
+ {\r
+ // remove exceeding values\r
+ for ( int anI = theCount; anI < aCount; ++anI )\r
+ {\r
+ myParameterMap->RemoveID( PARAMETER_IS_VISIBLE( anI ), PT_BOOLEAN );\r
+ myParameterMap->RemoveID( PARAMETER_IS_2D( anI ), PT_BOOLEAN );\r
+ myParameterMap->RemoveID( PARAMETER_NAME( anI ), PT_STRING );\r
+ myParameterMap->RemoveID( PARAMETER_TEXT( anI ), PT_STRING );\r
+ myParameterMap->RemoveID( PARAMETER_POSITION( anI ), PT_REALARRAY );\r
+ myParameterMap->RemoveID( PARAMETER_ATTACH( anI ), PT_REALARRAY );\r
+ myParameterMap->RemoveID( PARAMETER_SHAPE( anI ), PT_INTARRAY );\r
+ }\r
+ }\r
+\r
+ myParameterMap->SetInt( PARAMETER_COUNT, theCount );\r
+}\r
+\r
+//=================================================================================\r
+// function : GetNbAnnotation\r
+// purpose : \r
+//=================================================================================\r
+int GEOMGUI_AnnotationAttrs::GetNbAnnotation() const\r
+{\r
+ return myParameterMap->GetInt( PARAMETER_COUNT );\r
+}\r
+\r
+//=================================================================================\r
+// function : SetName\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::SetName( const int theIndex, const QString& theName )\r
+{\r
+ myParameterMap->SetString( PARAMETER_NAME( theIndex ), theName.toStdString() );\r
+}\r
+\r
+//=================================================================================\r
+// function : GetName\r
+// purpose : \r
+//=================================================================================\r
+QString GEOMGUI_AnnotationAttrs::GetName( const int theIndex ) const\r
+{\r
+ return QString::fromStdString( myParameterMap->GetString( PARAMETER_NAME( theIndex ) ) );\r
+}\r
+\r
+//=================================================================================\r
+// function : SetVisible\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::SetIsVisible( const int theIndex, const bool theIsVisible )\r
+{\r
+ myParameterMap->SetBool( PARAMETER_IS_VISIBLE( theIndex ), theIsVisible );\r
+}\r
+\r
+//=================================================================================\r
+// function : GetIsVisible\r
+// purpose : \r
+//=================================================================================\r
+bool GEOMGUI_AnnotationAttrs::GetIsVisible( const int theIndex ) const\r
+{\r
+ return myParameterMap->GetBool( PARAMETER_IS_VISIBLE( theIndex ) );\r
+}\r
+\r
+//=================================================================================\r
+// function : SetText\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::SetText( const int theIndex, const QString& theText )\r
+{\r
+ myParameterMap->SetString( PARAMETER_TEXT( theIndex ), theText.toStdString() );\r
+}\r
+\r
+//=================================================================================\r
+// function : GetText\r
+// purpose : \r
+//=================================================================================\r
+QString GEOMGUI_AnnotationAttrs::GetText( const int theIndex ) const\r
+{\r
+ return QString::fromStdString( myParameterMap->GetString( PARAMETER_TEXT( theIndex ) ) );\r
+}\r
+\r
+//=================================================================================\r
+// function : SetIsScreenFixed\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::SetIsScreenFixed( const int theIndex, const bool theIsScreenFixed )\r
+{\r
+ myParameterMap->SetBool( PARAMETER_IS_2D( theIndex ), theIsScreenFixed );\r
+}\r
+\r
+//=================================================================================\r
+// function : GetIsScreenFixed\r
+// purpose : \r
+//=================================================================================\r
+bool GEOMGUI_AnnotationAttrs::GetIsScreenFixed( const int theIndex ) const\r
+{\r
+ return myParameterMap->GetBool( PARAMETER_IS_2D( theIndex ) );\r
+}\r
+\r
+//=================================================================================\r
+// function : SetPosition\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::SetPosition( const int theIndex, const gp_Pnt& thePosition )\r
+{\r
+ std::vector<double> aCoords( 3 );\r
+\r
+ aCoords[0] = thePosition.X();\r
+ aCoords[1] = thePosition.Y();\r
+ aCoords[2] = thePosition.Z();\r
+\r
+ myParameterMap->SetRealArray( PARAMETER_POSITION( theIndex ), aCoords );\r
+}\r
+\r
+//=================================================================================\r
+// function : GetPosition\r
+// purpose : \r
+//=================================================================================\r
+gp_Pnt GEOMGUI_AnnotationAttrs::GetPosition( const int theIndex ) const\r
+{\r
+ std::vector<double> aCoords =\r
+ myParameterMap->GetRealArray( PARAMETER_POSITION( theIndex ) );\r
+\r
+ return gp_Pnt( aCoords[0], aCoords[1], aCoords[2] );\r
+}\r
+\r
+//=================================================================================\r
+// function : SetAttach\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::SetAttach( const int theIndex, const gp_Pnt& theAttach )\r
+{\r
+ std::vector<double> aCoords( 3 );\r
+\r
+ aCoords[0] = theAttach.X();\r
+ aCoords[1] = theAttach.Y();\r
+ aCoords[2] = theAttach.Z();\r
+\r
+ myParameterMap->SetRealArray( PARAMETER_ATTACH( theIndex ), aCoords );\r
+}\r
+\r
+//=================================================================================\r
+// function : GetAttach\r
+// purpose : \r
+//=================================================================================\r
+gp_Pnt GEOMGUI_AnnotationAttrs::GetAttach( const int theIndex ) const\r
+{\r
+ std::vector<double> aCoords =\r
+ myParameterMap->GetRealArray( PARAMETER_ATTACH( theIndex ) );\r
+\r
+ return gp_Pnt( aCoords[0], aCoords[1], aCoords[2] );\r
+}\r
+\r
+//=================================================================================\r
+// function : SetShapeSel\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::SetShapeSel( const int theIndex, const int theShapeType, const int theSubIdx )\r
+{\r
+ std::vector<int> aSelection( 2 );\r
+\r
+ aSelection[0] = theShapeType;\r
+ aSelection[1] = theSubIdx;\r
+\r
+ myParameterMap->SetIntArray( PARAMETER_SHAPE( theIndex ), aSelection );\r
+}\r
+\r
+//=================================================================================\r
+// function : GetShapeSel\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::GetShapeSel( const int theIndex, int& theShapeType, int& theSubIdx ) const\r
+{\r
+ std::vector<int> aSelection =\r
+ myParameterMap->GetIntArray( PARAMETER_SHAPE( theIndex ) );\r
+\r
+ theShapeType = aSelection[0];\r
+ theSubIdx = aSelection[1];\r
+}\r
+\r
+//=================================================================================\r
+// function : Append\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::Append( const Properties& theProps )\r
+{\r
+ const int aCount = this->GetNbAnnotation();\r
+ this->SetNbAnnotation( aCount + 1 );\r
+ this->SetProperties( aCount, theProps );\r
+}\r
+\r
+//=================================================================================\r
+// function : SetProperties\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::SetProperties( const int theIndex, const Properties& theProps )\r
+{\r
+ this->SetName( theIndex, theProps.Name );\r
+ this->SetText( theIndex, theProps.Text );\r
+ this->SetIsVisible( theIndex, theProps.IsVisible );\r
+ this->SetIsScreenFixed( theIndex, theProps.IsScreenFixed );\r
+ this->SetPosition( theIndex, theProps.Position );\r
+ this->SetAttach( theIndex, theProps.Attach );\r
+ this->SetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex );\r
+}\r
+\r
+//=================================================================================\r
+// function : GetProperties\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::GetProperties( const int theIndex, Properties& theProps ) const\r
+{\r
+ theProps.Name = this->GetName( theIndex );\r
+ theProps.Text = this->GetText( theIndex );\r
+ theProps.IsVisible = this->GetIsVisible( theIndex );\r
+ theProps.IsScreenFixed = this->GetIsScreenFixed( theIndex );\r
+ theProps.Position = this->GetPosition( theIndex );\r
+ theProps.Attach = this->GetAttach( theIndex );\r
+\r
+ this->GetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex );\r
+}\r
+\r
+//=================================================================================\r
+// function : SetupPresentation\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,\r
+ const Properties& theProps,\r
+ const gp_Ax3& theLCS )\r
+{\r
gp_Trsf aToLCS;\r
aToLCS.SetTransformation( theLCS, gp_Ax3() );\r
\r
thePresentation->SetText( aText );\r
thePresentation->SetScreenFixed( theProps.IsScreenFixed );\r
thePresentation->SetPosition( theProps.Position );\r
- 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 );
-}
+ thePresentation->SetAttachPoint( theProps.Attach.Transformed( aToLCS ) );\r
+}\r
+\r
+//=================================================================================\r
+// function : SetupPresentation\r
+// purpose : \r
+//=================================================================================\r
+void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,\r
+ const int theIndex,\r
+ const gp_Ax3& theLCS )\r
+{\r
+ Properties aProps;\r
+ this->GetProperties( theIndex, aProps );\r
+ this->SetupPresentation( thePresentation, aProps, theLCS );\r
+}\r
#define GEOMGUI_ANNOTATIONATTRS_H
// SALOME GUI includes
+#include <GEOMGUI.h>
#include <SalomeApp_Study.h>
// OCCT includes
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 );
+ GEOMGUI_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 );
+ GEOMGUI_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 );
+ GEOMGUI_EXPORT static void Remove( const _PTR(SObject)& theObject );
public:
//! @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 );
+ GEOMGUI_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 );
+ GEOMGUI_EXPORT void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
+ const int theIndex,
+ const gp_Ax3& theLCS );
public:
//! 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;
+ GEOMGUI_EXPORT void SetNbAnnotation( const int theCount ) const;
//! Returns number of annotation definitions stored on the object.
- Standard_EXPORT int GetCount() const;
+ GEOMGUI_EXPORT int GetNbAnnotation() 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 );
+ GEOMGUI_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;
+ GEOMGUI_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 );
+ GEOMGUI_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;
+ GEOMGUI_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 );
+ GEOMGUI_EXPORT void SetText( const int theIndex, const QString& theText );
//! Returns annotation label's text.
- Standard_EXPORT QString GetText( const int theIndex ) const;
+ GEOMGUI_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 );
+ GEOMGUI_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;
+ GEOMGUI_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 );
+ GEOMGUI_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;
+ GEOMGUI_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 );
+ GEOMGUI_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;
+ GEOMGUI_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 );
+ GEOMGUI_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;
+ GEOMGUI_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 );
+ GEOMGUI_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 );
+ GEOMGUI_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;
+ GEOMGUI_EXPORT void GetProperties( const int theIndex, Properties& theProps ) const;
private:
#define GEOMGUI_DIMENSIONPROPERTY_H
// OCCT includes
-#include <GEOMGUI_VisualProperties.h>
-
#include <AIS_DiameterDimension.hxx>
#include <AIS_LengthDimension.hxx>
#include <AIS_AngleDimension.hxx>
* Diam: (plane)[0-3] (flyout)[4] (text flags)[5-6] (arrow flag)[7] (circle loc, xdir, ydir, rad)[8-17]
* Angle: (flyout)[0] (text flags)[1-2] (arrow flag)[3] (p1)[4-6] (p2)[7-9] (center)[10-12]
*/
-class Standard_EXPORT GEOMGUI_DimensionProperty : public GEOMGUI_VisualProperties
+class Standard_EXPORT GEOMGUI_DimensionProperty
{
public:
#include "GEOMGUI_TextTreeWdg.h"
#include "GEOMGUI_DimensionProperty.h"
-//#include "GEOMGUI_ShapeAnnotations.h"
+#include "GEOMGUI_AnnotationAttrs.h"
#include "GeometryGUI.h"
#include "GeometryGUI_Operations.h"
#include <GEOM_Constants.h>
#include <QHBoxLayout>
#include <QHash>
+// ----------------------------------------------------------------------------
+// Common style interface for managing dimension and annotation properties
+// ----------------------------------------------------------------------------
+namespace
+{
+ //! Access interface implementation for shape dimension attribute/property.
+ class DimensionsProperty : public GEOMGUI_TextTreeWdg::VisualProperty
+ {
+ public:
+
+ DimensionsProperty( SalomeApp_Study* theStudy, const std::string& theEntry ) :
+ myStudy( theStudy ), myEntry( theEntry ) {
+ myAttr.LoadFromAttribute( theStudy, theEntry );
+ }
+ virtual int GetNumber() Standard_OVERRIDE {
+ return myAttr.GetNumber();
+ }
+ virtual QString GetName( const int theIndex ) Standard_OVERRIDE {
+ return myAttr.GetName( theIndex );
+ }
+ virtual bool GetIsVisible( const int theIndex ) Standard_OVERRIDE {
+ return myAttr.IsVisible( theIndex );
+ }
+ virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) Standard_OVERRIDE {
+ myAttr.SetVisible( theIndex, theIsVisible );
+ }
+ virtual void Save() Standard_OVERRIDE {
+ myAttr.SaveToAttribute( myStudy, myEntry );
+ }
+ GEOMGUI_DimensionProperty& Attr() { return myAttr; }
+
+ private:
+ GEOMGUI_DimensionProperty myAttr;
+ SalomeApp_Study* myStudy;
+ std::string myEntry;
+ };
+
+ //! Access interface implementation for shape annotation attribute.
+ class AnnotationsProperty : public GEOMGUI_TextTreeWdg::VisualProperty
+ {
+ public:
+
+ AnnotationsProperty( SalomeApp_Study* theStudy, const std::string& theEntry ) {
+ _PTR(SObject) aSObj = theStudy->studyDS()->FindObjectID( theEntry );
+ myAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+ }
+ virtual int GetNumber() Standard_OVERRIDE {
+ return !myAttr.IsNull() ? myAttr->GetNbAnnotation() : 0;
+ }
+ virtual QString GetName( const int theIndex ) Standard_OVERRIDE {
+ return !myAttr.IsNull() ? myAttr->GetName( theIndex ) : QString();
+ }
+ virtual bool GetIsVisible( const int theIndex ) Standard_OVERRIDE {
+ return !myAttr.IsNull() ? myAttr->GetIsVisible( theIndex ) : false;
+ }
+ virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) Standard_OVERRIDE {
+ if ( !myAttr.IsNull() ) {
+ myAttr->SetIsVisible( theIndex, theIsVisible );
+ }
+ }
+ virtual void Save() Standard_OVERRIDE {
+ /* every change is automatically saved */
+ }
+ Handle(GEOMGUI_AnnotationAttrs) Attr() { return myAttr; }
+
+ private:
+
+ Handle(GEOMGUI_AnnotationAttrs) myAttr;
+ };
+}
+
+// ----------------------------------------------------------------------------
+// Text tree widget implementation
+// ----------------------------------------------------------------------------
GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
: myDisplayer(NULL)
{
connect( this, SIGNAL( customContextMenuRequested(const QPoint&) ),
this, SLOT( showContextMenu(const QPoint&) ) );
- connect( myStudy, SIGNAL( objVisibilityChanged( QString, Qtx::VisibilityState ) ),
+ connect( myStudy, SIGNAL( objVisibilityChanged( QString, Qtx::VisibilityState ) ),
this, SLOT( updateVisibilityColumn( QString, Qtx::VisibilityState ) ) );
connect( app->objectBrowser(), SIGNAL( updated() ), this, SLOT( updateTree() ) );
+
GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
connect( aGeomGUI, SIGNAL( DimensionsUpdated( const QString& ) ), this, SLOT( updateBranch( const QString& ) ) );
connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ),
if ( SC ) {
_PTR(ChildIterator) anIter ( aDSStudy->NewChildIterator( SC ) );
anIter->InitEx( true );
- QList<QString> aGeomObjEntries = getObjects( Geometry ).keys();
+ QList<QString> aDimensionObjEntries = getObjects( DimensionShape ).keys();
QList<QString> anAnnotationObjEntries = getObjects( AnnotationShape ).keys();
while( anIter->More() ) {
_PTR(SObject) valSO ( anIter->Value() );
// update tree of object's dimensions
QString anEntry = valSO->GetID().c_str();
updateBranch( anEntry );
- aGeomObjEntries.removeAll( anEntry );
+ aDimensionObjEntries.removeAll( anEntry );
anAnnotationObjEntries.removeAll( anEntry );
}
anIter->Next();
}
- foreach (QString entry, aGeomObjEntries) {
- removeBranch( Geometry, entry, true );
+ foreach ( QString entry, aDimensionObjEntries ) {
+ removeBranch( DimensionShape, entry, true );
}
- foreach (QString entry, anAnnotationObjEntries) {
+ foreach ( QString entry, anAnnotationObjEntries ) {
removeBranch( AnnotationShape, entry, true );
}
}
}
}
-
+
//=================================================================================
// function : updateBranch
// purpose :
//=================================================================================
void GEOMGUI_TextTreeWdg::updateBranch( const QString& theEntry )
{
- /// dimension property branch
- fillBranch( Geometry, theEntry );
+ // dimension property branch
+ fillBranch( DimensionShape, theEntry );
// annotation property branch
- // fillBranch(AnnotationShape, theEntry);
+ fillBranch( AnnotationShape, theEntry );
}
+//=================================================================================
+// function : fillBranch
+// purpose :
+//=================================================================================
void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QString& theEntry )
{
myStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
if ( myStudy && !theEntry.isEmpty() ) {
- VisualPropertiesPtr aProp = getVisualProperty( theBranchType );
- int aNumber = aProp->GetNumber();
+ QSharedPointer<VisualProperty> aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
const std::string anEntry = theEntry.toStdString();
-
- aProp->LoadFromAttribute( myStudy, theEntry.toStdString() );
-
- if (!aProp)
+ if ( !aProp ) {
return;
+ }
_PTR(Study) aStudyDS = myStudy->studyDS();
if ( aStudyDS ) {
_PTR(SObject) obj( aStudyDS->FindObjectID( theEntry.toStdString() ) );
- QString aName = obj->GetName().c_str();
-
- int nbProps = aProp->GetNumber();
+ const QString aName = obj->GetName().c_str();
+ const int nbProps = aProp->GetNumber();
QTreeWidgetItem* objectItem = itemFromEntry( theBranchType, theEntry );
if ( objectItem ) {
if ( nbProps > 0 ) {
itemName << aName << "";
if ( !objectItem ) {
- QTreeWidgetItem* aPropRootItem = getPropertyRootItem(theBranchType);
+ QTreeWidgetItem* aPropRootItem = getPropertyRootItem( theBranchType );
objectItem = new QTreeWidgetItem( aPropRootItem, itemName );
objectItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
if ( aPropRootItem->childCount() == 1 )
aPropRootItem->setExpanded( true );
}
- bool isDisplayed = myDisplayer.IsDisplayed( theEntry );
- // read dimension records from property
- for ( int anIt = 0; anIt < aProp->GetNumber(); ++anIt ) {
- QString aName = aProp->GetName( anIt );
- bool isVisible = aProp->IsVisible( anIt );
-
+ for ( int anIt = 0; anIt < nbProps; ++anIt ) {
+ const QString aPropName = aProp->GetName( anIt );
+ const bool isVisible = aProp->GetIsVisible( anIt );
QTreeWidgetItem* anItem = new QTreeWidgetItem;
- anItem->setText( 0, aName );
- // if ( isDisplayed )
+ anItem->setText( 0, aPropName );
anItem->setIcon( 1, isVisible ? myVisibleIcon : myInvisibleIcon );
anItem->setData( 0, Qt::UserRole, anIt );
anItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
// function : getVisualProperty
// purpose :
//=================================================================================
-VisualPropertiesPtr GEOMGUI_TextTreeWdg::getVisualProperty( const BranchType& theBranchType )
+QSharedPointer<GEOMGUI_TextTreeWdg::VisualProperty>
+ GEOMGUI_TextTreeWdg::getVisualProperty( const BranchType& theBranchType,
+ SalomeApp_Study* theStudy,
+ const std::string& theEntry )
{
- VisualPropertiesPtr aProp;
-
- if ( theBranchType == Geometry ) {
- aProp = QSharedPointer<GEOMGUI_DimensionProperty>( new GEOMGUI_DimensionProperty() );
+ switch ( theBranchType )
+ {
+ case DimensionShape : return QSharedPointer<VisualProperty>( new DimensionsProperty( theStudy, theEntry ) );
+ case AnnotationShape : return QSharedPointer<VisualProperty>( new AnnotationsProperty( theStudy, theEntry ) );
+ default: break;
}
- else {
- //aProp = QSharedPointer<GEOMGUI_ShapeAnnotations>( new GEOMGUI_ShapeAnnotations() );
- }
-
-return aProp;
+ return QSharedPointer<VisualProperty>();
}
//=================================================================================
int aDimIndex = idFromItem( theItem );
- VisualPropertiesPtr aProp = getVisualProperty( aBranchType );
- aProp->LoadFromAttribute( myStudy, anEntry );
- if ( aProp->IsVisible( aDimIndex ) ) {
- aProp->SetVisible( aDimIndex, false );
+ QSharedPointer<VisualProperty> aProp = getVisualProperty( aBranchType, myStudy, anEntry );
+
+ if ( aProp->GetIsVisible( aDimIndex ) ) {
+ aProp->SetIsVisible( aDimIndex, false );
theItem->setIcon( 1, myInvisibleIcon );
} else {
- aProp->SetVisible( aDimIndex, true );
+ aProp->SetIsVisible( aDimIndex, true );
theItem->setIcon( 1, myVisibleIcon );
}
- aProp->SaveToAttribute( myStudy, anEntry );
+ aProp->Save();
redisplay( anEntry.c_str() );
}
//=================================================================================
void GEOMGUI_TextTreeWdg::updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState )
{
- //BranchType theBranchType,
- updateVisibilityColumn( Geometry, theEntry, theState );
+ // dimension property branch
+ updateVisibilityColumn( DimensionShape, theEntry, theState );
+
+ // annotation property branch
updateVisibilityColumn( AnnotationShape, theEntry, theState );
}
anItem->setDisabled( theState != Qtx::ShownState );
QTreeWidgetItem* aChildItem;
- VisualPropertiesPtr aProp = getVisualProperty( theBranchType );
+ QSharedPointer<VisualProperty> aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
for ( int i=0; i < anItem->childCount(); i++ ) {
aChildItem = anItem->child( i );
if ( theState == Qtx::ShownState ) {
- aProp->LoadFromAttribute( myStudy, theEntry.toStdString() );
if ( aProp->GetNumber() == 0 )
continue;
- aChildItem->setIcon( 1, aProp->IsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon
- : myInvisibleIcon );
+ aChildItem->setIcon( 1, aProp->GetIsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon
+ : myInvisibleIcon );
aChildItem->setDisabled( false );
} else {
aChildItem->setIcon( 1, QIcon() );
QString anEntry = entryFromItem( anItem->parent() );
if ( !anEntry.isEmpty() ) {
BranchType aBranchType = branchTypeFromItem( anItem );
- VisualPropertiesPtr aProp = getVisualProperty( aBranchType );
+ QSharedPointer<VisualProperty>
+ aProp = getVisualProperty( aBranchType, myStudy, anEntry.toStdString() );
- aProp->LoadFromAttribute( myStudy, anEntry.toStdString() );
if ( aProp->GetNumber() == 0 )
return;
aMenu.clear();
- if ( aProp->IsVisible( idFromItem( anItem ) ) )
+ if ( aProp->GetIsVisible( idFromItem( anItem ) ) )
aMenu.addAction( myActions[GEOMOp::OpHide] );
else
aMenu.addAction( myActions[GEOMOp::OpShow] );
BranchType aBranchType = branchTypeFromItem( theItem );
if ( theItem == myDimensionsItem ||
theItem == myAnnotationsItem ) {
- // set visibility for all dimensions
+
QTreeWidgetItem* anItem;
foreach ( QString entry, getObjects( aBranchType ).keys() ) {
anItem = itemFromEntry( aBranchType, entry );
if ( !anItem->isDisabled() )
- setShapeDimensionsVisibility( aBranchType, entry, theVisibility );
+ setAllShapeItemsVisibility( aBranchType, entry, theVisibility );
}
return;
}
QString anEntry = entryFromItem( theItem );
if ( !anEntry.isEmpty() ) {
// it is a shape item
- setShapeDimensionsVisibility( aBranchType, anEntry, theVisibility );
+ setAllShapeItemsVisibility( aBranchType, anEntry, theVisibility );
} else {
// it is a dimension item
anEntry = entryFromItem( theItem->parent() );
- setDimensionVisibility( aBranchType, anEntry, theItem, theVisibility );
- }
+ setShapeItemVisibility( aBranchType, anEntry, theItem, theVisibility );
}
+ }
}
}
//=================================================================================
-// function : setShapeDimensionsVisibility
+// function : setAllShapeItemsVisibility
// purpose :
//=================================================================================
-void GEOMGUI_TextTreeWdg::setShapeDimensionsVisibility( const BranchType& theBranchType,
- QString theEntry, bool theVisibility )
+void GEOMGUI_TextTreeWdg::setAllShapeItemsVisibility( const BranchType& theBranchType,
+ const QString& theEntry,
+ const bool theVisibility )
{
+ QSharedPointer<VisualProperty>
+ aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
+
QTreeWidgetItem* anItem = itemFromEntry( theBranchType, theEntry );
QTreeWidgetItem* aChildItem;
for ( int i=0; i < anItem->childCount(); i++ ) {
aChildItem = anItem->child( i );
- setDimensionVisibility( theBranchType, theEntry, aChildItem, theVisibility );
+ setShapeItemVisibility( aProp, aChildItem, theVisibility );
}
+
+ aProp->Save();
+
redisplay( theEntry );
}
//=================================================================================
-// function : setDimensionVisibility
+// function : setShapeItemVisibility
// purpose :
//=================================================================================
-void GEOMGUI_TextTreeWdg::setDimensionVisibility( const BranchType& theBranchType, QString theEntry,
- QTreeWidgetItem* theDimItem, bool theVisibility )
+void GEOMGUI_TextTreeWdg::setShapeItemVisibility( const BranchType& theBranchType,
+ const QString& theEntry,
+ QTreeWidgetItem* theWidgetItem,
+ const bool theVisibility )
{
- VisualPropertiesPtr aProp = getVisualProperty( theBranchType );
+ QSharedPointer<VisualProperty>
+ aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
- aProp->LoadFromAttribute( myStudy, theEntry.toStdString() );
- int aDimIndex = idFromItem( theDimItem );
- if ( aProp->GetNumber() == 0 || aProp->IsVisible( aDimIndex ) == theVisibility )
- return;;
- aProp->SetVisible( aDimIndex, theVisibility );
- aProp->SaveToAttribute( myStudy, theEntry.toStdString() );
+ if ( setShapeItemVisibility( aProp, theWidgetItem, theVisibility ) ) {
+ aProp->Save();
+ redisplay( theEntry );
+ }
+}
- theDimItem->setIcon( 1, theVisibility ? myVisibleIcon : myInvisibleIcon );
- redisplay( theEntry );
+//=================================================================================
+// function : setShapeItemVisibility
+// purpose :
+//=================================================================================
+bool GEOMGUI_TextTreeWdg::setShapeItemVisibility( QSharedPointer<VisualProperty>& theProps,
+ QTreeWidgetItem* theWidgetItem,
+ const bool theVisibility )
+{
+ int aDimIndex = idFromItem( theWidgetItem );
+ if ( theProps->GetNumber() == 0
+ || theProps->GetIsVisible( aDimIndex ) == theVisibility ) {
+ return false;
+ }
+ theProps->SetIsVisible( aDimIndex, theVisibility );
+
+ theWidgetItem->setIcon( 1, theVisibility ? myVisibleIcon : myInvisibleIcon );
+
+ return true;
}
//=================================================================================
//=================================================================================
QTreeWidgetItem* GEOMGUI_TextTreeWdg::getPropertyRootItem( const BranchType& theBranchType )
{
- return theBranchType == Geometry ? myDimensionsItem : myAnnotationsItem;
+ return (theBranchType == DimensionShape) ? myDimensionsItem : myAnnotationsItem;
}
//=================================================================================
//=================================================================================
QHash<QString, QTreeWidgetItem*>& GEOMGUI_TextTreeWdg::getObjects( const BranchType& theBranchType )
{
- return theBranchType == Geometry ? myObjects : myAnnotationObjects;
+ return (theBranchType == DimensionShape) ? myDimensionObjects : myAnnotationObjects;
}
//=================================================================================
//=================================================================================
GEOMGUI_TextTreeWdg::BranchType GEOMGUI_TextTreeWdg::branchTypeFromItem( QTreeWidgetItem* theItem )
{
- BranchType aBranchType = Geometry;
+ BranchType aBranchType = DimensionShape;
bool aBranchTypeFound = false;
QTreeWidgetItem* anItem = theItem;
if ( anItem == myDimensionsItem ||
anItem == myAnnotationsItem) {
aBranchTypeFound = true;
- aBranchType = anItem == myDimensionsItem ? Geometry : AnnotationShape;
+ aBranchType = (anItem == myDimensionsItem) ? DimensionShape : AnnotationShape;
}
else {
anItem = anItem->parent();
#include "GEOM_GEOMGUI.hxx"
#include "GEOM_Displayer.h"
-#include "GEOMGUI_VisualProperties.h"
-#include <QTreeWidget>
#include <QHash>
+#include <QSharedPointer>
+#include <QTreeWidget>
#include <SALOMEDSClient.hxx>
class SalomeApp_Application;
class SalomeApp_Study;
-
/*!
* \brief Tree view contains Dimension and Annotation text items:
* - text visibility in OCC viewer
Q_OBJECT
public:
- enum BranchType { Geometry, AnnotationShape };
-
+ enum BranchType { DimensionShape, AnnotationShape };
public:
GEOMGUI_TextTreeWdg( SalomeApp_Application* app );
int idFromItem( QTreeWidgetItem* theItem );
QString entryFromItem( QTreeWidgetItem* theShapeItem );
QTreeWidgetItem* itemFromEntry( const BranchType& theBranchType, QString theEntry );
- void setShapeDimensionsVisibility( const BranchType& theBranchType,
- QString theEntry, bool theVisibility );
- void setDimensionVisibility( const BranchType& theBranchType,
- QString theEntry, QTreeWidgetItem* theDimItem,
- bool theVisibility );
+ void setAllShapeItemsVisibility( const BranchType& theBranchType,
+ const QString& theEntry,
+ const bool theVisibility );
+ void setShapeItemVisibility( const BranchType& theBranchType,
+ const QString& theEntry,
+ QTreeWidgetItem* theWidgetItem,
+ const bool theVisibility );
protected:
void createActions();
void redisplay( QString theEntry );
void setVisibility( QTreeWidgetItem* theItem, bool visibility );
void showContextMenu( const QPoint& pos );
+public:
+
+ /*!
+ * \brief Common interface for working with shape dimension and annotation properties
+ * of object in a unified way irrespectively of the implementation.
+ */
+ class VisualProperty
+ {
+ public:
+ virtual int GetNumber() = 0;
+ virtual QString GetName( const int theIndex ) = 0;
+ virtual bool GetIsVisible( const int theIndex ) = 0;
+ virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) = 0;
+ virtual void Save() = 0;
+ };
+
private:
- VisualPropertiesPtr getVisualProperty( const BranchType& theBranchType );
-
- void fillBranch( const BranchType& theBranchType,
- const QString& theEntry );
- void updateVisibilityColumn( const BranchType& theBranchType,
- QString theEntry,
- Qtx::VisibilityState theState );
- QTreeWidgetItem* getPropertyRootItem( const BranchType& theBranchType );
+ bool setShapeItemVisibility( QSharedPointer<VisualProperty>& theProps,
+ QTreeWidgetItem* theWidgetItem,
+ const bool theVisibility );
+ QSharedPointer<VisualProperty> getVisualProperty( const BranchType& theBranchType,
+ SalomeApp_Study* theStudy,
+ const std::string& theEntry );
+ void fillBranch( const BranchType& theBranchType,
+ const QString& theEntry );
+ void updateVisibilityColumn( const BranchType& theBranchType,
+ QString theEntry,
+ Qtx::VisibilityState theState );
+ QTreeWidgetItem* getPropertyRootItem( const BranchType& theBranchType );
QHash<QString, QTreeWidgetItem*>& getObjects( const BranchType& theBranchType );
- BranchType branchTypeFromItem( QTreeWidgetItem* theItem );
+ BranchType branchTypeFromItem( QTreeWidgetItem* theItem );
private:
- int myWindowID;
- QIcon myVisibleIcon;
- QIcon myInvisibleIcon;
- QHash<QString, QTreeWidgetItem*> myObjects;
+ int myWindowID;
+ QIcon myVisibleIcon;
+ QIcon myInvisibleIcon;
+ QHash<QString, QTreeWidgetItem*> myDimensionObjects;
QHash<QString, QTreeWidgetItem*> myAnnotationObjects;
- SalomeApp_Study* myStudy;
- QTreeWidgetItem* myDimensionsItem;
- QTreeWidgetItem* myAnnotationsItem;
- GEOM_Displayer myDisplayer;
-
- QMap<int, QAction*> myActions; //!< menu actions list
-
+ SalomeApp_Study* myStudy;
+ QTreeWidgetItem* myDimensionsItem;
+ QTreeWidgetItem* myAnnotationsItem;
+ GEOM_Displayer myDisplayer;
+ QMap<int, QAction*> myActions; //!< menu actions list
};
+
#endif
+++ /dev/null
-// 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_VisualProperties.h
-// Author : Anton POLETAEV, Open CASCADE S.A.S.
-//
-
-#ifndef GEOMGUI_VisualProperties_H
-#define GEOMGUI_VisualProperties_H
-
-// OCCT includes
-#include <Standard_Macro.hxx>
-#include <QSharedPointer>
-
-class GEOMGUI_VisualProperties;
-typedef QSharedPointer<GEOMGUI_VisualProperties> VisualPropertiesPtr;
-
-class SalomeApp_Study;
-
-/*!
- * \brief Utility class to presentations as object property of study.
- *
- * This is an abstract class with interface to manipulate with a property object
- * Methods should be implemented in inherited classes.
- */
-class Standard_EXPORT GEOMGUI_VisualProperties
-{
-public:
-
- /*!
- * \brief Constructor. Inits empty property.
- */
- GEOMGUI_VisualProperties() {}
-
- /*!
- * \brief Destructor.
- */
- ~GEOMGUI_VisualProperties() {}
-
- /*!
- * \brief Returns number of dimension records.
- */
- virtual int GetNumber() const = 0;
-
- /*!
- * \brief Removes record by its index.
- * \param theIndex [in] the index of dimension record.
- */
- //virtual void RemoveRecord( const int theIndex ) = 0;
- /*!
- * \brief Clears property data.
- */
- //virtual void Clear() = 0;
-public:
-
- /*!
- * \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 = 0;
-
- /*!
- * \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 ) = 0;
-
- /*!
- * \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 = 0;
-
- /*!
- * \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 ) = 0;
-
-public:
-
- /*!
- * \brief Loads properties data from attribute "AttributeTableOfReal".
- * \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 ) = 0;
-
- /*!
- * \brief Saves properties data to attribute "AttributeTableOfReal".
- * \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 ) = 0;
-};
-
-#endif
gp_Trsf aToLCS;\r
aToLCS.SetTransformation( theShapeLCS, gp_Ax3() );
- for ( int anI = 0; anI < aShapeAnnotations->GetCount(); ++anI )
+ for ( int anI = 0; anI < aShapeAnnotations->GetNbAnnotation(); ++anI )
{
if ( !aShapeAnnotations->GetIsVisible( anI ) )
{