Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ClippingDlg.cxx
index 7770056ac61d92c549a69fbbe99a501b8a1a9511..1364b265d38a9436f9cea024343d8fb936f8d5dd 100644 (file)
@@ -1,6 +1,6 @@
-//  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,
+//  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
 //  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+// SMESH SMESHGUI : GUI for SMESH component
+// File   : SMESHGUI_ClippingDlg.cxx
+// Author : Nicolas REJNERI, Open CASCADE S.A.S.
+// SMESH includes
 //
-//
-//  File   : SMESHGUI_ClippingDlg.cxx
-//  Author : Nicolas REJNERI
-//  Module : SMESH
-//  $Header$
-
 #include "SMESHGUI_ClippingDlg.h"
 
 #include "SMESHGUI.h"
 #include "SMESHGUI_Utils.h"
 #include "SMESHGUI_VTKUtils.h"
+#include "SMESHGUI_SpinBox.h"
 
-#include "SMESH_Actor.h"
-#include "SMESH_ActorUtils.h"
+#include <SMESH_Actor.h>
+#include <SMESH_ActorUtils.h>
 
-#include "SUIT_Session.h"
-#include "SUIT_OverrideCursor.h"
-#include "SUIT_MessageBox.h"
+// SALOME GUI includes
+#include <SUIT_Desktop.h>
+#include <SUIT_Session.h>
+#include <SUIT_OverrideCursor.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_ResourceMgr.h>
 
-#include "SALOME_ListIO.hxx"
-#include "SALOME_InteractiveObject.hxx"
-#include "SALOME_ListIteratorOfListIO.hxx"
+#include <SALOME_ListIO.hxx>
 
-#include "LightApp_Application.h"
-#include "LightApp_SelectionMgr.h"
+#include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
 
-#include "SVTK_Selector.h"
-#include "SVTK_ViewWindow.h"
+#include <SVTK_ViewWindow.h>
 
-// QT Includes
-#include <qlabel.h>
-#include <qpushbutton.h>
-#include <qcombobox.h>
-#include <qcheckbox.h>
-#include <qlayout.h>
-#include <qgroupbox.h>
+// Qt includes
+#include <QLabel>
+#include <QPushButton>
+#include <QComboBox>
+#include <QCheckBox>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QKeyEvent>
 
-// VTK Includes
+// VTK includes
 #include <vtkMath.h>
-#include <vtkCamera.h>
-#include <vtkRenderer.h>
-#include <vtkImplicitBoolean.h>
-#include <vtkImplicitFunctionCollection.h>
-#include <vtkObjectFactory.h>
-
+#include <vtkPlane.h>
 #include <vtkDataSet.h>
 #include <vtkDataSetMapper.h>
 #include <vtkPlaneSource.h>
-#include <vtkPolyData.h>
-#include <vtkRenderer.h>
 #include <vtkProperty.h>
 
-// STL includes
-#include <algorithm>
-
-using namespace std;
-
+#define SPACING 6
+#define MARGIN  11
 
 class OrientedPlane: public vtkPlane
 {
@@ -182,7 +174,8 @@ protected:
     myMapper->RemoveAllInputs();
     myMapper->Delete();
 
-    myPlaneSource->UnRegisterAllOutputs();
+    // commented: porting to vtk 5.0
+    //    myPlaneSource->UnRegisterAllOutputs();
     myPlaneSource->Delete();
   };
 
@@ -201,147 +194,244 @@ struct TSetVisiblity {
   int myIsVisible;
 };
 
+//=================================================================================
+// used in SMESHGUI::restoreVisualParameters() to avoid
+// declaration of OrientedPlane outside of SMESHGUI_ClippingDlg.cxx
+//=================================================================================
+void SMESHGUI_ClippingDlg::AddPlane (SMESH_Actor*         theActor,
+                                     SVTK_ViewWindow*     theViewWindow,
+                                     SMESH::Orientation   theOrientation,
+                                     double               theDistance,
+                                     vtkFloatingPointType theAngle[2])
+{
+  OrientedPlane* aPlane = OrientedPlane::New(theViewWindow);
+
+  aPlane->myAngle[0] = theAngle[0];
+  aPlane->myAngle[1] = theAngle[1];
+
+  aPlane->SetOrientation(theOrientation);
+  aPlane->SetDistance(theDistance);
+
+  vtkFloatingPointType aNormal[3];
+  vtkFloatingPointType aDir[2][3] = {{0, 0, 0}, {0, 0, 0}};
+  {
+    static double aCoeff = vtkMath::Pi()/180.0;
+
+    vtkFloatingPointType anU[2] = {cos(aCoeff * theAngle[0]), cos(aCoeff * theAngle[1])};
+    vtkFloatingPointType aV[2] = {sqrt(1.0 - anU[0]*anU[0]), sqrt(1.0 - anU[1]*anU[1])};
+    aV[0] = theAngle[0] > 0? aV[0]: -aV[0];
+    aV[1] = theAngle[1] > 0? aV[1]: -aV[1];
+
+    switch (theOrientation) {
+    case SMESH::XY:
+      aDir[0][1] = anU[0];
+      aDir[0][2] = aV[0];
+
+      aDir[1][0] = anU[1];
+      aDir[1][2] = aV[1];
+
+      break;
+    case SMESH::YZ:
+      aDir[0][2] = anU[0];
+      aDir[0][0] = aV[0];
+
+      aDir[1][1] = anU[1];
+      aDir[1][0] = aV[1];
+
+      break;
+    case SMESH::ZX:
+      aDir[0][0] = anU[0];
+      aDir[0][1] = aV[0];
+
+      aDir[1][2] = anU[1];
+      aDir[1][1] = aV[1];
+
+      break;
+    }
+
+    vtkMath::Cross(aDir[1],aDir[0],aNormal);
+    vtkMath::Normalize(aNormal);
+    vtkMath::Cross(aNormal,aDir[1],aDir[0]);
+  }
+
+  // ???
+  theActor->SetPlaneParam(aNormal, theDistance, aPlane);
+
+  vtkDataSet* aDataSet = theActor->GetInput();
+  vtkFloatingPointType *aPnt = aDataSet->GetCenter();
+
+  vtkFloatingPointType* anOrigin = aPlane->GetOrigin();
+  vtkFloatingPointType aDel = aDataSet->GetLength()/2.0;
+
+  vtkFloatingPointType aDelta[2][3] = {{aDir[0][0]*aDel, aDir[0][1]*aDel, aDir[0][2]*aDel},
+                                       {aDir[1][0]*aDel, aDir[1][1]*aDel, aDir[1][2]*aDel}};
+  vtkFloatingPointType aParam, aPnt0[3], aPnt1[3], aPnt2[3];
+
+  vtkFloatingPointType aPnt01[3] = {aPnt[0] - aDelta[0][0] - aDelta[1][0],
+                                    aPnt[1] - aDelta[0][1] - aDelta[1][1],
+                                    aPnt[2] - aDelta[0][2] - aDelta[1][2]};
+  vtkFloatingPointType aPnt02[3] = {aPnt01[0] + aNormal[0],
+                                    aPnt01[1] + aNormal[1],
+                                    aPnt01[2] + aNormal[2]};
+  vtkPlane::IntersectWithLine(aPnt01,aPnt02,aNormal,anOrigin,aParam,aPnt0);
+
+  vtkFloatingPointType aPnt11[3] = {aPnt[0] - aDelta[0][0] + aDelta[1][0],
+                                    aPnt[1] - aDelta[0][1] + aDelta[1][1],
+                                    aPnt[2] - aDelta[0][2] + aDelta[1][2]};
+  vtkFloatingPointType aPnt12[3] = {aPnt11[0] + aNormal[0],
+                                    aPnt11[1] + aNormal[1],
+                                    aPnt11[2] + aNormal[2]};
+  vtkPlane::IntersectWithLine(aPnt11,aPnt12,aNormal,anOrigin,aParam,aPnt1);
+
+  vtkFloatingPointType aPnt21[3] = {aPnt[0] + aDelta[0][0] - aDelta[1][0],
+                                    aPnt[1] + aDelta[0][1] - aDelta[1][1],
+                                    aPnt[2] + aDelta[0][2] - aDelta[1][2]};
+  vtkFloatingPointType aPnt22[3] = {aPnt21[0] + aNormal[0],
+                                    aPnt21[1] + aNormal[1],
+                                    aPnt21[2] + aNormal[2]};
+  vtkPlane::IntersectWithLine(aPnt21,aPnt22,aNormal,anOrigin,aParam,aPnt2);
+
+  vtkPlaneSource* aPlaneSource = aPlane->myPlaneSource;
+  aPlaneSource->SetNormal(aNormal[0],aNormal[1],aNormal[2]);
+  aPlaneSource->SetOrigin(aPnt0[0],aPnt0[1],aPnt0[2]);
+  aPlaneSource->SetPoint1(aPnt1[0],aPnt1[1],aPnt1[2]);
+  aPlaneSource->SetPoint2(aPnt2[0],aPnt2[1],aPnt2[2]);
+
+  theActor->AddClippingPlane(aPlane);
+  aPlane->Delete();
+}
+
+//=================================================================================
+// used in SMESHGUI::restoreVisualParameters() to avoid
+// declaration of OrientedPlane outside of SMESHGUI_ClippingDlg.cxx
+//=================================================================================
+void SMESHGUI_ClippingDlg::GetPlaneParam (SMESH_Actor*          theActor,
+                                          int                   thePlaneIndex,
+                                          SMESH::Orientation&   theOrientation,
+                                          double&               theDistance,
+                                          vtkFloatingPointType* theAngle)
+{
+  if (vtkPlane* aPln = theActor->GetClippingPlane(thePlaneIndex)) {
+    if (OrientedPlane* aPlane = OrientedPlane::SafeDownCast(aPln)) {
+      theOrientation = aPlane->GetOrientation();
+      theDistance = aPlane->GetDistance();
+      theAngle[0] = aPlane->myAngle[0];
+      theAngle[1] = aPlane->myAngle[1];
+    }
+  }
+}
+
 //=================================================================================
 // class    : SMESHGUI_ClippingDlg()
 // purpose  :
 //
 //=================================================================================
-SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg (SMESHGUI* theModule,
-                                           const char* name,
-                                           bool modal,
-                                           WFlags fl):
-  QDialog(SMESH::GetDesktop(theModule),
-         name, 
-         modal, 
-         WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
+SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg( SMESHGUI* theModule ):
+  QDialog( SMESH::GetDesktop(theModule) ),
   mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
   mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
   mySMESHGUI(theModule)
 {
-  if (!name)
-    setName("SMESHGUI_ClippingDlg");
-  setCaption(tr("SMESH_CLIPPING_TITLE"));
-  setSizeGripEnabled(TRUE);
-  QGridLayout* SMESHGUI_ClippingDlgLayout = new QGridLayout(this);
-  SMESHGUI_ClippingDlgLayout->setSpacing(6);
-  SMESHGUI_ClippingDlgLayout->setMargin(11);
+  setModal( false );
+  setAttribute( Qt::WA_DeleteOnClose, true );
+  setWindowTitle(tr("SMESH_CLIPPING_TITLE"));
+  setSizeGripEnabled(true);
+
+  QVBoxLayout* SMESHGUI_ClippingDlgLayout = new QVBoxLayout(this);
+  SMESHGUI_ClippingDlgLayout->setSpacing(SPACING);
+  SMESHGUI_ClippingDlgLayout->setMargin(MARGIN);
 
   // Controls for selecting, creating, deleting planes
-  QGroupBox* GroupPlanes = new QGroupBox (this, "GroupPlanes");
-  GroupPlanes->setTitle(tr("Clipping planes"));
-  GroupPlanes->setColumnLayout(0, Qt::Vertical);
-  GroupPlanes->layout()->setSpacing(0);
-  GroupPlanes->layout()->setMargin(0);
-  QGridLayout* GroupPlanesLayout = new QGridLayout (GroupPlanes->layout());
-  GroupPlanesLayout->setAlignment(Qt::AlignTop);
-  GroupPlanesLayout->setSpacing(6);
-  GroupPlanesLayout->setMargin(11);
-
-  ComboBoxPlanes = new QComboBox(GroupPlanes, "ComboBoxPlanes");
-  GroupPlanesLayout->addWidget(ComboBoxPlanes, 0, 0);
-
-  QSpacerItem* spacerGP = new QSpacerItem (20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
-  GroupPlanesLayout->addItem(spacerGP, 0, 1);
-
-  buttonNew = new QPushButton (GroupPlanes, "buttonNew");
-  buttonNew->setText(tr("SMESH_BUT_NEW"));
-  GroupPlanesLayout->addWidget(buttonNew, 0, 2);
-
-  buttonDelete = new QPushButton (GroupPlanes, "buttonDelete");
-  buttonDelete->setText(tr("SMESH_BUT_DELETE"));
-  GroupPlanesLayout->addWidget(buttonDelete, 0, 3);
+  QGroupBox* GroupPlanes = new QGroupBox(tr("Clipping planes"), this);
+  QHBoxLayout* GroupPlanesLayout = new QHBoxLayout(GroupPlanes);
+  GroupPlanesLayout->setSpacing(SPACING);
+  GroupPlanesLayout->setMargin(MARGIN);
+
+  ComboBoxPlanes = new QComboBox(GroupPlanes);
+
+  buttonNew = new QPushButton(tr("SMESH_BUT_NEW"), GroupPlanes);
+
+  buttonDelete = new QPushButton(tr("SMESH_BUT_DELETE"), GroupPlanes);
+
+  GroupPlanesLayout->addWidget(ComboBoxPlanes);
+  GroupPlanesLayout->addStretch();
+  GroupPlanesLayout->addWidget(buttonNew);
+  GroupPlanesLayout->addWidget(buttonDelete);
 
   // Controls for defining plane parameters
-  QGroupBox* GroupParameters = new QGroupBox (this, "GroupParameters");
-  GroupParameters->setTitle(tr("SMESH_PARAMETERS"));
-  GroupParameters->setColumnLayout(0, Qt::Vertical);
-  GroupParameters->layout()->setSpacing(0);
-  GroupParameters->layout()->setMargin(0);
-  QGridLayout* GroupParametersLayout = new QGridLayout (GroupParameters->layout());
-  GroupParametersLayout->setAlignment(Qt::AlignTop);
-  GroupParametersLayout->setSpacing(6);
-  GroupParametersLayout->setMargin(11);
-
-  TextLabelOrientation = new QLabel(GroupParameters, "TextLabelOrientation");
-  TextLabelOrientation->setText(tr("SMESH_ORIENTATION"));
-  GroupParametersLayout->addWidget(TextLabelOrientation, 0, 0);
+  QGroupBox* GroupParameters = new QGroupBox(tr("SMESH_PARAMETERS"), this);
+  QGridLayout* GroupParametersLayout = new QGridLayout(GroupParameters);
+  GroupParametersLayout->setSpacing(SPACING);
+  GroupParametersLayout->setMargin(MARGIN);
+
+  TextLabelOrientation = new QLabel(tr("SMESH_ORIENTATION"), GroupParameters);
 
-  ComboBoxOrientation = new QComboBox(GroupParameters, "ComboBoxOrientation");
-  GroupParametersLayout->addWidget(ComboBoxOrientation, 0, 1);
+  ComboBoxOrientation = new QComboBox(GroupParameters);
 
-  TextLabelDistance = new QLabel(GroupParameters, "TextLabelDistance");
-  TextLabelDistance->setText(tr("SMESH_DISTANCE"));
-  GroupParametersLayout->addWidget(TextLabelDistance, 1, 0);
+  TextLabelDistance = new QLabel(tr("SMESH_DISTANCE"), GroupParameters);
 
-  SpinBoxDistance = new SMESHGUI_SpinBox(GroupParameters, "SpinBoxDistance");
-  GroupParametersLayout->addWidget(SpinBoxDistance, 1, 1);
+  SpinBoxDistance = new SMESHGUI_SpinBox(GroupParameters);
 
-  TextLabelRot1 = new QLabel(GroupParameters, "TextLabelRot1");
-  TextLabelRot1->setText(tr("Rotation around X (Y to Z):"));
-  GroupParametersLayout->addWidget(TextLabelRot1, 2, 0);
+  TextLabelRot1 = new QLabel(tr("Rotation around X (Y to Z):"), GroupParameters);
 
-  SpinBoxRot1 = new SMESHGUI_SpinBox(GroupParameters, "SpinBoxRot1");
-  GroupParametersLayout->addWidget(SpinBoxRot1, 2, 1);
+  SpinBoxRot1 = new SMESHGUI_SpinBox(GroupParameters);
 
-  TextLabelRot2 = new QLabel(GroupParameters, "TextLabelRot2");
-  TextLabelRot2->setText(tr("Rotation around Y (X to Z):"));
-  GroupParametersLayout->addWidget(TextLabelRot2, 3, 0);
+  TextLabelRot2 = new QLabel(tr("Rotation around Y (X to Z):"), GroupParameters);
 
-  SpinBoxRot2 = new SMESHGUI_SpinBox(GroupParameters, "SpinBoxRot2");
-  GroupParametersLayout->addWidget(SpinBoxRot2, 3, 1);
+  SpinBoxRot2 = new SMESHGUI_SpinBox(GroupParameters);
 
   PreviewCheckBox = new QCheckBox(tr("Show preview"), GroupParameters);
   PreviewCheckBox->setChecked(true);
-  GroupParametersLayout->addWidget(PreviewCheckBox, 4, 0);
 
   AutoApplyCheckBox = new QCheckBox(tr("Auto Apply"), GroupParameters);
   AutoApplyCheckBox->setChecked(false);
-  GroupParametersLayout->addWidget(AutoApplyCheckBox, 4, 1);
+
+  GroupParametersLayout->addWidget(TextLabelOrientation, 0, 0);
+  GroupParametersLayout->addWidget(ComboBoxOrientation,  0, 1);
+  GroupParametersLayout->addWidget(TextLabelDistance,    1, 0);
+  GroupParametersLayout->addWidget(SpinBoxDistance,      1, 1);
+  GroupParametersLayout->addWidget(TextLabelRot1,        2, 0);
+  GroupParametersLayout->addWidget(SpinBoxRot1,          2, 1);
+  GroupParametersLayout->addWidget(TextLabelRot2,        3, 0);
+  GroupParametersLayout->addWidget(SpinBoxRot2,          3, 1);
+  GroupParametersLayout->addWidget(PreviewCheckBox,      4, 0);
+  GroupParametersLayout->addWidget(AutoApplyCheckBox,    4, 1);
 
   // Controls for "Ok", "Apply" and "Close" button
-  QGroupBox* GroupButtons = new QGroupBox(this, "GroupButtons");
-  GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth()));
-  GroupButtons->setGeometry(QRect(10, 10, 281, 48));
-  GroupButtons->setTitle(tr("" ));
-  GroupButtons->setColumnLayout(0, Qt::Vertical);
-  GroupButtons->layout()->setSpacing(0);
-  GroupButtons->layout()->setMargin(0);
-  QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
-  GroupButtonsLayout->setAlignment(Qt::AlignTop);
-  GroupButtonsLayout->setSpacing(6);
-  GroupButtonsLayout->setMargin(11);
-  buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
-  buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
-  buttonCancel->setAutoDefault(TRUE);
-  GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
-  buttonApply = new QPushButton(GroupButtons, "buttonApply");
-  buttonApply->setText(tr("SMESH_BUT_APPLY" ));
-  buttonApply->setAutoDefault(TRUE);
-  GroupButtonsLayout->addWidget(buttonApply, 0, 1);
-  QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
-  GroupButtonsLayout->addItem(spacer_9, 0, 2);
-  buttonOk = new QPushButton(GroupButtons, "buttonOk");
-  buttonOk->setText(tr("SMESH_BUT_OK" ));
-  buttonOk->setAutoDefault(TRUE);
-  buttonOk->setDefault(TRUE);
-  GroupButtonsLayout->addWidget(buttonOk, 0, 0);
-  buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
-  buttonHelp->setText(tr("SMESH_BUT_HELP" ));
-  buttonHelp->setAutoDefault(TRUE);
-  GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
-
-  SMESHGUI_ClippingDlgLayout->addWidget(GroupPlanes,      0, 0);
-  SMESHGUI_ClippingDlgLayout->addWidget(GroupParameters,  1, 0);
-  SMESHGUI_ClippingDlgLayout->addWidget(GroupButtons,     2, 0);
+  QGroupBox* GroupButtons = new QGroupBox(this);
+  QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
+  GroupButtonsLayout->setSpacing(SPACING);
+  GroupButtonsLayout->setMargin(MARGIN);
+  
+  buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
+  buttonOk->setAutoDefault(true);
+  buttonOk->setDefault(true);
+  buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
+  buttonApply->setAutoDefault(true);
+  buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
+  buttonCancel->setAutoDefault(true);
+  buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
+  buttonHelp->setAutoDefault(true);
+  GroupButtonsLayout->addWidget(buttonOk);
+  GroupButtonsLayout->addSpacing(10);
+  GroupButtonsLayout->addWidget(buttonApply);
+  GroupButtonsLayout->addSpacing(10);
+  GroupButtonsLayout->addStretch();
+  GroupButtonsLayout->addWidget(buttonCancel);
+  GroupButtonsLayout->addWidget(buttonHelp);
+
+  SMESHGUI_ClippingDlgLayout->addWidget(GroupPlanes);
+  SMESHGUI_ClippingDlgLayout->addWidget(GroupParameters);
+  SMESHGUI_ClippingDlgLayout->addWidget(GroupButtons);
 
   // Initial state
   SpinBoxDistance->RangeStepAndValidator(0.0, 1.0, 0.01, 3);
   SpinBoxRot1->RangeStepAndValidator(-180.0, 180.0, 1, 3);
   SpinBoxRot2->RangeStepAndValidator(-180.0, 180.0, 1, 3);
 
-  ComboBoxOrientation->insertItem(tr("|| X-Y"));
-  ComboBoxOrientation->insertItem(tr("|| Y-Z"));
-  ComboBoxOrientation->insertItem(tr("|| Z-X"));
+  ComboBoxOrientation->addItem(tr("|| X-Y"));
+  ComboBoxOrientation->addItem(tr("|| Y-Z"));
+  ComboBoxOrientation->addItem(tr("|| Z-X"));
 
   SpinBoxDistance->SetValue(0.5);
 
@@ -349,7 +439,7 @@ SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg (SMESHGUI* theModule,
   myIsSelectPlane = false;
   onSelectionChanged();
 
-  myHelpFileName = "clipping.htm";
+  myHelpFileName = "clipping_page.html";
 
   // signals and slots connections :
   connect(ComboBoxPlanes, SIGNAL(activated(int)), this, SLOT(onSelectPlane(int)));
@@ -365,7 +455,7 @@ SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg (SMESHGUI* theModule,
   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
   connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
   connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
-  connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnOk()));
+  connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
   connect(mySelectionMgr,  SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged()));
   /* to close dialog if study frame change */
   connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), this, SLOT(ClickOnCancel()));
@@ -381,7 +471,29 @@ SMESHGUI_ClippingDlg::~SMESHGUI_ClippingDlg()
 {
   // no need to delete child widgets, Qt does it all for us
   std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false));
-  SMESH::RenderViewWindow(SMESH::GetViewWindow(mySMESHGUI));
+  if (mySMESHGUI)
+    if (SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow(mySMESHGUI))
+      SMESH::RenderViewWindow(aViewWindow);
+}
+
+double SMESHGUI_ClippingDlg::getDistance() const
+{
+  return SpinBoxDistance->GetValue();
+}
+
+void SMESHGUI_ClippingDlg::setDistance( const double theDistance )
+{
+  SpinBoxDistance->SetValue( theDistance );
+}
+
+double SMESHGUI_ClippingDlg::getRotation1() const
+{
+  return SpinBoxRot1->GetValue();
+}
+
+double SMESHGUI_ClippingDlg::getRotation2() const
+{
+  return SpinBoxRot2->GetValue();
 }
 
 //=======================================================================
@@ -403,7 +515,7 @@ void SMESHGUI_ClippingDlg::ClickOnApply()
     myActor->RemoveAllClippingPlanes();
 
     SMESH::TPlanes::iterator anIter = myPlanes.begin();
-    for (; anIter != myPlanes.end(); anIter++) {
+    for ( ; anIter != myPlanes.end(); anIter++) {
       OrientedPlane* anOrientedPlane = OrientedPlane::New(aViewWindow);
       anOrientedPlane->ShallowCopy(anIter->GetPointer());
       myActor->AddClippingPlane(anOrientedPlane);
@@ -443,10 +555,17 @@ void SMESHGUI_ClippingDlg::ClickOnHelp()
   if (app) 
     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
   else {
-    SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
-                          QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
-                          arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
-                          QObject::tr("BUT_OK"));
+                QString platform;
+#ifdef WIN32
+                platform = "winapplication";
+#else
+                platform = "application";
+#endif
+    SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
+                             tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+                             arg(app->resourceMgr()->stringValue("ExternalBrowser", 
+                                                                 platform)).
+                             arg(myHelpFileName));
   }
 }
 
@@ -462,24 +581,24 @@ void SMESHGUI_ClippingDlg::onSelectionChanged()
       Handle(SALOME_InteractiveObject) IOS = aList.First();
       myActor = SMESH::FindActorByEntry(IOS->getEntry());
       if (myActor) {
-       std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false));
-       myPlanes.clear();
-
-       vtkIdType anId = 0, anEnd = myActor->GetNumberOfClippingPlanes();
-       for (; anId < anEnd; anId++) {
-         if (vtkImplicitFunction* aFunction = myActor->GetClippingPlane(anId)) {
-           if(OrientedPlane* aPlane = OrientedPlane::SafeDownCast(aFunction)){
-             OrientedPlane* anOrientedPlane = OrientedPlane::New(aViewWindow);
-             SMESH::TVTKPlane aTVTKPlane(anOrientedPlane);
-             anOrientedPlane->Delete();
-             aTVTKPlane->ShallowCopy(aPlane);
-             myPlanes.push_back(aTVTKPlane);
-           }
-         }
-       }
-
-       std::for_each(myPlanes.begin(),myPlanes.end(),
-                     TSetVisiblity(PreviewCheckBox->isChecked()));
+        std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false));
+        myPlanes.clear();
+
+        vtkIdType anId = 0, anEnd = myActor->GetNumberOfClippingPlanes();
+        for ( ; anId < anEnd; anId++) {
+          if (vtkImplicitFunction* aFunction = myActor->GetClippingPlane(anId)) {
+            if(OrientedPlane* aPlane = OrientedPlane::SafeDownCast(aFunction)){
+              OrientedPlane* anOrientedPlane = OrientedPlane::New(aViewWindow);
+              SMESH::TVTKPlane aTVTKPlane(anOrientedPlane);
+              anOrientedPlane->Delete();
+              aTVTKPlane->ShallowCopy(aPlane);
+              myPlanes.push_back(aTVTKPlane);
+            }
+          }
+        }
+
+        std::for_each(myPlanes.begin(),myPlanes.end(),
+                      TSetVisiblity(PreviewCheckBox->isChecked()));
       }
     }
     SMESH::RenderViewWindow(aViewWindow);
@@ -510,15 +629,15 @@ void SMESHGUI_ClippingDlg::onSelectPlane (int theIndex)
   setRotation(aRot[0], aRot[1]);
   switch (anOrientation) {
   case SMESH::XY:
-    ComboBoxOrientation->setCurrentItem(0);
+    ComboBoxOrientation->setCurrentIndex(0);
     onSelectOrientation(0);
     break;
   case SMESH::YZ:
-    ComboBoxOrientation->setCurrentItem(1);
+    ComboBoxOrientation->setCurrentIndex(1);
     onSelectOrientation(1);
     break;
   case SMESH::ZX:
-    ComboBoxOrientation->setCurrentItem(2);
+    ComboBoxOrientation->setCurrentIndex(2);
     onSelectOrientation(2);
     break;
   }
@@ -556,7 +675,7 @@ void SMESHGUI_ClippingDlg::ClickOnDelete()
   if (!myActor || myPlanes.empty())
     return;
 
-  int aPlaneIndex = ComboBoxPlanes->currentItem();
+  int aPlaneIndex = ComboBoxPlanes->currentIndex();
 
   SMESH::TPlanes::iterator anIter = myPlanes.begin() + aPlaneIndex;
   anIter->GetPointer()->myActor->SetVisibility(false);
@@ -607,17 +726,17 @@ void SMESHGUI_ClippingDlg::Sinchronize()
   QString aName;
   for(int i = 1; i<=aNbPlanes; i++) {
     aName = QString(tr("Plane# %1")).arg(i);
-    ComboBoxPlanes->insertItem(aName);
+    ComboBoxPlanes->addItem(aName);
   }
 
   int aPos = ComboBoxPlanes->count() - 1;
-  ComboBoxPlanes->setCurrentItem(aPos);
+  ComboBoxPlanes->setCurrentIndex(aPos);
 
   bool anIsControlsEnable = (aPos >= 0);
   if (anIsControlsEnable) {
     onSelectPlane(aPos);
   } else {
-    ComboBoxPlanes->insertItem(tr("No planes"));
+    ComboBoxPlanes->addItem(tr("No planes"));
     SpinBoxRot1->SetValue(0.0);
     SpinBoxRot2->SetValue(0.0);
     SpinBoxDistance->SetValue(0.5);
@@ -652,7 +771,7 @@ void SMESHGUI_ClippingDlg::SetCurrentPlaneParam()
   if (myPlanes.empty() || myIsSelectPlane)
     return;
 
-  int aCurPlaneIndex = ComboBoxPlanes->currentItem();
+  int aCurPlaneIndex = ComboBoxPlanes->currentIndex();
 
   OrientedPlane* aPlane = myPlanes[aCurPlaneIndex].GetPointer();
 
@@ -671,7 +790,7 @@ void SMESHGUI_ClippingDlg::SetCurrentPlaneParam()
     aV[0] = aRot[0] > 0? aV[0]: -aV[0];
     aV[1] = aRot[1] > 0? aV[1]: -aV[1];
 
-    switch (ComboBoxOrientation->currentItem()) {
+    switch (ComboBoxOrientation->currentIndex()) {
     case 0:
       anOrientation = SMESH::XY;
 
@@ -721,31 +840,31 @@ void SMESHGUI_ClippingDlg::SetCurrentPlaneParam()
   vtkFloatingPointType aDel = aDataSet->GetLength()/2.0;
 
   vtkFloatingPointType aDelta[2][3] = {{aDir[0][0]*aDel, aDir[0][1]*aDel, aDir[0][2]*aDel},
-                                      {aDir[1][0]*aDel, aDir[1][1]*aDel, aDir[1][2]*aDel}};
+                                       {aDir[1][0]*aDel, aDir[1][1]*aDel, aDir[1][2]*aDel}};
   vtkFloatingPointType aParam, aPnt0[3], aPnt1[3], aPnt2[3];
 
   vtkFloatingPointType aPnt01[3] = {aPnt[0] - aDelta[0][0] - aDelta[1][0],
-                                   aPnt[1] - aDelta[0][1] - aDelta[1][1],
-                                   aPnt[2] - aDelta[0][2] - aDelta[1][2]};
+                                    aPnt[1] - aDelta[0][1] - aDelta[1][1],
+                                    aPnt[2] - aDelta[0][2] - aDelta[1][2]};
   vtkFloatingPointType aPnt02[3] = {aPnt01[0] + aNormal[0],
-                                   aPnt01[1] + aNormal[1],
-                                   aPnt01[2] + aNormal[2]};
+                                    aPnt01[1] + aNormal[1],
+                                    aPnt01[2] + aNormal[2]};
   vtkPlane::IntersectWithLine(aPnt01,aPnt02,aNormal,anOrigin,aParam,aPnt0);
 
   vtkFloatingPointType aPnt11[3] = {aPnt[0] - aDelta[0][0] + aDelta[1][0],
-                                   aPnt[1] - aDelta[0][1] + aDelta[1][1],
-                                   aPnt[2] - aDelta[0][2] + aDelta[1][2]};
+                                    aPnt[1] - aDelta[0][1] + aDelta[1][1],
+                                    aPnt[2] - aDelta[0][2] + aDelta[1][2]};
   vtkFloatingPointType aPnt12[3] = {aPnt11[0] + aNormal[0],
-                                   aPnt11[1] + aNormal[1],
-                                   aPnt11[2] + aNormal[2]};
+                                    aPnt11[1] + aNormal[1],
+                                    aPnt11[2] + aNormal[2]};
   vtkPlane::IntersectWithLine(aPnt11,aPnt12,aNormal,anOrigin,aParam,aPnt1);
 
   vtkFloatingPointType aPnt21[3] = {aPnt[0] + aDelta[0][0] - aDelta[1][0],
-                                   aPnt[1] + aDelta[0][1] - aDelta[1][1],
-                                   aPnt[2] + aDelta[0][2] - aDelta[1][2]};
+                                    aPnt[1] + aDelta[0][1] - aDelta[1][1],
+                                    aPnt[2] + aDelta[0][2] - aDelta[1][2]};
   vtkFloatingPointType aPnt22[3] = {aPnt21[0] + aNormal[0],
-                                   aPnt21[1] + aNormal[1],
-                                   aPnt21[2] + aNormal[2]};
+                                    aPnt21[1] + aNormal[1],
+                                    aPnt21[2] + aNormal[2]};
   vtkPlane::IntersectWithLine(aPnt21,aPnt22,aNormal,anOrigin,aParam,aPnt2);
 
   vtkPlaneSource* aPlaneSource = aPlane->myPlaneSource;
@@ -769,3 +888,19 @@ void SMESHGUI_ClippingDlg::OnPreviewToggle (bool theIsToggled)
   std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(theIsToggled));
   SMESH::RenderViewWindow(SMESH::GetCurrentVtkView());
 }
+
+//=================================================================================
+// function : keyPressEvent()
+// purpose  :
+//=================================================================================
+void SMESHGUI_ClippingDlg::keyPressEvent( QKeyEvent* e )
+{
+  QDialog::keyPressEvent( e );
+  if ( e->isAccepted() )
+    return;
+
+  if ( e->key() == Qt::Key_F1 ) {
+    e->accept();
+    ClickOnHelp();
+  }
+}