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
This commit is contained in:
Seth Hillbrand 2023-04-07 10:08:43 -07:00
parent 9efd24a69d
commit 2cd854af14
19 changed files with 154 additions and 266 deletions

View File

@ -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 <advanced_config.h>
#include <board.h>
#include <reporter.h>
#include <gl_context_mgr.h>
@ -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

View File

@ -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.

View File

@ -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

View File

@ -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 )
$<TARGET_PROPERTY:3DxWare::Navlib,INTERFACE_LINK_LIBRARIES>
3DxWare::Navlib
)
else()
add_library(3d-viewer_navlib STATIC
"nl_3d_viewer_plugin.cpp"
)
endif(KICAD_USE_3DCONNEXION)

View File

@ -19,14 +19,14 @@
*/
#include "nl_3d_viewer_plugin.h"
#if defined( KICAD_USE_3DCONNEXION )
#include "nl_3d_viewer_plugin_impl.h"
#include <advanced_config.h>
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 )
{
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

View File

@ -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 <advanced_config.h>
#include <bitmaps.h>
#include <board_design_settings.h>
#include <core/arraydim.h>
@ -56,9 +57,7 @@
#include <widgets/wx_infobar.h>
#include <wildcards_and_files_ext.h>
#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,7 +165,9 @@ 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 )
if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
{
try
{
m_spaceMouse = new NL_3D_VIEWER_PLUGIN( m_canvas );
@ -175,7 +176,7 @@ EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent
{
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
@ -192,13 +193,8 @@ 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
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
}

View File

@ -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()

View File

@ -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( $<$<BOOL:${KICAD_USE_VALGRIND}>:KICAD_USE_VALGRIND> )
add_compile_definitions( $<$<BOOL:${KICAD_GAL_PROFILE}>:KICAD_GAL_PROFILE> )
add_compile_definitions( $<$<BOOL:${KICAD_WIN32_VERIFY_CODESIGN}>:KICAD_WIN32_VERIFY_CODESIGN> )
# 3D mouse is only available on Windows and macOS
if( WIN32 OR APPLE )
add_compile_definitions( $<$<BOOL:${KICAD_USE_3DCONNEXION}>:KICAD_USE_3DCONNEXION> )
endif()
if( KICAD_USE_EGL )
message( STATUS "Configuring KiCad for the wxGLCanvas EGL backend" )
add_compile_definitions( KICAD_USE_EGL )

View File

@ -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()
add_dependencies( pcbcommon delaunator )

View File

@ -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

View File

@ -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 )
add_subdirectory( navlib )
target_link_libraries( eeschema_kiface_objects PUBLIC eeschema_navlib)
add_dependencies( eeschema_kiface_objects eeschema_navlib )
endif()
add_library( eeschema_kiface MODULE
eeschema.cpp

View File

@ -1,4 +1,4 @@
if( KICAD_USE_3DCONNEXION )
add_library(eeschema_navlib STATIC
"nl_schematic_plugin.cpp"
"nl_schematic_plugin_impl.cpp"
@ -23,8 +23,3 @@ if( KICAD_USE_3DCONNEXION )
$<TARGET_PROPERTY:3DxWare::Navlib,INTERFACE_LINK_LIBRARIES>
3DxWare::Navlib
)
else()
add_library(eeschema_navlib STATIC
"nl_schematic_plugin.cpp"
)
endif(KICAD_USE_3DCONNEXION)

View File

@ -19,13 +19,15 @@
*/
#include "nl_schematic_plugin.h"
#if defined( KICAD_USE_3DCONNEXION )
#include <advanced_config.h>
#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 )
{
if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
m_impl->SetFocus( focus );
}
void NL_SCHEMATIC_PLUGIN::SetCanvas( EDA_DRAW_PANEL_GAL* 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

View File

@ -22,6 +22,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <advanced_config.h>
#include <base_units.h>
#include <kiway.h>
#include <lib_tree_model_adapter.h>
@ -47,9 +48,7 @@
#include <wx/choicdlg.h>
#include <wx/log.h>
#if defined( KICAD_USE_3DCONNEXION )
#include <navlib/nl_schematic_plugin.h>
#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
}
@ -350,13 +343,12 @@ void SCH_BASE_FRAME::ActivateGalCanvas()
{
EDA_DRAW_FRAME::ActivateGalCanvas();
#if defined( KICAD_USE_3DCONNEXION )
if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
{
try
{
if( !m_spaceMouse )
{
m_spaceMouse = new NL_SCHEMATIC_PLUGIN();
}
m_spaceMouse->SetCanvas( GetCanvas() );
}
@ -364,7 +356,7 @@ void SCH_BASE_FRAME::ActivateGalCanvas()
{
wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
}
#endif
}
}
@ -543,26 +535,18 @@ 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
}
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
}
wxString SCH_BASE_FRAME::SelectLibraryFromList()

View File

@ -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_

View File

@ -247,6 +247,11 @@ public:
*/
bool m_UseClipper2;
/**
* Use the 3DConnexion Driver
*/
bool m_Use3DConnexionDriver;
///@}

View File

@ -1,4 +1,4 @@
if( KICAD_USE_3DCONNEXION )
add_library(pcbnew_navlib STATIC
"nl_pcbnew_plugin.cpp"
"nl_pcbnew_plugin_impl.cpp"
@ -23,8 +23,3 @@ if( KICAD_USE_3DCONNEXION )
$<TARGET_PROPERTY:3DxWare::Navlib,INTERFACE_LINK_LIBRARIES>
3DxWare::Navlib
)
else()
add_library(pcbnew_navlib STATIC
"nl_pcbnew_plugin.cpp"
)
endif(KICAD_USE_3DCONNEXION)

View File

@ -19,14 +19,14 @@
*/
#include "nl_pcbnew_plugin.h"
#if defined( KICAD_USE_3DCONNEXION )
#include "nl_pcbnew_plugin_impl.h"
#include <advanced_config.h>
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 )
{
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

View File

@ -33,39 +33,39 @@
#include <boost/uuid/entropy_error.hpp>
#endif
#include <kiface_base.h>
#include <confirm.h>
#include <pcb_base_frame.h>
#include <base_units.h>
#include <widgets/msgpanel.h>
#include <pgm_base.h>
#include <3d_viewer/eda_3d_viewer_frame.h> // To include VIEWER3D_FRAMENAME
#include <footprint_editor_settings.h>
#include <pcbnew_settings.h>
#include <fp_lib_table.h>
#include <pcbnew_id.h>
#include <advanced_config.h>
#include <base_units.h>
#include <board.h>
#include <footprint.h>
#include <cleanup_item.h>
#include <collectors.h>
#include <confirm.h>
#include <footprint.h>
#include <footprint_editor_settings.h>
#include <fp_lib_table.h>
#include <kiface_base.h>
#include <pcb_group.h>
#include <pcb_painter.h>
#include <pcbnew_id.h>
#include <pcbnew_settings.h>
#include <pcb_base_frame.h>
#include <pcb_draw_panel_gal.h>
#include <pgm_base.h>
#include <zoom_defines.h>
#include <math/vector2d.h>
#include <math/vector2wx.h>
#include <pcb_group.h>
#include <widgets/msgpanel.h>
#include <pcb_painter.h>
#include <settings/settings_manager.h>
#include <settings/cvpcb_settings.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tools/pcb_actions.h>
#include <tool/grid_menu.h>
#include "cleanup_item.h"
#include <zoom_defines.h>
#include <ratsnest/ratsnest_view_item.h>
#if defined( KICAD_USE_3DCONNEXION )
#include <navlib/nl_pcbnew_plugin.h>
#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,26 +118,19 @@ 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
}
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
}
EDA_3D_VIEWER_FRAME* PCB_BASE_FRAME::Get3DViewerFrame()
@ -1084,8 +1076,10 @@ void PCB_BASE_FRAME::ActivateGalCanvas()
canvas->SetEventDispatcher( m_toolDispatcher );
canvas->StartDrawing();
#if defined( KICAD_USE_3DCONNEXION )
if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
{
try
{
if( m_spaceMouse == nullptr )
{
@ -1096,7 +1090,7 @@ void PCB_BASE_FRAME::ActivateGalCanvas()
{
wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
}
#endif
}
}