KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_board_finish.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 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <pcb_edit_frame.h>
23#include <netclass.h>
28#include "panel_board_finish.h"
29
30
48
49
51 PANEL_SETUP_BOARD_FINISH_BASE( aParentWindow )
52{
53 m_frame = aFrame;
54 m_board = m_frame->GetBoard();
55 m_brdSettings = &m_board->GetDesignSettings();
56 m_stackup = m_board->GetStackupOrDefault();
57 m_copperLayerCount = m_board->GetCopperLayerCount();
58
59 // Get the translated list of choices and init m_choiceFinish
60 wxArrayString finish_list = GetStandardCopperFinishes( true );
61 m_choiceFinish->Append( finish_list );
62 m_choiceFinish->SetSelection( 0 ); // Will be correctly set later
63
64 for( const VIA_PROTECTION_CONTROL& control : viaProtectionControls() )
65 ( this->*control.m_CheckBox )->Bind( wxEVT_CHECKBOX, &PANEL_SETUP_BOARD_FINISH::onViaProtectionChanged, this );
66
68}
69
70
74
75
77{
78 const BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
79
80 m_choiceEdgeConn->SetSelection( brd_stackup.m_EdgeConnectorConstraints );
81 m_cbEgdesPlated->SetValue( brd_stackup.m_EdgePlating );
82
83 // find the choice depending on the initial finish setting
84 wxArrayString initial_finish_list = GetStandardCopperFinishes( false );
85 unsigned idx;
86
87 for( idx = 0; idx < initial_finish_list.GetCount(); idx++ )
88 {
89 if( initial_finish_list[idx] == brd_stackup.m_FinishType )
90 break;
91 }
92
93 // Now init the choice (use last choice: "User defined" if not found )
94 if( idx >= initial_finish_list.GetCount() )
95 idx = initial_finish_list.GetCount()-1;
96
97 m_choiceFinish->SetSelection( idx );
98
99 for( const VIA_PROTECTION_CONTROL& control : viaProtectionControls() )
100 ( this->*control.m_CheckBox )->SetValue( m_brdSettings->*control.m_Setting );
101
104}
105
106
108{
109 const bool filled = m_fillVias->GetValue();
110
111 m_capVias->Enable( VIA_PROTECTION_RULES::CapAllowed( filled ) );
114 m_coverViasFront->Enable(
115 VIA_PROTECTION_RULES::CoverAllowed( filled, m_tentViasFront->GetValue(), m_plugViasFront->GetValue() ) );
116 m_coverViasBack->Enable(
117 VIA_PROTECTION_RULES::CoverAllowed( filled, m_tentViasBack->GetValue(), m_plugViasBack->GetValue() ) );
118}
119
120
122{
124
125 state.m_InnerLayers = std::max( 0, m_copperLayerCount - 2 );
127
128 const std::shared_ptr<NETCLASS>& netclass = m_brdSettings->m_NetSettings->GetDefaultNetclass();
129
130 if( netclass->GetViaDrill() > 0 )
131 state.m_PadRatio = (double) netclass->GetViaDiameter() / netclass->GetViaDrill();
132
133 for( const VIA_PROTECTION_CONTROL& control : viaProtectionControls() )
134 state.*control.m_State = ( this->*control.m_CheckBox )->GetValue();
135
136 m_viaPreview->SetState( state );
137}
138
139
141{
143
144 // A choice the user has just ruled out is cleared. A stored one is only greyed.
145 bool cleared = false;
146
147 for( const VIA_PROTECTION_CONTROL& control : viaProtectionControls() )
148 {
149 wxCheckBox* checkBox = this->*control.m_CheckBox;
150
151 if( !checkBox->IsEnabled() && checkBox->GetValue() )
152 {
153 checkBox->SetValue( false );
154 cleared = true;
155 }
156 }
157
158 if( cleared )
160
162}
163
164
165void PANEL_SETUP_BOARD_FINISH::SetStackup( const BOARD_STACKUP& aStackup, int aCopperLayerCount )
166{
167 m_stackup = aStackup;
168 m_copperLayerCount = aCopperLayerCount;
170}
171
172
174{
175 BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
176
177 bool modified = TransferDataFromWindow( brd_stackup );
178
179 for( const VIA_PROTECTION_CONTROL& control : viaProtectionControls() )
180 {
181 bool& setting = m_brdSettings->*control.m_Setting;
182 const bool value = ( this->*control.m_CheckBox )->GetValue();
183
184 modified |= setting != value;
185 setting = value;
186 }
187
188 if( modified )
189 {
190 m_board->BumpDrillModelGeneration();
191 m_frame->OnModify();
192 }
193
194 return true;
195}
196
197
199{
200 wxArrayString finish_list = GetStandardCopperFinishes( false );
201 int finish = m_choiceFinish->GetSelection() >= 0 ? m_choiceFinish->GetSelection() : 0;
202 bool modified = aStackup.m_FinishType != finish_list[finish];
203 aStackup.m_FinishType = finish_list[finish];
204
205 int edge = m_choiceEdgeConn->GetSelection();
206 modified |= aStackup.m_EdgeConnectorConstraints != (BS_EDGE_CONNECTOR_CONSTRAINTS) edge;
208
209 modified |= aStackup.m_EdgePlating != m_cbEgdesPlated->GetValue();
210 aStackup.m_EdgePlating = m_cbEgdesPlated->GetValue();
211
212 return modified;
213}
214
215
217{
218 BOARD* savedBrd = m_board;
219 BOARD_DESIGN_SETTINGS* savedSettings = m_brdSettings;
220 m_brdSettings = &aBoard->GetDesignSettings();
221
223
224 m_brdSettings = savedSettings;
225 m_board = savedBrd;
226
228}
BS_EDGE_CONNECTOR_CONSTRAINTS
Container for design settings for a BOARD object.
Manage layers needed to make a physical board.
bool m_EdgePlating
True if the edge board is plated.
BS_EDGE_CONNECTOR_CONSTRAINTS m_EdgeConnectorConstraints
If the board has edge connector cards, some constrains can be specified in job file: BS_EDGE_CONNECTO...
wxString m_FinishType
The name of external copper finish.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
BOARD_DESIGN_SETTINGS & GetDesignSettings()
Definition board.cpp:1318
PANEL_SETUP_BOARD_FINISH_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
VIA_CROSS_SECTION_PREVIEW * m_viaPreview
void onViaProtectionChanged(wxCommandEvent &aEvent)
void enableViaProtection()
Grey out the features that cannot be built with the ones selected.
BOARD_DESIGN_SETTINGS * m_brdSettings
void ImportSettingsFrom(BOARD *aBoard)
static const std::vector< VIA_PROTECTION_CONTROL > & viaProtectionControls()
PANEL_SETUP_BOARD_FINISH(wxWindow *aParentWindow, PCB_EDIT_FRAME *aFrame)
void SetStackup(const BOARD_STACKUP &aStackup, int aCopperLayerCount)
The main frame for Pcbnew.
static int SetLayersFromStackup(STATE &aState, const BOARD_STACKUP &aStackup, int aCopperLayerCount)
Fill the layer depths and thicknesses from a stackup, or leave them empty when it does not match the ...
VIA_CROSS_SECTION_GEOMETRY::STATE STATE
bool PlugAllowed(bool aFilled)
A plug is a partial fill from one side. A filled hole has nothing left to plug.
bool CoverAllowed(bool aFilled, bool aTented, bool aPlugged)
A cover is a second coat over a tent, a plug or a fill.
bool CapAllowed(bool aFilled)
A cap is copper plated over a filled hole, so it needs the fill.
wxArrayString GetStandardCopperFinishes(bool aTranslate)
A via protection checkbox, the board setting it edits and the preview flag it drives.
double m_PadRatio
Pad diameter over hole diameter.
VIA_CROSS_SECTION_GEOMETRY::STATE STATE