MCPcopy Create free account
hub / github.com/Kitware/VTK / OnMouseMove

Method OnMouseMove

Interaction/Widgets/vtkSphereWidget.cxx:407–460  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

405
406//------------------------------------------------------------------------------
407void 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//------------------------------------------------------------------------------
463void vtkSphereWidget::OnLeftButtonUp()

Callers 1

ProcessEventsMethod · 0.95

Calls 8

TranslateMethod · 0.95
ScaleSphereMethod · 0.95
MoveHandleMethod · 0.95
GetActiveCameraMethod · 0.80
ComputeWorldToDisplayMethod · 0.80
ComputeDisplayToWorldMethod · 0.80
InvokeEventMethod · 0.80
RenderMethod · 0.65

Tested by

no test coverage detected