Salome HOME
IPAL54678: TC-9.5.0: Sub-mesh priority: not all sub-meshes are displayed in the dialog
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.cxx
index 8d2bb1606ce24d93bf29325bdf4876798a207915..f638d0391b8722e5ca7be3470c7fdd2a7d138a2b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2019  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
 
 #include "SMESH_version.h"
 
-#include "SMESH_ControlsDef.hxx"
 #include "SMESH_Actor.h"
 #include "SMESH_ActorUtils.h"
 #include "SMESH_Client.hxx"
+#include "SMESH_Comment.hxx"
+#include "SMESH_ControlsDef.hxx"
 #include "SMESH_ScalarBarActor.h"
-#include <SMESH_Comment.hxx>
 #include "SMESH_TypeFilter.hxx"
 
 // SALOME GUI includes
@@ -2870,8 +2870,24 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpComputeSubMesh:
   case SMESHOp::OpPreCompute:
   case SMESHOp::OpEvaluate:
+  case SMESHOp::OpShowErrors:
     startOperation( theCommandID );
     break;
+  case SMESHOp::OpRecompute:
+    {
+      if ( isStudyLocked() )
+        break;
+      SALOME_ListIO selected;
+      if ( LightApp_SelectionMgr *sel = selectionMgr() )
+        sel->selectedObjects( selected );
+      if ( selected.Extent() == 1 ) {
+        SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( selected.First() );
+        if ( !aMesh->_is_nil() )
+          aMesh->Clear();
+        startOperation( SMESHOp::OpCompute );
+      }
+    }
+    break;
   case SMESHOp::OpCopyMesh:
     {
       if (isStudyLocked()) break;
@@ -3998,7 +4014,7 @@ void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QStr
   if ( !icon_id.isEmpty() )
     pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
   else
-    pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
+    pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICON_%1" ).arg( po_id ).toLatin1().data() ), false );
   if ( !pix.isNull() )
     icon = QIcon( pix );
 
@@ -4105,7 +4121,9 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction( SMESHOp::OpCopyMesh,             "COPY_MESH",               "ICON_COPY_MESH" );
   createSMESHAction( SMESHOp::OpCompute,              "COMPUTE",                 "ICON_COMPUTE" );
   createSMESHAction( SMESHOp::OpComputeSubMesh,       "COMPUTE_SUBMESH",         "ICON_COMPUTE" );
+  createSMESHAction( SMESHOp::OpRecompute,            "RE_COMPUTE",              "ICON_COMPUTE" );
   createSMESHAction( SMESHOp::OpPreCompute,           "PRECOMPUTE",              "ICON_PRECOMPUTE" );
+  createSMESHAction( SMESHOp::OpShowErrors,           "SHOW_ERRORS",             "ICON_SHOW_ERRORS" );
   createSMESHAction( SMESHOp::OpEvaluate,             "EVALUATE",                "ICON_EVALUATE" );
   createSMESHAction( SMESHOp::OpMeshOrder,            "MESH_ORDER",              "ICON_MESH_ORDER");
   createSMESHAction( SMESHOp::OpCreateGroup,          "CREATE_GROUP",            "ICON_CREATE_GROUP" );
@@ -4659,20 +4677,22 @@ void SMESHGUI::initialize( CAM_Application* app )
     hasVolumes("({'Volume'} in elemTypes)"),
     hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
 
-  createPopupItem( SMESHOp::OpFileInformation,   OB, mesh, "&& selcount=1 && isImported" );
-  createPopupItem( SMESHOp::OpCreateSubMesh,     OB, mesh, "&& hasGeomReference");
   createPopupItem( SMESHOp::OpEditMesh,          OB, mesh, "&& selcount=1" );
+  createPopupItem( SMESHOp::OpCreateSubMesh,     OB, mesh, "&& hasGeomReference");
+  createPopupItem( SMESHOp::OpMeshOrder,         OB, mesh, "&& selcount=1 && hasAlgo && hasGeomReference" );
   createPopupItem( SMESHOp::OpEditSubMesh,       OB, subMesh, "&& selcount=1 && hasGeomReference" );
   createPopupItem( SMESHOp::OpEditGroup,         OB, group );
   createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
 
   popupMgr()->insert( separator(), -1, 0 );
-  createPopupItem( SMESHOp::OpCompute,           OB, mesh, "&& selcount=1 && isComputable" );
-  createPopupItem( SMESHOp::OpComputeSubMesh,    OB, subMesh, "&& selcount=1 && isComputable" );
-  createPopupItem( SMESHOp::OpPreCompute,        OB, mesh, "&& selcount=1 && isPreComputable" );
-  createPopupItem( SMESHOp::OpEvaluate,          OB, mesh, "&& selcount=1 && isComputable" );
-  createPopupItem( SMESHOp::OpMeshOrder,         OB, mesh, "&& selcount=1 && isComputable && hasGeomReference" );
-  createPopupItem( SMESHOp::OpUpdate,            OB, mesh_part );
+  createPopupItem( SMESHOp::OpCompute,           OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
+  createPopupItem( SMESHOp::OpRecompute,         OB, mesh, "&& selcount=1 && hasAlgo && " + isNotEmpty );
+  createPopupItem( SMESHOp::OpShowErrors,        OB, mesh, "&& selcount=1 && hasErrors" );
+  createPopupItem( SMESHOp::OpComputeSubMesh,    OB, subMesh, "&& selcount=1 && hasAlgo && isComputable" );
+  createPopupItem( SMESHOp::OpPreCompute,        OB, mesh, "&& selcount=1 && hasAlgo && isPreComputable" );
+  createPopupItem( SMESHOp::OpEvaluate,          OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
+  popupMgr()->insert( separator(), -1, 0 );
+  createPopupItem( SMESHOp::OpFileInformation,   OB, mesh, "&& selcount=1 && isImported" );
   createPopupItem( SMESHOp::OpMeshInformation,   OB, mesh_part );
   createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1" );
   createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
@@ -4686,8 +4706,8 @@ void SMESHGUI::initialize( CAM_Application* app )
   popupMgr()->insert( separator(), -1, 0 );
   createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh );
   createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
-  popupMgr()->insert( separator(), -1, 0 );
-  createPopupItem( SMESHOp::OpClearMesh,              OB, mesh );
+  //popupMgr()->insert( separator(), -1, 0 );
+
   //popupMgr()->insert( separator(), -1, 0 );
 
   QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
@@ -4695,6 +4715,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   QString only_one_2D        = only_one_non_empty + " && dim>1";
 
   int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 );        // EXPORT submenu
+  popupMgr()->findMenu( anId )->menuAction()->setIcon( resourceMgr()->loadPixmap( "SMESH", tr( "ICON_EXPORT" )));
   createPopupItem( SMESHOp::OpPopupExportMED,  OB, mesh_group, multiple_non_empty, anId );
   createPopupItem( SMESHOp::OpPopupExportUNV,  OB, mesh_group, only_one_non_empty, anId );
   createPopupItem( SMESHOp::OpPopupExportSTL,  OB, mesh_group, only_one_2D, anId );
@@ -4704,8 +4725,6 @@ void SMESHGUI::initialize( CAM_Application* app )
   createPopupItem( SMESHOp::OpPopupExportSAUV, OB, mesh_group, only_one_non_empty, anId );
   createPopupItem( SMESHOp::OpPopupExportGMF,  OB, mesh_group, only_one_non_empty, anId );
   createPopupItem( SMESHOp::OpPopupExportDAT,  OB, mesh_group, only_one_non_empty, anId );
-  createPopupItem( SMESHOp::OpDelete,          OB, mesh_part + " " + hyp_alg );
-  createPopupItem( SMESHOp::OpDeleteGroup,     OB, group );
 
   anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 );        // IMPORT submenu
   createPopupItem( SMESHOp::OpPopupImportMED,  OB, smesh, "", anId );
@@ -4719,18 +4738,22 @@ void SMESHGUI::initialize( CAM_Application* app )
   createPopupItem( SMESHOp::OpPopupImportDAT,  OB, smesh, "", anId );
   popupMgr()->insert( separator(), -1, 0 );
 
+  createPopupItem( SMESHOp::OpClearMesh,         OB, mesh );
+  createPopupItem( SMESHOp::OpDelete,            OB, mesh_part + " " + hyp_alg );
+  createPopupItem( SMESHOp::OpDeleteGroup,       OB, group );
+
   // popup for viewer
   createPopupItem( SMESHOp::OpEditGroup,            View, group );
   createPopupItem( SMESHOp::OpAddElemGroupPopup,    View, elems, "&& guiState = 800" );
   createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
 
   popupMgr()->insert( separator(), -1, 0 );
-  createPopupItem( SMESHOp::OpUpdate,             View, mesh_part );
   createPopupItem( SMESHOp::OpMeshInformation,    View, mesh_part );
   createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
   createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh );
   popupMgr()->insert( separator(), -1, 0 );
 
+  createPopupItem( SMESHOp::OpUpdate,           OB + " " + View, mesh_part );
   createPopupItem( SMESHOp::OpAutoColor,        OB + " " + View, mesh, "&& (not isAutoColor)" );
   createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
   popupMgr()->insert( separator(), -1, 0 );
@@ -5068,8 +5091,9 @@ bool SMESHGUI::isSelectionCompatible()
   SALOME_ListIteratorOfListIO It( selected );
   for ( ; isCompatible && It.More(); It.Next())
     isCompatible =
-      ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
-      ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
+      ( strcmp("GEOM",        It.Value()->getComponentDataType()) == 0 ) ||
+      ( strcmp("SHAPERSTUDY", It.Value()->getComponentDataType()) == 0 ) ||
+      ( strcmp("SMESH",       It.Value()->getComponentDataType()) == 0 );
 
   return isCompatible;
 }
@@ -5078,7 +5102,7 @@ bool SMESHGUI::isSelectionCompatible()
 bool SMESHGUI::reusableOperation( const int id )
 {
   // compute, evaluate and precompute are not reusable operations
-  return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate ) ? false : SalomeApp_Module::reusableOperation( id );
+  return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate || id == SMESHOp::OpRecompute ) ? false : SalomeApp_Module::reusableOperation( id );
 }
 
 bool SMESHGUI::activateModule( SUIT_Study* study )
@@ -5830,55 +5854,55 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const
   // to do : create operation here
   switch( id )
   {
-    case SMESHOp::OpSplitBiQuadratic:
-      op = new SMESHGUI_SplitBiQuadOp();
+  case SMESHOp::OpSplitBiQuadratic:
+    op = new SMESHGUI_SplitBiQuadOp();
     break;
-    case SMESHOp::OpConvertMeshToQuadratic:
-      op = new SMESHGUI_ConvToQuadOp();
+  case SMESHOp::OpConvertMeshToQuadratic:
+    op = new SMESHGUI_ConvToQuadOp();
     break;
-    case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
-      op = new SMESHGUI_Make2DFrom3DOp();
+  case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
+    op = new SMESHGUI_Make2DFrom3DOp();
     break;
-    case SMESHOp::OpReorientFaces:
-      op = new SMESHGUI_ReorientFacesOp();
-      break;
-    case SMESHOp::OpCreateMesh:
-      op = new SMESHGUI_MeshOp( true, true );
+  case SMESHOp::OpReorientFaces:
+    op = new SMESHGUI_ReorientFacesOp();
     break;
-    case SMESHOp::OpCreateSubMesh:
-      op = new SMESHGUI_MeshOp( true, false );
+  case SMESHOp::OpCreateMesh:
+    op = new SMESHGUI_MeshOp( true, true );
     break;
-    case SMESHOp::OpEditMeshOrSubMesh:
-    case SMESHOp::OpEditMesh:
-    case SMESHOp::OpEditSubMesh:
-      op = new SMESHGUI_MeshOp( false );
+  case SMESHOp::OpCreateSubMesh:
+    op = new SMESHGUI_MeshOp( true, false );
     break;
-    case SMESHOp::OpCompute:
-    case SMESHOp::OpComputeSubMesh:
-      op = new SMESHGUI_ComputeOp();
+  case SMESHOp::OpEditMeshOrSubMesh:
+  case SMESHOp::OpEditMesh:
+  case SMESHOp::OpEditSubMesh:
+    op = new SMESHGUI_MeshOp( false );
     break;
-    case SMESHOp::OpPreCompute:
-      op = new SMESHGUI_PrecomputeOp();
+  case SMESHOp::OpCompute:
+  case SMESHOp::OpComputeSubMesh:
+    op = new SMESHGUI_ComputeOp();
     break;
-    case SMESHOp::OpEvaluate:
-      op = new SMESHGUI_EvaluateOp();
+  case SMESHOp::OpPreCompute:
+    op = new SMESHGUI_PrecomputeOp();
     break;
-    case SMESHOp::OpMeshOrder:
-      op = new SMESHGUI_MeshOrderOp();
+  case SMESHOp::OpEvaluate:
+    op = new SMESHGUI_EvaluateOp();
     break;
-    case SMESHOp::OpCreateGeometryGroup:
-      op = new SMESHGUI_GroupOnShapeOp();
-      break;
-    case SMESHOp::OpFindElementByPoint:
-      op = new SMESHGUI_FindElemByPointOp();
-      break;
-    case SMESHOp::OpMoveNode: // Make mesh pass through point
-      op = new SMESHGUI_MakeNodeAtPointOp();
-      break;
-    case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
-      op = new SMESHGUI_Add0DElemsOnAllNodesOp();
-      break;
-    default:
+  case SMESHOp::OpMeshOrder:
+    op = new SMESHGUI_MeshOrderOp();
+    break;
+  case SMESHOp::OpCreateGeometryGroup:
+    op = new SMESHGUI_GroupOnShapeOp();
+    break;
+  case SMESHOp::OpFindElementByPoint:
+    op = new SMESHGUI_FindElemByPointOp();
+    break;
+  case SMESHOp::OpMoveNode: // Make mesh pass through point
+    op = new SMESHGUI_MakeNodeAtPointOp();
+    break;
+  case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
+    op = new SMESHGUI_Add0DElemsOnAllNodesOp();
+    break;
+  default:
     break;
   }
 
@@ -6332,8 +6356,6 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
 
   // componentName is used for encoding of entries when storing them in IParameters
   std::string componentName = myComponentSMESH->ComponentDataType();
-  //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
-  //if (!aSComponent) return;
 
   // IParameters
   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",