From b59cebb2a7b80cbe664e55c83be8b8047436ce0a Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 14 Jun 2012 08:29:54 +0200 Subject: [PATCH] fix incorrect use of KIROUND instead of KiROUND in parseBoardUnits( const char* aExpected ) (see comments in .h file) very minor fix in pcb_parser.cpp Fix scaling issue with nanometers in gpcb footprint import. --- pcbnew/gpcb_exchange.cpp | 9 +++++---- pcbnew/pcb_parser.cpp | 4 ++-- pcbnew/pcb_parser.h | 5 ++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pcbnew/gpcb_exchange.cpp b/pcbnew/gpcb_exchange.cpp index 58642bdbb4..878ff12422 100644 --- a/pcbnew/gpcb_exchange.cpp +++ b/pcbnew/gpcb_exchange.cpp @@ -40,6 +40,7 @@ #include #include +#include /* read parameters from a line, and return all params in a wxArrayString @@ -179,9 +180,9 @@ static bool TestFlags( const wxString& flg_string, long flg_mask, const wxChar* */ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) { - #define TEXT_DEFAULT_SIZE 400 - #define OLD_GPCB_UNIT_CONV 10 - #define NEW_GPCB_UNIT_CONV 0.1 + #define TEXT_DEFAULT_SIZE (40*IU_PER_MILS) + #define OLD_GPCB_UNIT_CONV IU_PER_MILS + #define NEW_GPCB_UNIT_CONV (0.01*IU_PER_MILS) FILE* cmpfile; double conv_unit = NEW_GPCB_UNIT_CONV; // GPCB unit = 0.01 mils and Pcbnew 0.1 @@ -277,7 +278,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) m_Reference->SetPos0( pos ); m_Reference->SetOrientation( ibuf[idx+2] ? 900 : 0 ); - // Calculate size: default is 40 mils (400 pcb units) + // Calculate size: default is 40 mils // real size is: default * ibuf[idx+3] / 100 (size in gpcb is given in percent of default size int tsize = ( ibuf[idx+3] * TEXT_DEFAULT_SIZE ) / 100; int thickness = m_Reference->m_Size.x / 6; diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 134d3cca2f..082106a148 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -729,7 +729,7 @@ int PCB_PARSER::lookUpLayer() throw( PARSE_ERROR, IO_ERROR ) if( it == m_layerMap.end() ) { wxString error; - error.Printf( _( "Layer %s in file <%s> at line %d, position %d was not defined in the layers section" ), + error.Printf( _( "Layer '%s' in file <%s> at line %d, position %d was not defined in the layers section" ), GetChars( name ), GetChars( CurSource() ), CurLineNumber(), CurOffset() ); THROW_IO_ERROR( error ); } @@ -2583,7 +2583,7 @@ PCB_TARGET* PCB_PARSER::parsePCB_TARGET() throw( IO_ERROR, PARSE_ERROR ) break; default: - Expecting( "x, plus, at, size, width, or tstamp" ); + Expecting( "x, plus, at, size, width, layer or tstamp" ); } } diff --git a/pcbnew/pcb_parser.h b/pcbnew/pcb_parser.h index e69edd6c71..f94d9c558e 100644 --- a/pcbnew/pcb_parser.h +++ b/pcbnew/pcb_parser.h @@ -175,7 +175,10 @@ class PCB_PARSER : public PCB_LEXER inline int parseBoardUnits( const char* aExpected ) throw( PARSE_ERROR ) { - return KIROUND( parseDouble( aExpected ) * IU_PER_MM ); + // Use here KiROUND, not KIROUND (see comments about them) + // when having a function as argument, because it will be called twice + // with KIROUND + return KiROUND( parseDouble( aExpected ) * IU_PER_MM ); } inline int parseBoardUnits( T aToken ) throw( PARSE_ERROR )