From be58ab679bd605b5181c7fde6a64811fc42c08dd Mon Sep 17 00:00:00 2001 From: markus-bonk Date: Mon, 5 Jul 2021 10:04:36 +0200 Subject: [PATCH] Fix coding style policy violations and CMake version. Fix violations of 4.2.2 Function Definitions and 4.2.3 Control Statements. Set the minimum CMake version required to build to 3.1. Removed the Visual Studio solution and project files. --- 3d-viewer/3d_navlib/nl_3d_viewer_plugin.cpp | 7 +++ 3d-viewer/3d_navlib/nl_3d_viewer_plugin.h | 1 + .../3d_navlib/nl_3d_viewer_plugin_impl.cpp | 54 +++++++++++++++++-- .../3d_navlib/nl_3d_viewer_plugin_impl.h | 3 ++ 3d-viewer/3d_rendering/camera.cpp | 5 ++ 3d-viewer/3d_rendering/camera.h | 6 +++ pcbnew/navlib/nl_pcbnew_plugin.cpp | 7 +++ pcbnew/navlib/nl_pcbnew_plugin_impl.cpp | 52 ++++++++++++++++-- pcbnew/navlib/nl_pcbnew_plugin_impl.h | 7 +++ pcbnew/pcb_edit_frame.cpp | 2 + thirdparty/3dxware_sdk/CMakeLists.txt | 2 +- .../inc/SpaceMouse/Navigation3D.vcxitems | 41 -------------- .../3dxware_sdk/inc/SpaceMouse/SpaceMouse.sln | 15 ------ 13 files changed, 138 insertions(+), 64 deletions(-) delete mode 100644 thirdparty/3dxware_sdk/inc/SpaceMouse/Navigation3D.vcxitems delete mode 100644 thirdparty/3dxware_sdk/inc/SpaceMouse/SpaceMouse.sln diff --git a/3d-viewer/3d_navlib/nl_3d_viewer_plugin.cpp b/3d-viewer/3d_navlib/nl_3d_viewer_plugin.cpp index 2f849a2c50..1cdb3bc3a6 100644 --- a/3d-viewer/3d_navlib/nl_3d_viewer_plugin.cpp +++ b/3d-viewer/3d_navlib/nl_3d_viewer_plugin.cpp @@ -23,29 +23,36 @@ #if defined( KICAD_USE_3DCONNEXION ) #include "nl_3d_viewer_plugin_impl.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() { delete m_impl; } + void NL_3D_VIEWER_PLUGIN::SetFocus( bool focus ) { m_impl->SetFocus( focus ); } #else + + NL_3DVIEWER_PLUGIN::NL_3DVIEWER_PLUGIN( EDA_3D_CANVAS* aViewport ) { } + void NL_3DVIEWER_PLUGIN::SetFocus( bool focus ) { } + NL_3DVIEWER_PLUGIN::~NL_3DVIEWER_PLUGIN() { } diff --git a/3d-viewer/3d_navlib/nl_3d_viewer_plugin.h b/3d-viewer/3d_navlib/nl_3d_viewer_plugin.h index 7cfbea042d..880c34a508 100644 --- a/3d-viewer/3d_navlib/nl_3d_viewer_plugin.h +++ b/3d-viewer/3d_navlib/nl_3d_viewer_plugin.h @@ -29,6 +29,7 @@ // Forward declarations. class EDA_3D_CANVAS; class NL_3D_VIEWER_PLUGIN_IMPL; + /** * The class that implements the public interface to the SpaceMouse plug-in. */ diff --git a/3d-viewer/3d_navlib/nl_3d_viewer_plugin_impl.cpp b/3d-viewer/3d_navlib/nl_3d_viewer_plugin_impl.cpp index 62c2a4b27e..1a4e63c867 100644 --- a/3d-viewer/3d_navlib/nl_3d_viewer_plugin_impl.cpp +++ b/3d-viewer/3d_navlib/nl_3d_viewer_plugin_impl.cpp @@ -42,6 +42,7 @@ #include #include + /** * Flag to enable the NL_3D_VIEWER_PLUGIN debug tracing. * @@ -63,17 +64,21 @@ template bool equals( T aFirst, T aSecond, T aEpsilon = static_cast( FLT_EPSILON ) ) { T diff = fabs( aFirst - aSecond ); + if( diff < aEpsilon ) { return true; } + aFirst = fabs( aFirst ); aSecond = fabs( aSecond ); T largest = aFirst > aSecond ? aFirst : aSecond; + if( diff <= largest * aEpsilon ) { return true; } + return false; } @@ -103,6 +108,7 @@ bool equals( glm::mat const& aFirst, glm::mat const& aSe return true; } + NL_3D_VIEWER_PLUGIN_IMPL::NL_3D_VIEWER_PLUGIN_IMPL( EDA_3D_CANVAS* aCanvas ) : NAV_3D( false, false ), m_canvas( aCanvas ), m_capIsMoving( false ) { @@ -116,11 +122,13 @@ NL_3D_VIEWER_PLUGIN_IMPL::NL_3D_VIEWER_PLUGIN_IMPL( EDA_3D_CANVAS* aCanvas ) : exportCommandsAndImages(); } + NL_3D_VIEWER_PLUGIN_IMPL::~NL_3D_VIEWER_PLUGIN_IMPL() { EnableNavigation( false ); } + void NL_3D_VIEWER_PLUGIN_IMPL::SetFocus( bool aFocus ) { wxLogTrace( m_logTrace, wxT( "NL_3D_VIEWER_PLUGIN_IMPL::SetFocus %d" ), aFocus ); @@ -150,6 +158,7 @@ CATEGORY_STORE::iterator add_category( std::string aCategoryPath, CATEGORY_STORE { std::string parentPath = aCategoryPath.substr( 0, pos ); parent_iter = aCategoryStore.find( parentPath ); + if( parent_iter == aCategoryStore.end() ) { parent_iter = add_category( parentPath, aCategoryStore ); @@ -167,9 +176,7 @@ CATEGORY_STORE::iterator add_category( std::string aCategoryPath, CATEGORY_STORE return iter; } -/** - * Export the invocable actions and images to the 3Dconnexion UI. - */ + void NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages() { wxLogTrace( m_logTrace, wxT( "NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages" ) ); @@ -205,6 +212,7 @@ void NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages() { const TOOL_ACTION* action = *it; std::string label = action->GetLabel().ToStdString(); + if( label.empty() ) { continue; @@ -220,6 +228,7 @@ void NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages() std::string strCategory = action->GetToolName(); CATEGORY_STORE::iterator iter = categoryStore.find( strCategory ); + if( iter == categoryStore.end() ) { iter = add_category( std::move( strCategory ), categoryStore ); @@ -229,6 +238,7 @@ void NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages() // Arbitrary 8-bit data stream wxMemoryOutputStream imageStream; + if( action->GetIcon() != BITMAPS::INVALID_BITMAP ) { wxImage image = KiBitmap( action->GetIcon() ).ConvertToImage(); @@ -260,6 +270,7 @@ void NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages() NAV_3D::AddImages( vImages ); } + long NL_3D_VIEWER_PLUGIN_IMPL::GetCameraMatrix( navlib::matrix_t& matrix ) const { // cache the camera matrix so that we can tell if the view has been moved and @@ -271,6 +282,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::GetCameraMatrix( navlib::matrix_t& matrix ) const return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::GetPointerPosition( navlib::point_t& position ) const { SFVEC3F origin, direction; @@ -281,6 +293,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::GetPointerPosition( navlib::point_t& position ) c return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::GetViewExtents( navlib::box_t& extents ) const { if( m_camera->GetProjection() == PROJECTION_TYPE::PERSPECTIVE ) @@ -297,6 +310,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::GetViewExtents( navlib::box_t& extents ) const return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::GetViewFOV( double& aFov ) const { const CAMERA_FRUSTUM& f = m_camera->GetFrustum(); @@ -305,6 +319,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::GetViewFOV( double& aFov ) const return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::GetViewFrustum( navlib::frustum_t& aFrustum ) const { if( m_camera->GetProjection() != PROJECTION_TYPE::PERSPECTIVE ) @@ -320,6 +335,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::GetViewFrustum( navlib::frustum_t& aFrustum ) con return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::GetIsViewPerspective( navlib::bool_t& perspective ) const { perspective = m_camera->GetProjection() == PROJECTION_TYPE::PERSPECTIVE ? 1 : 0; @@ -327,6 +343,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::GetIsViewPerspective( navlib::bool_t& perspective return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::SetCameraMatrix( const navlib::matrix_t& aCameraMatrix ) { long result = 0; @@ -335,11 +352,11 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetCameraMatrix( const navlib::matrix_t& aCameraM std::copy_n( aCameraMatrix.m, 16, glm::value_ptr( cam ) ); viewMatrix = glm::inverse( cam ); - glm::mat4 camera = m_camera->GetViewMatrix(); // The navlib does not move the camera in its z-axis in an orthographic projection // as this does not change the viewed object size. However ... + if( m_camera->GetProjection() == PROJECTION_TYPE::ORTHO ) { // ... the CAMERA class couples zoom and distance to the object: we need to @@ -374,6 +391,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetCameraMatrix( const navlib::matrix_t& aCameraM m_cameraMatrix = m_camera->GetViewMatrix(); // The camera has a constraint on the z position so we need to check that ... + if( !equals( m_cameraMatrix[3].z, viewMatrix[3].z ) ) { // ... and let the 3DMouse controller know, when something is amiss. @@ -383,6 +401,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetCameraMatrix( const navlib::matrix_t& aCameraM return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::SetViewExtents( const navlib::box_t& extents ) { const CAMERA_FRUSTUM& f = m_camera->GetFrustum(); @@ -406,16 +425,19 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetViewExtents( const navlib::box_t& extents ) return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::SetViewFOV( double fov ) { return navlib::make_result_code( navlib::navlib_errc::function_not_supported ); } + long NL_3D_VIEWER_PLUGIN_IMPL::SetViewFrustum( const navlib::frustum_t& frustum ) { return navlib::make_result_code( navlib::navlib_errc::permission_denied ); } + long NL_3D_VIEWER_PLUGIN_IMPL::GetModelExtents( navlib::box_t& extents ) const { SFVEC3F min = m_canvas->GetBoardAdapter().GetBBox().Min(); @@ -426,16 +448,19 @@ long NL_3D_VIEWER_PLUGIN_IMPL::GetModelExtents( navlib::box_t& extents ) const return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::GetSelectionExtents( navlib::box_t& extents ) const { return navlib::make_result_code( navlib::navlib_errc::no_data_available ); } + long NL_3D_VIEWER_PLUGIN_IMPL::GetSelectionTransform( navlib::matrix_t& transform ) const { return navlib::make_result_code( navlib::navlib_errc::no_data_available ); } + long NL_3D_VIEWER_PLUGIN_IMPL::GetIsSelectionEmpty( navlib::bool_t& empty ) const { empty = true; @@ -443,11 +468,13 @@ long NL_3D_VIEWER_PLUGIN_IMPL::GetIsSelectionEmpty( navlib::bool_t& empty ) cons return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::SetSelectionTransform( const navlib::matrix_t& matrix ) { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_3D_VIEWER_PLUGIN_IMPL::GetPivotPosition( navlib::point_t& position ) const { SFVEC3F lap = m_camera->GetLookAtPos(); @@ -457,6 +484,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::GetPivotPosition( navlib::point_t& position ) con return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::IsUserPivot( navlib::bool_t& userPivot ) const { userPivot = false; @@ -464,6 +492,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::IsUserPivot( navlib::bool_t& userPivot ) const return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::SetPivotPosition( const navlib::point_t& position ) { SFVEC3F pivotPos = SFVEC3F( position.x, position.y, position.z ); @@ -484,6 +513,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetPivotPosition( const navlib::point_t& position return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::GetPivotVisible( navlib::bool_t& visible ) const { visible = m_canvas->GetRenderPivot(); @@ -491,6 +521,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::GetPivotVisible( navlib::bool_t& visible ) const return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::SetPivotVisible( bool visible ) { m_canvas->SetRenderPivot( visible ); @@ -500,6 +531,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetPivotVisible( bool visible ) return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::GetHitLookAt( navlib::point_t& position ) const { RAY mouseRay; @@ -509,6 +541,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::GetHitLookAt( navlib::point_t& position ) const glm::vec3 vec; // Test it with the board bounding box + if( m_canvas->GetBoardAdapter().GetBBox().Intersect( mouseRay, &hit ) ) { vec = mouseRay.at( hit ); @@ -519,11 +552,13 @@ long NL_3D_VIEWER_PLUGIN_IMPL::GetHitLookAt( navlib::point_t& position ) const return navlib::make_result_code( navlib::navlib_errc::no_data_available ); } + long NL_3D_VIEWER_PLUGIN_IMPL::SetHitAperture( double aperture ) { return navlib::make_result_code( navlib::navlib_errc::function_not_supported ); } + long NL_3D_VIEWER_PLUGIN_IMPL::SetHitDirection( const navlib::vector_t& direction ) { m_rayDirection = { direction.x, direction.y, direction.z }; @@ -531,6 +566,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetHitDirection( const navlib::vector_t& directio return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::SetHitLookFrom( const navlib::point_t& eye ) { m_rayOrigin = { eye.x, eye.y, eye.z }; @@ -538,11 +574,13 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetHitLookFrom( const navlib::point_t& eye ) return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::SetHitSelectionOnly( bool onlySelection ) { return navlib::make_result_code( navlib::navlib_errc::function_not_supported ); } + long NL_3D_VIEWER_PLUGIN_IMPL::SetActiveCommand( std::string commandId ) { if( commandId.empty() ) @@ -570,6 +608,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetActiveCommand( std::string commandId ) // Only allow command execution if the window is enabled. i.e. there is not a modal dialog // currently active. + if( parent->IsEnabled() ) { TOOL_MANAGER* tool_manager = static_cast( parent )->GetToolManager(); @@ -605,11 +644,13 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetActiveCommand( std::string commandId ) return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::SetSettingsChanged( long change ) { return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::SetMotionFlag( bool value ) { m_capIsMoving = value; @@ -617,6 +658,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetMotionFlag( bool value ) return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::SetTransaction( long value ) { if( value != 0L ) @@ -631,17 +673,20 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetTransaction( long value ) return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::SetCameraTarget( const navlib::point_t& position ) { return navlib::make_result_code( navlib::navlib_errc::function_not_supported ); } + long NL_3D_VIEWER_PLUGIN_IMPL::GetFrontView( navlib::matrix_t& matrix ) const { matrix = { 1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1 }; return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::GetCoordinateSystem( navlib::matrix_t& matrix ) const { // Use the right-handed coordinate system X-right, Z-up, Y-in (row vectors) @@ -649,6 +694,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::GetCoordinateSystem( navlib::matrix_t& matrix ) c return 0; } + long NL_3D_VIEWER_PLUGIN_IMPL::GetIsViewRotatable( navlib::bool_t& isRotatable ) const { isRotatable = true; diff --git a/3d-viewer/3d_navlib/nl_3d_viewer_plugin_impl.h b/3d-viewer/3d_navlib/nl_3d_viewer_plugin_impl.h index 708e0c48f2..6ae6d23447 100644 --- a/3d-viewer/3d_navlib/nl_3d_viewer_plugin_impl.h +++ b/3d-viewer/3d_navlib/nl_3d_viewer_plugin_impl.h @@ -70,6 +70,9 @@ public: void SetFocus( bool aFocus = true ); private: + /** + * Export the invocable actions and images to the 3Dconnexion UI. + */ void exportCommandsAndImages(); long GetCameraMatrix( navlib::matrix_t& aMatrix ) const override; diff --git a/3d-viewer/3d_rendering/camera.cpp b/3d-viewer/3d_rendering/camera.cpp index eb9bdf87a5..418b3d37f5 100644 --- a/3d-viewer/3d_rendering/camera.cpp +++ b/3d-viewer/3d_rendering/camera.cpp @@ -120,6 +120,7 @@ void CAMERA::Reset_T1() m_rotate_aux_t1.z = static_cast( 2.0f * M_PI ); } + void CAMERA::SetBoardLookAtPos( const SFVEC3F& aBoardPos ) { if( m_board_lookat_pos_init != aBoardPos ) @@ -134,6 +135,7 @@ void CAMERA::SetBoardLookAtPos( const SFVEC3F& aBoardPos ) } } + void CAMERA::zoomChanged() { if( m_zoom < m_minZoom ) @@ -183,6 +185,7 @@ glm::mat4 CAMERA::GetRotationMatrix() const return m_rotationMatrix * m_rotationMatrixAux; } + void CAMERA::SetRotationMatrix( const glm::mat4& aRotation ) { m_parametersChanged = true; @@ -190,6 +193,7 @@ void CAMERA::SetRotationMatrix( const glm::mat4& aRotation ) glm::value_ptr( m_rotationMatrix ) ); } + void CAMERA::rebuildProjection() { if( ( m_windowSize.x == 0 ) || ( m_windowSize.y == 0 ) ) @@ -531,6 +535,7 @@ void CAMERA::ZoomReset() rebuildProjection(); } + bool CAMERA::Zoom( float aFactor ) { if( ( m_zoom <= m_minZoom && aFactor > 1 ) || ( m_zoom >= m_maxZoom && aFactor < 1 ) diff --git a/3d-viewer/3d_rendering/camera.h b/3d-viewer/3d_rendering/camera.h index 51b4b45bcc..df3f2c1d60 100644 --- a/3d-viewer/3d_rendering/camera.h +++ b/3d-viewer/3d_rendering/camera.h @@ -162,6 +162,9 @@ public: void ResetXYpos(); void ResetXYpos_T1(); + /** + * Get the current mouse position. + */ const wxPoint& GetCurMousePosition() { return m_lastPosition; } /** @@ -264,6 +267,9 @@ public: */ void MakeRayAtCurrentMousePosition( SFVEC3F& aOutOrigin, SFVEC3F& aOutDirection ) const; + /** + * Update the camera. + */ void Update() { updateFrustum(); } protected: diff --git a/pcbnew/navlib/nl_pcbnew_plugin.cpp b/pcbnew/navlib/nl_pcbnew_plugin.cpp index ab1d6def5d..99c5389431 100644 --- a/pcbnew/navlib/nl_pcbnew_plugin.cpp +++ b/pcbnew/navlib/nl_pcbnew_plugin.cpp @@ -23,29 +23,36 @@ #include "nl_pcbnew_plugin_impl.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() { delete m_impl; } + void NL_PCBNEW_PLUGIN::SetFocus( bool focus ) { 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() { } diff --git a/pcbnew/navlib/nl_pcbnew_plugin_impl.cpp b/pcbnew/navlib/nl_pcbnew_plugin_impl.cpp index b3dafa42fe..a59407d19c 100644 --- a/pcbnew/navlib/nl_pcbnew_plugin_impl.cpp +++ b/pcbnew/navlib/nl_pcbnew_plugin_impl.cpp @@ -54,17 +54,21 @@ template bool equals( T aFirst, T aSecond, T aEpsilon = static_cast( FLT_EPSILON ) ) { T diff = fabs( aFirst - aSecond ); + if( diff < aEpsilon ) { return true; } + aFirst = fabs( aFirst ); aSecond = fabs( aSecond ); T largest = aFirst > aSecond ? aFirst : aSecond; + if( diff <= largest * aEpsilon ) { return true; } + return false; } @@ -97,6 +101,7 @@ bool equals( VECTOR2 const& aFirst, VECTOR2 const& aSecond, */ const wxChar* NL_PCBNEW_PLUGIN_IMPL::m_logTrace = wxT( "KI_TRACE_NL_PCBNEW_PLUGIN" ); + NL_PCBNEW_PLUGIN_IMPL::NL_PCBNEW_PLUGIN_IMPL( PCB_DRAW_PANEL_GAL* aViewport ) : CNavigation3D( false, false ), m_viewport2D( aViewport ), m_isMoving( false ) { @@ -115,11 +120,13 @@ NL_PCBNEW_PLUGIN_IMPL::NL_PCBNEW_PLUGIN_IMPL( PCB_DRAW_PANEL_GAL* aViewport ) : exportCommandsAndImages(); } + NL_PCBNEW_PLUGIN_IMPL::~NL_PCBNEW_PLUGIN_IMPL() { EnableNavigation( false ); } + void NL_PCBNEW_PLUGIN_IMPL::SetFocus( bool aFocus ) { wxLogTrace( m_logTrace, "NL_PCBNEW_PLUGIN_IMPL::SetFocus %d", aFocus ); @@ -150,6 +157,7 @@ static CATEGORY_STORE::iterator add_category( std::string aCategoryPath, { std::string parentPath = aCategoryPath.substr( 0, pos ); parent_iter = aCategoryStore.find( parentPath ); + if( parent_iter == aCategoryStore.end() ) { parent_iter = add_category( parentPath, aCategoryStore ); @@ -167,9 +175,7 @@ static CATEGORY_STORE::iterator add_category( std::string aCategoryPath, return iter; } -/** - * Export the invocable actions and images to the 3Dconnexion UI. - */ + void NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages() { wxLogTrace( m_logTrace, "NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages" ); @@ -205,6 +211,7 @@ void NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages() { const TOOL_ACTION* action = *it; std::string label = action->GetLabel().ToStdString(); + if( label.empty() ) { continue; @@ -213,6 +220,7 @@ void NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages() std::string name = action->GetName(); // Do no export commands for the 3DViewer app. + if( name.rfind( "3DViewer.", 0 ) == 0 ) { continue; @@ -220,6 +228,7 @@ void NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages() std::string strCategory = action->GetToolName(); CATEGORY_STORE::iterator iter = categoryStore.find( strCategory ); + if( iter == categoryStore.end() ) { iter = add_category( std::move( strCategory ), categoryStore ); @@ -229,6 +238,7 @@ void NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages() // Arbitrary 8-bit data stream wxMemoryOutputStream imageStream; + if( action->GetIcon() != BITMAPS::INVALID_BITMAP ) { wxImage image = KiBitmap( action->GetIcon() ).ConvertToImage(); @@ -260,6 +270,7 @@ void NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages() NAV_3D::AddImages( vImages ); } + long NL_PCBNEW_PLUGIN_IMPL::GetCameraMatrix( navlib::matrix_t& matrix ) const { if( m_view == nullptr ) @@ -281,6 +292,7 @@ long NL_PCBNEW_PLUGIN_IMPL::GetCameraMatrix( navlib::matrix_t& matrix ) const return 0; } + long NL_PCBNEW_PLUGIN_IMPL::GetPointerPosition( navlib::point_t& position ) const { if( m_view == nullptr ) @@ -297,6 +309,7 @@ long NL_PCBNEW_PLUGIN_IMPL::GetPointerPosition( navlib::point_t& position ) cons return 0; } + long NL_PCBNEW_PLUGIN_IMPL::GetViewExtents( navlib::box_t& extents ) const { if( m_view == nullptr ) @@ -318,6 +331,7 @@ long NL_PCBNEW_PLUGIN_IMPL::GetViewExtents( navlib::box_t& extents ) const return 0; } + long NL_PCBNEW_PLUGIN_IMPL::GetIsViewPerspective( navlib::bool_t& perspective ) const { perspective = false; @@ -325,6 +339,7 @@ long NL_PCBNEW_PLUGIN_IMPL::GetIsViewPerspective( navlib::bool_t& perspective ) return 0; } + long NL_PCBNEW_PLUGIN_IMPL::SetCameraMatrix( const navlib::matrix_t& matrix ) { if( m_view == nullptr ) @@ -350,6 +365,7 @@ long NL_PCBNEW_PLUGIN_IMPL::SetCameraMatrix( const navlib::matrix_t& matrix ) return result; } + long NL_PCBNEW_PLUGIN_IMPL::SetViewExtents( const navlib::box_t& extents ) { if( m_view == nullptr ) @@ -358,6 +374,7 @@ long NL_PCBNEW_PLUGIN_IMPL::SetViewExtents( const navlib::box_t& extents ) } long result = 0; + if( m_viewportWidth != m_view->GetViewport().GetWidth() ) { result = navlib::make_result_code( navlib::navlib_errc::error ); @@ -377,16 +394,19 @@ long NL_PCBNEW_PLUGIN_IMPL::SetViewExtents( const navlib::box_t& extents ) return result; } + long NL_PCBNEW_PLUGIN_IMPL::SetViewFOV( double fov ) { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_PCBNEW_PLUGIN_IMPL::SetViewFrustum( const navlib::frustum_t& frustum ) { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_PCBNEW_PLUGIN_IMPL::GetModelExtents( navlib::box_t& extents ) const { if( m_view == nullptr ) @@ -398,6 +418,7 @@ long NL_PCBNEW_PLUGIN_IMPL::GetModelExtents( navlib::box_t& extents ) const box.Normalize(); double half_depth = 0.1 / m_viewport2D->GetGAL()->GetWorldScale(); + if( box.GetWidth() == 0 && box.GetHeight() == 0 ) { half_depth = 0; @@ -413,6 +434,7 @@ long NL_PCBNEW_PLUGIN_IMPL::GetModelExtents( navlib::box_t& extents ) const return 0; } + long NL_PCBNEW_PLUGIN_IMPL::GetCoordinateSystem( navlib::matrix_t& matrix ) const { // The coordinate system is defined as x to the right, y down and z into the screen. @@ -420,24 +442,28 @@ long NL_PCBNEW_PLUGIN_IMPL::GetCoordinateSystem( navlib::matrix_t& matrix ) cons return 0; } + long NL_PCBNEW_PLUGIN_IMPL::GetFrontView( navlib::matrix_t& matrix ) const { matrix = { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 }; return 0; } + long NL_PCBNEW_PLUGIN_IMPL::GetIsSelectionEmpty( navlib::bool_t& empty ) const { empty = true; return 0; } + long NL_PCBNEW_PLUGIN_IMPL::GetIsViewRotatable( navlib::bool_t& isRotatable ) const { isRotatable = false; return 0; } + long NL_PCBNEW_PLUGIN_IMPL::SetActiveCommand( std::string commandId ) { if( commandId.empty() ) @@ -465,6 +491,7 @@ long NL_PCBNEW_PLUGIN_IMPL::SetActiveCommand( std::string commandId ) // Only allow command execution if the window is enabled. i.e. there is not a modal dialog // currently active. + if( parent->IsEnabled() ) { TOOL_MANAGER* tool_manager = static_cast( parent )->GetToolManager(); @@ -494,11 +521,13 @@ long NL_PCBNEW_PLUGIN_IMPL::SetActiveCommand( std::string commandId ) return 0; } + long NL_PCBNEW_PLUGIN_IMPL::SetSettingsChanged( long change ) { return 0; } + long NL_PCBNEW_PLUGIN_IMPL::SetMotionFlag( bool value ) { m_isMoving = value; @@ -506,6 +535,7 @@ long NL_PCBNEW_PLUGIN_IMPL::SetMotionFlag( bool value ) return 0; } + long NL_PCBNEW_PLUGIN_IMPL::SetTransaction( long value ) { if( value == 0L ) @@ -516,81 +546,97 @@ long NL_PCBNEW_PLUGIN_IMPL::SetTransaction( long value ) return 0; } + long NL_PCBNEW_PLUGIN_IMPL::GetViewFOV( double& fov ) const { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_PCBNEW_PLUGIN_IMPL::GetViewFrustum( navlib::frustum_t& frustum ) const { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_PCBNEW_PLUGIN_IMPL::GetSelectionExtents( navlib::box_t& extents ) const { return navlib::make_result_code( navlib::navlib_errc::no_data_available ); } + long NL_PCBNEW_PLUGIN_IMPL::GetSelectionTransform( navlib::matrix_t& transform ) const { return navlib::make_result_code( navlib::navlib_errc::no_data_available ); } + long NL_PCBNEW_PLUGIN_IMPL::SetSelectionTransform( const navlib::matrix_t& matrix ) { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_PCBNEW_PLUGIN_IMPL::GetPivotPosition( navlib::point_t& position ) const { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_PCBNEW_PLUGIN_IMPL::IsUserPivot( navlib::bool_t& userPivot ) const { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_PCBNEW_PLUGIN_IMPL::SetPivotPosition( const navlib::point_t& position ) { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_PCBNEW_PLUGIN_IMPL::GetPivotVisible( navlib::bool_t& visible ) const { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_PCBNEW_PLUGIN_IMPL::SetPivotVisible( bool visible ) { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_PCBNEW_PLUGIN_IMPL::GetHitLookAt( navlib::point_t& position ) const { return navlib::make_result_code( navlib::navlib_errc::no_data_available ); } + long NL_PCBNEW_PLUGIN_IMPL::SetHitAperture( double aperture ) { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_PCBNEW_PLUGIN_IMPL::SetHitDirection( const navlib::vector_t& direction ) { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_PCBNEW_PLUGIN_IMPL::SetHitLookFrom( const navlib::point_t& eye ) { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_PCBNEW_PLUGIN_IMPL::SetHitSelectionOnly( bool onlySelection ) { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); } + long NL_PCBNEW_PLUGIN_IMPL::SetCameraTarget( const navlib::point_t& position ) { return navlib::make_result_code( navlib::navlib_errc::invalid_operation ); diff --git a/pcbnew/navlib/nl_pcbnew_plugin_impl.h b/pcbnew/navlib/nl_pcbnew_plugin_impl.h index 0e47803b6e..b89f26ec0a 100644 --- a/pcbnew/navlib/nl_pcbnew_plugin_impl.h +++ b/pcbnew/navlib/nl_pcbnew_plugin_impl.h @@ -54,6 +54,10 @@ class PCB_VIEW; // Convenience typedef. typedef TDx::SpaceMouse::Navigation3D::CNavigation3D NAV_3D; +/** + * The class that implements the accessors and mutators required for + * 3D navigation in an PCB_DRAW_PANEL_GAL using a SpaceMouse. + */ class NL_PCBNEW_PLUGIN_IMPL : public NAV_3D { public: @@ -75,6 +79,9 @@ public: void SetFocus( bool aFocus ); private: + /** + * Export the invocable actions and images to the 3Dconnexion UI. + */ void exportCommandsAndImages(); long GetCameraMatrix( navlib::matrix_t& aMatrix ) const override; diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 943b8d4ed3..3ae4580b11 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1260,6 +1260,7 @@ void PCB_EDIT_FRAME::OnDisplayOptionsChanged() m_appearancePanel->UpdateDisplayOptions(); } + void PCB_EDIT_FRAME::OnActivate( wxActivateEvent& aEvent ) { #if defined( KICAD_USE_3DCONNEXION ) @@ -1272,6 +1273,7 @@ void PCB_EDIT_FRAME::OnActivate( wxActivateEvent& aEvent ) aEvent.Skip(); // required under wxMAC } + bool PCB_EDIT_FRAME::IsElementVisible( GAL_LAYER_ID aElement ) const { return GetBoard()->IsElementVisible( aElement ); diff --git a/thirdparty/3dxware_sdk/CMakeLists.txt b/thirdparty/3dxware_sdk/CMakeLists.txt index 326642a138..36e1f6d108 100644 --- a/thirdparty/3dxware_sdk/CMakeLists.txt +++ b/thirdparty/3dxware_sdk/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_policy(PUSH) -cmake_policy(VERSION 2.6) +cmake_policy(VERSION 3.1) # Commands may need to know the format version. set(CMAKE_IMPORT_FILE_VERSION 1) diff --git a/thirdparty/3dxware_sdk/inc/SpaceMouse/Navigation3D.vcxitems b/thirdparty/3dxware_sdk/inc/SpaceMouse/Navigation3D.vcxitems deleted file mode 100644 index 94a614ca00..0000000000 --- a/thirdparty/3dxware_sdk/inc/SpaceMouse/Navigation3D.vcxitems +++ /dev/null @@ -1,41 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - {5df960db-b916-4732-a13d-228f20a806fe} - - - - %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/thirdparty/3dxware_sdk/inc/SpaceMouse/SpaceMouse.sln b/thirdparty/3dxware_sdk/inc/SpaceMouse/SpaceMouse.sln deleted file mode 100644 index 00758aef78..0000000000 --- a/thirdparty/3dxware_sdk/inc/SpaceMouse/SpaceMouse.sln +++ /dev/null @@ -1,15 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2042 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Navigation3D", "Navigation3D.vcxitems", "{5DF960DB-B916-4732-A13D-228F20A806FE}" -EndProject -Global - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7CEA499A-2163-4040-AFCB-8897C44712C3} - EndGlobalSection -EndGlobal