------------------------------------------------------------------------------
| 877 | |
| 878 | //------------------------------------------------------------------------------ |
| 879 | void vtkLineWidget::Scale(double* p1, double* p2, int vtkNotUsed(X), int Y) |
| 880 | { |
| 881 | // Get the motion vector |
| 882 | double v[3]; |
| 883 | v[0] = p2[0] - p1[0]; |
| 884 | v[1] = p2[1] - p1[1]; |
| 885 | v[2] = p2[2] - p1[2]; |
| 886 | |
| 887 | // int res = this->LineSource->GetResolution(); |
| 888 | double* pt1 = this->LineSource->GetPoint1(); |
| 889 | double* pt2 = this->LineSource->GetPoint2(); |
| 890 | |
| 891 | double center[3]; |
| 892 | center[0] = (pt1[0] + pt2[0]) / 2.0; |
| 893 | center[1] = (pt1[1] + pt2[1]) / 2.0; |
| 894 | center[2] = (pt1[2] + pt2[2]) / 2.0; |
| 895 | |
| 896 | // Compute the scale factor |
| 897 | double sf = vtkMath::Norm(v) / sqrt(vtkMath::Distance2BetweenPoints(pt1, pt2)); |
| 898 | if (Y > this->Interactor->GetLastEventPosition()[1]) |
| 899 | { |
| 900 | sf = 1.0 + sf; |
| 901 | } |
| 902 | else |
| 903 | { |
| 904 | sf = 1.0 - sf; |
| 905 | } |
| 906 | |
| 907 | // Move the end points |
| 908 | double point1[3], point2[3]; |
| 909 | for (int i = 0; i < 3; i++) |
| 910 | { |
| 911 | point1[i] = sf * (pt1[i] - center[i]) + center[i]; |
| 912 | point2[i] = sf * (pt2[i] - center[i]) + center[i]; |
| 913 | } |
| 914 | |
| 915 | this->LineSource->SetPoint1(point1); |
| 916 | this->LineSource->SetPoint2(point2); |
| 917 | this->LineSource->Update(); |
| 918 | |
| 919 | this->BuildRepresentation(); |
| 920 | } |
| 921 | |
| 922 | //------------------------------------------------------------------------------ |
| 923 | void vtkLineWidget::CreateDefaultProperties() |
no test coverage detected