Salome HOME
Merge from BR_V5_IMP_P8
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_RevolutionDlg.cxx
index 108a5f9ebc00524a041fd513796194483582c1c6..15119eca4fff895c1e3e26bb76da3807abbafe21 100644 (file)
@@ -1,29 +1,29 @@
-// SMESH SMESHGUI : GUI for SMESH component
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-// Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-// This library is free software; you can redistribute it and/or 
-// modify it under the terms of the GNU Lesser General Public 
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License. 
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
 //
-// This library is distributed in the hope that it will be useful, 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details. 
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
 //
-// You should have received a copy of the GNU Lesser General Public 
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+// SMESH SMESHGUI : GUI for SMESH component
 // File   : SMESHGUI_RevolutionDlg.cxx
 // Author : Michael ZORIN, Open CASCADE S.A.S.
-//
-
 // SMESH includes
+//
 #include "SMESHGUI_RevolutionDlg.h"
 
 #include "SMESHGUI.h"
@@ -32,6 +32,8 @@
 #include "SMESHGUI_VTKUtils.h"
 #include "SMESHGUI_MeshUtils.h"
 #include "SMESHGUI_IdValidator.h"
+#include "SMESHGUI_MeshEditPreview.h"
+#include "SMESHGUI_FilterDlg.h"
 
 #include <SMESH_Actor.h>
 #include <SMESH_TypeFilter.hxx>
 #include <SUIT_Session.h>
 #include <SUIT_MessageBox.h>
 #include <SUIT_Desktop.h>
+#include <SUIT_OverrideCursor.h>
 
 #include <LightApp_Application.h>
 #include <LightApp_SelectionMgr.h>
+#include <SalomeApp_Application.h>
 
 #include <SVTK_ViewWindow.h>
 #include <SVTK_Selector.h>
 #include <SALOME_ListIO.hxx>
+#include <VTKViewer_CellLocationsArray.h>
 
 // OCCT includes
 #include <TColStd_MapOfInteger.hxx>
@@ -68,6 +73,7 @@
 #include <QGridLayout>
 #include <QSpinBox>
 #include <QKeyEvent>
+#include <QMenu>
 
 // IDL includes
 #include <SALOMEconfig.h>
 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
   : QDialog( SMESH::GetDesktop( theModule ) ),
     mySMESHGUI( theModule ),
-    mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+    mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+    myVectorDefinition(NONE_SELECT),
+    myFilterDlg( 0 )
 {
+  mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
+
   SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
   QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
   QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
@@ -123,6 +133,8 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
   GroupArgumentsLayout->setSpacing(SPACING);
   GroupArgumentsLayout->setMargin(MARGIN);
 
+  myIdValidator = new SMESHGUI_IdValidator(this);
+
   // Controls for elements selection
   TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
 
@@ -130,7 +142,9 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
   SelectElementsButton->setIcon(image2);
 
   LineEditElements  = new QLineEdit(GroupArguments);
-  LineEditElements->setValidator(new SMESHGUI_IdValidator(this));
+  LineEditElements->setValidator(myIdValidator);
+  QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
+  connect(filterBtn,   SIGNAL(clicked()), this, SLOT(setFilters()));
 
   // Control for the whole mesh selection
   CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
@@ -184,18 +198,38 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
   GroupAxisLayout->addWidget(TextLabelDZ,        1, 6);
   GroupAxisLayout->addWidget(SpinBox_DZ,         1, 7);
 
-  // Controls for angle defining
-  TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupArguments);
-  SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments);
+  // Controls for angle defining & number of steps defining
+  GroupAngleBox = new QGroupBox(tr("SMESH_ANGLE"), GroupArguments);
+  GroupAngle = new QButtonGroup(GroupAngleBox);
+  QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngleBox);
+  GroupAngleLayout->setSpacing(6);
+  GroupAngleLayout->setMargin(11);
 
-  // Controls for nb. steps defining
-  TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupArguments);
-  SpinBox_NbSteps = new QSpinBox(GroupArguments);
+  RadioButton3 = new QRadioButton(tr("ANGLE_BY_STEP"), GroupAngleBox);
+  RadioButton4 = new QRadioButton(tr("TOTAL_ANGLE"),   GroupAngleBox);
+  GroupAngle->addButton(RadioButton3, 0);
+  GroupAngle->addButton(RadioButton4, 1);
+
+  TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupAngleBox);
+  SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
+
+  TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
+  SpinBox_NbSteps = new QSpinBox(GroupAngleBox);
+
+  GroupAngleLayout->addWidget(RadioButton3,     0, 0);
+  GroupAngleLayout->addWidget(RadioButton4,     0, 1);
+  GroupAngleLayout->addWidget(TextLabelAngle,   1, 0);
+  GroupAngleLayout->addWidget(SpinBox_Angle,    1, 1);
+  GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
+  GroupAngleLayout->addWidget(SpinBox_NbSteps,  2, 1);
 
   // Controls for tolerance defining
   TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupArguments);
   SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments);
 
+  // Control for mesh preview
+  CheckBoxPreview = new QCheckBox(tr("PREVIEW"), GroupArguments);
+
   // CheckBox for groups generation
   MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
   MakeGroupsCheck->setChecked(true);
@@ -203,15 +237,14 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
   GroupArgumentsLayout->addWidget(TextLabelElements,    0, 0);
   GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
   GroupArgumentsLayout->addWidget(LineEditElements,     0, 2);
-  GroupArgumentsLayout->addWidget(CheckBoxMesh,         1, 0, 1, 3);
-  GroupArgumentsLayout->addWidget(GroupAxis,            2, 0, 1, 3);
-  GroupArgumentsLayout->addWidget(TextLabelAngle,       3, 0, 1, 2);
-  GroupArgumentsLayout->addWidget(SpinBox_Angle,        3, 2);
-  GroupArgumentsLayout->addWidget(TextLabelNbSteps,     4, 0, 1, 2);
-  GroupArgumentsLayout->addWidget(SpinBox_NbSteps,      4, 2);
-  GroupArgumentsLayout->addWidget(TextLabelTolerance,   5, 0, 1, 2);
-  GroupArgumentsLayout->addWidget(SpinBox_Tolerance,    5, 2);
-  GroupArgumentsLayout->addWidget(MakeGroupsCheck,      6, 0, 1, 3);
+  GroupArgumentsLayout->addWidget(filterBtn,            0, 3);
+  GroupArgumentsLayout->addWidget(CheckBoxMesh,         1, 0, 1, 4);
+  GroupArgumentsLayout->addWidget(GroupAxis,            2, 0, 1, 4);
+  GroupArgumentsLayout->addWidget(GroupAngleBox,        3, 0, 1, 4);
+  GroupArgumentsLayout->addWidget(TextLabelTolerance,   4, 0, 1, 2);
+  GroupArgumentsLayout->addWidget(SpinBox_Tolerance,    4, 2, 1, 2);
+  GroupArgumentsLayout->addWidget(CheckBoxPreview,      5, 0, 1, 4);
+  GroupArgumentsLayout->addWidget(MakeGroupsCheck,      6, 0, 1, 4);
 
   /***************************************************************/
   GroupButtons = new QGroupBox(this);
@@ -219,7 +252,7 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
   GroupButtonsLayout->setSpacing(SPACING);
   GroupButtonsLayout->setMargin(MARGIN);
   
-  buttonOk = new QPushButton(tr("SMESH_BUT_OK"), GroupButtons);
+  buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
   buttonOk->setAutoDefault(true);
   buttonOk->setDefault(true);
   buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
@@ -250,11 +283,13 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
   SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
   SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
 
+  RadioButton3->setChecked(true);
+
   SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3);
 
   SpinBox_NbSteps->setRange(1, 999999);
 
-  SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.1, 6);
+  SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, 6);
 
   RadioButton1->setChecked(true);
 
@@ -277,6 +312,12 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
 
   Init();
 
+  /*Create menu to vector selection*/
+  SelectVectorMenu = new QMenu(this);
+  myMenuActions[SelectVectorMenu->addAction( tr( "MEN_POINT_SELECT" ) )] = POINT_SELECT;
+  myMenuActions[SelectVectorMenu->addAction( tr( "MEN_FACE_SELECT" ) )] = FACE_SELECT;
+  connect( SelectVectorMenu, SIGNAL( triggered( QAction* ) ), SLOT( onSelectVectorMenu( QAction* ) ) );
+
   /* signals and slots connections */
   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
@@ -286,7 +327,11 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
 
   connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
   connect(SelectPointButton,    SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
-  connect(SelectVectorButton,   SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+  connect(SelectVectorButton,   SIGNAL(clicked()), this, SLOT(onSelectVectorButton()));
+
+  connect(SpinBox_X,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
+  connect(SpinBox_Y,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
+  connect(SpinBox_Z,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
 
   connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
   connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
@@ -299,6 +344,12 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
   connect(LineEditElements, SIGNAL(textChanged(const QString&)),   SLOT(onTextChange(const QString&)));
   connect(CheckBoxMesh,     SIGNAL(toggled(bool)),                 SLOT(onSelectMesh(bool)));
 
+  connect(GroupAngle,        SIGNAL(buttonClicked(int)),   this, SLOT(toDisplaySimulation()));
+  connect(SpinBox_Angle,     SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
+  connect(SpinBox_NbSteps,   SIGNAL(valueChanged(int)),    this, SLOT(toDisplaySimulation()));
+  connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
+  connect(CheckBoxPreview,   SIGNAL(toggled(bool)),        this, SLOT(onDisplaySimulation(bool)));
+
   ConstructorsClicked(0);
   SelectionIntoArgument();
 }
@@ -309,7 +360,12 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
 //=================================================================================
 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
 {
-  // no need to delete child widgets, Qt does it all for us
+  delete mySimulation;
+  if ( myFilterDlg ) {
+    myFilterDlg->setParent( 0 );
+    delete myFilterDlg;
+    myFilterDlg = 0;
+  }
 }
 
 //=================================================================================
@@ -342,6 +398,8 @@ void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
 
     CheckBoxMesh->setChecked(false);
     onSelectMesh(false);
+    CheckBoxPreview->setChecked(false);
+    onDisplaySimulation(false);
   }
 }
 
@@ -351,7 +409,17 @@ void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
 //=================================================================================
 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
 {
-  disconnect(mySelectionMgr, 0, this, 0);
+  //disconnect(mySelectionMgr, 0, this, 0);
+
+  SALOME_ListIO io;
+  mySelectionMgr->selectedObjects( io );
+  SALOME_ListIO aList;
+  mySelectionMgr->setSelectedObjects( aList );
+//   LineEditElements->clear();
+  myNbOkElements = 0;
+  buttonApply->setEnabled(false);
+  buttonOk->setEnabled(false);
+  mySimulation->SetVisibility(false);
 
   Selection_Mode aSelMode = ActorSelection;
 
@@ -386,7 +454,8 @@ void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
   if (CheckBoxMesh->isChecked())
     onSelectMesh(true);
 
-  connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  //connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  mySelectionMgr->setSelectedObjects( io );
 }
 
 //=================================================================================
@@ -420,18 +489,19 @@ void SMESHGUI_RevolutionDlg::ClickOnApply()
     long aNbSteps = (long)SpinBox_NbSteps->value();
     double aTolerance = SpinBox_Tolerance->GetValue();
 
+    if ( GroupAngle->checkedId() == 1 )
+      anAngle = anAngle/aNbSteps;
+
     try {
+      SUIT_OverrideCursor aWaitCursor;
       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
-      QApplication::setOverrideCursor(Qt::WaitCursor);
-
+      
       if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
         SMESH::ListOfGroups_var groups = 
           aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
                                                anAngle, aNbSteps, aTolerance);
       else
         aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
-
-      QApplication::restoreOverrideCursor();
     } catch (...) {
     }
 
@@ -463,7 +533,10 @@ void SMESHGUI_RevolutionDlg::ClickOnCancel()
   disconnect(mySelectionMgr, 0, this, 0);
   mySelectionMgr->clearFilters();
   //mySelectionMgr->clearSelected();
-  SMESH::SetPointRepresentation(false);
+  if (SMESH::GetCurrentVtkView()) {
+    SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
+    SMESH::SetPointRepresentation(false);
+  }
   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
     aViewWindow->SetSelectionMode(ActorSelection);
   mySMESHGUI->ResetState();
@@ -543,6 +616,7 @@ void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
     buttonOk->setEnabled(true);
     buttonApply->setEnabled(true);
   }
+  onDisplaySimulation(true);
 
   myBusy = false;
 }
@@ -676,30 +750,57 @@ void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
 
     myNbOkElements = true;
   } else {
-    aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
-    if (aNbUnits != 1)
-      return;
 
     SMDS_Mesh* aMesh =  myActor->GetObject()->GetMesh();
     if (!aMesh)
       return;
 
-    const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
-    if (!n)
+    bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
+                           (myEditCurrentArgument == (QWidget*)SpinBox_DX && 
+                            myVectorDefinition==POINT_SELECT));
+
+    bool isFaceSelected = (myEditCurrentArgument == (QWidget*)SpinBox_DX && 
+                           myVectorDefinition==FACE_SELECT);
+
+    if(isNodeSelected) {
+      aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
+    }
+    else if(isFaceSelected){
+      aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
+    }
+    
+    if (aNbUnits != 1)
       return;
 
-    double x = n->X();
-    double y = n->Y();
-    double z = n->Z();
-
-    if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
-      SpinBox_X->SetValue(x);
-      SpinBox_Y->SetValue(y);
-      SpinBox_Z->SetValue(z);
-    } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
-      SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
-      SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
-      SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
+    if(isNodeSelected) {
+      const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
+      if (!n)
+        return;
+
+      double x = n->X();
+      double y = n->Y();
+      double z = n->Z();
+
+      if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
+        SpinBox_X->SetValue(x);
+        SpinBox_Y->SetValue(y);
+        SpinBox_Z->SetValue(z);
+      } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
+        SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
+        SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
+        SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
+      }
+    }
+    else if(isFaceSelected){
+      const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aString.toInt()));
+      if (!face)
+        return;
+      
+      gp_XYZ aNormale = SMESH::getNormale(face);
+      SpinBox_DX->SetValue(aNormale.X());
+      SpinBox_DY->SetValue(aNormale.Y());
+      SpinBox_DZ->SetValue(aNormale.Z());
+      
     }
   }
 
@@ -713,6 +814,8 @@ void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
     buttonOk->setEnabled(true);
     buttonApply->setEnabled(true);
   }
+
+  onDisplaySimulation(true);
 }
 
 //=================================================================================
@@ -728,6 +831,7 @@ void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
   mySelectionMgr->clearFilters();
 
   if (send == SelectElementsButton) {
+    mySimulation->SetVisibility(false);
     myEditCurrentArgument = (QWidget*)LineEditElements;
     SMESH::SetPointRepresentation(false);
     if (CheckBoxMesh->isChecked()) {
@@ -752,12 +856,6 @@ void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
     SMESH::SetPointRepresentation(true);
     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
       aViewWindow->SetSelectionMode(NodeSelection);
-  } else if (send == SelectVectorButton) {
-    myEditCurrentArgument = (QWidget*)SpinBox_DX;
-    SMESH::SetPointRepresentation(true);
-    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-      aViewWindow->SetSelectionMode(NodeSelection);
-  } else {
   }
 
   myEditCurrentArgument->setFocus();
@@ -841,6 +939,7 @@ void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
 
   if (myEditCurrentArgument != LineEditElements) {
     LineEditElements->clear();
+    mySimulation->SetVisibility(false);
     return;
   }
 
@@ -852,6 +951,7 @@ void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
       aViewWindow->SetSelectionMode(ActorSelection);
     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
     LineEditElements->setReadOnly(true);
+    LineEditElements->setValidator(0);
   } else {
     int aConstructorId = GetConstructorId();
     if (aConstructorId == 0)
@@ -866,7 +966,9 @@ void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
       }
 
     LineEditElements->setReadOnly(false);
+    LineEditElements->setValidator(myIdValidator);
     onTextChange(LineEditElements->text());
+    mySimulation->SetVisibility(false);
   }
 
   SelectionIntoArgument();
@@ -905,6 +1007,7 @@ void SMESHGUI_RevolutionDlg::onVectorChanged()
     buttonOk->setEnabled(false);
     buttonApply->setEnabled(false);
   }
+  onDisplaySimulation(true);
 }
 
 //=================================================================================
@@ -922,3 +1025,132 @@ void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
     ClickOnHelp();
   }
 }
+
+//=================================================================================
+// function : toDisplaySimulation()
+// purpose  :
+//=================================================================================
+void SMESHGUI_RevolutionDlg::toDisplaySimulation()
+{
+  onDisplaySimulation(true);
+}
+
+//=================================================================================
+// function : onDisplaySimulation()
+// purpose  :
+//=================================================================================
+void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
+{
+  if (CheckBoxPreview->isChecked() && toDisplayPreview)
+  {
+    //display preview
+    if (myNbOkElements && IsAxisOk())
+    {
+      QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
+      
+      SMESH::long_array_var anElementsId = new SMESH::long_array;
+      
+      anElementsId->length(aListElementsId.count());
+      for (int i = 0; i < aListElementsId.count(); i++)
+       anElementsId[i] = aListElementsId[i].toInt();
+      
+      SMESH::AxisStruct anAxis;
+      
+      anAxis.x =  SpinBox_X->GetValue();
+      anAxis.y =  SpinBox_Y->GetValue();
+      anAxis.z =  SpinBox_Z->GetValue();
+      anAxis.vx = SpinBox_DX->GetValue();
+      anAxis.vy = SpinBox_DY->GetValue();
+      anAxis.vz = SpinBox_DZ->GetValue();
+      
+      double anAngle = (SpinBox_Angle->GetValue())*PI/180;
+      long aNbSteps = (long)SpinBox_NbSteps->value();
+      double aTolerance = SpinBox_Tolerance->GetValue();
+      
+      if (GroupAngle->checkedId() == 1)
+       anAngle = anAngle/aNbSteps;
+      
+      try {
+       SUIT_OverrideCursor aWaitCursor;
+       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
+       aMeshEditor->RotationSweep(anElementsId.inout(), 
+                                  anAxis, 
+                                  anAngle, 
+                                  aNbSteps, 
+                                  aTolerance);
+       SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
+       mySimulation->SetData(aMeshPreviewStruct._retn());
+      } catch (...) {}
+    }
+    else
+    {
+      mySimulation->SetVisibility(false);
+    }
+  }
+  else
+  {
+    //erase preview
+    mySimulation->SetVisibility(false);
+  }
+}
+
+//=================================================================================
+// function : onSelectVectorButton()
+// purpose  : [slot]
+//=================================================================================
+void SMESHGUI_RevolutionDlg::onSelectVectorButton(){
+  if(SelectVectorMenu) {
+    SelectVectorMenu->exec( QCursor::pos() );
+  }
+}
+
+//=================================================================================
+// function : onSelectVectorMenu()
+// purpose  : [slot]
+//=================================================================================
+void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action){
+  if(!action)
+    return;
+
+  switch(myMenuActions[action]) {
+  case POINT_SELECT: 
+    SMESH::SetPointRepresentation(true);
+    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      aViewWindow->SetSelectionMode(NodeSelection);
+    break;
+    
+  case FACE_SELECT: 
+    SMESH::SetPointRepresentation(false);
+    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      aViewWindow->SetSelectionMode(FaceSelection);
+    break;
+  }
+
+  myVectorDefinition = myMenuActions[action];
+  myEditCurrentArgument = (QWidget*)SpinBox_DX;
+  myEditCurrentArgument->setFocus();
+  connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : setFilters()
+// purpose  : SLOT. Called when "Filter" button pressed.
+//=================================================================================
+void SMESHGUI_RevolutionDlg::setFilters()
+{
+  if ( !myFilterDlg )
+  {
+    QList<int> types;  
+    types.append( SMESH::EDGE );
+    types.append( SMESH::FACE );
+    myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
+  }
+  myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE );
+
+  myFilterDlg->SetSelection();
+  myFilterDlg->SetMesh( myMesh );
+  myFilterDlg->SetSourceWg( LineEditElements );
+
+  myFilterDlg->show();
+}