From 2cd854af14b00e34409f91bdcf899ebdbeba0f57 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 7 Apr 2023 10:08:43 -0700 Subject: [PATCH] Move Spacemouse to advanced config The spacemouse driver, particularly on Mac, is extremely unstable and causes crashes even when not being used. This places the interface behind an advanced config flag to ensure that users can affirmatively opt-in to the potential for crashes --- 3d-viewer/3d_canvas/eda_3d_canvas.cpp | 5 +- 3d-viewer/3d_canvas/eda_3d_canvas.h | 7 --- 3d-viewer/3d_canvas/eda_3d_canvas_pivot.cpp | 2 - 3d-viewer/3d_navlib/CMakeLists.txt | 6 -- 3d-viewer/3d_navlib/nl_3d_viewer_plugin.cpp | 28 ++------- 3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp | 39 +++++------- 3d-viewer/CMakeLists.txt | 8 +-- CMakeLists.txt | 9 --- common/CMakeLists.txt | 9 +-- common/advanced_config.cpp | 9 +++ eeschema/CMakeLists.txt | 11 ++-- eeschema/navlib/CMakeLists.txt | 51 +++++++-------- eeschema/navlib/nl_schematic_plugin.cpp | 34 +++------- eeschema/sch_base_frame.cpp | 46 +++++--------- eeschema/sch_base_frame.h | 2 - include/advanced_config.h | 5 ++ pcbnew/navlib/CMakeLists.txt | 51 +++++++-------- pcbnew/navlib/nl_pcbnew_plugin.cpp | 28 ++------- pcbnew/pcb_base_frame.cpp | 70 ++++++++++----------- 19 files changed, 154 insertions(+), 266 deletions(-) diff --git a/3d-viewer/3d_canvas/eda_3d_canvas.cpp b/3d-viewer/3d_canvas/eda_3d_canvas.cpp index 8e6bab547b..4155c709bd 100644 --- a/3d-viewer/3d_canvas/eda_3d_canvas.cpp +++ b/3d-viewer/3d_canvas/eda_3d_canvas.cpp @@ -32,6 +32,7 @@ #include <3d_rendering/raytracing/render_3d_raytrace.h> #include <3d_rendering/opengl/render_3d_opengl.h> #include <3d_viewer_id.h> +#include #include #include #include @@ -531,13 +532,11 @@ void EDA_3D_CANVAS::DoRePaint() render_pivot( curtime_delta_s, scale ); } -#if defined( KICAD_USE_3DCONNEXION ) - if( m_render3dmousePivot ) + if( m_render3dmousePivot && ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) { const float scale = glm::min( m_camera.GetZoom(), 1.0f ); render3dmousePivot( scale ); } -#endif // "Swaps the double-buffer of this window, making the back-buffer the // front-buffer and vice versa, so that the output of the previous OpenGL diff --git a/3d-viewer/3d_canvas/eda_3d_canvas.h b/3d-viewer/3d_canvas/eda_3d_canvas.h index aeb887ef93..8ebdfb33f6 100644 --- a/3d-viewer/3d_canvas/eda_3d_canvas.h +++ b/3d-viewer/3d_canvas/eda_3d_canvas.h @@ -178,8 +178,6 @@ public: */ void SetRenderPivot( bool aValue ) { m_render_pivot = aValue; } - -#if defined( KICAD_USE_3DCONNEXION ) /** * Get a value indicating whether to render the 3dmouse pivot. */ @@ -209,7 +207,6 @@ public: { m_3dmousePivotPos = aPos; } -#endif private: /** @@ -278,14 +275,12 @@ private: */ void render_pivot( float t, float aScale ); -#if defined( KICAD_USE_3DCONNEXION ) /** * Render the 3dmouse pivot cursor. * * @param aScale scale to apply on the cursor. */ void render3dmousePivot( float aScale ); -#endif /** * @return true if OpenGL initialization succeeded. @@ -331,10 +326,8 @@ private: BOARD_ITEM* m_currentRollOverItem; -#if defined( KICAD_USE_3DCONNEXION ) bool m_render3dmousePivot = false; // Render the 3dmouse pivot SFVEC3F m_3dmousePivotPos; // The position of the 3dmouse pivot -#endif /** * Trace mask used to enable or disable the trace output of this class. diff --git a/3d-viewer/3d_canvas/eda_3d_canvas_pivot.cpp b/3d-viewer/3d_canvas/eda_3d_canvas_pivot.cpp index b43da0af5c..b0cb7ecf04 100644 --- a/3d-viewer/3d_canvas/eda_3d_canvas_pivot.cpp +++ b/3d-viewer/3d_canvas/eda_3d_canvas_pivot.cpp @@ -120,7 +120,6 @@ void EDA_3D_CANVAS::render_pivot( float t, float aScale ) } -#if defined( KICAD_USE_3DCONNEXION ) void EDA_3D_CANVAS::render3dmousePivot( float aScale ) { wxASSERT( aScale >= 0.0f ); @@ -160,4 +159,3 @@ void EDA_3D_CANVAS::render3dmousePivot( float aScale ) glDisable( GL_BLEND ); glDisable( GL_POINT_SMOOTH ); } -#endif diff --git a/3d-viewer/3d_navlib/CMakeLists.txt b/3d-viewer/3d_navlib/CMakeLists.txt index 82c3b016ed..a6c4926264 100644 --- a/3d-viewer/3d_navlib/CMakeLists.txt +++ b/3d-viewer/3d_navlib/CMakeLists.txt @@ -1,4 +1,3 @@ -if( KICAD_USE_3DCONNEXION ) add_library(3d-viewer_navlib STATIC "nl_3d_viewer_plugin.cpp" "nl_3d_viewer_plugin_impl.cpp" @@ -23,9 +22,4 @@ if( KICAD_USE_3DCONNEXION ) $ 3DxWare::Navlib ) -else() - add_library(3d-viewer_navlib STATIC - "nl_3d_viewer_plugin.cpp" - ) -endif(KICAD_USE_3DCONNEXION) diff --git a/3d-viewer/3d_navlib/nl_3d_viewer_plugin.cpp b/3d-viewer/3d_navlib/nl_3d_viewer_plugin.cpp index 668cd9ac48..b178df0513 100644 --- a/3d-viewer/3d_navlib/nl_3d_viewer_plugin.cpp +++ b/3d-viewer/3d_navlib/nl_3d_viewer_plugin.cpp @@ -19,14 +19,14 @@ */ #include "nl_3d_viewer_plugin.h" - -#if defined( KICAD_USE_3DCONNEXION ) #include "nl_3d_viewer_plugin_impl.h" +#include -NL_3D_VIEWER_PLUGIN::NL_3D_VIEWER_PLUGIN( EDA_3D_CANVAS* aViewport ) : - m_impl( new NL_3D_VIEWER_PLUGIN_IMPL( aViewport ) ) +NL_3D_VIEWER_PLUGIN::NL_3D_VIEWER_PLUGIN( EDA_3D_CANVAS* aViewport ) { + if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) + m_impl = new NL_3D_VIEWER_PLUGIN_IMPL( aViewport ); } @@ -38,22 +38,6 @@ NL_3D_VIEWER_PLUGIN::~NL_3D_VIEWER_PLUGIN() void NL_3D_VIEWER_PLUGIN::SetFocus( bool focus ) { - m_impl->SetFocus( focus ); + if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) + m_impl->SetFocus( focus ); } -#else - - -NL_3D_VIEWER_PLUGIN::NL_3D_VIEWER_PLUGIN( EDA_3D_CANVAS* aViewport ) : m_impl( nullptr ) -{ -} - - -void NL_3D_VIEWER_PLUGIN::SetFocus( bool focus ) -{ -} - - -NL_3D_VIEWER_PLUGIN::~NL_3D_VIEWER_PLUGIN() -{ -} -#endif diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp index 961ec3b56d..bdf061e406 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp @@ -39,6 +39,7 @@ #include <3d_viewer/tools/eda_3d_actions.h> #include <3d_viewer/tools/eda_3d_controller.h> #include <3d_viewer/tools/eda_3d_conditions.h> +#include #include #include #include @@ -56,9 +57,7 @@ #include #include -#if defined( KICAD_USE_3DCONNEXION ) #include <3d_navlib/nl_3d_viewer_plugin.h> -#endif /** * Flag to enable 3D viewer main frame window debug tracing. @@ -166,16 +165,18 @@ EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent m_canvas->SetInfoBar( m_infoBar ); m_canvas->SetStatusBar( status_bar ); -#if defined( KICAD_USE_3DCONNEXION ) - try + + if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) { - m_spaceMouse = new NL_3D_VIEWER_PLUGIN( m_canvas ); + try + { + m_spaceMouse = new NL_3D_VIEWER_PLUGIN( m_canvas ); + } + catch( const std::system_error& e ) + { + wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() ); + } } - catch( const std::system_error& e ) - { - wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() ); - } -#endif // Fixes bug in Windows (XP and possibly others) where the canvas requires the focus // in order to receive mouse events. Otherwise, the user has to click somewhere on @@ -193,12 +194,7 @@ EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent EDA_3D_VIEWER_FRAME::~EDA_3D_VIEWER_FRAME() { -#if defined( KICAD_USE_3DCONNEXION ) - if( m_spaceMouse != nullptr ) - { - delete m_spaceMouse; - } -#endif + delete m_spaceMouse; Prj().GetProjectFile().m_Viewports3D = GetUserViewports(); @@ -334,12 +330,11 @@ void EDA_3D_VIEWER_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent ) { KIWAY_PLAYER::handleIconizeEvent( aEvent ); -#if defined( KICAD_USE_3DCONNEXION ) - if( m_spaceMouse != nullptr && aEvent.IsIconized() ) + if( m_spaceMouse != nullptr && aEvent.IsIconized() + && ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) { m_spaceMouse->SetFocus( false ); } -#endif } @@ -655,12 +650,8 @@ void EDA_3D_VIEWER_FRAME::OnActivate( wxActivateEvent &aEvent ) m_canvas->SetFocus(); } -#if defined( KICAD_USE_3DCONNEXION ) - if( m_spaceMouse != nullptr ) - { + if( m_spaceMouse != nullptr && ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) m_spaceMouse->SetFocus( aEvent.GetActive() ); - } -#endif aEvent.Skip(); // required under wxMAC } diff --git a/3d-viewer/CMakeLists.txt b/3d-viewer/CMakeLists.txt index 4070375104..54b48891d4 100644 --- a/3d-viewer/CMakeLists.txt +++ b/3d-viewer/CMakeLists.txt @@ -123,8 +123,6 @@ target_link_libraries( 3d-viewer add_subdirectory( 3d_cache ) -if( KICAD_USE_3DCONNEXION ) - message( STATUS "Including 3Dconnexion SpaceMouse navigation support in 3d-viewer" ) - add_subdirectory( 3d_navlib ) - target_link_libraries( 3d-viewer PRIVATE 3d-viewer_navlib) -endif() +message( STATUS "Including 3Dconnexion SpaceMouse navigation support in 3d-viewer" ) +add_subdirectory( 3d_navlib ) +target_link_libraries( 3d-viewer PRIVATE 3d-viewer_navlib) diff --git a/CMakeLists.txt b/CMakeLists.txt index c01d3c266d..e510c690b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,10 +83,6 @@ option( KICAD_USE_SENTRY "Build KiCad with support for sentry app metrics" OFF ) -option( KICAD_USE_3DCONNEXION - "Build KiCad with support for 3Dconnexion devices (Currently only for Mac/MSW)" - OFF ) - option( KICAD_SIGNAL_INTEGRITY "Build tools for signal integrity analysis ( default ON )" ON ) @@ -241,11 +237,6 @@ add_compile_definitions( $<$:KICAD_USE_VALGRIND> ) add_compile_definitions( $<$:KICAD_GAL_PROFILE> ) add_compile_definitions( $<$:KICAD_WIN32_VERIFY_CODESIGN> ) -# 3D mouse is only available on Windows and macOS -if( WIN32 OR APPLE ) - add_compile_definitions( $<$:KICAD_USE_3DCONNEXION> ) -endif() - if( KICAD_USE_EGL ) message( STATUS "Configuring KiCad for the wxGLCanvas EGL backend" ) add_compile_definitions( KICAD_USE_EGL ) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 978116c679..a11122ddb5 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -623,12 +623,9 @@ target_link_libraries( pcbcommon PUBLIC threadpool ) -if( KICAD_USE_3DCONNEXION ) - message( STATUS "Including 3Dconnexion SpaceMouse navigation support in pcbcommon" ) - add_subdirectory( ../pcbnew/navlib ./navlib) - target_link_libraries( pcbcommon PUBLIC pcbnew_navlib) -endif() - +message( STATUS "Including 3Dconnexion SpaceMouse navigation support in pcbcommon" ) +add_subdirectory( ../pcbnew/navlib ./navlib) +target_link_libraries( pcbcommon PUBLIC pcbnew_navlib) add_dependencies( pcbcommon delaunator ) diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index a4c5b45b5e..9f6c0c6508 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -62,6 +62,11 @@ namespace AC_STACK namespace AC_KEYS { +/** + * Decide whether to attempt usage of the 3DConnexion mouse + */ +static const wxChar Use3DConnexionDriver[] = wxT( "3DConnexionDriver" ); + /** * When filling zones, we add an extra amount of clearance to each zone to ensure that rounding * errors do not overrun minimum clearance distances. This is the extra in mm. @@ -320,6 +325,7 @@ ADVANCED_CFG::ADVANCED_CFG() m_3DRT_BevelExtentFactor = 1.0 / 16.0; m_UseClipper2 = true; + m_Use3DConnexionDriver = false; loadFromConfigFile(); } @@ -463,6 +469,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::UseClipper2, &m_UseClipper2, m_UseClipper2 ) ); + configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::Use3DConnexionDriver, + &m_Use3DConnexionDriver, m_Use3DConnexionDriver ) ); + // Special case for trace mask setting...we just grab them and set them immediately diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 39abaa286c..7522daede6 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -462,15 +462,12 @@ target_link_libraries( eeschema_kiface_objects # declare the dependency add_dependencies( eeschema_kiface_objects common ) -if( KICAD_USE_3DCONNEXION ) - message( STATUS "Including 3Dconnexion SpaceMouse navigation support in eeschema" ) - add_subdirectory( ./navlib ) +message( STATUS "Including 3Dconnexion SpaceMouse navigation support in eeschema" ) +add_subdirectory( navlib ) - target_link_libraries( eeschema_kiface_objects PUBLIC eeschema_navlib) - - add_dependencies( eeschema_kiface_objects eeschema_navlib ) -endif() +target_link_libraries( eeschema_kiface_objects PUBLIC eeschema_navlib) +add_dependencies( eeschema_kiface_objects eeschema_navlib ) add_library( eeschema_kiface MODULE eeschema.cpp diff --git a/eeschema/navlib/CMakeLists.txt b/eeschema/navlib/CMakeLists.txt index bd2e8bb458..68e2ce9c6b 100644 --- a/eeschema/navlib/CMakeLists.txt +++ b/eeschema/navlib/CMakeLists.txt @@ -1,30 +1,25 @@ -if( KICAD_USE_3DCONNEXION ) - add_library(eeschema_navlib STATIC - "nl_schematic_plugin.cpp" - "nl_schematic_plugin_impl.cpp" - ) - # eeschema_navlib depends on make_lexer outputs in common - add_dependencies( eeschema_navlib common ) +add_library(eeschema_navlib STATIC + "nl_schematic_plugin.cpp" + "nl_schematic_plugin_impl.cpp" +) - # Find the 3DxWare SDK component 3DxWare::NlClient - # find_package(TDxWare_SDK 4.0 REQUIRED COMPONENTS 3DxWare::Navlib) - target_compile_definitions(eeschema_navlib PRIVATE - $ - ) - target_compile_options(eeschema_navlib PRIVATE - $ - ) - target_include_directories(eeschema_navlib PRIVATE - $ - $ - ) - target_link_libraries(eeschema_navlib - $ - 3DxWare::Navlib - ) -else() - add_library(eeschema_navlib STATIC - "nl_schematic_plugin.cpp" - ) -endif(KICAD_USE_3DCONNEXION) +# eeschema_navlib depends on make_lexer outputs in common +add_dependencies( eeschema_navlib common ) + +# Find the 3DxWare SDK component 3DxWare::NlClient +# find_package(TDxWare_SDK 4.0 REQUIRED COMPONENTS 3DxWare::Navlib) +target_compile_definitions(eeschema_navlib PRIVATE + $ +) +target_compile_options(eeschema_navlib PRIVATE + $ +) +target_include_directories(eeschema_navlib PRIVATE + $ + $ +) +target_link_libraries(eeschema_navlib + $ + 3DxWare::Navlib +) diff --git a/eeschema/navlib/nl_schematic_plugin.cpp b/eeschema/navlib/nl_schematic_plugin.cpp index e38cb1e49a..8cf2899d03 100644 --- a/eeschema/navlib/nl_schematic_plugin.cpp +++ b/eeschema/navlib/nl_schematic_plugin.cpp @@ -19,13 +19,15 @@ */ #include "nl_schematic_plugin.h" -#if defined( KICAD_USE_3DCONNEXION ) +#include #include "nl_schematic_plugin_impl.h" -NL_SCHEMATIC_PLUGIN::NL_SCHEMATIC_PLUGIN() : m_impl( new NL_SCHEMATIC_PLUGIN_IMPL() ) +NL_SCHEMATIC_PLUGIN::NL_SCHEMATIC_PLUGIN() { + if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) + m_impl = new NL_SCHEMATIC_PLUGIN_IMPL(); } @@ -37,33 +39,13 @@ NL_SCHEMATIC_PLUGIN::~NL_SCHEMATIC_PLUGIN() void NL_SCHEMATIC_PLUGIN::SetFocus( bool focus ) { - m_impl->SetFocus( focus ); + if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) + m_impl->SetFocus( focus ); } void NL_SCHEMATIC_PLUGIN::SetCanvas( EDA_DRAW_PANEL_GAL* aViewport ) { - m_impl->SetCanvas( aViewport ); + if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) + m_impl->SetCanvas( aViewport ); } -#else - - -NL_SCHEMATIC_PLUGIN::NL_SCHEMATIC_PLUGIN() -{ -} - - -void NL_SCHEMATIC_PLUGIN::SetFocus( bool focus ) -{ -} - - -void NL_SCHEMATIC_PLUGIN::SetCanvas( EDA_DRAW_PANEL_GAL* aViewport ) -{ -} - - -NL_SCHEMATIC_PLUGIN::~NL_SCHEMATIC_PLUGIN() -{ -} -#endif diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index e166ef619f..115071072f 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -22,6 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include #include @@ -47,9 +48,7 @@ #include #include -#if defined( KICAD_USE_3DCONNEXION ) #include -#endif LIB_SYMBOL* SchGetLibSymbol( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, SYMBOL_LIB* aCacheLib, wxWindow* aParent, bool aShowErrorMsg ) @@ -91,10 +90,7 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindo const wxSize& aSize, long aStyle, const wxString& aFrameName ) : EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition, aSize, aStyle, aFrameName, schIUScale ), - m_base_frame_defaults( nullptr, "base_Frame_defaults" ) -#if defined( KICAD_USE_3DCONNEXION ) - ,m_spaceMouse( nullptr ) -#endif + m_base_frame_defaults( nullptr, "base_Frame_defaults" ), m_spaceMouse( nullptr ) { createCanvas(); @@ -116,10 +112,7 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindo SCH_BASE_FRAME::~SCH_BASE_FRAME() { -#if defined( KICAD_USE_3DCONNEXION ) - if( m_spaceMouse != nullptr ) - delete m_spaceMouse; -#endif + delete m_spaceMouse; } @@ -350,21 +343,20 @@ void SCH_BASE_FRAME::ActivateGalCanvas() { EDA_DRAW_FRAME::ActivateGalCanvas(); -#if defined( KICAD_USE_3DCONNEXION ) - try + if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) { - if( !m_spaceMouse ) + try { - m_spaceMouse = new NL_SCHEMATIC_PLUGIN(); - } + if( !m_spaceMouse ) + m_spaceMouse = new NL_SCHEMATIC_PLUGIN(); - m_spaceMouse->SetCanvas( GetCanvas() ); + m_spaceMouse->SetCanvas( GetCanvas() ); + } + catch( const std::system_error& e ) + { + wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() ); + } } - catch( const std::system_error& e ) - { - wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() ); - } -#endif } @@ -543,12 +535,8 @@ void SCH_BASE_FRAME::handleActivateEvent( wxActivateEvent& aEvent ) { EDA_DRAW_FRAME::handleActivateEvent( aEvent ); -#if defined( KICAD_USE_3DCONNEXION ) - if( m_spaceMouse ) - { + if( m_spaceMouse && ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) m_spaceMouse->SetFocus( aEvent.GetActive() ); - } -#endif } @@ -556,12 +544,8 @@ void SCH_BASE_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent ) { EDA_DRAW_FRAME::handleIconizeEvent( aEvent ); -#if defined( KICAD_USE_3DCONNEXION ) - if( m_spaceMouse && aEvent.IsIconized() ) - { + if( m_spaceMouse && aEvent.IsIconized() && ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) m_spaceMouse->SetFocus( false ); - } -#endif } diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h index cb5132c9af..e286d5eb3a 100644 --- a/eeschema/sch_base_frame.h +++ b/eeschema/sch_base_frame.h @@ -270,9 +270,7 @@ protected: SCHEMATIC_SETTINGS m_base_frame_defaults; private: -#if defined( KICAD_USE_3DCONNEXION ) NL_SCHEMATIC_PLUGIN* m_spaceMouse; -#endif }; #endif // SCH_BASE_FRAME_H_ diff --git a/include/advanced_config.h b/include/advanced_config.h index 6020e192b3..37506ddae7 100644 --- a/include/advanced_config.h +++ b/include/advanced_config.h @@ -247,6 +247,11 @@ public: */ bool m_UseClipper2; + /** + * Use the 3DConnexion Driver + */ + bool m_Use3DConnexionDriver; + ///@} diff --git a/pcbnew/navlib/CMakeLists.txt b/pcbnew/navlib/CMakeLists.txt index 23e4cb294c..8e4eca6208 100644 --- a/pcbnew/navlib/CMakeLists.txt +++ b/pcbnew/navlib/CMakeLists.txt @@ -1,30 +1,25 @@ -if( KICAD_USE_3DCONNEXION ) - add_library(pcbnew_navlib STATIC - "nl_pcbnew_plugin.cpp" - "nl_pcbnew_plugin_impl.cpp" - ) - # pcbnew_navlib depends on make_lexer outputs in common - add_dependencies( pcbnew_navlib pcbcommon ) +add_library(pcbnew_navlib STATIC + "nl_pcbnew_plugin.cpp" + "nl_pcbnew_plugin_impl.cpp" +) - # Find the 3DxWare SDK component 3DxWare::NlClient - # find_package(TDxWare_SDK 4.0 REQUIRED COMPONENTS 3DxWare::Navlib) - target_compile_definitions(pcbnew_navlib PRIVATE - $ - ) - target_compile_options(pcbnew_navlib PRIVATE - $ - ) - target_include_directories(pcbnew_navlib PRIVATE - $ - $ - ) - target_link_libraries(pcbnew_navlib - $ - 3DxWare::Navlib - ) -else() - add_library(pcbnew_navlib STATIC - "nl_pcbnew_plugin.cpp" - ) -endif(KICAD_USE_3DCONNEXION) +# pcbnew_navlib depends on make_lexer outputs in common +add_dependencies( pcbnew_navlib pcbcommon ) + +# Find the 3DxWare SDK component 3DxWare::NlClient +# find_package(TDxWare_SDK 4.0 REQUIRED COMPONENTS 3DxWare::Navlib) +target_compile_definitions(pcbnew_navlib PRIVATE + $ +) +target_compile_options(pcbnew_navlib PRIVATE + $ +) +target_include_directories(pcbnew_navlib PRIVATE + $ + $ +) +target_link_libraries(pcbnew_navlib + $ + 3DxWare::Navlib +) diff --git a/pcbnew/navlib/nl_pcbnew_plugin.cpp b/pcbnew/navlib/nl_pcbnew_plugin.cpp index 99c5389431..14ac787263 100644 --- a/pcbnew/navlib/nl_pcbnew_plugin.cpp +++ b/pcbnew/navlib/nl_pcbnew_plugin.cpp @@ -19,14 +19,14 @@ */ #include "nl_pcbnew_plugin.h" -#if defined( KICAD_USE_3DCONNEXION ) - #include "nl_pcbnew_plugin_impl.h" +#include -NL_PCBNEW_PLUGIN::NL_PCBNEW_PLUGIN( PCB_DRAW_PANEL_GAL* aViewport ) : - m_impl( new NL_PCBNEW_PLUGIN_IMPL( aViewport ) ) +NL_PCBNEW_PLUGIN::NL_PCBNEW_PLUGIN( PCB_DRAW_PANEL_GAL* aViewport ) { + if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) + m_impl = new NL_PCBNEW_PLUGIN_IMPL( aViewport ); } @@ -38,22 +38,6 @@ NL_PCBNEW_PLUGIN::~NL_PCBNEW_PLUGIN() void NL_PCBNEW_PLUGIN::SetFocus( bool focus ) { - m_impl->SetFocus( focus ); + if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) + m_impl->SetFocus( focus ); } -#else - - -NL_PCBNEW_PLUGIN::NL_PCBNEW_PLUGIN( PCB_DRAW_PANEL_GAL* aViewport ) -{ -} - - -void NL_PCBNEW_PLUGIN::SetFocus( bool focus ) -{ -} - - -NL_PCBNEW_PLUGIN::~NL_PCBNEW_PLUGIN() -{ -} -#endif diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 2d0c21d723..2255c25a06 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -33,39 +33,39 @@ #include #endif -#include -#include -#include -#include -#include -#include #include <3d_viewer/eda_3d_viewer_frame.h> // To include VIEWER3D_FRAMENAME -#include -#include -#include -#include +#include +#include #include -#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include + #include #include -#include +#include -#include #include #include #include #include #include #include -#include "cleanup_item.h" -#include #include -#if defined( KICAD_USE_3DCONNEXION ) #include -#endif using KIGFX::RENDER_SETTINGS; using KIGFX::PCB_RENDER_SETTINGS; @@ -86,9 +86,8 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame PCB_BASE_FRAME::~PCB_BASE_FRAME() { -#if defined( KICAD_USE_3DCONNEXION ) delete m_spaceMouse; -#endif + m_spaceMouse = nullptr; // Ensure m_canvasType is up to date, to save it in config m_canvasType = GetCanvas()->GetBackend(); @@ -119,12 +118,8 @@ void PCB_BASE_FRAME::handleActivateEvent( wxActivateEvent& aEvent ) { EDA_DRAW_FRAME::handleActivateEvent( aEvent ); -#if defined( KICAD_USE_3DCONNEXION ) - if( m_spaceMouse != nullptr ) - { + if( m_spaceMouse != nullptr && ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) m_spaceMouse->SetFocus( aEvent.GetActive() ); - } -#endif } @@ -132,12 +127,9 @@ void PCB_BASE_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent ) { EDA_DRAW_FRAME::handleIconizeEvent( aEvent ); -#if defined( KICAD_USE_3DCONNEXION ) - if( m_spaceMouse != nullptr && aEvent.IsIconized() ) - { + if( m_spaceMouse != nullptr && aEvent.IsIconized() + && ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) m_spaceMouse->SetFocus( false ); - } -#endif } @@ -1084,19 +1076,21 @@ void PCB_BASE_FRAME::ActivateGalCanvas() canvas->SetEventDispatcher( m_toolDispatcher ); canvas->StartDrawing(); -#if defined( KICAD_USE_3DCONNEXION ) - try + if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver ) { - if( m_spaceMouse == nullptr ) + try + { - m_spaceMouse = new NL_PCBNEW_PLUGIN( GetCanvas() ); + if( m_spaceMouse == nullptr ) + { + m_spaceMouse = new NL_PCBNEW_PLUGIN( GetCanvas() ); + } + } + catch( const std::system_error& e ) + { + wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() ); } } - catch( const std::system_error& e ) - { - wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() ); - } -#endif }