Update of text tree widget integration to new class

of shape annotation attributes
This commit is contained in:
apl 2016-10-19 15:55:06 +03:00
parent 96407303b7
commit c11f35e20d
8 changed files with 672 additions and 680 deletions

View File

@ -75,7 +75,6 @@ SET(GEOMGUI_HEADERS
GEOM_GEOMGUI.hxx GEOM_GEOMGUI.hxx
GEOMGUI_CreationInfoWdg.h GEOMGUI_CreationInfoWdg.h
GEOMGUI_TextTreeWdg.h GEOMGUI_TextTreeWdg.h
GEOMGUI_VisualProperties.h
GEOMGUI_DimensionProperty.h GEOMGUI_DimensionProperty.h
GEOMGUI_AnnotationAttrs.h GEOMGUI_AnnotationAttrs.h
) )

View File

@ -1,403 +1,403 @@
// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
// //
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version. // 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, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : GEOMGUI_AnnotationAttr.cxx // File : GEOMGUI_AnnotationAttr.cxx
// Author : Anton POLETAEV, Open CASCADE S.A.S. // Author : Anton POLETAEV, Open CASCADE S.A.S.
// //
// SALOME includes // SALOME includes
#include <GEOMGUI_AnnotationAttrs.h> #include <GEOMGUI_AnnotationAttrs.h>
#include <GEOM_Annotation.hxx> #include <GEOM_Annotation.hxx>
#include <SALOMEDSImpl_AttributeParameter.hxx> #include <SALOMEDSImpl_AttributeParameter.hxx>
// OCCT includes // OCCT includes
#include <gp_Ax3.hxx> #include <gp_Ax3.hxx>
// STL includes // STL includes
#include <string> #include <string>
#include <vector> #include <vector>
IMPLEMENT_STANDARD_RTTIEXT( GEOMGUI_AnnotationAttrs, Standard_Transient ) IMPLEMENT_STANDARD_RTTIEXT( GEOMGUI_AnnotationAttrs, Standard_Transient )
namespace namespace
{ {
static const std::string PARAMETER_COUNT = "GEOMGUI_AnnotationAttrs_Count"; static const std::string PARAMETER_COUNT = "GEOMGUI_AnnotationAttrs_Count";
std::string PARAMETER_I( const std::string& s, const int i ) { std::string PARAMETER_I( const std::string& s, const int i ) {
return std::string( s ) + std::to_string( i ); return std::string( s ) + std::to_string( i );
} }
std::string PARAMETER_IS_VISIBLE( const int i ) { std::string PARAMETER_IS_VISIBLE( const int i ) {
return PARAMETER_I( "GEOMGUI_AnnotationAttrs_IsVisible", i ); return PARAMETER_I( "GEOMGUI_AnnotationAttrs_IsVisible", i );
} }
std::string PARAMETER_IS_2D( const int i ) { std::string PARAMETER_IS_2D( const int i ) {
return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Is2D", i ); return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Is2D", i );
} }
std::string PARAMETER_NAME( const int i ) { std::string PARAMETER_NAME( const int i ) {
return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Name", i ); return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Name", i );
} }
std::string PARAMETER_TEXT( const int i ) { std::string PARAMETER_TEXT( const int i ) {
return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Text", i ); return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Text", i );
} }
std::string PARAMETER_POSITION( const int i ) { std::string PARAMETER_POSITION( const int i ) {
return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Position", i ); return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Position", i );
} }
std::string PARAMETER_ATTACH( const int i ) { std::string PARAMETER_ATTACH( const int i ) {
return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Attach", i ); return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Attach", i );
} }
std::string PARAMETER_SHAPE( const int i ) { std::string PARAMETER_SHAPE( const int i ) {
return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Shape", i ); return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Shape", i );
} }
} }
//================================================================================= //=================================================================================
// function : FindAttributes // function : FindAttributes
// purpose : // purpose :
//================================================================================= //=================================================================================
Handle(GEOMGUI_AnnotationAttrs) GEOMGUI_AnnotationAttrs::FindAttributes( const _PTR(SObject)& theObject ) Handle(GEOMGUI_AnnotationAttrs) GEOMGUI_AnnotationAttrs::FindAttributes( const _PTR(SObject)& theObject )
{ {
_PTR(GenericAttribute) aGenericAttr; _PTR(GenericAttribute) aGenericAttr;
_PTR(AttributeParameter) aParameterMap; _PTR(AttributeParameter) aParameterMap;
if ( !theObject->FindAttribute( aGenericAttr, "AttributeParameter" ) ) if ( !theObject->FindAttribute( aGenericAttr, "AttributeParameter" ) )
{ {
return Handle(GEOMGUI_AnnotationAttrs)(); return Handle(GEOMGUI_AnnotationAttrs)();
} }
aParameterMap = aGenericAttr; aParameterMap = aGenericAttr;
if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) ) if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) )
{ {
return Handle(GEOMGUI_AnnotationAttrs)(); return Handle(GEOMGUI_AnnotationAttrs)();
} }
return new GEOMGUI_AnnotationAttrs( theObject, aParameterMap ); return new GEOMGUI_AnnotationAttrs( theObject, aParameterMap );
} }
//================================================================================= //=================================================================================
// function : FindOrCreateAttributes // function : FindOrCreateAttributes
// purpose : // purpose :
//================================================================================= //=================================================================================
Handle(GEOMGUI_AnnotationAttrs) GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( Handle(GEOMGUI_AnnotationAttrs) GEOMGUI_AnnotationAttrs::FindOrCreateAttributes(
const _PTR(SObject)& theObject, SalomeApp_Study* theStudy ) const _PTR(SObject)& theObject, SalomeApp_Study* theStudy )
{ {
_PTR(StudyBuilder) aBuilder = theStudy->studyDS()->NewBuilder(); _PTR(StudyBuilder) aBuilder = theStudy->studyDS()->NewBuilder();
_PTR(AttributeParameter) aParameterMap = aBuilder->FindOrCreateAttribute( theObject, "AttributeParameter" ); _PTR(AttributeParameter) aParameterMap = aBuilder->FindOrCreateAttribute( theObject, "AttributeParameter" );
if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) ) if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) )
{ {
aParameterMap->SetInt( PARAMETER_COUNT, 0 ); aParameterMap->SetInt( PARAMETER_COUNT, 0 );
} }
return new GEOMGUI_AnnotationAttrs( theObject, aParameterMap ); return new GEOMGUI_AnnotationAttrs( theObject, aParameterMap );
} }
//================================================================================= //=================================================================================
// function : Remove // function : Remove
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::Remove( const _PTR(SObject)& theObject ) void GEOMGUI_AnnotationAttrs::Remove( const _PTR(SObject)& theObject )
{ {
_PTR(GenericAttribute) aGenericAttr; _PTR(GenericAttribute) aGenericAttr;
_PTR(AttributeParameter) aParameterMap; _PTR(AttributeParameter) aParameterMap;
if ( !theObject->FindAttribute( aGenericAttr, "AttributeParameter" ) ) if ( !theObject->FindAttribute( aGenericAttr, "AttributeParameter" ) )
{ {
return; return;
} }
aParameterMap = aGenericAttr; aParameterMap = aGenericAttr;
if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) ) if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) )
{ {
return; return;
} }
const int aParamCount = aParameterMap->GetInt( PARAMETER_COUNT ); const int aParamCount = aParameterMap->GetInt( PARAMETER_COUNT );
for ( int anI = 0; anI < aParamCount; ++anI ) for ( int anI = 0; anI < aParamCount; ++anI )
{ {
aParameterMap->RemoveID( PARAMETER_IS_VISIBLE( anI ), PT_BOOLEAN ); aParameterMap->RemoveID( PARAMETER_IS_VISIBLE( anI ), PT_BOOLEAN );
aParameterMap->RemoveID( PARAMETER_IS_2D( anI ), PT_BOOLEAN ); aParameterMap->RemoveID( PARAMETER_IS_2D( anI ), PT_BOOLEAN );
aParameterMap->RemoveID( PARAMETER_NAME( anI ), PT_STRING ); aParameterMap->RemoveID( PARAMETER_NAME( anI ), PT_STRING );
aParameterMap->RemoveID( PARAMETER_TEXT( anI ), PT_STRING ); aParameterMap->RemoveID( PARAMETER_TEXT( anI ), PT_STRING );
aParameterMap->RemoveID( PARAMETER_POSITION( anI ), PT_REALARRAY ); aParameterMap->RemoveID( PARAMETER_POSITION( anI ), PT_REALARRAY );
aParameterMap->RemoveID( PARAMETER_ATTACH( anI ), PT_REALARRAY ); aParameterMap->RemoveID( PARAMETER_ATTACH( anI ), PT_REALARRAY );
aParameterMap->RemoveID( PARAMETER_SHAPE( anI ), PT_INTARRAY ); aParameterMap->RemoveID( PARAMETER_SHAPE( anI ), PT_INTARRAY );
} }
aParameterMap->RemoveID( PARAMETER_COUNT, PT_INTEGER ); aParameterMap->RemoveID( PARAMETER_COUNT, PT_INTEGER );
} }
//================================================================================= //=================================================================================
// function : SetCount // function : SetNbAnnotation
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::SetCount( const int theCount ) const void GEOMGUI_AnnotationAttrs::SetNbAnnotation( const int theCount ) const
{ {
const int aCount = this->GetCount(); const int aCount = this->GetNbAnnotation();
if ( aCount < theCount ) if ( aCount < theCount )
{ {
// set default values // set default values
for ( int anI = aCount; anI < theCount; ++anI ) for ( int anI = aCount; anI < theCount; ++anI )
{ {
myParameterMap->SetBool( PARAMETER_IS_VISIBLE( anI ), true ); myParameterMap->SetBool( PARAMETER_IS_VISIBLE( anI ), true );
myParameterMap->SetBool( PARAMETER_IS_2D( anI ), false ); myParameterMap->SetBool( PARAMETER_IS_2D( anI ), false );
myParameterMap->SetString( PARAMETER_NAME( anI ), std::string() ); myParameterMap->SetString( PARAMETER_NAME( anI ), std::string() );
myParameterMap->SetString( PARAMETER_TEXT( anI ), std::string() ); myParameterMap->SetString( PARAMETER_TEXT( anI ), std::string() );
myParameterMap->SetRealArray( PARAMETER_POSITION( anI ), std::vector<double>(3, 0.0) ); myParameterMap->SetRealArray( PARAMETER_POSITION( anI ), std::vector<double>(3, 0.0) );
myParameterMap->SetRealArray( PARAMETER_ATTACH( 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) ); myParameterMap->SetIntArray( PARAMETER_SHAPE( anI ), std::vector<int>(2, 0) );
} }
} }
else else
{ {
// remove exceeding values // remove exceeding values
for ( int anI = theCount; anI < aCount; ++anI ) for ( int anI = theCount; anI < aCount; ++anI )
{ {
myParameterMap->RemoveID( PARAMETER_IS_VISIBLE( anI ), PT_BOOLEAN ); myParameterMap->RemoveID( PARAMETER_IS_VISIBLE( anI ), PT_BOOLEAN );
myParameterMap->RemoveID( PARAMETER_IS_2D( anI ), PT_BOOLEAN ); myParameterMap->RemoveID( PARAMETER_IS_2D( anI ), PT_BOOLEAN );
myParameterMap->RemoveID( PARAMETER_NAME( anI ), PT_STRING ); myParameterMap->RemoveID( PARAMETER_NAME( anI ), PT_STRING );
myParameterMap->RemoveID( PARAMETER_TEXT( anI ), PT_STRING ); myParameterMap->RemoveID( PARAMETER_TEXT( anI ), PT_STRING );
myParameterMap->RemoveID( PARAMETER_POSITION( anI ), PT_REALARRAY ); myParameterMap->RemoveID( PARAMETER_POSITION( anI ), PT_REALARRAY );
myParameterMap->RemoveID( PARAMETER_ATTACH( anI ), PT_REALARRAY ); myParameterMap->RemoveID( PARAMETER_ATTACH( anI ), PT_REALARRAY );
myParameterMap->RemoveID( PARAMETER_SHAPE( anI ), PT_INTARRAY ); myParameterMap->RemoveID( PARAMETER_SHAPE( anI ), PT_INTARRAY );
} }
} }
myParameterMap->SetInt( PARAMETER_COUNT, theCount ); myParameterMap->SetInt( PARAMETER_COUNT, theCount );
} }
//================================================================================= //=================================================================================
// function : GetCount // function : GetNbAnnotation
// purpose : // purpose :
//================================================================================= //=================================================================================
int GEOMGUI_AnnotationAttrs::GetCount() const int GEOMGUI_AnnotationAttrs::GetNbAnnotation() const
{ {
return myParameterMap->GetInt( PARAMETER_COUNT ); return myParameterMap->GetInt( PARAMETER_COUNT );
} }
//================================================================================= //=================================================================================
// function : SetName // function : SetName
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::SetName( const int theIndex, const QString& theName ) void GEOMGUI_AnnotationAttrs::SetName( const int theIndex, const QString& theName )
{ {
myParameterMap->SetString( PARAMETER_NAME( theIndex ), theName.toStdString() ); myParameterMap->SetString( PARAMETER_NAME( theIndex ), theName.toStdString() );
} }
//================================================================================= //=================================================================================
// function : GetName // function : GetName
// purpose : // purpose :
//================================================================================= //=================================================================================
QString GEOMGUI_AnnotationAttrs::GetName( const int theIndex ) const QString GEOMGUI_AnnotationAttrs::GetName( const int theIndex ) const
{ {
return QString::fromStdString( myParameterMap->GetString( PARAMETER_NAME( theIndex ) ) ); return QString::fromStdString( myParameterMap->GetString( PARAMETER_NAME( theIndex ) ) );
} }
//================================================================================= //=================================================================================
// function : SetVisible // function : SetVisible
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::SetIsVisible( const int theIndex, const bool theIsVisible ) void GEOMGUI_AnnotationAttrs::SetIsVisible( const int theIndex, const bool theIsVisible )
{ {
myParameterMap->SetBool( PARAMETER_IS_VISIBLE( theIndex ), theIsVisible ); myParameterMap->SetBool( PARAMETER_IS_VISIBLE( theIndex ), theIsVisible );
} }
//================================================================================= //=================================================================================
// function : GetIsVisible // function : GetIsVisible
// purpose : // purpose :
//================================================================================= //=================================================================================
bool GEOMGUI_AnnotationAttrs::GetIsVisible( const int theIndex ) const bool GEOMGUI_AnnotationAttrs::GetIsVisible( const int theIndex ) const
{ {
return myParameterMap->GetBool( PARAMETER_IS_VISIBLE( theIndex ) ); return myParameterMap->GetBool( PARAMETER_IS_VISIBLE( theIndex ) );
} }
//================================================================================= //=================================================================================
// function : SetText // function : SetText
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::SetText( const int theIndex, const QString& theText ) void GEOMGUI_AnnotationAttrs::SetText( const int theIndex, const QString& theText )
{ {
myParameterMap->SetString( PARAMETER_TEXT( theIndex ), theText.toStdString() ); myParameterMap->SetString( PARAMETER_TEXT( theIndex ), theText.toStdString() );
} }
//================================================================================= //=================================================================================
// function : GetText // function : GetText
// purpose : // purpose :
//================================================================================= //=================================================================================
QString GEOMGUI_AnnotationAttrs::GetText( const int theIndex ) const QString GEOMGUI_AnnotationAttrs::GetText( const int theIndex ) const
{ {
return QString::fromStdString( myParameterMap->GetString( PARAMETER_TEXT( theIndex ) ) ); return QString::fromStdString( myParameterMap->GetString( PARAMETER_TEXT( theIndex ) ) );
} }
//================================================================================= //=================================================================================
// function : SetIsScreenFixed // function : SetIsScreenFixed
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::SetIsScreenFixed( const int theIndex, const bool theIsScreenFixed ) void GEOMGUI_AnnotationAttrs::SetIsScreenFixed( const int theIndex, const bool theIsScreenFixed )
{ {
myParameterMap->SetBool( PARAMETER_IS_2D( theIndex ), theIsScreenFixed ); myParameterMap->SetBool( PARAMETER_IS_2D( theIndex ), theIsScreenFixed );
} }
//================================================================================= //=================================================================================
// function : GetIsScreenFixed // function : GetIsScreenFixed
// purpose : // purpose :
//================================================================================= //=================================================================================
bool GEOMGUI_AnnotationAttrs::GetIsScreenFixed( const int theIndex ) const bool GEOMGUI_AnnotationAttrs::GetIsScreenFixed( const int theIndex ) const
{ {
return myParameterMap->GetBool( PARAMETER_IS_2D( theIndex ) ); return myParameterMap->GetBool( PARAMETER_IS_2D( theIndex ) );
} }
//================================================================================= //=================================================================================
// function : SetPosition // function : SetPosition
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::SetPosition( const int theIndex, const gp_Pnt& thePosition ) void GEOMGUI_AnnotationAttrs::SetPosition( const int theIndex, const gp_Pnt& thePosition )
{ {
std::vector<double> aCoords( 3 ); std::vector<double> aCoords( 3 );
aCoords[0] = thePosition.X(); aCoords[0] = thePosition.X();
aCoords[1] = thePosition.Y(); aCoords[1] = thePosition.Y();
aCoords[2] = thePosition.Z(); aCoords[2] = thePosition.Z();
myParameterMap->SetRealArray( PARAMETER_POSITION( theIndex ), aCoords ); myParameterMap->SetRealArray( PARAMETER_POSITION( theIndex ), aCoords );
} }
//================================================================================= //=================================================================================
// function : GetPosition // function : GetPosition
// purpose : // purpose :
//================================================================================= //=================================================================================
gp_Pnt GEOMGUI_AnnotationAttrs::GetPosition( const int theIndex ) const gp_Pnt GEOMGUI_AnnotationAttrs::GetPosition( const int theIndex ) const
{ {
std::vector<double> aCoords = std::vector<double> aCoords =
myParameterMap->GetRealArray( PARAMETER_POSITION( theIndex ) ); myParameterMap->GetRealArray( PARAMETER_POSITION( theIndex ) );
return gp_Pnt( aCoords[0], aCoords[1], aCoords[2] ); return gp_Pnt( aCoords[0], aCoords[1], aCoords[2] );
} }
//================================================================================= //=================================================================================
// function : SetAttach // function : SetAttach
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::SetAttach( const int theIndex, const gp_Pnt& theAttach ) void GEOMGUI_AnnotationAttrs::SetAttach( const int theIndex, const gp_Pnt& theAttach )
{ {
std::vector<double> aCoords( 3 ); std::vector<double> aCoords( 3 );
aCoords[0] = theAttach.X(); aCoords[0] = theAttach.X();
aCoords[1] = theAttach.Y(); aCoords[1] = theAttach.Y();
aCoords[2] = theAttach.Z(); aCoords[2] = theAttach.Z();
myParameterMap->SetRealArray( PARAMETER_ATTACH( theIndex ), aCoords ); myParameterMap->SetRealArray( PARAMETER_ATTACH( theIndex ), aCoords );
} }
//================================================================================= //=================================================================================
// function : GetAttach // function : GetAttach
// purpose : // purpose :
//================================================================================= //=================================================================================
gp_Pnt GEOMGUI_AnnotationAttrs::GetAttach( const int theIndex ) const gp_Pnt GEOMGUI_AnnotationAttrs::GetAttach( const int theIndex ) const
{ {
std::vector<double> aCoords = std::vector<double> aCoords =
myParameterMap->GetRealArray( PARAMETER_ATTACH( theIndex ) ); myParameterMap->GetRealArray( PARAMETER_ATTACH( theIndex ) );
return gp_Pnt( aCoords[0], aCoords[1], aCoords[2] ); return gp_Pnt( aCoords[0], aCoords[1], aCoords[2] );
} }
//================================================================================= //=================================================================================
// function : SetShapeSel // function : SetShapeSel
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::SetShapeSel( const int theIndex, const int theShapeType, const int theSubIdx ) void GEOMGUI_AnnotationAttrs::SetShapeSel( const int theIndex, const int theShapeType, const int theSubIdx )
{ {
std::vector<int> aSelection( 2 ); std::vector<int> aSelection( 2 );
aSelection[0] = theShapeType; aSelection[0] = theShapeType;
aSelection[1] = theSubIdx; aSelection[1] = theSubIdx;
myParameterMap->SetIntArray( PARAMETER_SHAPE( theIndex ), aSelection ); myParameterMap->SetIntArray( PARAMETER_SHAPE( theIndex ), aSelection );
} }
//================================================================================= //=================================================================================
// function : GetShapeSel // function : GetShapeSel
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::GetShapeSel( const int theIndex, int& theShapeType, int& theSubIdx ) const void GEOMGUI_AnnotationAttrs::GetShapeSel( const int theIndex, int& theShapeType, int& theSubIdx ) const
{ {
std::vector<int> aSelection = std::vector<int> aSelection =
myParameterMap->GetIntArray( PARAMETER_SHAPE( theIndex ) ); myParameterMap->GetIntArray( PARAMETER_SHAPE( theIndex ) );
theShapeType = aSelection[0]; theShapeType = aSelection[0];
theSubIdx = aSelection[1]; theSubIdx = aSelection[1];
} }
//================================================================================= //=================================================================================
// function : Append // function : Append
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::Append( const Properties& theProps ) void GEOMGUI_AnnotationAttrs::Append( const Properties& theProps )
{ {
const int aCount = this->GetCount(); const int aCount = this->GetNbAnnotation();
this->SetCount( aCount + 1 ); this->SetNbAnnotation( aCount + 1 );
this->SetProperties( aCount, theProps ); this->SetProperties( aCount, theProps );
} }
//================================================================================= //=================================================================================
// function : SetProperties // function : SetProperties
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::SetProperties( const int theIndex, const Properties& theProps ) void GEOMGUI_AnnotationAttrs::SetProperties( const int theIndex, const Properties& theProps )
{ {
this->SetName( theIndex, theProps.Name ); this->SetName( theIndex, theProps.Name );
this->SetText( theIndex, theProps.Text ); this->SetText( theIndex, theProps.Text );
this->SetIsVisible( theIndex, theProps.IsVisible ); this->SetIsVisible( theIndex, theProps.IsVisible );
this->SetIsScreenFixed( theIndex, theProps.IsScreenFixed ); this->SetIsScreenFixed( theIndex, theProps.IsScreenFixed );
this->SetPosition( theIndex, theProps.Position ); this->SetPosition( theIndex, theProps.Position );
this->SetAttach( theIndex, theProps.Attach ); this->SetAttach( theIndex, theProps.Attach );
this->SetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex ); this->SetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex );
} }
//================================================================================= //=================================================================================
// function : GetProperties // function : GetProperties
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::GetProperties( const int theIndex, Properties& theProps ) const void GEOMGUI_AnnotationAttrs::GetProperties( const int theIndex, Properties& theProps ) const
{ {
theProps.Name = this->GetName( theIndex ); theProps.Name = this->GetName( theIndex );
theProps.Text = this->GetText( theIndex ); theProps.Text = this->GetText( theIndex );
theProps.IsVisible = this->GetIsVisible( theIndex ); theProps.IsVisible = this->GetIsVisible( theIndex );
theProps.IsScreenFixed = this->GetIsScreenFixed( theIndex ); theProps.IsScreenFixed = this->GetIsScreenFixed( theIndex );
theProps.Position = this->GetPosition( theIndex ); theProps.Position = this->GetPosition( theIndex );
theProps.Attach = this->GetAttach( theIndex ); theProps.Attach = this->GetAttach( theIndex );
this->GetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex ); this->GetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex );
} }
//================================================================================= //=================================================================================
// function : SetupPresentation // function : SetupPresentation
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation, void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
const Properties& theProps, const Properties& theProps,
const gp_Ax3& theLCS ) const gp_Ax3& theLCS )
{ {
gp_Trsf aToLCS; gp_Trsf aToLCS;
aToLCS.SetTransformation( theLCS, gp_Ax3() ); aToLCS.SetTransformation( theLCS, gp_Ax3() );
@ -408,18 +408,18 @@ void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)&
thePresentation->SetText( aText ); thePresentation->SetText( aText );
thePresentation->SetScreenFixed( theProps.IsScreenFixed ); thePresentation->SetScreenFixed( theProps.IsScreenFixed );
thePresentation->SetPosition( theProps.Position ); thePresentation->SetPosition( theProps.Position );
thePresentation->SetAttachPoint( theProps.Attach.Transformed( aToLCS ) ); thePresentation->SetAttachPoint( theProps.Attach.Transformed( aToLCS ) );
} }
//================================================================================= //=================================================================================
// function : SetupPresentation // function : SetupPresentation
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation, void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
const int theIndex, const int theIndex,
const gp_Ax3& theLCS ) const gp_Ax3& theLCS )
{ {
Properties aProps; Properties aProps;
this->GetProperties( theIndex, aProps ); this->GetProperties( theIndex, aProps );
this->SetupPresentation( thePresentation, aProps, theLCS ); this->SetupPresentation( thePresentation, aProps, theLCS );
} }

View File

@ -28,6 +28,7 @@
#define GEOMGUI_ANNOTATIONATTRS_H #define GEOMGUI_ANNOTATIONATTRS_H
// SALOME GUI includes // SALOME GUI includes
#include <GEOMGUI.h>
#include <SalomeApp_Study.h> #include <SalomeApp_Study.h>
// OCCT includes // OCCT includes
@ -50,14 +51,14 @@ public:
DEFINE_STANDARD_RTTIEXT( GEOMGUI_AnnotationAttrs, Standard_Transient ) DEFINE_STANDARD_RTTIEXT( GEOMGUI_AnnotationAttrs, Standard_Transient )
//! Find annotation data defined for an object. //! 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. //! Find or create annotation data fields for an object.
Standard_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindOrCreateAttributes( const _PTR(SObject)& theObject, GEOMGUI_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindOrCreateAttributes( const _PTR(SObject)& theObject,
SalomeApp_Study* theStudy ); SalomeApp_Study* theStudy );
//! Remove annotation data fields for an object. //! 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: public:
@ -80,17 +81,17 @@ public:
//! @param thePresentation [in] the presentation to setup. //! @param thePresentation [in] the presentation to setup.
//! @param theProps [in] the set of properties. //! @param theProps [in] the set of properties.
//! @param theLCS [in] the local coordinate system of the shape. //! @param theLCS [in] the local coordinate system of the shape.
Standard_EXPORT static void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation, GEOMGUI_EXPORT static void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
const Properties& theProps, const Properties& theProps,
const gp_Ax3& theLCS ); const gp_Ax3& theLCS );
//! Setup parameters of the annotation presentation with the properties of a definition. //! Setup parameters of the annotation presentation with the properties of a definition.
//! @param thePresentation [in] the presentation to setup. //! @param thePresentation [in] the presentation to setup.
//! @param theIndex [in] the index of the annotation definition. //! @param theIndex [in] the index of the annotation definition.
//! @param theLCS [in] the local coordinate system of the shape. //! @param theLCS [in] the local coordinate system of the shape.
Standard_EXPORT void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation, GEOMGUI_EXPORT void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
const int theIndex, const int theIndex,
const gp_Ax3& theLCS ); const gp_Ax3& theLCS );
public: public:
@ -98,84 +99,84 @@ public:
//! If the count is decreased the extra annotation definitions are //! If the count is decreased the extra annotation definitions are
//! cleared out from the attribute. //! cleared out from the attribute.
//! @param theNumber [in] the new number of annotation definitions. //! @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. //! 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. //! Sets application name property of an annotation definition.
//! @param theIndex [in] the index of the annotation definition. //! @param theIndex [in] the index of the annotation definition.
//! @param theName [in] the new application name. //! @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. //! Returns application name of an annotation definition.
//! @param theIndex [in] the index of the 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. //! Sets application visibility state of an annotation definition.
//! @param theIndex [in] the index of the annotation definition. //! @param theIndex [in] the index of the annotation definition.
//! @param theIsVisible [in] the visibility state. //! @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. //! 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. //! Sets annotation label's text.
//! @param theIndex [in] the index of the annotation definition. //! @param theIndex [in] the index of the annotation definition.
//! @param theText [in] the text string. //! @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. //! 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. //! Sets screen fixed flag of the annotation definition.
//! @param theIndex [in] the index of the annotation definition. //! @param theIndex [in] the index of the annotation definition.
//! @param theIsScreenFixed [in] the presentation flag. //! @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. //! 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. //! Sets position of the annotation definition.
//! @param theIndex [in] the index of the annotation definition. //! @param theIndex [in] the index of the annotation definition.
//! @param thePosition [in] the position of the annotation label. //! @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. //! 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. //! Sets attach point of the annotation definition.
//! @param theIndex [in] the index of the annotation definition. //! @param theIndex [in] the index of the annotation definition.
//! @param theAttach [in] the attach point of the annotation. //! @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. //! 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. //! Sets shape selection arguments.
//! @param theIndex [in] the index of the annotation definition. //! @param theIndex [in] the index of the annotation definition.
//! @param theShapeType, theSubIdx [in] the type of the selected shape and the sub-shape index. //! @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. //! Returns shape selection arguments.
//! @param theIndex [in] the index of the annotation definition. //! @param theIndex [in] the index of the annotation definition.
//! @param theShapeType, theSubIdx [out] the type of the selected shape and the sub-shape index. //! @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: public:
//! Appends new annotation definition with the given properties. //! 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. //! Sets complete properties of an annotation definition.
//! @param theIndex [in] the index of the annotation definition. //! @param theIndex [in] the index of the annotation definition.
//! @param theProps [in] the structure containing the properties. //! @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. //! Returns complete properties of an annotation definition.
//! @param theIndex [in] the index of the annotation definition. //! @param theIndex [in] the index of the annotation definition.
//! @param theProps [out] the structure containing the properties. //! @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: private:

View File

@ -28,8 +28,6 @@
#define GEOMGUI_DIMENSIONPROPERTY_H #define GEOMGUI_DIMENSIONPROPERTY_H
// OCCT includes // OCCT includes
#include <GEOMGUI_VisualProperties.h>
#include <AIS_DiameterDimension.hxx> #include <AIS_DiameterDimension.hxx>
#include <AIS_LengthDimension.hxx> #include <AIS_LengthDimension.hxx>
#include <AIS_AngleDimension.hxx> #include <AIS_AngleDimension.hxx>
@ -62,7 +60,7 @@ typedef QSharedPointer<GEOMGUI_DimensionProperty> DimensionPropertyPtr;
* Diam: (plane)[0-3] (flyout)[4] (text flags)[5-6] (arrow flag)[7] (circle loc, xdir, ydir, rad)[8-17] * 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] * 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: public:

View File

@ -22,7 +22,7 @@
#include "GEOMGUI_TextTreeWdg.h" #include "GEOMGUI_TextTreeWdg.h"
#include "GEOMGUI_DimensionProperty.h" #include "GEOMGUI_DimensionProperty.h"
//#include "GEOMGUI_ShapeAnnotations.h" #include "GEOMGUI_AnnotationAttrs.h"
#include "GeometryGUI.h" #include "GeometryGUI.h"
#include "GeometryGUI_Operations.h" #include "GeometryGUI_Operations.h"
#include <GEOM_Constants.h> #include <GEOM_Constants.h>
@ -50,6 +50,80 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QHash> #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 ) GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
: myDisplayer(NULL) : myDisplayer(NULL)
{ {
@ -102,9 +176,10 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
connect( this, SIGNAL( customContextMenuRequested(const QPoint&) ), connect( this, SIGNAL( customContextMenuRequested(const QPoint&) ),
this, SLOT( showContextMenu(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 ) ) ); this, SLOT( updateVisibilityColumn( QString, Qtx::VisibilityState ) ) );
connect( app->objectBrowser(), SIGNAL( updated() ), this, SLOT( updateTree() ) ); connect( app->objectBrowser(), SIGNAL( updated() ), this, SLOT( updateTree() ) );
GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) ); GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
connect( aGeomGUI, SIGNAL( DimensionsUpdated( const QString& ) ), this, SLOT( updateBranch( const QString& ) ) ); connect( aGeomGUI, SIGNAL( DimensionsUpdated( const QString& ) ), this, SLOT( updateBranch( const QString& ) ) );
connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ), connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ),
@ -145,7 +220,7 @@ void GEOMGUI_TextTreeWdg::updateTree()
if ( SC ) { if ( SC ) {
_PTR(ChildIterator) anIter ( aDSStudy->NewChildIterator( SC ) ); _PTR(ChildIterator) anIter ( aDSStudy->NewChildIterator( SC ) );
anIter->InitEx( true ); anIter->InitEx( true );
QList<QString> aGeomObjEntries = getObjects( Geometry ).keys(); QList<QString> aDimensionObjEntries = getObjects( DimensionShape ).keys();
QList<QString> anAnnotationObjEntries = getObjects( AnnotationShape ).keys(); QList<QString> anAnnotationObjEntries = getObjects( AnnotationShape ).keys();
while( anIter->More() ) { while( anIter->More() ) {
_PTR(SObject) valSO ( anIter->Value() ); _PTR(SObject) valSO ( anIter->Value() );
@ -154,54 +229,54 @@ void GEOMGUI_TextTreeWdg::updateTree()
// update tree of object's dimensions // update tree of object's dimensions
QString anEntry = valSO->GetID().c_str(); QString anEntry = valSO->GetID().c_str();
updateBranch( anEntry ); updateBranch( anEntry );
aGeomObjEntries.removeAll( anEntry ); aDimensionObjEntries.removeAll( anEntry );
anAnnotationObjEntries.removeAll( anEntry ); anAnnotationObjEntries.removeAll( anEntry );
} }
anIter->Next(); anIter->Next();
} }
foreach (QString entry, aGeomObjEntries) { foreach ( QString entry, aDimensionObjEntries ) {
removeBranch( Geometry, entry, true ); removeBranch( DimensionShape, entry, true );
} }
foreach (QString entry, anAnnotationObjEntries) { foreach ( QString entry, anAnnotationObjEntries ) {
removeBranch( AnnotationShape, entry, true ); removeBranch( AnnotationShape, entry, true );
} }
} }
} }
} }
//================================================================================= //=================================================================================
// function : updateBranch // function : updateBranch
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_TextTreeWdg::updateBranch( const QString& theEntry ) void GEOMGUI_TextTreeWdg::updateBranch( const QString& theEntry )
{ {
/// dimension property branch // dimension property branch
fillBranch( Geometry, theEntry ); fillBranch( DimensionShape, theEntry );
// annotation property branch // annotation property branch
// fillBranch(AnnotationShape, theEntry); fillBranch( AnnotationShape, theEntry );
} }
//=================================================================================
// function : fillBranch
// purpose :
//=================================================================================
void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QString& theEntry ) void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QString& theEntry )
{ {
myStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() ); myStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
if ( myStudy && !theEntry.isEmpty() ) { if ( myStudy && !theEntry.isEmpty() ) {
VisualPropertiesPtr aProp = getVisualProperty( theBranchType ); QSharedPointer<VisualProperty> aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
int aNumber = aProp->GetNumber();
const std::string anEntry = theEntry.toStdString(); const std::string anEntry = theEntry.toStdString();
if ( !aProp ) {
aProp->LoadFromAttribute( myStudy, theEntry.toStdString() );
if (!aProp)
return; return;
}
_PTR(Study) aStudyDS = myStudy->studyDS(); _PTR(Study) aStudyDS = myStudy->studyDS();
if ( aStudyDS ) { if ( aStudyDS ) {
_PTR(SObject) obj( aStudyDS->FindObjectID( theEntry.toStdString() ) ); _PTR(SObject) obj( aStudyDS->FindObjectID( theEntry.toStdString() ) );
QString aName = obj->GetName().c_str(); const QString aName = obj->GetName().c_str();
const int nbProps = aProp->GetNumber();
int nbProps = aProp->GetNumber();
QTreeWidgetItem* objectItem = itemFromEntry( theBranchType, theEntry ); QTreeWidgetItem* objectItem = itemFromEntry( theBranchType, theEntry );
if ( objectItem ) { if ( objectItem ) {
@ -211,7 +286,7 @@ void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QSt
if ( nbProps > 0 ) { if ( nbProps > 0 ) {
itemName << aName << ""; itemName << aName << "";
if ( !objectItem ) { if ( !objectItem ) {
QTreeWidgetItem* aPropRootItem = getPropertyRootItem(theBranchType); QTreeWidgetItem* aPropRootItem = getPropertyRootItem( theBranchType );
objectItem = new QTreeWidgetItem( aPropRootItem, itemName ); objectItem = new QTreeWidgetItem( aPropRootItem, itemName );
objectItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); objectItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
@ -221,15 +296,11 @@ void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QSt
if ( aPropRootItem->childCount() == 1 ) if ( aPropRootItem->childCount() == 1 )
aPropRootItem->setExpanded( true ); aPropRootItem->setExpanded( true );
} }
bool isDisplayed = myDisplayer.IsDisplayed( theEntry ); for ( int anIt = 0; anIt < nbProps; ++anIt ) {
// read dimension records from property const QString aPropName = aProp->GetName( anIt );
for ( int anIt = 0; anIt < aProp->GetNumber(); ++anIt ) { const bool isVisible = aProp->GetIsVisible( anIt );
QString aName = aProp->GetName( anIt );
bool isVisible = aProp->IsVisible( anIt );
QTreeWidgetItem* anItem = new QTreeWidgetItem; QTreeWidgetItem* anItem = new QTreeWidgetItem;
anItem->setText( 0, aName ); anItem->setText( 0, aPropName );
// if ( isDisplayed )
anItem->setIcon( 1, isVisible ? myVisibleIcon : myInvisibleIcon ); anItem->setIcon( 1, isVisible ? myVisibleIcon : myInvisibleIcon );
anItem->setData( 0, Qt::UserRole, anIt ); anItem->setData( 0, Qt::UserRole, anIt );
anItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); anItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
@ -244,18 +315,18 @@ void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QSt
// function : getVisualProperty // function : getVisualProperty
// purpose : // 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; switch ( theBranchType )
{
if ( theBranchType == Geometry ) { case DimensionShape : return QSharedPointer<VisualProperty>( new DimensionsProperty( theStudy, theEntry ) );
aProp = QSharedPointer<GEOMGUI_DimensionProperty>( new GEOMGUI_DimensionProperty() ); case AnnotationShape : return QSharedPointer<VisualProperty>( new AnnotationsProperty( theStudy, theEntry ) );
default: break;
} }
else { return QSharedPointer<VisualProperty>();
//aProp = QSharedPointer<GEOMGUI_ShapeAnnotations>( new GEOMGUI_ShapeAnnotations() );
}
return aProp;
} }
//================================================================================= //=================================================================================
@ -290,16 +361,16 @@ void GEOMGUI_TextTreeWdg::onItemClicked( QTreeWidgetItem* theItem, int theColumn
int aDimIndex = idFromItem( theItem ); int aDimIndex = idFromItem( theItem );
VisualPropertiesPtr aProp = getVisualProperty( aBranchType ); QSharedPointer<VisualProperty> aProp = getVisualProperty( aBranchType, myStudy, anEntry );
aProp->LoadFromAttribute( myStudy, anEntry );
if ( aProp->IsVisible( aDimIndex ) ) { if ( aProp->GetIsVisible( aDimIndex ) ) {
aProp->SetVisible( aDimIndex, false ); aProp->SetIsVisible( aDimIndex, false );
theItem->setIcon( 1, myInvisibleIcon ); theItem->setIcon( 1, myInvisibleIcon );
} else { } else {
aProp->SetVisible( aDimIndex, true ); aProp->SetIsVisible( aDimIndex, true );
theItem->setIcon( 1, myVisibleIcon ); theItem->setIcon( 1, myVisibleIcon );
} }
aProp->SaveToAttribute( myStudy, anEntry ); aProp->Save();
redisplay( anEntry.c_str() ); redisplay( anEntry.c_str() );
} }
@ -349,8 +420,10 @@ QTreeWidgetItem* GEOMGUI_TextTreeWdg::itemFromEntry( const BranchType& theBranch
//================================================================================= //=================================================================================
void GEOMGUI_TextTreeWdg::updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState ) void GEOMGUI_TextTreeWdg::updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState )
{ {
//BranchType theBranchType, // dimension property branch
updateVisibilityColumn( Geometry, theEntry, theState ); updateVisibilityColumn( DimensionShape, theEntry, theState );
// annotation property branch
updateVisibilityColumn( AnnotationShape, theEntry, theState ); updateVisibilityColumn( AnnotationShape, theEntry, theState );
} }
@ -367,16 +440,15 @@ void GEOMGUI_TextTreeWdg::updateVisibilityColumn( const BranchType& theBranchTyp
anItem->setDisabled( theState != Qtx::ShownState ); anItem->setDisabled( theState != Qtx::ShownState );
QTreeWidgetItem* aChildItem; QTreeWidgetItem* aChildItem;
VisualPropertiesPtr aProp = getVisualProperty( theBranchType ); QSharedPointer<VisualProperty> aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
for ( int i=0; i < anItem->childCount(); i++ ) { for ( int i=0; i < anItem->childCount(); i++ ) {
aChildItem = anItem->child( i ); aChildItem = anItem->child( i );
if ( theState == Qtx::ShownState ) { if ( theState == Qtx::ShownState ) {
aProp->LoadFromAttribute( myStudy, theEntry.toStdString() );
if ( aProp->GetNumber() == 0 ) if ( aProp->GetNumber() == 0 )
continue; continue;
aChildItem->setIcon( 1, aProp->IsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon aChildItem->setIcon( 1, aProp->GetIsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon
: myInvisibleIcon ); : myInvisibleIcon );
aChildItem->setDisabled( false ); aChildItem->setDisabled( false );
} else { } else {
aChildItem->setIcon( 1, QIcon() ); aChildItem->setIcon( 1, QIcon() );
@ -402,13 +474,13 @@ void GEOMGUI_TextTreeWdg::showContextMenu( const QPoint& pos )
QString anEntry = entryFromItem( anItem->parent() ); QString anEntry = entryFromItem( anItem->parent() );
if ( !anEntry.isEmpty() ) { if ( !anEntry.isEmpty() ) {
BranchType aBranchType = branchTypeFromItem( anItem ); 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 ) if ( aProp->GetNumber() == 0 )
return; return;
aMenu.clear(); aMenu.clear();
if ( aProp->IsVisible( idFromItem( anItem ) ) ) if ( aProp->GetIsVisible( idFromItem( anItem ) ) )
aMenu.addAction( myActions[GEOMOp::OpHide] ); aMenu.addAction( myActions[GEOMOp::OpHide] );
else else
aMenu.addAction( myActions[GEOMOp::OpShow] ); aMenu.addAction( myActions[GEOMOp::OpShow] );
@ -434,12 +506,12 @@ void GEOMGUI_TextTreeWdg::setVisibility( QTreeWidgetItem* theItem, bool theVisib
BranchType aBranchType = branchTypeFromItem( theItem ); BranchType aBranchType = branchTypeFromItem( theItem );
if ( theItem == myDimensionsItem || if ( theItem == myDimensionsItem ||
theItem == myAnnotationsItem ) { theItem == myAnnotationsItem ) {
// set visibility for all dimensions
QTreeWidgetItem* anItem; QTreeWidgetItem* anItem;
foreach ( QString entry, getObjects( aBranchType ).keys() ) { foreach ( QString entry, getObjects( aBranchType ).keys() ) {
anItem = itemFromEntry( aBranchType, entry ); anItem = itemFromEntry( aBranchType, entry );
if ( !anItem->isDisabled() ) if ( !anItem->isDisabled() )
setShapeDimensionsVisibility( aBranchType, entry, theVisibility ); setAllShapeItemsVisibility( aBranchType, entry, theVisibility );
} }
return; return;
} }
@ -448,50 +520,75 @@ void GEOMGUI_TextTreeWdg::setVisibility( QTreeWidgetItem* theItem, bool theVisib
QString anEntry = entryFromItem( theItem ); QString anEntry = entryFromItem( theItem );
if ( !anEntry.isEmpty() ) { if ( !anEntry.isEmpty() ) {
// it is a shape item // it is a shape item
setShapeDimensionsVisibility( aBranchType, anEntry, theVisibility ); setAllShapeItemsVisibility( aBranchType, anEntry, theVisibility );
} else { } else {
// it is a dimension item // it is a dimension item
anEntry = entryFromItem( theItem->parent() ); anEntry = entryFromItem( theItem->parent() );
setDimensionVisibility( aBranchType, anEntry, theItem, theVisibility ); setShapeItemVisibility( aBranchType, anEntry, theItem, theVisibility );
}
} }
}
} }
} }
//================================================================================= //=================================================================================
// function : setShapeDimensionsVisibility // function : setAllShapeItemsVisibility
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_TextTreeWdg::setShapeDimensionsVisibility( const BranchType& theBranchType, void GEOMGUI_TextTreeWdg::setAllShapeItemsVisibility( const BranchType& theBranchType,
QString theEntry, bool theVisibility ) const QString& theEntry,
const bool theVisibility )
{ {
QSharedPointer<VisualProperty>
aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
QTreeWidgetItem* anItem = itemFromEntry( theBranchType, theEntry ); QTreeWidgetItem* anItem = itemFromEntry( theBranchType, theEntry );
QTreeWidgetItem* aChildItem; QTreeWidgetItem* aChildItem;
for ( int i=0; i < anItem->childCount(); i++ ) { for ( int i=0; i < anItem->childCount(); i++ ) {
aChildItem = anItem->child( i ); aChildItem = anItem->child( i );
setDimensionVisibility( theBranchType, theEntry, aChildItem, theVisibility ); setShapeItemVisibility( aProp, aChildItem, theVisibility );
} }
aProp->Save();
redisplay( theEntry ); redisplay( theEntry );
} }
//================================================================================= //=================================================================================
// function : setDimensionVisibility // function : setShapeItemVisibility
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMGUI_TextTreeWdg::setDimensionVisibility( const BranchType& theBranchType, QString theEntry, void GEOMGUI_TextTreeWdg::setShapeItemVisibility( const BranchType& theBranchType,
QTreeWidgetItem* theDimItem, bool theVisibility ) 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() ); if ( setShapeItemVisibility( aProp, theWidgetItem, theVisibility ) ) {
int aDimIndex = idFromItem( theDimItem ); aProp->Save();
if ( aProp->GetNumber() == 0 || aProp->IsVisible( aDimIndex ) == theVisibility ) redisplay( theEntry );
return;; }
aProp->SetVisible( aDimIndex, theVisibility ); }
aProp->SaveToAttribute( myStudy, theEntry.toStdString() );
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;
} }
//================================================================================= //=================================================================================
@ -510,7 +607,7 @@ void GEOMGUI_TextTreeWdg::redisplay( QString theEntry )
//================================================================================= //=================================================================================
QTreeWidgetItem* GEOMGUI_TextTreeWdg::getPropertyRootItem( const BranchType& theBranchType ) QTreeWidgetItem* GEOMGUI_TextTreeWdg::getPropertyRootItem( const BranchType& theBranchType )
{ {
return theBranchType == Geometry ? myDimensionsItem : myAnnotationsItem; return (theBranchType == DimensionShape) ? myDimensionsItem : myAnnotationsItem;
} }
//================================================================================= //=================================================================================
@ -519,7 +616,7 @@ QTreeWidgetItem* GEOMGUI_TextTreeWdg::getPropertyRootItem( const BranchType& the
//================================================================================= //=================================================================================
QHash<QString, QTreeWidgetItem*>& GEOMGUI_TextTreeWdg::getObjects( const BranchType& theBranchType ) QHash<QString, QTreeWidgetItem*>& GEOMGUI_TextTreeWdg::getObjects( const BranchType& theBranchType )
{ {
return theBranchType == Geometry ? myObjects : myAnnotationObjects; return (theBranchType == DimensionShape) ? myDimensionObjects : myAnnotationObjects;
} }
//================================================================================= //=================================================================================
@ -528,7 +625,7 @@ QHash<QString, QTreeWidgetItem*>& GEOMGUI_TextTreeWdg::getObjects( const BranchT
//================================================================================= //=================================================================================
GEOMGUI_TextTreeWdg::BranchType GEOMGUI_TextTreeWdg::branchTypeFromItem( QTreeWidgetItem* theItem ) GEOMGUI_TextTreeWdg::BranchType GEOMGUI_TextTreeWdg::branchTypeFromItem( QTreeWidgetItem* theItem )
{ {
BranchType aBranchType = Geometry; BranchType aBranchType = DimensionShape;
bool aBranchTypeFound = false; bool aBranchTypeFound = false;
QTreeWidgetItem* anItem = theItem; QTreeWidgetItem* anItem = theItem;
@ -536,7 +633,7 @@ GEOMGUI_TextTreeWdg::BranchType GEOMGUI_TextTreeWdg::branchTypeFromItem( QTreeWi
if ( anItem == myDimensionsItem || if ( anItem == myDimensionsItem ||
anItem == myAnnotationsItem) { anItem == myAnnotationsItem) {
aBranchTypeFound = true; aBranchTypeFound = true;
aBranchType = anItem == myDimensionsItem ? Geometry : AnnotationShape; aBranchType = (anItem == myDimensionsItem) ? DimensionShape : AnnotationShape;
} }
else { else {
anItem = anItem->parent(); anItem = anItem->parent();

79
src/GEOMGUI/GEOMGUI_TextTreeWdg.h Normal file → Executable file
View File

@ -22,10 +22,10 @@
#include "GEOM_GEOMGUI.hxx" #include "GEOM_GEOMGUI.hxx"
#include "GEOM_Displayer.h" #include "GEOM_Displayer.h"
#include "GEOMGUI_VisualProperties.h"
#include <QTreeWidget>
#include <QHash> #include <QHash>
#include <QSharedPointer>
#include <QTreeWidget>
#include <SALOMEDSClient.hxx> #include <SALOMEDSClient.hxx>
@ -36,7 +36,6 @@ class QTreeWidgetItem;
class SalomeApp_Application; class SalomeApp_Application;
class SalomeApp_Study; class SalomeApp_Study;
/*! /*!
* \brief Tree view contains Dimension and Annotation text items: * \brief Tree view contains Dimension and Annotation text items:
* - text visibility in OCC viewer * - text visibility in OCC viewer
@ -47,8 +46,7 @@ class GEOMGUI_EXPORT GEOMGUI_TextTreeWdg : public QTreeWidget
Q_OBJECT Q_OBJECT
public: public:
enum BranchType { Geometry, AnnotationShape }; enum BranchType { DimensionShape, AnnotationShape };
public: public:
GEOMGUI_TextTreeWdg( SalomeApp_Application* app ); GEOMGUI_TextTreeWdg( SalomeApp_Application* app );
@ -61,11 +59,13 @@ public:
int idFromItem( QTreeWidgetItem* theItem ); int idFromItem( QTreeWidgetItem* theItem );
QString entryFromItem( QTreeWidgetItem* theShapeItem ); QString entryFromItem( QTreeWidgetItem* theShapeItem );
QTreeWidgetItem* itemFromEntry( const BranchType& theBranchType, QString theEntry ); QTreeWidgetItem* itemFromEntry( const BranchType& theBranchType, QString theEntry );
void setShapeDimensionsVisibility( const BranchType& theBranchType, void setAllShapeItemsVisibility( const BranchType& theBranchType,
QString theEntry, bool theVisibility ); const QString& theEntry,
void setDimensionVisibility( const BranchType& theBranchType, const bool theVisibility );
QString theEntry, QTreeWidgetItem* theDimItem, void setShapeItemVisibility( const BranchType& theBranchType,
bool theVisibility ); const QString& theEntry,
QTreeWidgetItem* theWidgetItem,
const bool theVisibility );
protected: protected:
void createActions(); void createActions();
void redisplay( QString theEntry ); void redisplay( QString theEntry );
@ -80,31 +80,50 @@ private slots:
void setVisibility( QTreeWidgetItem* theItem, bool visibility ); void setVisibility( QTreeWidgetItem* theItem, bool visibility );
void showContextMenu( const QPoint& pos ); void showContextMenu( const QPoint& pos );
private: public:
VisualPropertiesPtr getVisualProperty( const BranchType& theBranchType );
void fillBranch( const BranchType& theBranchType, /*!
const QString& theEntry ); * \brief Common interface for working with shape dimension and annotation properties
void updateVisibilityColumn( const BranchType& theBranchType, * of object in a unified way irrespectively of the implementation.
QString theEntry, */
Qtx::VisibilityState theState ); class VisualProperty
QTreeWidgetItem* getPropertyRootItem( const BranchType& theBranchType ); {
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:
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 ); QHash<QString, QTreeWidgetItem*>& getObjects( const BranchType& theBranchType );
BranchType branchTypeFromItem( QTreeWidgetItem* theItem ); BranchType branchTypeFromItem( QTreeWidgetItem* theItem );
private: private:
int myWindowID;
QIcon myVisibleIcon; int myWindowID;
QIcon myInvisibleIcon; QIcon myVisibleIcon;
QHash<QString, QTreeWidgetItem*> myObjects; QIcon myInvisibleIcon;
QHash<QString, QTreeWidgetItem*> myDimensionObjects;
QHash<QString, QTreeWidgetItem*> myAnnotationObjects; QHash<QString, QTreeWidgetItem*> myAnnotationObjects;
SalomeApp_Study* myStudy; SalomeApp_Study* myStudy;
QTreeWidgetItem* myDimensionsItem; QTreeWidgetItem* myDimensionsItem;
QTreeWidgetItem* myAnnotationsItem; QTreeWidgetItem* myAnnotationsItem;
GEOM_Displayer myDisplayer; GEOM_Displayer myDisplayer;
QMap<int, QAction*> myActions; //!< menu actions list
QMap<int, QAction*> myActions; //!< menu actions list
}; };
#endif #endif

View File

@ -1,122 +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_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

View File

@ -1420,7 +1420,7 @@ void GEOM_Displayer::updateShapeAnnotations( const Handle(SALOME_InteractiveObje
gp_Trsf aToLCS; gp_Trsf aToLCS;
aToLCS.SetTransformation( theShapeLCS, gp_Ax3() ); 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 ) ) if ( !aShapeAnnotations->GetIsVisible( anI ) )
{ {