Salome HOME
IPAL21340
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.cxx
index 8904fb435dd31cf438a791340babbb37a8db45dc..4b41c1d20a1b0765ea66e5f0d953f5c4c599996f 100644 (file)
@@ -67,6 +67,7 @@
 #include "SMESHGUI_BuildCompoundDlg.h"
 #include "SMESHGUI_ComputeDlg.h"
 #include "SMESHGUI_FileInfoDlg.h"
+#include "SMESHGUI_Make2DFrom3DOp.h"
 
 #include "SMESHGUI_Utils.h"
 #include "SMESHGUI_MeshUtils.h"
@@ -96,6 +97,8 @@
 #include <SVTK_ViewModel.h>
 #include <SVTK_ViewManager.h>
 
+#include <VTKViewer_Algorithm.h>
+
 #include <SUIT_MessageBox.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_FileDlg.h>
          if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
            unsigned int aMode = anActor->GetEntityMode();
            switch(theCommandID){
+            case 216:
+              InverseEntityMode(aMode,SMESH_Actor::e0DElements);
+              break;
            case 217:
              InverseEntityMode(aMode,SMESH_Actor::eEdges);
              break;
@@ -1467,6 +1473,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   break;
   
   // Display Entity
+  case 216: // 0D elements
   case 217: // Edges
   case 218: // Faces
   case 219: // Volumes
@@ -1571,7 +1578,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       break;
     }
 
-  case 400                                   // NODES
+  case 4000:                                   // NODES
     {
       if(checkLock(aStudy)) break;
 
@@ -1767,6 +1774,11 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
                               }*/
       break;
     }
+  case 418: // create 2D mesh from 3D
+    {
+      startOperation( 418 );
+      break;
+    }
   case 806:                                     // CREATE GEO GROUP
     {
       startOperation( 806 );
@@ -2093,9 +2105,9 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
         {
           // BUG 0020378
           //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
-          SMESH::HypothesisCreatorPtr aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
+          SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
           if (aCreator) {
-            aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
+            aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
           }
           else
           {
@@ -2103,7 +2115,6 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
           }
         }
       }
-      updateObjBrowser( true );
       break;
     }
 
@@ -2192,7 +2203,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       break;
     }
 
-  case 401:                                    // GEOM::EDGE
+  case 4009:                                   // ELEM0D
+  case 4010:                                   // GEOM::EDGE
   case 4021:                                   // TRIANGLE
   case 4022:                                   // QUAD
   case 4023:                                   // POLYGON
@@ -2205,6 +2217,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
         SMDSAbs_ElementType type    = SMDSAbs_Edge;
         int                 nbNodes = 2;
         switch (theCommandID) {
+        case 4009:                                      // ELEM0D
+          type = SMDSAbs_0DElement; nbNodes = 1; break;
         case 4021:                                      // TRIANGLE
           type = SMDSAbs_Face; nbNodes = 3; break;
         case 4022:                                      // QUAD
@@ -2696,7 +2710,6 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction(  704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
   createSMESHAction(  710, "BUILD_COMPOUND",  "ICON_BUILD_COMPOUND" );
   createSMESHAction(  711, "PRECOMPUTE",      "ICON_PRECOMPUTE" );
-  //createSMESHAction(  712, "EVALUATE",        "ICON_EVALUATE" );
   createSMESHAction(  712, "EVALUATE",        "ICON_COMPUTE" );
   createSMESHAction(  806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
   createSMESHAction(  801, "CREATE_GROUP",    "ICON_CREATE_GROUP" );
@@ -2729,8 +2742,9 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction( 6018, "LENGTH_2D",       "ICON_LENGTH_2D",     0, true );
   createSMESHAction( 6019, "CONNECTION_2D",   "ICON_CONNECTION_2D", 0, true );
   createSMESHAction( 6009, "VOLUME_3D",       "ICON_VOLUME_3D",     0, true );
-  createSMESHAction(  400, "NODE",            "ICON_DLG_NODE" );
-  createSMESHAction(  401, "EDGE",            "ICON_DLG_EDGE" );
+  createSMESHAction( 4000, "NODE",            "ICON_DLG_NODE" );
+  createSMESHAction( 4009, "ELEM0D",          "ICON_DLG_ELEM0D" );
+  createSMESHAction( 4010, "EDGE",            "ICON_DLG_EDGE" );
   createSMESHAction( 4021, "TRIANGLE",        "ICON_DLG_TRIANGLE" );
   createSMESHAction( 4022, "QUAD",            "ICON_DLG_QUADRANGLE" );
   createSMESHAction( 4023, "POLYGON",         "ICON_DLG_POLYGON" );
@@ -2760,6 +2774,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction(  415, "MAP",             "ICON_MAP" );
   createSMESHAction(  416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
   createSMESHAction(  417, "CONV_TO_QUAD",    "ICON_CONV_TO_QUAD" );
+  createSMESHAction(  418, "2D_FROM_3D",      "ICON_2D_FROM_3D" );
   createSMESHAction(  200, "RESET" );
   createSMESHAction(  201, "SCALAR_BAR_PROP" );
   createSMESHAction(  211, "WIRE",           "ICON_WIRE", 0, true );
@@ -2767,6 +2782,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction(  213, "SHRINK",         "ICON_SHRINK", 0, true );
   createSMESHAction(  214, "UPDATE",         "ICON_UPDATE" );
   createSMESHAction(  215, "NODES",          "ICON_POINTS", 0, true );
+  createSMESHAction(  216, "ELEMS0D",        "ICON_DLG_ELEM0D", 0, true );
   createSMESHAction(  217, "EDGES",          "ICON_DLG_EDGE", 0, true );
   createSMESHAction(  218, "FACES",          "ICON_DLG_TRIANGLE", 0, true );
   createSMESHAction(  219, "VOLUMES",        "ICON_DLG_TETRAS", 0, true );
@@ -2883,8 +2899,9 @@ void SMESHGUI::initialize( CAM_Application* app )
   createMenu( 6021, ctrlId, -1 );
   createMenu( separator(), ctrlId, -1 );
 
-  createMenu( 400, addId, -1 );
-  createMenu( 401, addId, -1 );
+  createMenu( 4000, addId, -1 );
+  createMenu( 4009, addId, -1 );
+  createMenu( 4010, addId, -1 );
   createMenu( 4021, addId, -1 );
   createMenu( 4022, addId, -1 );
   createMenu( 4023, addId, -1 );
@@ -2927,6 +2944,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createMenu( 414, modifyId, -1 );
   createMenu( 415, modifyId, -1 );
   createMenu( 417, modifyId, -1 );
+  createMenu( 418, modifyId, -1 );
 
   createMenu( 214, viewId, -1 );
 
@@ -2977,8 +2995,9 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( 6021, ctrlTb );
   createTool( separator(), ctrlTb );
 
-  createTool( 400, addRemTb );
-  createTool( 401, addRemTb );
+  createTool( 4000, addRemTb );
+  createTool( 4009, addRemTb );
+  createTool( 4010, addRemTb );
   createTool( 4021, addRemTb );
   createTool( 4022, addRemTb );
   createTool( 4023, addRemTb );
@@ -3022,6 +3041,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( 414, modifyTb );
   createTool( 415, modifyTb );
   createTool( 417, modifyTb );
+  createTool( 418, modifyTb );
 
   createTool( 214, dispModeTb );
 
@@ -3048,6 +3068,19 @@ void SMESHGUI::initialize( CAM_Application* app )
          hyp_alg = hypo + " " + algo;
 
   // popup for object browser
+  QString
+    isInvisible("not( isVisible )"),
+    isEmpty("numberOfNodes = 0"),
+    isNotEmpty("numberOfNodes <> 0"),
+
+    // has nodes, edges, etc in VISIBLE! actor
+    hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
+    hasElems("(count( elemTypes ) > 0)"),
+    hasDifferentElems("(count( elemTypes ) > 1)"),
+    hasElems0d("({'Elem0d'} in elemTypes)"),
+    hasEdges("({'Edge'} in elemTypes)"),
+    hasFaces("({'Face'} in elemTypes)"),
+    hasVolumes("({'Volume'} in elemTypes)");
 
   createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" );      // FILE INFORMATION
   createPopupItem( 703, OB, mesh, "&& isComputable");      // CREATE_SUBMESH
@@ -3060,6 +3093,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   popupMgr()->insert( separator(), -1, 0 );
   createPopupItem( 701, OB, mesh, "&& isComputable" );     // COMPUTE
   createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
+  createPopupItem( 712, OB, mesh, "&& isComputable" );     // COMPUTE
   createPopupItem( 214, OB, mesh_group );                  // UPDATE
   createPopupItem( 900, OB, mesh_group );                  // ADV_INFO
   createPopupItem( 902, OB, mesh );                        // STD_INFO
@@ -3075,6 +3109,9 @@ void SMESHGUI::initialize( CAM_Application* app )
   popupMgr()->insert( separator(), -1, 0 );
   createPopupItem( 4043, OB, mesh );                       // CLEAR_MESH
   popupMgr()->insert( separator(), -1, 0 );
+  createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/);       // convert to quadratic
+  createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/);     // create 2D mesh on 3D
+  popupMgr()->insert( separator(), -1, 0 );
 
   QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
 
@@ -3102,19 +3139,6 @@ void SMESHGUI::initialize( CAM_Application* app )
   popupMgr()->insert( separator(), -1, 0 );
 
   int anId;
-  QString
-    isInvisible("not( isVisible )"),
-    isEmpty("numberOfNodes = 0"),
-    isNotEmpty("numberOfNodes <> 0"),
-
-    // has nodes, edges, etc in VISIBLE! actor
-    hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
-    hasElems("(count( elemTypes ) > 0)"),
-    hasDifferentElems("(count( elemTypes ) > 1)"),
-    hasEdges("({'Edge'} in elemTypes)"),
-    hasFaces("({'Face'} in elemTypes)"),
-    hasVolumes("({'Volume'} in elemTypes)");
-
   QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
   QString aType = QString( "%1type in {%2}" ).arg( lc );
   aType = aType.arg( mesh_group );
@@ -3169,6 +3193,10 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
 
+  popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
+  popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
+  popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
+
   popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
   popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
   popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
@@ -3580,17 +3608,29 @@ void SMESHGUI::createPreferences()
   int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
   setPreferenceProperty( elemGroup, "columns", 2 );
 
-  addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
-  addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
+  addPreference( tr( "PREF_FILL"     ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
+  addPreference( tr( "PREF_OUTLINE"  ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
   addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
+  addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
+
+  //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
+  //setPreferenceProperty( sp, "hstretch", 0 );
+  //setPreferenceProperty( sp, "vstretch", 0 );
+
+  int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
+                             LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
   int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
+  int elemW  = addPreference(tr("PREF_WIDTH"), elemGroup,
+                             LightApp_Preferences::IntSpin, "SMESH", "element_width");
+  int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
+                             LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
+
+  setPreferenceProperty( size0d, "min", 1 );
+  setPreferenceProperty( size0d, "max", 10 );
 
   setPreferenceProperty( sp, "hstretch", 0 );
   setPreferenceProperty( sp, "vstretch", 0 );
 
-  int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
-  int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
-
   setPreferenceProperty( elemW, "min", 1 );
   setPreferenceProperty( elemW, "max", 5 );
 
@@ -3871,6 +3911,9 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const
     case 417: //convert to quadratic
       op = new SMESHGUI_ConvToQuadOp();
     break;
+    case 418: // create 2D mesh as boundary on 3D
+      op = new SMESHGUI_Make2DFrom3DOp();
+    break;
     case 4067: // make mesh pass through point
       op = new SMESHGUI_MakeNodeAtPointOp();
       break;
@@ -4009,7 +4052,8 @@ void SMESHGUI::storeVisualParameters (int savePoint)
       {
        if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
         {
-         vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
+         VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
+         vtkActorCollection* allActors = aCopy.GetActors();
          allActors->InitTraversal();
          while (vtkActor* actor = allActors->GetNextActor())
           {
@@ -4225,7 +4269,8 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
               // access later when restoring other parameters
               SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
               vtkRenderer* Renderer = vtkView->getRenderer();
-              vtkActorCollection* theActors = Renderer->GetActors();
+             VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
+              vtkActorCollection* theActors = aCopy.GetActors();
               theActors->InitTraversal();
               bool isFound = false;
               vtkActor *ac = theActors->GetNextActor();
@@ -4395,8 +4440,11 @@ int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString
   return tfont;
 }
 
-
-
-
-
-
+/*!
+  \brief Actions after hypothesis edition
+  Updates object browser after hypothesis edition
+*/
+void SMESHGUI::onHypothesisEdit( int result )
+{
+  updateObjBrowser( true );
+}