(cherry picked from commit d2681a122cd708f8ddb5c75005b6b2aa30c5f844)

This commit is contained in:
eap 2020-01-10 14:33:42 +03:00 committed by NATHALIE GORE
parent 517ed49d01
commit 4757f34bf5
6 changed files with 77 additions and 32 deletions

View File

@ -1191,11 +1191,11 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h
if ( !GetMeshDS()->IsUsedHypothesis( hyp )) if ( !GetMeshDS()->IsUsedHypothesis( hyp ))
return; return;
bool toCallBack = true; int nbEntities = ( _myMeshDS->NbNodes() + _myMeshDS->NbElements() );
if ( _callUp && hyp && NbNodes() == 0 ) // for not loaded mesh (#16648) if ( hyp && _callUp && !_callUp->IsLoaded() ) // for not loaded mesh (#16648)
{ {
_callUp->HypothesisModified( hyp->GetID() ); _callUp->HypothesisModified( hyp->GetID(), /*updateIcons=*/true );
toCallBack = ( NbNodes() > 0 ); nbEntities = ( _myMeshDS->NbNodes() + _myMeshDS->NbElements() ); // after loading mesh
} }
SMESH_Algo *algo; SMESH_Algo *algo;
@ -1265,8 +1265,9 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h
HasModificationsToDiscard(); // to reset _isModified flag if mesh becomes empty HasModificationsToDiscard(); // to reset _isModified flag if mesh becomes empty
GetMeshDS()->Modified(); GetMeshDS()->Modified();
if ( _callUp && hyp && toCallBack ) int newNbEntities = ( _myMeshDS->NbNodes() + _myMeshDS->NbElements() );
_callUp->HypothesisModified( hyp->GetID() ); if ( hyp && _callUp )
_callUp->HypothesisModified( hyp->GetID(), newNbEntities != nbEntities );
} }
//============================================================================= //=============================================================================

View File

@ -334,9 +334,10 @@ class SMESH_EXPORT SMESH_Mesh
struct TCallUp // callback from SMESH to SMESH_I level struct TCallUp // callback from SMESH to SMESH_I level
{ {
virtual void RemoveGroup (const int theGroupID)=0; virtual void RemoveGroup( const int theGroupID )=0;
virtual void HypothesisModified (int theHypID)=0; virtual void HypothesisModified( int hypID, bool updateIcons )=0;
virtual void Load ()=0; virtual void Load()=0;
virtual bool IsLoaded()=0;
virtual ~TCallUp() {} virtual ~TCallUp() {}
}; };
void SetCallUp( TCallUp * upCaller ); void SetCallUp( TCallUp * upCaller );

View File

@ -523,6 +523,7 @@ public:
const char* theName = 0); const char* theName = 0);
void UpdateIcons(SMESH::SMESH_Mesh_ptr theMesh); void UpdateIcons(SMESH::SMESH_Mesh_ptr theMesh);
void HighLightInvalid(CORBA::Object_ptr theObject, bool isInvalid); void HighLightInvalid(CORBA::Object_ptr theObject, bool isInvalid);
bool IsInvalid(SALOMEDS::SObject_ptr theObject);
bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr theMesh, bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShapeObject, GEOM::GEOM_Object_ptr theShapeObject,
SMESH::SMESH_Hypothesis_ptr theHyp); SMESH::SMESH_Hypothesis_ptr theHyp);

View File

@ -1030,6 +1030,28 @@ void SMESH_Gen_i::highLightInvalid( SALOMEDS::SObject_ptr theSObject, bool isInv
} }
} }
//=======================================================================
//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;
}
//======================================================================= //=======================================================================
//function : GetMeshOrSubmeshByShape //function : GetMeshOrSubmeshByShape
//purpose : //purpose :

View File

@ -113,6 +113,7 @@ SMESH_Mesh_i::SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
_impl = NULL; _impl = NULL;
_gen_i = gen_i; _gen_i = gen_i;
_id = _idGenerator++; _id = _idGenerator++;
_nbInvalidHypos= -1;
_editor = NULL; _editor = NULL;
_previewEditor = NULL; _previewEditor = NULL;
_preMeshInfo = NULL; _preMeshInfo = NULL;
@ -647,6 +648,8 @@ SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubShape,
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->ForgetOrLoad(); _preMeshInfo->ForgetOrLoad();
const int prevNbMeshEnt = _impl->NbNodes() + _impl->GetMeshDS()->NbElements();
std::string error; std::string error;
SMESH_Hypothesis::Hypothesis_Status status = addHypothesis( aSubShape, anHyp, &error ); SMESH_Hypothesis::Hypothesis_Status status = addHypothesis( aSubShape, anHyp, &error );
anErrorText = error.c_str(); anErrorText = error.c_str();
@ -655,7 +658,10 @@ SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubShape,
if ( !SMESH_Hypothesis::IsStatusFatal(status) ) if ( !SMESH_Hypothesis::IsStatusFatal(status) )
{ {
_gen_i->AddHypothesisToShape( mesh, aSubShape, anHyp ); _gen_i->AddHypothesisToShape( mesh, aSubShape, anHyp );
_gen_i->UpdateIcons( mesh );
int newNbMeshEnt = _impl->NbNodes() + _impl->GetMeshDS()->NbElements();
if ( newNbMeshEnt != prevNbMeshEnt )
_gen_i->UpdateIcons( mesh );
} }
if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status ); if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status );
@ -3072,40 +3078,55 @@ namespace
SMESH_Mesh_i* _mesh; SMESH_Mesh_i* _mesh;
TCallUp_i(SMESH_Mesh_i* mesh):_mesh(mesh) {} TCallUp_i(SMESH_Mesh_i* mesh):_mesh(mesh) {}
virtual void RemoveGroup (const int theGroupID) { _mesh->removeGroup( theGroupID ); } virtual void RemoveGroup (const int theGroupID) { _mesh->removeGroup( theGroupID ); }
virtual void HypothesisModified (int theHypID) { _mesh->onHypothesisModified( theHypID ); } virtual void HypothesisModified( int hypID,
bool updIcons) { _mesh->onHypothesisModified( hypID,
updIcons ); }
virtual void Load () { _mesh->Load(); } virtual void Load () { _mesh->Load(); }
virtual bool IsLoaded() { return _mesh->IsLoaded(); }
}; };
} }
//================================================================================ //================================================================================
/*! /*!
* \brief callback from _impl to forget not loaded mesh data (issue 0021208) * \brief callback from _impl to
* 1) forget not loaded mesh data (issue 0021208)
* 2) mark hypothesis as valid
*/ */
//================================================================================ //================================================================================
void SMESH_Mesh_i::onHypothesisModified(int theHypID) void SMESH_Mesh_i::onHypothesisModified(int theHypID, bool theUpdateIcons)
{ {
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->ForgetOrLoad(); _preMeshInfo->ForgetOrLoad();
SMESH::SMESH_Mesh_var mesh = _this(); if ( theUpdateIcons )
_gen_i->UpdateIcons( mesh );
// mark a hypothesis as valid after edition
SALOMEDS::SComponent_wrap smeshComp = _gen_i->PublishComponent();
SALOMEDS::SObject_wrap hypRoot;
if ( !smeshComp->_is_nil() &&
smeshComp->FindSubObject( _gen_i->GetHypothesisRootTag(), hypRoot.inout() ))
{ {
SALOMEDS::ChildIterator_wrap anIter = _gen_i->getStudyServant()->NewChildIterator( hypRoot ); SMESH::SMESH_Mesh_var mesh = _this();
for ( ; anIter->More(); anIter->Next() ) _gen_i->UpdateIcons( mesh );
}
if ( _nbInvalidHypos != 0 )
{
// mark a hypothesis as valid after edition
int nbInvalid = 0;
SALOMEDS::SComponent_wrap smeshComp = _gen_i->PublishComponent();
SALOMEDS::SObject_wrap hypRoot;
if ( !smeshComp->_is_nil() &&
smeshComp->FindSubObject( _gen_i->GetHypothesisRootTag(), hypRoot.inout() ))
{ {
SALOMEDS::SObject_wrap hypSO = anIter->Value(); SALOMEDS::ChildIterator_wrap anIter = _gen_i->getStudyServant()->NewChildIterator( hypRoot );
CORBA::Object_var obj = _gen_i->SObjectToObject( hypSO ); for ( ; anIter->More(); anIter->Next() )
SMESH::SMESH_Hypothesis_var hyp = SMESH::SMESH_Hypothesis::_narrow( obj ); {
if ( !hyp->_is_nil() && hyp->GetId() == theHypID ) SALOMEDS::SObject_wrap hypSO = anIter->Value();
_gen_i->HighLightInvalid( hyp, false ); CORBA::Object_var obj = _gen_i->SObjectToObject( hypSO );
SMESH::SMESH_Hypothesis_var hyp = SMESH::SMESH_Hypothesis::_narrow( obj );
if ( !hyp->_is_nil() && hyp->GetId() == theHypID )
_gen_i->HighLightInvalid( hyp, false );
else
nbInvalid += _gen_i->IsInvalid( hypSO );
}
} }
_nbInvalidHypos = nbInvalid;
} }
} }

View File

@ -452,11 +452,9 @@ public:
const std::map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; } const std::map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; }
// return existing group objects // return existing group objects
void onHypothesisModified(int theHypID); void onHypothesisModified(int theHypID, bool updateIcons);
// callback from _impl to forget not loaded mesh data (issue 0021208) // callback from _impl to forget not loaded mesh data (issue 0021208)
void checkMeshLoaded();
/*! /*!
* \brief Update data if geometry changes * \brief Update data if geometry changes
* *
@ -724,12 +722,13 @@ private:
*/ */
TListOfListOfInt findConcurrentSubMeshes(); TListOfListOfInt findConcurrentSubMeshes();
private: private:
static int _idGenerator; static int _idGenerator;
::SMESH_Mesh* _impl; // :: force no namespace here ::SMESH_Mesh* _impl; // :: force no namespace here
SMESH_Gen_i* _gen_i; SMESH_Gen_i* _gen_i;
int _id; // id given by creator (unique within the creator instance) int _id; // id given by creator (unique within the creator instance)
int _nbInvalidHypos;
std::map<int, SMESH::SMESH_subMesh_ptr> _mapSubMeshIor; std::map<int, SMESH::SMESH_subMesh_ptr> _mapSubMeshIor;
std::map<int, SMESH::SMESH_GroupBase_ptr> _mapGroups; std::map<int, SMESH::SMESH_GroupBase_ptr> _mapGroups;
std::map<int, SMESH::SMESH_Hypothesis_ptr> _mapHypo; std::map<int, SMESH::SMESH_Hypothesis_ptr> _mapHypo;