| 444 | } |
| 445 | |
| 446 | void vtkPointWidget::OnMouseMove() |
| 447 | { |
| 448 | // See whether we're active |
| 449 | if (this->State == vtkPointWidget::Outside || this->State == vtkPointWidget::Start) |
| 450 | { |
| 451 | return; |
| 452 | } |
| 453 | |
| 454 | int X = this->Interactor->GetEventPosition()[0]; |
| 455 | int Y = this->Interactor->GetEventPosition()[1]; |
| 456 | |
| 457 | // Do different things depending on state |
| 458 | // Calculations everybody does |
| 459 | double focalPoint[4], pickPoint[4], prevPickPoint[4]; |
| 460 | double z; |
| 461 | |
| 462 | vtkCamera* camera = this->CurrentRenderer->GetActiveCamera(); |
| 463 | if (!camera) |
| 464 | { |
| 465 | return; |
| 466 | } |
| 467 | |
| 468 | // Compute the two points defining the motion vector |
| 469 | this->ComputeWorldToDisplay( |
| 470 | this->LastPickPosition[0], this->LastPickPosition[1], this->LastPickPosition[2], focalPoint); |
| 471 | z = focalPoint[2]; |
| 472 | this->ComputeDisplayToWorld(double(this->Interactor->GetLastEventPosition()[0]), |
| 473 | double(this->Interactor->GetLastEventPosition()[1]), z, prevPickPoint); |
| 474 | this->ComputeDisplayToWorld(double(X), double(Y), z, pickPoint); |
| 475 | |
| 476 | // Process the motion |
| 477 | if (this->State == vtkPointWidget::Moving) |
| 478 | { |
| 479 | if (!this->WaitingForMotion || this->WaitCount++ > 3) |
| 480 | { |
| 481 | this->ConstraintAxis = this->DetermineConstraintAxis(this->ConstraintAxis, pickPoint); |
| 482 | this->MoveFocus(prevPickPoint, pickPoint); |
| 483 | } |
| 484 | else |
| 485 | { |
| 486 | return; // avoid the extra render |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | else if (this->State == vtkPointWidget::Scaling) |
| 491 | { |
| 492 | this->Scale(prevPickPoint, pickPoint, X, Y); |
| 493 | } |
| 494 | |
| 495 | else if (this->State == vtkPointWidget::Translating) |
| 496 | { |
| 497 | if (!this->WaitingForMotion || this->WaitCount++ > 3) |
| 498 | { |
| 499 | this->ConstraintAxis = this->DetermineConstraintAxis(this->ConstraintAxis, pickPoint); |
| 500 | this->Translate(prevPickPoint, pickPoint); |
| 501 | } |
| 502 | else |
| 503 | { |
no test coverage detected