KiCad PCB EDA Suite
panel_board_stackup.h
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 (C) 2009-2022 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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef PANEL_SETUP_BOARD_STACKUP_H
26#define PANEL_SETUP_BOARD_STACKUP_H
27
28
29#include <board.h>
30#include <widgets/unit_binder.h>
31#include <wx/gdicmn.h>
32
34#include "board_stackup.h"
36#include "dielectric_material.h"
37
38class wxBitmapComboBox;
40
41
42// A helper class to handle UI items managed by m_fgGridSizer
43// in PANEL_SETUP_BOARD_STACKUP
44// these items are shown or not in m_fgGridSizer, depending on
45// the enabled layers in the current board.
46// So we need to store the list of these UI items int m_fgGridSizer
47// row by row
49{
50 BOARD_STACKUP_ITEM* m_Item; // The BOARD_STACKUP_ITEM managed by this BOARD_STACKUP_ROW_UI_ITEM
51 int m_SubItem; // For multilayer dielectric, the index in sublayer list.
52 // Must be >= 0 and < m_Item sublayer count. Used only for dielectic
53 // 0 is the base list of parameters (always existing)
54 bool m_isEnabled; // True if the row is in board
55 // false if not (this row is not shown on the panel)
56 wxStaticBitmap* m_Icon; // Color icon in first column (column 1)
57 wxStaticText* m_LayerName; // string shown in column 2
58 wxControl* m_LayerTypeCtrl; // control shown in column 3
59 wxControl* m_MaterialCtrl; // control shown in column 4, with m_MaterialButt
60 wxButton* m_MaterialButt; // control shown in column 4, with m_MaterialCtrl
61 wxControl* m_ThicknessCtrl; // control shown in column 5
62 wxControl* m_ThicknessLockCtrl;// control shown in column 6
63 wxControl* m_ColorCtrl; // control shown in column 7
64 wxControl* m_EpsilonCtrl; // control shown in column 8
65 wxControl* m_LossTgCtrl; // control shown in column 9
66
67 COLOR4D m_UserColor; // User-specified color (if any)
68
69 BOARD_STACKUP_ROW_UI_ITEM( BOARD_STACKUP_ITEM* aItem, int aSubItem = 1 ) :
70 m_Item( aItem ),
71 m_SubItem( aSubItem ),
72 m_isEnabled( true ),
73 m_Icon( nullptr ),
74 m_LayerName( nullptr ),
75 m_LayerTypeCtrl( nullptr ),
76 m_MaterialCtrl( nullptr ),
77 m_MaterialButt( nullptr ),
78 m_ThicknessCtrl( nullptr ),
79 m_ThicknessLockCtrl( nullptr ),
80 m_ColorCtrl( nullptr ),
81 m_EpsilonCtrl( nullptr ),
82 m_LossTgCtrl( nullptr )
83 {}
84};
85
86
88{
89public:
91 PANEL_SETUP_LAYERS* aPanelLayers );
93
94 void ImportSettingsFrom( BOARD* aBoard );
95
102 void OnLayersOptionsChanged( LSET aNewLayerSet );
103
105 int GetCopperLayerCount() const;
106
110 int GetSublayerId( int aRow );
111
113 wxColor GetSelectedColor( int aRow ) const;
114
116
117 // Called by wxWidgets: transfer current settings stored in m_stackup to the board
118 bool TransferDataFromWindow() override;
119
120private:
131 int aSublayerIdx );
132
135 wxControl* addSpacer();
136
143 void addMaterialChooser( wxWindowID aId, const wxString * aMaterialName,
144 BOARD_STACKUP_ROW_UI_ITEM& aUiRowItem );
145
154 void buildLayerStackPanel( bool aCreatedInitialStackup );
155
161 void synchronizeWithBoard( bool aFullSync );
162
169
176
180
185
191
196 void setDefaultLayerWidths( int targetThickness );
197
198 void onColorSelected( wxCommandEvent& event );
199 void onMaterialChange( wxCommandEvent& event );
200 void onThicknessChange( wxCommandEvent& event );
201 void onExportToClipboard( wxCommandEvent& event ) override;
202 void onAddDielectricLayer( wxCommandEvent& event ) override;
203 void onRemoveDielectricLayer( wxCommandEvent& event ) override;
204 void onRemoveDielUI( wxUpdateUIEvent& event ) override;
205 void onCopperLayersSelCount( wxCommandEvent& event ) override;
206 void onAdjustDielectricThickness( wxCommandEvent& event ) override;
207
212 void updateIconColor( int aRow = -1 );
213
219 wxColor getColorIconItem( int aRow );
220
228 wxBitmapComboBox* createColorBox( BOARD_STACKUP_ITEM* aStackupItem, int aRow );
229
234 void disconnectEvents();
235
236private:
238 PANEL_SETUP_LAYERS* m_panelLayers; // The associated PANEL_SETUP_LAYERS, to know
239 // enabled layers and copper layer names
240 LSET m_enabledLayers; // the current enabled layers in this panel
241 // restricted to allowed layers in stackup.
242 // when do not match the enabled layers
243 // in PANEL_SETUP_LAYERS the stackup is not up to date
244 // a list of currently available dielectric materials
246 // a list of currently available solder mask materials
248 // a list of currently available solder mask materials
250 // List of items in m_fgGridSizer
251 std::vector<BOARD_STACKUP_ROW_UI_ITEM> m_rowUiItemsList;
252
257 wxSize m_numericTextCtrlSize; // Best size to enter values with units in wxTextCtrl
258 wxSize m_numericFieldsSize; // Best size to enter double values in wxTextCtrl
259 wxArrayString m_core_prepreg_choice; // Used to display the option list in dialog
260 wxSize m_colorSwatchesSize; // the size of color swatches in the wxBitmapComboBox.
261 wxSize m_colorIconsSize; // the size of color swatches in grid, left column.
262
263 // The list of controls (wxChoice, wxBitmapComboBox, wxTextCtrl) added to the panel
264 // when building the BOARD_STACKUP_ITEM list editor and connected to command events
265 // Used to disconnect event handlers
266 std::vector<wxControl*> m_controlItemsList;
267};
268
269#endif // #ifndef PANEL_SETUP_BOARD_STACKUP_H
Container for design settings for a BOARD object.
Manage one layer needed to make a physical board.
Definition: board_stackup.h:91
Manage layers needed to make a physical board.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
Class PANEL_SETUP_BOARD_STACKUP_BASE.
void onAddDielectricLayer(wxCommandEvent &event) override
DIELECTRIC_SUBSTRATE_LIST m_silkscreenMatList
void onExportToClipboard(wxCommandEvent &event) override
bool transferDataFromUIToStackup()
Transfer current UI settings to m_stackup but not to the board.
BOARD_STACKUP_ROW_UI_ITEM createRowData(int aRow, BOARD_STACKUP_ITEM *aStackupItem, int aSublayerIdx)
Creates a BOARD_STACKUP_ROW_UI_ITEM relative to the aStackupItem.
wxControl * addSpacer()
add a Spacer in m_fgGridSizer when a empty cell is needed
std::vector< wxControl * > m_controlItemsList
void onColorSelected(wxCommandEvent &event)
void onCopperLayersSelCount(wxCommandEvent &event) override
void ImportSettingsFrom(BOARD *aBoard)
void OnLayersOptionsChanged(LSET aNewLayerSet)
Must be called if the copper layers count has changed or solder mask, solder paste or silkscreen laye...
void updateIconColor(int aRow=-1)
Update the icons color (swatches in first grid column)
void updateCopperLayerCount()
Updates the enabled copper layers when the dropdown is changed.
wxColor GetSelectedColor(int aRow) const
Return the color currently selected for the row aRow.
void onRemoveDielectricLayer(wxCommandEvent &event) override
int computeBoardThickness()
Recompute the board thickness and update the textbox.
void setDefaultLayerWidths(int targetThickness)
Set the widths of dielectric layers to sensible defaults.
void synchronizeWithBoard(bool aFullSync)
Synchronize the full stackup shown in m_fgGridSizer according to the stackup of the current board and...
void onThicknessChange(wxCommandEvent &event)
BOARD_DESIGN_SETTINGS * m_brdSettings
BOARD_STACKUP_ITEM * GetStackupItem(int aRow)
void showOnlyActiveLayers()
Show or do not show items in m_fgGridSizer according to the stackup of the current board.
DIELECTRIC_SUBSTRATE_LIST m_solderMaskMatList
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList
PANEL_SETUP_LAYERS * m_panelLayers
void onRemoveDielUI(wxUpdateUIEvent &event) override
void buildLayerStackPanel(bool aCreatedInitialStackup)
Populate m_fgGridSizer with items to handle stackup parameters This is a full list: all copper layers...
DIELECTRIC_SUBSTRATE_LIST m_delectricMatList
wxBitmapComboBox * createColorBox(BOARD_STACKUP_ITEM *aStackupItem, int aRow)
creates a bitmap combobox to select a layer color
void disconnectEvents()
disconnect event handlers connected to wxControl items found in list m_controlItemsList
void onAdjustDielectricThickness(wxCommandEvent &event) override
void addMaterialChooser(wxWindowID aId, const wxString *aMaterialName, BOARD_STACKUP_ROW_UI_ITEM &aUiRowItem)
add a control (a wxTextCtrl + a button) in m_fgGridSizer to select a material
void rebuildLayerStackPanel()
Populate m_fgGridSizer with items to handle stackup parameters If previous items are in list,...
void onMaterialChange(wxCommandEvent &event)
PANEL_SETUP_BOARD_STACKUP(PAGED_DIALOG *aParent, PCB_EDIT_FRAME *aFrame, PANEL_SETUP_LAYERS *aPanelLayers)
The main frame for Pcbnew.
BOARD_STACKUP_ROW_UI_ITEM(BOARD_STACKUP_ITEM *aItem, int aSubItem=1)
BOARD_STACKUP_ITEM * m_Item