Salome HOME
0020833: EDF 1361 SMESH : Graphical Selection of the boundary faces in one clic
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ExtrusionDlg.cxx
index ab65f0570410e1cb813e8d95481cd01f566af8b9..fa367fd510ea421b7f88718e342b4df85053d1cd 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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
@@ -280,15 +280,22 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule)
   mySMESHGUI->SetActiveDialogBox(this);
 
   // Costruction of the logical filter for the elements: mesh/sub-mesh/group
-  SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
-  SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (GROUP);
-
   QList<SUIT_SelectionFilter*> aListOfFilters;
-  if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
-  if (aSmeshGroupFilter)    aListOfFilters.append(aSmeshGroupFilter);
-
-  myMeshOrSubMeshOrGroupFilter =
-    new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
+  aListOfFilters.append(new SMESH_TypeFilter (MESH));
+  aListOfFilters.append(new SMESH_TypeFilter (SUBMESH_VERTEX));
+  aListOfFilters.append(new SMESH_TypeFilter (GROUP_NODE));
+  myMeshOrSubMeshOrGroupFilter0D =
+    new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR, /*takeOwnership=*/true);
+  aListOfFilters[0] = new SMESH_TypeFilter (MESH);
+  aListOfFilters[1] = new SMESH_TypeFilter (SUBMESH_EDGE);
+  aListOfFilters[2] = new SMESH_TypeFilter (GROUP_EDGE);
+  myMeshOrSubMeshOrGroupFilter1D =
+    new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR, /*takeOwnership=*/true);
+  aListOfFilters[0] = new SMESH_TypeFilter (MESH);
+  aListOfFilters[1] = new SMESH_TypeFilter (SUBMESH_FACE);
+  aListOfFilters[2] = new SMESH_TypeFilter (GROUP_FACE);
+  myMeshOrSubMeshOrGroupFilter2D =
+    new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR, /*takeOwnership=*/true);
 
   myHelpFileName = "extrusion_page.html";
 
@@ -351,6 +358,9 @@ SMESHGUI_ExtrusionDlg::~SMESHGUI_ExtrusionDlg()
     myFilterDlg->setParent( 0 );
     delete myFilterDlg;
   }
+  if ( myMeshOrSubMeshOrGroupFilter0D ) delete myMeshOrSubMeshOrGroupFilter0D;
+  if ( myMeshOrSubMeshOrGroupFilter1D ) delete myMeshOrSubMeshOrGroupFilter1D;
+  if ( myMeshOrSubMeshOrGroupFilter2D ) delete myMeshOrSubMeshOrGroupFilter2D;
 }
 
 //=================================================================================
@@ -429,6 +439,8 @@ void SMESHGUI_ExtrusionDlg::ConstructorsClicked (int constructorId)
 
   hidePreview();
 
+  TextLabelElements->setText(tr( constructorId ? "SMESH_ID_ELEMENTS" : "SMESH_ID_NODES"));
+
   switch (constructorId) {
   case 0:
     {
@@ -552,10 +564,11 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply()
       aParameters << SpinBox_Dy->text();
       aParameters << SpinBox_Dz->text();
     } else if ( RadioButton4->isChecked() ) {
-      aParameters << SpinBox_Vx->text();
-      aParameters << SpinBox_Vy->text();
-      aParameters << SpinBox_Vz->text();
-      aParameters << SpinBox_VDist->text();
+      // only 3 coords in a python dump command :(
+      // aParameters << SpinBox_Vx->text();
+      // aParameters << SpinBox_Vy->text();
+      // aParameters << SpinBox_Vz->text();
+      // aParameters << SpinBox_VDist->text();
     }
 
     long aNbSteps = (long)SpinBox_NbSteps->value();
@@ -566,6 +579,8 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply()
       SUIT_OverrideCursor aWaitCursor;
       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
 
+      myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
+
       if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
         if( CheckBoxMesh->isChecked() ) 
           switch (GetConstructorId() ) {
@@ -624,8 +639,6 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply()
             aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps);
       }
 
-      myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
-
     } catch (...) {
     }
 
@@ -724,7 +737,7 @@ void SMESHGUI_ExtrusionDlg::onTextChange (const QString& theNewText)
         {
           SMESHType = SMESH::EDGE;
           SMDSType = SMDSAbs_Edge;
-          break;                 
+          break;                  
         }
       case 2:
         {
@@ -895,31 +908,38 @@ void SMESHGUI_ExtrusionDlg::SetEditCurrentArgument()
 
   if (send == SelectElementsButton) {
     myEditCurrentArgument = (QWidget*)LineEditElements;
-    if (CheckBoxMesh->isChecked()) {
+    if (CheckBoxMesh->isChecked())
+    {
       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
         aViewWindow->SetSelectionMode(ActorSelection);
-      mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
-    } else {
+      switch( GetConstructorId() ) {
+      case 0: mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter0D); break;
+      case 1: mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter1D); break;
+      case 2: mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter2D); break;
+      }
+    }
+    else
+    {
       int aConstructorId = GetConstructorId();
       switch(aConstructorId) {
-          case 0:
-          {   
-            if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-              aViewWindow->SetSelectionMode(NodeSelection);
-            break;
-          }
-          case 1:
-          {
-            if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-              aViewWindow->SetSelectionMode(EdgeSelection);
-            break;
-          }
-          case 2:
-          {
-            if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      case 0:
+        {
+          if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+            aViewWindow->SetSelectionMode(NodeSelection);
+          break;
+        }
+      case 1:
+        {
+          if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+            aViewWindow->SetSelectionMode(EdgeSelection);
+          break;
+        }
+      case 2:
+        {
+          if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
             aViewWindow->SetSelectionMode(FaceSelection);
-            break;
-          }
+          break;
+        }
       }
     }
   }
@@ -1025,13 +1045,20 @@ void SMESHGUI_ExtrusionDlg::onSelectMesh (bool toSelectMesh)
 
   mySelectionMgr->clearFilters();
 
-  if (toSelectMesh) {
+  if (toSelectMesh)
+  {
     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
       aViewWindow->SetSelectionMode(ActorSelection);
-    mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
+    switch( GetConstructorId() ) {
+    case 0: mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter0D); break;
+    case 1: mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter1D); break;
+    case 2: mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter2D); break;
+    }
     LineEditElements->setReadOnly(true);
     LineEditElements->setValidator(0);
-  } else {
+  }
+  else
+  {
     int aConstructorId = GetConstructorId();
     switch(aConstructorId) {
       case 0:
@@ -1187,17 +1214,17 @@ void SMESHGUI_ExtrusionDlg::onDisplaySimulation( bool toDisplayPreview ) {
             case 0:
               {
                 aMeshEditor->ExtrusionSweepObject0D(mySelectedObject, aVector, aNbSteps);
-                                       break;
+                                        break;
               }
             case 1:
               {
                 aMeshEditor->ExtrusionSweepObject1D(mySelectedObject, aVector, aNbSteps);
-                                       break;
+                                        break;
               }
             case 2:
               {
                 aMeshEditor->ExtrusionSweepObject2D(mySelectedObject, aVector, aNbSteps);
-                                       break;
+                                        break;
               }
           }
         }
@@ -1236,7 +1263,7 @@ void SMESHGUI_ExtrusionDlg::getExtrusionVector(SMESH::DirStruct& aVector) {
     
     
     aNormale /= aNormale.Modulus();
-    long aVDist = (long)SpinBox_VDist->value();
+    double aVDist = (double)SpinBox_VDist->value();
     
     aVector.PS.x = aNormale.X()*aVDist;
     aVector.PS.y = aNormale.Y()*aVDist;