X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_Selection.cxx;h=81a656b2ec07f5e2352d03d1ece2eef7be373966;hb=aad151600a149b1c90b99632e1e63e76fabf9e29;hp=73f961bea2a502751e214d4508c8528037e4efcf;hpb=c38c10811a065cf5b13e8807ed71864d92ca7d80;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index 73f961bea..81a656b2e 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -24,18 +24,30 @@ //function : SMESHGUI_Selection //purpose : //======================================================================= +SMESHGUI_Selection::SMESHGUI_Selection() +: SalomeApp_Selection() +{ +} + +//======================================================================= +//function : ~SMESHGUI_Selection +//purpose : +//======================================================================= +SMESHGUI_Selection::~SMESHGUI_Selection() +{ +} -SMESHGUI_Selection::SMESHGUI_Selection( const QString& client, - SalomeApp_SelectionMgr* mgr ) +//======================================================================= +//function : init +//purpose : +//======================================================================= +void SMESHGUI_Selection::init( const QString& client, SalomeApp_SelectionMgr* mgr ) { - myPopupClient = client; - - SalomeApp_Study* appStudy = dynamic_cast - (SUIT_Session::session()->activeApplication()->activeStudy()); + SalomeApp_Selection::init( client, mgr ); - if( mgr && appStudy ) + if( mgr && study() ) { - _PTR(Study) study = appStudy->studyDS(); + _PTR(Study) aStudy = study()->studyDS(); SUIT_DataOwnerPtrList sel; mgr->selected( sel, client ); @@ -47,36 +59,21 @@ SMESHGUI_Selection::SMESHGUI_Selection( const QString& client, SUIT_DataOwner* owner = ( SUIT_DataOwner* )( (*anIt ).get() ); SalomeApp_DataOwner* sowner = dynamic_cast( owner ); if( sowner ) - myTypes.append( typeName( type( sowner, study ) ) ); + myTypes.append( typeName( type( sowner, aStudy ) ) ); else myTypes.append( "Unknown" ); } } } -SMESHGUI_Selection::~SMESHGUI_Selection() -{ -} - -//======================================================================= -//function : count -//purpose : -//======================================================================= - -int SMESHGUI_Selection::count() const -{ - return myTypes.count(); -} - //======================================================================= //function : param //purpose : //======================================================================= - QtxValue SMESHGUI_Selection::param( const int ind, const QString& p ) const { QtxValue val; - if ( p=="client" ) val = QtxValue( myPopupClient ); + if ( p=="client" ) val = QtxValue( globalParam( p ) ); else if ( p=="type" ) val = QtxValue( myTypes[ind] ); else if ( p=="elemTypes" ) val = QtxValue( elemTypes( ind ) ); else if ( p=="numberOfNodes" ) val = QtxValue( numberOfNodes( ind ) ); @@ -87,12 +84,16 @@ QtxValue SMESHGUI_Selection::param( const int ind, const QString& p ) const else if ( p=="displayMode" ) val = QtxValue( displayMode( ind ) ); else if ( p=="isComputable" ) val = QtxValue( isComputable( ind ) ); else if ( p=="hasReference" ) val = QtxValue( hasReference( ind ) ); - else if ( p=="isVisible" ) val = QtxValue( isVisible( ind ) ); +// else if ( p=="isVisible" ) val = QtxValue( isVisible( ind ) ); + + // printf( "--> param() : [%s] = %s (%s)\n", p.latin1(), val.toString().latin1(), val.typeName() ); + //if ( val.type() == QVariant::List ) + //cout << "size: " << val.toList().count() << endl; - printf( "--> param() : [%s] = %s (%s)\n", p.latin1(), val.toString().latin1(), val.typeName() ); - if ( val.type() == QVariant::List ) - cout << "size: " << val.toList().count() << endl; - return val; + if( val.isValid() ) + return val; + else + return SalomeApp_Selection::param( ind, p ); } //======================================================================= @@ -105,7 +106,7 @@ SMESH_Actor* SMESHGUI_Selection::getActor( int ind ) const if ( ind >= 0 && ind < myDataOwners.count() ) { const SalomeApp_SVTKDataOwner* owner = dynamic_cast ( myDataOwners[ ind ].get() ); - if ( owner ) + if ( owner ) return dynamic_cast( owner->GetActor() ); } return 0; @@ -289,10 +290,12 @@ QVariant SMESHGUI_Selection::hasReference( int ind ) const { if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" ) { - Handle(SALOME_InteractiveObject) io = - static_cast( myDataOwners[ ind ].get() )->IO(); - if ( !io.IsNull() ) - return QVariant( io->hasReference(), 0 ); + SalomeApp_DataOwner* owner = dynamic_cast( myDataOwners[ ind ].operator->() ); + if( owner ) + { + _PTR(SObject) obj ( study()->studyDS()->FindObjectID( owner->entry().latin1() ) ), ref; + return QVariant( obj->ReferencedObject( ref ), 0 ); + } } return QVariant( false, 0 ); } @@ -309,31 +312,47 @@ QVariant SMESHGUI_Selection::isVisible( int ind ) const QString entry = static_cast( myDataOwners[ ind ].get() )->entry(); SMESH_Actor* actor = SMESH::FindActorByEntry( entry.latin1() ); if ( actor && actor->hasIO() ) { - SVTK_RenderWindowInteractor* renderInter = SMESH::GetCurrentVtkView()->getRWInteractor(); - return QVariant( renderInter->isVisible( actor->getIO() ), 0 ); + if(SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView()) + return QVariant( aViewWindow->isVisible( actor->getIO() ), 0 ); } } return QVariant( false, 0 ); } +//======================================================================= +//function : type +//purpose : +//======================================================================= +int SMESHGUI_Selection::type( SalomeApp_DataOwner* owner, _PTR(Study) study ) +{ + return type( owner->entry(), study ); +} + //======================================================================= //function : type //purpose : //======================================================================= -int SMESHGUI_Selection::type( SalomeApp_DataOwner* owner, - _PTR(Study) study ) +int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study ) { - QString entry = owner->entry(); - _PTR(SObject) obj (study->FindObjectID(entry.latin1())); if( !obj ) return -1; + _PTR(SObject) ref; + if( obj->ReferencedObject( ref ) ) + obj = ref; + _PTR(SObject) objFather = obj->GetFather(); _PTR(SComponent) objComponent = obj->GetFatherComponent(); + if( objComponent->ComponentDataType()!="SMESH" ) + return -1; + + if( objComponent->GetIOR()==obj->GetIOR() ) + return COMPONENT; + int aLevel = obj->Depth() - objComponent->Depth(), aFTag = objFather->Tag(), anOTag = obj->Tag(), @@ -415,6 +434,8 @@ QString SMESHGUI_Selection::typeName( const int t ) return "Mesh compound"; case GROUP: return "Group"; + case COMPONENT: + return "Component"; default: return "Unknown"; }