// 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);
_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();
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;
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);
_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();
{
// 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() )
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++) {
{
_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 :
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;
}
//=======================================================================
{
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() )
{
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 );
}
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 );
}
//=======================================================================
{
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 );
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 :
#include "SalomeApp_Selection.h"
#include "SALOMEDSClient_definitions.hxx"
-#include "SUIT_DataOwner.h"
class SalomeApp_SelectionMgr;
class SALOMEDSClient_Study;
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;
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
#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
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++ )
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() );
+ }
}
}