Salome HOME
bos #24009 Merge gni/adaptation branch (MG-Adapt)
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.cxx
index 762c7cb341a911478a46e8f9db8087f81a298abd..5c3cfa08e7377d5f9b1cc59f54b515a5426d83b0 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  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
@@ -30,7 +30,6 @@
 
 //  SMESH includes
 #include "SMESHGUI.h"
-#include "SMESHGUI_AdaptDlg.h"
 #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
 #include "SMESHGUI_AddMeshElementDlg.h"
 #include "SMESHGUI_AddQuadraticElementDlg.h"
@@ -61,6 +60,7 @@
 #include "SMESHGUI_GroupUtils.h"
 #include "SMESHGUI_Hypotheses.h"
 #include "SMESHGUI_HypothesesUtils.h"
+#include "SMESHGUI_MG_ADAPTDRIVER.h"
 #include "SMESHGUI_Make2DFrom3DOp.h"
 #include "SMESHGUI_MakeNodeAtPointDlg.h"
 #include "SMESHGUI_Measurements.h"
 #include <vtkRenderer.h>
 
 // SALOME KERNEL includes
+#include <Basics_Utils.hxx>
 #include <SALOMEDSClient_ClientFactory.hxx>
 #include <SALOMEDSClient_IParameters.hxx>
 #include <SALOMEDSClient_SComponent.hxx>
 #include <SALOMEDSClient_StudyBuilder.hxx>
-#include <SALOMEDS_Study.hxx>
 #include <SALOMEDS_SObject.hxx>
-#include "utilities.h"
+#include <SALOMEDS_Study.hxx>
+#include <SALOME_GenericObj_wrap.hxx>
 #include <SALOME_LifeCycleCORBA.hxx>
+#include <utilities.h>
 
 // OCCT includes
 #include <Standard_ErrorHandler.hxx>
 #include <NCollection_DataMap.hxx>
 #include <NCollection_DoubleMap.hxx>
 
-#include <Basics_Utils.hxx>
-
 // Below macro, when uncommented, switches on simplified (more performant) algorithm
 // of auto-color picking up
 #define SIMPLE_AUTOCOLOR
@@ -3044,11 +3044,19 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       break;
     }
   // Adaptation - begin
+#ifndef DISABLE_MG_ADAPT
   case SMESHOp::OpMGAdapt:
     {
-      SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
-      SMESHGUI_AdaptDlg *objet = new SMESHGUI_AdaptDlg( this, theCommandID, aMesh);
+      if ( isStudyLocked() )
+        break;
+      EmitSignalDeactivateDialog();
+
+      SALOME::GenericObj_wrap< SMESH::MG_ADAPT > model = GetSMESHGen()->CreateMG_ADAPT();
+      bool isCreation = false;
+      ( new SMESHGUI_MG_ADAPTDRIVER( this, model, isCreation ))->show();
+      break;
     }
+#endif
   // Adaptation - end
   case SMESHOp::OpSplitBiQuadratic:
   case SMESHOp::OpConvertMeshToQuadratic:
@@ -4288,7 +4296,9 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
 
   // Adaptation - begin
-  createSMESHAction( SMESHOp::OpMGAdapt,              "MG_ADAPT",                "ICON_MG_ADAPT" );
+#ifndef DISABLE_MG_ADAPT
+  createSMESHAction( SMESHOp::OpMGAdapt, "MG_ADAPT", "ICON_MG_ADAPT" );
+#endif
   // Adaptation - end
 
   createSMESHAction( SMESHOp::OpMinimumDistance,  "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
@@ -4332,7 +4342,9 @@ void SMESHGUI::initialize( CAM_Application* app )
       meshId    = createMenu( tr( "MEN_MESH" ),    -1, 70, 10 ),
       ctrlId    = createMenu( tr( "MEN_CTRL" ),    -1, 60, 10 ),
       modifyId  = createMenu( tr( "MEN_MODIFY" ),  -1, 40, 10 ),
+#ifndef DISABLE_MG_ADAPT
       adaptId   = createMenu( tr( "MEN_ADAPT" ),   -1, 80, 10 ),
+#endif
       measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
       viewId    = createMenu( tr( "MEN_VIEW" ),    -1,  2 );
 
@@ -4506,7 +4518,9 @@ void SMESHGUI::initialize( CAM_Application* app )
   createMenu( SMESHOp::OpPatternMapping,         modifyId, -1 );
 
   // Adaptation - begin
-  createMenu( SMESHOp::OpMGAdapt,              adaptId, -1 );
+#ifndef DISABLE_MG_ADAPT
+  createMenu( SMESHOp::OpMGAdapt, adaptId, -1 );
+#endif
   // Adaptation - end
 
   createMenu( SMESHOp::OpMinimumDistance,  measureId,   -1 );
@@ -4523,7 +4537,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
 
   // ----- create toolbars --------------
-  int meshTb       = createTool( tr( "TB_MESH" ),      QString( "SMESHMeshToolbar" ) ) ;
+  int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ) ;
   createTool( SMESHOp::OpCreateMesh,        meshTb );
   createTool( SMESHOp::OpCreateSubMesh,     meshTb );
   createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
@@ -4535,30 +4549,30 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( SMESHOp::OpEvaluate,          meshTb );
   createTool( SMESHOp::OpMeshOrder,         meshTb );
 
-  int infoTb       = createTool( tr( "TB_INFO" ),      QString( "SMESHInformationToolbar" ) ) ;
+  int infoTb = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ) ;
   createTool( SMESHOp::OpMeshInformation,    infoTb );
   //createTool( SMESHOp::OpStdInfo, meshTb );
   //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
   createTool( SMESHOp::OpFindElementByPoint, infoTb );
 
-  int groupTb      = createTool( tr( "TB_GROUP" ),     QString( "SMESHGroupToolbar" ) ) ;
+  int groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ) ;
   createTool( SMESHOp::OpCreateGroup,         groupTb );
   createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
   createTool( SMESHOp::OpConstructGroup,      groupTb );
   createTool( SMESHOp::OpEditGroup,           groupTb );
 
-  int ctrl0dTb     = createTool( tr( "TB_CTRL0D" ),    QString( "SMESHNodeControlsToolbar" ) ) ;
+  int ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ) ;
   createTool( SMESHOp::OpFreeNode,  ctrl0dTb );
   createTool( SMESHOp::OpEqualNode, ctrl0dTb );
   //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
 
-  int ctrl1dTb     = createTool( tr( "TB_CTRL1D" ),    QString( "SMESHEdgeControlsToolbar" ) ) ;
+  int ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ) ;
   createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
   createTool( SMESHOp::OpLength,     ctrl1dTb );
   createTool( SMESHOp::OpConnection, ctrl1dTb );
   createTool( SMESHOp::OpEqualEdge,  ctrl1dTb );
 
-  int ctrl2dTb     = createTool( tr( "TB_CTRL2D" ),    QString( "SMESHFaceControlsToolbar" ) ) ;
+  int ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ) ;
   createTool( SMESHOp::OpFreeEdge,            ctrl2dTb );
   createTool( SMESHOp::OpFreeFace,            ctrl2dTb );
   createTool( SMESHOp::OpBareBorderFace,      ctrl2dTb );
@@ -4575,7 +4589,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( SMESHOp::OpEqualFace,           ctrl2dTb );
   createTool( SMESHOp::OpDeflection2D,        ctrl2dTb );
 
-  int ctrl3dTb     = createTool( tr( "TB_CTRL3D" ),    QString( "SMESHVolumeControlsToolbar" ) ) ;
+  int ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ) ;
   createTool( SMESHOp::OpAspectRatio3D,         ctrl3dTb );
   createTool( SMESHOp::OpVolume,                ctrl3dTb );
   createTool( SMESHOp::OpMaxElementLength3D,    ctrl3dTb );
@@ -4583,7 +4597,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
   createTool( SMESHOp::OpEqualVolume,           ctrl3dTb );
 
-  int addElemTb    = createTool( tr( "TB_ADD" ),       QString( "SMESHAddElementToolbar" ) ) ;
+  int addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ) ;
   createTool( SMESHOp::OpNode,              addElemTb );
   createTool( SMESHOp::OpElem0D,            addElemTb );
   createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
@@ -4599,7 +4613,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( SMESHOp::OpHexagonalPrism,    addElemTb );
   createTool( SMESHOp::OpPolyhedron,        addElemTb );
 
-  int addNonElemTb = createTool( tr( "TB_ADDNON" ),    QString( "SMESHAddElementToolbar" ) ) ;
+  int addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ) ;
   createTool( SMESHOp::OpQuadraticEdge,          addNonElemTb );
   createTool( SMESHOp::OpQuadraticTriangle,      addNonElemTb );
   createTool( SMESHOp::OpBiQuadraticTriangle,    addNonElemTb );
@@ -4613,7 +4627,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( SMESHOp::OpQuadraticHexahedron,    addNonElemTb );
   createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
 
-  int remTb        = createTool( tr( "TB_REM" ),       QString( "SMESHRemoveToolbar" ) ) ;
+  int remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ) ;
   createTool( SMESHOp::OpRemoveNodes,       remTb );
   createTool( SMESHOp::OpRemoveElements,    remTb );
   createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
@@ -4623,7 +4637,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   //createTool( SMESHOp::OpRenumberingNodes,    renumbTb );
   //createTool( SMESHOp::OpRenumberingElements, renumbTb );
 
-  int transformTb  = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ) ;
+  int transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ) ;
   createTool( SMESHOp::OpMergeNodes,     transformTb );
   createTool( SMESHOp::OpMergeElements,  transformTb );
   createTool( SMESHOp::OpTranslation,    transformTb );
@@ -4634,7 +4648,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( SMESHOp::OpSewing,         transformTb );
   createTool( SMESHOp::OpDuplicateNodes, transformTb );
 
-  int modifyTb     = createTool( tr( "TB_MODIFY" ),    QString( "SMESHModificationToolbar" ) ) ;
+  int modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ) ;
   createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
   createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
   createTool( SMESHOp::OpExtrusion,              modifyTb );
@@ -4653,14 +4667,16 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( SMESHOp::OpPatternMapping,         modifyTb );
 
   // Adaptation - begin
-  int adaptTb      = createTool( tr( "TB_ADAPTATION" ),QString( "SMESHAdaptationToolbar" ) ) ;
-  createTool( SMESHOp::OpMGAdapt,              adaptTb );
+#ifndef DISABLE_MG_ADAPT
+  int adaptTb = createTool( tr( "TB_ADAPTATION" ), QString( "SMESHAdaptationToolbar" ) ) ;
+  createTool( SMESHOp::OpMGAdapt, adaptTb );
+#endif
   // Adaptation - end
 
-  int measuremTb   = createTool( tr( "TB_MEASUREM" ),  QString( "SMESHMeasurementsToolbar" ) ) ;
+  int measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ) ;
   createTool( SMESHOp::OpMinimumDistance, measuremTb );
 
-  int dispModeTb   = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
+  int dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
   createTool( SMESHOp::OpUpdate, dispModeTb );
 
   QString lc = "$";        // VSR : instead of QtxPopupSelection::defEquality();
@@ -4736,10 +4752,13 @@ void SMESHGUI::initialize( CAM_Application* app )
   popupMgr()->insert( separator(), -1, 0 );
   createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh, "&& " + hasElems );
   createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
-  popupMgr()->insert( separator(), -1, 0 );
 
   // Adaptation - begin
-  createPopupItem( SMESHOp::OpMGAdapt,              OB, mesh );
+#ifndef DISABLE_MG_ADAPT
+  popupMgr()->insert( separator(), -1, 0 );
+  createPopupItem( SMESHOp::OpMGAdapt, OB, mesh );
+  popupMgr()->insert( separator(), -1, 0 );
+#endif
   // Adaptation - end
 
   QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
@@ -5775,6 +5794,7 @@ void SMESHGUI::createPreferences()
   addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
 
   // Adaptation - begin
+#ifndef DISABLE_MG_ADAPT
   // Adaptation tab ------------------------------------------------------------------------
   int adaptTab = addPreference( tr( "ADAPT_PREF_TAB_GENERAL" ) );
   int bloc, pref ;
@@ -5795,8 +5815,8 @@ void SMESHGUI::createPreferences()
   aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST" );
   aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_C" );;
   setPreferenceProperty( pref, "strings", aListOfTimeStep );
+#endif
   // Adaptation - end
-
 }
 
 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
@@ -6010,10 +6030,6 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const
   case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
     op = new SMESHGUI_Add0DElemsOnAllNodesOp();
     break;
-  // Adaptation - begin
-  case SMESHOp::OpMGAdapt:
-    break;
-  // Adaptation - end
   default:
     break;
   }