1) Fix compiles using wx 3.x and 2.8.

2) Fix passing wxString to common/config_params so lookup keys 
   can be dynamically generated.  This gives ~/.kicad files all the colors.
3) Fix LEGACY_PLUGIN so it loads all layer types and masks properly.
4) Extend the table in router/pns_index.h to 128 from 64.
This commit is contained in:
Dick Hollenbeck 2014-06-24 23:36:02 -05:00
parent b76d0c533b
commit b920fa00a5
6 changed files with 121 additions and 63 deletions

View File

@ -47,7 +47,7 @@ void wxConfigSaveParams( wxConfigBase* aCfg,
BOOST_FOREACH( const PARAM_CFG_BASE& param, aList )
{
if( param.m_Group )
if( !!param.m_Group )
aCfg->SetPath( param.m_Group );
else
aCfg->SetPath( aGroup );
@ -57,7 +57,7 @@ void wxConfigSaveParams( wxConfigBase* aCfg,
if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( param.m_Ident )
if( !!param.m_Ident )
aCfg->DeleteGroup( param.m_Ident );
}
else
@ -75,7 +75,7 @@ void wxConfigLoadParams( wxConfigBase* aCfg,
BOOST_FOREACH( const PARAM_CFG_BASE& param, aList )
{
if( param.m_Group )
if( !!param.m_Group )
aCfg->SetPath( param.m_Group );
else
aCfg->SetPath( aGroup );
@ -99,7 +99,7 @@ void wxConfigSaveSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList )
if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( param.m_Ident )
if( !!param.m_Ident )
aCfg->DeleteGroup( param.m_Ident );
}
else
@ -137,7 +137,7 @@ void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double
}
PARAM_CFG_BASE::PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type,
PARAM_CFG_BASE::PARAM_CFG_BASE( const wxString& ident, const paramcfg_id type,
const wxChar* group )
{
m_Ident = ident;
@ -147,7 +147,7 @@ PARAM_CFG_BASE::PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type,
}
PARAM_CFG_INT::PARAM_CFG_INT( const wxChar* ident, int* ptparam,
PARAM_CFG_INT::PARAM_CFG_INT( const wxString& ident, int* ptparam,
int default_val, int min, int max,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_INT, group )
@ -159,7 +159,7 @@ PARAM_CFG_INT::PARAM_CFG_INT( const wxChar* ident, int* ptparam,
}
PARAM_CFG_INT::PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam,
PARAM_CFG_INT::PARAM_CFG_INT( bool Insetup, const wxString& ident, int* ptparam,
int default_val, int min, int max,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_INT, group )
@ -195,7 +195,7 @@ void PARAM_CFG_INT::SaveParam( wxConfigBase* aConfig ) const
}
PARAM_CFG_INT_WITH_SCALE::PARAM_CFG_INT_WITH_SCALE( const wxChar* ident, int* ptparam,
PARAM_CFG_INT_WITH_SCALE::PARAM_CFG_INT_WITH_SCALE( const wxString& ident, int* ptparam,
int default_val, int min, int max,
const wxChar* group, double aBiu2cfgunit ) :
PARAM_CFG_INT( ident, ptparam, default_val, min, max, group )
@ -206,7 +206,7 @@ PARAM_CFG_INT_WITH_SCALE::PARAM_CFG_INT_WITH_SCALE( const wxChar* ident, int* pt
PARAM_CFG_INT_WITH_SCALE::PARAM_CFG_INT_WITH_SCALE( bool Insetup,
const wxChar* ident, int* ptparam,
const wxString& ident, int* ptparam,
int default_val, int min, int max,
const wxChar* group, double aBiu2cfgunit ) :
PARAM_CFG_INT( Insetup, ident, ptparam, default_val, min, max, group )
@ -246,7 +246,7 @@ void PARAM_CFG_INT_WITH_SCALE::SaveParam( wxConfigBase* aConfig ) const
}
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, EDA_COLOR_T* ptparam,
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxString& ident, EDA_COLOR_T* ptparam,
EDA_COLOR_T default_val,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
@ -257,7 +257,7 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, EDA_COLOR_T* ptpara
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup,
const wxChar* ident,
const wxString& ident,
EDA_COLOR_T* ptparam,
EDA_COLOR_T default_val,
const wxChar* group ) :
@ -291,7 +291,7 @@ void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig ) const
}
PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam,
PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( const wxString& ident, double* ptparam,
double default_val, double min, double max,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_DOUBLE, group )
@ -304,7 +304,7 @@ PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam,
PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup,
const wxChar* ident,
const wxString& ident,
double* ptparam,
double default_val,
double min,
@ -348,7 +348,7 @@ void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig ) const
}
PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam,
PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxString& ident, bool* ptparam,
int default_val, const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_BOOL, group )
{
@ -358,7 +358,7 @@ PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam,
PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup,
const wxChar* ident,
const wxString& ident,
bool* ptparam,
int default_val,
const wxChar* group ) :
@ -390,7 +390,7 @@ void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig ) const
}
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxChar* ident,
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxString& ident,
wxString* ptparam,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_WXSTRING, group )
@ -399,7 +399,7 @@ PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxChar* ident,
}
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident,
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxString& ident,
wxString* ptparam,
const wxString& default_val,
const wxChar* group ) :
@ -407,7 +407,7 @@ PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident,
{
m_Pt_param = ptparam;
m_Setup = Insetup;
m_default = default_val;
m_default = default_val;
}
@ -429,7 +429,7 @@ void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig ) const
}
PARAM_CFG_FILENAME::PARAM_CFG_FILENAME( const wxChar* ident,
PARAM_CFG_FILENAME::PARAM_CFG_FILENAME( const wxString& ident,
wxString* ptparam,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_FILENAME, group )

View File

@ -89,13 +89,14 @@ enum paramcfg_id {
class PARAM_CFG_BASE
{
public:
const wxChar* m_Ident; ///< Keyword in config data
paramcfg_id m_Type; ///< Type of parameter
const wxChar* m_Group; ///< Group name (this is like a path in the config data)
bool m_Setup; ///< Install or Project based parameter, true == install
wxString m_Ident; ///< Keyword in config data
paramcfg_id m_Type; ///< Type of parameter
wxString m_Group; ///< Group name (this is like a path in the config data)
bool m_Setup; ///< Install or Project based parameter, true == install
public:
PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type, const wxChar* group = NULL );
PARAM_CFG_BASE( const wxString& ident, const paramcfg_id type,
const wxChar* group = NULL );
virtual ~PARAM_CFG_BASE() {}
/**
@ -126,12 +127,12 @@ public:
int m_Default; ///< The default value of the parameter
public:
PARAM_CFG_INT( const wxChar* ident, int* ptparam,
PARAM_CFG_INT( const wxString& ident, int* ptparam,
int default_val = 0,
int min = std::numeric_limits<int>::min(),
int max = std::numeric_limits<int>::max(),
const wxChar* group = NULL );
PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam,
PARAM_CFG_INT( bool Insetup, const wxString& ident, int* ptparam,
int default_val = 0,
int min = std::numeric_limits<int>::min(),
int max = std::numeric_limits<int>::max(),
@ -154,13 +155,13 @@ public:
double m_BIU_to_cfgunit; ///< the factor to convert the saved value in internal value
public:
PARAM_CFG_INT_WITH_SCALE( const wxChar* ident, int* ptparam,
PARAM_CFG_INT_WITH_SCALE( const wxString& ident, int* ptparam,
int default_val = 0,
int min = std::numeric_limits<int>::min(),
int max = std::numeric_limits<int>::max(),
const wxChar* group = NULL,
double aBiu2cfgunit = 1.0);
PARAM_CFG_INT_WITH_SCALE( bool Insetup, const wxChar* ident, int* ptparam,
PARAM_CFG_INT_WITH_SCALE( bool Insetup, const wxString& ident, int* ptparam,
int default_val = 0,
int min = std::numeric_limits<int>::min(),
int max = std::numeric_limits<int>::max(),
@ -183,9 +184,9 @@ public:
EDA_COLOR_T m_Default; ///< The default value of the parameter
public:
PARAM_CFG_SETCOLOR( const wxChar* ident, EDA_COLOR_T* ptparam,
PARAM_CFG_SETCOLOR( const wxString& ident, EDA_COLOR_T* ptparam,
EDA_COLOR_T default_val, const wxChar* group = NULL );
PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, EDA_COLOR_T* ptparam,
PARAM_CFG_SETCOLOR( bool Insetup, const wxString& ident, EDA_COLOR_T* ptparam,
EDA_COLOR_T default_val, const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig ) const;
@ -205,10 +206,10 @@ public:
double m_Min, m_Max; ///< Minimum and maximum values of the param type
public:
PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam,
PARAM_CFG_DOUBLE( const wxString& ident, double* ptparam,
double default_val = 0.0, double min = 0.0, double max = 10000.0,
const wxChar* group = NULL );
PARAM_CFG_DOUBLE( bool Insetup, const wxChar* ident, double* ptparam,
PARAM_CFG_DOUBLE( bool Insetup, const wxString& ident, double* ptparam,
double default_val = 0.0, double min = 0.0, double max = 10000.0,
const wxChar* group = NULL );
@ -228,9 +229,9 @@ public:
int m_Default; ///< The default value of the parameter
public:
PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam,
PARAM_CFG_BOOL( const wxString& ident, bool* ptparam,
int default_val = false, const wxChar* group = NULL );
PARAM_CFG_BOOL( bool Insetup, const wxChar* ident, bool* ptparam,
PARAM_CFG_BOOL( bool Insetup, const wxString& ident, bool* ptparam,
int default_val = false, const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig ) const;
@ -242,19 +243,20 @@ public:
* Configuration parameter - wxString Class
*
*/
class PARAM_CFG_WXSTRING : public PARAM_CFG_BASE
class PARAM_CFG_WXSTRING : public PARAM_CFG_BASE
{
public:
wxString* m_Pt_param; ///< Pointer to the parameter value
wxString m_default; ///< The default value of the parameter
public:
PARAM_CFG_WXSTRING( const wxChar* ident, wxString* ptparam, const wxChar* group = NULL );
PARAM_CFG_WXSTRING( const wxString& ident, wxString* ptparam, const wxChar* group = NULL );
PARAM_CFG_WXSTRING( bool Insetup,
const wxChar* ident,
const wxString& ident,
wxString* ptparam,
const wxString& default_val = wxEmptyString,
const wxChar* group = NULL );
const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ) const;
@ -273,7 +275,8 @@ public:
wxString* m_Pt_param; ///< Pointer to the parameter value
public:
PARAM_CFG_FILENAME( const wxChar* ident, wxString* ptparam, const wxChar* group = NULL );
PARAM_CFG_FILENAME( const wxString& ident, wxString* ptparam,
const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ) const;
};

View File

@ -106,15 +106,13 @@ struct LAYER
}
*/
/** The name of the layer, there should be no spaces in this name. */
UTF8 m_name;
wxString m_name; ///< The name of the layer, there should be no spaces in this name.
/** The type of the layer */
LAYER_T m_type;
LAYER_T m_type; ///< The type of the layer
bool m_visible;
bool m_visible;
int m_number;
int m_number;
/**
* Function ShowType

View File

@ -98,7 +98,7 @@ typedef LEGACY_PLUGIN::BIU BIU;
#define UNKNOWN_PAD_ATTRIBUTE _( "unknown pad attribute: %d" )
typedef unsigned LAYER_MASK;
typedef unsigned LEG_MASK;
#define FIRST_LAYER 0
#define FIRST_COPPER_LAYER 0
@ -255,7 +255,7 @@ static inline char* ReadLine( LINE_READER* rdr, const char* caller )
/* corrected old junk, element 14 was wrong. can delete.
// Look up Table for conversion copper layer count -> general copper layer mask:
static const LAYER_MASK all_cu_mask[] = {
static const LEG_MASK all_cu_mask[] = {
0x0001, 0x8001, 0x8003, 0x8007,
0x800F, 0x801F, 0x803F, 0x807F,
0x80FF, 0x81FF, 0x83FF, 0x87FF,
@ -313,7 +313,7 @@ static EDA_TEXT_VJUSTIFY_T vertJustify( const char* vertical )
/// Count the number of set layers in the mask
inline int layerMaskCountSet( LAYER_MASK aMask )
inline int layerMaskCountSet( LEG_MASK aMask )
{
int count = 0;
@ -338,6 +338,8 @@ LAYER_ID LEGACY_PLUGIN::leg_layer2new( int cu_count, LAYER_NUM aLayerNum )
{
if( old == LAYER_N_FRONT )
newid = F_Cu;
else if( old == LAYER_N_BACK )
newid = B_Cu;
else
{
newid = cu_count - 1 - old;
@ -376,6 +378,13 @@ LSET LEGACY_PLUGIN::leg_mask2new( int cu_count, unsigned aMask )
{
LSET ret;
if( ( aMask & ALL_CU_LAYERS ) == ALL_CU_LAYERS )
{
ret = LSET::AllCuMask();
aMask &= ~ALL_CU_LAYERS;
}
for( int i=0; i<NB_PCB_LAYERS && aMask; ++i, aMask >>= 1 )
{
if( aMask & 1 )
@ -601,6 +610,7 @@ void LEGACY_PLUGIN::loadGENERAL()
{
char* line;
char* saveptr;
bool saw_LayerCount = false;
while( ( line = READLINE( m_reader ) ) != NULL )
{
@ -617,22 +627,42 @@ void LEGACY_PLUGIN::loadGENERAL()
}
}
else if( TESTLINE( "LayerCount" ) )
{
int tmp = intParse( line + SZ( "LayerCount" ) );
m_board->SetCopperLayerCount( tmp );
// This has to be set early so that leg_layer2new() works OK, and
// that means before parsing "EnabledLayers" and "VisibleLayers".
m_cu_count = tmp;
saw_LayerCount = true;
}
else if( TESTLINE( "EnabledLayers" ) )
{
LAYER_MASK enabledLayers = hexParse( line + SZ( "EnabledLayers" ) );
if( !saw_LayerCount )
THROW_IO_ERROR( "Missing '$GENERAL's LayerCount" );
LEG_MASK enabledLayers = hexParse( line + SZ( "EnabledLayers" ) );
LSET new_mask = leg_mask2new( m_cu_count, enabledLayers );
// layer usage
//DBG( printf( "EnabledLayers: %s\n", new_mask.FmtHex().c_str() );)
m_board->SetEnabledLayers( new_mask );
// layer visibility equals layer usage, unless overridden later via "VisibleLayers"
// Must call SetEnabledLayers() before calling SetVisibleLayers().
m_board->SetVisibleLayers( new_mask );
}
else if( TESTLINE( "VisibleLayers" ) )
{
LAYER_MASK visibleLayers = hexParse( line + SZ( "VisibleLayers" ) );
if( !saw_LayerCount )
THROW_IO_ERROR( "Missing '$GENERAL's LayerCount" );
LEG_MASK visibleLayers = hexParse( line + SZ( "VisibleLayers" ) );
LSET new_mask = leg_mask2new( m_cu_count, visibleLayers );
@ -641,11 +671,16 @@ void LEGACY_PLUGIN::loadGENERAL()
else if( TESTLINE( "Ly" ) ) // Old format for Layer count
{
LAYER_MASK layer_mask = hexParse( line + SZ( "Ly" ) );
if( !saw_LayerCount )
{
LEG_MASK layer_mask = hexParse( line + SZ( "Ly" ) );
m_cu_count = layerMaskCountSet( layer_mask & ALL_CU_LAYERS );
m_cu_count = layerMaskCountSet( layer_mask & ALL_CU_LAYERS );
m_board->SetCopperLayerCount( m_cu_count );
m_board->SetCopperLayerCount( m_cu_count );
saw_LayerCount = true;
}
}
else if( TESTLINE( "BoardThickness" ) )
@ -867,18 +902,38 @@ void LEGACY_PLUGIN::loadSETUP()
bds.m_AuxOrigin = wxPoint( gx, gy );
}
/* Done from $General above's "LayerCount"
else if( TESTLINE( "Layers" ) )
{
int tmp = intParse( line + SZ( "Layers" ) );
m_board->SetCopperLayerCount( tmp );
m_cu_count = tmp;
}
*/
else if( TESTSUBSTR( "Layer[" ) )
{
// eg: "Layer[n] <a_Layer_name_with_no_spaces> <LAYER_T>"
LAYER_NUM layer_num = layerParse( line + SZ( "Layer[" ), &data );
LAYER_ID layer_id = leg_layer2new( m_cu_count, layer_num );
LAYER_ID layer_id = leg_layer2new( m_cu_count, layer_num );
/*
switch( layer_num )
{
case LAYER_N_BACK:
layer_id = B_Cu;
break;
case LAYER_N_FRONT:
layer_id = F_Cu;
break;
default:
layer_id = LAYER_ID( layer_num );
}
*/
data = strtok_r( (char*) data+1, delims, &saveptr ); // +1 for ']'
if( data )
@ -1496,7 +1551,7 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule )
data = strtok_r( NULL, delims, &saveptr ); // skip BufCar
data = strtok_r( NULL, delims, &saveptr );
LAYER_MASK layer_mask = hexParse( data );
LEG_MASK layer_mask = hexParse( data );
pad->SetLayerSet( leg_mask2new( m_cu_count, layer_mask ) );
pad->SetAttribute( attribute );

View File

@ -743,7 +743,7 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
{
cu.push_back( layer );
DBG( printf( "cop m_visible:%s\n", cu.back().m_visible ? "true" : "false" );)
//DBG( printf( "cop m_visible:%s\n", cu.back().m_visible ? "true" : "false" );)
}
else // all non-copper are fixed names, simply look up LAYER_ID.
{
@ -773,8 +773,10 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
m_board->SetLayer( LAYER_ID( it->m_number ), *it );
m_layerIndices[ it->m_name ] = LAYER_ID( it->m_number );
m_layerMasks[ it->m_name ] = LSET( it->m_number );
UTF8 name = it->m_name;
m_layerIndices[ name ] = LAYER_ID( it->m_number );
m_layerMasks[ name ] = LSET( it->m_number );
}
copperLayerCount = cu.size();
@ -782,12 +784,12 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
cu.clear(); // this marks the list as "one time processed".
}
LAYER_ID_MAP::const_iterator it = m_layerIndices.find( layer.m_name );
LAYER_ID_MAP::const_iterator it = m_layerIndices.find( UTF8( layer.m_name ) );
if( it == m_layerIndices.end() )
{
wxString error = wxString::Format(
_( "Layer '%s' in file <%s> at line %d, is not in fixed layer hash" ),
_( "Layer '%s' in file '%s' at line %d, is not in fixed layer hash" ),
GetChars( layer.m_name ),
GetChars( CurSource() ),
CurLineNumber(),
@ -804,7 +806,7 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
if( layer.m_visible )
visibleLayers.set( layer.m_number );
DBG( printf( "aux m_visible:%s\n", layer.m_visible ? "true" : "false" );)
//DBG( printf( "aux m_visible:%s\n", layer.m_visible ? "true" : "false" );)
m_board->SetLayer( LAYER_ID( layer.m_number ), layer );
}

View File

@ -137,7 +137,7 @@ public:
ITEM_SET::iterator end() { return m_allItems.end(); }
private:
static const int MaxSubIndices = 64;
static const int MaxSubIndices = 128;
static const int SI_Multilayer = 2;
static const int SI_SegDiagonal = 0;
static const int SI_SegStraight = 1;