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.

109 lines
3.7 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #include <widgets/paged_dialog.h>
  25. #include <pcb_edit_frame.h>
  26. #include <board_design_settings.h>
  27. #include <board_stackup_manager/stackup_predefined_prms.h>
  28. #include "panel_board_finish.h"
  29. #include <wx/treebook.h>
  30. PANEL_SETUP_BOARD_FINISH::PANEL_SETUP_BOARD_FINISH( PAGED_DIALOG* aParent, BOARD* aBoard ) :
  31. PANEL_SETUP_BOARD_FINISH_BASE( aParent->GetTreebook() )
  32. {
  33. m_parentDialog = aParent;
  34. m_board = aBoard;
  35. m_brdSettings = &m_board->GetDesignSettings();
  36. // Get the translated list of choices and init m_choiceFinish
  37. wxArrayString finish_list = GetStandardCopperFinishes( true );
  38. m_choiceFinish->Append( finish_list );
  39. m_choiceFinish->SetSelection( 0 ); // Will be correctly set later
  40. synchronizeWithBoard();
  41. }
  42. PANEL_SETUP_BOARD_FINISH::~PANEL_SETUP_BOARD_FINISH()
  43. {
  44. }
  45. void PANEL_SETUP_BOARD_FINISH::synchronizeWithBoard()
  46. {
  47. const BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
  48. m_choiceEdgeConn->SetSelection( brd_stackup.m_EdgeConnectorConstraints );
  49. m_cbCastellatedPads->SetValue( brd_stackup.m_CastellatedPads );
  50. m_cbEgdesPlated->SetValue( brd_stackup.m_EdgePlating );
  51. // find the choice depending on the initial finish setting
  52. wxArrayString initial_finish_list = GetStandardCopperFinishes( false );
  53. unsigned idx;
  54. for( idx = 0; idx < initial_finish_list.GetCount(); idx++ )
  55. {
  56. if( initial_finish_list[idx] == brd_stackup.m_FinishType )
  57. break;
  58. }
  59. // Now init the choice (use last choice: "User defined" if not found )
  60. if( idx >= initial_finish_list.GetCount() )
  61. idx = initial_finish_list.GetCount()-1;
  62. m_choiceFinish->SetSelection( idx );
  63. }
  64. bool PANEL_SETUP_BOARD_FINISH::TransferDataFromWindow()
  65. {
  66. BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
  67. wxArrayString finish_list = GetStandardCopperFinishes( false );
  68. int finish = m_choiceFinish->GetSelection() >= 0 ? m_choiceFinish->GetSelection() : 0;
  69. brd_stackup.m_FinishType = finish_list[finish];
  70. int edge = m_choiceEdgeConn->GetSelection();;
  71. brd_stackup.m_EdgeConnectorConstraints = (BS_EDGE_CONNECTOR_CONSTRAINTS) edge;
  72. brd_stackup.m_CastellatedPads = m_cbCastellatedPads->GetValue();
  73. brd_stackup.m_EdgePlating = m_cbEgdesPlated->GetValue();
  74. return true;
  75. }
  76. void PANEL_SETUP_BOARD_FINISH::ImportSettingsFrom( BOARD* aBoard )
  77. {
  78. BOARD* savedBrd = m_board;
  79. BOARD_DESIGN_SETTINGS* savedSettings = m_brdSettings;
  80. m_brdSettings = &aBoard->GetDesignSettings();
  81. synchronizeWithBoard();
  82. m_brdSettings = savedSettings;
  83. m_board = savedBrd;
  84. }