KiCad PCB EDA Suite
PANEL_SETUP_BOARD_STACKUP Class Reference

#include <panel_board_stackup.h>

Inheritance diagram for PANEL_SETUP_BOARD_STACKUP:
PANEL_SETUP_BOARD_STACKUP_BASE

Public Member Functions

 PANEL_SETUP_BOARD_STACKUP (PAGED_DIALOG *aParent, PCB_EDIT_FRAME *aFrame, PANEL_SETUP_LAYERS *aPanelLayers)
 
 ~PANEL_SETUP_BOARD_STACKUP ()
 
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 layers are enabled or disabled Rebuild the Layer Stack Panel if the new layer set differs from the current layet set. More...
 
int GetCopperLayerCount () const
 
BOARD_STACKUP_ITEMGetStackupItem (int aRow)
 
int GetSublayerId (int aRow)
 
wxColor GetSelectedColor (int aRow) const
 Return the color currently selected for the row aRow. More...
 
BOARD_STACKUPGetStackup ()
 
int GetPcbThickness ()
 
bool TransferDataFromWindow () override
 

Protected Attributes

wxStaticText * m_lblCopperLayers
 
wxChoice * m_choiceCopperLayers
 
wxCheckBox * m_impedanceControlled
 
wxButton * m_buttonAddDielectricLayer
 
wxButton * m_buttonRemoveDielectricLayer
 
wxScrolledWindow * m_scGridWin
 
wxFlexGridSizer * m_fgGridSizer
 
wxStaticText * m_staticTextLayer
 
wxStaticText * m_staticTextLayerId
 
wxStaticText * m_staticTextType
 
wxStaticText * m_staticTextMaterial
 
wxStaticText * m_staticTextThickness
 
wxStaticBitmap * m_bitmapLockThickness
 
wxStaticText * m_staticTextColor
 
wxStaticText * m_staticTextEpsilonR
 
wxStaticText * m_staticTextLossTg
 
wxStaticText * m_staticTextCT
 
wxTextCtrl * m_tcCTValue
 
wxButton * m_buttonExport
 

Private Member Functions

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. More...
 
wxControl * addSpacer ()
 add a Spacer in m_fgGridSizer when a empty cell is needed More...
 
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 More...
 
void buildLayerStackPanel (bool aCreatedInitialStackup)
 Populate m_fgGridSizer with items to handle stackup parameters This is a full list: all copper layers and all tech layers that are supported by the stackup items not in the current board stackup will be not shown, but they are existing in list. More...
 
void synchronizeWithBoard (bool aFullSync)
 Synchronize the full stackup shown in m_fgGridSizer according to the stackup of the current board and optionally update the stackup params (thickness, color ... More...
 
void showOnlyActiveLayers ()
 Show or do not show items in m_fgGridSizer according to the stackup of the current board. More...
 
void rebuildLayerStackPanel ()
 Populate m_fgGridSizer with items to handle stackup parameters If previous items are in list, remove old items New prms are added must be called after adding or deleting a dielectric parameter set. More...
 
bool transferDataFromUIToStackup ()
 Transfer current UI settings to m_stackup but not to the board. More...
 
void updateCopperLayerCount ()
 Updates the enabled copper layers when the dropdown is changed. More...
 
void computeBoardThickness ()
 Recompute the board thickness and update the textbox. More...
 
void onColorSelected (wxCommandEvent &event)
 
void onMaterialChange (wxCommandEvent &event)
 
void onThicknessChange (wxCommandEvent &event)
 
void onExportToClipboard (wxCommandEvent &event) override
 
void onAddDielectricLayer (wxCommandEvent &event) override
 
void onRemoveDielectricLayer (wxCommandEvent &event) override
 
void onRemoveDielUI (wxUpdateUIEvent &event) override
 
void updateIconColor (int aRow=-1)
 Update the icons color (swatches in first grid column) More...
 
wxColor getColorIconItem (int aRow)
 
wxBitmapComboBox * createBmComboBox (BOARD_STACKUP_ITEM *aStackupItem, int aRow)
 creates a bitmap combobox to select a layer color More...
 
void disconnectEvents ()
 disconnect event handlers connected to wxControl items found in list m_controlItemsList More...
 

Private Attributes

BOARD_STACKUP m_stackup
 
PANEL_SETUP_LAYERSm_panelLayers
 
LSET m_enabledLayers
 
DIELECTRIC_SUBSTRATE_LIST m_delectricMatList
 
DIELECTRIC_SUBSTRATE_LIST m_solderMaskMatList
 
DIELECTRIC_SUBSTRATE_LIST m_silkscreenMatList
 
std::vector< BOARD_STACKUP_ROW_UI_ITEMm_rowUiItemsList
 
PAGED_DIALOGm_parentDialog
 
BOARDm_board
 
BOARD_DESIGN_SETTINGSm_brdSettings
 
EDA_UNITS m_units
 
PCB_EDIT_FRAMEm_frame
 
wxSize m_numericTextCtrlSize
 
wxSize m_numericFieldsSize
 
wxArrayString m_core_prepreg_choice
 
wxSize m_colorSwatchesSize
 
wxSize m_colorIconsSize
 
std::vector< wxControl * > m_controlItemsList
 

Detailed Description

Definition at line 88 of file panel_board_stackup.h.

Constructor & Destructor Documentation

◆ PANEL_SETUP_BOARD_STACKUP()

PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP ( PAGED_DIALOG aParent,
PCB_EDIT_FRAME aFrame,
PANEL_SETUP_LAYERS aPanelLayers 
)

Definition at line 71 of file panel_board_stackup.cpp.

72  :
77 {
78  m_parentDialog = aParent;
79  m_frame = aFrame;
80  m_panelLayers = aPanelLayers;
83  m_units = aFrame->GetUserUnits();
84 
86 
88 
89  // Calculates a good size for color swatches (icons) in this dialog
90  wxClientDC dc( this );
91  m_colorSwatchesSize = dc.GetTextExtent( "XX" );
92  m_colorIconsSize = dc.GetTextExtent( "XXXX" );
93 
94  // Calculates a good size for wxTextCtrl to enter Epsilon R and Loss tan
95  // ("0.000000" + margins)
96  m_numericFieldsSize = dc.GetTextExtent( "X.XXXXXXX" );
97  m_numericFieldsSize.y = -1; // Use default for the vertical size
98 
99  // Calculates a minimal size for wxTextCtrl to enter a dim with units
100  // ("000.0000000 mils" + margins)
101  m_numericTextCtrlSize = dc.GetTextExtent( "XXX.XXXXXXX mils" );
102  m_numericTextCtrlSize.y = -1; // Use default for the vertical size
103 
104  // The grid column containing the lock checkbox is kept to a minimal
105  // size. So we use a wxStaticBitmap: set the bitmap itself
106  m_bitmapLockThickness->SetBitmap( KiScaledBitmap( BITMAPS::locked, aFrame ) );
107 
108  // Gives a minimal size of wxTextCtrl showing dimensions+units
109  m_tcCTValue->SetMinSize( m_numericTextCtrlSize );
110 
111  // Prepare dielectric layer type: layer type keyword is "core" or "prepreg"
112  m_core_prepreg_choice.Add( _( "Core" ) );
113  m_core_prepreg_choice.Add( _( "PrePreg" ) );
114 
115  buildLayerStackPanel( true );
116  synchronizeWithBoard( true );
118 
119  m_choiceCopperLayers->Bind( wxEVT_CHOICE,
120  [&]( wxCommandEvent& )
121  {
124  Layout();
125  } );
126 }
PANEL_SETUP_LAYERS * m_panelLayers
void updateCopperLayerCount()
Updates the enabled copper layers when the dropdown is changed.
void computeBoardThickness()
Recompute the board thickness and update the textbox.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
DIELECTRIC_SUBSTRATE_LIST m_silkscreenMatList
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings Returns a bit-mask of all t...
Definition: board.cpp:447
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_solderMaskMatList
wxTreebook * GetTreebook()
Definition: paged_dialog.h:52
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)
void synchronizeWithBoard(bool aFullSync)
Synchronize the full stackup shown in m_fgGridSizer according to the stackup of the current board and...
static LSET StackupAllowedBrdLayers()
BOARD_DESIGN_SETTINGS * m_brdSettings
#define _(s)
Definition: 3d_actions.cpp:33
void showOnlyActiveLayers()
Show or do not show items in m_fgGridSizer according to the stackup of the current board.
DIELECTRIC_SUBSTRATE_LIST m_delectricMatList
BOARD * GetBoard() const
void SetPhysicalStackupPanel(PANEL_SETUP_BOARD_STACKUP *aPanel)
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
wxBitmap KiScaledBitmap(BITMAPS aBitmap, wxWindow *aWindow, int aHeight)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:147

References _, buildLayerStackPanel(), computeBoardThickness(), PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), BOARD::GetEnabledLayers(), EDA_BASE_FRAME::GetUserUnits(), KiScaledBitmap(), locked, PANEL_SETUP_BOARD_STACKUP_BASE::m_bitmapLockThickness, m_board, m_brdSettings, PANEL_SETUP_BOARD_STACKUP_BASE::m_choiceCopperLayers, m_colorIconsSize, m_colorSwatchesSize, m_core_prepreg_choice, m_enabledLayers, m_frame, m_numericFieldsSize, m_numericTextCtrlSize, m_panelLayers, m_parentDialog, PANEL_SETUP_BOARD_STACKUP_BASE::m_tcCTValue, m_units, PANEL_SETUP_LAYERS::SetPhysicalStackupPanel(), showOnlyActiveLayers(), BOARD_STACKUP::StackupAllowedBrdLayers(), synchronizeWithBoard(), and updateCopperLayerCount().

◆ ~PANEL_SETUP_BOARD_STACKUP()

PANEL_SETUP_BOARD_STACKUP::~PANEL_SETUP_BOARD_STACKUP ( )

Definition at line 129 of file panel_board_stackup.cpp.

130 {
132 }
void disconnectEvents()
disconnect event handlers connected to wxControl items found in list m_controlItemsList

References disconnectEvents().

Member Function Documentation

◆ addMaterialChooser()

void PANEL_SETUP_BOARD_STACKUP::addMaterialChooser ( wxWindowID  aId,
const wxString *  aMaterialName,
BOARD_STACKUP_ROW_UI_ITEM aUiRowItem 
)
private

add a control (a wxTextCtrl + a button) in m_fgGridSizer to select a material

Parameters
aIdis the wxControl id, used to know the event source
aMaterialNameis the the name of the currently selected material (can be null)
aUiRowItemis the the BOARD_STACKUP_ROW_UI_ITEM to store the controls created

Definition at line 531 of file panel_board_stackup.cpp.

534 {
535  wxBoxSizer* bSizerMat = new wxBoxSizer( wxHORIZONTAL );
536  m_fgGridSizer->Add( bSizerMat, 1, wxRIGHT|wxEXPAND, 4 );
537  wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, wxID_ANY );
538 
539  if( aMaterialName )
540  {
541  if( IsPrmSpecified( *aMaterialName ) )
542  textCtrl->SetValue( *aMaterialName );
543  else
544  textCtrl->SetValue( wxGetTranslation( NotSpecifiedPrm() ) );
545  }
546 
547  textCtrl->SetMinSize( m_numericTextCtrlSize );
548  bSizerMat->Add( textCtrl, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
549 
550  wxButton* m_buttonMat = new wxButton( m_scGridWin, aId, _( "..." ), wxDefaultPosition,
551  wxDefaultSize, wxBU_EXACTFIT );
552  bSizerMat->Add( m_buttonMat, 0, wxALIGN_CENTER_VERTICAL, 2 );
553 
554  m_buttonMat->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
555  wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onMaterialChange ),
556  NULL, this );
557  m_controlItemsList.push_back( m_buttonMat );
558 
559  aUiRowItem.m_MaterialCtrl = textCtrl;
560  aUiRowItem.m_MaterialButt = m_buttonMat;
561 }
std::vector< wxControl * > m_controlItemsList
#define NULL
wxString NotSpecifiedPrm()
bool IsPrmSpecified(const wxString &aPrmValue)
#define _(s)
Definition: 3d_actions.cpp:33
void onMaterialChange(wxCommandEvent &event)

References _, IsPrmSpecified(), m_controlItemsList, PANEL_SETUP_BOARD_STACKUP_BASE::m_fgGridSizer, BOARD_STACKUP_ROW_UI_ITEM::m_MaterialButt, BOARD_STACKUP_ROW_UI_ITEM::m_MaterialCtrl, m_numericTextCtrlSize, PANEL_SETUP_BOARD_STACKUP_BASE::m_scGridWin, NotSpecifiedPrm(), NULL, and onMaterialChange().

Referenced by createRowData().

◆ addSpacer()

wxControl * PANEL_SETUP_BOARD_STACKUP::addSpacer ( )
private

add a Spacer in m_fgGridSizer when a empty cell is needed

Definition at line 564 of file panel_board_stackup.cpp.

565 {
566  wxStaticText* emptyText = new wxStaticText( m_scGridWin, wxID_ANY, wxEmptyString );
567  m_fgGridSizer->Add( emptyText, 0, wxALIGN_CENTER_VERTICAL );
568  return emptyText;
569 }

References PANEL_SETUP_BOARD_STACKUP_BASE::m_fgGridSizer, and PANEL_SETUP_BOARD_STACKUP_BASE::m_scGridWin.

Referenced by createRowData().

◆ buildLayerStackPanel()

void PANEL_SETUP_BOARD_STACKUP::buildLayerStackPanel ( bool  aCreatedInitialStackup)
private

Populate m_fgGridSizer with items to handle stackup parameters This is a full list: all copper layers and all tech layers that are supported by the stackup items not in the current board stackup will be not shown, but they are existing in list.

Parameters
aCreatedInitialStackup= true to create a initial stackup list for the dialog false to build the stackup panel from the existing stackup list.

Definition at line 817 of file panel_board_stackup.cpp.

818 {
819  wxWindowUpdateLocker locker( m_scGridWin );
820 
821  // Build a full stackup for the dialog, with a active copper layer count
822  // = current board layer count to calculate a reasonable default stackup:
823  if( aCreatedInitialStackup )
824  {
825  // Creates a full BOARD_STACKUP with 32 copper layers.
826  // extra layers will be hidden later.
827  // but if the number of layer is changed in the dialog, the corresponding
828  // widgets will be available with their previous values.
830  const BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
831 
832  // Now initialize all stackup items to the board values, when exist
833  for( BOARD_STACKUP_ITEM* item: m_stackup.GetList() )
834  {
835  // Search for board settings:
836  for( BOARD_STACKUP_ITEM* board_item: brd_stackup.GetList() )
837  {
838  if( item->GetBrdLayerId() != UNDEFINED_LAYER )
839  {
840  if( item->GetBrdLayerId() == board_item->GetBrdLayerId() )
841  {
842  *item = *board_item;
843  break;
844  }
845  }
846  else // dielectric layer: see m_DielectricLayerId for identification
847  {
848  // Compare dielectric layer with dielectric layer
849  if( board_item->GetBrdLayerId() != UNDEFINED_LAYER )
850  continue;
851 
852  if( item->GetDielectricLayerId() == board_item->GetDielectricLayerId() )
853  {
854  *item = *board_item;
855  break;
856  }
857  }
858  }
859  }
860  }
861 
862  int row = 0;
863 
864  for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() )
865  {
866  for( int sub_idx = 0; sub_idx < item->GetSublayersCount(); sub_idx++ )
867  {
868  BOARD_STACKUP_ROW_UI_ITEM ui_row_item = createRowData( row, item, sub_idx );
869  m_rowUiItemsList.emplace_back( ui_row_item );
870 
871  row++;
872  }
873  }
874 
875  updateIconColor();
876  m_scGridWin->Layout();
877 }
Manage layers needed to make a physical board.
BOARD_STACKUP & GetStackupDescriptor()
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.
BOARD_DESIGN_SETTINGS * m_brdSettings
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
void updateIconColor(int aRow=-1)
Update the icons color (swatches in first grid column)
void BuildDefaultStackupList(const BOARD_DESIGN_SETTINGS *aSettings, int aActiveCopperLayersCount=0)
Create a default stackup, according to the current BOARD_DESIGN_SETTINGS settings.
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References BOARD_STACKUP::BuildDefaultStackupList(), createRowData(), BOARD_DESIGN_SETTINGS::GetCopperLayerCount(), BOARD_STACKUP::GetList(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), m_brdSettings, m_rowUiItemsList, PANEL_SETUP_BOARD_STACKUP_BASE::m_scGridWin, m_stackup, UNDEFINED_LAYER, and updateIconColor().

Referenced by PANEL_SETUP_BOARD_STACKUP(), and rebuildLayerStackPanel().

◆ computeBoardThickness()

void PANEL_SETUP_BOARD_STACKUP::computeBoardThickness ( )
private

Recompute the board thickness and update the textbox.

Definition at line 321 of file panel_board_stackup.cpp.

322 {
323  int thickness = 0;
324 
326  {
327  BOARD_STACKUP_ITEM* item = ui_item.m_Item;
328 
329  if( !item->IsThicknessEditable() || !ui_item.m_isEnabled )
330  continue;
331 
332  wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_ThicknessCtrl );
333  wxString txt = textCtrl->GetValue();
334 
335  int item_thickness = ValueFromString( m_frame->GetUserUnits(), txt );
336  thickness += item_thickness;
337  }
338 
339  wxString thicknessStr = StringFromValue( m_units, thickness, true );
340 
341  // The text in the event will translate to the value for the text control
342  // and is only updated if it changed
343  m_tcCTValue->SetValue( thicknessStr );
344 }
bool IsThicknessEditable() const
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:402
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:190
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References EDA_BASE_FRAME::GetUserUnits(), BOARD_STACKUP_ITEM::IsThicknessEditable(), m_frame, m_rowUiItemsList, PANEL_SETUP_BOARD_STACKUP_BASE::m_tcCTValue, m_units, StringFromValue(), and ValueFromString().

Referenced by ImportSettingsFrom(), onAddDielectricLayer(), onRemoveDielectricLayer(), onThicknessChange(), and PANEL_SETUP_BOARD_STACKUP().

◆ createBmComboBox()

wxBitmapComboBox * PANEL_SETUP_BOARD_STACKUP::createBmComboBox ( BOARD_STACKUP_ITEM aStackupItem,
int  aRow 
)
private

creates a bitmap combobox to select a layer color

Returns
the created wxBitmapComboBox
Parameters
aStackupItem= the BOARD_STACKUP_ITEM realted to the bitmap combobox (to set the user color, if any) can be nullptr
aRow= the row index in the wxFlexGridSizer (used to build a wxWidget unique id)

Definition at line 1359 of file panel_board_stackup.cpp.

1361 {
1362  wxBitmapComboBox* combo = new wxBitmapComboBox( m_scGridWin, ID_ITEM_COLOR + aRow,
1363  wxEmptyString, wxDefaultPosition,
1364  wxDefaultSize, 0, nullptr, wxCB_READONLY );
1365 
1366  // Fills the combo box with choice list + bitmaps
1367  const FAB_LAYER_COLOR* color_list = GetColorStandardList();
1368 
1369  for( int ii = 0; ii < GetColorStandardListCount(); ii++ )
1370  {
1371  const FAB_LAYER_COLOR& item = color_list[ii];
1372 
1373  wxColor curr_color = item.m_Color;
1374  wxString label;
1375 
1376  // Defined colors have a name, the user color uses the HTML notation ( i.e. #FF0000)
1377  if( GetColorStandardListCount()-1 > (int)combo->GetCount() )
1378  {
1379  label = wxGetTranslation( item.m_ColorName );
1380  }
1381  else // Append the user color, if specified, else add a default user color
1382  {
1383  if( aStackupItem && aStackupItem->GetColor().StartsWith( "#" ) )
1384  curr_color = wxColour( aStackupItem->GetColor() );
1385 
1386  label = wxString::Format( _( "Custom (%s)" ),
1387  curr_color.GetAsString( wxC2S_HTML_SYNTAX ) );
1388  }
1389 
1390  wxBitmap layerbmp( m_colorSwatchesSize.x, m_colorSwatchesSize.y );
1391  LAYER_SELECTOR::DrawColorSwatch( layerbmp, COLOR4D( 0, 0, 0, 0 ), COLOR4D( curr_color ) );
1392 
1393  combo->Append( label, layerbmp );
1394  }
1395 
1396  // Ensure the size of the widget is enough to show the text and the icon
1397  // We have to have a selected item when doing this, because otherwise GTK
1398  // will just choose a random size that might not fit the actual data
1399  // (such as in cases where the font size is very large). So we select
1400  // the longest item (which should be the last item), and size it that way.
1401  int sel = combo->GetSelection();
1402  combo->SetSelection( combo->GetCount() - 1 );
1403 
1404  combo->SetMinSize( wxSize( -1, -1 ) );
1405  wxSize bestSize = combo->GetBestSize();
1406 
1407  bestSize.x = bestSize.x + m_colorSwatchesSize.x;
1408  combo->SetMinSize( bestSize );
1409  combo->SetSelection( sel );
1410 
1411  // add the wxBitmapComboBox to wxControl list, to be able to disconnect the event
1412  // on exit
1413  m_controlItemsList.push_back( combo );
1414 
1415  combo->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED,
1416  wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onColorSelected ),
1417  NULL, this );
1418 
1419  return combo;
1420 }
std::vector< wxControl * > m_controlItemsList
wxString GetColor() const
int GetColorStandardListCount()
#define NULL
static void DrawColorSwatch(wxBitmap &aLayerbmp, COLOR4D aBackground, COLOR4D aColor)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define _(s)
Definition: 3d_actions.cpp:33
const FAB_LAYER_COLOR * GetColorStandardList()
void onColorSelected(wxCommandEvent &event)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

References _, LAYER_SELECTOR::DrawColorSwatch(), Format(), BOARD_STACKUP_ITEM::GetColor(), GetColorStandardList(), GetColorStandardListCount(), ID_ITEM_COLOR, FAB_LAYER_COLOR::m_Color, FAB_LAYER_COLOR::m_ColorName, m_colorSwatchesSize, m_controlItemsList, PANEL_SETUP_BOARD_STACKUP_BASE::m_scGridWin, NULL, and onColorSelected().

Referenced by createRowData().

◆ createRowData()

BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData ( int  aRow,
BOARD_STACKUP_ITEM aStackupItem,
int  aSublayerIdx 
)
private

Creates a BOARD_STACKUP_ROW_UI_ITEM relative to the aStackupItem.

Returns
a BOARD_STACKUP_ROW_UI_ITEM filled with corresponding widgets
Parameters
aRowis the row index in the row list
aStackupItemis the stackup item controlled by the created BOARD_STACKUP_ROW_UI_ITEM.
aSublayerIdxis used only for BS_ITEM_TYPE_DIELECTRIC stackup items. this is the index of the sublayer to used inside aStackupItem (from 0 to sub layer count - 1)

Definition at line 572 of file panel_board_stackup.cpp.

575 {
576  wxASSERT( aStackupItem );
577  wxASSERT( aSublayerIdx >= 0 && aSublayerIdx < aStackupItem->GetSublayersCount() );
578 
579  BOARD_STACKUP_ROW_UI_ITEM ui_row_item( aStackupItem, aSublayerIdx );
580  BOARD_STACKUP_ITEM* item = aStackupItem;
581  int row = aRow;
582 
583  const FAB_LAYER_COLOR* color_list = GetColorStandardList();
584 
585  // Add color swatch icon. The color will be updated later,
586  // when all widgets are initialized
587  wxStaticBitmap* bitmap = new wxStaticBitmap( m_scGridWin, wxID_ANY, wxNullBitmap );
588  m_fgGridSizer->Add( bitmap, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 4 );
589  ui_row_item.m_Icon = bitmap;
590 
591  ui_row_item.m_isEnabled = true;
592 
593  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
594  {
595  wxString lname = item->FormatDielectricLayerName();
596 
597  if( item->GetSublayersCount() > 1 )
598  {
599  lname << " (" << aSublayerIdx+1 << "/" << item->GetSublayersCount() << ")";
600  }
601 
602  wxStaticText* st_text = new wxStaticText( m_scGridWin, wxID_ANY, lname );
603  m_fgGridSizer->Add( st_text, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
604  ui_row_item.m_LayerName = st_text;
605 
606  // For a dielectric layer, the layer type choice is not for each sublayer,
607  // only for the first (aSublayerIdx = 0), and is common to all sublayers
608  if( aSublayerIdx == 0 )
609  {
610  wxChoice* choice = new wxChoice( m_scGridWin, wxID_ANY, wxDefaultPosition,
611  wxDefaultSize, m_core_prepreg_choice );
612  choice->SetSelection( item->GetTypeName() == KEY_CORE ? 0 : 1 );
613  m_fgGridSizer->Add( choice, 1, wxEXPAND|wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
614 
615  ui_row_item.m_LayerTypeCtrl = choice;
616  }
617  else
618  {
619  ui_row_item.m_LayerTypeCtrl = addSpacer();
620  }
621  }
622  else
623  {
624  item->SetLayerName( m_board->GetLayerName( item->GetBrdLayerId() ) );
625  wxStaticText* st_text = new wxStaticText( m_scGridWin, wxID_ANY, item->GetLayerName() );
626  m_fgGridSizer->Add( st_text, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 1 );
627  st_text->Show( true );
628  ui_row_item.m_LayerName = st_text;
629 
630  wxString lname;
631 
632  if( item->GetTypeName() == KEY_COPPER )
633  lname = _( "Copper" );
634  else
635  lname = wxGetTranslation( item->GetTypeName() );
636 
637  st_text = new wxStaticText( m_scGridWin, wxID_ANY, lname );
638  m_fgGridSizer->Add( st_text, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
639  ui_row_item.m_LayerTypeCtrl = st_text;
640  }
641 
642  if( item->IsMaterialEditable() )
643  {
644  wxString matName = item->GetMaterial( aSublayerIdx );
645  addMaterialChooser( ID_ITEM_MATERIAL+row, &matName, ui_row_item );
646  }
647  else
648  {
649  ui_row_item.m_MaterialCtrl = addSpacer();
650  }
651 
652  if( item->IsThicknessEditable() )
653  {
654  wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, ID_ITEM_THICKNESS+row );
655  textCtrl->SetMinSize( m_numericTextCtrlSize );
656  textCtrl->SetValue( StringFromValue( m_units, item->GetThickness( aSublayerIdx ), true ) );
657  m_fgGridSizer->Add( textCtrl, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
658  m_controlItemsList.push_back( textCtrl );
659  textCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED,
660  wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onThicknessChange ),
661  NULL, this );
662  ui_row_item.m_ThicknessCtrl = textCtrl;
663 
664  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
665  {
666  wxCheckBox* cb_box = new wxCheckBox( m_scGridWin, ID_ITEM_THICKNESS_LOCKED+row,
667  wxEmptyString );
668  cb_box->SetValue( item->IsThicknessLocked( aSublayerIdx ) );
669  m_fgGridSizer->Add( cb_box, 0, wxALIGN_CENTER_VERTICAL, 2 );
670  ui_row_item.m_ThicknessLockCtrl = cb_box;
671  }
672  else
673  {
674  ui_row_item.m_ThicknessLockCtrl = addSpacer();
675  }
676  }
677  else
678  {
679  ui_row_item.m_ThicknessCtrl = addSpacer();
680  ui_row_item.m_ThicknessLockCtrl = addSpacer();
681  }
682 
683  if( item->IsColorEditable() )
684  {
685  int color_idx = 0;
686  int user_color_idx = GetColorUserDefinedListIdx();
687 
688  // Always init the user-defined color for a row
689  ui_row_item.m_UserColor = GetColorStandardList()[user_color_idx].m_Color;
690 
691  if( item->GetColor().StartsWith( "#" ) ) // User defined color
692  {
693  wxColour color( item->GetColor() );
694  ui_row_item.m_UserColor = color;
695  color_idx = user_color_idx;
696  }
697  else
698  {
699  for( int ii = 0; ii < GetColorStandardListCount(); ii++ )
700  {
701  if( color_list[ii].m_ColorName == item->GetColor() )
702  {
703  color_idx = ii;
704  break;
705  }
706  }
707  }
708 
709  wxBitmapComboBox* bm_combo = createBmComboBox( item, row );
710  m_fgGridSizer->Add( bm_combo, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
711  bm_combo->SetSelection( color_idx );
712  ui_row_item.m_ColorCtrl = bm_combo;
713  }
714  else
715  {
716  ui_row_item.m_ColorCtrl = addSpacer();
717  }
718 
719  if( item->HasEpsilonRValue() )
720  {
721  wxString txt;
722  txt.Printf( "%.2f", item->GetEpsilonR( aSublayerIdx ) );
723  wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, wxID_ANY, wxEmptyString,
724  wxDefaultPosition, m_numericFieldsSize );
725  textCtrl->SetValue( txt );
726  m_fgGridSizer->Add( textCtrl, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
727  ui_row_item.m_EpsilonCtrl = textCtrl;
728  }
729  else
730  {
731  ui_row_item.m_EpsilonCtrl = addSpacer();
732  }
733 
734  if( item->HasLossTangentValue() )
735  {
736  wxString txt;
737  txt.Printf( "%g", item->GetLossTangent( aSublayerIdx ) );
738  wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, wxID_ANY, wxEmptyString,
739  wxDefaultPosition, m_numericFieldsSize );
740  textCtrl->SetValue( txt );
741  m_fgGridSizer->Add( textCtrl, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
742  ui_row_item.m_LossTgCtrl = textCtrl;
743  }
744  else
745  {
746  ui_row_item.m_LossTgCtrl = addSpacer();
747  }
748 
749  return ui_row_item;
750 }
BOARD_STACKUP_ITEM_TYPE GetType() const
std::vector< wxControl * > m_controlItemsList
bool HasEpsilonRValue() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:342
int GetSublayersCount() const
int color
Definition: DXF_plotter.cpp:60
bool IsThicknessLocked(int aDielectricSubLayer=0) const
wxBitmapComboBox * createBmComboBox(BOARD_STACKUP_ITEM *aStackupItem, int aRow)
creates a bitmap combobox to select a layer color
#define KEY_COPPER
wxString GetColor() const
int GetColorStandardListCount()
int GetColorUserDefinedListIdx()
double GetLossTangent(int aDielectricSubLayer=0) const
void SetLayerName(const wxString &aName)
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
bool IsThicknessEditable() const
void onThicknessChange(wxCommandEvent &event)
#define NULL
int GetThickness(int aDielectricSubLayer=0) const
bool IsColorEditable() const
bool HasLossTangentValue() const
double GetEpsilonR(int aDielectricSubLayer=0) const
bool IsMaterialEditable() const
wxString GetTypeName() const
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
PCB_LAYER_ID GetBrdLayerId() const
wxString GetLayerName() const
wxControl * addSpacer()
add a Spacer in m_fgGridSizer when a empty cell is needed
#define _(s)
Definition: 3d_actions.cpp:33
const FAB_LAYER_COLOR * GetColorStandardList()
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:190
#define KEY_CORE
wxString GetMaterial(int aDielectricSubLayer=0) const
wxString FormatDielectricLayerName() const

References _, addMaterialChooser(), addSpacer(), BS_ITEM_TYPE_DIELECTRIC, color, createBmComboBox(), BOARD_STACKUP_ITEM::FormatDielectricLayerName(), BOARD_STACKUP_ITEM::GetBrdLayerId(), BOARD_STACKUP_ITEM::GetColor(), GetColorStandardList(), GetColorStandardListCount(), GetColorUserDefinedListIdx(), BOARD_STACKUP_ITEM::GetEpsilonR(), BOARD_STACKUP_ITEM::GetLayerName(), BOARD::GetLayerName(), BOARD_STACKUP_ITEM::GetLossTangent(), BOARD_STACKUP_ITEM::GetMaterial(), BOARD_STACKUP_ITEM::GetSublayersCount(), BOARD_STACKUP_ITEM::GetThickness(), BOARD_STACKUP_ITEM::GetType(), BOARD_STACKUP_ITEM::GetTypeName(), BOARD_STACKUP_ITEM::HasEpsilonRValue(), BOARD_STACKUP_ITEM::HasLossTangentValue(), ID_ITEM_MATERIAL, ID_ITEM_THICKNESS, ID_ITEM_THICKNESS_LOCKED, BOARD_STACKUP_ITEM::IsColorEditable(), BOARD_STACKUP_ITEM::IsMaterialEditable(), BOARD_STACKUP_ITEM::IsThicknessEditable(), BOARD_STACKUP_ITEM::IsThicknessLocked(), KEY_COPPER, KEY_CORE, m_board, FAB_LAYER_COLOR::m_Color, BOARD_STACKUP_ROW_UI_ITEM::m_ColorCtrl, m_controlItemsList, m_core_prepreg_choice, BOARD_STACKUP_ROW_UI_ITEM::m_EpsilonCtrl, PANEL_SETUP_BOARD_STACKUP_BASE::m_fgGridSizer, BOARD_STACKUP_ROW_UI_ITEM::m_Icon, BOARD_STACKUP_ROW_UI_ITEM::m_isEnabled, BOARD_STACKUP_ROW_UI_ITEM::m_LayerName, BOARD_STACKUP_ROW_UI_ITEM::m_LayerTypeCtrl, BOARD_STACKUP_ROW_UI_ITEM::m_LossTgCtrl, BOARD_STACKUP_ROW_UI_ITEM::m_MaterialCtrl, m_numericFieldsSize, m_numericTextCtrlSize, PANEL_SETUP_BOARD_STACKUP_BASE::m_scGridWin, BOARD_STACKUP_ROW_UI_ITEM::m_ThicknessCtrl, BOARD_STACKUP_ROW_UI_ITEM::m_ThicknessLockCtrl, m_units, BOARD_STACKUP_ROW_UI_ITEM::m_UserColor, NULL, onThicknessChange(), BOARD_STACKUP_ITEM::SetLayerName(), and StringFromValue().

Referenced by buildLayerStackPanel().

◆ disconnectEvents()

void PANEL_SETUP_BOARD_STACKUP::disconnectEvents ( )
private

disconnect event handlers connected to wxControl items found in list m_controlItemsList

Definition at line 135 of file panel_board_stackup.cpp.

136 {
137  // Disconnect Events connected to items in m_controlItemsList
138  for( wxControl* item: m_controlItemsList )
139  {
140  wxBitmapComboBox* cb = dynamic_cast<wxBitmapComboBox*>( item );
141 
142  if( cb )
143  cb->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED,
144  wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onColorSelected ),
145  NULL, this );
146 
147  wxButton* matButt = dynamic_cast<wxButton*>( item );
148 
149  if( matButt )
150  matButt->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
151  wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onMaterialChange ),
152  NULL, this );
153 
154  wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( item );
155 
156  if( textCtrl )
157  textCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED,
158  wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onThicknessChange ),
159  NULL, this );
160  }
161 }
std::vector< wxControl * > m_controlItemsList
void onThicknessChange(wxCommandEvent &event)
#define NULL
void onColorSelected(wxCommandEvent &event)
void onMaterialChange(wxCommandEvent &event)

References m_controlItemsList, NULL, onColorSelected(), onMaterialChange(), and onThicknessChange().

Referenced by rebuildLayerStackPanel(), and ~PANEL_SETUP_BOARD_STACKUP().

◆ getColorIconItem()

wxColor PANEL_SETUP_BOARD_STACKUP::getColorIconItem ( int  aRow)
private
Returns
the color of the BOARD_STACKUP_ITEM at row aRow, to draw a bitmap color according to the selected color or the best default color (for dielectric or copper item)
Parameters
aRowis the row index to find the color.

Definition at line 1306 of file panel_board_stackup.cpp.

1307 {
1308  BOARD_STACKUP_ITEM* st_item = dynamic_cast<BOARD_STACKUP_ITEM*>( GetStackupItem( aRow ) );
1309 
1310  wxASSERT( st_item );
1311  wxColor color;
1312 
1313  if( ! st_item )
1314  return color;
1315 
1316  switch( st_item->GetType() )
1317  {
1318  case BS_ITEM_TYPE_COPPER: color = copperColor; break;
1320  case BS_ITEM_TYPE_SOLDERMASK: color = GetSelectedColor( aRow ); break;
1321  case BS_ITEM_TYPE_SILKSCREEN: color = GetSelectedColor( aRow ); break;
1322  case BS_ITEM_TYPE_SOLDERPASTE: color = pasteColor; break;
1323 
1324  default:
1326  wxFAIL_MSG( "PANEL_SETUP_BOARD_STACKUP::getColorIconItem: unrecognized item type" );
1327  break;
1328  }
1329 
1330  wxASSERT_MSG( color.IsOk(), "Invalid color in PCB stackup" );
1331 
1332  return color;
1333 }
BOARD_STACKUP_ITEM_TYPE GetType() const
static wxColor pasteColor(200, 200, 200)
int color
Definition: DXF_plotter.cpp:60
static wxColor dielectricColor(75, 120, 75)
BOARD_STACKUP_ITEM * GetStackupItem(int aRow)
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
static wxColor copperColor(220, 180, 30)
wxColor GetSelectedColor(int aRow) const
Return the color currently selected for the row aRow.

References BS_ITEM_TYPE_COPPER, BS_ITEM_TYPE_DIELECTRIC, BS_ITEM_TYPE_SILKSCREEN, BS_ITEM_TYPE_SOLDERMASK, BS_ITEM_TYPE_SOLDERPASTE, BS_ITEM_TYPE_UNDEFINED, color, copperColor(), dielectricColor(), GetSelectedColor(), GetStackupItem(), BOARD_STACKUP_ITEM::GetType(), and pasteColor().

Referenced by updateIconColor().

◆ GetCopperLayerCount()

int PANEL_SETUP_BOARD_STACKUP::GetCopperLayerCount ( ) const
Returns
the number of copper layers configured for the board stackup

Definition at line 347 of file panel_board_stackup.cpp.

348 {
349  return ( m_choiceCopperLayers->GetSelection() + 1 ) * 2;
350 }

References PANEL_SETUP_BOARD_STACKUP_BASE::m_choiceCopperLayers.

Referenced by DIALOG_BOARD_SETUP::OnPageChange(), PANEL_SETUP_LAYERS::TransferDataFromWindow(), and updateCopperLayerCount().

◆ GetPcbThickness()

int PANEL_SETUP_BOARD_STACKUP::GetPcbThickness ( )

◆ GetSelectedColor()

wxColor PANEL_SETUP_BOARD_STACKUP::GetSelectedColor ( int  aRow) const

Return the color currently selected for the row aRow.

Definition at line 307 of file panel_board_stackup.cpp.

308 {
309  wxBitmapComboBox* choice = dynamic_cast<wxBitmapComboBox*>( m_rowUiItemsList[aRow].m_ColorCtrl );
310  wxASSERT( choice );
311 
312  int idx = choice ? choice->GetSelection() : 0;
313 
314  if( idx != GetColorUserDefinedListIdx() ) // a standard color is selected
315  return GetColorStandardList()[idx].m_Color;
316 
317  return m_rowUiItemsList[aRow].m_UserColor;
318 }
int GetColorUserDefinedListIdx()
const FAB_LAYER_COLOR * GetColorStandardList()
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References GetColorStandardList(), GetColorUserDefinedListIdx(), FAB_LAYER_COLOR::m_Color, and m_rowUiItemsList.

Referenced by getColorIconItem().

◆ GetStackup()

BOARD_STACKUP& PANEL_SETUP_BOARD_STACKUP::GetStackup ( )
inline

Definition at line 117 of file panel_board_stackup.h.

117 { return m_stackup; }

References m_stackup.

◆ GetStackupItem()

BOARD_STACKUP_ITEM * PANEL_SETUP_BOARD_STACKUP::GetStackupItem ( int  aRow)
Returns
the BOARD_STACKUP_ITEM managed by the row aRow

Definition at line 1294 of file panel_board_stackup.cpp.

1295 {
1296  return m_rowUiItemsList[aRow].m_Item;
1297 }
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References m_rowUiItemsList.

Referenced by getColorIconItem(), and onThicknessChange().

◆ GetSublayerId()

int PANEL_SETUP_BOARD_STACKUP::GetSublayerId ( int  aRow)
Returns
the BOARD_STACKUP_ITEM sublayermanaged by the row aRow

Definition at line 1300 of file panel_board_stackup.cpp.

1301 {
1302  return m_rowUiItemsList[aRow].m_SubItem;
1303 }
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References m_rowUiItemsList.

Referenced by onThicknessChange().

◆ ImportSettingsFrom()

void PANEL_SETUP_BOARD_STACKUP::ImportSettingsFrom ( BOARD aBoard)

Definition at line 1105 of file panel_board_stackup.cpp.

1106 {
1107  BOARD* savedBrd = m_board;
1108  BOARD_DESIGN_SETTINGS* savedSettings = m_brdSettings;
1109  m_brdSettings = &aBoard->GetDesignSettings();
1110 
1112  synchronizeWithBoard( true );
1113 
1114  m_brdSettings = savedSettings;
1115  m_board = savedBrd;
1116 
1119 }
PANEL_SETUP_LAYERS * m_panelLayers
void computeBoardThickness()
Recompute the board thickness and update the textbox.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
void synchronizeWithBoard(bool aFullSync)
Synchronize the full stackup shown in m_fgGridSizer according to the stackup of the current board and...
static LSET StackupAllowedBrdLayers()
BOARD_DESIGN_SETTINGS * m_brdSettings
void rebuildLayerStackPanel()
Populate m_fgGridSizer with items to handle stackup parameters If previous items are in list,...
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
Container for design settings for a BOARD object.

References computeBoardThickness(), BOARD::GetDesignSettings(), PANEL_SETUP_LAYERS::GetUILayerMask(), m_board, m_brdSettings, m_enabledLayers, m_panelLayers, rebuildLayerStackPanel(), BOARD_STACKUP::StackupAllowedBrdLayers(), and synchronizeWithBoard().

Referenced by DIALOG_BOARD_SETUP::OnAuxiliaryAction().

◆ onAddDielectricLayer()

void PANEL_SETUP_BOARD_STACKUP::onAddDielectricLayer ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_BOARD_STACKUP_BASE.

Definition at line 164 of file panel_board_stackup.cpp.

165 {
166  // Build Dielectric layers list:
167  wxArrayString d_list;
168  std::vector<int> rows; // indexes of row values for each selectable item
169  int row = -1;
170 
172  {
173  row++;
174 
175  if( !item.m_isEnabled )
176  continue;
177 
178  BOARD_STACKUP_ITEM* brd_stackup_item = item.m_Item;
179 
180  if( brd_stackup_item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
181  {
182  if( brd_stackup_item->GetSublayersCount() > 1 )
183  {
184  d_list.Add( wxString::Format( _( "Layer \"%s\" (sublayer %d/%d)" ),
185  brd_stackup_item->FormatDielectricLayerName(),
186  item.m_SubItem+1, brd_stackup_item->GetSublayersCount() ) );
187  }
188  else
189  d_list.Add( brd_stackup_item->FormatDielectricLayerName() );
190 
191  rows.push_back( row );
192  }
193  }
194 
195  // Show list
196  int index = wxGetSingleChoiceIndex( _( "Select dielectric layer to add to board stack up." ),
197  _("Dielectric Layers List"),
198  d_list);
199 
200  if( index < 0 )
201  return;
202 
203  row = rows[index];
204 
205  BOARD_STACKUP_ITEM* brd_stackup_item = m_rowUiItemsList[row].m_Item;
206  int new_sublayer = m_rowUiItemsList[row].m_SubItem;
207 
208  // Insert a new item after the selected item
209  brd_stackup_item->AddDielectricPrms( new_sublayer+1 );
210 
213 }
BOARD_STACKUP_ITEM_TYPE GetType() const
int GetSublayersCount() const
void computeBoardThickness()
Recompute the board thickness and update the textbox.
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,...
void AddDielectricPrms(int aDielectricPrmsIdx)
Add (insert) a DIELECTRIC_PRMS item to m_DielectricPrmsList all values are set to default.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define _(s)
Definition: 3d_actions.cpp:33
wxString FormatDielectricLayerName() const
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References _, BOARD_STACKUP_ITEM::AddDielectricPrms(), BS_ITEM_TYPE_DIELECTRIC, computeBoardThickness(), Format(), BOARD_STACKUP_ITEM::FormatDielectricLayerName(), BOARD_STACKUP_ITEM::GetSublayersCount(), BOARD_STACKUP_ITEM::GetType(), m_rowUiItemsList, and rebuildLayerStackPanel().

◆ onColorSelected()

void PANEL_SETUP_BOARD_STACKUP::onColorSelected ( wxCommandEvent &  event)
private

Definition at line 1144 of file panel_board_stackup.cpp.

1145 {
1146  int idx = event.GetSelection();
1147  int item_id = event.GetId();
1148 
1149  int row = item_id - ID_ITEM_COLOR;
1150 
1151  if( GetColorStandardListCount()-1 == idx ) // Set user color is the last option in list
1152  {
1153  wxColour userColour = m_rowUiItemsList[row].m_UserColor;
1154  COLOR4D currentColor( userColour.IsOk() ? userColour : COLOR4D( 0.5, 0.5, 0.5, 1.0 ) );
1155  COLOR4D defaultColor( GetColorStandardList()[GetColorUserDefinedListIdx()].m_Color );
1156 
1157  DIALOG_COLOR_PICKER dlg( this, currentColor, false, nullptr, defaultColor );
1158 
1159  // Give a time-slice to close the menu before opening the dialog.
1160  // (Only matters on some versions of GTK.)
1161  wxSafeYield();
1162 
1163  if( dlg.ShowModal() == wxID_OK )
1164  {
1165  wxBitmapComboBox* combo = static_cast<wxBitmapComboBox*>( FindWindowById( item_id ) );
1166 
1167  wxColour color = dlg.GetColor().ToColour();
1168 
1169  m_rowUiItemsList[row].m_UserColor = color;
1170 
1171  wxString label = wxString::Format( _( "Custom (%s)" ),
1172  color.GetAsString( wxC2S_HTML_SYNTAX ) );
1173 
1174  combo->SetString( idx, label );
1175 
1176  wxBitmap layerbmp( m_colorSwatchesSize.x, m_colorSwatchesSize.y );
1177  LAYER_SELECTOR::DrawColorSwatch( layerbmp, COLOR4D( 0, 0, 0, 0 ),
1178  COLOR4D( color ) );
1179  combo->SetItemBitmap( combo->GetCount()-1, layerbmp );
1180  }
1181  }
1182 
1183  updateIconColor( row );
1184 }
int color
Definition: DXF_plotter.cpp:60
int GetColorStandardListCount()
int GetColorUserDefinedListIdx()
static void DrawColorSwatch(wxBitmap &aLayerbmp, COLOR4D aBackground, COLOR4D aColor)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define _(s)
Definition: 3d_actions.cpp:33
const FAB_LAYER_COLOR * GetColorStandardList()
void updateIconColor(int aRow=-1)
Update the icons color (swatches in first grid column)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References _, color, LAYER_SELECTOR::DrawColorSwatch(), Format(), DIALOG_COLOR_PICKER::GetColor(), GetColorStandardList(), GetColorStandardListCount(), GetColorUserDefinedListIdx(), ID_ITEM_COLOR, m_colorSwatchesSize, m_rowUiItemsList, and updateIconColor().

Referenced by createBmComboBox(), and disconnectEvents().

◆ onExportToClipboard()

void PANEL_SETUP_BOARD_STACKUP::onExportToClipboard ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_BOARD_STACKUP_BASE.

Definition at line 287 of file panel_board_stackup.cpp.

288 {
290  return;
291 
292  // Build a ascii representation of stackup and copy it in the clipboard
293  wxString report = BuildStackupReport( m_stackup, m_units );
294 
295  wxLogNull doNotLog; // disable logging of failed clipboard actions
296 
297  if( wxTheClipboard->Open() )
298  {
299  // This data objects are held by the clipboard,
300  // so do not delete them in the app.
301  wxTheClipboard->SetData( new wxTextDataObject( report ) );
302  wxTheClipboard->Close();
303  }
304 }
wxString BuildStackupReport(BOARD_STACKUP &aStackup, EDA_UNITS aUnits)
bool transferDataFromUIToStackup()
Transfer current UI settings to m_stackup but not to the board.

References BuildStackupReport(), m_stackup, m_units, and transferDataFromUIToStackup().

◆ OnLayersOptionsChanged()

void PANEL_SETUP_BOARD_STACKUP::OnLayersOptionsChanged ( LSET  aNewLayerSet)

Must be called if the copper layers count has changed or solder mask, solder paste or silkscreen layers are enabled or disabled Rebuild the Layer Stack Panel if the new layer set differs from the current layet set.

Definition at line 1122 of file panel_board_stackup.cpp.

1123 {
1124  // First, verify the list of layers currently in stackup:
1125  // if it does not mach the list of layers set in PANEL_SETUP_LAYERS
1126  // rebuild the panel
1127 
1128  // the current enabled layers in PANEL_SETUP_LAYERS
1129  // Note: the number of layer can change, but not the layers properties
1131 
1132  if( m_enabledLayers != layersList )
1133  {
1134  m_enabledLayers = layersList;
1135 
1136  synchronizeWithBoard( false );
1137 
1138  Layout();
1139  Refresh();
1140  }
1141 }
PANEL_SETUP_LAYERS * m_panelLayers
LSET is a set of PCB_LAYER_IDs.
void synchronizeWithBoard(bool aFullSync)
Synchronize the full stackup shown in m_fgGridSizer according to the stackup of the current board and...
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
static LSET StackupAllowedBrdLayers()

References PANEL_SETUP_LAYERS::GetUILayerMask(), m_enabledLayers, m_panelLayers, Refresh(), BOARD_STACKUP::StackupAllowedBrdLayers(), and synchronizeWithBoard().

Referenced by DIALOG_BOARD_SETUP::OnPageChange(), and transferDataFromUIToStackup().

◆ onMaterialChange()

void PANEL_SETUP_BOARD_STACKUP::onMaterialChange ( wxCommandEvent &  event)
private

Definition at line 1187 of file panel_board_stackup.cpp.

1188 {
1189  // Ensure m_materialList contains all materials already in use in stackup list
1190  // and add it is missing
1192  return;
1193 
1194  for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() )
1195  {
1196  DIELECTRIC_SUBSTRATE_LIST* mat_list = nullptr;
1197 
1198  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
1199  mat_list = &m_delectricMatList;
1200  else if( item->GetType() == BS_ITEM_TYPE_SOLDERMASK )
1201  mat_list = &m_solderMaskMatList;
1202  else if( item->GetType() == BS_ITEM_TYPE_SILKSCREEN )
1203  mat_list = &m_silkscreenMatList;
1204 
1205  else
1206  continue;
1207 
1208  for( int ii = 0; ii < item->GetSublayersCount(); ii++ )
1209  {
1210  int idx = mat_list->FindSubstrate( item->GetMaterial( ii ),
1211  item->GetEpsilonR( ii ),
1212  item->GetLossTangent( ii ) );
1213 
1214  if( idx < 0 && !item->GetMaterial().IsEmpty() )
1215  {
1216  // This material is not in list: add it
1217  DIELECTRIC_SUBSTRATE new_mat;
1218  new_mat.m_Name = item->GetMaterial( ii );
1219  new_mat.m_EpsilonR = item->GetEpsilonR( ii );
1220  new_mat.m_LossTangent = item->GetLossTangent( ii );
1221  mat_list->AppendSubstrate( new_mat );
1222  }
1223  }
1224  }
1225 
1226  int row = event.GetId() - ID_ITEM_MATERIAL;
1227  BOARD_STACKUP_ITEM* item = m_rowUiItemsList[row].m_Item;
1228  int sub_item = m_rowUiItemsList[row].m_SubItem;
1229  DIELECTRIC_SUBSTRATE_LIST* item_mat_list = nullptr;
1230 
1231  switch( item->GetType() )
1232  {
1233  case BS_ITEM_TYPE_DIELECTRIC: item_mat_list = &m_delectricMatList; break;
1234  case BS_ITEM_TYPE_SOLDERMASK: item_mat_list = &m_solderMaskMatList; break;
1235  case BS_ITEM_TYPE_SILKSCREEN: item_mat_list = &m_silkscreenMatList; break;
1236  default: item_mat_list = nullptr; break;
1237  }
1238 
1239  wxCHECK( item_mat_list, /* void */ );
1240 
1241  DIALOG_DIELECTRIC_MATERIAL dlg( this, *item_mat_list );
1242 
1243  if( dlg.ShowModal() != wxID_OK )
1244  return;
1245 
1246  DIELECTRIC_SUBSTRATE substrate = dlg.GetSelectedSubstrate();
1247 
1248  if( substrate.m_Name.IsEmpty() ) // No substrate specified
1249  return;
1250 
1251  // Update Name, Epsilon R and Loss tg
1252  item->SetMaterial( substrate.m_Name, sub_item );
1253  item->SetEpsilonR( substrate.m_EpsilonR, sub_item );
1254  item->SetLossTangent( substrate.m_LossTangent, sub_item );
1255 
1256  wxTextCtrl* textCtrl;
1257  textCtrl = static_cast<wxTextCtrl*>( m_rowUiItemsList[row].m_MaterialCtrl );
1258  textCtrl->SetValue( item->GetMaterial( sub_item ) );
1259 
1260  // some layers have a material choice but not EpsilonR ctrl
1261  if( item->HasEpsilonRValue() )
1262  {
1263  textCtrl = dynamic_cast<wxTextCtrl*>( m_rowUiItemsList[row].m_EpsilonCtrl );
1264 
1265  if( textCtrl )
1266  textCtrl->SetValue( item->FormatEpsilonR( sub_item ) );
1267  }
1268 
1269  // some layers have a material choice but not loss tg ctrl
1270  if( item->HasLossTangentValue() )
1271  {
1272  textCtrl = dynamic_cast<wxTextCtrl*>( m_rowUiItemsList[row].m_LossTgCtrl );
1273 
1274  if( textCtrl )
1275  textCtrl->SetValue( item->FormatLossTangent( sub_item ) );
1276  }
1277 }
BOARD_STACKUP_ITEM_TYPE GetType() const
bool HasEpsilonRValue() const
a Dialog to select/change/add a dielectric material from a material list
int AppendSubstrate(DIELECTRIC_SUBSTRATE &aItem)
Append a item in list similar to aItem.
DIELECTRIC_SUBSTRATE_LIST m_silkscreenMatList
DIELECTRIC_SUBSTRATE_LIST m_solderMaskMatList
bool HasLossTangentValue() const
wxString FormatEpsilonR(int aDielectricSubLayer=0) const
wxString FormatLossTangent(int aDielectricSubLayer=0) const
void SetMaterial(const wxString &aName, int aDielectricSubLayer=0)
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
void SetEpsilonR(double aEpsilon, int aDielectricSubLayer=0)
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
int FindSubstrate(DIELECTRIC_SUBSTRATE *aItem)
Find a item in list similar to aItem.
bool transferDataFromUIToStackup()
Transfer current UI settings to m_stackup but not to the board.
DIELECTRIC_SUBSTRATE_LIST m_delectricMatList
void SetLossTangent(double aTg, int aDielectricSubLayer=0)
wxString GetMaterial(int aDielectricSubLayer=0) const
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References DIELECTRIC_SUBSTRATE_LIST::AppendSubstrate(), BS_ITEM_TYPE_DIELECTRIC, BS_ITEM_TYPE_SILKSCREEN, BS_ITEM_TYPE_SOLDERMASK, DIELECTRIC_SUBSTRATE_LIST::FindSubstrate(), BOARD_STACKUP_ITEM::FormatEpsilonR(), BOARD_STACKUP_ITEM::FormatLossTangent(), BOARD_STACKUP::GetList(), BOARD_STACKUP_ITEM::GetMaterial(), DIALOG_DIELECTRIC_MATERIAL::GetSelectedSubstrate(), BOARD_STACKUP_ITEM::GetType(), BOARD_STACKUP_ITEM::HasEpsilonRValue(), BOARD_STACKUP_ITEM::HasLossTangentValue(), ID_ITEM_MATERIAL, m_delectricMatList, DIELECTRIC_SUBSTRATE::m_EpsilonR, DIELECTRIC_SUBSTRATE::m_LossTangent, DIELECTRIC_SUBSTRATE::m_Name, m_rowUiItemsList, m_silkscreenMatList, m_solderMaskMatList, m_stackup, BOARD_STACKUP_ITEM::SetEpsilonR(), BOARD_STACKUP_ITEM::SetLossTangent(), BOARD_STACKUP_ITEM::SetMaterial(), and transferDataFromUIToStackup().

Referenced by addMaterialChooser(), and disconnectEvents().

◆ onRemoveDielectricLayer()

void PANEL_SETUP_BOARD_STACKUP::onRemoveDielectricLayer ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_BOARD_STACKUP_BASE.

Definition at line 216 of file panel_board_stackup.cpp.

217 {
218  // Build deletable Dielectric layers list.
219  // A layer can be deleted if there are 2 (or more) dielectric sub-layers
220  // between 2 copper layers
221  wxArrayString d_list;
222  std::vector<int> rows; // indexes of row values for each selectable item
223 
224  int ui_row = 0; // The row index in m_rowUiItemsList of items in choice list
225 
226  // Build the list of dielectric layers:
227  for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() )
228  {
229  if( !item->IsEnabled() || item->GetType() != BS_ITEM_TYPE_DIELECTRIC ||
230  item->GetSublayersCount() <= 1 )
231  {
232  ui_row++;
233  continue;
234  }
235 
236  for( int ii = 0; ii < item->GetSublayersCount(); ii++ )
237  {
238  d_list.Add( wxString::Format( "Layer \"%s\" sublayer %d/%d",
239  item->FormatDielectricLayerName(), ii+1,
240  item->GetSublayersCount() ) );
241 
242  rows.push_back( ui_row++ );
243  }
244  }
245 
246  // Show choice list
247  int index = wxGetSingleChoiceIndex( _( "Select dielectric layer to remove from board stack up." ),
248  _( "Dielectric Layers" ),
249  d_list );
250 
251  if( index < 0 )
252  return;
253 
254  ui_row = rows[index];
255 
256  BOARD_STACKUP_ITEM* brd_stackup_item = m_rowUiItemsList[ui_row].m_Item;
257  int sublayer = m_rowUiItemsList[ui_row].m_SubItem;
258 
259  // Remove the selected sub item for the selected dielectric layer
260  brd_stackup_item->RemoveDielectricPrms( sublayer );
261 
264 }
void computeBoardThickness()
Recompute the board thickness and update the textbox.
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,...
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define _(s)
Definition: 3d_actions.cpp:33
void RemoveDielectricPrms(int aDielectricPrmsIdx)
Remove a DIELECTRIC_PRMS item from m_DielectricPrmsList.
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References _, BS_ITEM_TYPE_DIELECTRIC, computeBoardThickness(), Format(), BOARD_STACKUP::GetList(), m_rowUiItemsList, m_stackup, rebuildLayerStackPanel(), and BOARD_STACKUP_ITEM::RemoveDielectricPrms().

◆ onRemoveDielUI()

void PANEL_SETUP_BOARD_STACKUP::onRemoveDielUI ( wxUpdateUIEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_BOARD_STACKUP_BASE.

Definition at line 267 of file panel_board_stackup.cpp.

268 {
269  // The m_buttonRemoveDielectricLayer wxButton is enabled only if a dielectric
270  // layer can be removed, i.e. if dielectric layers have sublayers
271  for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() )
272  {
273  if( !item->IsEnabled() || item->GetType() != BS_ITEM_TYPE_DIELECTRIC )
274  continue;
275 
276  if( item->GetSublayersCount() > 1 )
277  {
278  event.Enable( true );
279  return;
280  }
281  }
282 
283  event.Enable( false );
284 }
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const

References BS_ITEM_TYPE_DIELECTRIC, BOARD_STACKUP::GetList(), and m_stackup.

◆ onThicknessChange()

void PANEL_SETUP_BOARD_STACKUP::onThicknessChange ( wxCommandEvent &  event)
private

Definition at line 1280 of file panel_board_stackup.cpp.

1281 {
1282  int row = event.GetId() - ID_ITEM_THICKNESS;
1283  wxString value = event.GetString();
1284 
1285  BOARD_STACKUP_ITEM* item = GetStackupItem( row );
1286  int idx = GetSublayerId( row );
1287 
1288  item->SetThickness( ValueFromString( m_frame->GetUserUnits(), value ), idx );
1289 
1291 }
void computeBoardThickness()
Recompute the board thickness and update the textbox.
BOARD_STACKUP_ITEM * GetStackupItem(int aRow)
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:402
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
void SetThickness(int aThickness, int aDielectricSubLayer=0)
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References computeBoardThickness(), GetStackupItem(), GetSublayerId(), EDA_BASE_FRAME::GetUserUnits(), ID_ITEM_THICKNESS, m_frame, BOARD_STACKUP_ITEM::SetThickness(), and ValueFromString().

Referenced by createRowData(), and disconnectEvents().

◆ rebuildLayerStackPanel()

void PANEL_SETUP_BOARD_STACKUP::rebuildLayerStackPanel ( )
private

Populate m_fgGridSizer with items to handle stackup parameters If previous items are in list, remove old items New prms are added must be called after adding or deleting a dielectric parameter set.

Definition at line 753 of file panel_board_stackup.cpp.

754 {
755  // Rebuild the stackup for the dialog, after dielectric parameters list is modified
756  // (added/removed):
757 
758  // First, delete all ui objects, because wxID values will be no longer valid for many widgets
760  m_controlItemsList.clear();
761 
762  // Delete widgets (handled by the wxPanel parent)
764  {
765  // This remove and delete the current ui_item.m_MaterialCtrl sizer
766  ui_item.m_MaterialCtrl->SetSizer( nullptr );
767 
768  // Delete other widgets
769  delete ui_item.m_Icon; // Color icon in first column (column 1)
770  delete ui_item.m_LayerName; // string shown in column 2
771  delete ui_item.m_LayerTypeCtrl; // control shown in column 3
772  delete ui_item.m_MaterialCtrl; // control shown in column 4, with m_MaterialButt
773  delete ui_item.m_MaterialButt; // control shown in column 4, with m_MaterialCtrl
774  delete ui_item.m_ThicknessCtrl; // control shown in column 5
775  delete ui_item.m_ThicknessLockCtrl;// control shown in column 6
776  delete ui_item.m_ColorCtrl; // control shown in column 7
777  delete ui_item.m_EpsilonCtrl; // control shown in column 8
778  delete ui_item.m_LossTgCtrl; // control shown in column 9
779  }
780 
781  m_rowUiItemsList.clear();
782 
783  // In order to recreate a clean grid layer list, we have to delete and
784  // recreate the sizer m_fgGridSizer (just deleting items in this size is not enough)
785  // therefore we also have to add the "old" title items to the newly recreated m_fgGridSizer:
786  m_scGridWin->SetSizer( nullptr ); // This remove and delete the current m_fgGridSizer
787 
788  m_fgGridSizer = new wxFlexGridSizer( 0, 9, 0, 2 );
789  m_fgGridSizer->SetFlexibleDirection( wxHORIZONTAL );
790  m_fgGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
791  m_fgGridSizer->SetHGap( 6 );
792  m_scGridWin->SetSizer( m_fgGridSizer );
793 
794  // Re-add "old" title items:
795  const int sizer_flags = wxALIGN_CENTER_VERTICAL | wxALL | wxALIGN_CENTER_HORIZONTAL;
796  m_fgGridSizer->Add( m_staticTextLayer, 0, sizer_flags, 2 );
797  m_fgGridSizer->Add( m_staticTextType, 0, sizer_flags, 2 );
798  m_fgGridSizer->Add( m_staticTextLayerId, 0, sizer_flags, 5 );
799  m_fgGridSizer->Add( m_staticTextMaterial, 0, sizer_flags, 2 );
800  m_fgGridSizer->Add( m_staticTextThickness, 0, sizer_flags, 2 );
801  m_fgGridSizer->Add( m_bitmapLockThickness, 0, sizer_flags, 1 );
802  m_fgGridSizer->Add( m_staticTextColor, 0, sizer_flags, 2 );
803  m_fgGridSizer->Add( m_staticTextEpsilonR, 0, sizer_flags, 2 );
804  m_fgGridSizer->Add( m_staticTextLossTg, 0, sizer_flags, 2 );
805 
806 
807  // Now, rebuild the widget list from the new m_stackup items:
808  buildLayerStackPanel( false );
809 
810  // Now enable/disable stackup items, according to the m_enabledLayers config
812 
813  m_scGridWin->Layout();
814 }
std::vector< wxControl * > m_controlItemsList
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
void showOnlyActiveLayers()
Show or do not show items in m_fgGridSizer according to the stackup of the current board.
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References buildLayerStackPanel(), disconnectEvents(), PANEL_SETUP_BOARD_STACKUP_BASE::m_bitmapLockThickness, m_controlItemsList, PANEL_SETUP_BOARD_STACKUP_BASE::m_fgGridSizer, m_rowUiItemsList, PANEL_SETUP_BOARD_STACKUP_BASE::m_scGridWin, PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextColor, PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextEpsilonR, PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextLayer, PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextLayerId, PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextLossTg, PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextMaterial, PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextThickness, PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextType, and showOnlyActiveLayers().

Referenced by ImportSettingsFrom(), onAddDielectricLayer(), and onRemoveDielectricLayer().

◆ showOnlyActiveLayers()

void PANEL_SETUP_BOARD_STACKUP::showOnlyActiveLayers ( )
private

Show or do not show items in m_fgGridSizer according to the stackup of the current board.

The panel stackup stores all posible layers (because the number of layers is set from an other panel), but only some of them must be actually shown on screen

Definition at line 488 of file panel_board_stackup.cpp.

489 {
490 
491  // Now enable/disable stackup items, according to the m_enabledLayers config
492  // Calculate copper layer count from m_enabledLayers, and *do not use* brd_stackup
493  // for that, because it is not necessary up to date
494  // (for instance after modifying the layer count from the panel layers in dialog)
496  int copperLayersCount = copperMask.count();
497 
498  for( BOARD_STACKUP_ROW_UI_ITEM& ui_row_item: m_rowUiItemsList )
499  {
500  bool show_item;
501  BOARD_STACKUP_ITEM* item = ui_row_item.m_Item;
502 
503  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
504  // the m_DielectricLayerId is not a copper layer id, it is a dielectric idx from 1
505  show_item = item->GetDielectricLayerId() < copperLayersCount;
506  else
507  show_item = m_enabledLayers[item->GetBrdLayerId()];
508 
509  item->SetEnabled( show_item );
510 
511  ui_row_item.m_isEnabled = show_item;
512 
513  // Show or not items of this row:
514  ui_row_item.m_Icon->Show( show_item );
515  ui_row_item.m_LayerName->Show( show_item );
516  ui_row_item.m_LayerTypeCtrl->Show( show_item );
517  ui_row_item.m_MaterialCtrl->Show( show_item );
518 
519  if( ui_row_item.m_MaterialButt )
520  ui_row_item.m_MaterialButt->Show( show_item );
521 
522  ui_row_item.m_ThicknessCtrl->Show( show_item );
523  ui_row_item.m_ThicknessLockCtrl->Show( show_item );
524  ui_row_item.m_ColorCtrl->Show( show_item );
525  ui_row_item.m_EpsilonCtrl->Show( show_item );
526  ui_row_item.m_LossTgCtrl->Show( show_item );
527  }
528 }
BOARD_STACKUP_ITEM_TYPE GetType() const
LSET is a set of PCB_LAYER_IDs.
static LSET InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
Definition: lset.cpp:710
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition: lset.cpp:780
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
PCB_LAYER_ID GetBrdLayerId() const
int GetDielectricLayerId() const
void SetEnabled(bool aEnable)
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References BS_ITEM_TYPE_DIELECTRIC, LSET::ExternalCuMask(), BOARD_STACKUP_ITEM::GetBrdLayerId(), BOARD_STACKUP_ITEM::GetDielectricLayerId(), BOARD_STACKUP_ITEM::GetType(), LSET::InternalCuMask(), m_enabledLayers, m_rowUiItemsList, and BOARD_STACKUP_ITEM::SetEnabled().

Referenced by PANEL_SETUP_BOARD_STACKUP(), rebuildLayerStackPanel(), and synchronizeWithBoard().

◆ synchronizeWithBoard()

void PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard ( bool  aFullSync)
private

Synchronize the full stackup shown in m_fgGridSizer according to the stackup of the current board and optionally update the stackup params (thickness, color ...

)

Parameters
aFullSync= true to update stackup params, false to only update the list of shown items

Definition at line 367 of file panel_board_stackup.cpp.

368 {
369  const BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
370 
371  if( aFullSync )
372  {
373  m_choiceCopperLayers->SetSelection( ( m_board->GetCopperLayerCount() / 2 ) - 1 );
374  m_impedanceControlled->SetValue( brd_stackup.m_HasDielectricConstrains );
375  }
376 
377  for( BOARD_STACKUP_ROW_UI_ITEM& ui_row_item : m_rowUiItemsList )
378  {
379  BOARD_STACKUP_ITEM* item = ui_row_item.m_Item;
380  int sub_item = ui_row_item.m_SubItem;
381 
382  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
383  {
384  wxChoice* choice = dynamic_cast<wxChoice*>( ui_row_item.m_LayerTypeCtrl );
385 
386  if( choice )
387  choice->SetSelection( item->GetTypeName() == KEY_CORE ? 0 : 1 );
388  }
389 
390  if( item->IsMaterialEditable() )
391  {
392  wxTextCtrl* matName = dynamic_cast<wxTextCtrl*>( ui_row_item.m_MaterialCtrl );
393 
394  if( matName )
395  {
396  if( IsPrmSpecified( item->GetMaterial( sub_item ) ) )
397  matName->SetValue( item->GetMaterial( sub_item ) );
398  else
399  matName->SetValue( wxGetTranslation( NotSpecifiedPrm() ) );
400  }
401  }
402 
403  if( item->IsThicknessEditable() )
404  {
405  wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( ui_row_item.m_ThicknessCtrl );
406 
407  if( textCtrl )
408  textCtrl->SetValue( StringFromValue( m_units,
409  item->GetThickness( sub_item ), true ) );
410 
411  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
412  {
413  wxCheckBox* cb_box = dynamic_cast<wxCheckBox*> ( ui_row_item.m_ThicknessLockCtrl );
414 
415  if( cb_box )
416  cb_box->SetValue( item->IsThicknessLocked( sub_item ) );
417  }
418  }
419 
420  if( item->IsColorEditable() )
421  {
422  auto bm_combo = dynamic_cast<wxBitmapComboBox*>( ui_row_item.m_ColorCtrl );
423  int color_idx = 0;
424 
425  if( item->GetColor().StartsWith( "#" ) ) // User defined color
426  {
427  wxColour color( item->GetColor() );
428  ui_row_item.m_UserColor = color;
429  color_idx = GetColorUserDefinedListIdx();
430 
431  if( bm_combo ) // Update user color shown in the wxBitmapComboBox
432  {
433  wxString label = wxString::Format( _( "Custom (%s)" ),
434  color.GetAsString( wxC2S_HTML_SYNTAX ) );
435 
436  bm_combo->SetString( color_idx, label );
437  wxBitmap layerbmp( m_colorSwatchesSize.x, m_colorSwatchesSize.y );
439  bm_combo->SetItemBitmap( color_idx, layerbmp );
440  }
441  }
442  else
443  {
444  const FAB_LAYER_COLOR* color_list = GetColorStandardList();
445 
446  for( int ii = 0; ii < GetColorStandardListCount(); ii++ )
447  {
448  if( color_list[ii].m_ColorName == item->GetColor() )
449  {
450  color_idx = ii;
451  break;
452  }
453  }
454  }
455 
456  if( bm_combo )
457  bm_combo->SetSelection( color_idx );
458  }
459 
460  if( item->HasEpsilonRValue() )
461  {
462  wxString txt;
463  txt.Printf( "%.2f", item->GetEpsilonR( sub_item ) );
464  wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( ui_row_item.m_EpsilonCtrl );
465 
466  if( textCtrl )
467  textCtrl->SetValue( txt );
468  }
469 
470  if( item->HasLossTangentValue() )
471  {
472  wxString txt;
473  txt.Printf( "%g", item->GetLossTangent( sub_item ) );
474  wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( ui_row_item.m_LossTgCtrl );
475 
476  if( textCtrl )
477  textCtrl->SetValue( txt );
478  }
479  }
480 
481  // Now enable/disable stackup items, according to the m_enabledLayers config
483 
484  updateIconColor();
485 }
BOARD_STACKUP_ITEM_TYPE GetType() const
bool HasEpsilonRValue() const
Manage layers needed to make a physical board.
int color
Definition: DXF_plotter.cpp:60
bool IsThicknessLocked(int aDielectricSubLayer=0) const
wxString GetColor() const
int GetColorStandardListCount()
int GetColorUserDefinedListIdx()
double GetLossTangent(int aDielectricSubLayer=0) const
bool m_HasDielectricConstrains
True if some layers have impedance controlled tracks or have specific constrains for micro-wave appli...
BOARD_STACKUP & GetStackupDescriptor()
bool IsThicknessEditable() const
wxString NotSpecifiedPrm()
int GetThickness(int aDielectricSubLayer=0) const
bool IsColorEditable() const
bool HasLossTangentValue() const
BOARD_DESIGN_SETTINGS * m_brdSettings
double GetEpsilonR(int aDielectricSubLayer=0) const
bool IsMaterialEditable() const
wxString GetTypeName() const
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
static void DrawColorSwatch(wxBitmap &aLayerbmp, COLOR4D aBackground, COLOR4D aColor)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
bool IsPrmSpecified(const wxString &aPrmValue)
#define _(s)
Definition: 3d_actions.cpp:33
int GetCopperLayerCount() const
Definition: board.cpp:435
const FAB_LAYER_COLOR * GetColorStandardList()
void updateIconColor(int aRow=-1)
Update the icons color (swatches in first grid column)
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:190
void showOnlyActiveLayers()
Show or do not show items in m_fgGridSizer according to the stackup of the current board.
#define KEY_CORE
wxString GetMaterial(int aDielectricSubLayer=0) const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References _, BS_ITEM_TYPE_DIELECTRIC, color, LAYER_SELECTOR::DrawColorSwatch(), Format(), BOARD_STACKUP_ITEM::GetColor(), GetColorStandardList(), GetColorStandardListCount(), GetColorUserDefinedListIdx(), BOARD::GetCopperLayerCount(), BOARD_STACKUP_ITEM::GetEpsilonR(), BOARD_STACKUP_ITEM::GetLossTangent(), BOARD_STACKUP_ITEM::GetMaterial(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), BOARD_STACKUP_ITEM::GetThickness(), BOARD_STACKUP_ITEM::GetType(), BOARD_STACKUP_ITEM::GetTypeName(), BOARD_STACKUP_ITEM::HasEpsilonRValue(), BOARD_STACKUP_ITEM::HasLossTangentValue(), BOARD_STACKUP_ITEM::IsColorEditable(), BOARD_STACKUP_ITEM::IsMaterialEditable(), IsPrmSpecified(), BOARD_STACKUP_ITEM::IsThicknessEditable(), BOARD_STACKUP_ITEM::IsThicknessLocked(), KEY_CORE, m_board, m_brdSettings, PANEL_SETUP_BOARD_STACKUP_BASE::m_choiceCopperLayers, m_colorSwatchesSize, BOARD_STACKUP::m_HasDielectricConstrains, PANEL_SETUP_BOARD_STACKUP_BASE::m_impedanceControlled, m_rowUiItemsList, m_units, NotSpecifiedPrm(), showOnlyActiveLayers(), StringFromValue(), and updateIconColor().

Referenced by ImportSettingsFrom(), OnLayersOptionsChanged(), and PANEL_SETUP_BOARD_STACKUP().

◆ transferDataFromUIToStackup()

bool PANEL_SETUP_BOARD_STACKUP::transferDataFromUIToStackup ( )
private

Transfer current UI settings to m_stackup but not to the board.

Definition at line 881 of file panel_board_stackup.cpp.

882 {
883  // First, verify the list of layers currently in stackup: if it doesn't match the list
884  // of layers set in PANEL_SETUP_LAYERS prompt the user to update the stackup
886 
887  if( m_enabledLayers != layersList )
889 
890  // The board thickness and the thickness from stackup settings should be compatible
891  // so verify that compatibility
892  int stackup_thickness = 0;
893 
894  wxString txt;
895  wxString error_msg;
896  bool success = true;
897  double value;
898  int row = 0;
899 
901  {
902  // Skip stackup items useless for the current board
903  if( !ui_item.m_isEnabled )
904  {
905  row++;
906  continue;
907  }
908 
909  BOARD_STACKUP_ITEM* item = ui_item.m_Item;
910  int sub_item = ui_item.m_SubItem;
911 
912  // Add sub layer if there is a new sub layer:
913  while( item->GetSublayersCount() <= sub_item )
914  item->AddDielectricPrms( item->GetSublayersCount() );
915 
916  if( sub_item == 0 ) // Name only main layer
917  item->SetLayerName( ui_item.m_LayerName->GetLabel() );
918 
919  if( item->HasEpsilonRValue() )
920  {
921  wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_EpsilonCtrl );
922  txt = textCtrl->GetValue();
923 
924  if( txt.ToDouble( &value ) && value >= 0.0 )
925  item->SetEpsilonR( value, sub_item );
926  else if( txt.ToCDouble( &value ) && value >= 0.0 )
927  item->SetEpsilonR( value, sub_item );
928  else
929  {
930  success = false;
931  error_msg << _( "Incorrect value for Epsilon R (Epsilon R must be positive or null if not used)" );
932  }
933  }
934 
935  if( item->HasLossTangentValue() )
936  {
937  wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_LossTgCtrl );
938  txt = textCtrl->GetValue();
939 
940  if( txt.ToDouble( &value ) && value >= 0.0 )
941  item->SetLossTangent( value, sub_item );
942  else if( txt.ToCDouble( &value ) && value >= 0.0 )
943  item->SetLossTangent( value, sub_item );
944  else
945  {
946  success = false;
947 
948  if( !error_msg.IsEmpty() )
949  error_msg << "\n";
950 
951  error_msg << _( "Incorrect value for Loss tg (Loss tg must be positive or null if not used)" );
952  }
953  }
954 
955  if( item->IsMaterialEditable() )
956  {
957  wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_MaterialCtrl );
958  item->SetMaterial( textCtrl->GetValue(), sub_item );
959 
960  // Ensure the not specified mat name is the keyword, not its translation
961  // to avoid any issue is the language setting changes
962  if( !IsPrmSpecified( item->GetMaterial( sub_item ) ) )
963  item->SetMaterial( NotSpecifiedPrm(), sub_item );
964  }
965 
966  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
967  {
968  // Choice is Core or Prepreg. Sublayers have no choice:
969  wxChoice* choice = dynamic_cast<wxChoice*>( ui_item.m_LayerTypeCtrl );
970 
971  if( choice )
972  {
973  int idx = choice->GetSelection();
974 
975  if( idx == 0 )
976  item->SetTypeName( KEY_CORE );
977  else
978  item->SetTypeName( KEY_PREPREG );
979  }
980  }
981 
982  if( item->IsThicknessEditable() )
983  {
984  wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_ThicknessCtrl );
985  txt = textCtrl->GetValue();
986 
987  int new_thickness = ValueFromString( m_frame->GetUserUnits(), txt );
988  item->SetThickness( new_thickness, sub_item );
989  stackup_thickness += new_thickness;
990 
991  if( new_thickness < 0 )
992  {
993  success = false;
994 
995  if( !error_msg.IsEmpty() )
996  error_msg << "\n";
997 
998  error_msg << _( "A layer thickness is < 0. Fix it" );
999  }
1000 
1001  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
1002  {
1003  // Dielectric thickness layer can have a locked thickness:
1004  wxCheckBox* cb_box = static_cast<wxCheckBox*>
1005  ( ui_item.m_ThicknessLockCtrl );
1006  item->SetThicknessLocked( cb_box && cb_box->GetValue(), sub_item );
1007  }
1008  }
1009 
1010  if( sub_item == 0 && item->IsColorEditable() )
1011  {
1012  const FAB_LAYER_COLOR* color_list = GetColorStandardList();
1013 
1014  wxBitmapComboBox* choice = dynamic_cast<wxBitmapComboBox*>( ui_item.m_ColorCtrl );
1015 
1016  if( choice )
1017  {
1018  int idx = choice->GetSelection();
1019 
1020  if( idx == GetColorUserDefinedListIdx() )
1021  {
1022  wxColour color = ui_item.m_UserColor;
1023  item->SetColor( color.GetAsString( wxC2S_HTML_SYNTAX ) );
1024  }
1025  else
1026  {
1027  item->SetColor( color_list[idx].m_ColorName );
1028  }
1029  }
1030  }
1031 
1032  row++;
1033  }
1034 
1035  if( !success )
1036  {
1037  wxMessageBox( error_msg, _( "Errors" ) );
1038  return false;
1039  }
1040 
1042 
1043  return true;
1044 }
BOARD_STACKUP_ITEM_TYPE GetType() const
bool HasEpsilonRValue() const
void SetTypeName(const wxString &aName)
int GetSublayersCount() const
PANEL_SETUP_LAYERS * m_panelLayers
int color
Definition: DXF_plotter.cpp:60
int GetColorUserDefinedListIdx()
void OnLayersOptionsChanged(LSET aNewLayerSet)
Must be called if the copper layers count has changed or solder mask, solder paste or silkscreen laye...
bool m_HasDielectricConstrains
True if some layers have impedance controlled tracks or have specific constrains for micro-wave appli...
void SetLayerName(const wxString &aName)
bool IsThicknessEditable() const
LSET is a set of PCB_LAYER_IDs.
static LSET StackupAllowedBrdLayers()
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:402
wxString NotSpecifiedPrm()
bool IsColorEditable() const
bool HasLossTangentValue() const
bool IsMaterialEditable() const
void SetMaterial(const wxString &aName, int aDielectricSubLayer=0)
#define KEY_PREPREG
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
void SetEpsilonR(double aEpsilon, int aDielectricSubLayer=0)
void AddDielectricPrms(int aDielectricPrmsIdx)
Add (insert) a DIELECTRIC_PRMS item to m_DielectricPrmsList all values are set to default.
void SetThickness(int aThickness, int aDielectricSubLayer=0)
void SetThicknessLocked(bool aLocked, int aDielectricSubLayer=0)
bool IsPrmSpecified(const wxString &aPrmValue)
#define _(s)
Definition: 3d_actions.cpp:33
const FAB_LAYER_COLOR * GetColorStandardList()
void SetColor(const wxString &aColorName)
#define KEY_CORE
void SetLossTangent(double aTg, int aDielectricSubLayer=0)
wxString GetMaterial(int aDielectricSubLayer=0) const
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References _, BOARD_STACKUP_ITEM::AddDielectricPrms(), BS_ITEM_TYPE_DIELECTRIC, color, GetColorStandardList(), GetColorUserDefinedListIdx(), BOARD_STACKUP_ITEM::GetMaterial(), BOARD_STACKUP_ITEM::GetSublayersCount(), BOARD_STACKUP_ITEM::GetType(), PANEL_SETUP_LAYERS::GetUILayerMask(), EDA_BASE_FRAME::GetUserUnits(), BOARD_STACKUP_ITEM::HasEpsilonRValue(), BOARD_STACKUP_ITEM::HasLossTangentValue(), BOARD_STACKUP_ITEM::IsColorEditable(), BOARD_STACKUP_ITEM::IsMaterialEditable(), IsPrmSpecified(), BOARD_STACKUP_ITEM::IsThicknessEditable(), KEY_CORE, KEY_PREPREG, m_enabledLayers, m_frame, BOARD_STACKUP::m_HasDielectricConstrains, PANEL_SETUP_BOARD_STACKUP_BASE::m_impedanceControlled, m_panelLayers, m_rowUiItemsList, m_stackup, NotSpecifiedPrm(), OnLayersOptionsChanged(), BOARD_STACKUP_ITEM::SetColor(), BOARD_STACKUP_ITEM::SetEpsilonR(), BOARD_STACKUP_ITEM::SetLayerName(), BOARD_STACKUP_ITEM::SetLossTangent(), BOARD_STACKUP_ITEM::SetMaterial(), BOARD_STACKUP_ITEM::SetThickness(), BOARD_STACKUP_ITEM::SetThicknessLocked(), BOARD_STACKUP_ITEM::SetTypeName(), BOARD_STACKUP::StackupAllowedBrdLayers(), and ValueFromString().

Referenced by onExportToClipboard(), onMaterialChange(), and TransferDataFromWindow().

◆ TransferDataFromWindow()

bool PANEL_SETUP_BOARD_STACKUP::TransferDataFromWindow ( )
override

Definition at line 1047 of file panel_board_stackup.cpp.

1048 {
1050  return false;
1051 
1052  // NOTE: Copper layer count is transferred via PANEL_SETUP_LAYERS even though it is configured
1053  // on this page, because the logic for confirming deletion of board items on deleted layers is
1054  // on that panel and it doesn't make sense to split it up.
1055 
1057 
1058  STRING_FORMATTER old_stackup;
1059 
1060  // FormatBoardStackup() (using FormatInternalUnits()) expects a "C" locale
1061  // to execute some tests. So switch to the suitable locale
1062  LOCALE_IO dummy;
1063  brd_stackup.FormatBoardStackup( &old_stackup, m_board, 0 );
1064 
1065  brd_stackup.m_FinishType = m_stackup.m_FinishType;
1069  brd_stackup.m_EdgePlating = m_stackup.m_EdgePlating;
1070 
1071  // copy enabled items to the new board stackup
1072  brd_stackup.RemoveAll();
1073 
1074  for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() )
1075  {
1076  if( item->IsEnabled() )
1077  brd_stackup.Add( new BOARD_STACKUP_ITEM( *item ) );
1078  }
1079 
1080  STRING_FORMATTER new_stackup;
1081  brd_stackup.FormatBoardStackup( &new_stackup, m_board, 0 );
1082 
1083  bool modified = old_stackup.GetString() != new_stackup.GetString();
1084  int thickness = brd_stackup.BuildBoardThicknessFromStackup();
1085 
1086  if( m_brdSettings->GetBoardThickness() != thickness )
1087  {
1088  m_brdSettings->SetBoardThickness( thickness );
1089  modified = true;
1090  }
1091 
1092  if( !m_brdSettings->m_HasStackup )
1093  {
1094  m_brdSettings->m_HasStackup = true;
1095  modified = true;
1096  }
1097 
1098  if( modified )
1099  m_frame->OnModify();
1100 
1101  return true;
1102 }
void OnModify() override
Must be called after a board change to set the modified flag.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
Manage layers needed to make a physical board.
wxString m_FinishType
The name of external copper finish.
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...
bool m_CastellatedPads
True if castellated pads exist.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
void SetBoardThickness(int aThickness)
int BuildBoardThicknessFromStackup() const
bool m_HasDielectricConstrains
True if some layers have impedance controlled tracks or have specific constrains for micro-wave appli...
BOARD_STACKUP & GetStackupDescriptor()
BOARD_DESIGN_SETTINGS * m_brdSettings
const std::string & GetString()
Definition: richio.h:435
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
void FormatBoardStackup(OUTPUTFORMATTER *aFormatter, const BOARD *aBoard, int aNestLevel) const
Write the stackup info on board file.
void RemoveAll()
Delete all items in list and clear the list.
bool transferDataFromUIToStackup()
Transfer current UI settings to m_stackup but not to the board.
void Add(BOARD_STACKUP_ITEM *aItem)
Add a new item in stackup layer.
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:411

References BOARD_STACKUP::Add(), BOARD_STACKUP::BuildBoardThicknessFromStackup(), dummy(), BOARD_STACKUP::FormatBoardStackup(), BOARD_DESIGN_SETTINGS::GetBoardThickness(), BOARD_STACKUP::GetList(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), STRING_FORMATTER::GetString(), m_board, m_brdSettings, BOARD_STACKUP::m_CastellatedPads, BOARD_STACKUP::m_EdgeConnectorConstraints, BOARD_STACKUP::m_EdgePlating, BOARD_STACKUP::m_FinishType, m_frame, BOARD_STACKUP::m_HasDielectricConstrains, BOARD_DESIGN_SETTINGS::m_HasStackup, m_stackup, PCB_EDIT_FRAME::OnModify(), BOARD_STACKUP::RemoveAll(), BOARD_DESIGN_SETTINGS::SetBoardThickness(), and transferDataFromUIToStackup().

◆ updateCopperLayerCount()

void PANEL_SETUP_BOARD_STACKUP::updateCopperLayerCount ( )
private

Updates the enabled copper layers when the dropdown is changed.

Definition at line 353 of file panel_board_stackup.cpp.

354 {
355  int copperCount = GetCopperLayerCount();
356 
357  wxASSERT( copperCount >= 2 );
358 
360  m_enabledLayers &= ~LSET::InternalCuMask();
361 
362  for( int i = 1; i < copperCount - 1; i++ )
363  m_enabledLayers.set( F_Cu + i );
364 }
LSET is a set of PCB_LAYER_IDs.
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition: lset.cpp:780

References LSET::ExternalCuMask(), F_Cu, GetCopperLayerCount(), and m_enabledLayers.

Referenced by PANEL_SETUP_BOARD_STACKUP().

◆ updateIconColor()

void PANEL_SETUP_BOARD_STACKUP::updateIconColor ( int  aRow = -1)
private

Update the icons color (swatches in first grid column)

Parameters
aRowis the row (index in m_rowUiItemsList) that manages the icon to update. if -1 all icons will be updated

Definition at line 1336 of file panel_board_stackup.cpp.

1337 {
1338  if( aRow >= 0 )
1339  {
1340  wxStaticBitmap* st_bitmap = m_rowUiItemsList[aRow].m_Icon;
1341 
1342  // explicit depth important under MSW
1343  wxBitmap bmp( m_colorIconsSize.x, m_colorIconsSize.y / 2, 28 );
1344  drawBitmap( bmp, getColorIconItem( aRow ) );
1345  st_bitmap->SetBitmap( bmp );
1346  return;
1347  }
1348 
1349  for( unsigned row = 0; row < m_rowUiItemsList.size(); row++ )
1350  {
1351  // explicit depth important under MSW
1352  wxBitmap bmp( m_colorIconsSize.x, m_colorIconsSize.y / 2, 28 );
1353  drawBitmap( bmp, getColorIconItem( row ) );
1354  m_rowUiItemsList[row].m_Icon->SetBitmap( bmp );
1355  }
1356 }
static void drawBitmap(wxBitmap &aBitmap, wxColor aColor)
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References drawBitmap(), getColorIconItem(), m_colorIconsSize, and m_rowUiItemsList.

Referenced by buildLayerStackPanel(), onColorSelected(), and synchronizeWithBoard().

Member Data Documentation

◆ m_bitmapLockThickness

wxStaticBitmap* PANEL_SETUP_BOARD_STACKUP_BASE::m_bitmapLockThickness
protectedinherited

◆ m_board

BOARD* PANEL_SETUP_BOARD_STACKUP::m_board
private

◆ m_brdSettings

BOARD_DESIGN_SETTINGS* PANEL_SETUP_BOARD_STACKUP::m_brdSettings
private

◆ m_buttonAddDielectricLayer

wxButton* PANEL_SETUP_BOARD_STACKUP_BASE::m_buttonAddDielectricLayer
protectedinherited

◆ m_buttonExport

wxButton* PANEL_SETUP_BOARD_STACKUP_BASE::m_buttonExport
protectedinherited

◆ m_buttonRemoveDielectricLayer

wxButton* PANEL_SETUP_BOARD_STACKUP_BASE::m_buttonRemoveDielectricLayer
protectedinherited

◆ m_choiceCopperLayers

wxChoice* PANEL_SETUP_BOARD_STACKUP_BASE::m_choiceCopperLayers
protectedinherited

◆ m_colorIconsSize

wxSize PANEL_SETUP_BOARD_STACKUP::m_colorIconsSize
private

Definition at line 256 of file panel_board_stackup.h.

Referenced by PANEL_SETUP_BOARD_STACKUP(), and updateIconColor().

◆ m_colorSwatchesSize

wxSize PANEL_SETUP_BOARD_STACKUP::m_colorSwatchesSize
private

◆ m_controlItemsList

std::vector<wxControl*> PANEL_SETUP_BOARD_STACKUP::m_controlItemsList
private

◆ m_core_prepreg_choice

wxArrayString PANEL_SETUP_BOARD_STACKUP::m_core_prepreg_choice
private

Definition at line 254 of file panel_board_stackup.h.

Referenced by createRowData(), and PANEL_SETUP_BOARD_STACKUP().

◆ m_delectricMatList

DIELECTRIC_SUBSTRATE_LIST PANEL_SETUP_BOARD_STACKUP::m_delectricMatList
private

Definition at line 239 of file panel_board_stackup.h.

Referenced by onMaterialChange().

◆ m_enabledLayers

◆ m_fgGridSizer

wxFlexGridSizer* PANEL_SETUP_BOARD_STACKUP_BASE::m_fgGridSizer
protectedinherited

◆ m_frame

◆ m_impedanceControlled

wxCheckBox* PANEL_SETUP_BOARD_STACKUP_BASE::m_impedanceControlled
protectedinherited

◆ m_lblCopperLayers

wxStaticText* PANEL_SETUP_BOARD_STACKUP_BASE::m_lblCopperLayers
protectedinherited

◆ m_numericFieldsSize

wxSize PANEL_SETUP_BOARD_STACKUP::m_numericFieldsSize
private

Definition at line 253 of file panel_board_stackup.h.

Referenced by createRowData(), and PANEL_SETUP_BOARD_STACKUP().

◆ m_numericTextCtrlSize

wxSize PANEL_SETUP_BOARD_STACKUP::m_numericTextCtrlSize
private

◆ m_panelLayers

PANEL_SETUP_LAYERS* PANEL_SETUP_BOARD_STACKUP::m_panelLayers
private

◆ m_parentDialog

PAGED_DIALOG* PANEL_SETUP_BOARD_STACKUP::m_parentDialog
private

Definition at line 247 of file panel_board_stackup.h.

Referenced by PANEL_SETUP_BOARD_STACKUP().

◆ m_rowUiItemsList

◆ m_scGridWin

wxScrolledWindow* PANEL_SETUP_BOARD_STACKUP_BASE::m_scGridWin
protectedinherited

◆ m_silkscreenMatList

DIELECTRIC_SUBSTRATE_LIST PANEL_SETUP_BOARD_STACKUP::m_silkscreenMatList
private

Definition at line 243 of file panel_board_stackup.h.

Referenced by onMaterialChange().

◆ m_solderMaskMatList

DIELECTRIC_SUBSTRATE_LIST PANEL_SETUP_BOARD_STACKUP::m_solderMaskMatList
private

Definition at line 241 of file panel_board_stackup.h.

Referenced by onMaterialChange().

◆ m_stackup

◆ m_staticTextColor

wxStaticText* PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextColor
protectedinherited

◆ m_staticTextCT

wxStaticText* PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextCT
protectedinherited

◆ m_staticTextEpsilonR

wxStaticText* PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextEpsilonR
protectedinherited

◆ m_staticTextLayer

wxStaticText* PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextLayer
protectedinherited

◆ m_staticTextLayerId

wxStaticText* PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextLayerId
protectedinherited

◆ m_staticTextLossTg

wxStaticText* PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextLossTg
protectedinherited

◆ m_staticTextMaterial

wxStaticText* PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextMaterial
protectedinherited

◆ m_staticTextThickness

wxStaticText* PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextThickness
protectedinherited

◆ m_staticTextType

wxStaticText* PANEL_SETUP_BOARD_STACKUP_BASE::m_staticTextType
protectedinherited

◆ m_tcCTValue

wxTextCtrl* PANEL_SETUP_BOARD_STACKUP_BASE::m_tcCTValue
protectedinherited

◆ m_units

EDA_UNITS PANEL_SETUP_BOARD_STACKUP::m_units
private

The documentation for this class was generated from the following files: