Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/visu.git] / src / VISUGUI / VisuGUI_CutLinesDlg.cxx
index 20efa3369f51c54cfa7b947ab41efdbdcdb2439c..545e8c8168e9512dcde831a3e6afd821baf99495 100644 (file)
@@ -9,12 +9,19 @@
 //  Module : VISU
 
 #include "VisuGUI_CutLinesDlg.h"
-#include "VISU_CutLines_i.hh"
+
 #include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+#include "VisuGUI_ViewTools.h"
+
+#include "VISU_Gen_i.hh"
+#include "VISU_CutLines_i.hh"
+
 #include "VISU_PipeLine.hxx"
-//#include "VTKViewer_ViewWindow.h"
+#include "VISU_PipeLineUtils.hxx"
 #include "VISU_CutLinesPL.hxx"
-#include "VISU_Gen_i.hh"
+
+#include "SVTK_ViewWindow.h"
 
 #include "SalomeApp_Application.h"
 #include "SalomeApp_Study.h"
 #include <vtkPolyData.h>
 #include <vtkAppendPolyData.h>
 #include <vtkDataSetMapper.h>
+#include <vtkGlyph3D.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkFloatArray.h>
+#include <vtkGlyphSource2D.h>
 
 using namespace std;
 
-//extern VisuGUI *visuGUI;
-
-//#define GET_VTK_VIEWWINDOW(aMgr) dynamic_cast<VTKViewer_ViewWindow*>(aMgr->getActiveView())
-
 bool VisuGUI_CutLinesDlg::MYGenerateTable = true;
 bool VisuGUI_CutLinesDlg::MYGenerateCurve = true;
 
-//SalomeApp_Study* study()
-//{
-//  return dynamic_cast<SalomeApp_Study*>(VisuGUI::application()->activeStudy());
-//}
-
-VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (QWidget* parent, bool theIsCreation, bool theIsModal)
-     : QDialog(parent, "VisuGUI_CutLinesDlg", theIsModal, WStyle_Customize |
-               WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
-       myPreviewActor(0)
-       //,myMgr(VisuGUI::application()->activeViewManager())
+VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule)
+     : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutLinesDlg", false,
+               WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
+       myPreviewActor(0),myPreviewActorGlyphs(0)
 {
-  //myStudyWnd = myMgr->getActiveView();
-  if (!theIsModal) {
-    setWFlags(getWFlags() | WDestructiveClose);
-  }
   setCaption("Cut Lines Definition");
   setSizeGripEnabled(true);
-  myIsCreation = theIsCreation;
 
   QVBoxLayout* aMainLayout = new QVBoxLayout (this, 7, 6);
   aMainLayout->setSpacing(5);
@@ -77,9 +73,11 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (QWidget* parent, bool theIsCreation, b
   mySelPlane->setInsideSpacing( 5 );
   mySelPlane->setInsideMargin( 5 );
 
-  QRadioButton* aBxy = new QRadioButton( tr( "|| X-Y" ), mySelPlane);  // 0
-  QRadioButton* aByz = new QRadioButton( tr( "|| Y-Z" ), mySelPlane);  // 1
-  QRadioButton* aBzx = new QRadioButton( tr( "|| Z-X" ), mySelPlane);  // 2
+  QRadioButton* aBxy = new QRadioButton( tr( "PARALLEL_XOY" ), mySelPlane);  // 0
+  QRadioButton* aByz = new QRadioButton( tr( "PARALLEL_YOZ" ), mySelPlane);  // 1
+  QRadioButton* aBzx = new QRadioButton( tr( "PARALLEL_ZOX" ), mySelPlane);  // 2
+  aBxy->setChecked(false);
+  aByz->setChecked(false);
   aBzx->setChecked(true);
 
   aPlaneLayout->addWidget( mySelPlane );
@@ -96,28 +94,32 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (QWidget* parent, bool theIsCreation, b
 
   aPlaneLayout->addWidget( aRotBox );
 
-  QHGroupBox* aBaseBox = new QHGroupBox( tr( "Base plane position" ), aPlanePane );
+  QHGroupBox* aBaseBox = new QHGroupBox (tr("BASE_PLANE_POS"), aPlanePane);
   myBasePlanePos = new QLineEdit (aBaseBox);
   mydvalidator = new QDoubleValidator(this);
   mydvalidator->setDecimals(32);
   myBasePlanePos->setValidator(mydvalidator);
 
-  myCBSetDef = new QCheckBox(tr("Set default"),aBaseBox);
+  myCBSetDef = new QCheckBox (tr("SET_DEFAULT"),aBaseBox);
 
-  aPlaneLayout->addWidget( aBaseBox );
+  aPlaneLayout->addWidget(aBaseBox);
 
-  QHBox* aPosBox = new QHBox(aPlanePane);
+  QHBox* aPosBox = new QHBox (aPlanePane);
   aPosBox->setSpacing(5);
-  QLabel* aPosLbl = new QLabel( tr( "LBL_POS" ), aPosBox );
-  myPosSpn = new QtxDblSpinBox( 0, 1, 0.1, aPosBox );
-  myPosSpn->setValue( 0.5 );
-  aPlaneLayout->addWidget( aPosBox );
+  new QLabel (tr("LBL_POS"), aPosBox);
+  myPosSpn = new QtxDblSpinBox (0, 1, 0.1, aPosBox);
+  myPosSpn->setValue(0.5);
+  aPlaneLayout->addWidget(aPosBox);
 
-  myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), aPlanePane);
+  myPreviewCheck = new QCheckBox (tr("LBL_SHOW_PREVIEW"), aPlanePane);
   myPreviewCheck->setChecked(false);
-  aPlaneLayout->addWidget( myPreviewCheck );
+  aPlaneLayout->addWidget(myPreviewCheck);
+
+  myAllCurvesInvertedCheck = new QCheckBox(tr("LBL_INVERT_CURVES"), aPlanePane);
+  myAllCurvesInvertedCheck->setChecked(false);
+  aPlaneLayout->addWidget(myAllCurvesInvertedCheck);
 
-  myCreateTable = new QCheckBox(tr("LBL_GENERATE_TABLE"), aPlanePane);
+  myCreateTable = new QCheckBox (tr("LBL_GENERATE_TABLE"), aPlanePane);
   myCreateTable->setChecked(MYGenerateTable);
   aPlaneLayout->addWidget( myCreateTable );
 
@@ -145,9 +147,9 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (QWidget* parent, bool theIsCreation, b
   mySelPlane2->setInsideSpacing( 5 );
   mySelPlane2->setInsideMargin( 5 );
 
-  QRadioButton* aBxy2 = new QRadioButton( tr( "|| X-Y" ), mySelPlane2);  // 0
-  QRadioButton* aByz2 = new QRadioButton( tr( "|| Y-Z" ), mySelPlane2);  // 1
-  QRadioButton* aBzx2 = new QRadioButton( tr( "|| Z-X" ), mySelPlane2);  // 2
+  QRadioButton* aBxy2 = new QRadioButton( tr( "PARALLEL_XOY" ), mySelPlane2);  // 0
+  QRadioButton* aByz2 = new QRadioButton( tr( "PARALLEL_YOZ" ), mySelPlane2);  // 1
+  QRadioButton* aBzx2 = new QRadioButton( tr( "PARALLEL_ZOX" ), mySelPlane2);  // 2
   aBzx2->setEnabled(false);
   aByz2->setChecked(true);
   aLinesLayout->addWidget( mySelPlane2 );
@@ -165,7 +167,7 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (QWidget* parent, bool theIsCreation, b
 
   QHBox* aNbBox = new QHBox(aLinesPane);
   aNbBox->setSpacing(5);
-  QLabel* aNbLbl = new QLabel( tr( "LBL_NB_PLANS" ), aNbBox );
+  new QLabel( tr( "LBL_NB_PLANS" ), aNbBox );
   myNbSpn = new QtxDblSpinBox( 1, 100, 1, aNbBox );
   myNbSpn->setValue( 10 );
 
@@ -185,7 +187,7 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (QWidget* parent, bool theIsCreation, b
 
   QHBox* aPosBox2 = new QHBox(aLinesPane);
   aPosBox2->setSpacing(5);
-  QLabel* aPosLbl2 = new QLabel( tr( "LBL_POS" ), aPosBox2 );
+  new QLabel( tr( "LBL_POS" ), aPosBox2 );
   myPosSpn2 = new QtxDblSpinBox( 0, 1, 0.1, aPosBox2 );
   myPosSpn2->setValue( 0.5 );
   aLinesLayout->addWidget( aPosBox2 );
@@ -208,7 +210,7 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (QWidget* parent, bool theIsCreation, b
   aBtnLayout->setSpacing( 5 );
   aBtnLayout->setMargin( 11 );
 
-  QPushButton* aOkBtn = new QPushButton(tr( "VISU_BUT_OK" ),  aBtnBox);
+  QPushButton* aOkBtn = new QPushButton (tr("BUT_OK"), aBtnBox);
   aOkBtn->setAutoDefault( TRUE );
   aOkBtn->setDefault( true );
   aBtnLayout->addWidget(aOkBtn);
@@ -231,6 +233,7 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (QWidget* parent, bool theIsCreation, b
   connect(th            , SIGNAL(clicked(int))          , this, SLOT(setDefault(int)));
   connect(myPosSpn2     , SIGNAL(valueChanged(double))  , this, SLOT(DrawTable()));
   connect(myPreviewCheck, SIGNAL(toggled(bool))         , this, SLOT(onPreviewCheck(bool)));
+  connect(myAllCurvesInvertedCheck, SIGNAL(toggled(bool)),this, SLOT(onAllCurvesInvertedCheck(bool)));
   connect(myPosTable    , SIGNAL(valueChanged(int, int)), this, SLOT(onValueChanged(int, int)));
   connect(myRotXSpn     , SIGNAL(valueChanged(double))  , this, SLOT(onRotation(double)));
   connect(myRotYSpn     , SIGNAL(valueChanged(double))  , this, SLOT(onRotation(double)));
@@ -252,10 +255,12 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (QWidget* parent, bool theIsCreation, b
 */
 VisuGUI_CutLinesDlg::~VisuGUI_CutLinesDlg()
 {
+  cout<<"### VisuGUI_CutLinesDlg::~VisuGUI_CutLinesDlg"<<endl;
   deletePlanes();
-  if (myCutLines) delete myCutLines;
-  //jfa tmp:if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr))
-  //jfa tmp:  vf->Repaint();
+  if (myCutLines) //delete myCutLines;
+    myCutLines->Destroy();
+  if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
+    vf->Repaint();
 }
 
 //------------------------------------------------------------------------------
@@ -278,6 +283,8 @@ void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::CutLines_i* thePrs)
   hasInit = true;
   myCutLines = new VISU::CutLines_i(thePrs->GetResult(),false);
   myCutLines->SameAs(thePrs);
+  myCutLines->CopyCurvesInverted(thePrs->GetCurvesInverted());
+  if (myCutLines->IsAllCurvesInverted()) myAllCurvesInvertedCheck->setChecked(true);
   myBasePlanePos->setText( QString::number(myCutLines->GetBasePlanePosition()) );
   myCBSetDef->setChecked(thePrs->IsDefault());
   DrawTable();
@@ -313,37 +320,52 @@ int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::CutLines_i* thePrs)
       thePrs->SetLinePosition( i, myPosTable->text( i, 0 ).toDouble() );
     else thePrs->SetDefaultPosition(i);
   }
+  if (myAllCurvesInvertedCheck->isChecked())
+    thePrs->SetAllCurvesInverted(true);
   return 1;
 }
 
 //------------------------------------------------------------------------------
 void VisuGUI_CutLinesDlg::createPlanes()
 {
-  //jfa tmp:if (GET_VTK_VIEWWINDOW(myMgr) == NULL)
-  //jfa tmp:  return;
+  SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
+  if (aView == NULL) return;
   if (myCutLines == NULL) return;
   if (myPreviewActor != 0) return;
 
+  storeToPrsObject(myCutLines);
+  myCutLines->GetPL()->Update();
   vtkAppendPolyData* aPolyData = myCutLines->GetCutLinesPL()->GetAppendPolyData();
   vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
   aPlaneMapper->SetInput(aPolyData->GetOutput());
   aPlaneMapper->ScalarVisibilityOff();
-
+  
+  myPreviewActorGlyphs = myPreviewActorGlyphs = SALOME_Actor::New();
+  myPreviewActorGlyphs->PickableOff();
+  updateGlyphs(false);
+  
   myPreviewActor = SALOME_Actor::New();
   myPreviewActor->PickableOff();
   myPreviewActor->SetMapper(aPlaneMapper);
   aPlaneMapper->Delete();
-  //jfa tmp:GET_VTK_VIEWWINDOW(myMgr)->AddActor(myPreviewActor);
+  aView->AddActor(myPreviewActor);
+  aView->AddActor(myPreviewActorGlyphs);
+  aView->getRenderer()->Render();
+  aView->onFitAll();
 }
 
 //------------------------------------------------------------------------------
 void VisuGUI_CutLinesDlg::deletePlanes()
 {
   if (myPreviewActor == 0) return;
-  //jfa tmp:if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr))
-  //jfa tmp:  vf->RemoveActor(myPreviewActor);
+  if (SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>()){
+    aView->RemoveActor(myPreviewActor);
+    aView->RemoveActor(myPreviewActorGlyphs);
+  }
   myPreviewActor->Delete();
+  myPreviewActorGlyphs->Delete();
   myPreviewActor = 0;
+  myPreviewActorGlyphs = 0;
 }
 
 
@@ -393,18 +415,19 @@ void VisuGUI_CutLinesDlg::onCutSelect (int theId, bool theUpdate)
     myRotXLbl2->setText( tr("LBL_ROT_Z"));
     myRotYLbl2->setText( tr("LBL_ROT_X"));
   }
-  //jfa tmp:if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) {
+  SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
+  if (aView) {
     if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) {
-      myCutLines->SetOrientation2(getOrientaion(false),
+      /*myCutLines->SetOrientation2(getOrientaion(false),
                                   myRotXSpn2->value()*PI/180.,
                                   myRotYSpn2->value()*PI/180.);
-      myCutLines->SetDisplacement2(myPosSpn2->value());
-      myCutLines->GetPL()->Update();
+                                 myCutLines->SetDisplacement2(myPosSpn2->value());*/
+      //myCutLines->GetPL()->Update();
       deletePlanes();
       createPlanes();
-      //jfa tmp:vf->Repaint();
+      //aView->Repaint();
     }
-  //jfa tmp:}
+  }
 }
 
 //------------------------------------------------------------------------------
@@ -414,22 +437,26 @@ void VisuGUI_CutLinesDlg::setBaseDefault (bool theUpdate)
 
   if (myCBSetDef->isChecked()) {
     if (!myCutLines->IsDefault()) myCutLines->SetDefault();
-    myCutLines->SetOrientation(getOrientaion(),
+    /*myCutLines->SetOrientation(getOrientaion(),
                                myRotXSpn->value()*PI/180.,
                                myRotYSpn->value()*PI/180.);
-    myCutLines->SetDisplacement(myPosSpn->value());
-    float aPos = myCutLines->GetBasePlanePosition();
+                              myCutLines->SetDisplacement(myPosSpn->value());*/
+    /*    float aPos = myCutLines->GetBasePlanePosition();
     myBasePlanePos->setText( QString::number(aPos) );
-    myBasePlanePos->setEnabled(false);
-    //jfa tmp:if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) {
+    myBasePlanePos->setEnabled(false);*/
+    SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
+    if (aView) {
       if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) {
-        myCutLines->SetBasePlanePosition(aPos);
-        myCutLines->GetPL()->Update();
+        //myCutLines->SetBasePlanePosition(aPos);
+       //        myCutLines->GetPL()->Update();
         deletePlanes();
         createPlanes();
-        //jfa tmp:vf->Repaint();
+        //aView->Repaint();
       }
-    //jfa tmp:}
+    }
+    float aPos = myCutLines->GetBasePlanePosition();
+    myBasePlanePos->setText( QString::number(aPos) );
+    myBasePlanePos->setEnabled(false);
   } else {
     myBasePlanePos->setEnabled(true);
   }
@@ -489,14 +516,87 @@ void VisuGUI_CutLinesDlg::DrawTable()
     vh->setLabel( i, str.arg(i+1) );
   }
   // Update preview
-  //jfa tmp:if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) {
+  SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
+  if (aView) {
     if (myPreviewCheck->isChecked()) {
-      myCutLines->GetPL()->Update();
+      //      myCutLines->GetPL()->Update();
       deletePlanes();
       createPlanes();
-      //jfa tmp:vf->Repaint();
+      //aView->Repaint();
     }
-  //jfa tmp:}
+  }
+}
+
+void VisuGUI_CutLinesDlg::updateGlyphs(bool update){
+  if (myPreviewActorGlyphs == 0 ) return;
+  const float *aDirLn = myCutLines->GetCutLinesPL()->GetDirLn();
+  const float *aBasePnt = myCutLines->GetCutLinesPL()->GetBasePnt();
+  float aSecondPnt[3];
+  float aBoundCenter[3];
+
+  vtkAppendPolyData* aPolyData = myCutLines->GetCutLinesPL()->GetAppendPolyData();
+  vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
+  aPlaneMapper->SetInput(aPolyData->GetOutput());
+  float bounds[6];
+  aPlaneMapper->GetBounds(bounds);
+
+  for(int i=0; i<3; i++) aBoundCenter[i] = (bounds[i*2] + bounds[i*2+1])/2.0;
+  for(int i=0; i<3; i++){ 
+    if (!myAllCurvesInvertedCheck->isChecked())
+      aSecondPnt[i] = aBasePnt[i] + aDirLn[i];
+    else
+      aSecondPnt[i] = -aBasePnt[i] - aDirLn[i];
+  }
+  
+  float max_bound = 0;
+  max_bound < bounds[1]-bounds[0] ? max_bound = bounds[1] - bounds[0] : max_bound = max_bound;
+  max_bound < bounds[3]-bounds[2] ? max_bound = bounds[3] - bounds[2] : max_bound = max_bound;
+  max_bound < bounds[5]-bounds[4] ? max_bound = bounds[5] - bounds[4] : max_bound = max_bound;
+
+  vtkPolyData* profile = vtkPolyData::New();
+  vtkPoints* aPoints = vtkPoints::New();
+  vtkGlyph3D* glyphs = vtkGlyph3D::New();
+  vtkFloatArray *aFloatArray = vtkFloatArray::New();
+  vtkGlyphSource2D* source = vtkGlyphSource2D::New();
+  
+  source->FilledOn();
+  source->SetCenter(aBoundCenter);
+  source->SetGlyphTypeToArrow();
+  
+  aPoints->InsertNextPoint(aBasePnt);
+  profile->SetPoints(aPoints);
+  
+  aFloatArray->SetNumberOfComponents(3);
+  for(int i=0; i<3 ;i++)
+      aFloatArray->InsertNextValue(aSecondPnt[i]);
+  
+  vtkDataSetAttributes* aDataSetAttributes;
+  aDataSetAttributes = profile->GetPointData();
+  aDataSetAttributes->SetVectors(aFloatArray);
+  
+  glyphs->SetScaleFactor(0.25*max_bound);
+  glyphs->SetVectorModeToUseVector();
+  glyphs->SetScaleModeToScaleByVector();
+  glyphs->SetInput(profile);
+  glyphs->SetSource(source->GetOutput());
+
+  vtkPolyDataMapper* aGlyphsMapper = vtkPolyDataMapper::New();
+  aGlyphsMapper->ScalarVisibilityOff();
+  aGlyphsMapper->SetInput(glyphs->GetOutput());
+  
+  myPreviewActorGlyphs->SetMapper(aGlyphsMapper);
+
+  profile->Delete();
+  glyphs->Delete();
+  aPoints->Delete();
+  aGlyphsMapper->Delete();
+  aFloatArray->Delete();
+  source->Delete();
+  aPlaneMapper->Delete();
+
+  if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
+    if (update)
+      vf->Repaint();
 }
 
 //------------------------------------------------------------------------------
@@ -585,32 +685,33 @@ void VisuGUI_CutLinesDlg::onValueChanged (int theRow, int theCol)
     QString aTxt = myPosTable->text(theRow, 0);
     bool isChanged = !aTxt.isEmpty();
     ((QCheckTableItem*)myPosTable->item(theRow, 1))->setChecked(!isChanged);
-
-    //jfa tmp:if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) {
+    SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
+    if (aView) {
       if (myPreviewCheck->isChecked()) {
        //Update Preview
-       myCutLines->SetLinePosition( theRow, aTxt.toDouble());
-       myCutLines->GetPL()->Update();
+       //myCutLines->SetLinePosition( theRow, aTxt.toDouble());
+       //      myCutLines->GetPL()->Update();
        deletePlanes();
        createPlanes();
-       //jfa tmp:vf->Repaint();
+       //aView->Repaint();
       }
-    //jfa tmp:}
-  } else {
+    }
+  } else if (theCol == 1){
     bool isDefault = ((QCheckTableItem*)myPosTable->item(theRow, theCol))->isChecked();
     if (isDefault) {
-      myCutLines->SetDefaultPosition(theRow);
-      myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow)));
-
-      //jfa tmp:if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) {
+      //myCutLines->SetDefaultPosition(theRow);
+      // myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow)));
+      SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
+      if (aView) {
        if (myPreviewCheck->isChecked()) {
          //Update Preview
-         myCutLines->GetPL()->Update();
+         //      myCutLines->GetPL()->Update();
          deletePlanes();
          createPlanes();
-         //jfa tmp:vf->Repaint();
+         //aView->Repaint();
        }
-      //jfa tmp:}
+      }
+      myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow)));
     }
     myPosTable->item(theRow, 0)->setEnabled(!isDefault);
   }
@@ -618,13 +719,17 @@ void VisuGUI_CutLinesDlg::onValueChanged (int theRow, int theCol)
 
 void VisuGUI_CutLinesDlg::accept()
 {
+  //if ( !VisuGUI::CheckActiveStudyLock() ) {
+  //  reject();
+  //  return;
+  //}
   MYGenerateTable = myCreateTable->isChecked();
   MYGenerateCurve = myCurvesCheck->isChecked();
-  if (myScalarPane->check()) {
-    /*((QWidget*)sender())->setDisabled(true);
+  //  if (myScalarPane->check()) {
+    /*jfa tmp:((QWidget*)sender())->setDisabled(true);
     storeToPrsObject(myPrs);
     if (myIsCreation) {
-      jfa tmp:if (isGenerateTable()) {
+      if (isGenerateTable()) {
        visuGUI->GetVisuGen()->CreateTable(myPrs->GetEntry());
        if (isGenerateCurves()) {
          SALOMEDSClient_Study* aStudy = study()->studyDS();
@@ -697,65 +802,87 @@ void VisuGUI_CutLinesDlg::accept()
       }
     }
     VisuGUI::application()->objectBrowser()->updateTree();*/
+    myScalarPane->deletePreview();
+    deletePlanes();
     QDialog::accept();
-  }
+    //  }
 }
 
 void VisuGUI_CutLinesDlg::reject()
 {
-  /*if (myIsCreation) {
-    visuGUI->DeletePresentation(myPrs);
+  /*jfa tmp:if (myIsCreation) {
+    myPrs->RemoveFromStudy();
     VisuGUI::application()->objectBrowser()->updateTree();
   }*/
+  myScalarPane->deletePreview();
+  deletePlanes();
   QDialog::reject();
 }
 
 void VisuGUI_CutLinesDlg::onPreviewCheck (bool thePreview)
 {
-  /*jfa tmp:if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) {
+  if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
     if (thePreview) {
-      storeToPrsObject(myCutLines);
-      myCutLines->GetPL()->Update();
+      //storeToPrsObject(myCutLines);
+      //      myCutLines->GetPL()->Update();
       createPlanes();
-      vf->onFitAll();
+      //vf->onFitAll();
     } else {
       deletePlanes();
       vf->Repaint();
     }
-  }*/
+  }
+}
+
+/*! Inverting all curves in the table
+ */
+void VisuGUI_CutLinesDlg::onAllCurvesInvertedCheck(bool theInvert)
+{
+  if (myAllCurvesInvertedCheck->isChecked()){
+    myCutLines->SetAllCurvesInverted(true);
+    myPrs->SetAllCurvesInverted(true);
+  }
+  else {
+    myCutLines->SetAllCurvesInverted(false);
+    myPrs->SetAllCurvesInverted(false);
+  }
+  updateGlyphs(true);
 }
 
 void VisuGUI_CutLinesDlg::onRotation (double theValue)
 {
   if (myCutLines == NULL) return;
-  //jfa tmp:if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) {
+  SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
+  if (aView) {
     if (myPreviewCheck->isChecked()) {
-      myCutLines->SetOrientation(getOrientaion(),
+
+      /*myCutLines->SetOrientation(getOrientaion(),
                                  myRotXSpn->value()*PI/180.,
                                  myRotYSpn->value()*PI/180.);
       myCutLines->SetOrientation2(getOrientaion(false),
                                   myRotXSpn2->value()*PI/180.,
-                                  myRotYSpn2->value()*PI/180.);
-      myCutLines->GetPL()->Update();
+                                  myRotYSpn2->value()*PI/180.);*/
+      //      myCutLines->GetPL()->Update();
       deletePlanes();
       createPlanes();
-      //jfa tmp:vf->Repaint();
+      //aView->Repaint();
     }
-  //jfa tmp:}
+  }
 }
 
 void VisuGUI_CutLinesDlg::onPlanePos (const QString& theValue)
 {
   if (myCutLines == NULL) return;
-  //jfa tmp:if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) {
+  SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
+  if (aView) {
     if (myPreviewCheck->isChecked()) {
-      myCutLines->SetBasePlanePosition(theValue.toDouble());
-      myCutLines->GetPL()->Update();
+      //myCutLines->SetBasePlanePosition(theValue.toDouble());
+      //      myCutLines->GetPL()->Update();
       deletePlanes();
       createPlanes();
-      //jfa tmp:vf->Repaint();
+      //aView->Repaint();
     }
-  //jfa tmp:}
+  }
 }
 
 //jfa tmp:void VisuGUI_CutLinesDlg::onWindowActivated (SUIT_ViewWindow* theWnd)