2019-07-27 19:09:43 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <convert_to_biu.h>
|
|
|
|
#include <macros.h> // arrayDim definition
|
|
|
|
#include <pcb_edit_frame.h>
|
|
|
|
#include <class_board.h>
|
2020-06-28 01:42:09 +00:00
|
|
|
#include <dialogs/dialog_color_picker.h>
|
2019-07-27 19:09:43 +00:00
|
|
|
#include <widgets/paged_dialog.h>
|
|
|
|
#include <widgets/layer_box_selector.h>
|
|
|
|
#include <wx/rawbmp.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <math/util.h> // for KiROUND
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
#include "panel_board_stackup.h"
|
|
|
|
#include <panel_setup_layers.h>
|
2019-09-06 09:26:27 +00:00
|
|
|
#include "board_stackup_reporter.h"
|
2019-09-05 19:00:14 +00:00
|
|
|
#include <bitmaps.h>
|
2019-09-06 09:26:27 +00:00
|
|
|
#include <wx/clipbrd.h>
|
|
|
|
#include <wx/dataobj.h>
|
2019-09-09 18:30:43 +00:00
|
|
|
#include "dialog_dielectric_list_manager.h"
|
2019-11-14 15:26:05 +00:00
|
|
|
#include <wx/wupdlock.h>
|
2020-08-05 14:49:07 +00:00
|
|
|
#include <wx/richmsgdlg.h>
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
// Some wx widget ID to know what widget has fired a event:
|
2019-11-14 15:26:05 +00:00
|
|
|
#define ID_INCREMENT 256 // space between 2 ID type. Bigger than the layer count max
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
// The actual widget IDs are the base id + the row index.
|
|
|
|
// they are used in events to know the row index of the control that fired the event
|
|
|
|
enum WIDGETS_IDS
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
ID_ITEM_MATERIAL = 10000, // Be sure it is higher than other IDs
|
|
|
|
// used in the board setup dialog
|
2019-07-27 19:09:43 +00:00
|
|
|
ID_ITEM_THICKNESS = ID_ITEM_MATERIAL + ID_INCREMENT,
|
|
|
|
ID_ITEM_THICKNESS_LOCKED = ID_ITEM_THICKNESS + ID_INCREMENT,
|
|
|
|
ID_ITEM_COLOR = ID_ITEM_THICKNESS_LOCKED + ID_INCREMENT,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Default colors to draw icons:
|
|
|
|
static wxColor copperColor( 220, 180, 30 );
|
2019-09-06 18:59:13 +00:00
|
|
|
static wxColor dielectricColor( 75, 120, 75 );
|
2019-07-27 19:09:43 +00:00
|
|
|
static wxColor pasteColor( 200, 200, 200 );
|
|
|
|
|
|
|
|
static void drawBitmap( wxBitmap& aBitmap, wxColor aColor );
|
|
|
|
|
|
|
|
|
|
|
|
PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame,
|
|
|
|
PANEL_SETUP_LAYERS* aPanelLayers ):
|
2019-09-24 12:33:28 +00:00
|
|
|
PANEL_SETUP_BOARD_STACKUP_BASE( aParent->GetTreebook() ),
|
|
|
|
m_delectricMatList( DIELECTRIC_SUBSTRATE_LIST::DL_MATERIAL_DIELECTRIC ),
|
|
|
|
m_solderMaskMatList( DIELECTRIC_SUBSTRATE_LIST::DL_MATERIAL_SOLDERMASK ),
|
|
|
|
m_silkscreenMatList( DIELECTRIC_SUBSTRATE_LIST::DL_MATERIAL_SILKSCREEN )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2020-08-04 23:40:59 +00:00
|
|
|
m_parentDialog = aParent;
|
2019-07-27 19:09:43 +00:00
|
|
|
m_frame = aFrame;
|
|
|
|
m_panelLayers = aPanelLayers;
|
|
|
|
m_board = m_frame->GetBoard();
|
|
|
|
m_brdSettings = &m_board->GetDesignSettings();
|
|
|
|
m_units = aFrame->GetUserUnits();
|
|
|
|
|
|
|
|
m_enabledLayers = m_board->GetEnabledLayers() & BOARD_STACKUP::StackupAllowedBrdLayers();
|
2020-08-05 14:49:07 +00:00
|
|
|
m_stackupMismatch = false;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
// Calculates a good size for color swatches (icons) in this dialog
|
|
|
|
wxClientDC dc( this );
|
|
|
|
m_colorSwatchesSize = dc.GetTextExtent( "XX" );
|
2019-09-27 15:12:24 +00:00
|
|
|
m_colorComboSize = dc.GetTextExtent( wxString::Format( "XXX %s XXX",
|
|
|
|
wxGetTranslation( NotSpecifiedPrm() ) ) );
|
2019-09-06 18:59:13 +00:00
|
|
|
m_colorIconsSize = dc.GetTextExtent( "XXXX" );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-09-06 18:59:13 +00:00
|
|
|
// Calculates a good size for wxTextCtrl to enter Epsilon R and Loss tan
|
2019-07-27 19:09:43 +00:00
|
|
|
// ("0.000000" + margins)
|
2019-09-06 18:59:13 +00:00
|
|
|
m_numericFieldsSize = dc.GetTextExtent( "X.XXXXXXX" );
|
2019-07-27 19:09:43 +00:00
|
|
|
m_numericFieldsSize.y = -1; // Use default for the vertical size
|
|
|
|
|
|
|
|
// Calculates a minimal size for wxTextCtrl to enter a dim with units
|
|
|
|
// ("000.0000000 mils" + margins)
|
2019-09-06 18:59:13 +00:00
|
|
|
m_numericTextCtrlSize = dc.GetTextExtent( "XXX.XXXXXXX mils" );
|
2019-07-27 19:09:43 +00:00
|
|
|
m_numericTextCtrlSize.y = -1; // Use default for the vertical size
|
|
|
|
|
2019-09-06 18:59:13 +00:00
|
|
|
// The grid column containing the lock checkbox is kept to a minimal
|
2019-09-05 19:00:14 +00:00
|
|
|
// size. So we use a wxStaticBitmap: set the bitmap itself
|
|
|
|
m_bitmapLockThickness->SetBitmap( KiScaledBitmap( locked_xpm, aFrame ) );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
// Gives a minimal size of wxTextCtrl showing dimensions+units
|
|
|
|
m_thicknessCtrl->SetMinSize( m_numericTextCtrlSize );
|
|
|
|
m_tcCTValue->SetMinSize( m_numericTextCtrlSize );
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
// Prepare dielectric layer type: layer type keyword is "core" or "prepreg"
|
|
|
|
m_core_prepreg_choice.Add( _( "Core" ) );
|
|
|
|
m_core_prepreg_choice.Add( _( "PrePreg" ) );
|
2019-11-11 18:34:48 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
buildLayerStackPanel( true );
|
|
|
|
synchronizeWithBoard( true );
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PANEL_SETUP_BOARD_STACKUP::~PANEL_SETUP_BOARD_STACKUP()
|
|
|
|
{
|
|
|
|
disconnectEvents();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::disconnectEvents()
|
|
|
|
{
|
|
|
|
// Disconnect Events connected to items in m_controlItemsList
|
|
|
|
for( wxControl* item: m_controlItemsList )
|
|
|
|
{
|
|
|
|
wxBitmapComboBox* cb = dynamic_cast<wxBitmapComboBox*>( item );
|
|
|
|
|
|
|
|
if( cb )
|
|
|
|
cb->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED,
|
|
|
|
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onColorSelected ),
|
|
|
|
NULL, this );
|
|
|
|
|
2019-09-09 18:30:43 +00:00
|
|
|
wxButton* matButt = dynamic_cast<wxButton*>( item );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-09-09 18:30:43 +00:00
|
|
|
if( matButt )
|
|
|
|
matButt->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
|
|
|
|
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onMaterialChange ),
|
|
|
|
NULL, this );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( item );
|
|
|
|
|
|
|
|
if( textCtrl )
|
2019-09-25 07:27:36 +00:00
|
|
|
textCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED,
|
|
|
|
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onThicknessChange ),
|
|
|
|
NULL, this );
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
void PANEL_SETUP_BOARD_STACKUP::onAddDielectricLayer( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Build Dielectric layers list:
|
|
|
|
wxArrayString d_list;
|
2019-11-14 15:26:05 +00:00
|
|
|
std::vector<int> rows; // indexes of row values for each selectable item
|
|
|
|
int row = -1;
|
2019-11-11 18:34:48 +00:00
|
|
|
|
|
|
|
for( BOARD_STACKUP_ROW_UI_ITEM& item : m_rowUiItemsList )
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
row++;
|
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
if( !item.m_isEnabled )
|
|
|
|
continue;
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
BOARD_STACKUP_ITEM* brd_stackup_item = item.m_Item;
|
|
|
|
|
|
|
|
if( brd_stackup_item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
|
|
|
|
{
|
|
|
|
if( brd_stackup_item->GetSublayersCount() > 1 )
|
|
|
|
{
|
|
|
|
d_list.Add( wxString::Format( _( "Layer \"%s\" (sublayer %d/%d)" ),
|
|
|
|
brd_stackup_item->FormatDielectricLayerName(),
|
|
|
|
item.m_SubItem+1, brd_stackup_item->GetSublayersCount() ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
d_list.Add( brd_stackup_item->FormatDielectricLayerName() );
|
|
|
|
|
|
|
|
rows.push_back( row );
|
|
|
|
}
|
2019-11-11 18:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Show list
|
|
|
|
int index = wxGetSingleChoiceIndex( wxEmptyString, _("Dielectric Layers List"),
|
|
|
|
d_list);
|
|
|
|
|
|
|
|
if( index < 0 )
|
|
|
|
return;
|
2019-11-14 15:26:05 +00:00
|
|
|
|
|
|
|
row = rows[index];
|
|
|
|
|
|
|
|
BOARD_STACKUP_ITEM* brd_stackup_item = m_rowUiItemsList[row].m_Item;
|
|
|
|
int new_sublayer = m_rowUiItemsList[row].m_SubItem;
|
|
|
|
|
|
|
|
// Insert a new item after the selected item
|
|
|
|
brd_stackup_item->AddDielectricPrms( new_sublayer+1 );
|
|
|
|
|
|
|
|
rebuildLayerStackPanel();
|
2019-11-11 18:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::onRemoveDielectricLayer( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Build deletable Dielectric layers list.
|
2019-11-14 15:26:05 +00:00
|
|
|
// A layer can be deleted if there are 2 (or more) dielectric sub-layers
|
2019-11-11 18:34:48 +00:00
|
|
|
// between 2 copper layers
|
|
|
|
wxArrayString d_list;
|
2019-11-14 15:26:05 +00:00
|
|
|
std::vector<int> rows; // indexes of row values for each selectable item
|
|
|
|
|
2019-11-25 12:30:48 +00:00
|
|
|
int ui_row = 0; // The row index in m_rowUiItemsList of items in choice list
|
2019-11-11 18:34:48 +00:00
|
|
|
|
2019-11-25 12:30:48 +00:00
|
|
|
// Build the list of dielectric layers:
|
2019-11-11 18:34:48 +00:00
|
|
|
for( auto item : m_stackup.GetList() )
|
|
|
|
{
|
2019-11-25 12:30:48 +00:00
|
|
|
if( !item->IsEnabled() || item->GetType() != BS_ITEM_TYPE_DIELECTRIC ||
|
|
|
|
item->GetSublayersCount() <= 1 )
|
|
|
|
{
|
|
|
|
ui_row++;
|
2019-11-14 15:26:05 +00:00
|
|
|
continue;
|
2019-11-25 12:30:48 +00:00
|
|
|
}
|
2019-11-11 18:34:48 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
for( int ii = 0; ii < item->GetSublayersCount(); ii++ )
|
|
|
|
{
|
|
|
|
d_list.Add( wxString::Format( "Layer \"%s\" sublayer %d/%d",
|
2019-11-25 12:30:48 +00:00
|
|
|
item->FormatDielectricLayerName(), ii+1,
|
|
|
|
item->GetSublayersCount() ) );
|
2019-11-11 18:34:48 +00:00
|
|
|
|
2019-11-25 12:30:48 +00:00
|
|
|
rows.push_back( ui_row++ );
|
2019-11-11 18:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-25 12:30:48 +00:00
|
|
|
// Show choice list
|
2019-11-11 18:34:48 +00:00
|
|
|
int index = wxGetSingleChoiceIndex( wxEmptyString, _("Dielectric Layers List"),
|
2019-11-14 15:26:05 +00:00
|
|
|
d_list );
|
2019-11-11 18:34:48 +00:00
|
|
|
|
|
|
|
if( index < 0 )
|
|
|
|
return;
|
2019-11-14 15:26:05 +00:00
|
|
|
|
2019-11-25 12:30:48 +00:00
|
|
|
ui_row = rows[index];
|
2019-11-14 15:26:05 +00:00
|
|
|
|
2019-11-25 12:30:48 +00:00
|
|
|
BOARD_STACKUP_ITEM* brd_stackup_item = m_rowUiItemsList[ui_row].m_Item;
|
|
|
|
int sublayer = m_rowUiItemsList[ui_row].m_SubItem;
|
2019-11-14 15:26:05 +00:00
|
|
|
|
2019-11-25 12:30:48 +00:00
|
|
|
// Remove the selected sub item for the selected dielectric layer
|
2019-11-14 15:26:05 +00:00
|
|
|
brd_stackup_item->RemoveDielectricPrms( sublayer );
|
|
|
|
|
|
|
|
rebuildLayerStackPanel();
|
2019-11-11 18:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::onRemoveDielUI( wxUpdateUIEvent& event )
|
|
|
|
{
|
|
|
|
// The m_buttonRemoveDielectricLayer wxButton is enabled only if a dielectric
|
2019-11-14 15:26:05 +00:00
|
|
|
// layer can be removed, i.e. if dielectric layers have sublayers
|
2019-11-11 18:34:48 +00:00
|
|
|
for( auto item : m_stackup.GetList() )
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
if( !item->IsEnabled() || item->GetType() != BS_ITEM_TYPE_DIELECTRIC )
|
|
|
|
continue;
|
2019-11-11 18:34:48 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->GetSublayersCount() > 1 )
|
2019-11-11 18:34:48 +00:00
|
|
|
{
|
|
|
|
m_buttonRemoveDielectricLayer->Enable( true );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_buttonRemoveDielectricLayer->Enable( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-06 09:26:27 +00:00
|
|
|
void PANEL_SETUP_BOARD_STACKUP::onExportToClipboard( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( !transferDataFromUIToStackup() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Build a ascii representation of stackup and copy it in the clipboard
|
|
|
|
wxString report = BuildStackupReport( m_stackup, m_units );
|
|
|
|
|
|
|
|
if( wxTheClipboard->Open() )
|
|
|
|
{
|
|
|
|
// This data objects are held by the clipboard,
|
|
|
|
// so do not delete them in the app.
|
|
|
|
wxTheClipboard->SetData( new wxTextDataObject( report ) );
|
|
|
|
wxTheClipboard->Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
wxColor PANEL_SETUP_BOARD_STACKUP::GetSelectedColor( int aRow ) const
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxBitmapComboBox* choice = dynamic_cast<wxBitmapComboBox*>( m_rowUiItemsList[aRow].m_ColorCtrl );
|
2019-07-27 19:09:43 +00:00
|
|
|
wxASSERT( choice );
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
int idx = choice ? choice->GetSelection() : 0;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
if( idx != GetColorUserDefinedListIdx() ) // a standard color is selected
|
|
|
|
return GetColorStandardList()[idx].m_Color;
|
2020-06-28 01:42:09 +00:00
|
|
|
else if( m_UserColors.count( aRow ) )
|
|
|
|
return m_UserColors.at( aRow );
|
2019-07-27 19:09:43 +00:00
|
|
|
else
|
2020-06-28 01:42:09 +00:00
|
|
|
return wxNullColour;
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::onUpdateThicknessValue( wxUpdateUIEvent& event )
|
|
|
|
{
|
|
|
|
int thickness = 0;
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
for( BOARD_STACKUP_ROW_UI_ITEM& ui_item : m_rowUiItemsList )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
BOARD_STACKUP_ITEM* item = ui_item.m_Item;
|
|
|
|
|
|
|
|
if( !item->IsThicknessEditable() || !ui_item.m_isEnabled )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_ThicknessCtrl );
|
|
|
|
wxString txt = textCtrl->GetValue();
|
|
|
|
|
2020-10-02 20:51:24 +00:00
|
|
|
int item_thickness = ValueFromString( m_frame->GetUserUnits(), txt );
|
2019-11-14 15:26:05 +00:00
|
|
|
thickness += item_thickness;
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 20:51:24 +00:00
|
|
|
m_tcCTValue->SetValue( StringFromValue( m_units, thickness, true ) );
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
int PANEL_SETUP_BOARD_STACKUP::GetPcbThickness()
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2020-10-02 20:51:24 +00:00
|
|
|
return ValueFromString( m_units, m_thicknessCtrl->GetValue() );
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard( bool aFullSync )
|
|
|
|
{
|
|
|
|
BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
|
|
|
|
|
|
|
|
if( aFullSync )
|
|
|
|
{
|
|
|
|
int thickness = m_brdSettings->GetBoardThickness();
|
2020-10-02 20:51:24 +00:00
|
|
|
m_thicknessCtrl->SetValue( StringFromValue( m_units, thickness, true ) );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
m_rbDielectricConstraint->SetSelection( brd_stackup.m_HasDielectricConstrains ? 1 : 0 );
|
|
|
|
m_choiceEdgeConn->SetSelection( brd_stackup.m_EdgeConnectorConstraints );
|
|
|
|
m_cbCastellatedPads->SetValue( brd_stackup.m_CastellatedPads );
|
|
|
|
m_cbEgdesPlated->SetValue( brd_stackup.m_EdgePlating );
|
|
|
|
|
|
|
|
// find the choice depending on the initial finish setting
|
|
|
|
wxArrayString initial_finish_list = GetCopperFinishStandardList( false );
|
|
|
|
unsigned idx;
|
|
|
|
|
|
|
|
for( idx = 0; idx < initial_finish_list.GetCount(); idx++ )
|
|
|
|
{
|
|
|
|
if( initial_finish_list[idx] == brd_stackup.m_FinishType )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now init the choice (use last choice: "User defined" if not found )
|
|
|
|
if( idx >= initial_finish_list.GetCount() )
|
|
|
|
idx = initial_finish_list.GetCount()-1;
|
|
|
|
|
|
|
|
m_choiceFinish->SetSelection( idx );
|
|
|
|
}
|
|
|
|
|
|
|
|
int row = 0;
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
for( BOARD_STACKUP_ROW_UI_ITEM& ui_row_item : m_rowUiItemsList )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
BOARD_STACKUP_ITEM* item = ui_row_item.m_Item;
|
|
|
|
int sub_item = ui_row_item.m_SubItem;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxChoice* choice = dynamic_cast<wxChoice*>( ui_row_item.m_LayerTypeCtrl );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( choice )
|
|
|
|
choice->SetSelection( item->GetTypeName() == KEY_CORE ? 0 : 1 );
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->IsMaterialEditable() )
|
|
|
|
{
|
|
|
|
wxTextCtrl* matName = dynamic_cast<wxTextCtrl*>( ui_row_item.m_MaterialCtrl );
|
|
|
|
|
|
|
|
if( matName )
|
|
|
|
{
|
|
|
|
if( IsPrmSpecified( item->GetMaterial( sub_item ) ) )
|
|
|
|
matName->SetValue( item->GetMaterial( sub_item ) );
|
|
|
|
else
|
|
|
|
matName->SetValue( wxGetTranslation( NotSpecifiedPrm() ) );
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->IsThicknessEditable() )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( ui_row_item.m_ThicknessCtrl );
|
|
|
|
|
|
|
|
if( textCtrl )
|
|
|
|
textCtrl->SetValue( StringFromValue( m_units,
|
2020-10-02 20:51:24 +00:00
|
|
|
item->GetThickness( sub_item ), true ) );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-12 07:59:02 +00:00
|
|
|
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxCheckBox* cb_box = dynamic_cast<wxCheckBox*> ( ui_row_item.m_ThicknessLockCtrl );
|
2019-11-12 07:59:02 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( cb_box )
|
|
|
|
cb_box->SetValue( item->IsThicknessLocked( sub_item ) );
|
2019-11-12 07:59:02 +00:00
|
|
|
}
|
2019-11-14 15:26:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( item->IsColorEditable() )
|
|
|
|
{
|
|
|
|
auto bm_combo = dynamic_cast<wxBitmapComboBox*>( ui_row_item.m_ColorCtrl );
|
|
|
|
int color_idx = 0;
|
2019-11-12 07:59:02 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->GetColor().StartsWith( "#" ) ) // User defined color
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxColour color( item->GetColor() );
|
|
|
|
m_UserColors[row] = color;
|
|
|
|
color_idx = GetColorUserDefinedListIdx();
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( bm_combo ) // Update user color shown in the wxBitmapComboBox
|
2019-09-27 15:12:24 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
bm_combo->SetString( color_idx, color.GetAsString( wxC2S_HTML_SYNTAX ) );
|
|
|
|
wxBitmap layerbmp( m_colorSwatchesSize.x, m_colorSwatchesSize.y );
|
|
|
|
LAYER_SELECTOR::DrawColorSwatch( layerbmp, COLOR4D(), COLOR4D( color ) );
|
|
|
|
bm_combo->SetItemBitmap( color_idx, layerbmp );
|
2019-09-27 15:12:24 +00:00
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
2019-11-14 15:26:05 +00:00
|
|
|
else
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
const FAB_LAYER_COLOR* color_list = GetColorStandardList();
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
for( int ii = 0; ii < GetColorStandardListCount(); ii++ )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
if( color_list[ii].m_ColorName == item->GetColor() )
|
|
|
|
{
|
|
|
|
color_idx = ii;
|
|
|
|
break;
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( bm_combo )
|
|
|
|
bm_combo->SetSelection( color_idx );
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->HasEpsilonRValue() )
|
|
|
|
{
|
|
|
|
wxString txt;
|
2020-02-26 17:12:24 +00:00
|
|
|
txt.Printf( "%.2f", item->GetEpsilonR( sub_item ) );
|
2019-11-14 15:26:05 +00:00
|
|
|
wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( ui_row_item.m_EpsilonCtrl );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( textCtrl )
|
|
|
|
textCtrl->SetValue( txt );
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->HasLossTangentValue() )
|
|
|
|
{
|
|
|
|
wxString txt;
|
|
|
|
txt.Printf( "%g", item->GetLossTangent( sub_item ) );
|
|
|
|
wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( ui_row_item.m_LossTgCtrl );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( textCtrl )
|
|
|
|
textCtrl->SetValue( txt );
|
|
|
|
}
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
// Now enable/disable stackup items, according to the m_enabledLayers config
|
|
|
|
showOnlyActiveLayers();
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
updateIconColor();
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
void PANEL_SETUP_BOARD_STACKUP::showOnlyActiveLayers()
|
|
|
|
{
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
// Now enable/disable stackup items, according to the m_enabledLayers config
|
|
|
|
// Calculate copper layer count from m_enabledLayers, and *do not use* brd_stackup
|
|
|
|
// for that, because it is not necessary up to date
|
|
|
|
// (for instance after modifying the layer count from the panel layers in dialog)
|
|
|
|
LSET copperMask = m_enabledLayers & ( LSET::ExternalCuMask() | LSET::InternalCuMask() );
|
|
|
|
int copperLayersCount = copperMask.count();
|
|
|
|
|
|
|
|
for( BOARD_STACKUP_ROW_UI_ITEM& ui_row_item: m_rowUiItemsList )
|
|
|
|
{
|
2019-07-27 19:09:43 +00:00
|
|
|
bool show_item;
|
2019-11-14 15:26:05 +00:00
|
|
|
BOARD_STACKUP_ITEM* item = ui_row_item.m_Item;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
|
2019-07-27 19:09:43 +00:00
|
|
|
// the m_DielectricLayerId is not a copper layer id, it is a dielectric idx from 1
|
2019-11-11 18:34:48 +00:00
|
|
|
show_item = item->GetDielectricLayerId() < copperLayersCount;
|
2019-07-27 19:09:43 +00:00
|
|
|
else
|
2019-11-11 18:34:48 +00:00
|
|
|
show_item = m_enabledLayers[item->GetBrdLayerId()];
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
item->SetEnabled( show_item );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
ui_row_item.m_isEnabled = show_item;
|
|
|
|
|
|
|
|
// Show or not items of this row:
|
|
|
|
ui_row_item.m_Icon->Show( show_item );
|
|
|
|
ui_row_item.m_LayerName->Show( show_item );
|
|
|
|
ui_row_item.m_LayerTypeCtrl->Show( show_item );
|
|
|
|
ui_row_item.m_MaterialCtrl->Show( show_item );
|
2019-09-09 18:30:43 +00:00
|
|
|
|
|
|
|
if( ui_row_item.m_MaterialButt )
|
|
|
|
ui_row_item.m_MaterialButt->Show( show_item );
|
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
ui_row_item.m_ThicknessCtrl->Show( show_item );
|
|
|
|
ui_row_item.m_ThicknessLockCtrl->Show( show_item );
|
|
|
|
ui_row_item.m_ColorCtrl->Show( show_item );
|
|
|
|
ui_row_item.m_EpsilonCtrl->Show( show_item );
|
|
|
|
ui_row_item.m_LossTgCtrl->Show( show_item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-09 18:30:43 +00:00
|
|
|
void PANEL_SETUP_BOARD_STACKUP::addMaterialChooser( wxWindowID aId,
|
|
|
|
const wxString * aMaterialName,
|
|
|
|
BOARD_STACKUP_ROW_UI_ITEM& aUiRowItem )
|
|
|
|
{
|
|
|
|
wxBoxSizer* bSizerMat = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
m_fgGridSizer->Add( bSizerMat, 1, wxEXPAND, 2 );
|
|
|
|
wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, wxID_ANY );
|
|
|
|
|
|
|
|
if( aMaterialName )
|
2019-09-27 15:12:24 +00:00
|
|
|
{
|
|
|
|
if( IsPrmSpecified( *aMaterialName ) )
|
|
|
|
textCtrl->SetValue( *aMaterialName );
|
|
|
|
else
|
|
|
|
textCtrl->SetValue( wxGetTranslation( NotSpecifiedPrm() ) );
|
|
|
|
}
|
2019-09-09 18:30:43 +00:00
|
|
|
|
|
|
|
textCtrl->SetMinSize( m_numericTextCtrlSize );
|
|
|
|
bSizerMat->Add( textCtrl, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
|
|
|
|
|
|
|
|
wxButton* m_buttonMat = new wxButton( m_scGridWin, aId, _("..."),
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
|
|
|
|
bSizerMat->Add( m_buttonMat, 0, wxALIGN_CENTER_VERTICAL, 2 );
|
|
|
|
|
|
|
|
m_buttonMat->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
|
|
|
|
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onMaterialChange ),
|
|
|
|
NULL, this );
|
|
|
|
m_controlItemsList.push_back( m_buttonMat );
|
|
|
|
|
|
|
|
aUiRowItem.m_MaterialCtrl = textCtrl;
|
|
|
|
aUiRowItem.m_MaterialButt = m_buttonMat;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-06 18:59:13 +00:00
|
|
|
wxControl* PANEL_SETUP_BOARD_STACKUP::addSpacer()
|
|
|
|
{
|
|
|
|
wxStaticText* emptyText = new wxStaticText( m_scGridWin, wxID_ANY, wxEmptyString );
|
|
|
|
m_fgGridSizer->Add( emptyText, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND );
|
|
|
|
return emptyText;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
|
|
|
|
BOARD_STACKUP_ITEM* aStackupItem, int aSublayerIdx )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxASSERT( aStackupItem );
|
|
|
|
wxASSERT( aSublayerIdx >= 0 && aSublayerIdx < aStackupItem->GetSublayersCount() );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
BOARD_STACKUP_ROW_UI_ITEM ui_row_item( aStackupItem, aSublayerIdx );
|
|
|
|
BOARD_STACKUP_ITEM* item = aStackupItem;
|
|
|
|
int row = aRow;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
const FAB_LAYER_COLOR* color_list = GetColorStandardList();
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
// Add color swatch icon. The color will be updated later,
|
|
|
|
// when all widgets are initialized
|
|
|
|
wxStaticBitmap* bitmap = new wxStaticBitmap( m_scGridWin, wxID_ANY, wxNullBitmap );
|
|
|
|
m_fgGridSizer->Add( bitmap, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT );
|
|
|
|
ui_row_item.m_Icon = bitmap;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
ui_row_item.m_isEnabled = true;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
|
|
|
|
{
|
|
|
|
wxString lname = item->FormatDielectricLayerName();
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->GetSublayersCount() > 1 )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
lname << " (" << aSublayerIdx+1 << "/" << item->GetSublayersCount() << ")";
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
wxStaticText* st_text = new wxStaticText( m_scGridWin, wxID_ANY, lname );
|
|
|
|
m_fgGridSizer->Add( st_text, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
|
|
|
|
ui_row_item.m_LayerName = st_text;
|
|
|
|
|
|
|
|
// For a dielectric layer, the layer type choice is not for each sublayer,
|
|
|
|
// only for the first (aSublayerIdx = 0), and is common to all sublayers
|
|
|
|
if( aSublayerIdx == 0 )
|
|
|
|
{
|
2019-07-27 19:09:43 +00:00
|
|
|
wxChoice* choice = new wxChoice( m_scGridWin, wxID_ANY, wxDefaultPosition,
|
|
|
|
wxDefaultSize, m_core_prepreg_choice );
|
2019-11-11 18:34:48 +00:00
|
|
|
choice->SetSelection( item->GetTypeName() == KEY_CORE ? 0 : 1 );
|
2019-09-06 18:59:13 +00:00
|
|
|
m_fgGridSizer->Add( choice, 0, wxEXPAND|wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
ui_row_item.m_LayerTypeCtrl = choice;
|
|
|
|
}
|
|
|
|
else
|
2019-11-14 15:26:05 +00:00
|
|
|
ui_row_item.m_LayerTypeCtrl = addSpacer();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->SetLayerName( m_board->GetLayerName( item->GetBrdLayerId() ) );
|
|
|
|
wxStaticText* st_text = new wxStaticText( m_scGridWin, wxID_ANY, item->GetLayerName() );
|
|
|
|
m_fgGridSizer->Add( st_text, 0, wxALL|wxALIGN_CENTER_VERTICAL, 1 );
|
|
|
|
st_text->Show( true );
|
|
|
|
ui_row_item.m_LayerName = st_text;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
wxString lname;
|
2019-09-06 18:59:13 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->GetTypeName() == KEY_COPPER )
|
|
|
|
lname = _( "Copper" );
|
|
|
|
else
|
|
|
|
lname = wxGetTranslation( item->GetTypeName() );
|
2019-09-06 18:59:13 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
st_text = new wxStaticText( m_scGridWin, wxID_ANY, lname );
|
|
|
|
m_fgGridSizer->Add( st_text, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
|
|
|
|
ui_row_item.m_LayerTypeCtrl = st_text;
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->IsMaterialEditable() )
|
|
|
|
{
|
|
|
|
wxString matName = item->GetMaterial( aSublayerIdx );
|
|
|
|
addMaterialChooser( ID_ITEM_MATERIAL+row, &matName, ui_row_item );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui_row_item.m_MaterialCtrl = addSpacer();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item->IsThicknessEditable() )
|
|
|
|
{
|
|
|
|
wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, ID_ITEM_THICKNESS+row );
|
|
|
|
textCtrl->SetMinSize( m_numericTextCtrlSize );
|
2020-10-02 20:51:24 +00:00
|
|
|
textCtrl->SetValue( StringFromValue( m_units, item->GetThickness( aSublayerIdx ), true ) );
|
2019-11-14 15:26:05 +00:00
|
|
|
m_fgGridSizer->Add( textCtrl, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
|
|
|
|
m_controlItemsList.push_back( textCtrl );
|
|
|
|
textCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED,
|
|
|
|
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onThicknessChange ),
|
|
|
|
NULL, this );
|
|
|
|
ui_row_item.m_ThicknessCtrl = textCtrl;
|
|
|
|
|
|
|
|
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxCheckBox* cb_box = new wxCheckBox( m_scGridWin, ID_ITEM_THICKNESS_LOCKED+row,
|
|
|
|
wxEmptyString );
|
|
|
|
cb_box->SetValue( item->IsThicknessLocked( aSublayerIdx ) );
|
|
|
|
m_fgGridSizer->Add( cb_box, 0, wxALIGN_CENTER_VERTICAL, 2 );
|
|
|
|
ui_row_item.m_ThicknessLockCtrl = cb_box;
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
2019-09-06 18:59:13 +00:00
|
|
|
else
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
ui_row_item.m_ThicknessLockCtrl = addSpacer();
|
2019-09-06 18:59:13 +00:00
|
|
|
}
|
2019-11-14 15:26:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui_row_item.m_ThicknessCtrl = addSpacer();
|
|
|
|
ui_row_item.m_ThicknessLockCtrl = addSpacer();
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->IsColorEditable() )
|
|
|
|
{
|
|
|
|
int color_idx = 0;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->GetColor().StartsWith( "#" ) ) // User defined color
|
|
|
|
{
|
|
|
|
wxColour color( item->GetColor() );
|
|
|
|
m_UserColors[row] = color;
|
|
|
|
color_idx = GetColorUserDefinedListIdx();
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
for( int ii = 0; ii < GetColorStandardListCount(); ii++ )
|
|
|
|
{
|
|
|
|
if( color_list[ii].m_ColorName == item->GetColor() )
|
|
|
|
{
|
|
|
|
color_idx = ii;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
wxBitmapComboBox* bm_combo = createBmComboBox( item, row );
|
|
|
|
m_colorComboSize.y = bm_combo->GetSize().y;
|
|
|
|
bm_combo->SetMinSize( m_colorComboSize );
|
|
|
|
m_fgGridSizer->Add( bm_combo, 0, wxEXPAND|wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
|
|
|
|
bm_combo->SetSelection( color_idx );
|
|
|
|
ui_row_item.m_ColorCtrl = bm_combo;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui_row_item.m_ColorCtrl = addSpacer();
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->HasEpsilonRValue() )
|
|
|
|
{
|
|
|
|
wxString txt;
|
2020-02-26 17:12:24 +00:00
|
|
|
txt.Printf( "%.2f", item->GetEpsilonR( aSublayerIdx ) );
|
2019-11-14 15:26:05 +00:00
|
|
|
wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, wxID_ANY, wxEmptyString,
|
|
|
|
wxDefaultPosition, m_numericFieldsSize );
|
|
|
|
textCtrl->SetValue( txt );
|
|
|
|
m_fgGridSizer->Add( textCtrl, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
|
|
|
|
ui_row_item.m_EpsilonCtrl = textCtrl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui_row_item.m_EpsilonCtrl = addSpacer();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item->HasLossTangentValue() )
|
|
|
|
{
|
|
|
|
wxString txt;
|
|
|
|
txt.Printf( "%g", item->GetLossTangent( aSublayerIdx ) );
|
|
|
|
wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, wxID_ANY, wxEmptyString,
|
|
|
|
wxDefaultPosition, m_numericFieldsSize );
|
|
|
|
textCtrl->SetValue( txt );
|
|
|
|
m_fgGridSizer->Add( textCtrl, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
|
|
|
|
ui_row_item.m_LossTgCtrl = textCtrl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui_row_item.m_LossTgCtrl = addSpacer();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ui_row_item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::rebuildLayerStackPanel()
|
|
|
|
{
|
|
|
|
// Rebuild the stackup for the dialog, after dielectric parameters list is modified
|
|
|
|
// (added/removed):
|
|
|
|
|
|
|
|
// First, delete all ui objects, because wxID values will be no longer valid for many widgets
|
|
|
|
disconnectEvents();
|
|
|
|
m_controlItemsList.clear();
|
|
|
|
|
|
|
|
// Delete widgets (handled by the wxPanel parent)
|
|
|
|
for( BOARD_STACKUP_ROW_UI_ITEM ui_item: m_rowUiItemsList )
|
|
|
|
{
|
2019-11-25 08:53:14 +00:00
|
|
|
// This remove and delete the current ui_item.m_MaterialCtrl sizer
|
|
|
|
ui_item.m_MaterialCtrl->SetSizer( nullptr );
|
|
|
|
|
|
|
|
// Delete other widgets
|
2019-11-14 15:26:05 +00:00
|
|
|
delete ui_item.m_Icon; // Color icon in first column (column 1)
|
|
|
|
delete ui_item.m_LayerName; // string shown in column 2
|
|
|
|
delete ui_item.m_LayerTypeCtrl; // control shown in column 3
|
|
|
|
delete ui_item.m_MaterialCtrl; // control shown in column 4, with m_MaterialButt
|
|
|
|
delete ui_item.m_MaterialButt; // control shown in column 4, with m_MaterialCtrl
|
|
|
|
delete ui_item.m_ThicknessCtrl; // control shown in column 5
|
|
|
|
delete ui_item.m_ThicknessLockCtrl;// control shown in column 6
|
|
|
|
delete ui_item.m_ColorCtrl; // control shown in column 7
|
|
|
|
delete ui_item.m_EpsilonCtrl; // control shown in column 8
|
|
|
|
delete ui_item.m_LossTgCtrl; // control shown in column 9
|
|
|
|
}
|
|
|
|
|
|
|
|
m_rowUiItemsList.clear();
|
|
|
|
m_UserColors.clear();
|
|
|
|
|
|
|
|
// In order to recreate a clean grid layer list, we have to delete and
|
|
|
|
// recreate the sizer m_fgGridSizer (just deleting items in this size is not enough)
|
|
|
|
// therefore we also have to add the "old" title items to the newly recreated m_fgGridSizer:
|
2019-11-25 08:53:14 +00:00
|
|
|
m_scGridWin->SetSizer( nullptr ); // This remove and delete the current m_fgGridSizer
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
m_fgGridSizer = new wxFlexGridSizer( 0, 9, 0, 2 );
|
|
|
|
m_fgGridSizer->SetFlexibleDirection( wxHORIZONTAL );
|
|
|
|
m_fgGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
|
|
|
m_scGridWin->SetSizer( m_fgGridSizer );
|
|
|
|
|
|
|
|
// Re-add "old" title items:
|
2019-11-25 08:53:14 +00:00
|
|
|
const int sizer_flags = wxALIGN_CENTER_VERTICAL | wxTOP|wxBOTTOM |
|
|
|
|
wxLEFT | wxALIGN_CENTER_HORIZONTAL;
|
|
|
|
m_fgGridSizer->Add( m_staticTextLayer, 0, sizer_flags, 2 );
|
|
|
|
m_fgGridSizer->Add( m_staticTextType, 0, sizer_flags, 2 );
|
|
|
|
m_fgGridSizer->Add( m_staticTextLayerId, 0, wxALL|sizer_flags, 5 );
|
|
|
|
m_fgGridSizer->Add( m_staticTextMaterial, 0, sizer_flags, 2 );
|
|
|
|
m_fgGridSizer->Add( m_staticTextThickness, 0, sizer_flags, 2 );
|
|
|
|
m_fgGridSizer->Add( m_bitmapLockThickness, 0,
|
|
|
|
wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
|
|
|
|
m_fgGridSizer->Add( m_staticTextColor, 0, sizer_flags, 2 );
|
|
|
|
m_fgGridSizer->Add( m_staticTextEpsilonR, 0, sizer_flags, 2 );
|
|
|
|
m_fgGridSizer->Add( m_staticTextLossTg, 0, sizer_flags, 2 );
|
2019-11-14 15:26:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Now, rebuild the widget list from the new m_stackup items:
|
|
|
|
buildLayerStackPanel( false );
|
|
|
|
|
|
|
|
// Now enable/disable stackup items, according to the m_enabledLayers config
|
|
|
|
showOnlyActiveLayers();
|
|
|
|
|
|
|
|
m_scGridWin->Layout();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::buildLayerStackPanel( bool aCreatedInitialStackup )
|
|
|
|
{
|
|
|
|
wxWindowUpdateLocker locker( m_scGridWin );
|
|
|
|
|
|
|
|
// Build a full stackup for the dialog, with a active copper layer count
|
|
|
|
// = current board layer count to calculate a reasonable default stackup:
|
|
|
|
if( aCreatedInitialStackup )
|
|
|
|
{
|
|
|
|
// Creates a full BOARD_STACKUP with 32 copper layers.
|
|
|
|
// extra layers will be hiden later.
|
|
|
|
// but if the number of layer is changed in the dialog, the corresponding
|
|
|
|
// widgets will be available with their previous values.
|
|
|
|
m_stackup.BuildDefaultStackupList( nullptr, m_brdSettings->GetCopperLayerCount() );
|
|
|
|
BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
|
|
|
|
|
|
|
|
// Now initialize all stackup items to the board values, when exist
|
|
|
|
for( BOARD_STACKUP_ITEM* item: m_stackup.GetList() )
|
|
|
|
{
|
|
|
|
// Search for board settings:
|
|
|
|
for( BOARD_STACKUP_ITEM* board_item: brd_stackup.GetList() )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->GetBrdLayerId() != UNDEFINED_LAYER )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->GetBrdLayerId() == board_item->GetBrdLayerId() )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
*item = *board_item;
|
2019-07-27 19:09:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-11-14 15:26:05 +00:00
|
|
|
else // dielectric layer: see m_DielectricLayerId for identification
|
|
|
|
{
|
|
|
|
// Compare dielectric layer with dielectric layer
|
|
|
|
if( board_item->GetBrdLayerId() != UNDEFINED_LAYER )
|
|
|
|
continue;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->GetDielectricLayerId() == board_item->GetDielectricLayerId() )
|
|
|
|
{
|
|
|
|
*item = *board_item;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-06 18:59:13 +00:00
|
|
|
}
|
2019-11-14 15:26:05 +00:00
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
int row = 0;
|
|
|
|
|
|
|
|
for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() )
|
|
|
|
{
|
|
|
|
for( int sub_idx = 0; sub_idx < item->GetSublayersCount(); sub_idx++ )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
BOARD_STACKUP_ROW_UI_ITEM ui_row_item = createRowData( row, item, sub_idx );
|
|
|
|
m_rowUiItemsList.emplace_back( ui_row_item );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
row++;
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( aCreatedInitialStackup )
|
|
|
|
{
|
|
|
|
// Get the translated list of choices and init m_choiceFinish
|
|
|
|
wxArrayString finish_list = GetCopperFinishStandardList( true );
|
|
|
|
m_choiceFinish->Append( finish_list );
|
|
|
|
m_choiceFinish->SetSelection( 0 ); // Will be correctly set later
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
updateIconColor();
|
2019-09-07 12:22:33 +00:00
|
|
|
m_scGridWin->Layout();
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-06 09:26:27 +00:00
|
|
|
|
|
|
|
// Transfer current UI settings to m_stackup but not to the board
|
|
|
|
bool PANEL_SETUP_BOARD_STACKUP::transferDataFromUIToStackup()
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2020-08-05 14:49:07 +00:00
|
|
|
// First, verify the list of layers currently in stackup: if it doesn't match the list
|
|
|
|
// of layers set in PANEL_SETUP_LAYERS prompt the user to update the stackup
|
2019-07-27 19:09:43 +00:00
|
|
|
LSET layersList = m_panelLayers->GetUILayerMask() & BOARD_STACKUP::StackupAllowedBrdLayers();
|
|
|
|
|
|
|
|
if( m_enabledLayers != layersList )
|
|
|
|
{
|
2020-08-05 14:49:07 +00:00
|
|
|
for( size_t i = 0; i < m_parentDialog->GetTreebook()->GetPageCount(); ++i )
|
|
|
|
{
|
|
|
|
if( m_parentDialog->GetTreebook()->GetPage( i ) == this )
|
|
|
|
{
|
|
|
|
m_parentDialog->GetTreebook()->SetSelection( i );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_stackupMismatch = true;
|
2019-07-27 19:09:43 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The board thickness and the thickness from stackup settings should be compatible
|
|
|
|
// so verify that compatibility
|
2020-01-15 18:12:06 +00:00
|
|
|
int pcbThickness = GetPcbThickness() ;
|
2019-07-27 19:09:43 +00:00
|
|
|
int stackup_thickness = 0;
|
|
|
|
|
|
|
|
wxString txt;
|
|
|
|
wxString error_msg;
|
|
|
|
bool success = true;
|
|
|
|
double value;
|
2019-11-14 15:26:05 +00:00
|
|
|
int row = 0;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
for( BOARD_STACKUP_ROW_UI_ITEM& ui_item : m_rowUiItemsList )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
|
|
|
// Skip stackup items useless for the current board
|
2019-11-14 15:26:05 +00:00
|
|
|
if( !ui_item.m_isEnabled )
|
2020-06-28 01:42:09 +00:00
|
|
|
{
|
|
|
|
row++;
|
2019-07-27 19:09:43 +00:00
|
|
|
continue;
|
2020-06-28 01:42:09 +00:00
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
BOARD_STACKUP_ITEM* item = ui_item.m_Item;
|
|
|
|
int sub_item = ui_item.m_SubItem;
|
|
|
|
|
|
|
|
// Add sub layer if there is a new sub layer:
|
|
|
|
while( item->GetSublayersCount() <= sub_item )
|
|
|
|
item->AddDielectricPrms( item->GetSublayersCount() );
|
|
|
|
|
|
|
|
if( sub_item == 0 ) // Name only main layer
|
|
|
|
item->SetLayerName( ui_item.m_LayerName->GetLabel() );
|
2019-09-06 09:26:27 +00:00
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
if( item->HasEpsilonRValue() )
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_EpsilonCtrl );
|
2019-07-27 19:09:43 +00:00
|
|
|
txt = textCtrl->GetValue();
|
|
|
|
|
2019-09-09 18:30:43 +00:00
|
|
|
if( txt.ToDouble( &value ) && value >= 0.0 )
|
2019-11-14 15:26:05 +00:00
|
|
|
item->SetEpsilonR( value, sub_item );
|
2019-09-09 18:30:43 +00:00
|
|
|
else if( txt.ToCDouble( &value ) && value >= 0.0 )
|
2019-11-14 15:26:05 +00:00
|
|
|
item->SetEpsilonR( value, sub_item );
|
2019-07-27 19:09:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
success = false;
|
2019-09-09 18:30:43 +00:00
|
|
|
error_msg << _( "Incorrect value for Epsilon R (Epsilon R must be positive or null if not used)" );
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item->HasLossTangentValue() )
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_LossTgCtrl );
|
2019-07-27 19:09:43 +00:00
|
|
|
txt = textCtrl->GetValue();
|
|
|
|
|
2019-09-09 18:30:43 +00:00
|
|
|
if( txt.ToDouble( &value ) && value >= 0.0 )
|
2019-11-14 15:26:05 +00:00
|
|
|
item->SetLossTangent( value, sub_item );
|
2019-09-09 18:30:43 +00:00
|
|
|
else if( txt.ToCDouble( &value ) && value >= 0.0 )
|
2019-11-14 15:26:05 +00:00
|
|
|
item->SetLossTangent( value, sub_item );
|
2019-07-27 19:09:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
success = false;
|
|
|
|
if( !error_msg.IsEmpty() )
|
|
|
|
error_msg << "\n";
|
2019-09-21 07:50:01 +00:00
|
|
|
error_msg << _( "Incorrect value for Loss tg (Loss tg must be positive or null if not used)" );
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item->IsMaterialEditable() )
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_MaterialCtrl );
|
|
|
|
item->SetMaterial( textCtrl->GetValue(), sub_item );
|
2019-09-27 15:12:24 +00:00
|
|
|
|
|
|
|
// Ensure the not specified mat name is the keyword, not its translation
|
|
|
|
// to avoid any issue is the language setting changes
|
2019-11-14 15:26:05 +00:00
|
|
|
if( !IsPrmSpecified( item->GetMaterial( sub_item ) ) )
|
|
|
|
item->SetMaterial( NotSpecifiedPrm(), sub_item );
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
// Choice is Core or Prepreg. Sublayers have no choice:
|
|
|
|
wxChoice* choice = dynamic_cast<wxChoice*>( ui_item.m_LayerTypeCtrl );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( choice )
|
|
|
|
{
|
|
|
|
int idx = choice->GetSelection();
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( idx == 0 )
|
|
|
|
item->SetTypeName( KEY_CORE );
|
|
|
|
else
|
|
|
|
item->SetTypeName( KEY_PREPREG );
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( item->IsThicknessEditable() )
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_ThicknessCtrl );
|
2019-07-27 19:09:43 +00:00
|
|
|
txt = textCtrl->GetValue();
|
|
|
|
|
2020-10-02 20:51:24 +00:00
|
|
|
int new_thickness = ValueFromString( m_frame->GetUserUnits(), txt );
|
2019-11-14 15:26:05 +00:00
|
|
|
item->SetThickness( new_thickness, sub_item );
|
|
|
|
stackup_thickness += new_thickness;
|
|
|
|
|
|
|
|
if( new_thickness < 0 )
|
|
|
|
{
|
|
|
|
success = false;
|
|
|
|
|
|
|
|
if( !error_msg.IsEmpty() )
|
|
|
|
error_msg << "\n";
|
|
|
|
|
|
|
|
error_msg << _( "A layer thickness is < 0. Fix it" );
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
|
|
|
// Dielectric thickness layer can have a locked thickness:
|
|
|
|
wxCheckBox* cb_box = static_cast<wxCheckBox*>
|
2019-11-14 15:26:05 +00:00
|
|
|
( ui_item.m_ThicknessLockCtrl );
|
|
|
|
item->SetThicknessLocked( cb_box && cb_box->GetValue(), sub_item );
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( sub_item == 0 && item->IsColorEditable() )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
|
|
|
const FAB_LAYER_COLOR* color_list = GetColorStandardList();
|
|
|
|
|
2020-06-28 01:42:09 +00:00
|
|
|
wxBitmapComboBox* choice = dynamic_cast<wxBitmapComboBox*>( ui_item.m_ColorCtrl );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2020-07-19 00:47:03 +00:00
|
|
|
if( choice )
|
2020-06-28 01:42:09 +00:00
|
|
|
{
|
2020-07-19 00:47:03 +00:00
|
|
|
int idx = choice->GetSelection();
|
|
|
|
|
|
|
|
if( idx == GetColorUserDefinedListIdx() )
|
|
|
|
{
|
|
|
|
wxASSERT( m_UserColors.count( row ) );
|
|
|
|
wxColour color = m_UserColors[row];
|
|
|
|
item->SetColor( color.GetAsString( wxC2S_HTML_SYNTAX ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
item->SetColor( color_list[idx].m_ColorName );
|
2020-06-28 01:42:09 +00:00
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
2019-11-14 15:26:05 +00:00
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
row++;
|
|
|
|
}
|
|
|
|
|
2020-01-15 18:12:06 +00:00
|
|
|
int delta = std::abs( stackup_thickness - pcbThickness );
|
|
|
|
double relative_error = pcbThickness ? (double)delta / pcbThickness : 1;
|
2019-11-14 15:26:05 +00:00
|
|
|
const double relative_error_max = 0.01;
|
|
|
|
|
|
|
|
// warn user if relative_error > 0.01
|
|
|
|
if( relative_error > relative_error_max )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Board thickness %s differs from stackup thickness %s\n"
|
|
|
|
"Allowed max error %s" ),
|
2020-10-02 20:51:24 +00:00
|
|
|
StringFromValue( m_units, pcbThickness ),
|
|
|
|
StringFromValue( m_units, stackup_thickness ),
|
|
|
|
StringFromValue( m_units, KiROUND( relative_error_max * pcbThickness) ) );
|
2019-11-14 15:26:05 +00:00
|
|
|
|
|
|
|
if( !error_msg.IsEmpty() )
|
|
|
|
error_msg << "\n";
|
|
|
|
|
|
|
|
error_msg << msg;
|
|
|
|
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
if( !success )
|
|
|
|
{
|
|
|
|
wxMessageBox( error_msg, _( "Errors" ) );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxArrayString finish_list = GetCopperFinishStandardList( false );
|
|
|
|
int finish = m_choiceFinish->GetSelection() >= 0 ? m_choiceFinish->GetSelection() : 0;
|
2019-09-06 09:26:27 +00:00
|
|
|
m_stackup.m_FinishType = finish_list[finish];
|
|
|
|
m_stackup.m_HasDielectricConstrains = m_rbDielectricConstraint->GetSelection() == 1;
|
|
|
|
m_stackup.m_EdgeConnectorConstraints = (BS_EDGE_CONNECTOR_CONSTRAINTS)m_choiceEdgeConn->GetSelection();
|
|
|
|
m_stackup.m_CastellatedPads = m_cbCastellatedPads->GetValue();
|
|
|
|
m_stackup.m_EdgePlating = m_cbEgdesPlated->GetValue();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PANEL_SETUP_BOARD_STACKUP::TransferDataFromWindow()
|
|
|
|
{
|
|
|
|
if( !transferDataFromUIToStackup() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
|
|
|
|
|
2020-10-13 22:05:15 +00:00
|
|
|
STRING_FORMATTER old_stackup;
|
|
|
|
brd_stackup.FormatBoardStackup( &old_stackup, m_board, 0 );
|
|
|
|
|
2019-09-06 09:26:27 +00:00
|
|
|
brd_stackup.m_FinishType = m_stackup.m_FinishType;
|
|
|
|
brd_stackup.m_HasDielectricConstrains = m_stackup.m_HasDielectricConstrains;
|
|
|
|
brd_stackup.m_EdgeConnectorConstraints = m_stackup.m_EdgeConnectorConstraints;
|
|
|
|
brd_stackup.m_CastellatedPads = m_stackup.m_CastellatedPads;
|
|
|
|
brd_stackup.m_EdgePlating = m_stackup.m_EdgePlating;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
// copy enabled items to the new board stackup
|
|
|
|
brd_stackup.RemoveAll();
|
|
|
|
|
2020-10-13 22:05:15 +00:00
|
|
|
for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
if( item->IsEnabled() )
|
2019-11-14 15:26:05 +00:00
|
|
|
brd_stackup.Add( new BOARD_STACKUP_ITEM( *item ) );
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 22:05:15 +00:00
|
|
|
STRING_FORMATTER new_stackup;
|
|
|
|
brd_stackup.FormatBoardStackup( &new_stackup, m_board, 0 );
|
|
|
|
|
|
|
|
bool modified = old_stackup.GetString() != new_stackup.GetString();
|
|
|
|
|
|
|
|
if( m_brdSettings->GetBoardThickness() != GetPcbThickness() )
|
|
|
|
{
|
|
|
|
m_brdSettings->SetBoardThickness( GetPcbThickness() );
|
|
|
|
modified = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !m_brdSettings->m_HasStackup )
|
|
|
|
{
|
|
|
|
m_brdSettings->m_HasStackup = true;
|
|
|
|
modified = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( modified )
|
|
|
|
m_frame->OnModify();
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::ImportSettingsFrom( BOARD* aBoard )
|
|
|
|
{
|
|
|
|
BOARD* savedBrd = m_board;
|
|
|
|
BOARD_DESIGN_SETTINGS* savedSettings = m_brdSettings;
|
|
|
|
m_brdSettings = &aBoard->GetDesignSettings();
|
|
|
|
|
|
|
|
m_enabledLayers = m_panelLayers->GetUILayerMask() & BOARD_STACKUP::StackupAllowedBrdLayers();
|
|
|
|
synchronizeWithBoard( true );
|
|
|
|
|
|
|
|
m_brdSettings = savedSettings;
|
|
|
|
m_board = savedBrd;
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
rebuildLayerStackPanel();
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::OnLayersOptionsChanged( LSET aNewLayerSet )
|
|
|
|
{
|
|
|
|
// First, verify the list of layers currently in stackup:
|
|
|
|
// if it does not mach the list of layers set in PANEL_SETUP_LAYERS
|
|
|
|
// rebuild the panel
|
|
|
|
|
|
|
|
// the current enabled layers in PANEL_SETUP_LAYERS
|
2019-11-14 15:26:05 +00:00
|
|
|
// Note: the number of layer can change, but not the layers properties
|
2019-07-27 19:09:43 +00:00
|
|
|
LSET layersList = m_panelLayers->GetUILayerMask() & BOARD_STACKUP::StackupAllowedBrdLayers();
|
|
|
|
|
|
|
|
if( m_enabledLayers != layersList )
|
|
|
|
{
|
|
|
|
m_enabledLayers = layersList;
|
|
|
|
|
|
|
|
synchronizeWithBoard( false );
|
|
|
|
|
|
|
|
Layout();
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::onCalculateDielectricThickness( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Collect thickness of all layers but dielectric
|
|
|
|
int thickness = 0;
|
|
|
|
int fixed_thickness_cnt = 0;
|
2019-09-08 09:22:52 +00:00
|
|
|
bool thickness_error = false; // True if a locked thickness value in list is < 0
|
2019-11-14 15:26:05 +00:00
|
|
|
int dielectricCount = 0;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
for( BOARD_STACKUP_ROW_UI_ITEM& ui_item : m_rowUiItemsList )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
BOARD_STACKUP_ITEM* item = ui_item.m_Item;
|
|
|
|
int sublayer_idx = ui_item.m_SubItem;
|
|
|
|
|
|
|
|
if( !item->IsThicknessEditable() || !ui_item.m_isEnabled )
|
2019-07-27 19:09:43 +00:00
|
|
|
continue;
|
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
dielectricCount++;
|
|
|
|
|
|
|
|
wxCheckBox* checkBox = static_cast<wxCheckBox*>( ui_item.m_ThicknessLockCtrl );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
if( !checkBox->GetValue() ) // Only not locked dielectric thickness can be modified
|
|
|
|
continue;
|
|
|
|
else
|
2019-09-08 09:22:52 +00:00
|
|
|
{
|
2019-07-27 19:09:43 +00:00
|
|
|
fixed_thickness_cnt++;
|
2019-09-08 09:22:52 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->GetThickness( sublayer_idx ) < 0 )
|
2019-09-08 09:22:52 +00:00
|
|
|
thickness_error = true;
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
thickness += item->GetThickness( sublayer_idx );
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
2019-09-08 09:22:52 +00:00
|
|
|
if( thickness_error )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "A locked dielectric thickness is < 0\n"
|
|
|
|
"Unlock it or change its thickness") );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// the number of adjustable dielectric layers must obvioulsly be > 0
|
|
|
|
// So verify the user has at least one dielectric layer free
|
2019-11-14 15:26:05 +00:00
|
|
|
int adjustableDielectricCount = dielectricCount - fixed_thickness_cnt;
|
2019-09-08 09:22:52 +00:00
|
|
|
|
|
|
|
if( adjustableDielectricCount <= 0 )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "Cannot calculate dielectric thickness\n"
|
|
|
|
"At least one dielectric layer must be not locked") );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
int dielectric_thickness = GetPcbThickness() - thickness;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
if( dielectric_thickness <= 0 ) // fixed thickness is too big: cannot calculate free thickness
|
2019-09-08 09:22:52 +00:00
|
|
|
{
|
2019-07-27 19:09:43 +00:00
|
|
|
wxMessageBox( _( "Cannot calculate dielectric thickness\n"
|
|
|
|
"Fixed thickness too big or board thickness too small") );
|
2019-09-08 09:22:52 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-09-08 09:22:52 +00:00
|
|
|
dielectric_thickness /= adjustableDielectricCount;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
// Update items thickness, and the values displayed on screen
|
2019-11-14 15:26:05 +00:00
|
|
|
for( BOARD_STACKUP_ROW_UI_ITEM& ui_item : m_rowUiItemsList )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
BOARD_STACKUP_ITEM* item = ui_item.m_Item;
|
|
|
|
int sublayer_idx = ui_item.m_SubItem;
|
|
|
|
|
|
|
|
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC && ui_item.m_isEnabled )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxCheckBox* checkBox = static_cast<wxCheckBox*>( ui_item.m_ThicknessLockCtrl );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
if( !checkBox->GetValue() ) // Not locked thickness: can be modified
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
item->SetThickness( dielectric_thickness, sublayer_idx );
|
|
|
|
wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_ThicknessCtrl );
|
2020-10-02 20:51:24 +00:00
|
|
|
textCtrl->SetValue( StringFromValue( m_units, item->GetThickness( sublayer_idx ) ) );
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::onColorSelected( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int idx = event.GetSelection();
|
|
|
|
int item_id = event.GetId();
|
|
|
|
|
|
|
|
int row = item_id - ID_ITEM_COLOR;
|
|
|
|
|
|
|
|
if( GetColorStandardListCount()-1 == idx ) // Set user color is the last option in list
|
|
|
|
{
|
2020-06-28 01:42:09 +00:00
|
|
|
COLOR4D defaultColor( GetColorStandardList()[GetColorUserDefinedListIdx()].m_Color );
|
|
|
|
COLOR4D currentColor(
|
|
|
|
m_UserColors.count( row ) ? m_UserColors[row] : COLOR4D( 0.5, 0.5, 0.5, 1.0 ) );
|
|
|
|
|
|
|
|
DIALOG_COLOR_PICKER dlg( this, currentColor, false, nullptr, defaultColor );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
|
|
|
{
|
|
|
|
wxBitmapComboBox* combo = static_cast<wxBitmapComboBox*>( FindWindowById( item_id ) );
|
2020-06-28 01:42:09 +00:00
|
|
|
|
|
|
|
wxColour color = dlg.GetColor().ToColour();
|
2019-07-27 19:09:43 +00:00
|
|
|
m_UserColors[row] = color;
|
|
|
|
|
|
|
|
combo->SetString( idx, color.GetAsString( wxC2S_HTML_SYNTAX ) );
|
|
|
|
|
|
|
|
wxBitmap layerbmp( m_colorSwatchesSize.x, m_colorSwatchesSize.y );
|
|
|
|
LAYER_SELECTOR::DrawColorSwatch( layerbmp, COLOR4D( 0, 0, 0, 0 ),
|
|
|
|
COLOR4D( color ) );
|
|
|
|
combo->SetItemBitmap( combo->GetCount()-1, layerbmp );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateIconColor( row );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::onMaterialChange( wxCommandEvent& event )
|
|
|
|
{
|
2019-09-24 12:33:28 +00:00
|
|
|
// Ensure m_materialList contains all materials already in use in stackup list
|
2019-09-09 18:30:43 +00:00
|
|
|
// and add it is missing
|
|
|
|
if( !transferDataFromUIToStackup() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() )
|
|
|
|
{
|
2019-09-24 12:33:28 +00:00
|
|
|
DIELECTRIC_SUBSTRATE_LIST* mat_list = nullptr;
|
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
|
2019-09-24 12:33:28 +00:00
|
|
|
mat_list = &m_delectricMatList;
|
2019-11-11 18:34:48 +00:00
|
|
|
else if( item->GetType() == BS_ITEM_TYPE_SOLDERMASK )
|
2019-09-24 12:33:28 +00:00
|
|
|
mat_list = &m_solderMaskMatList;
|
2019-11-11 18:34:48 +00:00
|
|
|
else if( item->GetType() == BS_ITEM_TYPE_SILKSCREEN )
|
2019-09-24 12:33:28 +00:00
|
|
|
mat_list = &m_silkscreenMatList;
|
2019-09-09 18:30:43 +00:00
|
|
|
|
2019-09-24 12:33:28 +00:00
|
|
|
else
|
|
|
|
continue;
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
for( int ii = 0; ii < item->GetSublayersCount(); ii++ )
|
2019-09-24 12:33:28 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
int idx = mat_list->FindSubstrate( item->GetMaterial( ii ),
|
|
|
|
item->GetEpsilonR( ii ),
|
|
|
|
item->GetLossTangent( ii ) );
|
|
|
|
|
|
|
|
if( idx < 0 && !item->GetMaterial().IsEmpty() )
|
|
|
|
{
|
|
|
|
// This material is not in list: add it
|
|
|
|
DIELECTRIC_SUBSTRATE new_mat;
|
|
|
|
new_mat.m_Name = item->GetMaterial( ii );
|
|
|
|
new_mat.m_EpsilonR = item->GetEpsilonR( ii );
|
|
|
|
new_mat.m_LossTangent = item->GetLossTangent( ii );
|
|
|
|
mat_list->AppendSubstrate( new_mat );
|
|
|
|
}
|
2019-09-09 18:30:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-24 12:33:28 +00:00
|
|
|
int row = event.GetId() - ID_ITEM_MATERIAL;
|
2019-11-14 15:26:05 +00:00
|
|
|
BOARD_STACKUP_ITEM* item = m_rowUiItemsList[row].m_Item;
|
|
|
|
int sub_item = m_rowUiItemsList[row].m_SubItem;
|
2019-09-24 12:33:28 +00:00
|
|
|
DIELECTRIC_SUBSTRATE_LIST* item_mat_list = nullptr;
|
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
switch( item->GetType() )
|
2019-09-24 12:33:28 +00:00
|
|
|
{
|
|
|
|
case BS_ITEM_TYPE_DIELECTRIC:
|
|
|
|
item_mat_list = &m_delectricMatList;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BS_ITEM_TYPE_SOLDERMASK:
|
|
|
|
item_mat_list = &m_solderMaskMatList;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BS_ITEM_TYPE_SILKSCREEN:
|
|
|
|
item_mat_list = &m_silkscreenMatList;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
item_mat_list = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
DIALOG_DIELECTRIC_MATERIAL dlg( this, *item_mat_list );
|
2019-09-09 18:30:43 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
DIELECTRIC_SUBSTRATE substrate = dlg.GetSelectedSubstrate();
|
|
|
|
|
|
|
|
if( substrate.m_Name.IsEmpty() ) // No substrate specified
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Update Name, Epsilon R and Loss tg
|
2019-11-14 15:26:05 +00:00
|
|
|
item->SetMaterial( substrate.m_Name, sub_item );
|
|
|
|
item->SetEpsilonR( substrate.m_EpsilonR, sub_item );
|
|
|
|
item->SetLossTangent( substrate.m_LossTangent, sub_item );
|
2019-09-09 18:30:43 +00:00
|
|
|
|
|
|
|
wxTextCtrl* textCtrl;
|
|
|
|
textCtrl = static_cast<wxTextCtrl*>( m_rowUiItemsList[row].m_MaterialCtrl );
|
2019-11-14 15:26:05 +00:00
|
|
|
textCtrl->SetValue( item->GetMaterial( sub_item ) );
|
2019-09-09 14:45:21 +00:00
|
|
|
|
2019-09-26 18:48:28 +00:00
|
|
|
// some layers have a material choice but not EpsilonR ctrl
|
|
|
|
if( item->HasEpsilonRValue() )
|
|
|
|
{
|
|
|
|
textCtrl = dynamic_cast<wxTextCtrl*>( m_rowUiItemsList[row].m_EpsilonCtrl );
|
|
|
|
|
|
|
|
if( textCtrl )
|
2019-11-14 15:26:05 +00:00
|
|
|
textCtrl->SetValue( item->FormatEpsilonR( sub_item ) );
|
2019-09-26 18:48:28 +00:00
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-09-26 18:48:28 +00:00
|
|
|
// some layers have a material choice but not loss tg ctrl
|
|
|
|
if( item->HasLossTangentValue() )
|
|
|
|
{
|
|
|
|
textCtrl = dynamic_cast<wxTextCtrl*>( m_rowUiItemsList[row].m_LossTgCtrl );
|
|
|
|
|
|
|
|
if( textCtrl )
|
2019-11-14 15:26:05 +00:00
|
|
|
textCtrl->SetValue( item->FormatLossTangent( sub_item ) );
|
2019-09-26 18:48:28 +00:00
|
|
|
}
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::onThicknessChange( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int row = event.GetId() - ID_ITEM_THICKNESS;
|
|
|
|
wxString value = event.GetString();
|
|
|
|
|
|
|
|
BOARD_STACKUP_ITEM* item = GetStackupItem( row );
|
2019-11-14 15:26:05 +00:00
|
|
|
int idx = GetSublayerId( row );
|
|
|
|
|
2020-10-02 20:51:24 +00:00
|
|
|
item->SetThickness( ValueFromString( m_frame->GetUserUnits(), value ), idx );
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
BOARD_STACKUP_ITEM* PANEL_SETUP_BOARD_STACKUP::GetStackupItem( int aRow )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
return m_rowUiItemsList[aRow].m_Item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PANEL_SETUP_BOARD_STACKUP::GetSublayerId( int aRow )
|
|
|
|
{
|
|
|
|
return m_rowUiItemsList[aRow].m_SubItem;
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxColor PANEL_SETUP_BOARD_STACKUP::getColorIconItem( int aRow )
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
BOARD_STACKUP_ITEM* st_item = dynamic_cast<BOARD_STACKUP_ITEM*>( GetStackupItem( aRow ) );
|
|
|
|
|
|
|
|
wxASSERT( st_item );
|
2019-07-27 19:09:43 +00:00
|
|
|
wxColor color;
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( ! st_item )
|
|
|
|
return color;
|
|
|
|
|
|
|
|
switch( st_item->GetType() )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2020-08-05 14:49:07 +00:00
|
|
|
case BS_ITEM_TYPE_COPPER: color = copperColor; break;
|
|
|
|
case BS_ITEM_TYPE_DIELECTRIC: color = dielectricColor; break;
|
|
|
|
case BS_ITEM_TYPE_SOLDERMASK: color = GetSelectedColor( aRow ); break;
|
|
|
|
case BS_ITEM_TYPE_SILKSCREEN: color = GetSelectedColor( aRow ); break;
|
|
|
|
case BS_ITEM_TYPE_SOLDERPASTE: color = pasteColor; break;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2020-08-05 14:49:07 +00:00
|
|
|
default:
|
|
|
|
case BS_ITEM_TYPE_UNDEFINED:
|
|
|
|
wxFAIL_MSG( "PANEL_SETUP_BOARD_STACKUP::getColorIconItem: unrecognized item type" );
|
2019-07-27 19:09:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::updateIconColor( int aRow )
|
|
|
|
{
|
|
|
|
if( aRow >= 0 )
|
|
|
|
{
|
|
|
|
wxStaticBitmap* st_bitmap = m_rowUiItemsList[aRow].m_Icon;
|
|
|
|
// explicit depth important under MSW
|
2019-09-06 18:59:13 +00:00
|
|
|
wxBitmap bmp(m_colorIconsSize.x, m_colorIconsSize.y / 2, 24);
|
2019-07-27 19:09:43 +00:00
|
|
|
drawBitmap( bmp, getColorIconItem( aRow ) );
|
|
|
|
st_bitmap->SetBitmap( bmp );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for( unsigned row = 0; row < m_rowUiItemsList.size(); row++ )
|
|
|
|
{
|
|
|
|
// explicit depth important under MSW
|
2019-09-06 18:59:13 +00:00
|
|
|
wxBitmap bmp(m_colorIconsSize.x, m_colorIconsSize.y / 2, 24);
|
2019-07-27 19:09:43 +00:00
|
|
|
drawBitmap( bmp, getColorIconItem( row ) );
|
|
|
|
m_rowUiItemsList[row].m_Icon->SetBitmap( bmp );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-05 14:49:07 +00:00
|
|
|
wxBitmapComboBox* PANEL_SETUP_BOARD_STACKUP::createBmComboBox( BOARD_STACKUP_ITEM* aStackupItem,
|
|
|
|
int aRow )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
|
|
|
wxBitmapComboBox* combo = new wxBitmapComboBox( m_scGridWin, ID_ITEM_COLOR+aRow,
|
|
|
|
wxEmptyString, wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0, nullptr, wxCB_READONLY );
|
|
|
|
// Fills the combo box with choice list + bitmaps
|
2019-09-27 15:12:24 +00:00
|
|
|
const FAB_LAYER_COLOR* color_list = GetColorStandardList();
|
|
|
|
|
|
|
|
for( int ii = 0; ii < GetColorStandardListCount(); ii++ )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-09-27 15:12:24 +00:00
|
|
|
const FAB_LAYER_COLOR& item = color_list[ii];
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-09-27 15:12:24 +00:00
|
|
|
wxColor curr_color = item.m_Color;
|
2019-07-27 19:09:43 +00:00
|
|
|
wxString label;
|
|
|
|
|
|
|
|
// Defined colors have a name, the user color uses the HTML notation ( i.e. #FF0000)
|
|
|
|
if( GetColorStandardListCount()-1 > (int)combo->GetCount() )
|
2019-09-27 15:12:24 +00:00
|
|
|
label = wxGetTranslation( item.m_ColorName );
|
2019-07-27 19:09:43 +00:00
|
|
|
else // Append the user color, if specified, else add a default user color
|
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
if( aStackupItem && aStackupItem->GetColor().StartsWith( "#" ) )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
curr_color = wxColour( aStackupItem->GetColor() );
|
|
|
|
label = aStackupItem->GetColor();
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
label = curr_color.GetAsString( wxC2S_HTML_SYNTAX );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxBitmap layerbmp( m_colorSwatchesSize.x, m_colorSwatchesSize.y );
|
|
|
|
LAYER_SELECTOR::DrawColorSwatch( layerbmp, COLOR4D( 0, 0, 0, 0 ),
|
|
|
|
COLOR4D( curr_color ) );
|
|
|
|
|
|
|
|
combo->Append( label, layerbmp );
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __WXGTK__
|
|
|
|
// Adjust the minimal width. On GTK, the size calculated by wxWidgets is not good
|
|
|
|
// bitmaps are ignored
|
|
|
|
combo->Fit();
|
|
|
|
int min_width = combo->GetSize().x;
|
|
|
|
min_width += m_colorSwatchesSize.x;
|
|
|
|
combo->SetMinSize( wxSize( min_width, -1 ) );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// add the wxBitmapComboBox to wxControl list, to be able to disconnect the event
|
|
|
|
// on exit
|
|
|
|
m_controlItemsList.push_back( combo );
|
|
|
|
|
|
|
|
combo->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED,
|
|
|
|
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onColorSelected ),
|
|
|
|
NULL, this );
|
|
|
|
|
|
|
|
return combo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void drawBitmap( wxBitmap& aBitmap, wxColor aColor )
|
|
|
|
{
|
|
|
|
wxNativePixelData data( aBitmap );
|
|
|
|
wxNativePixelData::Iterator p(data);
|
|
|
|
|
|
|
|
for( int yy = 0; yy < data.GetHeight(); yy++ )
|
|
|
|
{
|
|
|
|
wxNativePixelData::Iterator rowStart = p;
|
|
|
|
|
|
|
|
for( int xx = 0; xx < data.GetWidth(); xx++ )
|
|
|
|
{
|
|
|
|
p.Red() = aColor.Red();
|
|
|
|
p.Green() = aColor.Green();
|
|
|
|
p.Blue() = aColor.Blue();
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = rowStart;
|
|
|
|
p.OffsetY(data, 1);
|
|
|
|
}
|
|
|
|
}
|
2020-08-05 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_BOARD_STACKUP::OnUpdateUI( wxUpdateUIEvent& event )
|
|
|
|
{
|
|
|
|
// Handle an error. This is delayed to OnUpdateUI so that we can change the focus
|
|
|
|
// even when the original validation was triggered from a killFocus event, and so
|
|
|
|
// that the corresponding notebook page can be shown in the background when triggered
|
|
|
|
// from an OK.
|
|
|
|
if( m_stackupMismatch )
|
|
|
|
{
|
|
|
|
m_stackupMismatch = false;
|
|
|
|
|
|
|
|
wxRichMessageDialog dlg( this,
|
|
|
|
_( "Physical stackup has not been updated to match layer count." ),
|
|
|
|
_( "Update Physical Stackup" ),
|
|
|
|
wxOK | wxCENTER | wxICON_WARNING );
|
|
|
|
dlg.ShowCheckBox( _( "Update dielectric thickness from board thickness" ), true );
|
|
|
|
|
|
|
|
dlg.ShowModal();
|
|
|
|
|
|
|
|
if( dlg.IsCheckBoxChecked() )
|
|
|
|
{
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
onCalculateDielectricThickness( dummy );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|