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.

110 lines
3.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018 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. #include <fctsys.h>
  24. #include <class_drawpanel.h>
  25. #include <pcbnew.h>
  26. #include <pcb_edit_frame.h>
  27. #include <board_design_settings.h>
  28. #include <dialog_text_entry.h>
  29. #include <panel_setup_mask_and_paste.h>
  30. PANEL_SETUP_MASK_AND_PASTE::PANEL_SETUP_MASK_AND_PASTE( PAGED_DIALOG* aParent,
  31. PCB_EDIT_FRAME* aFrame ) :
  32. PANEL_SETUP_MASK_AND_PASTE_BASE( aParent->GetTreebook() ),
  33. m_maskMargin( aFrame, m_MaskMarginLabel, m_MaskMarginCtrl, m_MaskMarginUnits, true ),
  34. m_maskMinWidth( aFrame, m_MaskMinWidthLabel, m_MaskMinWidthCtrl, m_MaskMinWidthUnits, true ),
  35. m_pasteMargin( aFrame, m_PasteMarginLabel, m_PasteMarginCtrl, m_PasteMarginUnits, true )
  36. {
  37. m_Frame = aFrame;
  38. m_BrdSettings = &m_Frame->GetBoard()->GetDesignSettings();
  39. wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
  40. infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
  41. m_staticTextInfoValPos->SetFont( infoFont );
  42. m_staticTextInfoValNeg->SetFont( infoFont );
  43. m_staticTextInfoCopper->SetFont( infoFont );
  44. }
  45. bool PANEL_SETUP_MASK_AND_PASTE::TransferDataToWindow()
  46. {
  47. m_maskMargin.SetValue( m_BrdSettings->m_SolderMaskMargin );
  48. m_maskMinWidth.SetValue( m_BrdSettings->m_SolderMaskMinWidth );
  49. m_pasteMargin.SetValue( m_BrdSettings->m_SolderPasteMargin );
  50. // Prefer "-0" to "0" for normally negative values
  51. if( m_BrdSettings->m_SolderPasteMargin == 0 )
  52. m_PasteMarginCtrl->SetValue( wxT( "-" ) + m_PasteMarginCtrl->GetValue() );
  53. // Add solder paste margin ratio in per cent
  54. // for the usual default value 0.0, display -0.0 (or -0,0 in some countries)
  55. wxString msg;
  56. msg.Printf( wxT( "%f" ), m_BrdSettings->m_SolderPasteMarginRatio * 100.0 );
  57. // Sometimes Printf adds a sign if the value is small
  58. if( m_BrdSettings->m_SolderPasteMarginRatio == 0.0 && msg[0] == '0' )
  59. m_SolderPasteMarginRatioCtrl->SetValue( wxT( "-" ) + msg );
  60. else
  61. m_SolderPasteMarginRatioCtrl->SetValue( msg );
  62. return true;
  63. }
  64. bool PANEL_SETUP_MASK_AND_PASTE::TransferDataFromWindow()
  65. {
  66. m_BrdSettings->m_SolderMaskMargin = m_maskMargin.GetValue();
  67. m_BrdSettings->m_SolderMaskMinWidth = m_maskMinWidth.GetValue();
  68. m_BrdSettings->m_SolderPasteMargin = m_pasteMargin.GetValue();
  69. double dtmp = 0.0;
  70. wxString msg = m_SolderPasteMarginRatioCtrl->GetValue();
  71. msg.ToDouble( &dtmp );
  72. // A margin ratio de -50% means no paste on a pad, the ratio must be >= 50 %
  73. if( dtmp < -50 )
  74. dtmp = -50;
  75. if( dtmp > +100 )
  76. dtmp = +100;
  77. m_BrdSettings->m_SolderPasteMarginRatio = dtmp / 100;
  78. return true;
  79. }
  80. void PANEL_SETUP_MASK_AND_PASTE::ImportSettingsFrom( BOARD* aBoard )
  81. {
  82. BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
  83. m_BrdSettings = &aBoard->GetDesignSettings();
  84. TransferDataToWindow();
  85. m_BrdSettings = savedSettings;
  86. }