-//=======================================================================
-// name : GetFlag
-// Purpose : Retrieve specified flaf from "AttributeFlags" attribute
-//=======================================================================
-bool SALOMEDS_Tool::GetFlag( const int theFlag,
- _PTR(Study) theStudy,
- _PTR(SObject) theObj )
-{
- _PTR(GenericAttribute) anAttr;
- if ( theObj && theObj->FindAttribute( anAttr, "AttributeFlags" ) )
- {
- _PTR(AttributeFlags) aFlags( anAttr );
- bool ret = aFlags->Get( theFlag );
- return ret;
- }
-
- return false;
-}
-
-//=======================================================================
-// name : SetFlag
-// Purpose : Set/Unset specified flaf from "AttributeFlags" attribute
-//=======================================================================
-bool SALOMEDS_Tool::SetFlag( const int theFlag,
- _PTR(Study) theStudy,
- const std::string& theEntry,
- const bool theValue )
-{
- _PTR(SObject) anObj (theStudy->FindObjectID(theEntry.c_str()));
-
- if ( anObj )
- {
- _PTR(GenericAttribute) aGAttr;
- if ( anObj->FindAttribute( aGAttr, "AttributeFlags" ) )
- {
- _PTR(AttributeFlags) anAttr ( aGAttr );
- anAttr->Set( theFlag, theValue );
- }
- else if ( theValue )
- {
- _PTR(StudyBuilder) aBuilder ( theStudy->NewBuilder() );
- _PTR(AttributeFlags) anAttr = aBuilder->FindOrCreateAttribute( anObj, "AttributeFlags" );
- anAttr->Set( theFlag, theValue );
- }
- return true;
- }
-
- return false;
-}
-
-//=======================================================================
-// name : getAllChildren
-// Purpose : Get all entries of children of object.
-// If theObj is null all entries of objects of study are returned
-//=======================================================================
-void SALOMEDS_Tool::GetAllChildren( _PTR(Study) theStudy,
- _PTR(SObject) theObj,
- std::list<std::string>& theList )
-{
- if ( !theObj )
- {
- _PTR(SComponentIterator) anIter (theStudy->NewComponentIterator());
- for ( ; anIter->More(); anIter->Next() )
- {
- _PTR(SObject) anObj ( anIter->Value() );
- if ( anObj )
- {
- theList.push_back( anObj->GetID() );
- GetAllChildren( theStudy, anObj, theList );
- }
- }
- }
- else
- {
- _PTR(ChildIterator) anIter ( theStudy->NewChildIterator( theObj ) );
- for ( ; anIter->More(); anIter->Next() )
- {
- _PTR(SObject) anObj ( anIter->Value() );
- _PTR(SObject) aRef;
- if ( !anObj->ReferencedObject( aRef ) )
- {
- theList.push_back( anObj->GetID() );
- GetAllChildren( theStudy, anObj, theList );
- }
- }
- }
-}
-
-
-
-
-
-
-
-
SALOMEDS::SObject_var theObj,
std::list<SALOMEDS::SObject_var>& theList );
-
- // Retrieves specified flaf from "AttributeFlags" attribute
- static bool GetFlag( const int theFlag,
- _PTR(Study) theStudy,
- _PTR(SObject) theObj );
-
- // Sets/Unsets specified flaf from "AttributeFlags" attribute
- static bool SetFlag( const int theFlag,
- _PTR(Study) theStudy,
- const std::string& theEntry,
- const bool theValue );
-
- // Get all entries of children of object. If theObj is null all entries of objects of study are returned
- static void GetAllChildren( _PTR(Study) theStudy,
- _PTR(SObject) theObj,
- std::list<std::string>& theList );
-
};
#endif