+//=======================================================================
+//function : UpdateIcons
+//purpose : update icons of a mesh and its children upon mesh modification
+//=======================================================================
+
+void SMESH_Gen_i::UpdateIcons( SMESH::SMESH_Mesh_ptr theMesh )
+{
+ SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( theMesh );
+ if ( ! mesh_i )
+ return;
+
+ SALOMEDS::SObject_wrap so = ObjectToSObject( theMesh );
+ if ( so->_is_nil() )
+ return;
+
+ // set icon of the mesh
+ if ( mesh_i->NbNodes() == 0 )
+ SetPixMap( so, "ICON_SMESH_TREE_MESH_WARN" );
+ else if ( mesh_i->IsComputedOK() )
+ SetPixMap( so, "ICON_SMESH_TREE_MESH" );
+ else if ( mesh_i->HasShapeToMesh() )
+ SetPixMap( so, "ICON_SMESH_TREE_MESH_PARTIAL" );
+ else
+ SetPixMap( so, "ICON_SMESH_TREE_MESH_IMPORTED" );
+
+ // set icons of sub-objects
+ SALOMEDS::Study_var study = getStudyServant();
+ SALOMEDS::ChildIterator_wrap iter = study->NewChildIterator( so );
+ for ( ; iter->More(); iter->Next() )
+ {
+ so = iter->Value(); // 1st level child - root of algos, hyps, sub-meshes or groups
+ if ( so->Tag() < SMESH::Tag_FirstSubMesh )
+ continue;
+
+ SALOMEDS::ChildIterator_wrap subIter = study->NewChildIterator( so );
+ for ( ; subIter->More(); subIter->Next() )
+ {
+ so = subIter->Value(); // 2nd level child - a sub-mesh or group
+
+ CORBA::Object_var obj = SObjectToObject( so );
+ SMESH::SMESH_IDSource_var idSrc = SMESH::SMESH_IDSource::_narrow( obj );
+ if ( idSrc->_is_nil() )
+ continue;
+
+ SMESH::SMESH_GroupBase_var grp = SMESH::SMESH_GroupBase::_narrow( obj );
+ SMESH::SMESH_GroupOnFilter_var gof = SMESH::SMESH_GroupOnFilter::_narrow( obj );
+ const bool isGroup = !grp->_is_nil();
+ const bool isGroupOnFilter = !gof->_is_nil();
+
+ bool isEmpty = ( mesh_i->NbNodes() == 0 );
+ if ( !isEmpty )
+ {
+ if ( isGroupOnFilter ) // GetTypes() can be very long on GroupOnFilter!
+ {
+ SMESH::smIdType_array_var nbByType = mesh_i->GetNbElementsByType();
+ isEmpty = ( nbByType[ grp->GetType() ] == 0 );
+ }
+ else
+ {
+ SMESH::array_of_ElementType_var elemTypes = idSrc->GetTypes();
+ isEmpty = ( elemTypes->length() == 0 );
+
+ if ( !isEmpty )
+ {
+ // check if all sub-shapes of sub-mesh on group are computed
+ // (pb: "Compute sub-mesh" menu is missing if a sub-mesh is partially computed)
+ SMESH::SMESH_subMesh_var subMesh = SMESH::SMESH_subMesh::_narrow( obj );
+ if ( !subMesh->_is_nil() )
+ if ( SMESH_subMesh* sm = mesh_i->GetImpl().GetSubMeshContaining( subMesh->GetId() ))
+ if ( sm->IsComputedPartially() )
+ {
+ SetPixMap( so, "ICON_SMESH_TREE_MESH_PARTIAL" );
+ continue;
+ }
+ }
+ }
+ }
+
+ if ( isEmpty )
+ SetPixMap( so, "ICON_SMESH_TREE_MESH_WARN");
+ else if ( !isGroup )
+ SetPixMap( so, "ICON_SMESH_TREE_MESH" );
+ else if ( isGroupOnFilter )
+ SetPixMap( so, "ICON_SMESH_TREE_GROUP_ON_FILTER" );
+ else
+ SetPixMap( so, "ICON_SMESH_TREE_GROUP" );
+
+ } // loop on sub-meshes or groups
+ } // loop on roots
+}
+
+//=======================================================================
+//function : HighLightInvalid
+//purpose : change font color of a object in the Object Browser
+//=======================================================================
+
+void SMESH_Gen_i::HighLightInvalid( CORBA::Object_ptr theObject, bool isInvalid )
+{
+ SALOMEDS::SObject_wrap so = ObjectToSObject(theObject);
+ highLightInvalid( so.in(), isInvalid );
+}
+
+//=======================================================================
+//function : highLightInvalid
+//purpose : change font color of a object in the Object Browser
+//=======================================================================
+
+void SMESH_Gen_i::highLightInvalid( SALOMEDS::SObject_ptr theSObject, bool isInvalid )
+{
+ if ( !theSObject->_is_nil() )
+ {
+ SALOMEDS::StudyBuilder_var studyBuilder = getStudyServant()->NewBuilder();
+ if ( isInvalid )
+ {
+ SALOMEDS::Color red = { 178,34,34 }; // to differ from reference color
+ SALOMEDS::GenericAttribute_wrap attr =
+ studyBuilder->FindOrCreateAttribute( theSObject, "AttributeTextColor" );
+ SALOMEDS::AttributeTextColor_wrap colorAttr = attr;
+ colorAttr->SetTextColor( red );
+ }
+ else
+ {
+ studyBuilder->RemoveAttribute( theSObject, "AttributeTextColor" );
+ }
+ }
+}
+
+//=======================================================================
+//function : IsInvalid
+//purpose : Check object validity == absence of AttributeTextColor=(178,34,34)
+//=======================================================================
+
+bool SMESH_Gen_i::IsInvalid( SALOMEDS::SObject_ptr theSObject )
+{
+ bool isValid = true;
+ if ( !theSObject->_is_nil() )
+ {
+ SALOMEDS::GenericAttribute_wrap attr;
+ SALOMEDS::StudyBuilder_var studyBuilder = getStudyServant()->NewBuilder();
+ if ( studyBuilder->FindAttribute( theSObject, attr.inout(), "AttributeTextColor" ))
+ {
+ SALOMEDS::AttributeTextColor_wrap colorAttr = attr;
+ SALOMEDS::Color color = colorAttr->TextColor();
+ isValid = ( color.R != 178 || color.G != 34 || color.B != 34 );
+ }
+ }
+ return isValid;
+}
+