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-2019 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 <fctsys.h>
30 #include <pcbnew.h>
31 #include <class_board.h>
32 #include <widgets/unit_binder.h>
33 
35 #include "class_board_stackup.h"
37 #include "dielectric_material.h"
38 
39 class wxBitmapComboBox;
40 class PANEL_SETUP_LAYERS;
41 
42 
43 // A helper class to handle UI items managed by m_fgGridSizer
44 // in PANEL_SETUP_BOARD_STACKUP
45 // these items are shown or not in m_fgGridSizer, depending on
46 // the enabled layers in the current board.
47 // So we need to store the list of these UI items int m_fgGridSizer
48 // row by row
50 {
51  BOARD_STACKUP_ITEM* m_Item; // The BOARD_STACKUP_ITEM managed by this BOARD_STACKUP_ROW_UI_ITEM
52  int m_SubItem; // For multilayer dielectric, the index in sublayer list.
53  // Must be >= 0 and < m_Item sublayer count. Used only for dielectic
54  // 0 is the base list of parameters (always existing)
55  bool m_isEnabled; // True if the row is in board
56  // false if not (this row is not shown on the panel)
57  wxStaticBitmap* m_Icon; // Color icon in first column (column 1)
58  wxStaticText* m_LayerName; // string shown in column 2
59  wxControl* m_LayerTypeCtrl; // control shown in column 3
60  wxControl* m_MaterialCtrl; // control shown in column 4, with m_MaterialButt
61  wxButton* m_MaterialButt; // control shown in column 4, with m_MaterialCtrl
62  wxControl* m_ThicknessCtrl; // control shown in column 5
63  wxControl* m_ThicknessLockCtrl;// control shown in column 6
64  wxControl* m_ColorCtrl; // control shown in column 7
65  wxControl* m_EpsilonCtrl; // control shown in column 8
66  wxControl* m_LossTgCtrl; // control shown in column 9
67 
68  BOARD_STACKUP_ROW_UI_ITEM( BOARD_STACKUP_ITEM* aItem, int aSubItem = 1 ) :
69  m_Item( aItem ), m_SubItem( aSubItem ),
70  m_isEnabled( true ), m_Icon( nullptr ), m_LayerName( nullptr ),
71  m_LayerTypeCtrl( nullptr ),
72  m_MaterialCtrl( nullptr ),m_MaterialButt( nullptr ),
73  m_ThicknessCtrl( nullptr ), m_ThicknessLockCtrl( nullptr ),
74  m_ColorCtrl( nullptr ),
75  m_EpsilonCtrl( nullptr ), m_LossTgCtrl( nullptr )
76  {}
77 };
78 
79 
81 {
82 public:
84  PCB_EDIT_FRAME* aFrame,
85  PANEL_SETUP_LAYERS* aPanelLayers );
87 
88  void ImportSettingsFrom( BOARD* aBoard );
89 
96  void OnLayersOptionsChanged( LSET aNewLayerSet );
97 
101  int GetSublayerId( int aRow );
102 
104  wxColor GetSelectedColor( int aRow ) const;
105 
107  int GetPcbThickness();
108 
109  // Called by wxWidgets: transfer current settings stored in m_stackup to the board
110  bool TransferDataFromWindow() override;
111 
112  std::map<int, wxColor> m_UserColors; // the list of user colors for each grid row
113  // other colors are defined colors, and are not stored
114 private:
125  int aSublayerIdx );
126 
129  wxControl* addSpacer();
130 
137  void addMaterialChooser( wxWindowID aId, const wxString * aMaterialName,
138  BOARD_STACKUP_ROW_UI_ITEM& aUiRowItem );
139 
148  void buildLayerStackPanel( bool aCreatedInitialStackup );
149 
155  void synchronizeWithBoard( bool aFullSync );
156 
162  void showOnlyActiveLayers();
163 
169  void rebuildLayerStackPanel();
170 
174 
175  void onUpdateThicknessValue( wxUpdateUIEvent& event ) override;
176  void onCalculateDielectricThickness( wxCommandEvent& event ) override;
177 
178  void onColorSelected( wxCommandEvent& event );
179  void onMaterialChange( wxCommandEvent& event );
180  void onThicknessChange( wxCommandEvent& event );
181  void onExportToClipboard( wxCommandEvent& event ) override;
182  void onAddDielectricLayer( wxCommandEvent& event ) override;
183  void onRemoveDielectricLayer( wxCommandEvent& event ) override;
184  void onRemoveDielUI( wxUpdateUIEvent& event ) override;
185  void OnUpdateUI( wxUpdateUIEvent& event ) override;
186 
191  void updateIconColor( int aRow = -1 );
192 
198  wxColor getColorIconItem( int aRow );
199 
207  wxBitmapComboBox* createBmComboBox( BOARD_STACKUP_ITEM* aStackupItem, int aRow );
208 
213  void disconnectEvents();
214 
215 private:
217  PANEL_SETUP_LAYERS* m_panelLayers; // The associated PANEL_SETUP_LAYERS, to know
218  // enabled layers and copper layer names
219  LSET m_enabledLayers; // the current enabled layers in this panel
220  // restricted to allowed layers in stackup.
221  // when do not match the enabled layers
222  // in PANEL_SETUP_LAYERS the stackup is not up to date
223  // a list of currently available dielectric materials
225  // a list of currently available solder mask materials
227  // a list of currently available solder mask materials
229  // List of items in m_fgGridSizer
230  std::vector<BOARD_STACKUP_ROW_UI_ITEM> m_rowUiItemsList;
231 
237  wxSize m_numericTextCtrlSize; // Best size to enter values with units in wxTextCtrl
238  wxSize m_numericFieldsSize; // Best size to enter double values in wxTextCtrl
239  wxArrayString m_core_prepreg_choice; // Used to display the option list in dialog
240  wxSize m_colorSwatchesSize; // the size of color swatches in the wxBitmapComboBox.
241  wxSize m_colorComboSize; // the size of the wxBitmapComboBox.
242  wxSize m_colorIconsSize; // the size of color swatches in grid, left column.
243 
244  // The list of controls (wxChoice, wxBitmapComboBox, wxTextCtrl) added to the panel
245  // when building the BOARD_STACKUP_ITEM list editor and connected to command events
246  // Used to disconnect event handlers
247  std::vector<wxControl*> m_controlItemsList;
248 
249  bool m_stackupMismatch; // flags an error when the stackup was not updated
250  // to match changes made to the enabled layers
251 };
252 
253 #endif // #ifndef PANEL_SETUP_BOARD_STACKUP_H
void onExportToClipboard(wxCommandEvent &event) override
EDA_UNITS
Definition: common.h:198
std::vector< wxControl * > m_controlItemsList
this class manage the layers needed to make a physical board they are solder mask,...
PANEL_SETUP_LAYERS * m_panelLayers
void onAddDielectricLayer(wxCommandEvent &event) override
wxBitmapComboBox * createBmComboBox(BOARD_STACKUP_ITEM *aStackupItem, int aRow)
creates a bitmap combobox to select a layer color
void onUpdateThicknessValue(wxUpdateUIEvent &event) override
DIELECTRIC_SUBSTRATE_LIST m_silkscreenMatList
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...
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.
std::map< int, wxColor > m_UserColors
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
this class manage one layer needed to make a physical board it can be a solder mask,...
void rebuildLayerStackPanel()
Populate m_fgGridSizer with items to handle stackup parameters If previous items are in list,...
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)
void onCalculateDielectricThickness(wxCommandEvent &event) override
Information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:176
PCB_EDIT_FRAME is 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 OnUpdateUI(wxUpdateUIEvent &event) override
void onRemoveDielectricLayer(wxCommandEvent &event) override
void onMaterialChange(wxCommandEvent &event)
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList