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_buttonAdjust
 
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 onCopperLayersSelCount (wxCommandEvent &event) override
 
void onAdjustDielectricThickness (wxCommandEvent &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 75 of file panel_board_stackup.cpp.

76  :
81 {
82  m_parentDialog = aParent;
83  m_frame = aFrame;
84  m_panelLayers = aPanelLayers;
87  m_units = aFrame->GetUserUnits();
88 
90 
92 
93  // Calculates a good size for color swatches (icons) in this dialog
94  wxClientDC dc( this );
95  m_colorSwatchesSize = dc.GetTextExtent( "XX" );
96  m_colorIconsSize = dc.GetTextExtent( "XXXX" );
97 
98  // Calculates a good size for wxTextCtrl to enter Epsilon R and Loss tan
99  // ("0.000000" + margins)
100  m_numericFieldsSize = dc.GetTextExtent( "X.XXXXXX" );
101  m_numericFieldsSize.y = -1; // Use default for the vertical size
102 
103  // Calculates a minimal size for wxTextCtrl to enter a dim with units
104  // ("000.0000000 mils" + margins)
105  m_numericTextCtrlSize = dc.GetTextExtent( "XXX.XXXXXX mils" );
106  m_numericTextCtrlSize.y = -1; // Use default for the vertical size
107 
108  // The grid column containing the lock checkbox is kept to a minimal
109  // size. So we use a wxStaticBitmap: set the bitmap itself
110  m_bitmapLockThickness->SetBitmap( KiScaledBitmap( BITMAPS::locked, aFrame ) );
111 
112  // Gives a minimal size of wxTextCtrl showing dimensions+units
113  m_tcCTValue->SetMinSize( m_numericTextCtrlSize );
114 
115  // Prepare dielectric layer type: layer type keyword is "core" or "prepreg"
116  m_core_prepreg_choice.Add( _( "Core" ) );
117  m_core_prepreg_choice.Add( _( "PrePreg" ) );
118 
119  buildLayerStackPanel( true );
120  synchronizeWithBoard( true );
122 }
PANEL_SETUP_LAYERS * m_panelLayers
void computeBoardThickness()
Recompute the board thickness and update the textbox.
DIELECTRIC_SUBSTRATE_LIST m_silkscreenMatList
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:465
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:588
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:37
void synchronizeWithBoard(bool aFullSync)
Synchronize the full stackup shown in m_fgGridSizer according to the stackup of the current board and...
static LSET StackupAllowedBrdLayers()
PANEL_SETUP_BOARD_STACKUP_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(680, 281), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
BOARD_DESIGN_SETTINGS * m_brdSettings
#define _(s)
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:148

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, 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(), BOARD_STACKUP::StackupAllowedBrdLayers(), and synchronizeWithBoard().

◆ ~PANEL_SETUP_BOARD_STACKUP()

PANEL_SETUP_BOARD_STACKUP::~PANEL_SETUP_BOARD_STACKUP ( )

Definition at line 125 of file panel_board_stackup.cpp.

126 {
128 }
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 name of the currently selected material (can be null)
aUiRowItemis the BOARD_STACKUP_ROW_UI_ITEM to store the controls created

Definition at line 636 of file panel_board_stackup.cpp.

638 {
639  wxBoxSizer* bSizerMat = new wxBoxSizer( wxHORIZONTAL );
640  m_fgGridSizer->Add( bSizerMat, 1, wxRIGHT|wxEXPAND, 4 );
641  wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, wxID_ANY );
642 
643  if( aMaterialName )
644  {
645  if( IsPrmSpecified( *aMaterialName ) )
646  textCtrl->SetValue( *aMaterialName );
647  else
648  textCtrl->SetValue( wxGetTranslation( NotSpecifiedPrm() ) );
649  }
650 
651  textCtrl->SetMinSize( m_numericTextCtrlSize );
652  bSizerMat->Add( textCtrl, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
653 
654  wxButton* m_buttonMat = new wxButton( m_scGridWin, aId, _( "..." ), wxDefaultPosition,
655  wxDefaultSize, wxBU_EXACTFIT );
656  bSizerMat->Add( m_buttonMat, 0, wxALIGN_CENTER_VERTICAL, 2 );
657 
658  m_buttonMat->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
659  wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onMaterialChange ),
660  nullptr, this );
661  m_controlItemsList.push_back( m_buttonMat );
662 
663  aUiRowItem.m_MaterialCtrl = textCtrl;
664  aUiRowItem.m_MaterialButt = m_buttonMat;
665 }
std::vector< wxControl * > m_controlItemsList
wxString NotSpecifiedPrm()
#define _(s)
bool IsPrmSpecified(const wxString &aPrmValue)
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(), 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 668 of file panel_board_stackup.cpp.

669 {
670  wxStaticText* emptyText = new wxStaticText( m_scGridWin, wxID_ANY, wxEmptyString );
671  m_fgGridSizer->Add( emptyText, 0, wxALIGN_CENTER_VERTICAL );
672  return emptyText;
673 }

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 925 of file panel_board_stackup.cpp.

926 {
927  // Build a full stackup for the dialog, with a active copper layer count
928  // = current board layer count to calculate a reasonable default stackup:
929  if( aCreatedInitialStackup )
930  {
931  // Creates a full BOARD_STACKUP with 32 copper layers.
932  // extra layers will be hidden later.
933  // but if the number of layer is changed in the dialog, the corresponding
934  // widgets will be available with their previous values.
936  const BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
937 
938  // Now initialize all stackup items to the board values, when exist
939  for( BOARD_STACKUP_ITEM* item: m_stackup.GetList() )
940  {
941  // Search for board settings:
942  for( BOARD_STACKUP_ITEM* board_item: brd_stackup.GetList() )
943  {
944  if( item->GetBrdLayerId() != UNDEFINED_LAYER )
945  {
946  if( item->GetBrdLayerId() == board_item->GetBrdLayerId() )
947  {
948  *item = *board_item;
949  break;
950  }
951  }
952  else // dielectric layer: see m_DielectricLayerId for identification
953  {
954  // Compare dielectric layer with dielectric layer
955  if( board_item->GetBrdLayerId() != UNDEFINED_LAYER )
956  continue;
957 
958  if( item->GetDielectricLayerId() == board_item->GetDielectricLayerId() )
959  {
960  *item = *board_item;
961  break;
962  }
963  }
964  }
965  }
966  }
967 
968  int row = 0;
969 
970  for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() )
971  {
972  for( int sub_idx = 0; sub_idx < item->GetSublayersCount(); sub_idx++ )
973  {
974  BOARD_STACKUP_ROW_UI_ITEM ui_row_item = createRowData( row, item, sub_idx );
975  m_rowUiItemsList.emplace_back( ui_row_item );
976 
977  row++;
978  }
979  }
980 
981  updateIconColor();
982 }
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, 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 426 of file panel_board_stackup.cpp.

427 {
428  int thickness = 0;
429 
431  {
432  BOARD_STACKUP_ITEM* item = ui_item.m_Item;
433 
434  if( !item->IsThicknessEditable() || !ui_item.m_isEnabled )
435  continue;
436 
437  wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_ThicknessCtrl );
438  wxString txt = textCtrl->GetValue();
439 
440  int item_thickness = ValueFromString( m_frame->GetUserUnits(), txt );
441  thickness += item_thickness;
442  }
443 
444  wxString thicknessStr = StringFromValue( m_units, thickness, true );
445 
446  // The text in the event will translate to the value for the text control
447  // and is only updated if it changed
448  m_tcCTValue->SetValue( thicknessStr );
449 }
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:416
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:204
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(), onAdjustDielectricThickness(), onCopperLayersSelCount(), 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 related 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 1453 of file panel_board_stackup.cpp.

1455 {
1456  wxBitmapComboBox* combo = new wxBitmapComboBox( m_scGridWin, ID_ITEM_COLOR + aRow,
1457  wxEmptyString, wxDefaultPosition,
1458  wxDefaultSize, 0, nullptr, wxCB_READONLY );
1459 
1460  // Fills the combo box with choice list + bitmaps
1461  const FAB_LAYER_COLOR* color_list = GetColorStandardList();
1462 
1463  for( int ii = 0; ii < GetColorStandardListCount(); ii++ )
1464  {
1465  const FAB_LAYER_COLOR& item = color_list[ii];
1466 
1467  wxColor curr_color = item.m_Color;
1468  wxString label;
1469 
1470  // Defined colors have a name, the user color uses the HTML notation ( i.e. #FF0000)
1471  if( GetColorStandardListCount()-1 > (int)combo->GetCount() )
1472  {
1473  label = wxGetTranslation( item.m_ColorName );
1474  }
1475  else // Append the user color, if specified, else add a default user color
1476  {
1477  if( aStackupItem && aStackupItem->GetColor().StartsWith( "#" ) )
1478  curr_color = wxColour( aStackupItem->GetColor() );
1479 
1480  label = wxString::Format( _( "Custom (%s)" ),
1481  curr_color.GetAsString( wxC2S_HTML_SYNTAX ) );
1482  }
1483 
1484  wxBitmap layerbmp( m_colorSwatchesSize.x, m_colorSwatchesSize.y );
1485  LAYER_SELECTOR::DrawColorSwatch( layerbmp, COLOR4D( 0, 0, 0, 0 ), COLOR4D( curr_color ) );
1486 
1487  combo->Append( label, layerbmp );
1488  }
1489 
1490  // Ensure the size of the widget is enough to show the text and the icon
1491  // We have to have a selected item when doing this, because otherwise GTK
1492  // will just choose a random size that might not fit the actual data
1493  // (such as in cases where the font size is very large). So we select
1494  // the longest item (which should be the last item), and size it that way.
1495  int sel = combo->GetSelection();
1496  combo->SetSelection( combo->GetCount() - 1 );
1497 
1498  combo->SetMinSize( wxSize( -1, -1 ) );
1499  wxSize bestSize = combo->GetBestSize();
1500 
1501  bestSize.x = bestSize.x + m_colorSwatchesSize.x;
1502  combo->SetMinSize( bestSize );
1503  combo->SetSelection( sel );
1504 
1505  // add the wxBitmapComboBox to wxControl list, to be able to disconnect the event
1506  // on exit
1507  m_controlItemsList.push_back( combo );
1508 
1509  combo->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED,
1510  wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onColorSelected ),
1511  nullptr, this );
1512 
1513  return combo;
1514 }
std::vector< wxControl * > m_controlItemsList
static void DrawColorSwatch(wxBitmap &aLayerbmp, const COLOR4D &aBackground, const COLOR4D &aColor)
wxString GetColor() const
int GetColorStandardListCount()
#define _(s)
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
const FAB_LAYER_COLOR * GetColorStandardList()
void onColorSelected(wxCommandEvent &event)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

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, 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 676 of file panel_board_stackup.cpp.

679 {
680  wxASSERT( aStackupItem );
681  wxASSERT( aSublayerIdx >= 0 && aSublayerIdx < aStackupItem->GetSublayersCount() );
682 
683  BOARD_STACKUP_ROW_UI_ITEM ui_row_item( aStackupItem, aSublayerIdx );
684  BOARD_STACKUP_ITEM* item = aStackupItem;
685  int row = aRow;
686 
687  const FAB_LAYER_COLOR* color_list = GetColorStandardList();
688 
689  // Add color swatch icon. The color will be updated later,
690  // when all widgets are initialized
691  wxStaticBitmap* bitmap = new wxStaticBitmap( m_scGridWin, wxID_ANY, wxNullBitmap );
692  m_fgGridSizer->Add( bitmap, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 4 );
693  ui_row_item.m_Icon = bitmap;
694 
695  ui_row_item.m_isEnabled = true;
696 
697  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
698  {
699  wxString lname = item->FormatDielectricLayerName();
700 
701  if( item->GetSublayersCount() > 1 )
702  {
703  lname << " (" << aSublayerIdx+1 << "/" << item->GetSublayersCount() << ")";
704  }
705 
706  wxStaticText* st_text = new wxStaticText( m_scGridWin, wxID_ANY, lname );
707  m_fgGridSizer->Add( st_text, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
708  ui_row_item.m_LayerName = st_text;
709 
710  // For a dielectric layer, the layer type choice is not for each sublayer,
711  // only for the first (aSublayerIdx = 0), and is common to all sublayers
712  if( aSublayerIdx == 0 )
713  {
714  wxChoice* choice = new wxChoice( m_scGridWin, wxID_ANY, wxDefaultPosition,
715  wxDefaultSize, m_core_prepreg_choice );
716  choice->SetSelection( item->GetTypeName() == KEY_CORE ? 0 : 1 );
717  m_fgGridSizer->Add( choice, 1, wxEXPAND|wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
718 
719  ui_row_item.m_LayerTypeCtrl = choice;
720  }
721  else
722  {
723  ui_row_item.m_LayerTypeCtrl = addSpacer();
724  }
725  }
726  else
727  {
728  item->SetLayerName( m_board->GetLayerName( item->GetBrdLayerId() ) );
729  wxStaticText* st_text = new wxStaticText( m_scGridWin, wxID_ANY, item->GetLayerName() );
730  m_fgGridSizer->Add( st_text, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 1 );
731  st_text->Show( true );
732  ui_row_item.m_LayerName = st_text;
733 
734  wxString lname;
735 
736  if( item->GetTypeName() == KEY_COPPER )
737  lname = _( "Copper" );
738  else
739  lname = wxGetTranslation( item->GetTypeName() );
740 
741  st_text = new wxStaticText( m_scGridWin, wxID_ANY, lname );
742  m_fgGridSizer->Add( st_text, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
743  ui_row_item.m_LayerTypeCtrl = st_text;
744  }
745 
746  if( item->IsMaterialEditable() )
747  {
748  wxString matName = item->GetMaterial( aSublayerIdx );
749  addMaterialChooser( ID_ITEM_MATERIAL+row, &matName, ui_row_item );
750  }
751  else
752  {
753  ui_row_item.m_MaterialCtrl = addSpacer();
754  }
755 
756  if( item->IsThicknessEditable() )
757  {
758  wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, ID_ITEM_THICKNESS+row );
759  textCtrl->SetMinSize( m_numericTextCtrlSize );
760  textCtrl->SetValue( StringFromValue( m_units, item->GetThickness( aSublayerIdx ), true ) );
761  m_fgGridSizer->Add( textCtrl, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
762  m_controlItemsList.push_back( textCtrl );
763  textCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED,
764  wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onThicknessChange ),
765  nullptr, this );
766  ui_row_item.m_ThicknessCtrl = textCtrl;
767 
768  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
769  {
770  wxCheckBox* cb_box = new wxCheckBox( m_scGridWin, ID_ITEM_THICKNESS_LOCKED+row,
771  wxEmptyString );
772  cb_box->SetValue( item->IsThicknessLocked( aSublayerIdx ) );
773  m_fgGridSizer->Add( cb_box, 0, wxALIGN_CENTER_VERTICAL, 2 );
774  ui_row_item.m_ThicknessLockCtrl = cb_box;
775  }
776  else
777  {
778  ui_row_item.m_ThicknessLockCtrl = addSpacer();
779  }
780  }
781  else
782  {
783  ui_row_item.m_ThicknessCtrl = addSpacer();
784  ui_row_item.m_ThicknessLockCtrl = addSpacer();
785  }
786 
787  if( item->IsColorEditable() )
788  {
789  int color_idx = 0;
790  int user_color_idx = GetColorUserDefinedListIdx();
791 
792  // Always init the user-defined color for a row
793  ui_row_item.m_UserColor = GetColorStandardList()[user_color_idx].m_Color;
794 
795  if( item->GetColor().StartsWith( "#" ) ) // User defined color
796  {
797  wxColour color( item->GetColor() );
798  ui_row_item.m_UserColor = color;
799  color_idx = user_color_idx;
800  }
801  else
802  {
803  for( int ii = 0; ii < GetColorStandardListCount(); ii++ )
804  {
805  if( color_list[ii].m_ColorName == item->GetColor() )
806  {
807  color_idx = ii;
808  break;
809  }
810  }
811  }
812 
813  wxBitmapComboBox* bm_combo = createBmComboBox( item, row );
814  m_fgGridSizer->Add( bm_combo, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
815  bm_combo->SetSelection( color_idx );
816  ui_row_item.m_ColorCtrl = bm_combo;
817  }
818  else
819  {
820  ui_row_item.m_ColorCtrl = addSpacer();
821  }
822 
823  if( item->HasEpsilonRValue() )
824  {
825  wxString txt;
826  txt.Printf( "%.2f", item->GetEpsilonR( aSublayerIdx ) );
827  wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, wxID_ANY, wxEmptyString,
828  wxDefaultPosition, m_numericFieldsSize );
829  textCtrl->SetValue( txt );
830  m_fgGridSizer->Add( textCtrl, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
831  ui_row_item.m_EpsilonCtrl = textCtrl;
832  }
833  else
834  {
835  ui_row_item.m_EpsilonCtrl = addSpacer();
836  }
837 
838  if( item->HasLossTangentValue() )
839  {
840  wxString txt;
841  txt.Printf( "%g", item->GetLossTangent( aSublayerIdx ) );
842  wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, wxID_ANY, wxEmptyString,
843  wxDefaultPosition, m_numericFieldsSize );
844  textCtrl->SetValue( txt );
845  m_fgGridSizer->Add( textCtrl, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
846  ui_row_item.m_LossTgCtrl = textCtrl;
847  }
848  else
849  {
850  ui_row_item.m_LossTgCtrl = addSpacer();
851  }
852 
853  return ui_row_item;
854 }
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:360
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)
int GetThickness(int aDielectricSubLayer=0) const
bool IsColorEditable() const
bool HasLossTangentValue() const
double GetEpsilonR(int aDielectricSubLayer=0) const
bool IsMaterialEditable() const
wxString GetTypeName() const
#define _(s)
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
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:204
#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, 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 221 of file panel_board_stackup.cpp.

222 {
223  // Disconnect Events connected to items in m_controlItemsList
224  for( wxControl* item: m_controlItemsList )
225  {
226  wxBitmapComboBox* cb = dynamic_cast<wxBitmapComboBox*>( item );
227 
228  if( cb )
229  {
230  cb->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED,
231  wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onColorSelected ),
232  nullptr, this );
233  }
234 
235  wxButton* matButt = dynamic_cast<wxButton*>( item );
236 
237  if( matButt )
238  {
239  matButt->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
240  wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onMaterialChange ),
241  nullptr, this );
242  }
243 
244  wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( item );
245 
246  if( textCtrl )
247  {
248  textCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED,
249  wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onThicknessChange ),
250  nullptr, this );
251  }
252  }
253 }
std::vector< wxControl * > m_controlItemsList
void onThicknessChange(wxCommandEvent &event)
void onColorSelected(wxCommandEvent &event)
void onMaterialChange(wxCommandEvent &event)

References m_controlItemsList, 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 1400 of file panel_board_stackup.cpp.

1401 {
1402  BOARD_STACKUP_ITEM* st_item = dynamic_cast<BOARD_STACKUP_ITEM*>( GetStackupItem( aRow ) );
1403 
1404  wxASSERT( st_item );
1405  wxColor color;
1406 
1407  if( ! st_item )
1408  return color;
1409 
1410  switch( st_item->GetType() )
1411  {
1412  case BS_ITEM_TYPE_COPPER: color = copperColor; break;
1414  case BS_ITEM_TYPE_SOLDERMASK: color = GetSelectedColor( aRow ); break;
1415  case BS_ITEM_TYPE_SILKSCREEN: color = GetSelectedColor( aRow ); break;
1416  case BS_ITEM_TYPE_SOLDERPASTE: color = pasteColor; break;
1417 
1418  default:
1420  wxFAIL_MSG( "PANEL_SETUP_BOARD_STACKUP::getColorIconItem: unrecognized item type" );
1421  break;
1422  }
1423 
1424  wxASSERT_MSG( color.IsOk(), "Invalid color in PCB stackup" );
1425 
1426  return color;
1427 }
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 452 of file panel_board_stackup.cpp.

453 {
454  return ( m_choiceCopperLayers->GetSelection() + 1 ) * 2;
455 }

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 412 of file panel_board_stackup.cpp.

413 {
414  wxBitmapComboBox* choice = dynamic_cast<wxBitmapComboBox*>( m_rowUiItemsList[aRow].m_ColorCtrl );
415  wxASSERT( choice );
416 
417  int idx = choice ? choice->GetSelection() : 0;
418 
419  if( idx != GetColorUserDefinedListIdx() ) // a standard color is selected
420  return GetColorStandardList()[idx].m_Color;
421 
422  return m_rowUiItemsList[aRow].m_UserColor;
423 }
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 1388 of file panel_board_stackup.cpp.

1389 {
1390  return m_rowUiItemsList[aRow].m_Item;
1391 }
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 1394 of file panel_board_stackup.cpp.

1395 {
1396  return m_rowUiItemsList[aRow].m_SubItem;
1397 }
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 1200 of file panel_board_stackup.cpp.

1201 {
1202  BOARD* savedBrd = m_board;
1203  BOARD_DESIGN_SETTINGS* savedSettings = m_brdSettings;
1204  m_brdSettings = &aBoard->GetDesignSettings();
1205 
1207  synchronizeWithBoard( true );
1208 
1209  m_brdSettings = savedSettings;
1210  m_board = savedBrd;
1211 
1214 }
PANEL_SETUP_LAYERS * m_panelLayers
void computeBoardThickness()
Recompute the board thickness and update the textbox.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:588
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 256 of file panel_board_stackup.cpp.

257 {
258  wxArrayString headers;
259  headers.Add( _( "Layers" ) );
260 
261  // Build Dielectric layers list:
262  std::vector<wxArrayString> d_list;
263  std::vector<int> rows; // indexes of row values for each selectable item
264  int row = -1;
265 
267  {
268  row++;
269 
270  if( !item.m_isEnabled )
271  continue;
272 
273  BOARD_STACKUP_ITEM* brd_stackup_item = item.m_Item;
274 
275  if( brd_stackup_item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
276  {
277  wxArrayString d_item;
278 
279  if( brd_stackup_item->GetSublayersCount() > 1 )
280  {
281  d_item.Add( wxString::Format( _( "Layer '%s' (sublayer %d/%d)" ),
282  brd_stackup_item->FormatDielectricLayerName(),
283  item.m_SubItem+1,
284  brd_stackup_item->GetSublayersCount() ) );
285  }
286  else
287  {
288  d_item.Add( brd_stackup_item->FormatDielectricLayerName() );
289  }
290 
291  d_list.emplace_back( d_item );
292  rows.push_back( row );
293  }
294  }
295 
296  EDA_LIST_DIALOG dlg( m_parentDialog, _( "Add Dielectric Layer" ), headers, d_list );
297  dlg.SetListLabel( _( "Select layer to add:" ) );
298  dlg.HideFilter();
299 
300  if( dlg.ShowModal() == wxID_OK && dlg.GetSelection() >= 0 )
301  {
302  row = rows[ dlg.GetSelection() ];
303 
304  BOARD_STACKUP_ITEM* brd_stackup_item = m_rowUiItemsList[row].m_Item;
305  int new_sublayer = m_rowUiItemsList[row].m_SubItem;
306 
307  // Insert a new item after the selected item
308  brd_stackup_item->AddDielectricPrms( new_sublayer+1 );
309 
312  }
313 }
BOARD_STACKUP_ITEM_TYPE GetType() const
int GetSublayersCount() const
void computeBoardThickness()
Recompute the board thickness and update the textbox.
A dialog which shows:
#define _(s)
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
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(), EDA_LIST_DIALOG::GetSelection(), BOARD_STACKUP_ITEM::GetSublayersCount(), BOARD_STACKUP_ITEM::GetType(), EDA_LIST_DIALOG::HideFilter(), m_parentDialog, m_rowUiItemsList, rebuildLayerStackPanel(), and EDA_LIST_DIALOG::SetListLabel().

◆ onAdjustDielectricThickness()

void PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_BOARD_STACKUP_BASE.

Definition at line 140 of file panel_board_stackup.cpp.

141 {
142  // The list of items that can be modified:
143  std::vector< BOARD_STACKUP_ROW_UI_ITEM* > items_candidate;
144 
145  // Some dielectric layers can have a locked thickness, so calculate the min
146  // acceptable thickness
147  int min_thickness = 0;
148 
150  {
151  BOARD_STACKUP_ITEM* item = ui_item.m_Item;
152 
153  if( !item->IsThicknessEditable() || !ui_item.m_isEnabled )
154  continue;
155 
156  // We are looking for locked thickness items only:
157  wxCheckBox* cb_box = dynamic_cast<wxCheckBox*> ( ui_item.m_ThicknessLockCtrl );
158 
159  if( cb_box && !cb_box->GetValue() )
160  {
161  items_candidate.push_back( &ui_item );
162  continue;
163  }
164 
165  wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_ThicknessCtrl );
166  wxString txt = textCtrl->GetValue();
167 
168  int item_thickness = ValueFromString( m_frame->GetUserUnits(), txt );
169  min_thickness += item_thickness;
170  }
171 
172  wxString title;
173 
174  if( min_thickness == 0 )
175  title.Printf( _( "Enter board thickness in %s" ),
177  else
178  title.Printf( _( "Enter expected board thickness in %s (min value %s)" ),
180  StringFromValue( m_frame->GetUserUnits(), min_thickness ) );
181 
182  wxTextEntryDialog dlg( this, title, _( "Adjust not locked dielectric thickness layers" ) );
183 
184  if( dlg.ShowModal() != wxID_OK )
185  return;
186 
187  wxString result = dlg.GetValue();
188 
189  int iu_thickness = ValueFromString( m_frame->GetUserUnits(), result );
190 
191  if( iu_thickness <= min_thickness )
192  {
193  wxMessageBox( wxString::Format( _("Too small value (min value %s %s). Aborted" ),
194  StringFromValue( m_frame->GetUserUnits(), min_thickness ),
196  return;
197  }
198 
199  // Now adjust not locked dielectric thickness layers:
200 
201  if( items_candidate.size() )
202  {
203  int thickness_layer = ( iu_thickness - min_thickness ) / items_candidate.size();
204  wxString txt = StringFromValue( m_frame->GetUserUnits(), thickness_layer );
205 
206  for( BOARD_STACKUP_ROW_UI_ITEM* ui_item : items_candidate )
207  {
208  wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item->m_ThicknessCtrl );
209  textCtrl->SetValue( txt );
210  }
211  }
212  else
213  {
214  wxMessageBox( _( "All dielectric thickness layers are locked" ) );
215  }
216 
218 }
void computeBoardThickness()
Recompute the board thickness and update the textbox.
wxString GetAbbreviatedUnitsLabel(EDA_UNITS aUnit, EDA_DATA_TYPE aType)
Get the units string for a given units type.
Definition: base_units.cpp:424
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:416
#define _(s)
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
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
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:204
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
std::vector< BOARD_STACKUP_ROW_UI_ITEM > m_rowUiItemsList

References _, computeBoardThickness(), Format(), GetAbbreviatedUnitsLabel(), EDA_BASE_FRAME::GetUserUnits(), BOARD_STACKUP_ITEM::IsThicknessEditable(), m_frame, m_rowUiItemsList, StringFromValue(), and ValueFromString().

◆ onColorSelected()

void PANEL_SETUP_BOARD_STACKUP::onColorSelected ( wxCommandEvent &  event)
private

Definition at line 1239 of file panel_board_stackup.cpp.

1240 {
1241  int idx = event.GetSelection();
1242  int item_id = event.GetId();
1243 
1244  int row = item_id - ID_ITEM_COLOR;
1245 
1246  if( GetColorStandardListCount()-1 == idx ) // Set user color is the last option in list
1247  {
1248  wxColour userColour = m_rowUiItemsList[row].m_UserColor;
1249  COLOR4D currentColor( userColour.IsOk() ? userColour : COLOR4D( 0.5, 0.5, 0.5, 1.0 ) );
1250  COLOR4D defaultColor( GetColorStandardList()[GetColorUserDefinedListIdx()].m_Color );
1251 
1252  DIALOG_COLOR_PICKER dlg( this, currentColor, false, nullptr, defaultColor );
1253 
1254  // Give a time-slice to close the menu before opening the dialog.
1255  // (Only matters on some versions of GTK.)
1256  wxSafeYield();
1257 
1258  if( dlg.ShowModal() == wxID_OK )
1259  {
1260  wxBitmapComboBox* combo = static_cast<wxBitmapComboBox*>( FindWindowById( item_id ) );
1261 
1262  wxColour color = dlg.GetColor().ToColour();
1263 
1264  m_rowUiItemsList[row].m_UserColor = color;
1265 
1266  wxString label = wxString::Format( _( "Custom (%s)" ),
1267  color.GetAsString( wxC2S_HTML_SYNTAX ) );
1268 
1269  combo->SetString( idx, label );
1270 
1271  wxBitmap layerbmp( m_colorSwatchesSize.x, m_colorSwatchesSize.y );
1272  LAYER_SELECTOR::DrawColorSwatch( layerbmp, COLOR4D( 0, 0, 0, 0 ), COLOR4D( color ) );
1273  combo->SetItemBitmap( combo->GetCount()-1, layerbmp );
1274  }
1275  }
1276 
1277  updateIconColor( row );
1278 }
static void DrawColorSwatch(wxBitmap &aLayerbmp, const COLOR4D &aBackground, const COLOR4D &aColor)
int color
Definition: DXF_plotter.cpp:60
int GetColorStandardListCount()
int GetColorUserDefinedListIdx()
#define _(s)
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
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:103
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().

◆ onCopperLayersSelCount()

void PANEL_SETUP_BOARD_STACKUP::onCopperLayersSelCount ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_BOARD_STACKUP_BASE.

Definition at line 131 of file panel_board_stackup.cpp.

132 {
136  Layout();
137 }
void updateCopperLayerCount()
Updates the enabled copper layers when the dropdown is changed.
void computeBoardThickness()
Recompute the board thickness and update the textbox.
void showOnlyActiveLayers()
Show or do not show items in m_fgGridSizer according to the stackup of the current board.

References computeBoardThickness(), showOnlyActiveLayers(), and updateCopperLayerCount().

◆ onExportToClipboard()

void PANEL_SETUP_BOARD_STACKUP::onExportToClipboard ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_BOARD_STACKUP_BASE.

Definition at line 391 of file panel_board_stackup.cpp.

392 {
394  return;
395 
396  // Build a ASCII representation of stackup and copy it in the clipboard
397  wxString report = BuildStackupReport( m_stackup, m_units );
398 
399  wxLogNull doNotLog; // disable logging of failed clipboard actions
400 
401  if( wxTheClipboard->Open() )
402  {
403  // This data objects are held by the clipboard,
404  // so do not delete them in the app.
405  wxTheClipboard->SetData( new wxTextDataObject( report ) );
406  wxTheClipboard->Flush(); // Allow data to be available after closing KiCad
407  wxTheClipboard->Close();
408  }
409 }
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 1217 of file panel_board_stackup.cpp.

1218 {
1219  // First, verify the list of layers currently in stackup:
1220  // if it does not mach the list of layers set in PANEL_SETUP_LAYERS
1221  // rebuild the panel
1222 
1223  // the current enabled layers in PANEL_SETUP_LAYERS
1224  // Note: the number of layer can change, but not the layers properties
1226 
1227  if( m_enabledLayers != layersList )
1228  {
1229  m_enabledLayers = layersList;
1230 
1231  synchronizeWithBoard( false );
1232 
1233  Layout();
1234  Refresh();
1235  }
1236 }
PANEL_SETUP_LAYERS * m_panelLayers
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:502
void synchronizeWithBoard(bool aFullSync)
Synchronize the full stackup shown in m_fgGridSizer according to the stackup of the current board and...
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().

◆ onMaterialChange()

void PANEL_SETUP_BOARD_STACKUP::onMaterialChange ( wxCommandEvent &  event)
private

Definition at line 1281 of file panel_board_stackup.cpp.

1282 {
1283  // Ensure m_materialList contains all materials already in use in stackup list
1284  // and add it is missing
1286  return;
1287 
1288  for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() )
1289  {
1290  DIELECTRIC_SUBSTRATE_LIST* mat_list = nullptr;
1291 
1292  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
1293  mat_list = &m_delectricMatList;
1294  else if( item->GetType() == BS_ITEM_TYPE_SOLDERMASK )
1295  mat_list = &m_solderMaskMatList;
1296  else if( item->GetType() == BS_ITEM_TYPE_SILKSCREEN )
1297  mat_list = &m_silkscreenMatList;
1298 
1299  else
1300  continue;
1301 
1302  for( int ii = 0; ii < item->GetSublayersCount(); ii++ )
1303  {
1304  int idx = mat_list->FindSubstrate( item->GetMaterial( ii ),
1305  item->GetEpsilonR( ii ),
1306  item->GetLossTangent( ii ) );
1307 
1308  if( idx < 0 && !item->GetMaterial().IsEmpty() )
1309  {
1310  // This material is not in list: add it
1311  DIELECTRIC_SUBSTRATE new_mat;
1312  new_mat.m_Name = item->GetMaterial( ii );
1313  new_mat.m_EpsilonR = item->GetEpsilonR( ii );
1314  new_mat.m_LossTangent = item->GetLossTangent( ii );
1315  mat_list->AppendSubstrate( new_mat );
1316  }
1317  }
1318  }
1319 
1320  int row = event.GetId() - ID_ITEM_MATERIAL;
1321  BOARD_STACKUP_ITEM* item = m_rowUiItemsList[row].m_Item;
1322  int sub_item = m_rowUiItemsList[row].m_SubItem;
1323  DIELECTRIC_SUBSTRATE_LIST* item_mat_list = nullptr;
1324 
1325  switch( item->GetType() )
1326  {
1327  case BS_ITEM_TYPE_DIELECTRIC: item_mat_list = &m_delectricMatList; break;
1328  case BS_ITEM_TYPE_SOLDERMASK: item_mat_list = &m_solderMaskMatList; break;
1329  case BS_ITEM_TYPE_SILKSCREEN: item_mat_list = &m_silkscreenMatList; break;
1330  default: item_mat_list = nullptr; break;
1331  }
1332 
1333  wxCHECK( item_mat_list, /* void */ );
1334 
1335  DIALOG_DIELECTRIC_MATERIAL dlg( this, *item_mat_list );
1336 
1337  if( dlg.ShowModal() != wxID_OK )
1338  return;
1339 
1340  DIELECTRIC_SUBSTRATE substrate = dlg.GetSelectedSubstrate();
1341 
1342  if( substrate.m_Name.IsEmpty() ) // No substrate specified
1343  return;
1344 
1345  // Update Name, Epsilon R and Loss tg
1346  item->SetMaterial( substrate.m_Name, sub_item );
1347  item->SetEpsilonR( substrate.m_EpsilonR, sub_item );
1348  item->SetLossTangent( substrate.m_LossTangent, sub_item );
1349 
1350  wxTextCtrl* textCtrl;
1351  textCtrl = static_cast<wxTextCtrl*>( m_rowUiItemsList[row].m_MaterialCtrl );
1352  textCtrl->SetValue( item->GetMaterial( sub_item ) );
1353 
1354  // some layers have a material choice but not EpsilonR ctrl
1355  if( item->HasEpsilonRValue() )
1356  {
1357  textCtrl = dynamic_cast<wxTextCtrl*>( m_rowUiItemsList[row].m_EpsilonCtrl );
1358 
1359  if( textCtrl )
1360  textCtrl->SetValue( item->FormatEpsilonR( sub_item ) );
1361  }
1362 
1363  // some layers have a material choice but not loss tg ctrl
1364  if( item->HasLossTangentValue() )
1365  {
1366  textCtrl = dynamic_cast<wxTextCtrl*>( m_rowUiItemsList[row].m_LossTgCtrl );
1367 
1368  if( textCtrl )
1369  textCtrl->SetValue( item->FormatLossTangent( sub_item ) );
1370  }
1371 }
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 316 of file panel_board_stackup.cpp.

317 {
318  wxArrayString headers;
319  headers.Add( _( "Layers" ) );
320 
321  // Build deletable Dielectric layers list.
322  // A layer can be deleted if there are 2 (or more) dielectric sub-layers
323  // between 2 copper layers
324  std::vector<wxArrayString> d_list;
325  std::vector<int> rows; // indexes of row values for each selectable item
326  int row = 0; // row index in m_rowUiItemsList of items in choice list
327 
328  // Build the list of dielectric layers:
329  for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() )
330  {
331  if( !item->IsEnabled() || item->GetType() != BS_ITEM_TYPE_DIELECTRIC ||
332  item->GetSublayersCount() <= 1 )
333  {
334  row++;
335  continue;
336  }
337 
338  for( int ii = 0; ii < item->GetSublayersCount(); ii++ )
339  {
340  wxArrayString d_item;
341 
342  d_item.Add( wxString::Format( _( "Layer '%s' sublayer %d/%d" ),
343  item->FormatDielectricLayerName(),
344  ii+1,
345  item->GetSublayersCount() ) );
346 
347  d_list.emplace_back( d_item );
348  rows.push_back( row++ );
349  }
350  }
351 
352  EDA_LIST_DIALOG dlg( m_parentDialog, _( "Remove Dielectric Layer" ), headers, d_list );
353  dlg.SetListLabel( _( "Select layer to remove:" ) );
354  dlg.HideFilter();
355 
356  if( dlg.ShowModal() == wxID_OK && dlg.GetSelection() >= 0 )
357  {
358  row = rows[ dlg.GetSelection() ];
359  BOARD_STACKUP_ITEM* brd_stackup_item = m_rowUiItemsList[ row ].m_Item;
360  int sublayer = m_rowUiItemsList[ row ].m_SubItem;
361 
362  // Remove the selected sub item for the selected dielectric layer
363  brd_stackup_item->RemoveDielectricPrms( sublayer );
364 
367  }
368 }
void computeBoardThickness()
Recompute the board thickness and update the textbox.
A dialog which shows:
#define _(s)
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
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(), EDA_LIST_DIALOG::GetSelection(), EDA_LIST_DIALOG::HideFilter(), m_parentDialog, m_rowUiItemsList, m_stackup, rebuildLayerStackPanel(), BOARD_STACKUP_ITEM::RemoveDielectricPrms(), and EDA_LIST_DIALOG::SetListLabel().

◆ onRemoveDielUI()

void PANEL_SETUP_BOARD_STACKUP::onRemoveDielUI ( wxUpdateUIEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_BOARD_STACKUP_BASE.

Definition at line 371 of file panel_board_stackup.cpp.

372 {
373  // The m_buttonRemoveDielectricLayer wxButton is enabled only if a dielectric
374  // layer can be removed, i.e. if dielectric layers have sublayers
375  for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() )
376  {
377  if( !item->IsEnabled() || item->GetType() != BS_ITEM_TYPE_DIELECTRIC )
378  continue;
379 
380  if( item->GetSublayersCount() > 1 )
381  {
382  event.Enable( true );
383  return;
384  }
385  }
386 
387  event.Enable( false );
388 }
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 1374 of file panel_board_stackup.cpp.

1375 {
1376  int row = event.GetId() - ID_ITEM_THICKNESS;
1377  wxString value = event.GetString();
1378 
1379  BOARD_STACKUP_ITEM* item = GetStackupItem( row );
1380  int idx = GetSublayerId( row );
1381 
1382  item->SetThickness( ValueFromString( m_frame->GetUserUnits(), value ), idx );
1383 
1385 }
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:416
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 857 of file panel_board_stackup.cpp.

858 {
859  wxWindowUpdateLocker locker( m_scGridWin );
860  m_scGridWin->Hide();
861 
862  // Rebuild the stackup for the dialog, after dielectric parameters list is modified
863  // (added/removed):
864 
865  // First, delete all ui objects, because wxID values will be no longer valid for many widgets
867  m_controlItemsList.clear();
868 
869  // Delete widgets (handled by the wxPanel parent)
871  {
872  // This remove and delete the current ui_item.m_MaterialCtrl sizer
873  ui_item.m_MaterialCtrl->SetSizer( nullptr );
874 
875  // Delete other widgets
876  delete ui_item.m_Icon; // Color icon in first column (column 1)
877  delete ui_item.m_LayerName; // string shown in column 2
878  delete ui_item.m_LayerTypeCtrl; // control shown in column 3
879  delete ui_item.m_MaterialCtrl; // control shown in column 4, with m_MaterialButt
880  delete ui_item.m_MaterialButt; // control shown in column 4, with m_MaterialCtrl
881  delete ui_item.m_ThicknessCtrl; // control shown in column 5
882  delete ui_item.m_ThicknessLockCtrl;// control shown in column 6
883  delete ui_item.m_ColorCtrl; // control shown in column 7
884  delete ui_item.m_EpsilonCtrl; // control shown in column 8
885  delete ui_item.m_LossTgCtrl; // control shown in column 9
886  }
887 
888  m_rowUiItemsList.clear();
889 
890  // In order to recreate a clean grid layer list, we have to delete and
891  // recreate the sizer m_fgGridSizer (just deleting items in this size is not enough)
892  // therefore we also have to add the "old" title items to the newly recreated m_fgGridSizer:
893  m_scGridWin->SetSizer( nullptr ); // This remove and delete the current m_fgGridSizer
894 
895  m_fgGridSizer = new wxFlexGridSizer( 0, 9, 0, 2 );
896  m_fgGridSizer->SetFlexibleDirection( wxHORIZONTAL );
897  m_fgGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
898  m_fgGridSizer->SetHGap( 6 );
899  m_scGridWin->SetSizer( m_fgGridSizer );
900 
901  // Re-add "old" title items:
902  const int sizer_flags = wxALIGN_CENTER_VERTICAL | wxALL | wxALIGN_CENTER_HORIZONTAL;
903  m_fgGridSizer->Add( m_staticTextLayer, 0, sizer_flags, 2 );
904  m_fgGridSizer->Add( m_staticTextType, 0, sizer_flags, 2 );
905  m_fgGridSizer->Add( m_staticTextLayerId, 0, sizer_flags, 5 );
906  m_fgGridSizer->Add( m_staticTextMaterial, 0, sizer_flags, 2 );
907  m_fgGridSizer->Add( m_staticTextThickness, 0, sizer_flags, 2 );
908  m_fgGridSizer->Add( m_bitmapLockThickness, 0, sizer_flags, 1 );
909  m_fgGridSizer->Add( m_staticTextColor, 0, sizer_flags, 2 );
910  m_fgGridSizer->Add( m_staticTextEpsilonR, 0, sizer_flags, 2 );
911  m_fgGridSizer->Add( m_staticTextLossTg, 0, sizer_flags, 2 );
912 
913 
914  // Now, rebuild the widget list from the new m_stackup items:
915  buildLayerStackPanel( false );
916 
917  // Now enable/disable stackup items, according to the m_enabledLayers config
919 
920  m_scGridWin->Layout();
921  m_scGridWin->Show();
922 }
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 possible 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 593 of file panel_board_stackup.cpp.

594 {
595 
596  // Now enable/disable stackup items, according to the m_enabledLayers config
597  // Calculate copper layer count from m_enabledLayers, and *do not use* brd_stackup
598  // for that, because it is not necessary up to date
599  // (for instance after modifying the layer count from the panel layers in dialog)
601  int copperLayersCount = copperMask.count();
602 
603  for( BOARD_STACKUP_ROW_UI_ITEM& ui_row_item: m_rowUiItemsList )
604  {
605  bool show_item;
606  BOARD_STACKUP_ITEM* item = ui_row_item.m_Item;
607 
608  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
609  // the m_DielectricLayerId is not a copper layer id, it is a dielectric idx from 1
610  show_item = item->GetDielectricLayerId() < copperLayersCount;
611  else
612  show_item = m_enabledLayers[item->GetBrdLayerId()];
613 
614  item->SetEnabled( show_item );
615 
616  ui_row_item.m_isEnabled = show_item;
617 
618  // Show or not items of this row:
619  ui_row_item.m_Icon->Show( show_item );
620  ui_row_item.m_LayerName->Show( show_item );
621  ui_row_item.m_LayerTypeCtrl->Show( show_item );
622  ui_row_item.m_MaterialCtrl->Show( show_item );
623 
624  if( ui_row_item.m_MaterialButt )
625  ui_row_item.m_MaterialButt->Show( show_item );
626 
627  ui_row_item.m_ThicknessCtrl->Show( show_item );
628  ui_row_item.m_ThicknessLockCtrl->Show( show_item );
629  ui_row_item.m_ColorCtrl->Show( show_item );
630  ui_row_item.m_EpsilonCtrl->Show( show_item );
631  ui_row_item.m_LossTgCtrl->Show( show_item );
632  }
633 }
BOARD_STACKUP_ITEM_TYPE GetType() const
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:502
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 onCopperLayersSelCount(), 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 472 of file panel_board_stackup.cpp.

473 {
474  const BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
475 
476  if( aFullSync )
477  {
478  m_choiceCopperLayers->SetSelection( ( m_board->GetCopperLayerCount() / 2 ) - 1 );
479  m_impedanceControlled->SetValue( brd_stackup.m_HasDielectricConstrains );
480  }
481 
482  for( BOARD_STACKUP_ROW_UI_ITEM& ui_row_item : m_rowUiItemsList )
483  {
484  BOARD_STACKUP_ITEM* item = ui_row_item.m_Item;
485  int sub_item = ui_row_item.m_SubItem;
486 
487  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
488  {
489  wxChoice* choice = dynamic_cast<wxChoice*>( ui_row_item.m_LayerTypeCtrl );
490 
491  if( choice )
492  choice->SetSelection( item->GetTypeName() == KEY_CORE ? 0 : 1 );
493  }
494 
495  if( item->IsMaterialEditable() )
496  {
497  wxTextCtrl* matName = dynamic_cast<wxTextCtrl*>( ui_row_item.m_MaterialCtrl );
498 
499  if( matName )
500  {
501  if( IsPrmSpecified( item->GetMaterial( sub_item ) ) )
502  matName->SetValue( item->GetMaterial( sub_item ) );
503  else
504  matName->SetValue( wxGetTranslation( NotSpecifiedPrm() ) );
505  }
506  }
507 
508  if( item->IsThicknessEditable() )
509  {
510  wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( ui_row_item.m_ThicknessCtrl );
511 
512  if( textCtrl )
513  textCtrl->SetValue( StringFromValue( m_units,
514  item->GetThickness( sub_item ), true ) );
515 
516  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
517  {
518  wxCheckBox* cb_box = dynamic_cast<wxCheckBox*> ( ui_row_item.m_ThicknessLockCtrl );
519 
520  if( cb_box )
521  cb_box->SetValue( item->IsThicknessLocked( sub_item ) );
522  }
523  }
524 
525  if( item->IsColorEditable() )
526  {
527  auto bm_combo = dynamic_cast<wxBitmapComboBox*>( ui_row_item.m_ColorCtrl );
528  int color_idx = 0;
529 
530  if( item->GetColor().StartsWith( "#" ) ) // User defined color
531  {
532  wxColour color( item->GetColor() );
533  ui_row_item.m_UserColor = color;
534  color_idx = GetColorUserDefinedListIdx();
535 
536  if( bm_combo ) // Update user color shown in the wxBitmapComboBox
537  {
538  wxString label = wxString::Format( _( "Custom (%s)" ),
539  color.GetAsString( wxC2S_HTML_SYNTAX ) );
540 
541  bm_combo->SetString( color_idx, label );
542  wxBitmap layerbmp( m_colorSwatchesSize.x, m_colorSwatchesSize.y );
544  bm_combo->SetItemBitmap( color_idx, layerbmp );
545  }
546  }
547  else
548  {
549  const FAB_LAYER_COLOR* color_list = GetColorStandardList();
550 
551  for( int ii = 0; ii < GetColorStandardListCount(); ii++ )
552  {
553  if( color_list[ii].m_ColorName == item->GetColor() )
554  {
555  color_idx = ii;
556  break;
557  }
558  }
559  }
560 
561  if( bm_combo )
562  bm_combo->SetSelection( color_idx );
563  }
564 
565  if( item->HasEpsilonRValue() )
566  {
567  wxString txt;
568  txt.Printf( "%.2f", item->GetEpsilonR( sub_item ) );
569  wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( ui_row_item.m_EpsilonCtrl );
570 
571  if( textCtrl )
572  textCtrl->SetValue( txt );
573  }
574 
575  if( item->HasLossTangentValue() )
576  {
577  wxString txt;
578  txt.Printf( "%g", item->GetLossTangent( sub_item ) );
579  wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( ui_row_item.m_LossTgCtrl );
580 
581  if( textCtrl )
582  textCtrl->SetValue( txt );
583  }
584  }
585 
586  // Now enable/disable stackup items, according to the m_enabledLayers config
588 
589  updateIconColor();
590 }
BOARD_STACKUP_ITEM_TYPE GetType() const
static void DrawColorSwatch(wxBitmap &aLayerbmp, const COLOR4D &aBackground, const COLOR4D &aColor)
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
#define _(s)
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
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)
int GetCopperLayerCount() const
Definition: board.cpp:453
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:204
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:103
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 986 of file panel_board_stackup.cpp.

987 {
988  wxString txt;
989  wxString error_msg;
990  bool success = true;
991  double value;
992  int row = 0;
993 
995  {
996  // Skip stackup items useless for the current board
997  if( !ui_item.m_isEnabled )
998  {
999  row++;
1000  continue;
1001  }
1002 
1003  BOARD_STACKUP_ITEM* item = ui_item.m_Item;
1004  int sub_item = ui_item.m_SubItem;
1005 
1006  // Add sub layer if there is a new sub layer:
1007  while( item->GetSublayersCount() <= sub_item )
1008  item->AddDielectricPrms( item->GetSublayersCount() );
1009 
1010  if( sub_item == 0 ) // Name only main layer
1011  item->SetLayerName( ui_item.m_LayerName->GetLabel() );
1012 
1013  if( item->HasEpsilonRValue() )
1014  {
1015  wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_EpsilonCtrl );
1016  txt = textCtrl->GetValue();
1017 
1018  if( txt.ToDouble( &value ) && value >= 0.0 )
1019  item->SetEpsilonR( value, sub_item );
1020  else if( txt.ToCDouble( &value ) && value >= 0.0 )
1021  item->SetEpsilonR( value, sub_item );
1022  else
1023  {
1024  success = false;
1025  error_msg << _( "Incorrect value for Epsilon R (Epsilon R must be positive or "
1026  "null if not used)" );
1027  }
1028  }
1029 
1030  if( item->HasLossTangentValue() )
1031  {
1032  wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_LossTgCtrl );
1033  txt = textCtrl->GetValue();
1034 
1035  if( txt.ToDouble( &value ) && value >= 0.0 )
1036  item->SetLossTangent( value, sub_item );
1037  else if( txt.ToCDouble( &value ) && value >= 0.0 )
1038  item->SetLossTangent( value, sub_item );
1039  else
1040  {
1041  success = false;
1042 
1043  if( !error_msg.IsEmpty() )
1044  error_msg << "\n";
1045 
1046  error_msg << _( "Incorrect value for Loss tg (Loss tg must be positive or null "
1047  "if not used)" );
1048  }
1049  }
1050 
1051  if( item->IsMaterialEditable() )
1052  {
1053  wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_MaterialCtrl );
1054  item->SetMaterial( textCtrl->GetValue(), sub_item );
1055 
1056  // Ensure the not specified mat name is the keyword, not its translation
1057  // to avoid any issue is the language setting changes
1058  if( !IsPrmSpecified( item->GetMaterial( sub_item ) ) )
1059  item->SetMaterial( NotSpecifiedPrm(), sub_item );
1060  }
1061 
1062  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
1063  {
1064  // Choice is Core or Prepreg. Sublayers have no choice:
1065  wxChoice* choice = dynamic_cast<wxChoice*>( ui_item.m_LayerTypeCtrl );
1066 
1067  if( choice )
1068  {
1069  int idx = choice->GetSelection();
1070 
1071  if( idx == 0 )
1072  item->SetTypeName( KEY_CORE );
1073  else
1074  item->SetTypeName( KEY_PREPREG );
1075  }
1076  }
1077 
1078  if( item->IsThicknessEditable() )
1079  {
1080  wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_ThicknessCtrl );
1081  txt = textCtrl->GetValue();
1082 
1083  int new_thickness = ValueFromString( m_frame->GetUserUnits(), txt );
1084  item->SetThickness( new_thickness, sub_item );
1085 
1086  if( new_thickness < 0 )
1087  {
1088  success = false;
1089 
1090  if( !error_msg.IsEmpty() )
1091  error_msg << "\n";
1092 
1093  error_msg << _( "A layer thickness is < 0. Fix it" );
1094  }
1095 
1096  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
1097  {
1098  // Dielectric thickness layer can have a locked thickness:
1099  wxCheckBox* cb_box = static_cast<wxCheckBox*>
1100  ( ui_item.m_ThicknessLockCtrl );
1101  item->SetThicknessLocked( cb_box && cb_box->GetValue(), sub_item );
1102  }
1103  }
1104 
1105  if( sub_item == 0 && item->IsColorEditable() )
1106  {
1107  const FAB_LAYER_COLOR* color_list = GetColorStandardList();
1108 
1109  wxBitmapComboBox* choice = dynamic_cast<wxBitmapComboBox*>( ui_item.m_ColorCtrl );
1110 
1111  if( choice )
1112  {
1113  int idx = choice->GetSelection();
1114 
1115  if( idx == GetColorUserDefinedListIdx() )
1116  {
1117  wxColour color = ui_item.m_UserColor;
1118  item->SetColor( color.GetAsString( wxC2S_HTML_SYNTAX ) );
1119  }
1120  else
1121  {
1122  item->SetColor( color_list[idx].m_ColorName );
1123  }
1124  }
1125  }
1126 
1127  row++;
1128  }
1129 
1130  if( !success )
1131  {
1132  wxMessageBox( error_msg, _( "Errors" ) );
1133  return false;
1134  }
1135 
1137 
1138  return true;
1139 }
BOARD_STACKUP_ITEM_TYPE GetType() const
bool HasEpsilonRValue() const
void SetTypeName(const wxString &aName)
int GetSublayersCount() const
int color
Definition: DXF_plotter.cpp:60
int GetColorUserDefinedListIdx()
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
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:416
wxString NotSpecifiedPrm()
bool IsColorEditable() const
bool HasLossTangentValue() const
bool IsMaterialEditable() const
#define _(s)
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)
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(), 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_frame, BOARD_STACKUP::m_HasDielectricConstrains, PANEL_SETUP_BOARD_STACKUP_BASE::m_impedanceControlled, m_rowUiItemsList, m_stackup, NotSpecifiedPrm(), 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(), and ValueFromString().

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

◆ TransferDataFromWindow()

bool PANEL_SETUP_BOARD_STACKUP::TransferDataFromWindow ( )
override

Definition at line 1142 of file panel_board_stackup.cpp.

1143 {
1145  return false;
1146 
1147  // NOTE: Copper layer count is transferred via PANEL_SETUP_LAYERS even though it is configured
1148  // on this page, because the logic for confirming deletion of board items on deleted layers is
1149  // on that panel and it doesn't make sense to split it up.
1150 
1152 
1153  STRING_FORMATTER old_stackup;
1154 
1155  // FormatBoardStackup() (using FormatInternalUnits()) expects a "C" locale
1156  // to execute some tests. So switch to the suitable locale
1157  LOCALE_IO dummy;
1158  brd_stackup.FormatBoardStackup( &old_stackup, m_board, 0 );
1159 
1160  brd_stackup.m_FinishType = m_stackup.m_FinishType;
1164  brd_stackup.m_EdgePlating = m_stackup.m_EdgePlating;
1165 
1166  // copy enabled items to the new board stackup
1167  brd_stackup.RemoveAll();
1168 
1169  for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() )
1170  {
1171  if( item->IsEnabled() )
1172  brd_stackup.Add( new BOARD_STACKUP_ITEM( *item ) );
1173  }
1174 
1175  STRING_FORMATTER new_stackup;
1176  brd_stackup.FormatBoardStackup( &new_stackup, m_board, 0 );
1177 
1178  bool modified = old_stackup.GetString() != new_stackup.GetString();
1179  int thickness = brd_stackup.BuildBoardThicknessFromStackup();
1180 
1181  if( m_brdSettings->GetBoardThickness() != thickness )
1182  {
1183  m_brdSettings->SetBoardThickness( thickness );
1184  modified = true;
1185  }
1186 
1187  if( !m_brdSettings->m_HasStackup )
1188  {
1189  m_brdSettings->m_HasStackup = true;
1190  modified = true;
1191  }
1192 
1193  if( modified )
1194  m_frame->OnModify();
1195 
1196  return true;
1197 }
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.
void SetBoardThickness(int aThickness)
int BuildBoardThicknessFromStackup() const
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:71
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:438
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:414

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 458 of file panel_board_stackup.cpp.

459 {
460  int copperCount = GetCopperLayerCount();
461 
462  wxASSERT( copperCount >= 2 );
463 
465  m_enabledLayers &= ~LSET::InternalCuMask();
466 
467  for( int i = 1; i < copperCount - 1; i++ )
468  m_enabledLayers.set( F_Cu + i );
469 }
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:502
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition: lset.cpp:780
Definition: layer_ids.h:70

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

Referenced by onCopperLayersSelCount().

◆ 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 1430 of file panel_board_stackup.cpp.

1431 {
1432  if( aRow >= 0 )
1433  {
1434  wxStaticBitmap* st_bitmap = m_rowUiItemsList[aRow].m_Icon;
1435 
1436  // explicit depth important under MSW
1437  wxBitmap bmp( m_colorIconsSize.x, m_colorIconsSize.y / 2, 28 );
1438  drawBitmap( bmp, getColorIconItem( aRow ) );
1439  st_bitmap->SetBitmap( bmp );
1440  return;
1441  }
1442 
1443  for( unsigned row = 0; row < m_rowUiItemsList.size(); row++ )
1444  {
1445  // explicit depth important under MSW
1446  wxBitmap bmp( m_colorIconsSize.x, m_colorIconsSize.y / 2, 28 );
1447  drawBitmap( bmp, getColorIconItem( row ) );
1448  m_rowUiItemsList[row].m_Icon->SetBitmap( bmp );
1449  }
1450 }
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_buttonAdjust

wxButton* PANEL_SETUP_BOARD_STACKUP_BASE::m_buttonAdjust
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 258 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 256 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 241 of file panel_board_stackup.h.

Referenced by onMaterialChange().

◆ m_enabledLayers

LSET PANEL_SETUP_BOARD_STACKUP::m_enabledLayers
private

◆ 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 255 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

◆ 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 245 of file panel_board_stackup.h.

Referenced by onMaterialChange().

◆ m_solderMaskMatList

DIELECTRIC_SUBSTRATE_LIST PANEL_SETUP_BOARD_STACKUP::m_solderMaskMatList
private

Definition at line 243 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: