using namespace std;
+static double EPS = 10e-4;
+
vtkStandardNewMacro(SALOME_Transform);
-void SALOME_Transform::SetScale(float theScaleX, float theScaleY, float theScaleZ){
+//void SALOME_Transform::SetScale(float theScaleX, float theScaleY, float theScaleZ){
+// double aMatrix[16] = {theScaleX,0,0,0,
+// 0,theScaleY,0,0,
+// 0,0,theScaleZ,0,
+// 0,0,0,1.0000000};
+// vtkTransform::SetMatrix(aMatrix);
+//}
+
+/*!Sets matrix scale.*/
+void SALOME_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);
+}
+
+/*!Gets matrix scale.*/
+void SALOME_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 SALOME_Transform::IsIdentity(){
- float* aScale = GetScale();
- return (aScale[0] == 1.0 && aScale[1] == 1.0 && aScale[2] == 1.0);
+ //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);
}
static SALOME_Transform *New();
vtkTypeMacro(SALOME_Transform,vtkTransform);
- void SetScale(float theScaleX, float theScaleY, float theScaleZ);
+ //void SetScale(float theScaleX, float theScaleY, float theScaleZ);
int IsIdentity();
+ void SetMatrixScale(double theScaleX, double theScaleY, double theScaleZ);
+ void GetMatrixScale(double theScale[3]);
protected:
SALOME_Transform() {}
}
void VTKViewer_ViewFrame::GetScale(double theScale[3]){
- m_Transform->GetScale(theScale);
+ m_Transform->GetMatrixScale(theScale);
}
void VTKViewer_ViewFrame::SetScale(double theScale[3]){
- m_Transform->SetScale(theScale[0], theScale[1], theScale[2]);
+ m_Transform->SetMatrixScale(theScale[0], theScale[1], theScale[2]);
m_RWInteractor->Render();
Repaint();
}