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

Add spacenavd motion event support to Placement dialog that allows for object rotation and translation #15375

Closed
wants to merge 0 commits into from

Conversation

pwolny
Copy link

@pwolny pwolny commented Jul 11, 2024

This commit adds spacemouse/spacenavd support to Placement dialog that allows for moving of objects (rotation and translation with 6-axis controller) instead of rotating the view.
It allows for smooth changing of object`s pitch/yaw/roll despite the range limits set in ui spinboxes (object rotation does not stop when reaching the spinbox limit).
When one of the angles exceeds limits set in spinbox all angles are corrected in such a way that the actual direction is still accurate.
Rotation and translation is relative to the main coordinate system (not the current camera view position).

Because this commit is using the Gui::QuantitySpinBox as data storage for object Placement it is susceptible to errors introduced by rounding (inherent to Gui::QuantitySpinBox and configured by decimal places setting).
Rounding errors accumulation is especially visible when using "Rotation axis with angle" in Placement dialog during consecutive calls to "Placement::eventFilter(QObject*, QEvent* ev)". This issue can be circumvented by increasing the decimal places setting in Edit->Preferences->General->Units->Number of decimals.
This can be tested by orienting object in such a way that x/y/z part of direction vector is non zero and then rotating it by 360degrees around any axis - the object does not return to the same, starting orientation when the rounding issue is present.

Code was tested and was working in 3 versions of freecad:

OS: Debian GNU/Linux 12 (bookworm) (X-Cinnamon/lightdm-xsession)
Word size of FreeCAD: 64-bit
Version: 0.22.0dev.38124 (Git)
Build type: Unknown
Branch: spacenav-move-obj
Hash: 4e9e0f4111f137eeec56a6990ee043fe3a2ea3b5
Python 3.11.2, Qt 5.15.8, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: English/United States (en_US)
OS: Debian GNU/Linux 12 (bookworm) (X-Cinnamon/lightdm-xsession)
Word size of FreeCAD: 64-bit
Version: 0.21.2.
Build type: Unknown
Python 3.11.2, Qt 5.15.8, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: English/United States (en_US)
OS: Debian GNU/Linux 12 (bookworm) (X-Cinnamon/lightdm-xsession)
Word size of FreeCAD: 64-bit
Version: 0.20.2.
Build type: Unknown
Python 3.11.2, Qt 5.15.8, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: English/United States (en_US)

Libraries used by above compilations of freecad:

Boost 1_74
Coin3D 4.0.0
Eigen 3.4.0
FreeType 2.12.1
KDL 
libarea 
Open CASCADE Technology 7.6.3
Point Cloud Library 
PyCXX 7.1.9
Python 3.11.2
Qt for Python (PySide) 5.15.8
Qt 5.15.8
Salome SMESH 7.7.1.0
Qt for Python (Shiboken) 5.15.8
vtk 9.1.0
Xerces-C 3.2.4
Zipios++
zlib 1.2.13

@github-actions github-actions bot added the Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD label Jul 11, 2024
@pwolny
Copy link
Author

pwolny commented Jul 11, 2024

one more comment:
Event filter code is capturing events from main window.
I could not get it to work otherwise (SoMouseButtonEvent is possible to use but SoMotion3Event does not trigger).

In my test I have tried to use something like this (tested with only one of the addEventCallback lines in the Placement constructor) :

View3DInventor* mdi = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());

//works and triggers events with mouse.
mdi->getViewer()->addEventCallback(SoMouseButtonEvent::getClassTypeId(), Placement::processMotionEventB);

//does not work.
mdi->getViewer()->addEventCallback(SoMotion3Event::getClassTypeId(), Placement::processMotionEventB);

Unfortunately I could not find on the forum anything specific enough to this problem and the event system.
I would welcome any suggestions on how to properly connect it to the events of active document or pointers where to find any documentation pertaining to the freecad event system (any diagrams?).

@maxwxyz
Copy link
Collaborator

maxwxyz commented Nov 10, 2024

@pwolny could you please resolve the conflicts? TIA

@chennes chennes requested a review from wwmayer November 22, 2024 17:10
@maxwxyz
Copy link
Collaborator

maxwxyz commented Nov 22, 2024

Looked at this at the merge meeting but it still has conflicts. Could you please resolve them?

@pwolny
Copy link
Author

pwolny commented Nov 23, 2024

Closed unintentionally during git conflict resolution/push/branch rename.
Reopened a new pull request ( #18098 ) with resolved conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hardware: 3dconnexion Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants