------------------------------------------------------------------------------
| 405 | |
| 406 | //------------------------------------------------------------------------------ |
| 407 | void vtkSphereWidget::OnMouseMove() |
| 408 | { |
| 409 | // See whether we're active |
| 410 | if (this->State == vtkSphereWidget::Outside || this->State == vtkSphereWidget::Start) |
| 411 | { |
| 412 | return; |
| 413 | } |
| 414 | |
| 415 | if (!this->Interactor) |
| 416 | { |
| 417 | return; |
| 418 | } |
| 419 | |
| 420 | int X = this->Interactor->GetEventPosition()[0]; |
| 421 | int Y = this->Interactor->GetEventPosition()[1]; |
| 422 | |
| 423 | // Do different things depending on state |
| 424 | // Calculations everybody does |
| 425 | double focalPoint[4], pickPoint[4], prevPickPoint[4]; |
| 426 | double z; |
| 427 | |
| 428 | vtkCamera* camera = this->CurrentRenderer->GetActiveCamera(); |
| 429 | if (!camera) |
| 430 | { |
| 431 | return; |
| 432 | } |
| 433 | |
| 434 | // Compute the two points defining the motion vector |
| 435 | camera->GetFocalPoint(focalPoint); |
| 436 | this->ComputeWorldToDisplay(focalPoint[0], focalPoint[1], focalPoint[2], focalPoint); |
| 437 | z = focalPoint[2]; |
| 438 | this->ComputeDisplayToWorld(double(this->Interactor->GetLastEventPosition()[0]), |
| 439 | double(this->Interactor->GetLastEventPosition()[1]), z, prevPickPoint); |
| 440 | this->ComputeDisplayToWorld(double(X), double(Y), z, pickPoint); |
| 441 | |
| 442 | // Process the motion |
| 443 | if (this->State == vtkSphereWidget::Moving) |
| 444 | { |
| 445 | this->Translate(prevPickPoint, pickPoint); |
| 446 | } |
| 447 | else if (this->State == vtkSphereWidget::Scaling) |
| 448 | { |
| 449 | this->ScaleSphere(prevPickPoint, pickPoint, X, Y); |
| 450 | } |
| 451 | else if (this->State == vtkSphereWidget::Positioning) |
| 452 | { |
| 453 | this->MoveHandle(prevPickPoint, pickPoint, X, Y); |
| 454 | } |
| 455 | |
| 456 | // Interact, if desired |
| 457 | this->EventCallbackCommand->SetAbortFlag(1); |
| 458 | this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); |
| 459 | this->Interactor->Render(); |
| 460 | } |
| 461 | |
| 462 | //------------------------------------------------------------------------------ |
| 463 | void vtkSphereWidget::OnLeftButtonUp() |
no test coverage detected