SUIT_DataOwnerPtrList anOwners;
aSelectionMgr->selected( anOwners );
+ QStringList aCollectedNameList; // to avoid duplication
foreach( SUIT_DataOwner* aSUITOwner, anOwners )
{
if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
{
- Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry(), KIND_UNKNOWN );
+ Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() );
if( !anObject.IsNull() )
- aSeq.Append( anObject );
+ {
+ QString aName = anObject->GetName();
+ if( !aCollectedNameList.contains( aName ) )
+ {
+ aSeq.Append( anObject );
+ aCollectedNameList.append( aName );
+ }
+ }
}
}
return aSeq;
}
return aList;
}
+
+void HYDROGUI_Tool::GetObjectReferences( const Handle(HYDROData_Image)& theImage,
+ HYDROData_SequenceOfObjects& theRefObjects,
+ QStringList& theRefNames )
+{
+ if( theImage.IsNull() )
+ return;
+
+ for( int anIndex = 0, aNbRef = theImage->NbReferences(); anIndex < aNbRef; anIndex++ )
+ {
+ Handle(HYDROData_Image) aRefImage = theImage->Reference( anIndex );
+ if( !aRefImage.IsNull() && !aRefImage->IsRemoved() )
+ {
+ QString aName = aRefImage->GetName();
+ if( !theRefNames.contains( aName ) )
+ {
+ theRefObjects.Append( aRefImage );
+ theRefNames.append( aRefImage->GetName() );
+ GetObjectReferences( aRefImage, theRefObjects, theRefNames );
+ }
+ }
+ }
+}
+
+void HYDROGUI_Tool::GetObjectBackReferences( HYDROGUI_Module* theModule,
+ const Handle(HYDROData_Object)& theObj,
+ HYDROData_SequenceOfObjects& theBackRefObjects,
+ QStringList& theBackRefNames )
+{
+ if( theObj.IsNull() )
+ return;
+
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
+ if( aDocument.IsNull() )
+ return;
+
+ QString aName = theObj->GetName();
+
+ HYDROData_Iterator anIterator( aDocument, KIND_IMAGE );
+ for( ; anIterator.More(); anIterator.Next() )
+ {
+ Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anIterator.Current() );
+ if( !anImage.IsNull() )
+ {
+ HYDROData_SequenceOfObjects aRefObjects;
+ QStringList aRefNames;
+ GetObjectReferences( anImage, aRefObjects, aRefNames );
+ if( aRefNames.contains( aName ) )
+ {
+ theBackRefObjects.Append( anImage );
+ theBackRefNames.append( anImage->GetName() );
+ }
+ }
+ }
+}