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.

141 lines
4.3 KiB

4 years ago
4 years ago
4 years ago
4 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018-2021 KiCad Developers, see change_log.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #ifndef PANEL_SETUP_LAYERS_H
  24. #define PANEL_SETUP_LAYERS_H
  25. #include <widgets/unit_binder.h>
  26. #include <widgets/paged_dialog.h>
  27. #include <panel_setup_layers_base.h>
  28. class PCB_EDIT_FRAME;
  29. class BOARD;
  30. class BOARD_DESIGN_SETTINGS;
  31. class PANEL_SETUP_BOARD_STACKUP;
  32. /**
  33. * The 3 UI control pointers for a single board layer.
  34. */
  35. struct PANEL_SETUP_LAYERS_CTLs
  36. {
  37. PANEL_SETUP_LAYERS_CTLs( wxControl* aName, wxCheckBox* aCheckBox, wxControl* aChoiceOrDesc )
  38. {
  39. name = aName;
  40. checkbox = aCheckBox;
  41. choice = aChoiceOrDesc;
  42. }
  43. wxControl* name;
  44. wxCheckBox* checkbox;
  45. wxControl* choice;
  46. };
  47. class PANEL_SETUP_LAYERS : public PANEL_SETUP_LAYERS_BASE
  48. {
  49. public:
  50. PANEL_SETUP_LAYERS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame );
  51. void ImportSettingsFrom( BOARD* aBoard );
  52. /**
  53. * Check and warn if inner copper layers will be deleted
  54. *
  55. * This function warns users if they are going to delete inner copper layers because
  56. * they're importing settings from a board with less copper layers than the board
  57. * already loaded.
  58. *
  59. * @param aWorkingBoard is the currently loaded PCB
  60. * @param aImportedBoard is the PCB imported to get settings from.
  61. * @return Approval to delete inner copper if needed.
  62. */
  63. bool CheckCopperLayerCount( BOARD* aWorkingBoard, BOARD* aImportedBoard );
  64. ///< @return the selected layer mask within the UI checkboxes
  65. LSET GetUILayerMask();
  66. ///< @return the layer name within the UI wxTextCtrl
  67. wxString GetLayerName( int layer );
  68. /**
  69. * Called when switching to this tab to make sure that any changes to the copper layer count
  70. * made on the physical stackup page are reflected here
  71. * @param aNumCopperLayers is the number of copper layers in the board
  72. */
  73. void SyncCopperLayers( int aNumCopperLayers );
  74. void SetPhysicalStackupPanel( PANEL_SETUP_BOARD_STACKUP* aPanel )
  75. {
  76. m_physicalStackup = aPanel;
  77. }
  78. private:
  79. void setLayerCheckBox( int layer, bool isChecked );
  80. void setCopperLayerCheckBoxes( int copperCount );
  81. void setMandatoryLayerCheckBoxes();
  82. void setUserDefinedLayerCheckBoxes();
  83. void showBoardLayerNames();
  84. void showSelectedLayerCheckBoxes( LSET enableLayerMask );
  85. void showLayerTypes();
  86. int getLayerTypeIndex( int layer );
  87. void OnCheckBox( wxCommandEvent& event ) override;
  88. void DenyChangeCheckBox( wxCommandEvent& event ) override;
  89. bool TransferDataToWindow() override;
  90. bool TransferDataFromWindow() override;
  91. virtual void addUserDefinedLayer( wxCommandEvent& aEvent ) override;
  92. bool testLayerNames();
  93. /**
  94. * Return a list of layers removed from the board that contain items.
  95. */
  96. LSEQ getRemovedLayersWithItems();
  97. /**
  98. * Return a list of layers in use in footprints, and therefore not removable.
  99. */
  100. LSEQ getNonRemovableLayers();
  101. PANEL_SETUP_LAYERS_CTLs getCTLs( int aLayerNumber );
  102. wxControl* getName( int aLayer );
  103. wxCheckBox* getCheckBox( int aLayer );
  104. wxChoice* getChoice( int aLayer );
  105. PAGED_DIALOG* m_parentDialog;
  106. PCB_EDIT_FRAME* m_frame;
  107. PANEL_SETUP_BOARD_STACKUP* m_physicalStackup;
  108. BOARD* m_pcb;
  109. LSET m_enabledLayers;
  110. };
  111. #endif //PANEL_SETUP_LAYERS_H