You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
4.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2021 3Dconnexion
  5. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software: you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation, either version 3 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * @file nl_pcbnew_plugin_impl.h
  22. * @brief Declaration of the NL_PCBNEW_PLUGIN_IMPL class
  23. */
  24. #ifndef NL_PCBNEW_PLUGIN_IMPL_H_
  25. #define NL_PCBNEW_PLUGIN_IMPL_H_
  26. #if _WIN32
  27. #ifndef _WIN32_WINNT
  28. #define _WIN32_WINNT 0x0603
  29. #endif
  30. #endif
  31. // TDxWare SDK.
  32. #include <SpaceMouse/CNavigation3D.hpp>
  33. // wx
  34. #include <wx/chartype.h>
  35. // KiCAD
  36. #include <math/vector2d.h>
  37. // stdlib
  38. #include <string>
  39. // Forward declarations.
  40. class PCB_DRAW_PANEL_GAL;
  41. namespace KIGFX
  42. {
  43. class PCB_VIEW;
  44. }
  45. // Convenience typedef.
  46. typedef TDx::SpaceMouse::Navigation3D::CNavigation3D NAV_3D;
  47. /**
  48. * The class that implements the accessors and mutators required for
  49. * 3D navigation in an PCB_DRAW_PANEL_GAL using a SpaceMouse.
  50. */
  51. class NL_PCBNEW_PLUGIN_IMPL : public NAV_3D
  52. {
  53. public:
  54. /**
  55. * Initializes a new instance of the NL_PCBNEW_PLUGIN_IMPL.
  56. *
  57. * @param aViewport is the viewport to be navigated.
  58. */
  59. NL_PCBNEW_PLUGIN_IMPL( PCB_DRAW_PANEL_GAL* aViewport );
  60. virtual ~NL_PCBNEW_PLUGIN_IMPL();
  61. /**
  62. * Set the connection to the 3Dconnexion driver to the focus state so that
  63. * 3DMouse data is routed here.
  64. *
  65. * @param aFocus is true to set the connection active.
  66. */
  67. void SetFocus( bool aFocus );
  68. private:
  69. /**
  70. * Export the invocable actions and images to the 3Dconnexion UI.
  71. */
  72. void exportCommandsAndImages();
  73. long GetCameraMatrix( navlib::matrix_t& aMatrix ) const override;
  74. long GetPointerPosition( navlib::point_t& aPosition ) const override;
  75. long GetViewExtents( navlib::box_t& aExtents ) const override;
  76. long GetViewFOV( double& aFov ) const override;
  77. long GetViewFrustum( navlib::frustum_t& aFrustum ) const override;
  78. long GetIsViewPerspective( navlib::bool_t& aPerspective ) const override;
  79. long SetCameraMatrix( const navlib::matrix_t& aMatrix ) override;
  80. long SetViewExtents( const navlib::box_t& aExtents ) override;
  81. long SetViewFOV( double aFov ) override;
  82. long SetViewFrustum( const navlib::frustum_t& aFrustum ) override;
  83. long GetModelExtents( navlib::box_t& aExtents ) const override;
  84. long GetSelectionExtents( navlib::box_t& aExtents ) const override;
  85. long GetSelectionTransform( navlib::matrix_t& aTransform ) const override;
  86. long GetIsSelectionEmpty( navlib::bool_t& aEmpty ) const override;
  87. long SetSelectionTransform( const navlib::matrix_t& aMatrix ) override;
  88. long GetPivotPosition( navlib::point_t& aPosition ) const override;
  89. long IsUserPivot( navlib::bool_t& aUserPivot ) const override;
  90. long SetPivotPosition( const navlib::point_t& aPosition ) override;
  91. long GetPivotVisible( navlib::bool_t& aVisible ) const override;
  92. long SetPivotVisible( bool aVisible ) override;
  93. long GetHitLookAt( navlib::point_t& aPosition ) const override;
  94. long SetHitAperture( double aAperture ) override;
  95. long SetHitDirection( const navlib::vector_t& aDirection ) override;
  96. long SetHitLookFrom( const navlib::point_t& aPosition ) override;
  97. long SetHitSelectionOnly( bool aSelectionOnly ) override;
  98. long SetActiveCommand( std::string aCommandId ) override;
  99. long SetSettingsChanged( long aChangeNumber ) override;
  100. long SetMotionFlag( bool aValue ) override;
  101. long SetTransaction( long aValue ) override;
  102. long SetCameraTarget( const navlib::point_t& aPosition ) override;
  103. long GetFrontView( navlib::matrix_t& aMatrix ) const override;
  104. long GetCoordinateSystem( navlib::matrix_t& aMatrix ) const override;
  105. long GetIsViewRotatable( navlib::bool_t& isRotatable ) const override;
  106. private:
  107. PCB_DRAW_PANEL_GAL* m_viewport2D;
  108. KIGFX::PCB_VIEW* m_view;
  109. bool m_isMoving;
  110. mutable double m_viewportWidth;
  111. mutable VECTOR2D m_viewPosition;
  112. /**
  113. * Trace mask used to enable or disable the trace output of this class.
  114. * The debug output can be turned on by setting the WXTRACE environment variable to
  115. * "KI_TRACE_NL_PCBNEW_PLUGIN". See the wxWidgets documentation on wxLogTrace for
  116. * more information.
  117. */
  118. static const wxChar* m_logTrace;
  119. };
  120. #endif // NL_PCBNEW_PLUGIN_IMPL_H_