board stackup manager: a few enhancements in code and make some strings translatable

This commit is contained in:
jean-pierre charras 2019-09-27 17:12:24 +02:00
parent 2e3d781bf2
commit d3982d0cb2
7 changed files with 96 additions and 52 deletions

View File

@ -28,6 +28,7 @@
#include <i18n_utility.h> // For _HKI definition
#include "stackup_predefined_prms.h"
BOARD_STACKUP_ITEM::BOARD_STACKUP_ITEM( BOARD_STACKUP_ITEM_TYPE aType )
{
m_LayerId = UNDEFINED_LAYER;
@ -63,7 +64,7 @@ BOARD_STACKUP_ITEM::BOARD_STACKUP_ITEM( BOARD_STACKUP_ITEM_TYPE aType )
case BS_ITEM_TYPE_SOLDERMASK:
m_TypeName = "soldermask";
m_Color = "Green";
m_Material = NOT_SPECIFIED; // or other solder mask material name
m_Material = NotSpecifiedPrm(); // or other solder mask material name
m_Thickness = GetMaskDefaultThickness();
m_EpsilonR = DEFAULT_EPSILON_R_SOLDERMASK;
m_LossTangent = 0.0;
@ -71,8 +72,8 @@ BOARD_STACKUP_ITEM::BOARD_STACKUP_ITEM( BOARD_STACKUP_ITEM_TYPE aType )
case BS_ITEM_TYPE_SILKSCREEN:
m_TypeName = "silkscreen";
m_Color = NOT_SPECIFIED;
m_Material = NOT_SPECIFIED; // or other silkscreen material name
m_Color = NotSpecifiedPrm();
m_Material = NotSpecifiedPrm(); // or other silkscreen material name
m_EpsilonR = DEFAULT_EPSILON_R_SILKSCREEN;
m_Thickness = 0.0; // to be specified
break;
@ -136,7 +137,7 @@ bool BOARD_STACKUP_ITEM::HasLossTangentValue()
bool BOARD_STACKUP_ITEM::HasMaterialValue()
{
// return true if the material is specified
return IsMaterialEditable() && ( m_Material.CmpNoCase( NOT_SPECIFIED ) != 0 );
return IsMaterialEditable() && IsPrmSpecified( m_Material );
}
@ -498,6 +499,8 @@ void BOARD_STACKUP::FormatBoardStackup( OUTPUTFORMATTER* aFormatter,
aFormatter->Print( aNestLevel, "(stackup\n" );
int nest_level = aNestLevel+1;
// Note:
// Unspecified parameters are not stored in file.
for( BOARD_STACKUP_ITEM* item: m_list )
{
wxString layer_name;
@ -534,8 +537,7 @@ void BOARD_STACKUP::FormatBoardStackup( OUTPUTFORMATTER* aFormatter,
aFormatter->Print( 0, " (loss_tangent %s)",
Double2Str(item->m_LossTangent ).c_str() );
if( item->IsColorEditable() && !item->m_Color.IsEmpty()
&& item->m_Color != NOT_SPECIFIED )
if( item->IsColorEditable() && IsPrmSpecified( item->m_Color ) )
aFormatter->Print( 0, " (color %s)",
aFormatter->Quotew( item->m_Color ).c_str() );
@ -543,7 +545,7 @@ void BOARD_STACKUP::FormatBoardStackup( OUTPUTFORMATTER* aFormatter,
}
// Other infos about board, related to layers and other fabrication specifications
if( !m_FinishType.IsEmpty() && m_FinishType != NOT_SPECIFIED )
if( IsPrmSpecified( m_FinishType ) )
aFormatter->Print( nest_level, "(copper_finish %s)\n",
aFormatter->Quotew( m_FinishType ).c_str() );
@ -562,3 +564,16 @@ void BOARD_STACKUP::FormatBoardStackup( OUTPUTFORMATTER* aFormatter,
aFormatter->Print( aNestLevel, ")\n" );
}
bool IsPrmSpecified( const wxString& aPrmValue )
{
// return true if the param value is specified:
if( !aPrmValue.IsEmpty()
&& ( aPrmValue.CmpNoCase( NotSpecifiedPrm() ) != 0 )
&& aPrmValue != wxGetTranslation( NotSpecifiedPrm() ) )
return true;
return false;
}

View File

@ -96,14 +96,14 @@ void DIALOG_DIELECTRIC_MATERIAL::initMaterialList()
m_lcMaterials->AppendColumn( _( "Loss Tg" ) );
// Fills m_lcMaterials with available materials
// The first item is expected a not specified material
// Other names are proper nouns, and are not translated
for( int idx = 0; idx < m_materialList.GetCount(); ++idx )
{
DIELECTRIC_SUBSTRATE* item = m_materialList.GetSubstrate( idx );
if( item->m_Name == USER_DEFINED )
break;
long tmp = m_lcMaterials->InsertItem( idx, item->m_Name );
long tmp = m_lcMaterials->InsertItem( idx,
idx == 0 ? wxGetTranslation( item->m_Name ) : item->m_Name );
m_lcMaterials->SetItemData(tmp, idx);
m_lcMaterials->SetItem(tmp, 1, item->FormatEpsilonR() );
@ -119,6 +119,9 @@ void DIALOG_DIELECTRIC_MATERIAL::onListItemSelected( wxListEvent& event )
if( idx < 0 )
return;
if( idx == 0 )
m_tcMaterial->SetValue( wxGetTranslation( m_materialList.GetSubstrate( 0 )->m_Name ) );
else
m_tcMaterial->SetValue( m_materialList.GetSubstrate( idx )->m_Name );
m_tcEpsilonR->SetValue( m_materialList.GetSubstrate( idx )->FormatEpsilonR() );
m_tcLossTg->SetValue( m_materialList.GetSubstrate( idx )->FormatLossTangent() );

View File

@ -27,7 +27,7 @@
* @file dielectric_material.cpp
*/
#include "stackup_predefined_prms.h" // For NOT_SPECIFIED definition
#include "stackup_predefined_prms.h"
#include "dielectric_material.h"
@ -39,7 +39,7 @@
// DO NOT translate them, as they are proper noun
static DIELECTRIC_SUBSTRATE substrateMaterial[] =
{
{ NOT_SPECIFIED, 0.0, 0.0 }, // Not specified, not in .gbrjob file
{ NotSpecifiedPrm(), 0.0, 0.0 }, // Not specified, not in .gbrjob
{ "FR4", 4.5, 0.02 }, // used in .gbrjob file
{ "Polyimide", 1.0, 0.0 }, // used in .gbrjob file
{ "Polyolefin", 1.0, 0.0 }, // used in .gbrjob file
@ -52,7 +52,7 @@ static DIELECTRIC_SUBSTRATE substrateMaterial[] =
static DIELECTRIC_SUBSTRATE solderMaskMaterial[] =
{
{ NOT_SPECIFIED, DEFAULT_EPSILON_R_SOLDERMASK, 0.0 }, // Not specified, not in .gbrjob file
{ NotSpecifiedPrm(), DEFAULT_EPSILON_R_SOLDERMASK, 0.0 }, // Not specified, not in .gbrjob
{ "Epoxy", DEFAULT_EPSILON_R_SOLDERMASK, 0.0 }, // Epoxy Liquid material (usual)
{ "Liquid Ink", DEFAULT_EPSILON_R_SOLDERMASK, 0.0 }, // Liquid Ink Photoimageable
{ "Dry Film", DEFAULT_EPSILON_R_SOLDERMASK, 0.0 } // Dry Film Photoimageable
@ -60,7 +60,7 @@ static DIELECTRIC_SUBSTRATE solderMaskMaterial[] =
static DIELECTRIC_SUBSTRATE silkscreenMaterial[] =
{
{ NOT_SPECIFIED, DEFAULT_EPSILON_R_SILKSCREEN, 0.0 }, // Not specified, not in .gbrjob file
{ NotSpecifiedPrm(), DEFAULT_EPSILON_R_SILKSCREEN, 0.0 }, // Not specified, not in .gbrjob
{ "Liquid Photo", DEFAULT_EPSILON_R_SILKSCREEN, 0.0 }, // Liquid Ink Photoimageable
{ "Direct Printing", DEFAULT_EPSILON_R_SILKSCREEN, 0.0 } // Direct Legend Printing
};

View File

@ -78,7 +78,8 @@ PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( PAGED_DIALOG* aParent, PCB
// Calculates a good size for color swatches (icons) in this dialog
wxClientDC dc( this );
m_colorSwatchesSize = dc.GetTextExtent( "XX" );
m_colorComboSize = dc.GetTextExtent( "XXX Undefined XXX" );
m_colorComboSize = dc.GetTextExtent( wxString::Format( "XXX %s XXX",
wxGetTranslation( NotSpecifiedPrm() ) ) );
m_colorIconsSize = dc.GetTextExtent( "XXXX" );
// Calculates a good size for wxTextCtrl to enter Epsilon R and Loss tan
@ -265,7 +266,12 @@ void PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard( bool aFullSync )
wxTextCtrl* matName = dynamic_cast<wxTextCtrl*>( ui_row_item.m_MaterialCtrl );
if( matName )
{
if( IsPrmSpecified( item->m_Material ) )
matName->SetValue( item->m_Material );
else
matName->SetValue( wxGetTranslation( NotSpecifiedPrm() ) );
}
}
if( item->IsThicknessEditable() )
@ -386,7 +392,12 @@ void PANEL_SETUP_BOARD_STACKUP::addMaterialChooser( wxWindowID aId,
wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, wxID_ANY );
if( aMaterialName )
{
if( IsPrmSpecified( *aMaterialName ) )
textCtrl->SetValue( *aMaterialName );
else
textCtrl->SetValue( wxGetTranslation( NotSpecifiedPrm() ) );
}
textCtrl->SetMinSize( m_numericTextCtrlSize );
bSizerMat->Add( textCtrl, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
@ -715,6 +726,11 @@ bool PANEL_SETUP_BOARD_STACKUP::transferDataFromUIToStackup()
{
wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( m_rowUiItemsList[row].m_MaterialCtrl );
item->m_Material = textCtrl->GetValue();
// Ensure the not specified mat name is the keyword, not its translation
// to avoid any issue is the language setting changes
if( !IsPrmSpecified( item->m_Material ) )
item->m_Material = NotSpecifiedPrm();
}
if( item->m_Type == BS_ITEM_TYPE_DIELECTRIC )
@ -1146,17 +1162,18 @@ wxBitmapComboBox* PANEL_SETUP_BOARD_STACKUP::createBmComboBox( BOARD_STACKUP_ITE
wxEmptyString, wxDefaultPosition,
wxDefaultSize, 0, nullptr, wxCB_READONLY );
// Fills the combo box with choice list + bitmaps
for( const FAB_LAYER_COLOR* item = GetColorStandardList(); ; ++item )
{
if( item->m_ColorName.IsEmpty() )
break;
const FAB_LAYER_COLOR* color_list = GetColorStandardList();
wxColor curr_color = item->m_Color;
for( int ii = 0; ii < GetColorStandardListCount(); ii++ )
{
const FAB_LAYER_COLOR& item = color_list[ii];
wxColor curr_color = item.m_Color;
wxString label;
// Defined colors have a name, the user color uses the HTML notation ( i.e. #FF0000)
if( GetColorStandardListCount()-1 > (int)combo->GetCount() )
label = wxGetTranslation( item->m_ColorName );
label = wxGetTranslation( item.m_ColorName );
else // Append the user color, if specified, else add a default user color
{
if( aStackupItem && aStackupItem->m_Color.StartsWith( "#" ) )

View File

@ -41,7 +41,7 @@
// These names are in fact usual copper finish names.
static wxString CopperFinishType[] =
{
_HKI( NOT_SPECIFIED ), // Not specified, not in .gbrjob file
NotSpecifiedPrm(), // Not specified, not in .gbrjob file
_HKI("ENIG"), // used in .gbrjob file
_HKI("ENEPIG"), // used in .gbrjob file
_HKI("HAL SnPb"), // used in .gbrjob file
@ -66,15 +66,14 @@ static wxString CopperFinishType[] =
// and R<integer>G<integer>B<integer> In gbrjob file.
static FAB_LAYER_COLOR solderMaskColors[] =
{
{ _HKI( NOT_SPECIFIED ), wxColor( 80, 80, 80 ) }, // Not specified, not in .gbrjob file
{ NotSpecifiedPrm(), wxColor( 80, 80, 80 ) }, // Not specified, not in .gbrjob file
{ _HKI( "Green" ), wxColor( 60, 150, 80 ) }, // used in .gbrjob file
{ _HKI( "Red" ), wxColor( 128, 0, 0 ) }, // used in .gbrjob file
{ _HKI( "Blue" ), wxColor( 0, 0, 128 ) }, // used in .gbrjob file
{ _HKI( "Black" ), wxColor( 20, 20, 20 ) }, // used in .gbrjob file
{ _HKI( "White" ), wxColor( 200, 200, 200 ) }, // used in .gbrjob file
{ _HKI( "Yellow" ), wxColor( 128, 128, 0 ) }, // used in .gbrjob file
{ _HKI( USER_DEFINED ), wxColor( 128, 128, 128 ) }, //free. the name is a dummy name here
{ "", wxColor( 0, 0, 0 ) } // Sentinel
{ _HKI( "User defined" ), wxColor( 128, 128, 128 ) }//free. the name is a dummy name here
};
@ -97,12 +96,12 @@ const FAB_LAYER_COLOR* GetColorStandardList()
int GetColorStandardListCount()
{
return arrayDim( solderMaskColors ) - 1;
return arrayDim( solderMaskColors );
}
int GetColorUserDefinedListIdx()
{
// this is the last item in list
return GetColorStandardListCount() - 1;
}

View File

@ -32,6 +32,7 @@
#include <wx/string.h>
#include <layers_id_colors_and_visibility.h>
#include <i18n_utility.h> // For _HKI definition
// Keyword used in file to identify the dielectric layer type
#define KEY_CORE "core"
@ -40,10 +41,19 @@
#define KEY_COPPER "copper"
// key string used for not specified parameters
#define NOT_SPECIFIED "Undefined"
// Can be translated in dialogs, and is also a keyword
// outside dialogs
wxString inline NotSpecifiedPrm()
{
return _HKI( "Not specified" );
}
// String in wxChoice to use user defined material or solder mask color
#define USER_DEFINED "user defined"
/**
* @return true if the param value is specified:
* not empty
* not NotSpecifiedPrm() value or its translation
*/
bool IsPrmSpecified( const wxString& aPrmValue );
// A reasonable Epsilon R value for solder mask dielectric
#define DEFAULT_EPSILON_R_SOLDERMASK 3.3

View File

@ -656,7 +656,7 @@ void GERBER_JOBFILE_WRITER::addJSONMaterialStackup()
if( item->IsColorEditable() && uptodate )
{
if( !item->m_Color.IsEmpty() && item->m_Color != NOT_SPECIFIED )
if( IsPrmSpecified( item->m_Color ) )
{
wxString colorName = item->m_Color;