| 572 | } |
| 573 | |
| 574 | void vtkPointWidget::Scale(double* p1, double* p2, int vtkNotUsed(X), int Y) |
| 575 | { |
| 576 | // Get the motion vector |
| 577 | double v[3]; |
| 578 | v[0] = p2[0] - p1[0]; |
| 579 | v[1] = p2[1] - p1[1]; |
| 580 | v[2] = p2[2] - p1[2]; |
| 581 | |
| 582 | // int res = this->Cursor3D->GetResolution(); |
| 583 | double* bounds = this->Cursor3D->GetModelBounds(); |
| 584 | double* focus = this->Cursor3D->GetFocalPoint(); |
| 585 | |
| 586 | // Compute the scale factor |
| 587 | double sf = vtkMath::Norm(v) / |
| 588 | sqrt((bounds[1] - bounds[0]) * (bounds[1] - bounds[0]) + |
| 589 | (bounds[3] - bounds[2]) * (bounds[3] - bounds[2]) + |
| 590 | (bounds[5] - bounds[4]) * (bounds[5] - bounds[4])); |
| 591 | |
| 592 | if (Y > this->Interactor->GetLastEventPosition()[1]) |
| 593 | { |
| 594 | sf = 1.0 + sf; |
| 595 | } |
| 596 | else |
| 597 | { |
| 598 | sf = 1.0 - sf; |
| 599 | } |
| 600 | |
| 601 | // Move the end points |
| 602 | double newBounds[6]; |
| 603 | for (int i = 0; i < 3; i++) |
| 604 | { |
| 605 | newBounds[2 * i] = sf * (bounds[2 * i] - focus[i]) + focus[i]; |
| 606 | newBounds[2 * i + 1] = sf * (bounds[2 * i + 1] - focus[i]) + focus[i]; |
| 607 | } |
| 608 | |
| 609 | this->Cursor3D->SetModelBounds(newBounds); |
| 610 | this->Cursor3D->Update(); |
| 611 | } |
| 612 | |
| 613 | void vtkPointWidget::CreateDefaultProperties() |
| 614 | { |
no test coverage detected