Merge pull request #18244 from wwmayer/space_mouse_runtime

Gui: Add runtime check to choose between modern and legacy space mous…
This commit is contained in:
Chris Hennes
2024-12-09 11:36:17 -05:00
committed by GitHub
7 changed files with 141 additions and 68 deletions

View File

@@ -560,8 +560,15 @@ Application::Application(bool GUIenabled)
_pcWorkbenchDictionary = PyDict_New();
#ifdef USE_3DCONNEXION_NAVLIB
// Instantiate the 3Dconnexion controller
pNavlibInterface = new NavlibInterface();
ParameterGrp::handle hViewGrp = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/View");
if (!hViewGrp->GetBool("LegacySpaceMouseDevices", false)) {
// Instantiate the 3Dconnexion controller
pNavlibInterface = new NavlibInterface();
}
else {
pNavlibInterface = nullptr;
}
#endif
if (GUIenabled) {
@@ -2295,7 +2302,9 @@ void Application::runApplication()
Gui::getMainWindow()->setProperty("eventLoop", true);
#ifdef USE_3DCONNEXION_NAVLIB
Instance->pNavlibInterface->enableNavigation();
if (Instance->pNavlibInterface) {
Instance->pNavlibInterface->enableNavigation();
}
#endif
runEventLoop(mainApp);

View File

@@ -151,22 +151,28 @@ IF(SPNAV_FOUND)
SET(FreeCADGui_SDK_SRCS
3Dconnexion/GuiAbstractNativeEvent.cpp
3Dconnexion/GuiNativeEventLinuxX11.cpp
)
)
SET(FreeCADGui_SDK_MOC_HDRS
3Dconnexion/GuiAbstractNativeEvent.h
3Dconnexion/GuiNativeEventLinuxX11.h
)
)
else(SPNAV_USE_X11)
SET(FreeCADGui_SDK_SRCS
3Dconnexion/GuiAbstractNativeEvent.cpp
3Dconnexion/GuiNativeEventLinux.cpp
)
)
SET(FreeCADGui_SDK_MOC_HDRS
3Dconnexion/GuiAbstractNativeEvent.h
3Dconnexion/GuiNativeEventLinux.h
)
)
endif(SPNAV_USE_X11)
SOURCE_GROUP("3D connexion SDK" FILES ${FreeCADGui_SDK_SRCS})
list(APPEND FreeCADGui_connexion_SRCS
${FreeCADGui_SDK_SRCS}
)
list(APPEND FreeCADGui_connexion_HDRS
${FreeCADGui_SDK_MOC_HDRS}
)
add_definitions(-DSPNAV_FOUND)
include_directories(
@@ -270,30 +276,42 @@ SOURCE_GROUP("XML" FILES ${FreeCADApp_XML_SRCS})
# The 3D Connexion SDK files
if(FREECAD_USE_3DCONNEXION AND MSVC)
SET(FreeCADGui_SDK_SRCS
3Dconnexion/I3dMouseParams.h
3Dconnexion/MouseParameters.cpp
3Dconnexion/MouseParameters.h
3Dconnexion/GuiAbstractNativeEvent.cpp
3Dconnexion/GuiNativeEventWin32.cpp
)
SOURCE_GROUP("3D connexion SDK" FILES ${FreeCADGui_SDK_SRCS})
SET(FreeCADGui_SDK_MOC_HDRS
3Dconnexion/GuiAbstractNativeEvent.h
3Dconnexion/GuiNativeEventWin32.h
)
SET(FreeCADGui_SDK_SRCS
3Dconnexion/I3dMouseParams.h
3Dconnexion/MouseParameters.cpp
3Dconnexion/MouseParameters.h
3Dconnexion/GuiAbstractNativeEvent.cpp
3Dconnexion/GuiNativeEventWin32.cpp
)
SOURCE_GROUP("3D connexion SDK" FILES ${FreeCADGui_SDK_SRCS})
SET(FreeCADGui_SDK_MOC_HDRS
3Dconnexion/GuiAbstractNativeEvent.h
3Dconnexion/GuiNativeEventWin32.h
)
list(APPEND FreeCADGui_connexion_SRCS
${FreeCADGui_SDK_SRCS}
)
list(APPEND FreeCADGui_connexion_HDRS
${FreeCADGui_SDK_MOC_HDRS}
)
endif(FREECAD_USE_3DCONNEXION AND MSVC)
if(FREECAD_USE_3DCONNEXION AND APPLE)
SET(FreeCADGui_SDK_SRCS
3Dconnexion/GuiAbstractNativeEvent.cpp
3Dconnexion/GuiNativeEventMac.cpp
)
SOURCE_GROUP("3D connexion SDK" FILES ${FreeCADGui_SDK_SRCS})
SET(FreeCADGui_SDK_MOC_HDRS
3Dconnexion/GuiAbstractNativeEvent.h
3Dconnexion/GuiNativeEventMac.h
)
SET(FreeCADGui_SDK_SRCS
3Dconnexion/GuiAbstractNativeEvent.cpp
3Dconnexion/GuiNativeEventMac.cpp
)
SOURCE_GROUP("3D connexion SDK" FILES ${FreeCADGui_SDK_SRCS})
SET(FreeCADGui_SDK_MOC_HDRS
3Dconnexion/GuiAbstractNativeEvent.h
3Dconnexion/GuiNativeEventMac.h
)
list(APPEND FreeCADGui_connexion_SRCS
${FreeCADGui_SDK_SRCS}
)
list(APPEND FreeCADGui_connexion_HDRS
${FreeCADGui_SDK_MOC_HDRS}
)
endif(FREECAD_USE_3DCONNEXION AND APPLE)
if(FREECAD_USE_3DCONNEXION_NAVLIB AND (MSVC OR APPLE))
@@ -306,9 +324,15 @@ if(FREECAD_USE_3DCONNEXION_NAVLIB AND (MSVC OR APPLE))
${NAVLIB_STUB_DIR}/navlib_stub.c
)
SOURCE_GROUP("3Dconnexion Navlib" FILES ${FreeCADGui_SDK_SRCS})
SET(FreeCADGui_SDK_MOC_HDRS
SET(FreeCADGui_SDK_MOC_HDRS
3Dconnexion/navlib/NavlibInterface.h
)
)
list(APPEND FreeCADGui_connexion_SRCS
${FreeCADGui_SDK_SRCS}
)
list(APPEND FreeCADGui_connexion_HDRS
${FreeCADGui_SDK_MOC_HDRS}
)
endif(FREECAD_USE_3DCONNEXION_NAVLIB AND (MSVC OR APPLE))
set_property(SOURCE GraphvizView.h GraphvizView.cpp PROPERTY SKIP_AUTOMOC ON)
@@ -390,9 +414,9 @@ SET(Gui_UIC_SRCS
VectorListEditor.ui
)
if(FREECAD_3DCONNEXION_SUPPORT STREQUAL "Raw input")
list(APPEND Gui_UIC_SRCS DlgCustomizeSpNavSettings.ui)
endif(FREECAD_3DCONNEXION_SUPPORT STREQUAL "Raw input")
if(FREECAD_USE_3DCONNEXION_RAWINPUT)
list(APPEND Gui_UIC_SRCS DlgCustomizeSpNavSettings.ui)
endif(FREECAD_USE_3DCONNEXION_RAWINPUT)
set (FreeCAD_TR_QRC ${CMAKE_CURRENT_BINARY_DIR}/Language/FreeCAD_translation.qrc)
qt_find_and_add_translation(QM_SRCS "Language/FreeCAD_*.ts"
@@ -581,10 +605,10 @@ SET(Dialog_Customize_HPP_SRCS
ListWidgetDragBugFix.h
)
if(FREECAD_3DCONNEXION_SUPPORT STREQUAL "Raw input")
list(APPEND Dialog_Customize_CPP_SRCS DlgCustomizeSpaceball.cpp DlgCustomizeSpNavSettings.cpp)
list(APPEND Dialog_Customize_HPP_SRCS DlgCustomizeSpaceball.h DlgCustomizeSpNavSettings.h)
endif(FREECAD_3DCONNEXION_SUPPORT STREQUAL "Raw input")
if(FREECAD_USE_3DCONNEXION_RAWINPUT)
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)
SET(Dialog_Customize_SRCS
${Dialog_Customize_CPP_SRCS}
@@ -595,9 +619,9 @@ SET(Dialog_Customize_SRCS
DlgToolbars.ui
)
if(FREECAD_3DCONNEXION_SUPPORT STREQUAL "Raw input")
list(APPEND Dialog_Customize_SRCS DlgCustomizeSpNavSettings.ui)
endif(FREECAD_3DCONNEXION_SUPPORT STREQUAL "Raw input")
if(FREECAD_USE_3DCONNEXION_RAWINPUT)
list(APPEND Dialog_Customize_SRCS DlgCustomizeSpNavSettings.ui)
endif(FREECAD_USE_3DCONNEXION_RAWINPUT)
SOURCE_GROUP("Dialog\\Customize" FILES ${Dialog_Customize_SRCS})
@@ -1297,11 +1321,11 @@ SET(FreeCADGui_SRCS
StartupProcess.h
TransactionObject.h
ToolHandler.h
${FreeCADGui_SDK_MOC_HDRS}
)
SET(FreeCADGui_SRCS
${FreeCADGui_SDK_SRCS}
${FreeCADGui_connexion_SRCS}
${FreeCADGui_connexion_HDRS}
${FreeCADGui_CPP_SRCS}
${FreeCADGui_XML_SRCS}
${qsint_MOC_SRCS}

View File

@@ -60,6 +60,9 @@ DlgSettingsNavigation::DlgSettingsNavigation(QWidget* parent)
ui->naviCubeBaseColor->setAllowTransparency(true);
ui->rotationCenterColor->setAllowTransparency(true);
retranslate();
#if !defined(_USE_3DCONNEXION_SDK) && !defined(SPNAV_FOUND)
ui->legacySpaceMouseDevices->setDisabled(true);
#endif
}
/**
@@ -97,6 +100,10 @@ void DlgSettingsNavigation::saveSettings()
ui->prefCubeSize->onSave();
ui->naviCubeBaseColor->onSave();
ui->naviCubeInactiveOpacity->onSave();
ui->legacySpaceMouseDevices->onSave();
if (property("LegacySpaceMouse").toBool() != ui->legacySpaceMouseDevices->isChecked()) {
requireRestart();
}
bool showNaviCube = ui->groupBoxNaviCube->isChecked();
hGrp->SetBool("ShowNaviCube", showNaviCube);
@@ -143,6 +150,8 @@ void DlgSettingsNavigation::loadSettings()
ui->prefCubeSize->onRestore();
ui->naviCubeBaseColor->onRestore();
ui->naviCubeInactiveOpacity->onRestore();
ui->legacySpaceMouseDevices->onRestore();
setProperty("LegacySpaceMouse", ui->legacySpaceMouseDevices->isChecked());
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/View");

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>548</width>
<height>762</height>
<height>795</height>
</rect>
</property>
<property name="windowTitle">
@@ -255,7 +255,7 @@
<property name="toolTip">
<string>Base color for all elements</string>
</property>
<property name="color" stdset="0">
<property name="color">
<color alpha="128">
<red>226</red>
<green>232</green>
@@ -335,7 +335,7 @@
<property name="toolTip">
<string>The color of the rotation center indicator</string>
</property>
<property name="color" stdset="0">
<property name="color">
<color alpha="51">
<red>255</red>
<green>0</green>
@@ -572,7 +572,7 @@ Free Turntable: the part will be rotated around the z-axis.</string>
</widget>
</item>
<item row="4" column="2">
<widget class="Gui::PrefUnitSpinBox" name="qspinNewDocScale" native="true">
<widget class="Gui::PrefUnitSpinBox" name="qspinNewDocScale">
<property name="toolTip">
<string>Sets camera zoom for new documents.
The value is the diameter of the sphere to fit on the screen.</string>
@@ -580,21 +580,21 @@ The value is the diameter of the sphere to fit on the screen.</string>
<property name="unit" stdset="0">
<string>mm</string>
</property>
<property name="minimum" stdset="0">
<property name="minimum">
<double>0.000010000000000</double>
</property>
<property name="maximum" stdset="0">
<property name="maximum">
<double>10000000.000000000000000</double>
</property>
<property name="rawValue" stdset="0">
<double>100.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>NewDocumentCameraScale</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
<property name="rawValue" stdset="0">
<double>100.000000000000000</double>
</property>
</widget>
</item>
<item row="6" column="0">
@@ -721,6 +721,28 @@ Mouse tilting is not disabled by this setting.</string>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="spaceMouseDevice">
<property name="title">
<string>Space mouse</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="legacySpaceMouseDevices">
<property name="text">
<string>Enable support of legacy space mouse devices</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>LegacySpaceMouseDevices</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxAnimations">
<property name="title">

View File

@@ -51,7 +51,7 @@
#include "DlgActionsImp.h"
#include "DlgKeyboardImp.h"
#ifndef USE_3DCONNEXION_NAVLIB
#if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND)
#include "DlgCustomizeSpaceball.h"
#include "DlgCustomizeSpNavSettings.h"
#endif
@@ -98,7 +98,7 @@ WidgetFactorySupplier::WidgetFactorySupplier()
new CustomPageProducer<DlgCustomKeyboardImp>;
new CustomPageProducer<DlgCustomToolbarsImp>;
new CustomPageProducer<DlgCustomActionsImp>;
#ifndef USE_3DCONNEXION_NAVLIB
#if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND)
new CustomPageProducer<DlgCustomizeSpNavSettings>;
new CustomPageProducer<DlgCustomizeSpaceball>;
#endif