From d08f93793241017caad9359c3ad18568a4af44ba 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 (cherry picked from commit 2cd854af14b00e34409f91bdcf899ebdbeba0f57) --- 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 +-- 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 | 7 ++ pcbnew/navlib/CMakeLists.txt | 51 +++++++-------- pcbnew/navlib/nl_pcbnew_plugin.cpp | 28 ++------ pcbnew/pcb_base_frame.cpp | 72 ++++++++++----------- 18 files changed, 157 insertions(+), 258 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 7b1e9ab77e..a0e310eb24 100644 --- a/3d-viewer/CMakeLists.txt +++ b/3d-viewer/CMakeLists.txt @@ -122,8 +122,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/common/CMakeLists.txt b/common/CMakeLists.txt index 8b2c453f58..92bc9d840f 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -620,12 +620,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 7698a32ae6..a32bed5de2 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 92fcfd145f..594b6fedeb 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -463,15 +463,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 d98b78c8f1..5f506f83f1 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 @@ -46,9 +47,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 ) @@ -90,10 +89,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(); @@ -115,10 +111,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; } @@ -349,21 +342,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 } @@ -538,12 +530,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 } @@ -551,12 +539,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 2b7b5f3445..cd32e567d9 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 84e3cc1763..503eea0304 100644 --- a/include/advanced_config.h +++ b/include/advanced_config.h @@ -239,6 +239,13 @@ public: */ bool m_UseClipper2; + /** + * Use the 3DConnexion Driver + */ + bool m_Use3DConnexionDriver; + +///@} + private: ADVANCED_CFG(); 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 6de5b8954f..68bc84cae1 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -33,38 +33,38 @@ #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 "cleanup_item.h" -#include #include -#if defined( KICAD_USE_3DCONNEXION ) #include -#endif using KIGFX::RENDER_SETTINGS; using KIGFX::PCB_RENDER_SETTINGS; @@ -84,9 +84,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(); @@ -117,12 +116,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 } @@ -130,12 +125,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 } @@ -1057,19 +1049,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 }