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) 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 
24 
25 #include <fctsys.h>
26 #include <class_drawpanel.h>
27 #include <pcbnew.h>
28 #include <pcb_edit_frame.h>
29 #include <board_design_settings.h>
30 #include <dialog_text_entry.h>
31 
33 
34 
36  PCB_EDIT_FRAME* aFrame ) :
37  PANEL_SETUP_MASK_AND_PASTE_BASE( aParent->GetTreebook() ),
38  m_maskMargin( aFrame, m_MaskMarginLabel, m_MaskMarginCtrl, m_MaskMarginUnits, true ),
39  m_maskMinWidth( aFrame, m_MaskMinWidthLabel, m_MaskMinWidthCtrl, m_MaskMinWidthUnits, true ),
40  m_pasteMargin( aFrame, m_PasteMarginLabel, m_PasteMarginCtrl, m_PasteMarginUnits, true )
41 {
42  m_Frame = aFrame;
44 
45  wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
46  infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
47  m_staticTextInfoValPos->SetFont( infoFont );
48  m_staticTextInfoValNeg->SetFont( infoFont );
49  m_staticTextInfoCopper->SetFont( infoFont );
50 }
51 
52 
54 {
58 
59  // Prefer "-0" to "0" for normally negative values
61  m_PasteMarginCtrl->SetValue( wxT( "-" ) + m_PasteMarginCtrl->GetValue() );
62 
63  // Add solder paste margin ratio in per cent
64  // for the usual default value 0.0, display -0.0 (or -0,0 in some countries)
65  wxString msg;
66  msg.Printf( wxT( "%f" ), m_BrdSettings->m_SolderPasteMarginRatio * 100.0 );
67 
68  // Sometimes Printf adds a sign if the value is small
69  if( m_BrdSettings->m_SolderPasteMarginRatio == 0.0 && msg[0] == '0' )
70  m_SolderPasteMarginRatioCtrl->SetValue( wxT( "-" ) + msg );
71  else
72  m_SolderPasteMarginRatioCtrl->SetValue( msg );
73 
74  return true;
75 }
76 
77 
79 {
82 
84 
85  double dtmp = 0.0;
86  wxString msg = m_SolderPasteMarginRatioCtrl->GetValue();
87  msg.ToDouble( &dtmp );
88 
89  // A margin ratio de -50% means no paste on a pad, the ratio must be >= 50 %
90  if( dtmp < -50 )
91  dtmp = -50;
92 
93  if( dtmp > +100 )
94  dtmp = +100;
95 
97 
98  return true;
99 }
100 
101 
103 {
104  BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
105 
106  m_BrdSettings = &aBoard->GetDesignSettings();
108 
109  m_BrdSettings = savedSettings;
110 }
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 * GetBoard() const
virtual int GetValue()
Function GetValue Returns the current value in Internal Units.
BOARD_DESIGN_SETTINGS * m_BrdSettings
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
Class PANEL_SETUP_MASK_AND_PASTE_BASE.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
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.
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.