mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-15 02:03:07 +05:00
Update of text tree widget integration to new class
of shape annotation attributes
This commit is contained in:
parent
96407303b7
commit
c11f35e20d
@ -75,7 +75,6 @@ SET(GEOMGUI_HEADERS
|
||||
GEOM_GEOMGUI.hxx
|
||||
GEOMGUI_CreationInfoWdg.h
|
||||
GEOMGUI_TextTreeWdg.h
|
||||
GEOMGUI_VisualProperties.h
|
||||
GEOMGUI_DimensionProperty.h
|
||||
GEOMGUI_AnnotationAttrs.h
|
||||
)
|
||||
|
@ -1,403 +1,403 @@
|
||||
// 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
|
||||
//
|
||||
// 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 : SetNbAnnotation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetNbAnnotation( const int theCount ) const
|
||||
{
|
||||
const int aCount = this->GetNbAnnotation();
|
||||
|
||||
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 : GetNbAnnotation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
int GEOMGUI_AnnotationAttrs::GetNbAnnotation() 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->GetNbAnnotation();
|
||||
this->SetNbAnnotation( aCount + 1 );
|
||||
this->SetProperties( aCount, theProps );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetProperties
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetProperties( const int theIndex, const Properties& theProps )
|
||||
{
|
||||
this->SetName( theIndex, theProps.Name );
|
||||
this->SetText( theIndex, theProps.Text );
|
||||
this->SetIsVisible( theIndex, theProps.IsVisible );
|
||||
this->SetIsScreenFixed( theIndex, theProps.IsScreenFixed );
|
||||
this->SetPosition( theIndex, theProps.Position );
|
||||
this->SetAttach( theIndex, theProps.Attach );
|
||||
this->SetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : GetProperties
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::GetProperties( const int theIndex, Properties& theProps ) const
|
||||
{
|
||||
theProps.Name = this->GetName( theIndex );
|
||||
theProps.Text = this->GetText( theIndex );
|
||||
theProps.IsVisible = this->GetIsVisible( theIndex );
|
||||
theProps.IsScreenFixed = this->GetIsScreenFixed( theIndex );
|
||||
theProps.Position = this->GetPosition( theIndex );
|
||||
theProps.Attach = this->GetAttach( theIndex );
|
||||
|
||||
this->GetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetupPresentation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
|
||||
const Properties& theProps,
|
||||
const gp_Ax3& theLCS )
|
||||
{
|
||||
gp_Trsf aToLCS;
|
||||
aToLCS.SetTransformation( theLCS, gp_Ax3() );
|
||||
|
||||
@ -408,18 +408,18 @@ void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)&
|
||||
thePresentation->SetText( aText );
|
||||
thePresentation->SetScreenFixed( theProps.IsScreenFixed );
|
||||
thePresentation->SetPosition( theProps.Position );
|
||||
thePresentation->SetAttachPoint( theProps.Attach.Transformed( aToLCS ) );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetupPresentation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
|
||||
const int theIndex,
|
||||
const gp_Ax3& theLCS )
|
||||
{
|
||||
Properties aProps;
|
||||
this->GetProperties( theIndex, aProps );
|
||||
this->SetupPresentation( thePresentation, aProps, theLCS );
|
||||
}
|
||||
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 );
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#define GEOMGUI_ANNOTATIONATTRS_H
|
||||
|
||||
// SALOME GUI includes
|
||||
#include <GEOMGUI.h>
|
||||
#include <SalomeApp_Study.h>
|
||||
|
||||
// OCCT includes
|
||||
@ -50,14 +51,14 @@ public:
|
||||
DEFINE_STANDARD_RTTIEXT( GEOMGUI_AnnotationAttrs, Standard_Transient )
|
||||
|
||||
//! Find annotation data defined for an object.
|
||||
Standard_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindAttributes( const _PTR(SObject)& theObject );
|
||||
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:
|
||||
|
||||
@ -80,17 +81,17 @@ 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:
|
||||
|
||||
@ -98,84 +99,84 @@ 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:
|
||||
|
||||
|
@ -28,8 +28,6 @@
|
||||
#define GEOMGUI_DIMENSIONPROPERTY_H
|
||||
|
||||
// OCCT includes
|
||||
#include <GEOMGUI_VisualProperties.h>
|
||||
|
||||
#include <AIS_DiameterDimension.hxx>
|
||||
#include <AIS_LengthDimension.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]
|
||||
* 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:
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#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>
|
||||
@ -50,6 +50,80 @@
|
||||
#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)
|
||||
{
|
||||
@ -102,9 +176,10 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
|
||||
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) ),
|
||||
@ -145,7 +220,7 @@ void GEOMGUI_TextTreeWdg::updateTree()
|
||||
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() );
|
||||
@ -154,54 +229,54 @@ void GEOMGUI_TextTreeWdg::updateTree()
|
||||
// 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 ) {
|
||||
@ -211,7 +286,7 @@ void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QSt
|
||||
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 );
|
||||
@ -221,15 +296,11 @@ void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QSt
|
||||
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 );
|
||||
@ -244,18 +315,18 @@ void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QSt
|
||||
// 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>();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -290,16 +361,16 @@ void GEOMGUI_TextTreeWdg::onItemClicked( QTreeWidgetItem* theItem, int theColumn
|
||||
|
||||
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() );
|
||||
}
|
||||
@ -349,8 +420,10 @@ QTreeWidgetItem* GEOMGUI_TextTreeWdg::itemFromEntry( const BranchType& theBranch
|
||||
//=================================================================================
|
||||
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 );
|
||||
}
|
||||
|
||||
@ -367,16 +440,15 @@ void GEOMGUI_TextTreeWdg::updateVisibilityColumn( const BranchType& theBranchTyp
|
||||
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() );
|
||||
@ -402,13 +474,13 @@ void GEOMGUI_TextTreeWdg::showContextMenu( const QPoint& pos )
|
||||
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] );
|
||||
@ -434,12 +506,12 @@ void GEOMGUI_TextTreeWdg::setVisibility( QTreeWidgetItem* theItem, bool theVisib
|
||||
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;
|
||||
}
|
||||
@ -448,50 +520,75 @@ void GEOMGUI_TextTreeWdg::setVisibility( QTreeWidgetItem* theItem, bool theVisib
|
||||
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;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -510,7 +607,7 @@ void GEOMGUI_TextTreeWdg::redisplay( QString theEntry )
|
||||
//=================================================================================
|
||||
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 )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
BranchType aBranchType = Geometry;
|
||||
BranchType aBranchType = DimensionShape;
|
||||
|
||||
bool aBranchTypeFound = false;
|
||||
QTreeWidgetItem* anItem = theItem;
|
||||
@ -536,7 +633,7 @@ GEOMGUI_TextTreeWdg::BranchType GEOMGUI_TextTreeWdg::branchTypeFromItem( QTreeWi
|
||||
if ( anItem == myDimensionsItem ||
|
||||
anItem == myAnnotationsItem) {
|
||||
aBranchTypeFound = true;
|
||||
aBranchType = anItem == myDimensionsItem ? Geometry : AnnotationShape;
|
||||
aBranchType = (anItem == myDimensionsItem) ? DimensionShape : AnnotationShape;
|
||||
}
|
||||
else {
|
||||
anItem = anItem->parent();
|
||||
|
79
src/GEOMGUI/GEOMGUI_TextTreeWdg.h
Normal file → Executable file
79
src/GEOMGUI/GEOMGUI_TextTreeWdg.h
Normal file → Executable file
@ -22,10 +22,10 @@
|
||||
|
||||
#include "GEOM_GEOMGUI.hxx"
|
||||
#include "GEOM_Displayer.h"
|
||||
#include "GEOMGUI_VisualProperties.h"
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QHash>
|
||||
#include <QSharedPointer>
|
||||
#include <QTreeWidget>
|
||||
|
||||
#include <SALOMEDSClient.hxx>
|
||||
|
||||
@ -36,7 +36,6 @@ class QTreeWidgetItem;
|
||||
class SalomeApp_Application;
|
||||
class SalomeApp_Study;
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Tree view contains Dimension and Annotation text items:
|
||||
* - text visibility in OCC viewer
|
||||
@ -47,8 +46,7 @@ class GEOMGUI_EXPORT GEOMGUI_TextTreeWdg : public QTreeWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum BranchType { Geometry, AnnotationShape };
|
||||
|
||||
enum BranchType { DimensionShape, AnnotationShape };
|
||||
|
||||
public:
|
||||
GEOMGUI_TextTreeWdg( SalomeApp_Application* app );
|
||||
@ -61,11 +59,13 @@ public:
|
||||
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 );
|
||||
@ -80,31 +80,50 @@ private slots:
|
||||
void setVisibility( QTreeWidgetItem* theItem, bool visibility );
|
||||
void showContextMenu( const QPoint& pos );
|
||||
|
||||
private:
|
||||
VisualPropertiesPtr getVisualProperty( const BranchType& theBranchType );
|
||||
public:
|
||||
|
||||
void fillBranch( const BranchType& theBranchType,
|
||||
const QString& theEntry );
|
||||
void updateVisibilityColumn( const BranchType& theBranchType,
|
||||
QString theEntry,
|
||||
Qtx::VisibilityState theState );
|
||||
QTreeWidgetItem* getPropertyRootItem( const BranchType& theBranchType );
|
||||
/*!
|
||||
* \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:
|
||||
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
|
||||
|
@ -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
|
@ -1420,7 +1420,7 @@ void GEOM_Displayer::updateShapeAnnotations( const Handle(SALOME_InteractiveObje
|
||||
gp_Trsf aToLCS;
|
||||
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 ) )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user