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-2021 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 
38 class wxBitmapComboBox;
39 class PANEL_SETUP_LAYERS;
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  wxColour 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  m_UserColor( wxNullColour )
84  {}
85 };
86 
87 
89 {
90 public:
92  PCB_EDIT_FRAME* aFrame,
93  PANEL_SETUP_LAYERS* aPanelLayers );
95 
96  void ImportSettingsFrom( BOARD* aBoard );
97 
104  void OnLayersOptionsChanged( LSET aNewLayerSet );
105 
107  int GetCopperLayerCount() const;
108 
110  BOARD_STACKUP_ITEM* GetStackupItem( int aRow );
112  int GetSublayerId( int aRow );
113 
115  wxColor GetSelectedColor( int aRow ) const;
116 
118  int GetPcbThickness();
119 
120  // Called by wxWidgets: transfer current settings stored in m_stackup to the board
121  bool TransferDataFromWindow() override;
122 
123 private:
134  int aSublayerIdx );
135 
138  wxControl* addSpacer();
139 
146  void addMaterialChooser( wxWindowID aId, const wxString * aMaterialName,
147  BOARD_STACKUP_ROW_UI_ITEM& aUiRowItem );
148 
157  void buildLayerStackPanel( bool aCreatedInitialStackup );
158 
164  void synchronizeWithBoard( bool aFullSync );
165 
171  void showOnlyActiveLayers();
172 
178  void rebuildLayerStackPanel();
179 
183 
187  void updateCopperLayerCount();
188 
192  void computeBoardThickness();
193 
194  void onColorSelected( wxCommandEvent& event );
195  void onMaterialChange( wxCommandEvent& event );
196  void onThicknessChange( wxCommandEvent& event );
197  void onExportToClipboard( wxCommandEvent& event ) override;
198  void onAddDielectricLayer( wxCommandEvent& event ) override;
199  void onRemoveDielectricLayer( wxCommandEvent& event ) override;
200  void onRemoveDielUI( wxUpdateUIEvent& event ) override;
201  void onCopperLayersSelCount( wxCommandEvent& event ) override;
202  void onAdjustDielectricThickness( wxCommandEvent& event ) override;
203 
208  void updateIconColor( int aRow = -1 );
209 
215  wxColor getColorIconItem( int aRow );
216 
224  wxBitmapComboBox* createBmComboBox( BOARD_STACKUP_ITEM* aStackupItem, int aRow );
225 
230  void disconnectEvents();
231 
232 private:
234  PANEL_SETUP_LAYERS* m_panelLayers; // The associated PANEL_SETUP_LAYERS, to know
235  // enabled layers and copper layer names
236  LSET m_enabledLayers; // the current enabled layers in this panel
237  // restricted to allowed layers in stackup.
238  // when do not match the enabled layers
239  // in PANEL_SETUP_LAYERS the stackup is not up to date
240  // a list of currently available dielectric materials
242  // a list of currently available solder mask materials
244  // a list of currently available solder mask materials
246  // List of items in m_fgGridSizer
247  std::vector<BOARD_STACKUP_ROW_UI_ITEM> m_rowUiItemsList;
248 
254  wxSize m_numericTextCtrlSize; // Best size to enter values with units in wxTextCtrl
255  wxSize m_numericFieldsSize; // Best size to enter double values in wxTextCtrl
256  wxArrayString m_core_prepreg_choice; // Used to display the option list in dialog
257  wxSize m_colorSwatchesSize; // the size of color swatches in the wxBitmapComboBox.
258  wxSize m_colorIconsSize; // the size of color swatches in grid, left column.
259 
260  // The list of controls (wxChoice, wxBitmapComboBox, wxTextCtrl) added to the panel
261  // when building the BOARD_STACKUP_ITEM list editor and connected to command events
262  // Used to disconnect event handlers
263  std::vector<wxControl*> m_controlItemsList;
264 };
265 
266 #endif // #ifndef PANEL_SETUP_BOARD_STACKUP_H
void onExportToClipboard(wxCommandEvent &event) override
std::vector< wxControl * > m_controlItemsList
Manage layers needed to make a physical board.
PANEL_SETUP_LAYERS * m_panelLayers
void updateCopperLayerCount()
Updates the enabled copper layers when the dropdown is changed.
void onAddDielectricLayer(wxCommandEvent &event) override
void computeBoardThickness()
Recompute the board thickness and update the textbox.
wxBitmapComboBox * createBmComboBox(BOARD_STACKUP_ITEM *aStackupItem, int aRow)
creates a bitmap combobox to select a layer color
DIELECTRIC_SUBSTRATE_LIST m_silkscreenMatList
void onRemoveDielUI(wxUpdateUIEvent &event) override
void onCopperLayersSelCount(wxCommandEvent &event) override
void buildLayerStackPanel(bool aCreatedInitialStackup)
Populate m_fgGridSizer with items to handle stackup parameters This is a full list: all copper layers...
void disconnectEvents()
disconnect event handlers connected to wxControl items found in list m_controlItemsList
BOARD_STACKUP_ITEM * GetStackupItem(int aRow)
void OnLayersOptionsChanged(LSET aNewLayerSet)
Must be called if the copper layers count has changed or solder mask, solder paste or silkscreen laye...
DIELECTRIC_SUBSTRATE_LIST m_solderMaskMatList
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
Class PANEL_SETUP_BOARD_STACKUP_BASE.
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.
void onThicknessChange(wxCommandEvent &event)
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:502
void synchronizeWithBoard(bool aFullSync)
Synchronize the full stackup shown in m_fgGridSizer according to the stackup of the current board and...
BOARD_STACKUP_ROW_UI_ITEM(BOARD_STACKUP_ITEM *aItem, int aSubItem=1)
BOARD_DESIGN_SETTINGS * m_brdSettings
void ImportSettingsFrom(BOARD *aBoard)
BOARD_STACKUP_ITEM * m_Item
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
void rebuildLayerStackPanel()
Populate m_fgGridSizer with items to handle stackup parameters If previous items are in list,...
EDA_UNITS
Definition: eda_units.h:38
wxControl * addSpacer()
add a Spacer in m_fgGridSizer when a empty cell is needed
PANEL_SETUP_BOARD_STACKUP(PAGED_DIALOG *aParent, PCB_EDIT_FRAME *aFrame, PANEL_SETUP_LAYERS *aPanelLayers)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
The main frame for Pcbnew.
void updateIconColor(int aRow=-1)
Update the icons color (swatches in first grid column)
void onColorSelected(wxCommandEvent &event)
wxColor GetSelectedColor(int aRow) const
Return the color currently selected for the row aRow.
bool transferDataFromUIToStackup()
Transfer current UI settings to m_stackup but not to the board.
void showOnlyActiveLayers()
Show or do not show items in m_fgGridSizer according to the stackup of the current board.
DIELECTRIC_SUBSTRATE_LIST m_delectricMatList
void onRemoveDielectricLayer(wxCommandEvent &event) override
void onAdjustDielectricThickness(wxCommandEvent &event) override
void onMaterialChange(wxCommandEvent &event)
Container for design settings for a BOARD object.
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList