Salome HOME
Merge branch 'occ/shaper2smesh'
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.cxx
index b4a75cb4dd97d6b84bf532bf65ed155e95736149..ba08d51011a880d5e2c693412a918a8823586cb7 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2019  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
 #include <SUIT_OverrideCursor.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_Session.h>
+#include <SVTK_Renderer.h>
 #include <SVTK_ViewManager.h>
 #include <SVTK_ViewModel.h>
 #include <SVTK_ViewWindow.h>
 #include <SALOMEDS_Study.hxx>
 #include <SALOMEDS_SObject.hxx>
 #include "utilities.h"
+#include <SALOME_LifeCycleCORBA.hxx>
 
 // OCCT includes
 #include <Standard_ErrorHandler.hxx>
@@ -1381,6 +1383,108 @@ namespace
     }
   }
 
+  // Break link with Shaper model
+  void breakShaperLink()
+  {
+    LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
+    SALOME_ListIO selected;
+    if (aSel) {
+      aSel->selectedObjects(selected);
+      if (selected.Extent()) {
+        Handle(SALOME_InteractiveObject) anIObject = selected.First();
+        _PTR(Study) aStudy = SMESH::getStudy();
+        std::string aEntry = anIObject->getEntry();
+        _PTR(SObject) aSObj = aStudy->FindObjectID(aEntry);
+        if (aSObj) {
+          std::string aName = aSObj->GetName();
+          QMessageBox::StandardButton aRes = SUIT_MessageBox::warning(SMESHGUI::desktop(),
+            QObject::tr("SMESH_WRN_WARNING"),
+            QObject::tr("MSG_BREAK_SHAPER_LINK").arg(aName.c_str()),
+            SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No);
+          if (aRes == SUIT_MessageBox::Yes) {
+            SUIT_DataOwnerPtrList aList;
+            aSel->selected(aList, "ObjectBrowser", true);
+            SUIT_DataOwner* aOwn = aList.first();
+            LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>(aOwn);
+            QString aREntry = sowner->entry();
+
+            static GEOM::GEOM_Gen_var geomGen;
+            if (CORBA::is_nil(geomGen)) {
+              SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
+                (SUIT_Session::session()->activeApplication());
+              if (app) {
+                SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
+                Engines::EngineComponent_var comp =
+                  ls->FindOrLoad_Component("FactoryServer", "SHAPERSTUDY");
+                geomGen = GEOM::GEOM_Gen::_narrow(comp);
+              }
+            }
+            if (!CORBA::is_nil(geomGen))
+            {
+              geomGen->BreakLink(aREntry.toStdString().c_str());
+              SMESHGUI::GetSMESHGUI()->updateObjBrowser();
+
+              // remove actors whose objects are removed by BreakLink()
+              QList<SUIT_ViewWindow*> wndList = SMESHGUI::desktop()->windows();
+              SUIT_ViewWindow* wnd;
+              foreach(wnd, wndList)
+                SMESH::UpdateActorsAfterUpdateStudy(wnd);
+            }
+          }
+        }
+      }
+    }
+  }
+
+  //================================================================================
+  /*!
+   * \brief Return true if a mesh icon == ICON_SMESH_TREE_GEOM_MODIF
+   * which means that the mesh can't be modified. It should be either re-computed
+   * or breakShaperLink()'ed. Warn the user about it.
+   */
+  //================================================================================
+
+  bool warnOnGeomModif()
+  {
+    SALOME_ListIO selected;
+    if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
+      aSel->selectedObjects(selected,"",/*convertReferences=*/false);
+
+    SALOME_ListIteratorOfListIO It( selected );
+    for ( ; It.More(); It.Next() )
+    {
+      Handle(SALOME_InteractiveObject) io = It.Value();
+      if ( !io->hasEntry() ) continue;
+      _PTR(SObject) so = SMESH::getStudy()->FindObjectID( io->getEntry() );
+      SMESH::SMESH_Mesh_var mesh;
+      while ( mesh->_is_nil() && so )
+      {
+        CORBA::Object_var obj = SMESH::SObjectToObject( so );
+        SMESH::SMESH_IDSource_var isrc = SMESH::SMESH_IDSource::_narrow( obj );
+        if ( isrc->_is_nil() )
+          so = so->GetFather();
+        else
+          mesh = isrc->GetMesh();
+      }
+      if ( mesh->_is_nil() ) continue;
+      so = SMESH::FindSObject( mesh );
+      if ( !so ) continue;
+      _PTR(GenericAttribute) attr;
+      so->FindAttribute( attr, "AttributePixMap" );
+      _PTR(AttributePixMap) pixmap = attr;
+      if ( !pixmap ) continue;
+
+      if ( pixmap->GetPixMap() == "ICON_SMESH_TREE_GEOM_MODIF" )
+      {
+        SUIT_MessageBox::warning(SMESHGUI::desktop(),
+                                 QObject::tr("SMESH_WRN_WARNING"),
+                                 QObject::tr("MSG_WARN_ON_GEOM_MODIF"));
+        return true;
+      }
+    }
+    return false;
+  }
+
   void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap)
   {
     SALOME_ListIO selected;
@@ -1749,7 +1853,7 @@ namespace
                 int anEntitiesCount = anActor->GetNumberControlEntities();
                 if (anEntitiesCount >= 0)
                   functorName = functorName + ": " + QString::number(anEntitiesCount);
-                anActor->GetScalarBarActor()->SetTitle( functorName.toLatin1().constData() );
+                anActor->GetScalarBarActor()->SetTitle( functorName.toUtf8().constData() );
                 SMESH::RepaintCurrentView();
 #ifndef DISABLE_PLOT2DVIEWER
                 if ( anActor->GetPlot2Histogram() ) {
@@ -1919,8 +2023,8 @@ void SMESHGUI::OnEditDelete()
 
   SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
 
-  // Put the whole hierarchy of sub-objects of the selected SO's into a list and
-  // then treat them all starting from the deepest objects (at list back)
+  // Put one level of sub-objects of the selected SO's into a list
+  // in order to get objects inside folders like "Assigned Algorithms"
   std::list< _PTR(SObject) > listSO;
   SALOME_ListIteratorOfListIO It(selected);
   for( ; It.More(); It.Next()) // loop on selected IO's
@@ -1941,43 +2045,47 @@ void SMESHGUI::OnEditDelete()
         aSO = aRefSObject; // Delete main Object instead of reference
 
       listSO.push_back( aSO );
-      std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
-      for ( ; itSO != listSO.end(); ++itSO ) {
-        _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
-        for (it->InitEx(false); it->More(); it->Next())
-          listSO.push_back( it->Value() );
-      }
+
+      _PTR(ChildIterator) it = aStudy->NewChildIterator( aSO );
+      for (it->InitEx(false); it->More(); it->Next())
+        listSO.push_back( it->Value() );
     }
   }
   // Check if none of objects to delete is referred from outside
   std::list< _PTR(SObject) >::reverse_iterator ritSO;
+  std::vector< _PTR(SObject) > subSO;
   for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
   {
     _PTR(SObject) SO = *ritSO;
     if ( !SO ) continue;
-    std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO  );
-    for (size_t i = 0; i < aReferences.size(); i++) {
-      _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
-      std::string type = aComponent->ComponentDataType();
-      if ( type != "SMESH" )
-      {
-        SUIT_MessageBox::warning( anApp->desktop(),
-                                  QObject::tr("WRN_WARNING"),
-                                  QObject::tr("DEP_OBJECT") );
-        return; // outside SMESH, there is an object depending on a SMESH object
+
+    int nbChildren = SO->GetLastChildTag();
+    subSO.clear();
+    subSO.reserve( 1 + nbChildren );
+    subSO.push_back( SO );
+    if ( nbChildren > 0 )
+    {
+      _PTR(ChildIterator) it = aStudy->NewChildIterator( SO );
+      for ( it->InitEx( true ); it->More(); it->Next() )
+        subSO.push_back( it->Value() );
+    }
+    for ( size_t i = 0; i < subSO.size(); ++i )
+    {
+      std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( subSO[i] );
+      for ( size_t j = 0; j < aReferences.size(); j++ ) {
+        _PTR(SComponent) aComponent = aReferences[j]->GetFatherComponent();
+        std::string type = aComponent->ComponentDataType();
+        if ( type != "SMESH" )
+        {
+          SUIT_MessageBox::warning( anApp->desktop(),
+                                    QObject::tr("WRN_WARNING"),
+                                    QObject::tr("DEP_OBJECT") );
+          return; // outside SMESH, there is an object depending on a SMESH object
+        }
       }
     }
   }
 
-  // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
-  for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
-  {
-    Handle(SALOME_InteractiveObject) IObject = It.Value();
-    SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
-    if ( !mesh->_is_nil() )
-      mesh->Clear();
-  }
-
   // Treat SO's in the list starting from the back
   aStudyBuilder->NewCommand();  // There is a transaction
   for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
@@ -1987,7 +2095,7 @@ void SMESHGUI::OnEditDelete()
     std::string anEntry = SO->GetID();
 
     /** Erase graphical object and remove all its data **/
-    if(SO->FindAttribute(anAttr, "AttributeIOR")) {
+    if ( SO->FindAttribute( anAttr, "AttributeIOR" )) {
       SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
     }
     /** Remove an object from data structures **/
@@ -2540,6 +2648,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
 #ifndef DISABLE_PLOT2DVIEWER
             SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
 #endif
+            anActor->UpdateFilter();
           }
         }
       }
@@ -2726,6 +2835,10 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       else
         aSel->setSelectedObjects( to_process );
 
+      if ( vtkwnd && vtkwnd->GetRenderer() && !isStudyLocked() &&
+           ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) )
+        vtkwnd->GetRenderer()->AdjustActors();
+
       break;
     }
 
@@ -2744,16 +2857,19 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       break;
     }
 
-  case SMESHOp::OpCreateMesh:
-  case SMESHOp::OpCreateSubMesh:
   case SMESHOp::OpEditMeshOrSubMesh:
   case SMESHOp::OpEditMesh:
   case SMESHOp::OpEditSubMesh:
+  case SMESHOp::OpMeshOrder:
+  case SMESHOp::OpCreateSubMesh:
+    if ( warnOnGeomModif() )
+      break; // action forbiden as geometry modified
+
+  case SMESHOp::OpCreateMesh:
   case SMESHOp::OpCompute:
   case SMESHOp::OpComputeSubMesh:
   case SMESHOp::OpPreCompute:
   case SMESHOp::OpEvaluate:
-  case SMESHOp::OpMeshOrder:
     startOperation( theCommandID );
     break;
   case SMESHOp::OpCopyMesh:
@@ -2782,6 +2898,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
 
       if ( isStudyLocked() )
         break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
 
       /*Standard_Boolean aRes;
       SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
@@ -2812,6 +2930,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
 
       if ( isStudyLocked() )
         break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
 
       EmitSignalDeactivateDialog();
       SMESHGUI_MultiEditDlg* aDlg = NULL;
@@ -2830,6 +2950,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpSmoothing:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if( vtkwnd ) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_SmoothingDlg( this ) )->show();
@@ -2842,6 +2964,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpExtrusion:
     {
       if (isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if (vtkwnd) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
@@ -2853,6 +2977,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpExtrusionAlongAPath:
     {
       if (isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if (vtkwnd) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
@@ -2864,6 +2990,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpRevolution:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if( vtkwnd ) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_RevolutionDlg( this ) )->show();
@@ -2877,6 +3005,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
     {
       if ( isStudyLocked() )
         break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if ( vtkwnd )
       {
         EmitSignalDeactivateDialog();
@@ -2893,6 +3023,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpReorientFaces:
   case SMESHOp::OpCreateGeometryGroup:
     {
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       startOperation( theCommandID );
       break;
     }
@@ -2905,6 +3037,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       }
 
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       EmitSignalDeactivateDialog();
       SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
 
@@ -2932,6 +3066,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       }
 
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       EmitSignalDeactivateDialog();
 
       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
@@ -3009,6 +3145,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       }
 
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       EmitSignalDeactivateDialog();
 
       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
@@ -3106,6 +3244,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
 
       if ( isStudyLocked() )
         break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
 
       EmitSignalDeactivateDialog();
 
@@ -3126,6 +3266,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
     {
       if ( isStudyLocked() )
         break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
 
       EmitSignalDeactivateDialog();
       SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
@@ -3138,6 +3280,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
     {
       if ( isStudyLocked() )
         break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
 
       EmitSignalDeactivateDialog();
       SMESHGUI_FaceGroupsSeparatedByEdgesDlg* aDlg = new SMESHGUI_FaceGroupsSeparatedByEdgesDlg( this );
@@ -3197,6 +3341,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpEditHypothesis:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
 
       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
       SALOME_ListIO selected;
@@ -3242,6 +3388,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpUnassign:                      // REMOVE HYPOTHESIS / ALGORITHMS
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       SUIT_OverrideCursor wc;
 
       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
@@ -3273,6 +3421,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpHexagonalPrism:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if ( vtkwnd ) {
         EmitSignalDeactivateDialog();
         SMDSAbs_EntityType type = SMDSEntity_Edge;
@@ -3299,6 +3449,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpPolyhedron:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if ( vtkwnd ) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
@@ -3322,6 +3474,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpTriQuadraticHexahedron:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if ( vtkwnd ) {
         EmitSignalDeactivateDialog();
         SMDSAbs_EntityType type = SMDSEntity_Last;
@@ -3353,6 +3507,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpRemoveNodes:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if ( vtkwnd ) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
@@ -3366,6 +3522,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpRemoveElements:                                    // REMOVES ELEMENTS
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if( vtkwnd ) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
@@ -3380,6 +3538,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpClearMesh: {
 
     if(isStudyLocked()) break;
+    if ( warnOnGeomModif() )
+      break; // action forbiden as geometry modified
 
     SALOME_ListIO selected;
     if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
@@ -3419,6 +3579,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpRemoveOrphanNodes:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       SALOME_ListIO selected;
       if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
         aSel->selectedObjects( selected );
@@ -3458,6 +3620,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpRenumberingNodes:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if( vtkwnd ) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
@@ -3472,6 +3636,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpRenumberingElements:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if ( vtkwnd ) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
@@ -3486,6 +3652,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpTranslation:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if ( vtkwnd ) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_TranslationDlg( this ) )->show();
@@ -3499,6 +3667,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpRotation:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if( vtkwnd ) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_RotationDlg( this ) )->show();
@@ -3512,6 +3682,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpSymmetry:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if(vtkwnd) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_SymmetryDlg( this ) )->show();
@@ -3525,6 +3697,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpScale:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if ( vtkwnd ) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_ScaleDlg( this ) )->show();
@@ -3539,6 +3713,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpOffset:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if ( vtkwnd ) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_OffsetDlg( this ) )->show();
@@ -3553,6 +3729,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpSewing:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if(vtkwnd) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_SewingDlg( this ) )->show();
@@ -3566,6 +3744,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpMergeNodes:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if(vtkwnd) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
@@ -3579,6 +3759,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpMergeElements:
     {
       if (isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if (vtkwnd) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
@@ -3590,12 +3772,16 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
     }
 
   case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
+    if ( warnOnGeomModif() )
+      break; // action forbiden as geometry modified
     startOperation( SMESHOp::OpMoveNode );
     break;
 
   case SMESHOp::OpDuplicateNodes:
     {
       if(isStudyLocked()) break;
+      if ( warnOnGeomModif() )
+        break; // action forbiden as geometry modified
       if ( vtkwnd ) {
         EmitSignalDeactivateDialog();
         ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
@@ -3608,6 +3794,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
     }
 
   case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
+    if ( warnOnGeomModif() )
+      break; // action forbiden as geometry modified
     startOperation( SMESHOp::OpElem0DOnElemNodes );
     break;
 
@@ -3741,6 +3929,9 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpSortChild:
     ::sortChildren();
     break;
+  case SMESHOp::OpBreakLink:
+    ::breakShaperLink();
+    break;
 
   }
 
@@ -4074,6 +4265,8 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
 
+  createSMESHAction( SMESHOp::OpBreakLink, "BREAK_SHAPER_LINK" );
+
   QList<int> aCtrlActions;
   aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
                << SMESHOp::OpNodeConnectivityNb                                         // node controls
@@ -4847,6 +5040,9 @@ void SMESHGUI::initialize( CAM_Application* app )
   popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
   popupMgr()->insert( separator(), -1, -1 );
 
+  popupMgr()->insert( action( SMESHOp::OpBreakLink), -1, -1 );
+  popupMgr()->setRule( action( SMESHOp::OpBreakLink), "$component={'SHAPERSTUDY'} and client='ObjectBrowser' and canBreakLink", QtxPopupMgr::VisibleRule );
+
   connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
            this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
 
@@ -4920,7 +5116,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);
@@ -4986,9 +5189,9 @@ void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& ti
     _PTR(Study) study = appStudy->studyDS();
     _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
     if ( obj ) {
-      QString aName = QString( SMESH::fromUtf8(obj->GetName()) );
-      while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
-          aName.remove( (aName.length() - 1), 1 );
+      QString aName = SMESH::fromUtf8( obj->GetName());
+      while ( !aName.isEmpty() && aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
+        aName.remove(( aName.length() - 1 ), 1 );
       title = aName;
     }
   }
@@ -5086,6 +5289,9 @@ void SMESHGUI::createPreferences()
 
   int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
   setPreferenceProperty( dispgroup, "columns", 2 );
+
+  addPreference( tr( "PREF_FITALL_ON_DISPLAYONLY" ), dispgroup, LightApp_Preferences::Bool, "SMESH", "fitall_on_displayonly" );
+  
   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
   QStringList modes;
   modes.append( tr("MEN_WIRE") );
@@ -5198,6 +5404,7 @@ void SMESHGUI::createPreferences()
                              "SMESH", "nb_segments_per_edge" );
   setPreferenceProperty( nbSeg, "min", 1 );
   setPreferenceProperty( nbSeg, "max", 10000000 );
+  addPreference( tr( "PREF_USE_MESHGEMS_HYPOSET" ), segGroup, LightApp_Preferences::Bool, "SMESH", "use-meshgems-hypo-sets" );
 
   int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
   addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
@@ -5471,13 +5678,13 @@ void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
     std::string aWarning;
     SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
 
-    if ( name== "selection_object_color" ||
-         name=="selection_element_color" ||
-         name==        "highlight_color" ||
-         name=="selection_precision_node"    ||
-         name=="selection_precision_element" ||
-         name=="selection_precision_object"   ||
-         name=="selection_increment")
+    if ( name ==  "selection_object_color" ||
+         name == "selection_element_color" ||
+         name ==         "highlight_color" ||
+         name == "selection_precision_node"    ||
+         name == "selection_precision_element" ||
+         name == "selection_precision_object"  ||
+         name == "selection_increment")
     {
       SMESH::UpdateSelectionProp( this );
     }