mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-26 01:10:35 +05:00
#16522 [CEA 7599] Viscous layers hypothesis: extract layers as a group
1) Fix invalid python dump (missing Compute() before GetGroups()) 2) Remove a group if group name changes 3) Remove an actor of a removed group
This commit is contained in:
parent
70eb9c09d0
commit
66ec81f68d
@ -4930,7 +4930,14 @@ bool SMESHGUI::activateModule( SUIT_Study* study )
|
||||
QList<SUIT_ViewWindow*> wndList = aDesk->windows();
|
||||
SUIT_ViewWindow* wnd;
|
||||
foreach ( wnd, wndList )
|
||||
{
|
||||
connectView( wnd );
|
||||
|
||||
// remove actors whose objects are removed in GetSMESHGen()->UpdateStudy()
|
||||
SMESH::UpdateActorsAfterUpdateStudy(wnd);
|
||||
|
||||
wnd->update();
|
||||
}
|
||||
}
|
||||
|
||||
Py_XDECREF(pluginsmanager);
|
||||
|
@ -340,6 +340,8 @@ void SMESHGUI_GenericHypothesisCreator::onDialogFinished( int result )
|
||||
myDlg->close();
|
||||
//delete myDlg; since WA_DeleteOnClose==true
|
||||
myDlg = 0;
|
||||
|
||||
SMESH::UpdateActorsAfterUpdateStudy();// remove actors of removed groups (#16522)
|
||||
if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) {
|
||||
vf->Repaint();
|
||||
}
|
||||
|
@ -232,6 +232,86 @@ namespace SMESH
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Remove/update actors while module activation
|
||||
* \param [in] wnd - window
|
||||
*
|
||||
* At module activation, groups and sub-meshes can be removed on engine side due
|
||||
* to modification of meshed geometry, while their actors can remain.
|
||||
* Here we remove/update SMESH_Actor's of changed objects. State (emptiness) of objects
|
||||
* is defined by their icons in the Object Browser
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void UpdateActorsAfterUpdateStudy( SUIT_ViewWindow* theWindow )
|
||||
{
|
||||
const char* emptyIcon = "ICON_SMESH_TREE_MESH_WARN";
|
||||
_PTR(Study) aStudy = SMESH::getStudy();
|
||||
|
||||
if ( SVTK_ViewWindow* aViewWindow = GetVtkViewWindow( theWindow ))
|
||||
{
|
||||
vtkRenderer *aRenderer = aViewWindow->getRenderer();
|
||||
VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
|
||||
vtkActorCollection *aCollection = aCopy.GetActors();
|
||||
aCollection->InitTraversal();
|
||||
while ( vtkActor *actor = aCollection->GetNextActor() ) {
|
||||
if ( SMESH_Actor *smeshActor = dynamic_cast<SMESH_Actor*>( actor ))
|
||||
{
|
||||
if ( !smeshActor->hasIO() )
|
||||
continue;
|
||||
Handle(SALOME_InteractiveObject) io = smeshActor->getIO();
|
||||
if ( !io->hasEntry() )
|
||||
continue;
|
||||
_PTR(SObject) so = aStudy->FindObjectID( io->getEntry() );
|
||||
if ( !so )
|
||||
continue; // seems impossible
|
||||
|
||||
CORBA::Object_var obj = SMESH::SObjectToObject( so );
|
||||
if ( CORBA::is_nil( obj )) // removed object
|
||||
{
|
||||
RemoveActor( theWindow, smeshActor );
|
||||
continue;
|
||||
}
|
||||
|
||||
bool toShow = smeshActor->GetVisibility();
|
||||
_PTR(GenericAttribute) attr;
|
||||
if ( toShow && so->FindAttribute( attr, "AttributePixMap" )) // check emptiness
|
||||
{
|
||||
_PTR(AttributePixMap) pixMap = attr;
|
||||
toShow = ( pixMap->GetPixMap() != emptyIcon );
|
||||
}
|
||||
smeshActor->Update();
|
||||
UpdateView( theWindow, toShow ? eDisplay : eErase, io->getEntry() );
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Remove/update actors while module activation
|
||||
*
|
||||
* At module activation, groups and sub-meshes can be removed on engine side due
|
||||
* to modification of meshed geometry, while their actors can remain.
|
||||
* Here we remove/update SMESH_Actor's of changed objects. State (emptiness) of objects
|
||||
* is defined by their icons in the Object Browser
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void UpdateActorsAfterUpdateStudy()
|
||||
{
|
||||
SUIT_Study* study = SMESH::GetActiveStudy();
|
||||
if ( SUIT_Desktop* desk = study->application()->desktop() )
|
||||
{
|
||||
QList<SUIT_ViewWindow*> wndList = desk->windows();
|
||||
SUIT_ViewWindow* wnd;
|
||||
foreach ( wnd, wndList )
|
||||
SMESH::UpdateActorsAfterUpdateStudy(wnd);
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Notify the user on problems during visualization
|
||||
|
@ -216,6 +216,12 @@ SMESHGUI_EXPORT
|
||||
double& theDist );
|
||||
SMESHGUI_EXPORT
|
||||
void RemoveVisualObjectWithActors( const char* theEntry, bool fromAllViews = false );
|
||||
|
||||
SMESHGUI_EXPORT
|
||||
void UpdateActorsAfterUpdateStudy( SUIT_ViewWindow* wnd );
|
||||
|
||||
SMESHGUI_EXPORT
|
||||
void UpdateActorsAfterUpdateStudy();
|
||||
};
|
||||
|
||||
#endif // SMESHGUI_VTKUTILS_H
|
||||
|
@ -1827,7 +1827,7 @@ _pyMesh::_pyMesh(const Handle(_pyCommand) theCreationCmd, const _pyID& meshId):
|
||||
|
||||
void _pyMesh::Process( const Handle(_pyCommand)& theCommand )
|
||||
{
|
||||
// some methods of SMESH_Mesh interface needs special conversion
|
||||
// some methods of SMESH_Mesh interface need special conversion
|
||||
// to methods of Mesh python class
|
||||
//
|
||||
// 1. GetSubMesh(geom, name) + AddHypothesis(geom, algo)
|
||||
@ -1980,7 +1980,7 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand )
|
||||
// if GetGroups() is just after Compute(), this can mean that the groups
|
||||
// were created by some algorithm and hence Compute() should not be discarded
|
||||
std::list< Handle(_pyCommand) >& cmdList = theGen->GetCommands();
|
||||
std::list< Handle(_pyCommand) >::iterator cmd = cmdList.begin();
|
||||
std::list< Handle(_pyCommand) >::reverse_iterator cmd = cmdList.rbegin();
|
||||
while ( (*cmd)->GetMethod() == "GetGroups" )
|
||||
++cmd;
|
||||
if ( myLastComputeCmd == (*cmd))
|
||||
@ -3158,8 +3158,7 @@ void _pyHypothesis::ComputeDiscarded( const Handle(_pyCommand)& theComputeCmd )
|
||||
continue;
|
||||
// check if a cmd is a sole command setting its parameter;
|
||||
// don't use method name for search as it can change
|
||||
map<TCollection_AsciiString, list<Handle(_pyCommand)> >::iterator
|
||||
m2cmds = myMeth2Commands.begin();
|
||||
map<_AString, list<Handle(_pyCommand)> >::iterator m2cmds = myMeth2Commands.begin();
|
||||
for ( ; m2cmds != myMeth2Commands.end(); ++m2cmds )
|
||||
{
|
||||
list< Handle(_pyCommand)>& cmds = m2cmds->second;
|
||||
|
@ -171,7 +171,7 @@ char* SMESH_GroupBase_i::GetName()
|
||||
{
|
||||
::SMESH_Group* aGroup = GetSmeshGroup();
|
||||
if (aGroup)
|
||||
return CORBA::string_dup (aGroup->GetName());
|
||||
return CORBA::string_dup( aGroup->GetName() );
|
||||
return CORBA::string_dup( "NO_NAME" );
|
||||
}
|
||||
|
||||
|
@ -378,10 +378,51 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Remove a group, whose name is stored by hypothesis, upon group name modification
|
||||
* \param [in] oldName - old group name
|
||||
* \param [in] newName - new group name
|
||||
* \param [in] type - group type
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void StdMeshersGUI_StdHypothesisCreator::
|
||||
removeOldGroup(const char* oldName, const char* newName, SMESH::ElementType type) const
|
||||
{
|
||||
if ( !oldName || !oldName[0] )
|
||||
return; // old name undefined
|
||||
if ( newName && strcmp( oldName, newName ) == 0 )
|
||||
return; // same name
|
||||
|
||||
SMESH::SMESH_Hypothesis_var h = hypothesis();
|
||||
SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( h );
|
||||
for ( size_t i = 0; i < listSOmesh.size(); i++ )
|
||||
{
|
||||
_PTR(SObject) submSO = listSOmesh[i];
|
||||
SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( submSO );
|
||||
SMESH::SMESH_subMesh_var subMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( submSO );
|
||||
if( !subMesh->_is_nil() )
|
||||
mesh = subMesh->GetFather();
|
||||
if ( mesh->_is_nil() )
|
||||
continue;
|
||||
SMESH::ListOfGroups_var groups = mesh->GetGroups();
|
||||
for ( CORBA::ULong iG = 0; iG < groups->length(); iG++ )
|
||||
{
|
||||
if ( groups[iG]->GetType() != type )
|
||||
continue;
|
||||
CORBA::String_var name = groups[iG]->GetName();
|
||||
if ( strcmp( name.in(), oldName ))
|
||||
continue;
|
||||
mesh->RemoveGroup( groups[iG] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Check parameter values before accept()
|
||||
* \retval bool - true if OK
|
||||
* \retval bool - true if OK
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
@ -733,7 +774,10 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
|
||||
if ( StdMeshersGUI_NameCheckableGrpWdg* nameWg =
|
||||
widget< StdMeshersGUI_NameCheckableGrpWdg >( 6 ))
|
||||
{
|
||||
CORBA::String_var oldName = h->GetGroupName();
|
||||
h->SetGroupName( nameWg->getName().toUtf8().data() );
|
||||
CORBA::String_var newName = h->GetGroupName();
|
||||
removeOldGroup( oldName, newName, SMESH::VOLUME );
|
||||
}
|
||||
}
|
||||
else if( hypType()=="ViscousLayers2D" )
|
||||
@ -757,7 +801,10 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
|
||||
if ( StdMeshersGUI_NameCheckableGrpWdg* nameWg =
|
||||
widget< StdMeshersGUI_NameCheckableGrpWdg >( 5 ))
|
||||
{
|
||||
CORBA::String_var oldName = h->GetGroupName();
|
||||
h->SetGroupName( nameWg->getName().toUtf8().data() );
|
||||
CORBA::String_var newName = h->GetGroupName();
|
||||
removeOldGroup( oldName, newName, SMESH::FACE );
|
||||
}
|
||||
}
|
||||
// else if( hypType()=="QuadrangleParams" )
|
||||
|
@ -66,6 +66,9 @@ protected:
|
||||
bool initVariableName(SMESH::SMESH_Hypothesis_var theHyp, StdParam& theParams, const char* theMethod) const;
|
||||
QWidget* makeReverseEdgesWdg( SMESH::long_array_var edgeIDs,
|
||||
CORBA::String_var shapeEntry) const;
|
||||
void removeOldGroup(const char* oldName,
|
||||
const char* newName,
|
||||
SMESH::ElementType type) const;
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user