Salome HOME
Merge with branch V2_2_0_VISU_improvement
[modules/gui.git] / src / VTKViewer / VTKViewer_Transform.cxx
index 6001490e6c6992fbce3fe6707a1b1fdb7319dd28..63d60d66696ce52b3b44d175a1b7e95c970c329c 100755 (executable)
 #include <vtkObjectFactory.h>
 #include <vtkMatrix4x4.h>
 
+static double EPS = 10e-4;
+
 
 vtkStandardNewMacro(VTKViewer_Transform);
 
-void VTKViewer_Transform::SetScale(float theScaleX, float theScaleY, float theScaleZ){ 
+void VTKViewer_Transform::SetMatrixScale(double theScaleX, double theScaleY, double theScaleZ){ 
   double aMatrix[16] = {theScaleX,0,0,0, 
                         0,theScaleY,0,0, 
                         0,0,theScaleZ,0, 
                         0,0,0,1.0000000};
-  vtkTransform::SetMatrix(aMatrix);
+  this->SetMatrix(aMatrix);
+}
+
+void VTKViewer_Transform::GetMatrixScale(double theScale[3]){
+  vtkMatrix4x4 *aTMatrix=this->GetMatrix();
+  const double aScaleX = aTMatrix->GetElement(0,0);
+  const double aScaleY = aTMatrix->GetElement(1,1);
+  const double aScaleZ = aTMatrix->GetElement(2,2);
+  theScale[0] = aScaleX;
+  theScale[1] = aScaleY;
+  theScale[2] = aScaleZ;
 }
 
 int VTKViewer_Transform::IsIdentity(){ 
-  float* aScale = GetScale();
-  return (aScale[0] == 1.0 && aScale[1] == 1.0 && aScale[2] == 1.0);
+  double aScale[3];
+  this->GetMatrixScale(aScale);
+  return (fabs(aScale[0] - 1.0) < EPS && 
+         fabs(aScale[1] - 1.0) < EPS && 
+         fabs(aScale[2] - 1.0) < EPS);
 }