if ( mgr->application() )
myStudy = dynamic_cast<SalomeApp_Study*>( mgr->application()->activeStudy() );
+ if( !myStudy )
+ return;
+
+ _PTR(Study) studyds = myStudy->studyDS();
+ _PTR(SObject) refobj;
+
SUIT_DataOwnerPtrList sel;
mgr->selected( sel, client );
SUIT_DataOwnerPtrList::const_iterator anIt = sel.begin(), aLast = sel.end();
{
SUIT_DataOwner* owner = ( SUIT_DataOwner* )( (*anIt ).get() );
SalomeApp_DataOwner* sowner = dynamic_cast<SalomeApp_DataOwner*>( owner );
- if( sowner ) {
- myEntries.append( sowner->entry() );
+ if( sowner )
+ {
+ _PTR(SObject) obj = studyds->FindObjectID( sowner->entry() );
+ if( obj->ReferencedObject( refobj ) )
+ {
+ myEntries.append( refobj->GetID() );
+ myIsReferences.append( true );
+ }
+ else
+ {
+ myEntries.append( sowner->entry() );
+ myIsReferences.append( false );
+ }
processOwner( sowner );
}
}
if( !mod_name.isEmpty() )
return mod_name;
}
+ else if( p=="isReference" )
+ return QtxValue( isReference( ind ), false );
return QtxValue();
}
return QString();
}
+/*!
+ Returns true if i-th selected object was reference to object with entry( i )
+*/
+bool SalomeApp_Selection::isReference( const int index ) const
+{
+ if( index >= 0 && index < count() )
+ return myIsReferences[ index ];
+ else
+ return false;
+}
+
/*!
Gets type of active view manager.
*/
protected:
QString entry( const int ) const;
+ bool isReference( const int ) const;
/*!Gets study.*/
SalomeApp_Study* study() const { return myStudy; }
QString activeViewType() const;
private:
QString myPopupClient;
QStringList myEntries; // entries of selected objects
+ QValueList<bool> myIsReferences; // whether i-th selected object was a reference
SalomeApp_Study* myStudy;
};
/*!
Get all selected objects from selection manager
*/
-void SalomeApp_SelectionMgr::selectedObjects( SALOME_ListIO& theList, const QString& theType ) const
+void SalomeApp_SelectionMgr::selectedObjects( SALOME_ListIO& theList, const QString& theType,
+ const bool convertReferences ) const
{
theList.Clear();
selected( aList, theType );
QMap<QString,int> entryMap;
+ SalomeApp_Study* st = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
+ if( !st )
+ return;
+
+ _PTR(Study) dstudy = st->studyDS();
+ QString entry;
+ _PTR(SObject) refobj;
for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
{
const SalomeApp_DataOwner* owner = dynamic_cast<const SalomeApp_DataOwner*>( (*itr).operator->() );
- if( !owner ) continue;
-
- if ( !entryMap.contains(owner->entry()) )
- theList.Append( owner->IO() );
- entryMap.insert(owner->entry(), 1);
+ if( !owner )
+ continue;
+
+ _PTR(SObject) obj = dstudy->FindObjectID( owner->entry() );
+ if( convertReferences && obj->ReferencedObject( refobj ) )
+ {
+ entry = refobj->GetID();
+ if( !entryMap.contains( entry ) )
+ theList.Append( new SALOME_InteractiveObject( refobj->GetID().c_str(),
+ refobj->GetFatherComponent()->ComponentDataType().c_str(),
+ refobj->Name().c_str() ) );
+ }
+ else
+ {
+ entry = owner->entry();
+ if( !entryMap.contains( entry ) )
+ theList.Append( owner->IO() );
+ }
+
+ entryMap.insert( entry , 1);
}
}
SalomeApp_Application* application() const;
- void selectedObjects( SALOME_ListIO&, const QString& = QString::null ) const;
+ void selectedObjects( SALOME_ListIO&, const QString& = QString::null, const bool = true ) const;
void setSelectedObjects( const SALOME_ListIO&, const bool = false );
void GetIndexes( const Handle(SALOME_InteractiveObject)& IObject,
#include "SalomeApp_ShowHideOp.h"
#include "SalomeApp_Application.h"
#include "SalomeApp_SelectionMgr.h"
-#include "SalomeApp_DataOwner.h"
#include "SalomeApp_Selection.h"
#include "SalomeApp_Module.h"
#include "SalomeApp_Displayer.h"
#include "CAM_Study.h"
+#include <SALOME_ListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
SalomeApp_ShowHideOp::SalomeApp_ShowHideOp( ActionType type )
: SalomeApp_Operation(),
if( myActionType==DISPLAY_ONLY )
d->EraseAll( false, false, 0 );
- SUIT_DataOwnerPtrList selected;
- mgr->selected( selected );
- SUIT_DataOwnerPtrList::const_iterator anIt = selected.begin(), aLast = selected.end();
- for( ; anIt!=aLast; anIt++ )
+ SALOME_ListIO selObjs;
+ mgr->selectedObjects( selObjs );
+ SALOME_ListIteratorOfListIO anIt( selObjs );
+ for( ; anIt.More(); anIt.Next() )
{
- SalomeApp_DataOwner* owner = dynamic_cast<SalomeApp_DataOwner*>( (*anIt).operator->() );
- if( !owner )
+ if( anIt.Value().IsNull() )
continue;
if( myActionType==DISPLAY || myActionType==DISPLAY_ONLY )
- d->Display( owner->entry(), false, 0 );
+ d->Display( anIt.Value()->getEntry(), false, 0 );
else if( myActionType==ERASE )
- d->Erase( owner->entry(), false, false, 0 );
+ d->Erase( anIt.Value()->getEntry(), false, false, 0 );
}
d->UpdateViewer();
commit();