I'm trying to add a mode to rotate the model/scene at the bounding box center. This means the model will rotate around its center (like you've done Isometric and Zoom to Fit and the model is in the middle of the screen) even if the model is not in the middle of the screen.
I've modified NavigationStyle.cpp to get the scene boundingBox and set it as the rotationCenter. However I have some trouble understanding the existing code, and the best place to implement the new function.
1. In NavigationStyle.cpp, saveCursorPosition, what does the different cases (ScenePointAtCursor, FocalPointAtCursor) mean? If I understand correctly this has to do with "Rotate at cursor" setting. But what is ScenePoint and what is FocalPoint in this case?
2. This is my code to get the center and set the rotation center. I was thinking to make a third case, RotationAtBoundingBoxCenter, is this a good place to put it? I currently put it in case ScenePointAtCursor to try it out.
Code: Select all
SoGetBoundingBoxAction action(viewer->getSoRenderManager()->getViewportRegion());
SbBox3f boundingBox = action.getBoundingBox();
SbVec3f boundingBoxCenter = boundingBox.getCenter();
setRotationCenter(boundingBoxCenter);
break;
3. Here's how it looks, and it rotates at the models boundingBox center. The problem is that when it's started (mmb held down) the model is "teleported" to the mouse location. I want the model to stay in the same place and rotate. Youtube video link Why does it teleport?
Edit: forgot my FreeCAD info
Code: Select all
OS: Ubuntu 20.04.1 LTS (ubuntu:GNOME/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22882 (Git)
Build type: Unknown
Branch: master
Hash: aebf568eaec7f62b95b29037851c04d1a6f65d47
Python version: 3.8.5
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.3.0
Locale: English/United States (en_US)