Commit b59cebb2 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

fix incorrect use of KIROUND instead of KiROUND in parseBoardUnits( const...

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.
parent 0c4a026e
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@
#include <class_edge_mod.h>
#include <class_edge_mod.h>


#include <pcbnew.h>
#include <pcbnew.h>
#include <convert_to_biu.h>




/* read parameters from a line, and return all params in a wxArrayString
/* 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 )
bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
{
{
    #define TEXT_DEFAULT_SIZE  400
    #define TEXT_DEFAULT_SIZE  (40*IU_PER_MILS)
    #define OLD_GPCB_UNIT_CONV 10
    #define OLD_GPCB_UNIT_CONV IU_PER_MILS
    #define NEW_GPCB_UNIT_CONV 0.1
    #define NEW_GPCB_UNIT_CONV (0.01*IU_PER_MILS)


    FILE*         cmpfile;
    FILE*         cmpfile;
    double        conv_unit = NEW_GPCB_UNIT_CONV; // GPCB unit = 0.01 mils and Pcbnew 0.1
    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->SetPos0( pos );
    m_Reference->SetOrientation( ibuf[idx+2] ? 900 : 0 );
    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
    // 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 tsize = ( ibuf[idx+3] * TEXT_DEFAULT_SIZE ) / 100;
    int thickness = m_Reference->m_Size.x / 6;
    int thickness = m_Reference->m_Size.x / 6;
+2 −2
Original line number Original line Diff line number Diff line
@@ -729,7 +729,7 @@ int PCB_PARSER::lookUpLayer() throw( PARSE_ERROR, IO_ERROR )
    if( it == m_layerMap.end() )
    if( it == m_layerMap.end() )
    {
    {
        wxString error;
        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() );
                      GetChars( name ), GetChars( CurSource() ), CurLineNumber(), CurOffset() );
        THROW_IO_ERROR( error );
        THROW_IO_ERROR( error );
    }
    }
@@ -2583,7 +2583,7 @@ PCB_TARGET* PCB_PARSER::parsePCB_TARGET() throw( IO_ERROR, PARSE_ERROR )
            break;
            break;


        default:
        default:
            Expecting( "x, plus, at, size, width, or tstamp" );
            Expecting( "x, plus, at, size, width, layer or tstamp" );
        }
        }
    }
    }


+4 −1
Original line number Original line Diff line number Diff line
@@ -175,7 +175,10 @@ class PCB_PARSER : public PCB_LEXER


    inline int parseBoardUnits( const char* aExpected ) throw( PARSE_ERROR )
    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 )
    inline int parseBoardUnits( T aToken ) throw( PARSE_ERROR )