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);
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();
}
}
}
+ //================================================================================
+ /*!
+ * \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
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
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)
// 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))
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;
{
::SMESH_Group* aGroup = GetSmeshGroup();
if (aGroup)
- return CORBA::string_dup (aGroup->GetName());
+ return CORBA::string_dup( aGroup->GetName() );
return CORBA::string_dup( "NO_NAME" );
}
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
}
}
+//================================================================================
+/*!
+ * \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
*/
//================================================================================
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" )
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" )
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;