KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 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#ifndef PANEL_SETUP_BOARD_STACKUP_H
22#define PANEL_SETUP_BOARD_STACKUP_H
23
24
25#include <board.h>
26#include <widgets/unit_binder.h>
27#include <wx/gdicmn.h>
28
30#include "board_stackup.h"
32#include "dielectric_material.h"
33
34class wxBitmapComboBox;
37
38
39// A helper class to handle UI items managed by m_fgGridSizer
40// in PANEL_SETUP_BOARD_STACKUP
41// these items are shown or not in m_fgGridSizer, depending on
42// the enabled layers in the current board.
43// So we need to store the list of these UI items int m_fgGridSizer
44// row by row
46{
47 BOARD_STACKUP_ITEM* m_Item; // The BOARD_STACKUP_ITEM managed by this BOARD_STACKUP_ROW_UI_ITEM
48 int m_SubItem; // For multilayer dielectric, the index in sublayer list.
49 // Must be >= 0 and < m_Item sublayer count. Used only for dielectic
50 // 0 is the base list of parameters (always existing)
51 int m_Row; // The row number in the parent grid
52 bool m_isEnabled; // True if the row is in board
53 // false if not (this row is not shown on the panel)
54 wxStaticBitmap* m_Icon; // Color icon in first column (column 1)
55 wxStaticText* m_LayerName; // string shown in column 2
56 wxControl* m_LayerTypeCtrl; // control shown in column 3
57 wxControl* m_MaterialCtrl; // control shown in column 4, with m_MaterialButt
58 wxButton* m_MaterialButt; // control shown in column 4, with m_MaterialCtrl
59 wxControl* m_ThicknessCtrl; // control shown in column 5
60 wxControl* m_ThicknessLockCtrl; // control shown in column 6
61 wxControl* m_ColorCtrl; // control shown in column 7
62 wxControl* m_EpsilonCtrl; // control shown in column 8
63 wxControl* m_LossTgCtrl; // control shown in column 9
64 wxControl* m_SpecFreqCtrl; // control shown in column 10
65 wxControl* m_SpecFreqUnitsCtrl; // control shown in column 11
66 wxControl* m_DielectricModelCtrl; // control shown in column 12
67
68 COLOR4D m_UserColor; // User-specified color (if any)
69
70 BOARD_STACKUP_ROW_UI_ITEM( BOARD_STACKUP_ITEM* aItem, int aSubItem, int aRow ) :
71 m_Item( aItem ),
72 m_SubItem( aSubItem ),
73 m_Row( aRow ),
74 m_isEnabled( false ),
75 m_Icon( nullptr ),
76 m_LayerName( nullptr ),
77 m_LayerTypeCtrl( nullptr ),
78 m_MaterialCtrl( nullptr ),
79 m_MaterialButt( nullptr ),
80 m_ThicknessCtrl( nullptr ),
81 m_ThicknessLockCtrl( nullptr ),
82 m_ColorCtrl( nullptr ),
83 m_EpsilonCtrl( nullptr ),
84 m_LossTgCtrl( nullptr ),
85 m_SpecFreqCtrl( nullptr ),
86 m_SpecFreqUnitsCtrl( nullptr ),
87 m_DielectricModelCtrl( nullptr )
88 {}
89};
90
91
93{
94public:
95 PANEL_SETUP_BOARD_STACKUP( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame,
96 PANEL_SETUP_LAYERS* aPanelLayers,
97 PANEL_SETUP_BOARD_FINISH* aPanelFinish );
99
100 void ImportSettingsFrom( BOARD* aBoard );
101
108 void OnLayersOptionsChanged( const LSET& aNewLayerSet );
109
111 int GetCopperLayerCount() const;
112
116 int GetSublayerId( int aRow );
117
119 wxColor GetSelectedColor( int aRow ) const;
120
121 // Called by wxWidgets: transfer current settings stored in m_stackup to the board
122 bool TransferDataFromWindow() override;
123
124private:
134 void lazyBuildRowUI( BOARD_STACKUP_ROW_UI_ITEM& ui_row_item, int aPos );
135
138 wxControl* addSpacer( int aPos );
139
149 void buildLayerStackPanel( bool aCreateInitialStackup = false, bool aRelinkStackup = false );
150
156 void synchronizeWithBoard( bool aFullSync );
157
164
171 void rebuildLayerStackPanel( bool aRelinkItems = false );
172
176
181
187
192 void setDefaultLayerWidths( int targetThickness );
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* createColorBox( BOARD_STACKUP_ITEM* aStackupItem, int aRow );
225
226 void onUnitsChanged( wxCommandEvent& event );
227
231 void disconnectEvents();
232
236 static wxString m_specFreqChoices[4];
237
241 static wxString m_dielecticModelChoices[2];
242
244 enum class FREQ_UNITS : int
245 {
246 HZ = 0,
250 };
251
255 static std::pair<double, FREQ_UNITS> normaliseFrequency( double aFreq );
256
257private:
259 PANEL_SETUP_LAYERS* m_panelLayers; // The associated PANEL_SETUP_LAYERS, to know enabled
260 // layers and copper layer names
261 LSET m_enabledLayers; // The current enabled layers in this panel restricted
262 // to allowed layers in stackup. (When this doesn't
263 // match the enabled layers in PANEL_SETUP_LAYERS the
264 // stackup is not up to date.)
266
267 DIELECTRIC_SUBSTRATE_LIST m_delectricMatList; // List of currently available
268 // dielectric materials
269 DIELECTRIC_SUBSTRATE_LIST m_solderMaskMatList; // List of currently available
270 // solder mask materials
271 DIELECTRIC_SUBSTRATE_LIST m_silkscreenMatList; // List of currently available
272 // solder mask materials
273 std::vector<BOARD_STACKUP_ROW_UI_ITEM> m_rowUiItemsList; // List of items in m_fgGridSizer
274
279 wxSize m_numericTextCtrlSize; // Best size for wxTextCtrls with units
280 wxSize m_numericFieldsSize; // Best size for wxTextCtrls without units
281 wxSize m_unitsFieldsSize; // Best size for wxChoice units selection
282 wxSize m_modelFieldSize; // Best size for dielectric model selection
283 wxArrayString m_core_prepreg_choice; // Used to display the option list in dialog
284 wxSize m_colorSwatchesSize; // Size of swatches in the wxBitmapComboBox.
285 wxSize m_colorIconsSize; // Size of swatches in the grid (left column)
286
287 std::vector<wxControl*> m_controlItemsList; // List of ctrls (wxChoice, wxTextCtrl, etc.)
288 // with added event handlers
289};
290
291#endif // #ifndef PANEL_SETUP_BOARD_STACKUP_H
Container for design settings for a BOARD object.
Manage one layer needed to make a physical board.
Manage layers needed to make a physical board.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
PANEL_SETUP_BOARD_STACKUP_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)
static wxString m_dielecticModelChoices[2]
The choices available for dielectric frequency-dependency model.
void onAddDielectricLayer(wxCommandEvent &event) override
FREQ_UNITS
Describes the displayed units for a normalised frequency.
DIELECTRIC_SUBSTRATE_LIST m_silkscreenMatList
void onExportToClipboard(wxCommandEvent &event) override
bool transferDataFromUIToStackup()
Transfer current UI settings to m_stackup but not to the board.
PANEL_SETUP_BOARD_STACKUP(wxWindow *aParentWindow, PCB_EDIT_FRAME *aFrame, PANEL_SETUP_LAYERS *aPanelLayers, PANEL_SETUP_BOARD_FINISH *aPanelFinish)
std::vector< wxControl * > m_controlItemsList
void onColorSelected(wxCommandEvent &event)
void onCopperLayersSelCount(wxCommandEvent &event) override
void onUnitsChanged(wxCommandEvent &event)
void ImportSettingsFrom(BOARD *aBoard)
PANEL_SETUP_BOARD_FINISH * m_panelFinish
void updateIconColor(int aRow=-1)
Update the icons color (swatches in first grid column)
static std::pair< double, FREQ_UNITS > normaliseFrequency(double aFreq)
Normalises a frequency in Hz to a value and a units multiplier.
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
wxControl * addSpacer(int aPos)
add a Spacer in m_fgGridSizer when a empty cell is needed
int computeBoardThickness()
Recompute the board thickness and update the textbox.
void setDefaultLayerWidths(int targetThickness)
Set the widths of dielectric layers to sensible defaults.
static wxString m_specFreqChoices[4]
The choices available for spec freq units.
void synchronizeWithBoard(bool aFullSync)
Synchronize the full stackup shown in m_fgGridSizer according to the stackup of the current board and...
void buildLayerStackPanel(bool aCreateInitialStackup=false, bool aRelinkStackup=false)
Populate m_fgGridSizer with items to handle stackup parameters This is a full list: all copper layers...
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 lazyBuildRowUI(BOARD_STACKUP_ROW_UI_ITEM &ui_row_item, int aPos)
Creates the controls in a BOARD_STACKUP_ROW_UI_ITEM relative to the aStackupItem.
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 OnLayersOptionsChanged(const LSET &aNewLayerSet)
Must be called if the copper layers count has changed or solder mask, solder paste or silkscreen laye...
void onMaterialChange(wxCommandEvent &event)
void rebuildLayerStackPanel(bool aRelinkItems=false)
Populate m_fgGridSizer with items to handle stackup parameters If previous items are in list,...
The main frame for Pcbnew.
EDA_UNITS
Definition eda_units.h:44
BOARD_STACKUP_ROW_UI_ITEM(BOARD_STACKUP_ITEM *aItem, int aSubItem, int aRow)
BOARD_STACKUP_ITEM * m_Item