------------------------------------------------------------------------------
| 1017 | |
| 1018 | //------------------------------------------------------------------------------ |
| 1019 | void vtkLineWidget::SetLinePosition(double x[3]) |
| 1020 | { |
| 1021 | double p1[3], p2[3], v[3]; |
| 1022 | |
| 1023 | // vector of motion |
| 1024 | v[0] = x[0] - this->LastPosition[0]; |
| 1025 | v[1] = x[1] - this->LastPosition[1]; |
| 1026 | v[2] = x[2] - this->LastPosition[2]; |
| 1027 | |
| 1028 | // update position |
| 1029 | this->GetPoint1(p1); |
| 1030 | this->GetPoint2(p2); |
| 1031 | for (int i = 0; i < 3; i++) |
| 1032 | { |
| 1033 | p1[i] += v[i]; |
| 1034 | p2[i] += v[i]; |
| 1035 | } |
| 1036 | |
| 1037 | // See whether we can move |
| 1038 | if (this->ClampToBounds && (!this->InBounds(p1) || !this->InBounds(p2))) |
| 1039 | { |
| 1040 | this->PointWidget->SetPosition(this->LastPosition); |
| 1041 | return; |
| 1042 | } |
| 1043 | |
| 1044 | this->SetPoint1(p1); |
| 1045 | this->SetPoint2(p2); |
| 1046 | |
| 1047 | // remember last position |
| 1048 | this->LastPosition[0] = x[0]; |
| 1049 | this->LastPosition[1] = x[1]; |
| 1050 | this->LastPosition[2] = x[2]; |
| 1051 | } |
| 1052 | |
| 1053 | //------------------------------------------------------------------------------ |
| 1054 | void vtkLineWidget::ClampPosition(double x[3]) |