Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/visu.git] / src / VISUGUI / VisuGUI_CutPlanesDlg.cxx
index fc0d175d9b7deffae418657f59472dad9d8e7e52..486a475d200b47b435f13d0fd01f54d9940c1843 100644 (file)
@@ -1,82 +1,78 @@
-using namespace std;
-//  File      : VisuGUI_CutPlanesDlg.cxx
-//  Created   : Wed Aug 01 10:23:06 2001
-//  Author    : Laurent CORNABE & Hubert ROLLAND 
-//  Project   : SALOME
-//  Module    : VISUGUI
-//  Copyright : PRINCIPIA
+//  VISU VISUGUI : GUI of VISU component
+//
+//  Copyright (C) 2003  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 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
+//
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+//  File   : VisuGUI_CutPlanesDlg.cxx
+//  Author : Laurent CORNABE & Hubert ROLLAND
+//  Module : VISU
 //  $Header$
 
 #include "VisuGUI_CutPlanesDlg.h"
+
+#include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+#include "VisuGUI_ViewTools.h"
+
+#include "VISU_CutPlanes_i.hh"
+#include "VISU_CutPlanesPL.hxx"
+
+#include "OB_Browser.h"
+
+#include "SVTK_ViewWindow.h"
+
+#include "SalomeApp_Application.h"
+
+#include "SUIT_Application.h"
+#include "SUIT_Desktop.h"
+#include "SUIT_ViewWindow.h"
+#include "SUIT_ViewManager.h"
+
 #include <qlayout.h>
-#include "QAD_Application.h"
-#include "QAD_Desktop.h"
+#include <qcheckbox.h>
+#include <qstyle.h>
+#include <qstring.h>
+#include <qvalidator.h>
+#include <qlineedit.h>
+#include <qtabwidget.h>
+
+#include <vtkRenderer.h>
+#include <vtkPolyData.h>
+#include <vtkAppendPolyData.h>
+#include <vtkDataSetMapper.h>
 
-/*!
-  Constructor
-*/
-VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg()
-    : QDialog(  QAD_Application::getDesktop(), "VisuGUI_CutPlanesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
-{
-  setCaption( tr( "Cut Planes Definition" ) );
-  setSizeGripEnabled( TRUE );
+using namespace std;
+
+//extern VisuGUI *visuGUI;
 
-  QGridLayout* TopLayout = new QGridLayout( this ); 
+VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent)
+     : QFrame(theParent), myPreviewActor(0)
+{
+  QGridLayout* TopLayout = new QGridLayout( this );
   TopLayout->setSpacing( 6 );
-  TopLayout->setMargin( 11 );
-  /*
-  QGridLayout* CommentLayout = new QGridLayout;
-  CommentLayout->setMargin( 0 );
-  CommentLayout->setSpacing( 6 );
-  
-  QLabel* Comment1 = new QLabel( tr( "Enter plane position between" ), this, "Comment1" );
-  Comment1->setText( tr( "Enter plane position between" ) );
-  Comment1->setAlignment( AlignCenter );
-
-  Comment2_1 = new QLabel( tr( "v1" ), this, "Comment2_1" );
-  Comment2_1->setMinimumSize( QSize( 70, 0 ) );
-  Comment2_1->setAlignment( AlignCenter);
-
-  QLabel* Comment2 = new QLabel( tr( " and " ), this, "Comment2" );
-  Comment2->setAlignment( AlignCenter );
-  
-  Comment2_2 = new QLabel( tr( "v2" ), this, "Comment2_2" );
-  Comment2_2->setMinimumSize( QSize( 70, 0 ) );
-  Comment2_2->setAlignment( AlignCenter );
-  
-  QLabel* Comment3 = new QLabel( tr( "or in fraction between" ), this, "Comment3" );
-  Comment3->setAlignment( AlignCenter );
-
-  QLabel* Commento4 = new QLabel( tr( " and " ), this, "Comment4" );
-  Comment4->setAlignment( AlignCenter );
-
-  QLabel* Comment4_1 = new QLabel( tr( "0" ), this, "Comment4_1" );
-  Comment4_1->setMinimumSize( QSize( 70, 0 ) );
-  Comment4_1->setAlignment( AlignCenter );
-
-  QLabel* Comment4_2 = new QLabel( tr( "100" ), this, "Comment4_2" );
-  Comment4_2->setMinimumSize( QSize( 70, 0 ) );
-  Comment4_2->setAlignment( AlignCenter );
-  QFont font = Comment3->font(); font.setBold( true );
-  Comment2_1->setFont( font );
-  Comment2_2->setFont( font );
-  Comment4_1->setFont( font );
-  Comment4_2->setFont( font );
-  
-  CommentLayout->addMultiCellWidget( Comment1, 0, 0, 0, 2 );
-  CommentLayout->addWidget( Comment2_1, 1, 0 );
-  CommentLayout->addWidget( Comment2,   1, 1 );
-  CommentLayout->addWidget( Comment2_2, 1, 2 );
-  CommentLayout->addMultiCellWidget( Comment3, 2, 2, 0, 2 );
-  CommentLayout->addWidget( Comment4_1, 3, 0 );
-  CommentLayout->addWidget( Comment4,   3, 1 );
-  CommentLayout->addWidget( Comment4_2, 3, 2 );
-  CommentLayout->setColStretch( 0 , 5 );
-  CommentLayout->setColStretch( 2 , 5 );
-  */
-  QButtonGroup* SelPlane = new QButtonGroup( tr( "Orientation" ), this, "SelPlane" );
-  SelPlane->setTitle( tr( "Orientation" ) );
-  SelPlane->setColumnLayout(0, Qt::Vertical );
+  TopLayout->setMargin( 10 );
+
+  QButtonGroup* SelPlane = new QButtonGroup (tr("TXT_ORIENTATION"), this, "SelPlane");
+  //SelPlane->setTitle(tr("TXT_ORIENTATION"));
+  SelPlane->setColumnLayout(0, Qt::Vertical);
   SelPlane->layout()->setSpacing( 0 );
   SelPlane->layout()->setMargin( 0 );
   QGridLayout* SelPlaneLayout = new QGridLayout( SelPlane->layout() );
@@ -84,71 +80,33 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg()
   SelPlaneLayout->setSpacing( 6 );
   SelPlaneLayout->setMargin( 11 );
 
-  RBzx = new QRadioButton( tr( "// Z-X" ), SelPlane, "RBzx" );
-  RByz = new QRadioButton( tr( "// Y-Z" ), SelPlane, "RByz" );
-  RBxy = new QRadioButton( tr( "// X-Y" ), SelPlane, "RBxy" );
+  RBxy = new QRadioButton (tr("PARALLEL_XOY"), SelPlane, "RBxy");
+  RByz = new QRadioButton (tr("PARALLEL_YOZ"), SelPlane, "RByz");
+  RBzx = new QRadioButton (tr("PARALLEL_ZOX"), SelPlane, "RBzx");
   SelPlaneLayout->addWidget( RBxy, 0, 0 );
   SelPlaneLayout->addWidget( RByz, 0, 1 );
   SelPlaneLayout->addWidget( RBzx, 0, 2 );
 
-  QLabel* LabelPosi_3 = new QLabel( tr( "Number of planes:" ), this, "LabelPosi_3" );
+  QLabel* LabelPosi_3 = new QLabel (tr("LBL_NB_PLANS"), this, "LabelPosi_3");
 
   nbPlan = new QSpinBox( 1, 100, 1, this, "nbPlan" );
   nbPlan->setValue( 1 );
   nbPlan->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-  /*
-  GBplan1 = new QGroupBox( tr( "First plane" ), this, "GBplan1" );
-  GBplan1->setColumnLayout(0, Qt::Vertical );
-  GBplan1->layout()->setSpacing( 0 );
-  GBplan1->layout()->setMargin( 0 );
-  QGridLayout* GBplan1Layout = new QGridLayout( GBplan1->layout() );
-  GBplan1Layout->setAlignment( Qt::AlignTop );
-  GBplan1Layout->setSpacing( 6 );
-  GBplan1Layout->setMargin( 11 );
-  
-  QLabel* LabelPos = new QLabel( tr( "Plane position (value):" ), GBplan1, "LabelPos" );
-  GBplan1Layout->addWidget( LabelPos, 0, 0 );
-
-  PosPlan1 = new QAD_SpinBoxDbl( GBplan1, -999.999, 999.999, 0.1 );
-  PosPlan1->setValue( 0 );
-  PosPlan1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-  GBplan1Layout->addWidget( PosPlan1, 0, 1 );
-
-  QLabel* LabelPosi = new QLabel( tr( "Plane position (fraction):" ), GBplan1, "LabelPosi" );
-  GBplan1Layout->addWidget( LabelPosi, 1, 0 );
-
-  PosFrac1 = new QAD_SpinBoxDbl( GBplan1, 0, 100, 0.1 );
-  PosFrac1->setValue( 0 );
-  PosFrac1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-  GBplan1Layout->addWidget( PosFrac1, 1, 1 );
-
-  GBplan2 = new QGroupBox( tr( "Second plane" ), this, "GBplan2" );
-  GBplan2->setColumnLayout(0, Qt::Vertical );
-  GBplan2->layout()->setSpacing( 0 );
-  GBplan2->layout()->setMargin( 0 );
-  QGridLayout* GBplan2Layout = new QGridLayout( GBplan2->layout() );
-  GBplan2Layout->setAlignment( Qt::AlignTop );
-  GBplan2Layout->setSpacing( 6 );
-  GBplan2Layout->setMargin( 11 );
-
-  QLabel* LabelPos_5 = new QLabel( tr( "Plane position (value):" ), GBplan2, "LabelPos_5" );
-  GBplan2Layout->addWidget( LabelPos_5, 0, 0); 
-
-  PosPlan2 = new QAD_SpinBoxDbl( GBplan2, -999.999, 999.999, 0.1 );
-  PosPlan2->setValue( 0 );
-  PosPlan2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-  GBplan2Layout->addWidget( PosPlan2, 0, 1 );
-
-  QLabel* LabelPosi_6 = new QLabel( tr( "Plane position (fraction):" ), GBplan2, "LabelPosi_6" );
-  GBplan2Layout->addWidget( LabelPosi_6, 1, 0); 
-  
-  PosFrac2 = new QAD_SpinBoxDbl( GBplan2, 0, 100, 0.1 );
-  PosFrac2->setValue( 100 );
-  PosFrac2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-  GBplan2Layout->addWidget( PosFrac2, 1, 1 );
-  */
-  QGroupBox* GBrot = new QGroupBox( tr( "Rotations" ), this, "GBrot" );
-  GBrot->setColumnLayout(0, Qt::Vertical );
+
+  myPosTable = new QTable (this, "Positions of planes");
+  myPosTable->setMaximumHeight( 227 );
+  myPosTable->setMinimumWidth( 294 );
+  myPosTable->setNumCols(2);
+  myPosTable->setNumRows(0);
+  connect( myPosTable, SIGNAL(valueChanged(int, int)), this, SLOT(onValueChanged(int, int)) );
+
+  QHeader *th = myPosTable->horizontalHeader();
+  th->setLabel( 0, "Position" );
+  th->setLabel( 1, "Set default" );
+  th->setStyle("QStyle::CE_PushButton");
+
+  QGroupBox* GBrot = new QGroupBox (tr("LBL_ROTATION"), this, "GBrot");
+  GBrot->setColumnLayout(0, Qt::Vertical);
   GBrot->layout()->setSpacing( 0 );
   GBrot->layout()->setMargin( 0 );
   QGridLayout* GBrotLayout = new QGridLayout( GBrot->layout() );
@@ -156,371 +114,446 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg()
   GBrotLayout->setSpacing( 6 );
   GBrotLayout->setMargin( 11 );
 
-  LabelRot1 = new QLabel( tr( "Rotation around X (Y to Z):" ), GBrot, "LabelRot1" );
+  LabelRot1 = new QLabel (tr("LBL_ROT_X"), GBrot, "LabelRot1");
   GBrotLayout->addWidget( LabelRot1, 0, 0 );
 
-  Rot1 = new QAD_SpinBoxDbl( GBrot, -180, 180, 10 );
+  Rot1 = new QtxDblSpinBox( -180, 180, 10, GBrot );
   Rot1->setValue( 0 );
   Rot1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  connect( Rot1, SIGNAL( valueChanged( double )), this, SLOT( onRotation( double ) ) );
   GBrotLayout->addWidget( Rot1, 0, 1 );
 
-  LabelRot2 = new QLabel( tr( "Rotation around Y (Z to X):" ), GBrot, "LabelRot2" );
+  LabelRot2 = new QLabel (tr("LBL_ROT_Y"), GBrot, "LabelRot2");
   GBrotLayout->addWidget( LabelRot2, 1, 0 );
-  
-  Rot2 = new QAD_SpinBoxDbl( GBrot, -180, 180, 10 );
+
+  Rot2 = new QtxDblSpinBox( -180, 180, 10, GBrot );
   Rot2->setValue( 0 );
   Rot2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  connect( Rot2, SIGNAL( valueChanged( double )), this, SLOT( onRotation( double ) ) );
   GBrotLayout->addWidget( Rot2, 1, 1 );
 
-  QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
-  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 );
-
-  QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
-  buttonOk->setAutoDefault( TRUE );
-  buttonOk->setDefault( TRUE );
-  GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
-  GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1 );
-
-  QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ), GroupButtons, "buttonCancel" );
-  buttonCancel->setAutoDefault( TRUE );
-  GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
-
-  // layouting
+  QLabel* aPosLbl = new QLabel(tr( "LBL_POS" ), this);
+  myPosSpn = new QtxDblSpinBox( 0, 1, 0.1, this );
+
+  myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), this);
+  myPreviewCheck->setChecked(false);
+  connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
+
   TopLayout->addMultiCellWidget( SelPlane, 0, 0, 0, 1 );
-  //  TopLayout->addLayout( CommentLayout, 0, 1 );
-  TopLayout->addWidget( LabelPosi_3,   1, 0 );
-  TopLayout->addWidget( nbPlan,        1, 1 );
-  //TopLayout->addMultiCellWidget( GBplan1,      2, 2, 0, 1 );
-  //TopLayout->addMultiCellWidget( GBplan2,      3, 3, 0, 1 );
-  TopLayout->addMultiCellWidget( GBrot,        2, 2, 0, 1 );
-  TopLayout->addMultiCellWidget( GroupButtons, 3, 3, 0, 1 );
+  TopLayout->addMultiCellWidget( GBrot, 1, 1, 0, 1 );
+  TopLayout->addWidget( LabelPosi_3,   2, 0 );
+  TopLayout->addWidget( nbPlan,        2, 1 );
+  TopLayout->addMultiCellWidget( myPosTable, 3, 3, 0, 1 );
+  TopLayout->setRowStretch ( 3, 3 );
+  TopLayout->addWidget(aPosLbl, 4, 0 );
+  TopLayout->addWidget(myPosSpn, 4, 1 );
+  TopLayout->addMultiCellWidget( myPreviewCheck, 5, 5, 0, 1 );
 
   // signals and slots connections
-  connect( SelPlane, SIGNAL( clicked( int ) ),         this, SLOT( orientationChanged( int ) ) );
-  //connect( PosPlan1, SIGNAL( valueChanged( double ) ), this, SLOT( posChanged( double ) ) );
-  //connect( PosPlan2, SIGNAL( valueChanged( double ) ), this, SLOT( posChanged( double ) ) );
-  //connect( PosFrac1, SIGNAL( valueChanged( double ) ), this, SLOT( fracChanged( double ) ) );
-  //connect( PosFrac2, SIGNAL( valueChanged( double ) ), this, SLOT( fracChanged( double ) ) );
-  //connect( nbPlan,   SIGNAL( valueChanged( int ) ),    this, SLOT( nbPlanChanged( int ) ) );
-  
-  connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
-  connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+  connect( SelPlane, SIGNAL( clicked( int )), this, SLOT( orientationChanged( int ) ) );
+  connect( nbPlan, SIGNAL( valueChanged( int )), this, SLOT( DrawTable( ) ) );
+  connect( myPosSpn, SIGNAL( valueChanged( double )), this, SLOT( DrawTable( ) ) );
+  connect( th, SIGNAL( clicked(int)), this, SLOT( setDefault(int) ) );
 
   // default values
+  myCutPlanes = NULL;
+  hasInit = false;
   X1 = 0; X2 = 0;
   Y1 = 0; Y2 = 0;
   Z1 = 0; Z2 = 0;
-  //nbPold = 0;
-  RBxy->setChecked( true );
-  orientationChanged( 0 );
-  //nbPlanChanged( 1 );
-}
+  RByz->setChecked( true );
 
-/*!
-  Destructor
-*/
-VisuGUI_CutPlanesDlg::~VisuGUI_CutPlanesDlg()
+} // End of Constructor
+
+VisuGUI_CutPlanesPane::~VisuGUI_CutPlanesPane()
 {
+  deletePlanes();
+  if (myCutPlanes)
+    myCutPlanes->Destroy();
+  if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
+    vf->Repaint();
 }
 
-
-void VisuGUI_CutPlanesDlg::initFromPrsObject(VISU::CutPlanes_i* thePrs) {
+void VisuGUI_CutPlanesPane::initFromPrsObject (VISU::CutPlanes_i* thePrs)
+{
   setNbPlanes(thePrs->GetNbPlanes());
   setRotation(thePrs->GetRotateX()*180./PI, thePrs->GetRotateY()*180./PI);
   setPlanePos(thePrs->GetOrientationType());
+  myPosSpn->setValue(thePrs->GetDisplacement());
+  hasInit = true;
+  // init table
+  myCutPlanes = new VISU::CutPlanes_i(thePrs->GetResult(),false);
+  myCutPlanes->SameAs(thePrs);
+  DrawTable();
+
+  // Draw Preview
+  if (myPreviewCheck->isChecked()) {
+    createPlanes();
+  }
+}
+
+void VisuGUI_CutPlanesPane::createPlanes()
+{
+  if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
+  if (myCutPlanes == NULL) return;
+  if (myPreviewActor != 0) return;
+
+  vtkAppendPolyData* aPolyData = myCutPlanes->GetCutPlanesPL()->GetAppendPolyData();
+  if (!aPolyData->GetOutput()->GetNumberOfCells()) {
+    onPreviewCheck(false);
+    return;
+  }
+  vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
+  aPlaneMapper->SetInput(aPolyData->GetOutput());
+  aPlaneMapper->ScalarVisibilityOff();
+
+  myPreviewActor = SALOME_Actor::New();
+  myPreviewActor->PickableOff();
+  myPreviewActor->SetMapper(aPlaneMapper);
+  aPlaneMapper->Delete();
+  VISU::GetActiveViewWindow<SVTK_ViewWindow>()->AddActor(myPreviewActor);
 }
 
-void VisuGUI_CutPlanesDlg::storeToPrsObject(VISU::CutPlanes_i* thePrs) {
+int VisuGUI_CutPlanesPane::storeToPrsObject (VISU::CutPlanes_i* thePrs)
+{
+  thePrs->SetOrientation(getOrientaion(), getRotation1()*PI/180., getRotation2()*PI/180.);
   thePrs->SetNbPlanes(getNbPlanes());
-  thePrs->SetRotateX(getRotation1()*PI/180.);
-  thePrs->SetRotateY(getRotation2()*PI/180.);
-  thePrs->SetOrientationType(getOrientaion());
-  thePrs->Update();
+  thePrs->SetDisplacement(myPosSpn->value());
+  for (int i = 0; i < getNbPlanes(); ++i) {
+    QCheckTableItem* anItem = (QCheckTableItem*)myPosTable->item(i, 1);
+    if (!anItem)
+      break;
+    if (!anItem->isChecked())
+      thePrs->SetPlanePosition(i, myPosTable->text(i, 0).toDouble());
+    else
+      thePrs->SetDefault(i);
+  }
+  return 1;
 }
 
 /*!
   Called when orientation is changed
 */
-void VisuGUI_CutPlanesDlg::orientationChanged( int )
+void VisuGUI_CutPlanesPane::orientationChanged (int Id)
 {
-  if ( RBxy->isChecked() ) {
-    LabelRot1->setText( tr( "Rotation around X (Y to Z):" ) );
-    LabelRot2->setText( tr( "Rotation around Y (Z to X):" ) );
-    //Comment2_1->setText( QString::number( Z1 ) );
-    //Comment2_2->setText( QString::number( Z2 ) );
-    //PosPlan1->setMinValue( Z1 );
-    //PosPlan1->setMaxValue( Z2 );
-    //PosPlan2->setMinValue( Z1 );
-    //PosPlan2->setMaxValue( Z2 );
-    /*    
-    if( nbPlan->value() == 1 ) {
-//      PosFrac1->setValue( 50 );
-      PosPlan1->setValue( ( Z1 + Z2 ) / 2 );
-//      PosFrac2->setValue( 50 );
-      PosPlan2->setValue(  ( Z1 + Z2 ) / 2 );
-    }
-    else {
-//      PosFrac1->setValue( 0 );
-      //PosPlan1->setValue( Z1 );
-//      PosFrac2->setValue(100);
-      PosPlan2->setValue( Z2 );
-      }*/
+  if (Id == 0) { // RBxy->isChecked()
+    LabelRot1->setText(tr("LBL_ROT_X"));
+    LabelRot2->setText(tr("LBL_ROT_Y"));
+  } else if (Id == 1) { // RByz->isChecked()
+    LabelRot1->setText(tr("LBL_ROT_Y"));
+    LabelRot2->setText(tr("LBL_ROT_Z"));
+  } else {
+    LabelRot1->setText(tr("LBL_ROT_Z"));
+    LabelRot2->setText(tr("LBL_ROT_X"));
   }
-  else if ( RByz->isChecked() ) {
-    LabelRot1->setText( tr( "Rotation around Y (Z to X):" ) );
-    LabelRot2->setText( tr( "Rotation around Z (X to Y):" ) );
-    //Comment2_1->setText( QString::number( X1 ) );
-    //Comment2_2->setText( QString::number( X2 ) );
-    //PosPlan1->setMinValue( X1 );
-    //PosPlan1->setMaxValue( X2 );
-    //PosPlan2->setMinValue( X1 );
-    //PosPlan2->setMaxValue( X2 );
-    /*    
-    if( nbPlan->value() == 1 ) {
-//      PosFrac1->setValue( 50 );
-      PosPlan1->setValue( ( X1 + X2 ) / 2 );
-//      PosFrac2->setValue( 50 );
-      PosPlan2->setValue( ( X1 + X2 ) / 2 );
+  DrawTable();
+}
+
+/*!
+  Sets planes orientation and position
+*/
+void VisuGUI_CutPlanesPane::setPlanePos (const VISU::CutPlanes::Orientation orient)
+{
+  if (orient == VISU::CutPlanes::XY)           // xy
+    {
+      RBxy->setChecked( true );
+      orientationChanged( 0 );
     }
-    else {
-//      PosFrac1->setValue( 0 );
-      PosPlan1->setValue( X1 );
-//      PosFrac2->setValue( 100 );
-      PosPlan2->setValue( X2 );
-      }*/
-  }
-  else { // RBzx->isChecked()
-    //Comment2_1->setText( QString::number( Y1 ) );
-    //Comment2_2->setText( QString::number( Y2 ) );
-    //PosPlan1->setMinValue( Y1 );
-    //PosPlan1->setMaxValue( Y2 );
-    //PosPlan2->setMinValue( Y1 );
-    //PosPlan2->setMaxValue( Y2 );
-    LabelRot1->setText( tr( "Rotation around Z (X to Y):" ) );
-    LabelRot2->setText( tr( "Rotation around X (Y to Z):" ) );
-    /* 
-    if( (nbPlan->value()) == 1 ) {
-//      PosFrac1->setValue( 50 );
-      PosPlan1->setValue( ( Y1 + Y2 ) / 2 );
-//      PosFrac2->setValue( 50 );
-      PosPlan2->setValue( ( Y1 + Y2 ) / 2 );
+  else if (orient == VISU::CutPlanes::YZ)       // yz
+    {
+      RByz->setChecked( true );
+      orientationChanged( 1 );
     }
-    else {
-//      PosFrac1->setValue( 0 );
-      PosPlan1->setValue( Y1 );
-//      PosFrac2->setValue( 100 );
-      PosPlan2->setValue( Y2 );
-      }*/
-  }
+  else                         // zx
+   {
+     RBzx->setChecked( true );
+     orientationChanged( 2 );
+   }
+
 }
 
 /*!
-  Called when nb of planes is changed
+  Gets planes orientation
 */
-/*void VisuGUI_CutPlanesDlg::nbPlanChanged( int nb )
+VISU::CutPlanes::Orientation VisuGUI_CutPlanesPane::getOrientaion()
 {
-  int nold = ( nbPold == 0 ? 0 : ( nbPold > 1 ? 2 : 1 ) );
-  int nnew = ( nb == 0 ? 0 : ( nb > 1 ? 2 : 1 ) );
-  
-  if( nold != nnew )
-    orientationChanged( 0 );
-  //GBplan1->setEnabled( nnew != 0 );
-  //GBplan2->setEnabled( nnew > 1 && nnew != 0 );
-  nbPold = nb;
-  }*/
+  VISU::CutPlanes::Orientation orient;
+  if ( RBxy->isChecked() )     // xy
+    orient = VISU::CutPlanes::XY;
+  else if ( RByz->isChecked() )     // yz
+    orient = VISU::CutPlanes::YZ;
+  else if ( RBzx->isChecked() )     // zx
+    orient = VISU::CutPlanes::ZX;
+  return orient;
+}
 
 /*!
-  Called when position ( fraction ) is changed
+  Sets planes rotation
 */
-/*void VisuGUI_CutPlanesDlg::fracChanged( double value )
+void VisuGUI_CutPlanesPane::setRotation (const double r1, const double r2)
 {
-  if ( signalsBlocked() )
-    return;
-  QAD_SpinBoxDbl* spin = 0;
-  double V1, V2;
-  if ( sender() == PosFrac1 )
-    spin = PosPlan1;
-  if ( sender() == PosFrac2 )
-    spin = PosPlan2;
-  if( RBxy->isChecked() ) {
-    V1 = Z1; V2 = Z2;
-  }
-  else if( RByz->isChecked() ) {
-    V1 = X1; V2 = X2;
-  }
-  else {
-    V1 = Y1; V2 = Y2;
-  }
-  if ( spin ) {
-    blockSignals( true );
-    spin->setValue( V1 + ( V2 - V1 ) * value / 100 );
-    blockSignals( false );
-  } 
-  }*/
+  Rot1->setValue( r1 );
+  Rot2->setValue( r2 );
+}
 
 /*!
-  Called when position ( value ) is changed
+  Draw the table of planes positions
 */
-/*void VisuGUI_CutPlanesDlg::posChanged( double value )
+void VisuGUI_CutPlanesPane::DrawTable()
 {
-  if ( signalsBlocked() )
-    return;
-  QAD_SpinBoxDbl* spin = 0;
-  double V;
-  if ( sender() == PosPlan1 )
-    spin = PosFrac1;
-  if ( sender() == PosPlan2 )
-    spin = PosFrac2;
-  if( RBxy->isChecked() ) {
-    if ( value <= Z1 )
-      V = 0;
-    else if ( value >= Z2 )
-      V = 100;
-    else
-      V = ( value - Z1 ) / ( Z2 - Z1 ) * 100;
+  if (myCutPlanes == NULL) return;
+  if (!hasInit) return;
+
+  int aNbRows = myPosTable->numRows();
+  int aNbPlanes = getNbPlanes();
+
+  myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.);
+  myCutPlanes->SetNbPlanes(aNbPlanes);
+  myCutPlanes->SetDisplacement(myPosSpn->value());
+  if (aNbRows>0)
+    for (int i = 0; i < aNbRows; ++i) {
+      QCheckTableItem* aItem = (QCheckTableItem*)myPosTable->item( i, 1 );
+      if (aItem == 0) break;
+      if (!aItem->isChecked())
+       myCutPlanes->SetPlanePosition(i, myPosTable->text(i, 0).toDouble());
+    }
+
+  if (aNbPlanes > aNbRows)
+    myPosTable->insertRows(aNbRows, aNbPlanes - aNbRows );
+  else if (aNbPlanes < aNbRows)
+    myPosTable->setNumRows(aNbPlanes);
+
+  int aMin = (aNbRows < aNbPlanes)? aNbRows : aNbPlanes;
+  for (int i = 0; i<aMin; i++) {
+    myPosTable->setText(i, 0, QString::number(myCutPlanes->GetPlanePosition(i)));
+    ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(myCutPlanes->IsDefault(i));
   }
-  else if( RByz->isChecked() )
-    if ( value <= X1 )
-      V = 0;
-    else if ( value >= X2 )
-      V = 100;
-    else
-      V = ( value - X1 ) / ( X2 - X1 ) * 100;
-  else
-    if ( value <= Y1 )
-      V = 0;
-    else if ( value >= Y2 )
-      V = 100;
-    else
-      V = ( value - Y1 ) / ( Y2 - Y1 ) * 100;
-  if ( spin ) {
-    blockSignals( true );
-    spin->setValue( V );
-    blockSignals( false );
+
+  QHeader *vh = myPosTable->verticalHeader();
+  QString str("Plane# %1");
+  for (int i=aMin; i<aNbPlanes; i++) {
+    VisuGUI_NumEditItem* aEditItem = new VisuGUI_NumEditItem(myPosTable,
+                                                            QTableItem::OnTyping,
+                                                            QString::number(myCutPlanes->GetPlanePosition(i)));
+    aEditItem->setReplaceable(false);
+    aEditItem->setEnabled(!myCutPlanes->IsDefault(i));
+    myPosTable->setItem(i, 0, aEditItem);
+
+    QCheckTableItem* aCheck = new QCheckTableItem(myPosTable, 0);
+    aCheck->setChecked(myCutPlanes->IsDefault(i));
+    aCheck->setReplaceable(false);
+    myPosTable->setItem(i, 1, aCheck);
+
+    vh->setLabel( i, str.arg(i+1) );
   }
-  }*/
 
-/*!
-  Sets bounds ( must be called first )
-*/
-void VisuGUI_CutPlanesDlg::setBounds( const double x1, const double x2, 
-                                     const double y1, const double y2, 
-                                     const double z1, const double z2 )
-{
-  X1 = min( x1, x2 ); X2 = max( x1, x2 );
-  Y1 = min( y1, y2 ); Y2 = max( y1, y2 );
-  Z1 = min( z1, z2 ); Z2 = max( z1, z2 );
-  orientationChanged( 0 );
+  // Update preview
+  if (myPreviewCheck->isChecked()) {
+    if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
+      myCutPlanes->GetPL()->Update();
+      deletePlanes();
+      createPlanes();
+      vf->Repaint();
+    }
+  }
 }
 
-/*!
-  Sets nb of planes
-*/
-void VisuGUI_CutPlanesDlg::setNbPlanes( const int nbp )
+void VisuGUI_CutPlanesPane::setDefault (int all)
 {
-  nbPlan->setValue( nbp );
+  myPosTable->setCurrentCell(-1, 1);
+  myPosTable->clearSelection();
+  if (all == 0) return;
+  if (all == 1)
+    for (int i = 0; i < getNbPlanes(); ++i)
+      ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(true);
+
+  for (int i = 0; i < getNbPlanes(); ++i) {
+    if ( ((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked() ) {
+      myCutPlanes->SetDefault(i);
+      myPosTable->setText( i, 0, QString::number(myCutPlanes->GetPlanePosition(i)));
+      myPosTable->item( i, 0 )->setEnabled(false);
+    } else
+      myPosTable->item( i, 0 )->setEnabled(true);
+  }
 }
 
-/*!
-  Gets nb of planes
-*/
-int VisuGUI_CutPlanesDlg::getNbPlanes()
+void VisuGUI_CutPlanesPane::onValueChanged (int theRow, int theCol)
 {
-  return nbPlan->value();
+  if (theCol == 0) {
+    QString aTxt = myPosTable->text(theRow, 0);
+    bool isChanged = !aTxt.isEmpty();
+    ((QCheckTableItem*)myPosTable->item(theRow, 1))->setChecked(!isChanged);
+
+    if (myPreviewCheck->isChecked()) {
+      //Update Preview
+      if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
+       myCutPlanes->SetPlanePosition( theRow, aTxt.toDouble());
+       myCutPlanes->GetPL()->Update();
+       deletePlanes();
+       createPlanes();
+       vf->Repaint();
+      }
+    }
+  } else {
+    bool isDefault = ((QCheckTableItem*)myPosTable->item(theRow, theCol))->isChecked();
+    if (isDefault) {
+      myCutPlanes->SetDefault(theRow);
+      myPosTable->setText(theRow, 0, QString::number(myCutPlanes->GetPlanePosition(theRow)));
+
+      if (myPreviewCheck->isChecked()) {
+       if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
+         //Update Preview
+         myCutPlanes->GetPL()->Update();
+         deletePlanes();
+         createPlanes();
+         vf->Repaint();
+       }
+      }
+    }
+    myPosTable->item(theRow, 0)->setEnabled(!isDefault);
+  }
 }
 
-/*!
-  Sets planes orientation and position
-*/
-void VisuGUI_CutPlanesDlg::setPlanePos( const VISU::CutPlanes::Orientation  orient/*, const double pos1, const double pos2 */)
+void VisuGUI_CutPlanesPane::deletePlanes()
 {
-  if ( orient == VISU::CutPlanes::XY )           // xy
-    RBxy->setChecked( true );
-  else if ( orient == VISU::CutPlanes::YZ )       // yz
-    RByz->setChecked( true );
-  else                         // zx
-    RBzx->setChecked( true );
-  orientationChanged( 0 );
-  //PosPlan1->setValue( pos1 );
-  //PosPlan2->setValue( pos2 );
+  if (myPreviewActor == 0) return;
+  if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
+    vf->RemoveActor(myPreviewActor);
+  myPreviewActor->Delete();
+  myPreviewActor = 0;
 }
 
-/*!
-  Sets planes orientation and position ( fraction )
-*/
-/*void VisuGUI_CutPlanesDlg::setPlanePosFrac( const int orient, const double frac1, const double frac2 )
+void VisuGUI_CutPlanesPane::onRotation (double theValue)
 {
-  if ( orient == 1 )           // xy
-    RBxy->setChecked( true );
-  else if ( orient == 2)       // yz
-    RByz->setChecked( true );
-  else                         // zx
-    RBzx->setChecked( true );
-  orientationChanged( 0 );
-  PosFrac1->setValue( frac1 );
-  PosFrac2->setValue( frac2 );
-  }*/
+  if (myCutPlanes == NULL) return;
+  if (myPreviewCheck->isChecked()) {
+    if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
+      myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.);
+      myCutPlanes->GetPL()->Update();
+      deletePlanes();
+      createPlanes();
+      vf->Repaint();
+    }
+  }
+}
 
-/*!
-  Gets planes orientation
-*/
-VISU::CutPlanes::Orientation VisuGUI_CutPlanesDlg::getOrientaion()
+void VisuGUI_CutPlanesPane::onPreviewCheck (bool thePreview)
 {
-  VISU::CutPlanes::Orientation orient;
-  if ( RBxy->isChecked() )     // xy
-    orient = VISU::CutPlanes::XY;
-  if ( RByz->isChecked() )     // yz
-    orient = VISU::CutPlanes::YZ;
-  if ( RBzx->isChecked() )     // zx
-    orient = VISU::CutPlanes::ZX;
-  return orient;
+  if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
+    if (thePreview) {
+      storeToPrsObject(myCutPlanes);
+      myCutPlanes->GetPL()->Update();
+      createPlanes();
+      vf->onFitAll();
+    } else {
+      deletePlanes();
+      vf->Repaint();
+    }
+  }
 }
 
+//###################################################################
+
+
 /*!
-  Gets planes  position 1
+  Constructor
 */
-/*double VisuGUI_CutPlanesDlg::getPlanePos1()
+VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg (SalomeApp_Module* theModule)
+     : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutPlanesDlg", false,
+               WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
 {
-  return PosPlan1->value();
-  }*/
+  setCaption("Cut Planes Definition");
+  setSizeGripEnabled(true);
+
+  QVBoxLayout* TopLayout = new QVBoxLayout (this);
+  TopLayout->setSpacing(6);
+  TopLayout->setMargin(11);
+
+  // Tab pane
+  QTabWidget* aTabBox = new QTabWidget(this);
+  myCutPane = new VisuGUI_CutPlanesPane(this/*, myMgr*/);
+  aTabBox->addTab(myCutPane, "Cut Planes");
+  myScalarPane = new VisuGUI_ScalarBarPane(this, false);
+  myScalarPane->setMargin(5);
+  aTabBox->addTab(myScalarPane, "Scalar Bar");
+
+  TopLayout->addWidget(aTabBox);
+
+  QGroupBox* GroupButtons = new QGroupBox(this, "GroupButtons");
+  GroupButtons->setGeometry(QRect(10, 10, 281, 48));
+  GroupButtons->setTitle("");
+  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);
+
+  QPushButton* buttonOk = new QPushButton(tr("&OK"), GroupButtons, "buttonOk");
+  buttonOk->setAutoDefault(TRUE);
+  buttonOk->setDefault(TRUE);
+  GroupButtonsLayout->addWidget(buttonOk, 0, 0);
+  GroupButtonsLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1);
+
+  QPushButton* buttonCancel = new QPushButton(tr("&Cancel"), GroupButtons, "buttonCancel");
+  buttonCancel->setAutoDefault(TRUE);
+  GroupButtonsLayout->addWidget(buttonCancel, 0, 2);
+
+  TopLayout->addWidget(GroupButtons);
+
+  connect(buttonOk,     SIGNAL(clicked()), this, SLOT(accept()));
+  connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
+  //connect(myMgr, SIGNAL(closeAllViews()), this, SLOT(reject()));
+  //connect(VisuGUI::application()->desktop(),
+  //        SIGNAL(windowActivated(SUIT_ViewWindow*)),
+  //        this, SLOT(onWindowActivated(SUIT_ViewWindow*)));
+}
 
-/*!
-  Gets planes  position 2
-*/
-/*double VisuGUI_CutPlanesDlg::getPlanePos2()
+void VisuGUI_CutPlanesDlg::initFromPrsObject (VISU::CutPlanes_i* thePrs)
 {
-  return PosPlan2->value();
-  }*/
+  myPrs = thePrs;
+  myScalarPane->initFromPrsObject(thePrs);
+  myCutPane->initFromPrsObject(thePrs);
+}
 
-/*!
-  Sets planes rotation
-*/
-void VisuGUI_CutPlanesDlg::setRotation( const double r1, const double r2 )
+int VisuGUI_CutPlanesDlg::storeToPrsObject (VISU::CutPlanes_i* thePrs)
 {
-  Rot1->setValue( r1 );
-  Rot2->setValue( r2 );
+  return (myScalarPane->storeToPrsObject(thePrs) &&
+          myCutPane->storeToPrsObject(thePrs));
 }
 
-/*!
-  Gets plane rotation 1
-*/
-double VisuGUI_CutPlanesDlg::getRotation1()
+void VisuGUI_CutPlanesDlg::accept()
 {
-  return Rot1->value();
+  //if ( !VisuGUI::CheckActiveStudyLock() ) {
+  //  reject();
+  //  return;
+  //}
+  if (myScalarPane->check())
+    {
+      myScalarPane->deletePreview();
+      QDialog::accept();
+    }
 }
 
-/*!
-  Gets plane rotation 2
-*/
-double VisuGUI_CutPlanesDlg::getRotation2()
+void VisuGUI_CutPlanesDlg::reject() {
+  myScalarPane->deletePreview();
+  QDialog::reject();
+}
+
+//void VisuGUI_CutPlanesDlg::onWindowActivated (SUIT_ViewWindow* theWnd)
+//{
+//  if (theWnd != myStudyWnd)
+//    reject();
+//}
+
+//###################################################################
+
+QWidget* VisuGUI_NumEditItem::createEditor() const
 {
-  return Rot2->value();
+  QLineEdit *editline = new QLineEdit(text(), table()->viewport());
+  QDoubleValidator *dvalidator = new QDoubleValidator(table()->viewport());
+  dvalidator->setDecimals(32);
+  editline->setValidator(dvalidator);
+  return editline;
 }