Skip to content

Commit

Permalink
Merge pull request FreeCAD#17000 from pskowronskiTDx/tdx-mac
Browse files Browse the repository at this point in the history
Enabling 3Dconnexion NavLib integration for MacOS
chennes authored Jan 24, 2025
2 parents c7620fd + 1baee31 commit 836ad91
Showing 5 changed files with 48 additions and 48 deletions.
41 changes: 20 additions & 21 deletions cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake
Original file line number Diff line number Diff line change
@@ -143,31 +143,30 @@ macro(InitializeFreeCADBuildOptions)
option(BUILD_CLOUD "Build the FreeCAD cloud module" OFF)
option(ENABLE_DEVELOPER_TESTS "Build the FreeCAD unit tests suit" ON)

if(MSVC)
if(MSVC OR APPLE)
set(FREECAD_3DCONNEXION_SUPPORT "NavLib" CACHE STRING "Select version of the 3Dconnexion device integration")
set_property(CACHE FREECAD_3DCONNEXION_SUPPORT PROPERTY STRINGS "NavLib" "Raw input" "Both")
option(FREECAD_USE_3DCONNEXION "Use the 3D connexion SDK to support 3d mouse." ON)
elseif(APPLE)
set(FREECAD_USE_3DCONNEXION_RAWINPUT ON)
find_library(3DCONNEXIONCLIENT_FRAMEWORK 3DconnexionClient)
if(IS_DIRECTORY ${3DCONNEXIONCLIENT_FRAMEWORK})
option(FREECAD_USE_3DCONNEXION "Use the 3D connexion SDK to support 3d mouse." ON)
else(IS_DIRECTORY ${3DCONNEXIONCLIENT_FRAMEWORK})
option(FREECAD_USE_3DCONNEXION "Use the 3D connexion SDK to support 3d mouse." OFF)
endif(IS_DIRECTORY ${3DCONNEXIONCLIENT_FRAMEWORK})
else(MSVC)
set(FREECAD_USE_3DCONNEXION_RAWINPUT ON)
set(FREECAD_USE_3DCONNEXION OFF )
endif(MSVC)
set_property(CACHE FREECAD_3DCONNEXION_SUPPORT PROPERTY STRINGS "None" "NavLib" "Legacy" "Both")
else(MSVC OR APPLE)
set(FREECAD_USE_3DCONNEXION_LEGACY ON)
endif(MSVC OR APPLE)

if(FREECAD_3DCONNEXION_SUPPORT STREQUAL "NavLib" AND FREECAD_USE_3DCONNEXION)
if(FREECAD_3DCONNEXION_SUPPORT STREQUAL "NavLib")
set(FREECAD_USE_3DCONNEXION_NAVLIB ON)
set(FREECAD_USE_3DCONNEXION OFF)
elseif(FREECAD_3DCONNEXION_SUPPORT STREQUAL "Both" AND FREECAD_USE_3DCONNEXION)
elseif(FREECAD_3DCONNEXION_SUPPORT STREQUAL "Both")
set(FREECAD_USE_3DCONNEXION_NAVLIB ON)
set(FREECAD_USE_3DCONNEXION_RAWINPUT ON)
elseif(FREECAD_3DCONNEXION_SUPPORT STREQUAL "Raw input" AND FREECAD_USE_3DCONNEXION)
set(FREECAD_USE_3DCONNEXION_RAWINPUT ON)
set(FREECAD_USE_3DCONNEXION_LEGACY ON)
elseif(FREECAD_3DCONNEXION_SUPPORT STREQUAL "Legacy")
set(FREECAD_USE_3DCONNEXION_LEGACY ON)
elseif(FREECAD_3DCONNEXION_SUPPORT STREQUAL "None")
set(FREECAD_USE_3DCONNEXION_NAVLIB OFF)
set(FREECAD_USE_3DCONNEXION_LEGACY OFF)
endif()

if(APPLE AND FREECAD_USE_3DCONNEXION_LEGACY)
find_library(3DCONNEXIONCLIENT_FRAMEWORK 3DconnexionClient)
if(NOT (IS_DIRECTORY ${3DCONNEXIONCLIENT_FRAMEWORK}))
set(FREECAD_USE_3DCONNEXION_LEGACY OFF)
endif()
endif()

if(MSVC)
16 changes: 6 additions & 10 deletions cMake/FreeCAD_Helpers/PrintFinalReport.cmake
Original file line number Diff line number Diff line change
@@ -193,20 +193,16 @@ macro(PrintFinalReport)
simple(OpenGLU_Incl [${OPENGL_INCLUDE_DIR}])
simple(Coin3D "${COIN3D_VERSION} [${COIN3D_LIBRARIES}] [${COIN3D_INCLUDE_DIRS}]")
simple(pivy ${PIVY_VERSION})
if (WIN32)
if (FREECAD_USE_3DCONNEXION_RAWINPUT AND FREECAD_USE_3DCONNEXION_NAVLIB)
simple(3Dconnexion "Building 3Dconnexion support with raw input and NavLib")
elseif (FREECAD_USE_3DCONNEXION)
simple(3Dconnexion "Building 3Dconnexion support with raw input")
if(WIN32 OR APPLE)
if(FREECAD_USE_3DCONNEXION_LEGACY AND FREECAD_USE_3DCONNEXION_NAVLIB)
simple(3Dconnexion "Building with 3Dconnexion legacy and NavLib support")
elseif(FREECAD_USE_3DCONNEXION_LEGACY)
simple(3Dconnexion "Building with 3Dconnexion legacy support")
elseif(FREECAD_USE_3DCONNEXION_NAVLIB)
simple(3Dconnexion "Building 3Dconnexion support with NavLib")
simple(3Dconnexion "Building with 3Dconnexion NavLib support")
else()
simple(3Dconnexion "Not building 3Dconnexion device support")
endif()
elseif(APPLE)
if (FREECAD_USE_3DCONNEXION)
simple(3Dconnexion "Building 3Dconnexion support with raw input")
endif()
else()
conditional(SPNAV SPNAV_FOUND "not found" "[${SPNAV_LIBRARY}] [${SPNAV_INCLUDE_DIR}]")
endif()
5 changes: 4 additions & 1 deletion src/Gui/3Dconnexion/navlib/NavlibNavigation.cpp
Original file line number Diff line number Diff line change
@@ -127,6 +127,8 @@ CameraType NavlibInterface::getCamera() const
return nullptr;
}

template SoCamera* NavlibInterface::getCamera<SoCamera*>() const;

void NavlibInterface::onViewChanged(const Gui::MDIView* view)
{
if (view == nullptr)
@@ -185,7 +187,8 @@ void NavlibInterface::enableNavigation()
exportCommands(std::string(wb));
});

exportCommands("StartWorkbench");
auto activeWorkbench = Gui::WorkbenchManager::instance()->activeName();
exportCommands(activeWorkbench);

initializePivot();
connectActiveTab();
4 changes: 3 additions & 1 deletion src/Gui/3Dconnexion/navlib/NavlibPivot.cpp
Original file line number Diff line number Diff line change
@@ -109,9 +109,11 @@ long NavlibInterface::SetPivotVisible(bool visible)
return 0;
}

extern template SoCamera* NavlibInterface::getCamera<SoCamera*>() const;

long NavlibInterface::GetHitLookAt(navlib::point_t& position) const
{
if (is2DView())
if (is2DView() || !is3DView())
return navlib::make_result_code(navlib::navlib_errc::no_data_available);

const Gui::View3DInventorViewer* const inventorViewer = currentView.pView3d->getViewer();
30 changes: 15 additions & 15 deletions src/Gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -19,21 +19,21 @@ IF(CMAKE_BUILD_TYPE)
add_definitions(-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}")
ENDIF(CMAKE_BUILD_TYPE)

if (FREECAD_USE_3DCONNEXION)
if (FREECAD_USE_3DCONNEXION_LEGACY)
add_definitions(-D_USE_3DCONNEXION_SDK)
if(APPLE)
set(3DCONNEXION_LINKFLAGS "-F/Library/Frameworks -weak_framework 3DconnexionClient")
set(3DCONNEXION_INCLUDE_DIR ${3DCONNEXIONCLIENT_FRAMEWORK}/Headers
list(APPEND 3DCONNEXION_INCLUDE_DIR ${3DCONNEXIONCLIENT_FRAMEWORK}/Headers
${3DCONNEXIONCLIENT_FRAMEWORK}/Headers/3DconnexionClient )
endif(APPLE)
endif(FREECAD_USE_3DCONNEXION)
endif(FREECAD_USE_3DCONNEXION_LEGACY)

if(FREECAD_USE_3DCONNEXION_NAVLIB AND (MSVC OR APPLE))
add_definitions(-DUSE_3DCONNEXION_NAVLIB)
if(APPLE)
add_definitions(-D__APPLE__)
endif(APPLE)
set(3DCONNEXION_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/3rdParty/3Dconnexion/inc)
list(APPEND 3DCONNEXION_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/3rdParty/3Dconnexion/inc)
endif(FREECAD_USE_3DCONNEXION_NAVLIB AND (MSVC OR APPLE))

if (BUILD_VR)
@@ -76,7 +76,7 @@ if(MSVC)
${OPENGL_gl_LIBRARY}
)

if(FREECAD_USE_3DCONNEXION)
if(FREECAD_USE_3DCONNEXION_LEGACY)
list(APPEND FreeCADGui_LIBS
hid
)
@@ -281,7 +281,7 @@ SET(FreeCADGui_XML_SRCS
SOURCE_GROUP("XML" FILES ${FreeCADApp_XML_SRCS})

# The 3D Connexion SDK files
if(FREECAD_USE_3DCONNEXION AND MSVC)
if(FREECAD_USE_3DCONNEXION_LEGACY AND MSVC)
SET(FreeCADGui_SDK_SRCS
3Dconnexion/I3dMouseParams.h
3Dconnexion/MouseParameters.cpp
@@ -300,9 +300,9 @@ if(FREECAD_USE_3DCONNEXION AND MSVC)
list(APPEND FreeCADGui_connexion_HDRS
${FreeCADGui_SDK_MOC_HDRS}
)
endif(FREECAD_USE_3DCONNEXION AND MSVC)
endif(FREECAD_USE_3DCONNEXION_LEGACY AND MSVC)

if(FREECAD_USE_3DCONNEXION AND APPLE)
if(FREECAD_USE_3DCONNEXION_LEGACY AND APPLE)
SET(FreeCADGui_SDK_SRCS
3Dconnexion/GuiAbstractNativeEvent.cpp
3Dconnexion/GuiNativeEventMac.cpp
@@ -318,7 +318,7 @@ if(FREECAD_USE_3DCONNEXION AND APPLE)
list(APPEND FreeCADGui_connexion_HDRS
${FreeCADGui_SDK_MOC_HDRS}
)
endif(FREECAD_USE_3DCONNEXION AND APPLE)
endif(FREECAD_USE_3DCONNEXION_LEGACY AND APPLE)

if(FREECAD_USE_3DCONNEXION_NAVLIB AND (MSVC OR APPLE))
SET(NAVLIB_STUB_DIR ${CMAKE_SOURCE_DIR}/src/3rdParty/3Dconnexion/src)
@@ -421,9 +421,9 @@ SET(Gui_UIC_SRCS
VectorListEditor.ui
)

if(FREECAD_USE_3DCONNEXION_RAWINPUT)
if(FREECAD_USE_3DCONNEXION_LEGACY)
list(APPEND Gui_UIC_SRCS DlgCustomizeSpNavSettings.ui)
endif(FREECAD_USE_3DCONNEXION_RAWINPUT)
endif(FREECAD_USE_3DCONNEXION_LEGACY)

set (FreeCAD_TR_QRC ${CMAKE_CURRENT_BINARY_DIR}/Language/FreeCAD_translation.qrc)
qt_find_and_add_translation(QM_SRCS "Language/FreeCAD_*.ts"
@@ -612,10 +612,10 @@ SET(Dialog_Customize_HPP_SRCS
ListWidgetDragBugFix.h
)

if(FREECAD_USE_3DCONNEXION_RAWINPUT)
if(FREECAD_USE_3DCONNEXION_LEGACY)
list(APPEND Dialog_Customize_CPP_SRCS DlgCustomizeSpaceball.cpp DlgCustomizeSpNavSettings.cpp)
list(APPEND Dialog_Customize_HPP_SRCS DlgCustomizeSpaceball.h DlgCustomizeSpNavSettings.h)
endif(FREECAD_USE_3DCONNEXION_RAWINPUT)
endif(FREECAD_USE_3DCONNEXION_LEGACY)

SET(Dialog_Customize_SRCS
${Dialog_Customize_CPP_SRCS}
@@ -626,9 +626,9 @@ SET(Dialog_Customize_SRCS
DlgToolbars.ui
)

if(FREECAD_USE_3DCONNEXION_RAWINPUT)
if(FREECAD_USE_3DCONNEXION_LEGACY)
list(APPEND Dialog_Customize_SRCS DlgCustomizeSpNavSettings.ui)
endif(FREECAD_USE_3DCONNEXION_RAWINPUT)
endif(FREECAD_USE_3DCONNEXION_LEGACY)

SOURCE_GROUP("Dialog\\Customize" FILES ${Dialog_Customize_SRCS})

0 comments on commit 836ad91

Please sign in to comment.