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 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 <fctsys.h>
26 #include <pcbnew.h>
27 #include <pcb_edit_frame.h>
28 #include <board_design_settings.h>
29 #include <dialog_text_entry.h>
31 
32 
34  PCB_EDIT_FRAME* aFrame ) :
35  PANEL_SETUP_MASK_AND_PASTE_BASE( aParent->GetTreebook() ),
36  m_maskMargin( aFrame, m_MaskMarginLabel, m_MaskMarginCtrl, m_MaskMarginUnits, true ),
37  m_maskMinWidth( aFrame, m_MaskMinWidthLabel, m_MaskMinWidthCtrl, m_MaskMinWidthUnits, true ),
38  m_pasteMargin( aFrame, m_PasteMarginLabel, m_PasteMarginCtrl, m_PasteMarginUnits, true )
39 {
40  m_Frame = aFrame;
42 
43  wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
44  infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
45  m_staticTextInfoCopper->SetFont( infoFont );
46  m_staticTextInfoPaste->SetFont( infoFont );
47 
48  infoFont.SetStyle( wxFONTSTYLE_ITALIC );
49  m_staticTextInfoValPos->SetFont( infoFont );
50  m_staticTextInfoValNeg->SetFont( infoFont );
51 }
52 
53 
55 {
59 
60  // Prefer "-0" to "0" for normally negative values
62  m_PasteMarginCtrl->SetValue( wxT( "-" ) + m_PasteMarginCtrl->GetValue() );
63 
64  // Add solder paste margin ratio in percent
65  // for the usual default value 0.0, display -0.0 (or -0,0 in some countries)
66  wxString msg;
67  msg.Printf( wxT( "%f" ), m_BrdSettings->m_SolderPasteMarginRatio * 100.0 );
68 
69  // Sometimes Printf adds a sign if the value is small
70  if( m_BrdSettings->m_SolderPasteMarginRatio == 0.0 && msg[0] == '0' )
71  m_SolderPasteMarginRatioCtrl->SetValue( wxT( "-" ) + msg );
72  else
73  m_SolderPasteMarginRatioCtrl->SetValue( msg );
74 
75  return true;
76 }
77 
78 
80 {
83 
85 
86  double dtmp = 0.0;
87  wxString msg = m_SolderPasteMarginRatioCtrl->GetValue();
88  msg.ToDouble( &dtmp );
89 
90  // A margin ratio de -50% means no paste on a pad, the ratio must be >= 50 %
91  if( dtmp < -50 )
92  dtmp = -50;
93 
94  if( dtmp > +100 )
95  dtmp = +100;
96 
98 
99  return true;
100 }
101 
102 
104 {
105  BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
106 
107  m_BrdSettings = &aBoard->GetDesignSettings();
109 
110  m_BrdSettings = savedSettings;
111 }
int m_SolderMaskMargin
Solder mask margin.
PANEL_SETUP_MASK_AND_PASTE(PAGED_DIALOG *aParent, PCB_EDIT_FRAME *aFrame)
int m_SolderPasteMargin
Solder paste margin absolute value.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:531
BOARD_DESIGN_SETTINGS * m_BrdSettings
Class PANEL_SETUP_MASK_AND_PASTE_BASE.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:161
virtual void SetValue(int aValue)
Function SetValue Sets new value (in Internal Units) for the text field, taking care of units convers...
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
virtual long long int GetValue()
Function GetValue Returns the current value in Internal Units.
BOARD * GetBoard() const
double m_SolderPasteMarginRatio
Solder pask margin ratio value of pad size The final margin is the sum of these 2 values.
int m_SolderMaskMinWidth
Solder mask min width.
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.