]> SALOME platform Git repositories - modules/visu.git/blobdiff - src/VISUGUI/VisuGUI_ClippingDlg.cxx
Salome HOME
Merge from BR_WIN_INDUS_514 branch 21/03/2011 (Windows industrialization)
[modules/visu.git] / src / VISUGUI / VisuGUI_ClippingDlg.cxx
index 0f9bea8d3ad1e75a63fa9603f95cc4c915483286..458a8058cd3fbc89a6c491cc7fa6e86b53a293bc 100644 (file)
@@ -31,6 +31,7 @@
 #include "VISU_ColoredPrs3dHolder_i.hh"
 
 #include "VISU_PipeLine.hxx"
+#include "VISU_PipeLineUtils.hxx"
 #include "VISU_DataSetActor.h"
 
 #include <SalomeApp_IntSpinBox.h>
@@ -948,16 +949,23 @@ void VisuGUI_ClippingDlg::SetCurrentPlaneParam()
 
   myPrs3d->SetPlaneParam(aNormal, 1. - getDistance(), aPlane);
 
-  vtkDataSet* aDataSet = myPrs3d->GetInput();
-  vtkFloatingPointType *aPnt = aDataSet->GetCenter();
+  //Get bounds of the visible part of the dataset
+  vtkFloatingPointType aBounds[6];
+  myPrs3d->GetPipeLine()->GetVisibleBounds(aBounds);
 
-  vtkFloatingPointType* anOrigin = aPlane->GetOrigin();
-  vtkFloatingPointType aDel = aDataSet->GetLength()/2.0;
+  //Get center 
+  vtkFloatingPointType aPnt[3];
+  VISU::ComputeBoxCenter(aBounds,aPnt);
 
+  vtkFloatingPointType* anOrigin = aPlane->GetOrigin();
+  
+  //Get Length of the diagonal
+  vtkFloatingPointType aDel = VISU::ComputeBoxDiagonal(aBounds)/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]};
@@ -1014,7 +1022,7 @@ void VisuGUI_ClippingDlg::onTabChanged(QWidget* newTab)
 // purpose  : set non structured parameters by IJK parameters
 //=================================================================================
 void VisuGUI_ClippingDlg::SetCurrentPlaneIJKParam()
-{
+{  
   if (myPlanes.empty() || myIsSelectPlane || !WidgetIJKTab->isEnabled())
     return;
 
@@ -1139,11 +1147,11 @@ void VisuGUI_ClippingDlg::setIJKByNonStructured()
   // find index value
   double v = SpinBoxDistance->value();
   // reverse value?
-//   bool reverse = (normal * axDir < 0); // normal and axis are opposite
-//   if (gridDir * axDir < 0) // grid dir and axis are opposite
-//     reverse = !reverse;
-//   if (reverse)
-//     v = 1. - v;
+   bool reverse = (normal * axDir < 0); // normal and axis are opposite
+   if (gridDir * axDir < 0) // grid dir and axis are opposite
+     reverse = !reverse;
+   if (reverse)
+     v = 1. - v;
   for (i = 0; i < values->size(); ++i)
     if ((*values)[ i ] > v)
       break;
@@ -1153,11 +1161,11 @@ void VisuGUI_ClippingDlg::setIJKByNonStructured()
     --i;
 
   // set control values
+  onIJKAxisChanged(gridAxId); // first of all update label and range of index
   myIsSelectPlane = true;
   CheckBoxIJKPlaneReverse->setChecked(normal * axDir < 0);
   SpinBoxIJKIndex->setValue(i);
   ButtonGroupIJKAxis->button(gridAxId)->setChecked( true );
-  onIJKAxisChanged(gridAxId); // update label and range of index
   myIsSelectPlane = false;
 
   SetCurrentPlaneIJKParam();