X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_Selection.cxx;h=77d5abaa23cb68de88c92fac787fb0100e664a88;hp=fbc43c922d46b397ad32b2e0236898043b67c281;hb=e85e13ee2a8e2484050471ff8e4dea298abe481a;hpb=e330934ca6f8bb1f67b5367bb65a861868998aeb diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index fbc43c922..77d5abaa2 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -1,4 +1,4 @@ -// 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 @@ -125,6 +125,8 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const 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 ) ); @@ -140,6 +142,7 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const 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; @@ -543,22 +546,17 @@ int SMESHGUI_Selection::dim( int ind ) const } //======================================================================= -//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 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; @@ -566,6 +564,51 @@ bool SMESHGUI_Selection::isComputable( int ind ) const 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 @@ -605,6 +648,35 @@ bool SMESHGUI_Selection::hasGeomReference( int ind ) const 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(aGeomSObject); + if (!aObject->_is_nil()) + return aObject->IsParametrical(); + } + } + } + } + } + return false; +} + //======================================================================= //function : isEditableHyp //purpose :