+
+//=======================================================================
+// name : SetFlag
+// Purpose : Set/Unset specified flaf from "AttributeFlags" attribute
+//=======================================================================
+bool SALOMEDS_Tool::SetFlag( const int theFlag,
+ SALOMEDS::Study_var theStudy,
+ const std::string& theEntry,
+ const bool theValue )
+{
+ SALOMEDS::SObject_var anObj = theStudy->FindObjectID(theEntry.c_str());
+
+ if ( !anObj->_is_nil() )
+ {
+ SALOMEDS::GenericAttribute_var aGAttr;
+ if ( anObj->FindAttribute( aGAttr, "AttributeFlags" ) )
+ {
+ SALOMEDS::AttributeFlags_var anAttr = SALOMEDS::AttributeFlags::_narrow( aGAttr );
+ anAttr->Set( theFlag, theValue );
+ }
+ else if ( theValue )
+ {
+ SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder();
+ SALOMEDS::AttributeFlags_var anAttr = SALOMEDS::AttributeFlags::_narrow(
+ aBuilder->FindOrCreateAttribute( anObj, "AttributeFlags" ) );
+ anAttr->Set( theFlag, theValue );
+ }
+ return true;
+ }
+
+ return false;
+}
+
+//=======================================================================
+// name : getAllChildren
+// Purpose : Get all children of object.
+// If theObj is null all objects of study are returned
+//=======================================================================
+void SALOMEDS_Tool::GetAllChildren( SALOMEDS::Study_var theStudy,
+ SALOMEDS::SObject_var theObj,
+ std::list<SALOMEDS::SObject_var>& theList )
+{
+ if ( theObj->_is_nil() )
+ {
+ SALOMEDS::SComponentIterator_var anIter = theStudy->NewComponentIterator();
+ for ( ; anIter->More(); anIter->Next() )
+ {
+ SALOMEDS::SObject_var anObj = SALOMEDS::SObject::_narrow( anIter->Value() );
+ if ( !anObj->_is_nil() )
+ {
+ theList.push_back( anObj );
+ GetAllChildren( theStudy, anObj, theList );
+ }
+ }
+ }
+ else
+ {
+ SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator( theObj );
+ for ( ; anIter->More(); anIter->Next() )
+ {
+ SALOMEDS::SObject_var anObj = anIter->Value();
+ SALOMEDS::SObject_var aRef;
+ if ( !anObj->ReferencedObject( aRef ) )
+ {
+ theList.push_back( anObj );
+ GetAllChildren( theStudy, anObj, theList );
+ }
+ }
+ }
+}
+
+
+