PAL10332 - references are interpreted as original objects in filters, dialogs, etc.

This commit is contained in:
asl 2005-10-25 08:19:21 +00:00
parent 868e306e09
commit b0105f0f9d
7 changed files with 81 additions and 62 deletions

View File

@ -127,7 +127,7 @@ bool SMESH_NumberFilter::isOk (const SUIT_DataOwner* theDataOwner) const
// Purpose : Retrieve geom object from SALOME_InteractiveObject
//=======================================================================
GEOM::GEOM_Object_ptr SMESH_NumberFilter::getGeom
(const SUIT_DataOwner* theDataOwner) const
(const SUIT_DataOwner* theDataOwner, const bool extractReference ) const
{
const SalomeApp_DataOwner* owner =
dynamic_cast<const SalomeApp_DataOwner*>(theDataOwner);
@ -142,7 +142,10 @@ GEOM::GEOM_Object_ptr SMESH_NumberFilter::getGeom
_PTR(Study) study = appStudy->studyDS();
QString entry = owner->entry();
_PTR(SObject) aSO(study->FindObjectID(entry.latin1()));
_PTR(SObject) aSO( study->FindObjectID( entry.latin1() ) ), aRefSO;
if( extractReference && aSO && aSO->ReferencedObject( aRefSO ) )
aSO = aRefSO;
if (!aSO)
return GEOM::GEOM_Object::_nil();

View File

@ -55,7 +55,7 @@ class SMESH_NumberFilter : public SUIT_SelectionFilter
void SetMainShape (GEOM::GEOM_Object_ptr);
private:
GEOM::GEOM_Object_ptr getGeom (const SUIT_DataOwner*) const;
GEOM::GEOM_Object_ptr getGeom (const SUIT_DataOwner*, const bool extractReference = true ) const;
private:
char* myKind;

View File

@ -16,7 +16,7 @@ SMESH_TypeFilter::~SMESH_TypeFilter()
bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const
{
bool Ok = false;
bool Ok = false, extractReference = true;
const SalomeApp_DataOwner* owner =
dynamic_cast<const SalomeApp_DataOwner*>(theDataOwner);
@ -27,7 +27,9 @@ bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const
_PTR(Study) study = appStudy->studyDS();
QString entry = owner->entry();
_PTR(SObject) obj (study->FindObjectID(entry.latin1()));
_PTR(SObject) obj (study->FindObjectID(entry.latin1())), aRefSO;
if( extractReference && obj && obj->ReferencedObject( aRefSO ) )
obj = aRefSO;
if (!obj) return false;
_PTR(SObject) objFather = obj->GetFather();

View File

@ -667,7 +667,7 @@ namespace{
{
// VSR 17/11/04: check if all objects selected belong to SMESH component --> start
SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
SALOME_ListIO selected; aSel->selectedObjects( selected );
SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
QString aParentComponent = QString::null;
for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
@ -1829,7 +1829,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
SALOME_ListIO selected;
if( aSel )
aSel->selectedObjects( selected );
aSel->selectedObjects( selected, QString::null, false );
SALOME_ListIteratorOfListIO It(selected);
for (int i = 0; It.More(); It.Next(), i++) {

View File

@ -49,23 +49,25 @@ void SMESHGUI_Selection::init( const QString& client, SalomeApp_SelectionMgr* mg
{
_PTR(Study) aStudy = study()->studyDS();
SUIT_DataOwnerPtrList sel;
mgr->selected( sel, client );
myDataOwners = sel;
SUIT_DataOwnerPtrList::const_iterator anIt = sel.begin(),
aLast = sel.end();
for( ; anIt!=aLast; anIt++ )
{
SUIT_DataOwner* owner = ( SUIT_DataOwner* )( (*anIt ).get() );
SalomeApp_DataOwner* sowner = dynamic_cast<SalomeApp_DataOwner*>( owner );
if( sowner )
myTypes.append( typeName( type( sowner, aStudy ) ) );
else
myTypes.append( "Unknown" );
}
for( int i=0, n=count(); i<n; i++ )
myTypes.append( typeName( type( entry( i ), aStudy ) ) );
}
}
//=======================================================================
//function : processOwner
//purpose :
//=======================================================================
void SMESHGUI_Selection::processOwner( const SalomeApp_DataOwner* ow )
{
const SalomeApp_SVTKDataOwner* owner =
dynamic_cast<const SalomeApp_SVTKDataOwner*> ( ow );
if( owner )
myActors.append( dynamic_cast<SMESH_Actor*>( owner->GetActor() ) );
else
myActors.append( 0 );
}
//=======================================================================
//function : param
//purpose :
@ -103,13 +105,10 @@ QtxValue SMESHGUI_Selection::param( const int ind, const QString& p ) const
SMESH_Actor* SMESHGUI_Selection::getActor( int ind ) const
{
if ( ind >= 0 && ind < myDataOwners.count() ) {
const SalomeApp_SVTKDataOwner* owner =
dynamic_cast<const SalomeApp_SVTKDataOwner*> ( myDataOwners[ ind ].get() );
if ( owner )
return dynamic_cast<SMESH_Actor*>( owner->GetActor() );
}
return 0;
if( ind >= 0 && ind < count() )
return ((QPtrList<SMESH_Actor>&)myActors).at( ind );
else
return 0;
}
//=======================================================================
@ -240,8 +239,9 @@ int SMESHGUI_Selection::numberOfNodes( int ind ) const
{
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
{
CORBA::Object_var obj =
SMESH::DataOwnerToObject( static_cast<SalomeApp_DataOwner*>( myDataOwners[ ind ].get() ));
_PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).latin1() );
CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
if ( ! CORBA::is_nil( obj )) {
SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
if ( ! mesh->_is_nil() )
@ -266,18 +266,19 @@ QVariant SMESHGUI_Selection::isComputable( int ind ) const
{
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
{
Handle(SALOME_InteractiveObject) io =
/* Handle(SALOME_InteractiveObject) io =
static_cast<SalomeApp_DataOwner*>( myDataOwners[ ind ].get() )->IO();
if ( !io.IsNull() ) {
SMESH::SMESH_Mesh_var mesh = SMESH::GetMeshByIO(io) ; // m,sm,gr->m
if ( !mesh->_is_nil() ) {
_PTR(SObject) so = SMESH::FindSObject( mesh );
if ( !mesh->_is_nil() ) {*/
_PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ) );
//FindSObject( mesh );
if ( so ) {
GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
return QVariant( !shape->_is_nil(), 0 );
}
}
}
// }
// }
}
return QVariant( false, 0 );
}
@ -289,16 +290,7 @@ QVariant SMESHGUI_Selection::isComputable( int ind ) const
QVariant SMESHGUI_Selection::hasReference( int ind ) const
{
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
{
SalomeApp_DataOwner* owner = dynamic_cast<SalomeApp_DataOwner*>( 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 );
return QVariant( isReference( ind ), 0 );
}
//=======================================================================
@ -310,8 +302,8 @@ QVariant SMESHGUI_Selection::isVisible( int ind ) const
{
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
{
QString entry = static_cast<SalomeApp_DataOwner*>( myDataOwners[ ind ].get() )->entry();
SMESH_Actor* actor = SMESH::FindActorByEntry( entry.latin1() );
QString ent = entry( ind );
SMESH_Actor* actor = SMESH::FindActorByEntry( ent.latin1() );
if ( actor && actor->hasIO() ) {
SVTK_RenderWindowInteractor* renderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
return QVariant( renderInter->isVisible( actor->getIO() ), 0 );
@ -320,16 +312,6 @@ QVariant SMESHGUI_Selection::isVisible( int ind ) const
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 :

View File

@ -31,7 +31,6 @@
#include "SalomeApp_Selection.h"
#include "SALOMEDSClient_definitions.hxx"
#include "SUIT_DataOwner.h"
class SalomeApp_SelectionMgr;
class SALOMEDSClient_Study;
@ -46,6 +45,7 @@ public:
virtual void init( const QString&, SalomeApp_SelectionMgr* );
virtual QtxValue param( const int , const QString& paramName ) const;
virtual void processOwner( const SalomeApp_DataOwner* );
// got from object, not from actor
virtual int numberOfNodes( int ind ) const;
@ -64,12 +64,11 @@ public:
SMESH_Actor* getActor( int ind ) const;
static int type( const QString&, _PTR(Study) );
static int type( SalomeApp_DataOwner* owner, _PTR(Study) study);
static QString typeName( const int type);
private:
QStringList myTypes;
SUIT_DataOwnerPtrList myDataOwners;
QStringList myTypes;
QPtrList<SMESH_Actor> myActors;
};
#endif

View File

@ -43,6 +43,8 @@
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include <SALOMEDS_SObject.hxx>
#include <SALOME_ListIteratorOfListIO.hxx>
/*
Class : SMESHGUI_SelectionOp
Description : Base operation for all operations using object selection in viewer or objectbrowser
@ -357,7 +359,7 @@ void SMESHGUI_SelectionOp::selected( QStringList& names,
SalomeApp_Dialog::TypesList& types,
QStringList& ids ) const
{
SUIT_DataOwnerPtrList list; selectionMgr()->selected( list );
/* SUIT_DataOwnerPtrList list; selectionMgr()->selected( list );
SUIT_DataOwnerPtrList::const_iterator anIt = list.begin(),
aLast = list.end();
for( ; anIt!=aLast; anIt++ )
@ -389,6 +391,37 @@ void SMESHGUI_SelectionOp::selected( QStringList& names,
types.append( typeById( id, Object ) );
names.append( owner->IO()->getName() );
}
}*/
SALOME_ListIO selObjs;
TColStd_IndexedMapOfInteger selIndices;
selectionMgr()->selectedObjects( selObjs );
Selection_Mode mode = selectionMode();
EntityType objtype = mode == NodeSelection ? MeshNode : MeshElement;
for( SALOME_ListIteratorOfListIO anIt( selObjs ); anIt.More(); anIt.Next() )
{
selIndices.Clear();
selectionMgr()->GetIndexes( anIt.Value(), selIndices );
if( selIndices.Extent()==0 )
{
QString id_str = QString( "%1%2%3" ).arg( anIt.Value()->getEntry() ).arg( idChar() ), current_id_str;
for( int i=1, n=selIndices.Extent(); i<=n; i++ )
{
int curid = selIndices( i );
current_id_str = id_str.arg( curid );
ids.append( current_id_str );
types.append( typeById( current_id_str, objtype ) );
names.append( QString( "%1" ).arg( curid ) );
}
}
else
{
QString id = anIt.Value()->getEntry();
ids.append( id );
types.append( typeById( id, Object ) );
names.append( anIt.Value()->getName() );
}
}
}