Commit 25b65b2e authored by Dick Hollenbeck's avatar Dick Hollenbeck

Consistent with my email posting from a day or two ago, remove the translated

standard layer name support from BOARD::GetLayerName().  This function evolved
in a contorted direction over time, and was being asked to return one of 3
different kinds of layer names, even though it only took a boolean to control
that choice.  

Users are better served by forcing them to get to know the concise new 
English Standard layer names.  This is because these concise names show up
in the "pretty" footprint/module files as the standard representation of
both feature and copper layers.

Change the name of BOARD::GetDefaultLayerName() to GetStandardLayerName().
Drop boolean argument to both BOARD::GetStandardLayerName() and 
BOARD::GetLayerName().
parent 8421cace
......@@ -77,7 +77,7 @@ BOARD::BOARD() :
for( int layer = 0; layer < LAYER_COUNT; ++layer )
{
m_Layer[layer].m_Name = GetDefaultLayerName( layer, true );
m_Layer[layer].m_Name = GetStandardLayerName( layer );
if( layer <= LAST_COPPER_LAYER )
m_Layer[layer].m_Type = LT_SIGNAL;
......@@ -356,7 +356,7 @@ bool BOARD::SetLayer( int aIndex, const LAYER& aLayer )
}
wxString BOARD::GetLayerName( int aLayerIndex, bool aTranslate ) const
wxString BOARD::GetLayerName( int aLayerIndex ) const
{
if( !IsValidLayerIndex( aLayerIndex ) )
return wxEmptyString;
......@@ -364,53 +364,19 @@ wxString BOARD::GetLayerName( int aLayerIndex, bool aTranslate ) const
// All layer names are stored in the BOARD.
if( IsLayerEnabled( aLayerIndex ) )
{
// default names were set in BOARD::BOARD() but they may be
// over-ridden by BOARD::SetLayerName()
// For non translated name, return the actual copper layer names,
// otherwise, return the native layer names
if( aTranslate || aLayerIndex < FIRST_NO_COPPER_LAYER )
// Standard names were set in BOARD::BOARD() but they may be
// over-ridden by BOARD::SetLayerName().
// For copper layers, return the actual copper layer name,
// otherwise return the Standard English layer name.
if( aLayerIndex < FIRST_NO_COPPER_LAYER )
return m_Layer[aLayerIndex].m_Name;
}
return GetDefaultLayerName( aLayerIndex, aTranslate );
}
// Default layer names are statically initialized,
// because we want the English name and the translation.
// The English name is stored here, and to get the translation
// wxGetTranslation must be called explicitly.
static const wxChar* layer_FRONT_name = _( "F.Cu" );
static const wxChar* layer_INNER1_name = _( "Inner1.Cu" );
static const wxChar* layer_INNER2_name = _( "Inner2.Cu" );
static const wxChar* layer_INNER3_name = _( "Inner3.Cu" );
static const wxChar* layer_INNER4_name = _( "Inner4.Cu" );
static const wxChar* layer_INNER5_name = _( "Inner5.Cu" );
static const wxChar* layer_INNER6_name = _( "Inner6.Cu" );
static const wxChar* layer_INNER7_name = _( "Inner7.Cu" );
static const wxChar* layer_INNER8_name = _( "Inner8.Cu" );
static const wxChar* layer_INNER9_name = _( "Inner9.Cu" );
static const wxChar* layer_INNER10_name = _( "Inner10.Cu" );
static const wxChar* layer_INNER11_name = _( "Inner11.Cu" );
static const wxChar* layer_INNER12_name = _( "Inner12.Cu" );
static const wxChar* layer_INNER13_name = _( "Inner13.Cu" );
static const wxChar* layer_INNER14_name = _( "Inner14.Cu" );
static const wxChar* layer_BACK_name = _( "B.Cu" );
static const wxChar* layer_ADHESIVE_BACK_name = _( "B.Adhes" );
static const wxChar* layer_ADHESIVE_FRONT_name = _( "F.Adhes" );
static const wxChar* layer_SOLDERPASTE_BACK_name = _( "B.Paste" );
static const wxChar* layer_SOLDERPASTE_FRONT_name = _( "F.Paste" );
static const wxChar* layer_SILKSCREEN_BACK_name = _( "B.SilkS" );
static const wxChar* layer_SILKSCREEN_FRONT_name = _( "F.SilkS" );
static const wxChar* layer_SOLDERMASK_BACK_name = _( "B.Mask" );
static const wxChar* layer_SOLDERMASK_FRONT_name = _( "F.Mask" );
static const wxChar* layer_DRAW_name = _( "Dwgs.User" );
static const wxChar* layer_COMMENT_name = _( "Cmts.User" );
static const wxChar* layer_ECO1_name = _( "Eco1.User" );
static const wxChar* layer_ECO2_name = _( "Eco2.User" );
static const wxChar* layer_EDGE_name = _( "Edge.Cuts" );
wxString BOARD::GetDefaultLayerName( int aLayerNumber, bool aTranslate )
return GetStandardLayerName( aLayerIndex );
}
wxString BOARD::GetStandardLayerName( int aLayerNumber )
{
const wxChar* txt;
......@@ -420,51 +386,39 @@ wxString BOARD::GetDefaultLayerName( int aLayerNumber, bool aTranslate )
// Use a switch to explicitly show the mapping more clearly
switch( aLayerNumber )
{
case LAYER_N_FRONT: txt = layer_FRONT_name; break;
case LAYER_N_2: txt = layer_INNER1_name; break;
case LAYER_N_3: txt = layer_INNER2_name; break;
case LAYER_N_4: txt = layer_INNER3_name; break;
case LAYER_N_5: txt = layer_INNER4_name; break;
case LAYER_N_6: txt = layer_INNER5_name; break;
case LAYER_N_7: txt = layer_INNER6_name; break;
case LAYER_N_8: txt = layer_INNER7_name; break;
case LAYER_N_9: txt = layer_INNER8_name; break;
case LAYER_N_10: txt = layer_INNER9_name; break;
case LAYER_N_11: txt = layer_INNER10_name; break;
case LAYER_N_12: txt = layer_INNER11_name; break;
case LAYER_N_13: txt = layer_INNER12_name; break;
case LAYER_N_14: txt = layer_INNER13_name; break;
case LAYER_N_15: txt = layer_INNER14_name; break;
case LAYER_N_BACK: txt = layer_BACK_name; break;
case ADHESIVE_N_BACK: txt = layer_ADHESIVE_BACK_name; break;
case ADHESIVE_N_FRONT: txt = layer_ADHESIVE_FRONT_name; break;
case SOLDERPASTE_N_BACK: txt = layer_SOLDERPASTE_BACK_name; break;
case SOLDERPASTE_N_FRONT: txt = layer_SOLDERPASTE_FRONT_name; break;
case SILKSCREEN_N_BACK: txt = layer_SILKSCREEN_BACK_name; break;
case SILKSCREEN_N_FRONT: txt = layer_SILKSCREEN_FRONT_name; break;
case SOLDERMASK_N_BACK: txt = layer_SOLDERMASK_BACK_name; break;
case SOLDERMASK_N_FRONT: txt = layer_SOLDERMASK_FRONT_name; break;
case DRAW_N: txt = layer_DRAW_name; break;
case COMMENT_N: txt = layer_COMMENT_name; break;
case ECO1_N: txt = layer_ECO1_name; break;
case ECO2_N: txt = layer_ECO2_name; break;
case EDGE_N: txt = layer_EDGE_name; break;
case LAYER_N_FRONT: txt = wxT( "F.Cu" ); break;
case LAYER_N_2: txt = wxT( "Inner1.Cu" ); break;
case LAYER_N_3: txt = wxT( "Inner2.Cu" ); break;
case LAYER_N_4: txt = wxT( "Inner3.Cu" ); break;
case LAYER_N_5: txt = wxT( "Inner4.Cu" ); break;
case LAYER_N_6: txt = wxT( "Inner5.Cu" ); break;
case LAYER_N_7: txt = wxT( "Inner6.Cu" ); break;
case LAYER_N_8: txt = wxT( "Inner7.Cu" ); break;
case LAYER_N_9: txt = wxT( "Inner8.Cu" ); break;
case LAYER_N_10: txt = wxT( "Inner9.Cu" ); break;
case LAYER_N_11: txt = wxT( "Inner10.Cu" ); break;
case LAYER_N_12: txt = wxT( "Inner11.Cu" ); break;
case LAYER_N_13: txt = wxT( "Inner12.Cu" ); break;
case LAYER_N_14: txt = wxT( "Inner13.Cu" ); break;
case LAYER_N_15: txt = wxT( "Inner14.Cu" ); break;
case LAYER_N_BACK: txt = wxT( "B.Cu" ); break;
case ADHESIVE_N_BACK: txt = wxT( "B.Adhes" ); break;
case ADHESIVE_N_FRONT: txt = wxT( "F.Adhes" ); break;
case SOLDERPASTE_N_BACK: txt = wxT( "B.Paste" ); break;
case SOLDERPASTE_N_FRONT: txt = wxT( "F.Paste" ); break;
case SILKSCREEN_N_BACK: txt = wxT( "B.SilkS" ); break;
case SILKSCREEN_N_FRONT: txt = wxT( "F.SilkS" ); break;
case SOLDERMASK_N_BACK: txt = wxT( "B.Mask" ); break;
case SOLDERMASK_N_FRONT: txt = wxT( "F.Mask" ); break;
case DRAW_N: txt = wxT( "Dwgs.User" ); break;
case COMMENT_N: txt = wxT( "Cmts.User" ); break;
case ECO1_N: txt = wxT( "Eco1.User" ); break;
case ECO2_N: txt = wxT( "Eco2.User" ); break;
case EDGE_N: txt = wxT( "Edge.Cuts" ); break;
default: txt = wxT( "BAD_INDEX" ); break;
}
if( aTranslate )
{
wxString name = wxGetTranslation( txt );
/* would someone translate into a name with leading or trailing spaces?
name.Trim( true );
name.Trim( false );
*/
return name;
}
else
return txt;
return txt; // wxString constructed once here
}
......
......@@ -287,29 +287,6 @@ public:
void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
int GetFileFormatVersionAtLoad() const { return m_fileFormatVersionAtLoad; }
/**
* Function GetDefaultLayerName
* returns a default name of a PCB layer when given \a aLayerNumber. This
* function is static so it can be called without a BOARD instance. Use
* GetLayerName() if want the layer names of a specific BOARD, which could
* be different than the default if the user has renamed any copper layers.
*
* @param aLayerNumber is the layer number to fetch
* @param aTranslate = true to return the translated version
* = false to get the native version
* @return wxString - containing the layer name or "BAD INDEX" if aLayerNumber
* is not legal
*/
static wxString GetDefaultLayerName( int aLayerNumber, bool aTranslate );
/**
* Function ReturnFlippedLayerNumber
* @return the layer number after flipping an item
* some (not all) layers: external copper, Mask, Paste, and solder
* are swapped between front and back sides
*/
static int ReturnFlippedLayerNumber( int oldlayer );
/**
* Function Add
* adds the given item to this BOARD and takes ownership of its memory.
......@@ -604,22 +581,22 @@ public:
* Function SetColorsSettings
* @param aColorsSettings = the new COLORS_DESIGN_SETTINGS to use
*/
void SetColorsSettings(COLORS_DESIGN_SETTINGS* aColorsSettings)
void SetColorsSettings( COLORS_DESIGN_SETTINGS* aColorsSettings )
{
m_colorsSettings = aColorsSettings;
}
/**
* Function GetLayerName
* returns the name of the layer given by aLayerIndex.
* returns the name of a layer given by aLayerIndex. Copper layers may
* have custom names.
*
* @param aLayerIndex = A layer index, like LAYER_N_BACK, etc.
* @param aTranslate = true to return the translated version (default)
* = false to get the native English name
* (Useful to build filenames from layer names)
* @return wxString - the layer name.
*
* @return wxString - the layer name, which for copper layers may
* be custom, else standard.
*/
wxString GetLayerName( int aLayerIndex, bool aTranslate = true ) const;
wxString GetLayerName( int aLayerIndex ) const;
/**
* Function SetLayerName
......@@ -632,6 +609,19 @@ public:
*/
bool SetLayerName( int aLayerIndex, const wxString& aLayerName );
/**
* Function GetStandardLayerName
* returns an "English Standard" name of a PCB layer when given \a aLayerNumber.
* This function is static so it can be called without a BOARD instance. Use
* GetLayerName() if want the layer names of a specific BOARD, which could
* be different than the default if the user has renamed any copper layers.
*
* @param aLayerNumber is the layer number to fetch
* @return wxString - containing the layer name or "BAD INDEX" if aLayerNumber
* is not legal
*/
static wxString GetStandardLayerName( int aLayerNumber );
bool SetLayer( int aIndex, const LAYER& aLayer );
/**
......@@ -666,6 +656,14 @@ public:
*/
EDA_COLOR_T GetLayerColor( int aLayer ) const;
/**
* Function ReturnFlippedLayerNumber
* @return the layer number after flipping an item
* some (not all) layers: external copper, Mask, Paste, and solder
* are swapped between front and back sides
*/
static int ReturnFlippedLayerNumber( int oldlayer );
/** Functions to get some items count */
int GetNumSegmTrack() const;
......
......@@ -79,10 +79,10 @@ wxString BOARD_ITEM::GetLayerName() const
BOARD* board = GetBoard();
if( board )
return board->GetLayerName( m_Layer ).Trim();
return board->GetLayerName( m_Layer );
// If no parent, return the untranslated layer name.
return BOARD::GetDefaultLayerName( m_Layer, false );
// If no parent, return standard name
return BOARD::GetStandardLayerName( m_Layer );
}
......
......@@ -250,7 +250,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile )
if( (printMaskLayer & currlayer_mask ) == 0 )
continue;
wxString suffix = m_board->GetLayerName( layer, false );
wxString suffix = m_board->GetStandardLayerName( layer );
if( aOnlyOneFile )
{
......@@ -260,7 +260,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile )
else
{
m_printMaskLayer = currlayer_mask;
suffix = m_board->GetLayerName( layer, false );
suffix = m_board->GetStandardLayerName( layer );
}
wxFileName fn(boardFilename);
......
......@@ -325,7 +325,7 @@ void DIALOG_LAYERS_SETUP::showBoardLayerNames()
{
// Establish all the board's layer names into the dialog presentation, by
// obtaining them from BOARD::GetLayerName() which calls
// BOARD::GetDefaultLayerName() for non-coppers.
// BOARD::GetStandardLayerName() for non-coppers.
for( int layer=0; layer<NB_LAYERS; ++layer )
{
......
......@@ -381,12 +381,12 @@ void PCB_IO::Format( BOARD_ITEM* aItem, int aNestLevel ) const
void PCB_IO::formatLayer( const BOARD_ITEM* aItem ) const
{
if( m_ctl & CTL_UNTRANSLATED_LAYERS )
if( m_ctl & CTL_STD_LAYER_NAMES )
{
int layer = aItem->GetLayer();
// English layer names should never need quoting.
m_out->Print( 0, " (layer %s)", TO_UTF8( BOARD::GetDefaultLayerName( layer, false ) ) );
m_out->Print( 0, " (layer %s)", TO_UTF8( BOARD::GetStandardLayerName( layer ) ) );
}
else
m_out->Print( 0, " (layer %s)", m_out->Quotew( aItem->GetLayerName() ).c_str() );
......@@ -1040,11 +1040,11 @@ void PCB_IO::formatLayers( int aLayerMask, int aNestLevel ) const
{
if( layerMask & 1 )
{
if( m_board && !(m_ctl & CTL_UNTRANSLATED_LAYERS) )
if( m_board && !(m_ctl & CTL_STD_LAYER_NAMES) )
layerName = m_board->GetLayerName( layer );
else // I am being called from FootprintSave()
layerName = BOARD::GetDefaultLayerName( layer, false );
layerName = BOARD::GetStandardLayerName( layer );
m_out->Print( 0, " %s", m_out->Quotew( layerName ).c_str() );
}
......
......@@ -36,8 +36,8 @@ class PCB_PARSER;
/// Current s-expression file format version. 2 was the last legacy format version.
#define SEXPR_BOARD_FILE_VERSION 3
/// Use English default layer names
#define CTL_UNTRANSLATED_LAYERS (1 << 0)
/// Use English Standard layer names
#define CTL_STD_LAYER_NAMES (1 << 0)
#define CTL_OMIT_NETS (1 << 1)
......@@ -46,10 +46,10 @@ class PCB_PARSER;
// common combinations of the above:
/// Format output for the clipboard instead of footprint library or BOARD
#define CTL_FOR_CLIPBOARD (CTL_UNTRANSLATED_LAYERS|CTL_OMIT_NETS)
#define CTL_FOR_CLIPBOARD (CTL_STD_LAYER_NAMES|CTL_OMIT_NETS)
/// Format output for a footprint library instead of clipboard or BOARD
#define CTL_FOR_LIBRARY (CTL_UNTRANSLATED_LAYERS|CTL_OMIT_NETS|CTL_OMIT_TSTAMPS)
#define CTL_FOR_LIBRARY (CTL_STD_LAYER_NAMES|CTL_OMIT_NETS|CTL_OMIT_TSTAMPS)
/**
* Class PCB_IO
......
......@@ -63,7 +63,7 @@ void PCB_PARSER::init()
// The english name will survive if parsing only a footprint.
for( int layerNdx = 0; layerNdx < NB_LAYERS; ++layerNdx )
{
std::string untranslated = TO_UTF8( BOARD::GetDefaultLayerName( layerNdx, false ) );
std::string untranslated = TO_UTF8( BOARD::GetStandardLayerName( layerNdx ) );
m_layerIndices[ untranslated ] = layerNdx;
m_layerMasks[ untranslated ] = 1 << layerNdx;
......
......@@ -272,7 +272,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
// Create file name (from the English layer name for non copper layers).
BuildPlotFileName( &fn, outputDir.GetPath(),
m_board->GetLayerName( layer, false ),
m_board->GetStandardLayerName( layer ),
file_ext );
LOCALE_IO toggle;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment