| 754 | } |
| 755 | |
| 756 | void vtkBoxWidget::OnMouseMove() |
| 757 | { |
| 758 | // See whether we're active |
| 759 | if (this->State == vtkBoxWidget::Outside || this->State == vtkBoxWidget::Start) |
| 760 | { |
| 761 | return; |
| 762 | } |
| 763 | |
| 764 | int X = this->Interactor->GetEventPosition()[0]; |
| 765 | int Y = this->Interactor->GetEventPosition()[1]; |
| 766 | |
| 767 | // Do different things depending on state |
| 768 | // Calculations everybody does |
| 769 | double focalPoint[4], pickPoint[4], prevPickPoint[4]; |
| 770 | double z, vpn[3]; |
| 771 | |
| 772 | vtkCamera* camera = this->CurrentRenderer->GetActiveCamera(); |
| 773 | if (!camera) |
| 774 | { |
| 775 | return; |
| 776 | } |
| 777 | |
| 778 | // Compute the two points defining the motion vector |
| 779 | this->ComputeWorldToDisplay( |
| 780 | this->LastPickPosition[0], this->LastPickPosition[1], this->LastPickPosition[2], focalPoint); |
| 781 | z = focalPoint[2]; |
| 782 | this->ComputeDisplayToWorld(double(this->Interactor->GetLastEventPosition()[0]), |
| 783 | double(this->Interactor->GetLastEventPosition()[1]), z, prevPickPoint); |
| 784 | this->ComputeDisplayToWorld(double(X), double(Y), z, pickPoint); |
| 785 | |
| 786 | // Process the motion |
| 787 | if (this->State == vtkBoxWidget::Moving) |
| 788 | { |
| 789 | // Okay to process |
| 790 | if (this->CurrentHandle) |
| 791 | { |
| 792 | if (this->RotationEnabled && this->CurrentHandle == this->HexFace) |
| 793 | { |
| 794 | camera->GetViewPlaneNormal(vpn); |
| 795 | this->Rotate(X, Y, prevPickPoint, pickPoint, vpn); |
| 796 | } |
| 797 | else if (this->TranslationEnabled && this->CurrentHandle == this->Handle[6]) |
| 798 | { |
| 799 | this->Translate(prevPickPoint, pickPoint); |
| 800 | } |
| 801 | else if (this->TranslationEnabled && this->ScalingEnabled) |
| 802 | { |
| 803 | if (this->CurrentHandle == this->Handle[0]) |
| 804 | { |
| 805 | this->MoveMinusXFace(prevPickPoint, pickPoint); |
| 806 | } |
| 807 | else if (this->CurrentHandle == this->Handle[1]) |
| 808 | { |
| 809 | this->MovePlusXFace(prevPickPoint, pickPoint); |
| 810 | } |
| 811 | else if (this->CurrentHandle == this->Handle[2]) |
| 812 | { |
| 813 | this->MoveMinusYFace(prevPickPoint, pickPoint); |
no test coverage detected