-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
else if ( p=="entityMode" ) val = QVariant( entityMode( ind ) );
else if ( p=="isNumFunctor" ) val = QVariant( isNumFunctor( ind ) );
else if ( p=="displayMode" ) val = QVariant( displayMode( ind ) );
+ else if ( p=="hasAlgo" ) val = QVariant( hasAlgo( ind ) );
+ else if ( p=="hasErrors" ) val = QVariant( hasErrors( ind ) );
else if ( p=="isComputable" ) val = QVariant( isComputable( ind ) );
else if ( p=="isPreComputable" ) val = QVariant( isPreComputable( ind ) );
else if ( p=="hasGeomReference" ) val = QVariant( hasGeomReference( ind ) );
else if ( p=="nbChildren") val = QVariant( nbChildren( ind ) );
else if ( p=="isContainer") val = QVariant( isContainer( ind ) );
else if ( p=="guiState") val = QVariant( guiState() );
+ else if ( p=="canBreakLink") val = QVariant( canBreakLink(ind) );
if ( val.isValid() )
return val;
}
//=======================================================================
-//function : isComputable
-//purpose : return true for a ready-to-compute mesh
+//function : hasAlgo
+//purpose : return true for a ready-to-compute [sub-]mesh
//=======================================================================
-bool SMESHGUI_Selection::isComputable( int ind ) const
+bool SMESHGUI_Selection::hasAlgo( int ind ) const
{
if ( ind >= 0 && ind < myTypes.count() && ( myTypes[ind] == "Mesh" ||
myTypes[ind].startsWith("Mesh " )))
{
QMap<int,int> modeMap;
- _PTR(SObject) meshSO = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().data() );
-
- _PTR(SComponent) component = meshSO->GetFatherComponent();
- if ( meshSO->Depth() - component->Depth() > 1 ) // sub-mesh, get a mesh
- while ( meshSO->Depth() - component->Depth() > 1 )
- meshSO = meshSO->GetFather();
+ _PTR(SObject) meshSO = SMESH::getStudy()->FindObjectID( entry( ind ).toStdString() );
SMESHGUI_PrecomputeOp::getAssignedAlgos( meshSO, modeMap );
return modeMap.size() > 0;
return false;
}
+
+//=======================================================================
+//function : hasAlgo
+//purpose : return true if a mesh was computed with errors
+//=======================================================================
+
+bool SMESHGUI_Selection::hasErrors( int ind ) const
+{
+ if ( ind >= 0 && ind < myTypes.count() && ( myTypes[ind] == "Mesh"))
+ {
+ _PTR(SObject) meshSO = SMESH::getStudy()->FindObjectID( entry( ind ).toStdString() );
+ CORBA::Object_var obj = SMESH::SObjectToObject( meshSO );
+ SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
+ if ( !CORBA::is_nil( mesh ) )
+ {
+ SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGUI()->GetSMESHGen();
+ GEOM::GEOM_Object_var geom = mesh->GetShapeToMesh();
+ SMESH::compute_error_array_var compErrors = gen->GetComputeErrors( mesh, geom );
+ return compErrors->length();
+ }
+ }
+ return false;
+}
+
+//=======================================================================
+//function : isComputable
+//purpose : Return true if a [sub-]mesh does not have "computed" icon
+//=======================================================================
+
+bool SMESHGUI_Selection::isComputable( int ind ) const
+{
+ if ( ind >= 0 && ind < myTypes.count() && ( myTypes[ind] == "Mesh" ||
+ myTypes[ind].startsWith("Mesh " )))
+ {
+ _PTR(GenericAttribute) attr;
+ if ( _PTR(SObject) meshSO = SMESH::getStudy()->FindObjectID( entry( ind ).toStdString() ))
+ if ( meshSO->FindAttribute( attr, "AttributePixMap" ))
+ {
+ _PTR(AttributePixMap) pixmap = attr;
+ return ( pixmap->GetPixMap() != "ICON_SMESH_TREE_MESH" );
+ }
+ }
+ return false;
+}
+
//=======================================================================
//function : isPreComputable
//purpose : returns true for a mesh with algorithms
return false;
}
+//=======================================================================
+//function : canBreakLink
+//purpose : returns true if selected object is a Shaper object and it can break link
+//=======================================================================
+
+bool SMESHGUI_Selection::canBreakLink( int ind ) const
+{
+ if ( ind >= 0 && isReference(ind) ) {
+ QString aEntry = objectInfo(ind, OI_RefEntry).toString();
+ if (!aEntry.isEmpty()) {
+ _PTR(SObject) aSObject = SMESH::getStudy()->FindObjectID( aEntry.toStdString());
+ if (aSObject) {
+ _PTR(SObject) aFatherObj = aSObject->GetFather();
+ if (aFatherObj) {
+ _PTR(SComponent) aComponent = aFatherObj->GetFatherComponent();
+ if (aComponent && aComponent->ComponentDataType() == "SMESH") {
+ QString aObjEntry = entry(ind);
+ _PTR(SObject) aGeomSObject = SMESH::getStudy()->FindObjectID(aObjEntry.toStdString());
+ GEOM::GEOM_Object_var aObject = SMESH::SObjectToInterface<GEOM::GEOM_Object>(aGeomSObject);
+ if (!aObject->_is_nil())
+ return aObject->IsParametrical();
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
+
//=======================================================================
//function : isEditableHyp
//purpose :