Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add zoom to mouse position #1199

Merged
merged 7 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ f3d_test(NAME TestInteractionEmptyLoadParentDirectory INTERACTION NO_BASELINE RE
f3d_test(NAME TestInteractionGroupGeometriesLoadParentDirectory DATA mb/mb_0_0.vtu ARGS --group-geometries --filename INTERACTION DEFAULT_LIGHTS) #Down;
f3d_test(NAME TestInteractionInvertZoom DATA suzanne.ply ARGS --invert-zoom INTERACTION DEFAULT_LIGHTS)
f3d_test(NAME TestInteractionCameraHotkeys DATA cow.vtp INTERACTION DEFAULT_LIGHTS)
f3d_test(NAME TestInteractionZoomToMouse DATA cow.vtp INTERACTION DEFAULT_LIGHTS)

# Progress test
f3d_test(NAME TestProgress DATA cow.vtp ARGS --progress NO_BASELINE)
Expand Down
45 changes: 44 additions & 1 deletion library/VTKExtensions/Rendering/vtkF3DInteractorStyle.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,50 @@ void vtkF3DInteractorStyle::Dolly(double factor)
{
return;
}
this->Superclass::Dolly(factor);
if (this->Interactor->GetControlKey())
{
vtkF3DInteractorStyle::DollyToPosition(
factor, this->Interactor->GetEventPosition(), this->CurrentRenderer);
}
else
{
this->Superclass::Dolly(factor);
}
}

//----------------------------------------------------------------------------
void vtkF3DInteractorStyle::DollyToPosition(double factor, int* position, vtkRenderer* renderer)
{
vtkCamera* cam = renderer->GetActiveCamera();
double viewFocus[4], originalViewFocus[3], cameraPos[3], newCameraPos[3];
double newFocalPoint[4], norm[3];

// Move focal point to cursor position
cam->GetPosition(cameraPos);
cam->GetFocalPoint(viewFocus);
cam->GetFocalPoint(originalViewFocus);
cam->GetViewPlaneNormal(norm);

vtkF3DInteractorStyle::ComputeWorldToDisplay(
renderer, viewFocus[0], viewFocus[1], viewFocus[2], viewFocus);

vtkF3DInteractorStyle::ComputeDisplayToWorld(
renderer, double(position[0]), double(position[1]), viewFocus[2], newFocalPoint);

cam->SetFocalPoint(newFocalPoint);

// Move camera in/out along projection direction
cam->Dolly(factor);

// Find new focal point
cam->GetPosition(newCameraPos);

double newPoint[3];
newPoint[0] = originalViewFocus[0] + newCameraPos[0] - cameraPos[0];
newPoint[1] = originalViewFocus[1] + newCameraPos[1] - cameraPos[1];
newPoint[2] = originalViewFocus[2] + newCameraPos[2] - cameraPos[2];

cam->SetFocalPoint(newPoint);
}

//----------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions library/VTKExtensions/Rendering/vtkF3DInteractorStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class vtkF3DInteractorStyle : public vtkInteractorStyleTrackballCamera
void Dolly() override;
///@}

/**
* Dolly the renderer's camera to a specific point
*/
void DollyToPosition(double fact, int* position, vtkRenderer* renderer);
0x006E marked this conversation as resolved.
Show resolved Hide resolved

/**
* Overridden to rotate the skybox as well
*/
Expand Down
3 changes: 3 additions & 0 deletions testing/baselines/TestInteractionZoomToMouse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
293 changes: 293 additions & 0 deletions testing/recordings/TestInteractionZoomToMouse.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
# StreamVersion 1.2
ExposeEvent 0 599 0 0 0 0 0
RenderEvent 0 599 0 0 0 0 0
EnterEvent 2 331 0 0 0 0 0
MouseMoveEvent 2 331 0 0 0 0 0
MouseMoveEvent 6 333 0 0 0 0 0
MouseMoveEvent 11 334 0 0 0 0 0
MouseMoveEvent 16 336 0 0 0 0 0
MouseMoveEvent 23 338 0 0 0 0 0
MouseMoveEvent 29 340 0 0 0 0 0
MouseMoveEvent 36 342 0 0 0 0 0
MouseMoveEvent 43 343 0 0 0 0 0
MouseMoveEvent 51 345 0 0 0 0 0
MouseMoveEvent 60 347 0 0 0 0 0
MouseMoveEvent 69 349 0 0 0 0 0
MouseMoveEvent 79 350 0 0 0 0 0
MouseMoveEvent 89 352 0 0 0 0 0
MouseMoveEvent 98 353 0 0 0 0 0
MouseMoveEvent 108 354 0 0 0 0 0
MouseMoveEvent 117 354 0 0 0 0 0
MouseMoveEvent 127 354 0 0 0 0 0
MouseMoveEvent 136 354 0 0 0 0 0
MouseMoveEvent 145 354 0 0 0 0 0
MouseMoveEvent 154 354 0 0 0 0 0
MouseMoveEvent 165 354 0 0 0 0 0
MouseMoveEvent 176 354 0 0 0 0 0
MouseMoveEvent 186 354 0 0 0 0 0
MouseMoveEvent 196 353 0 0 0 0 0
MouseMoveEvent 206 352 0 0 0 0 0
MouseMoveEvent 216 351 0 0 0 0 0
MouseMoveEvent 226 350 0 0 0 0 0
MouseMoveEvent 235 349 0 0 0 0 0
MouseMoveEvent 243 347 0 0 0 0 0
MouseMoveEvent 251 345 0 0 0 0 0
MouseMoveEvent 260 343 0 0 0 0 0
MouseMoveEvent 269 340 0 0 0 0 0
MouseMoveEvent 279 338 0 0 0 0 0
MouseMoveEvent 289 336 0 0 0 0 0
MouseMoveEvent 299 334 0 0 0 0 0
MouseMoveEvent 309 332 0 0 0 0 0
MouseMoveEvent 320 330 0 0 0 0 0
MouseMoveEvent 331 328 0 0 0 0 0
MouseMoveEvent 341 325 0 0 0 0 0
MouseMoveEvent 351 323 0 0 0 0 0
MouseMoveEvent 360 321 0 0 0 0 0
MouseMoveEvent 369 320 0 0 0 0 0
MouseMoveEvent 377 318 0 0 0 0 0
MouseMoveEvent 384 317 0 0 0 0 0
MouseMoveEvent 392 315 0 0 0 0 0
MouseMoveEvent 399 314 0 0 0 0 0
MouseMoveEvent 407 313 0 0 0 0 0
MouseMoveEvent 414 313 0 0 0 0 0
MouseMoveEvent 421 312 0 0 0 0 0
MouseMoveEvent 428 311 0 0 0 0 0
MouseMoveEvent 434 309 0 0 0 0 0
MouseMoveEvent 440 308 0 0 0 0 0
MouseMoveEvent 445 307 0 0 0 0 0
MouseMoveEvent 449 307 0 0 0 0 0
MouseMoveEvent 452 306 0 0 0 0 0
MouseMoveEvent 455 305 0 0 0 0 0
MouseMoveEvent 458 305 0 0 0 0 0
MouseMoveEvent 460 305 0 0 0 0 0
MouseMoveEvent 462 304 0 0 0 0 0
MouseMoveEvent 463 304 0 0 0 0 0
MouseMoveEvent 464 304 0 0 0 0 0
MouseMoveEvent 465 304 0 0 0 0 0
MouseMoveEvent 466 304 0 0 0 0 0
MouseMoveEvent 467 304 0 0 0 0 0
MouseMoveEvent 468 304 0 0 0 0 0
MouseMoveEvent 471 308 0 0 0 0 0
MouseMoveEvent 476 314 0 0 0 0 0
MouseMoveEvent 484 322 0 0 0 0 0
MouseMoveEvent 495 333 0 0 0 0 0
MouseMoveEvent 509 345 0 0 0 0 0
MouseMoveEvent 523 357 0 0 0 0 0
MouseMoveEvent 537 367 0 0 0 0 0
MouseMoveEvent 551 377 0 0 0 0 0
MouseMoveEvent 565 388 0 0 0 0 0
MouseMoveEvent 579 398 0 0 0 0 0
MouseMoveEvent 590 405 0 0 0 0 0
MouseMoveEvent 601 411 0 0 0 0 0
MouseMoveEvent 609 416 0 0 0 0 0
MouseMoveEvent 616 420 0 0 0 0 0
MouseMoveEvent 624 423 0 0 0 0 0
MouseMoveEvent 632 427 0 0 0 0 0
MouseMoveEvent 641 430 0 0 0 0 0
MouseMoveEvent 650 434 0 0 0 0 0
MouseMoveEvent 658 437 0 0 0 0 0
MouseMoveEvent 666 440 0 0 0 0 0
MouseMoveEvent 673 443 0 0 0 0 0
MouseMoveEvent 681 446 0 0 0 0 0
MouseMoveEvent 689 449 0 0 0 0 0
MouseMoveEvent 696 452 0 0 0 0 0
MouseMoveEvent 703 455 0 0 0 0 0
MouseMoveEvent 708 457 0 0 0 0 0
MouseMoveEvent 712 459 0 0 0 0 0
MouseMoveEvent 716 461 0 0 0 0 0
MouseMoveEvent 720 462 0 0 0 0 0
MouseMoveEvent 723 463 0 0 0 0 0
MouseMoveEvent 726 465 0 0 0 0 0
MouseMoveEvent 729 466 0 0 0 0 0
MouseMoveEvent 732 467 0 0 0 0 0
MouseMoveEvent 735 469 0 0 0 0 0
MouseMoveEvent 738 470 0 0 0 0 0
MouseMoveEvent 741 471 0 0 0 0 0
MouseMoveEvent 744 472 0 0 0 0 0
MouseMoveEvent 747 473 0 0 0 0 0
MouseMoveEvent 750 474 0 0 0 0 0
MouseMoveEvent 752 475 0 0 0 0 0
MouseMoveEvent 754 475 0 0 0 0 0
MouseMoveEvent 756 475 0 0 0 0 0
MouseMoveEvent 758 476 0 0 0 0 0
MouseMoveEvent 759 476 0 0 0 0 0
MouseMoveEvent 761 476 0 0 0 0 0
MouseMoveEvent 763 477 0 0 0 0 0
MouseMoveEvent 766 477 0 0 0 0 0
MouseMoveEvent 768 478 0 0 0 0 0
MouseMoveEvent 770 478 0 0 0 0 0
MouseMoveEvent 773 478 0 0 0 0 0
MouseMoveEvent 775 479 0 0 0 0 0
MouseMoveEvent 778 479 0 0 0 0 0
MouseMoveEvent 780 479 0 0 0 0 0
MouseMoveEvent 783 480 0 0 0 0 0
MouseMoveEvent 785 480 0 0 0 0 0
MouseMoveEvent 787 480 0 0 0 0 0
MouseMoveEvent 789 480 0 0 0 0 0
MouseMoveEvent 790 480 0 0 0 0 0
MouseMoveEvent 792 480 0 0 0 0 0
MouseMoveEvent 794 480 0 0 0 0 0
MouseMoveEvent 795 480 0 0 0 0 0
MouseMoveEvent 796 480 0 0 0 0 0
MouseMoveEvent 798 480 0 0 0 0 0
MouseMoveEvent 799 480 0 0 0 0 0
MouseMoveEvent 800 480 0 0 0 0 0
MouseMoveEvent 801 480 0 0 0 0 0
MouseMoveEvent 802 479 0 0 0 0 0
MouseMoveEvent 803 479 0 0 0 0 0
MouseMoveEvent 804 479 0 0 0 0 0
MouseMoveEvent 805 478 0 0 0 0 0
MouseMoveEvent 806 478 0 0 0 0 0
MouseMoveEvent 807 478 0 0 0 0 0
MouseMoveEvent 808 478 0 0 0 0 0
MouseMoveEvent 809 478 0 0 0 0 0
MouseMoveEvent 810 478 0 0 0 0 0
MouseMoveEvent 810 477 0 0 0 0 0
MouseMoveEvent 811 477 0 0 0 0 0
MouseMoveEvent 811 476 0 0 0 0 0
MouseMoveEvent 810 476 0 0 0 0 0
MouseMoveEvent 810 475 0 0 0 0 0
MouseMoveEvent 809 474 0 0 0 0 0
KeyPressEvent 809 474 0 0 1 Control_L 0
CharEvent 809 474 0 0 1 Control_L 0
MouseWheelBackwardEvent 808 474 2 0 0 Control_L 0
StartInteractionEvent 808 474 2 0 0 Control_L 0
EndInteractionEvent 808 474 2 0 0 Control_L 0
RenderEvent 808 474 2 0 0 Control_L 0
MouseWheelBackwardEvent 808 474 2 0 1 Control_L 0
StartInteractionEvent 808 474 2 0 1 Control_L 0
EndInteractionEvent 808 474 2 0 1 Control_L 0
RenderEvent 808 474 2 0 1 Control_L 0
MouseWheelForwardEvent 808 474 2 0 0 Control_L 0
StartInteractionEvent 808 474 2 0 0 Control_L 0
EndInteractionEvent 808 474 2 0 0 Control_L 0
RenderEvent 808 474 2 0 0 Control_L 0
MouseWheelForwardEvent 808 474 2 0 0 Control_L 0
StartInteractionEvent 808 474 2 0 0 Control_L 0
EndInteractionEvent 808 474 2 0 0 Control_L 0
RenderEvent 808 474 2 0 0 Control_L 0
MouseWheelForwardEvent 808 474 2 0 1 Control_L 0
StartInteractionEvent 808 474 2 0 1 Control_L 0
EndInteractionEvent 808 474 2 0 1 Control_L 0
RenderEvent 808 474 2 0 1 Control_L 0
MouseWheelForwardEvent 808 474 2 0 0 Control_L 0
StartInteractionEvent 808 474 2 0 0 Control_L 0
EndInteractionEvent 808 474 2 0 0 Control_L 0
RenderEvent 808 474 2 0 0 Control_L 0
MouseWheelBackwardEvent 808 474 2 0 0 Control_L 0
StartInteractionEvent 808 474 2 0 0 Control_L 0
EndInteractionEvent 808 474 2 0 0 Control_L 0
RenderEvent 808 474 2 0 0 Control_L 0
MouseMoveEvent 797 471 2 0 0 Control_L 0
MouseMoveEvent 756 462 2 0 0 Control_L 0
MouseMoveEvent 711 453 2 0 0 Control_L 0
MouseMoveEvent 662 442 2 0 0 Control_L 0
MouseMoveEvent 658 441 2 0 0 Control_L 0
MouseMoveEvent 627 434 2 0 0 Control_L 0
MouseMoveEvent 572 420 2 0 0 Control_L 0
MouseMoveEvent 515 407 2 0 0 Control_L 0
MouseMoveEvent 478 398 2 0 0 Control_L 0
MouseMoveEvent 445 390 2 0 0 Control_L 0
MouseMoveEvent 407 383 2 0 0 Control_L 0
MouseMoveEvent 371 375 2 0 0 Control_L 0
MouseMoveEvent 345 370 2 0 0 Control_L 0
MouseMoveEvent 318 365 2 0 0 Control_L 0
MouseMoveEvent 292 360 2 0 0 Control_L 0
MouseMoveEvent 266 356 2 0 0 Control_L 0
MouseMoveEvent 252 354 2 0 0 Control_L 0
MouseMoveEvent 237 352 2 0 0 Control_L 0
MouseMoveEvent 228 352 2 0 0 Control_L 0
MouseMoveEvent 222 352 2 0 0 Control_L 0
MouseMoveEvent 215 352 2 0 0 Control_L 0
MouseMoveEvent 214 352 2 0 0 Control_L 0
MouseMoveEvent 213 352 2 0 0 Control_L 0
MouseMoveEvent 211 352 2 0 0 Control_L 0
MouseMoveEvent 210 353 2 0 0 Control_L 0
MouseMoveEvent 209 353 2 0 0 Control_L 0
MouseMoveEvent 208 354 2 0 0 Control_L 0
MouseMoveEvent 207 354 2 0 0 Control_L 0
MouseMoveEvent 206 355 2 0 0 Control_L 0
MouseMoveEvent 206 356 2 0 0 Control_L 0
MouseMoveEvent 205 356 2 0 0 Control_L 0
MouseMoveEvent 205 357 2 0 0 Control_L 0
MouseMoveEvent 204 358 2 0 0 Control_L 0
MouseMoveEvent 204 359 2 0 0 Control_L 0
MouseMoveEvent 204 360 2 0 0 Control_L 0
MouseMoveEvent 204 361 2 0 0 Control_L 0
MouseMoveEvent 204 362 2 0 0 Control_L 0
MouseMoveEvent 203 363 2 0 0 Control_L 0
MouseMoveEvent 202 364 2 0 0 Control_L 0
MouseMoveEvent 201 365 2 0 0 Control_L 0
MouseMoveEvent 200 365 2 0 0 Control_L 0
MouseMoveEvent 199 366 2 0 0 Control_L 0
MouseMoveEvent 197 367 2 0 0 Control_L 0
MouseMoveEvent 196 368 2 0 0 Control_L 0
MouseMoveEvent 194 369 2 0 0 Control_L 0
MouseMoveEvent 192 370 2 0 0 Control_L 0
MouseMoveEvent 190 371 2 0 0 Control_L 0
MouseMoveEvent 188 373 2 0 0 Control_L 0
MouseMoveEvent 186 376 2 0 0 Control_L 0
MouseMoveEvent 185 377 2 0 0 Control_L 0
MouseMoveEvent 183 380 2 0 0 Control_L 0
MouseMoveEvent 182 382 2 0 0 Control_L 0
MouseMoveEvent 180 385 2 0 0 Control_L 0
MouseMoveEvent 179 387 2 0 0 Control_L 0
MouseMoveEvent 178 389 2 0 0 Control_L 0
MouseMoveEvent 177 392 2 0 0 Control_L 0
MouseMoveEvent 177 393 2 0 0 Control_L 0
MouseMoveEvent 176 395 2 0 0 Control_L 0
MouseMoveEvent 176 396 2 0 0 Control_L 0
MouseMoveEvent 175 397 2 0 0 Control_L 0
MouseMoveEvent 175 398 2 0 0 Control_L 0
MouseMoveEvent 175 399 2 0 0 Control_L 0
MouseMoveEvent 175 400 2 0 0 Control_L 0
MouseMoveEvent 175 401 2 0 0 Control_L 0
MouseWheelBackwardEvent 175 402 2 0 0 Control_L 0
StartInteractionEvent 175 402 2 0 0 Control_L 0
EndInteractionEvent 175 402 2 0 0 Control_L 0
RenderEvent 175 402 2 0 0 Control_L 0
MouseWheelForwardEvent 175 402 2 0 0 Control_L 0
StartInteractionEvent 175 402 2 0 0 Control_L 0
EndInteractionEvent 175 402 2 0 0 Control_L 0
RenderEvent 175 402 2 0 0 Control_L 0
MouseWheelForwardEvent 175 402 2 0 1 Control_L 0
StartInteractionEvent 175 402 2 0 1 Control_L 0
EndInteractionEvent 175 402 2 0 1 Control_L 0
RenderEvent 175 402 2 0 1 Control_L 0
MouseWheelForwardEvent 175 402 2 0 0 Control_L 0
StartInteractionEvent 175 402 2 0 0 Control_L 0
EndInteractionEvent 175 402 2 0 0 Control_L 0
RenderEvent 175 402 2 0 0 Control_L 0
MouseWheelForwardEvent 175 402 2 0 1 Control_L 0
StartInteractionEvent 175 402 2 0 1 Control_L 0
EndInteractionEvent 175 402 2 0 1 Control_L 0
RenderEvent 175 402 2 0 1 Control_L 0
MouseWheelBackwardEvent 175 402 2 0 0 Control_L 0
StartInteractionEvent 175 402 2 0 0 Control_L 0
EndInteractionEvent 175 402 2 0 0 Control_L 0
RenderEvent 175 402 2 0 0 Control_L 0
MouseWheelBackwardEvent 175 402 2 0 1 Control_L 0
StartInteractionEvent 175 402 2 0 1 Control_L 0
EndInteractionEvent 175 402 2 0 1 Control_L 0
RenderEvent 175 402 2 0 1 Control_L 0
MouseWheelBackwardEvent 175 402 2 0 0 Control_L 0
StartInteractionEvent 175 402 2 0 0 Control_L 0
EndInteractionEvent 175 402 2 0 0 Control_L 0
RenderEvent 175 402 2 0 0 Control_L 0
MouseWheelBackwardEvent 175 402 2 0 0 Control_L 0
StartInteractionEvent 175 402 2 0 0 Control_L 0
EndInteractionEvent 175 402 2 0 0 Control_L 0
RenderEvent 175 402 2 0 0 Control_L 0
MouseWheelBackwardEvent 175 402 2 0 1 Control_L 0
StartInteractionEvent 175 402 2 0 1 Control_L 0
EndInteractionEvent 175 402 2 0 1 Control_L 0
RenderEvent 175 402 2 0 1 Control_L 0
MouseWheelForwardEvent 175 402 2 0 0 Control_L 0
StartInteractionEvent 175 402 2 0 0 Control_L 0
EndInteractionEvent 175 402 2 0 0 Control_L 0
RenderEvent 175 402 2 0 0 Control_L 0
MouseWheelForwardEvent 175 402 2 0 0 Control_L 0
StartInteractionEvent 175 402 2 0 0 Control_L 0
EndInteractionEvent 175 402 2 0 0 Control_L 0
RenderEvent 175 402 2 0 0 Control_L 0
KeyReleaseEvent 175 402 2 0 1 Control_L 0
Loading