KiCad PCB EDA Suite
panel_setup_mask_and_paste.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.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 
24 
25 #include <pcb_edit_frame.h>
26 #include <board_design_settings.h>
29 
30 
32  PCB_EDIT_FRAME* aFrame ) :
33  PANEL_SETUP_MASK_AND_PASTE_BASE( aParent->GetTreebook() ),
34  m_maskMargin( aFrame, m_MaskMarginLabel, m_MaskMarginCtrl, m_MaskMarginUnits, true ),
35  m_maskMinWidth( aFrame, m_MaskMinWidthLabel, m_MaskMinWidthCtrl, m_MaskMinWidthUnits,
36  true ),
37  m_pasteMargin( aFrame, m_PasteMarginLabel, m_PasteMarginCtrl, m_PasteMarginUnits, true )
38 {
39  m_Frame = aFrame;
41 }
42 
43 
45 {
49 
50  // Prefer "-0" to "0" for normally negative values
52  m_PasteMarginCtrl->SetValue( wxT( "-" ) + m_PasteMarginCtrl->GetValue() );
53 
54  // Add solder paste margin ratio in percent
55  // for the usual default value 0.0, display -0.0 (or -0,0 in some countries)
56  wxString msg;
57  msg.Printf( wxT( "%f" ), m_BrdSettings->m_SolderPasteMarginRatio * 100.0 );
58 
59  // Sometimes Printf adds a sign if the value is small
60  if( m_BrdSettings->m_SolderPasteMarginRatio == 0.0 && msg[0] == '0' )
61  m_SolderPasteMarginRatioCtrl->SetValue( wxT( "-" ) + msg );
62  else
63  m_SolderPasteMarginRatioCtrl->SetValue( msg );
64 
65  return true;
66 }
67 
68 
70 {
71  // These are all stored in project file, not board, so no need for OnModify()
74 
76 
77  double dtmp = 0.0;
78  wxString msg = m_SolderPasteMarginRatioCtrl->GetValue();
79  msg.ToDouble( &dtmp );
80 
81  // A margin ratio de -50% means no paste on a pad, the ratio must be >= 50 %
82  if( dtmp < -50 )
83  dtmp = -50;
84 
85  if( dtmp > +100 )
86  dtmp = +100;
87 
89 
90  return true;
91 }
92 
93 
95 {
96  BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
97 
98  m_BrdSettings = &aBoard->GetDesignSettings();
100 
101  m_BrdSettings = savedSettings;
102 }
PANEL_SETUP_MASK_AND_PASTE(PAGED_DIALOG *aParent, PCB_EDIT_FRAME *aFrame)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:591
BOARD_DESIGN_SETTINGS * m_BrdSettings
Class PANEL_SETUP_MASK_AND_PASTE_BASE.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
virtual void SetValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
The main frame for Pcbnew.
virtual long long int GetValue()
Return the current value in Internal Units.
BOARD * GetBoard() const
Container for design settings for a BOARD object.