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.

142 lines
4.8 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2014 CERN
  5. * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * @author Maciej Suminski <maciej.suminski@cern.ch>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. #ifndef BOARD_EDITOR_CONTROL_H
  27. #define BOARD_EDITOR_CONTROL_H
  28. #include <tools/pcb_tool_base.h>
  29. #include <tool/tool_menu.h>
  30. namespace KIGFX {
  31. class ORIGIN_VIEWITEM;
  32. }
  33. class PCB_EDIT_FRAME;
  34. /**
  35. * Handle actions specific to the board editor in PcbNew.
  36. */
  37. class BOARD_EDITOR_CONTROL : public PCB_TOOL_BASE
  38. {
  39. public:
  40. BOARD_EDITOR_CONTROL();
  41. ~BOARD_EDITOR_CONTROL();
  42. /// @copydoc TOOL_INTERACTIVE::Reset()
  43. void Reset( RESET_REASON aReason ) override;
  44. /// @copydoc TOOL_INTERACTIVE::Init()
  45. bool Init() override;
  46. int New( const TOOL_EVENT& aEvent );
  47. int Open( const TOOL_EVENT& aEvent );
  48. int Save( const TOOL_EVENT& aEvent );
  49. int SaveAs( const TOOL_EVENT& aEvent );
  50. int SaveCopy( const TOOL_EVENT& aEvent );
  51. int Revert( const TOOL_EVENT& aEvent );
  52. int PageSettings( const TOOL_EVENT& aEvent );
  53. int Plot( const TOOL_EVENT& aEvent );
  54. int Find( const TOOL_EVENT& aEvent );
  55. int FindNext( const TOOL_EVENT& aEvent );
  56. int BoardSetup( const TOOL_EVENT& aEvent );
  57. int ImportNetlist( const TOOL_EVENT& aEvent );
  58. int ImportSpecctraSession( const TOOL_EVENT& aEvent );
  59. int ExportSpecctraDSN( const TOOL_EVENT& aEvent );
  60. int ExportNetlist( const TOOL_EVENT& aEvent );
  61. int GenerateDrillFiles( const TOOL_EVENT& aEvent );
  62. int GeneratePosFile( const TOOL_EVENT& aEvent );
  63. int GenerateFabFiles( const TOOL_EVENT& aEvent );
  64. int RepairBoard( const TOOL_EVENT& aEvent );
  65. int UpdatePCBFromSchematic( const TOOL_EVENT& aEvent );
  66. int UpdateSchematicFromPCB( const TOOL_EVENT& aEvent );
  67. int ShowEeschema( const TOOL_EVENT& aEvent );
  68. int ToggleLayersManager( const TOOL_EVENT& aEvent );
  69. int TogglePythonConsole( const TOOL_EVENT& aEvent );
  70. // Track & via size control
  71. int TrackWidthInc( const TOOL_EVENT& aEvent );
  72. int TrackWidthDec( const TOOL_EVENT& aEvent );
  73. int ViaSizeInc( const TOOL_EVENT& aEvent );
  74. int ViaSizeDec( const TOOL_EVENT& aEvent );
  75. // Zone actions
  76. int ZoneMerge( const TOOL_EVENT& aEvent );
  77. ///< Duplicate a zone onto a layer (prompts for new layer)
  78. int ZoneDuplicate( const TOOL_EVENT& aEvent );
  79. int EditFpInFpEditor( const TOOL_EVENT& aEvent );
  80. /**
  81. * Display a dialog to select a footprint to be added and allows the user to set its position.
  82. */
  83. int PlaceFootprint( const TOOL_EVENT& aEvent );
  84. /**
  85. * Re-entrancy checker for above.
  86. */
  87. bool PlacingFootprint() const { return m_placingFootprint; }
  88. ///< Toggle 'lock' property for selected items.
  89. int ToggleLockSelected( const TOOL_EVENT& aEvent );
  90. ///< Lock selected items.
  91. int LockSelected( const TOOL_EVENT& aEvent );
  92. ///< Unlock selected items.
  93. int UnlockSelected( const TOOL_EVENT& aEvent );
  94. ///< Run the drill origin tool for setting the origin for drill and pick-and-place files.
  95. int DrillOrigin( const TOOL_EVENT& aEvent );
  96. ///< Low-level access (below undo) to setting the drill origin.
  97. static void DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
  98. EDA_ITEM* aItem, const VECTOR2D& aPoint );
  99. private:
  100. ///< How to modify a property for selected items.
  101. enum MODIFY_MODE { ON, OFF, TOGGLE };
  102. int modifyLockSelected( MODIFY_MODE aMode );
  103. ///< Set up handlers for various events.
  104. void setTransitions() override;
  105. private:
  106. PCB_EDIT_FRAME* m_frame;
  107. bool m_inPlaceFootprint; // Re-entrancy guard for tool.
  108. bool m_placingFootprint; // Re-entrancy guard for placement loop.
  109. bool m_inPlaceTarget; // Re-entrancy guard.
  110. std::unique_ptr<KIGFX::ORIGIN_VIEWITEM> m_placeOrigin;
  111. static const int WIDTH_STEP; ///< How does line width change after one -/+ key press.
  112. };
  113. #endif