Commit 1468a4ae authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Pcbnew s-experssion footprint library implementation.

* Add footprint methods to PCB_IO.
* Add FP_CACHE and FP_CACHE_ITEM for handling new footprint library design.
* Add code to save legacy libraries in new format.
* Change behavior of BOARD_ITEM::GetLayerName() to return the default layer
  name when the item does not have a BOARD as a parent.
* Minor changes to the module output formatter when writing to module library
  files (no BOARD as parent).
* Add new (and some that I forgot along the way) CMake flags to
  EDA_BASE_FRAME::CopyVersionInfoToClipboard().
* Add -Wno-narrowing to GCC flags to stop GCC 4.7 from complaining about
  a conversion from int to unsigned in the Boost polygon library.
* Add INPUT_STREAM_READER to richio.cpp to allow using any object derived
  from wxInputStream as a LINE_READER (needs to be validated).
parent 8031e512
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -21,11 +21,14 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
#

option(USE_PCBNEW_SEXPR_FILE_FORMAT
       "Use s-expression Pcbnew file format support (default OFF)." )
       "Use Pcbnew s-expression file format support (default OFF)." )

option(USE_PCBNEW_NANOMETRES
       "Use nanometers for Pcbnew internal units instead of deci-mils (default OFF).")

option(USE_PCBNEW_SEXPR_FOOTPRINT_LIBS
       "Use Pcbnew s-expression footprint library format (default OFF).")

# Russian GOST patch
option(wxUSE_UNICODE "enable/disable building unicode (default OFF)")
option(KICAD_GOST "enable/disable building using GOST notation for multiple gates per package (default OFF)")
@@ -100,15 +103,20 @@ endif( USE_PCBNEW_SEXPR_FILE_FORMAT AND NOT USE_PCBNEW_NANOMETRES )
#================================================

if(CMAKE_COMPILER_IS_GNUCXX)
    # Added -Wno-narrowing on 10/7/12 to prevent a huge number of warnings when
    # compiling with GCC 4.7.  This appears to be caused by and int to unsigned
    # conversion in the Boost polygon library.  At some point in the future when
    # Boost is updated to the next version, -Wno-narrowing should be removed to
    # see if the problem has been resolved.  Wayne.
    if(WIN32)   # under Windows/mingw,  -fPIC option is enabled by default
        # Set default flags for Release build.
        set(CMAKE_C_FLAGS_RELEASE "-Wall -O2 -DNDEBUG")
        set(CMAKE_CXX_FLAGS_RELEASE "-Wall -O2 -DNDEBUG")
        set(CMAKE_C_FLAGS_RELEASE "-Wall -Wno-narrowing -O2 -DNDEBUG")
        set(CMAKE_CXX_FLAGS_RELEASE "-Wall -Wno-narrowing -O2 -DNDEBUG")
        set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s")

        # Set default flags for Debug build.
        set(CMAKE_C_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG")
        set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG")
        set(CMAKE_C_FLAGS_DEBUG "-Wall -Wno-narrowing -g3 -ggdb3 -DDEBUG")
        set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wno-narrowing -g3 -ggdb3 -DDEBUG")
    else(WIN32)
        # Set default flags for Release build.
        set(CMAKE_C_FLAGS_RELEASE "-Wall -O2 -DNDEBUG -fPIC")
@@ -116,8 +124,8 @@ if(CMAKE_COMPILER_IS_GNUCXX)
        set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s")

        # Set default flags for Debug build.
        set(CMAKE_C_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG -fPIC")
        set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG -fPIC")
        set(CMAKE_C_FLAGS_DEBUG "-Wall -Wno-narrowing -g3 -ggdb3 -DDEBUG -fPIC")
        set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wno-narrowing -g3 -ggdb3 -DDEBUG -fPIC")
    endif(WIN32)

endif(CMAKE_COMPILER_IS_GNUCXX)
+2 −0
Original line number Diff line number Diff line
@@ -55,8 +55,10 @@

#cmakedefine USE_IMAGES_IN_MENUS 1

/// Definitions to enable the s-expression file formats and nanometer units.
#cmakedefine USE_PCBNEW_NANOMETRES
#cmakedefine USE_PCBNEW_SEXPR_FILE_FORMAT
#cmakedefine USE_PCBNEW_SEXPR_FOOTPRINT_LIBS

/// The legacy file format revision of the *.brd file created by this build
#if defined(USE_PCBNEW_NANOMETRES)
+21 −0
Original line number Diff line number Diff line
@@ -499,6 +499,27 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event )

    tmp << wxT( "Options: " );

    tmp << wxT( "         USE_PCBNEW_SEXPR_FILE_FORMAT=" );
#ifdef USE_PCBNEW_SEXPR_FILE_FORMAT
    tmp << wxT( "ON\n" );
#else
    tmp << wxT( "OFF\n" );
#endif

    tmp << wxT( "         USE_PCBNEW_NANOMETRES=" );
#ifdef USE_PCBNEW_NANOMETRES
    tmp << wxT( "ON\n" );
#else
    tmp << wxT( "OFF\n" );
#endif

    tmp << wxT( "         USE_PCBNEW_SEXPR_FOOTPRINT_LIBS=" );
#ifdef USE_PCBNEW_SEXPR_FOOTPRINT_LIBS
    tmp << wxT( "ON\n" );
#else
    tmp << wxT( "OFF\n" );
#endif

    tmp << wxT( "         KICAD_GOST=" );
#ifdef KICAD_GOST
    tmp << wxT( "ON\n" );
+38 −0
Original line number Diff line number Diff line
@@ -185,6 +185,44 @@ unsigned STRING_LINE_READER::ReadLine() throw( IO_ERROR )
}


INPUTSTREAM_LINE_READER::INPUTSTREAM_LINE_READER( wxInputStream* aStream ) :
    LINE_READER( LINE_READER_LINE_DEFAULT_MAX ),
    m_stream( aStream )
{
}


unsigned INPUTSTREAM_LINE_READER::ReadLine() throw( IO_ERROR )
{
    length  = 0;
    line[0] = 0;

    while( !m_stream->Eof() )
    {
        if( length >= maxLineLength )
            THROW_IO_ERROR( _( "Maximum line length exceeded" ) );

        if( length + 1 > capacity )
            expandCapacity( capacity * 2 );

        line[ length ] = m_stream->GetC();
        length++;

        if( line[ length - 1 ] == '\n' )
            break;
    }

    line[ length ] = 0;
    length -= 1;

    // lineNum is incremented even if there was no line read, because this
    // leads to better error reporting when we hit an end of file.
    ++lineNum;

    return length;
}


//-----<OUTPUTFORMATTER>----------------------------------------------------

// factor out a common GetQuoteChar
+3 −1
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ const wxString DrillFileExtension( wxT( "drl" ) );
const wxString SVGFileExtension( wxT( "svg" ) );
const wxString ReportFileExtension( wxT( "rpt" ) );
const wxString FootprintPlaceFileExtension( wxT( "pos" ) );
const wxString FootprintFileExtension( wxT( "kicad_mod" ) );

// These strings are wildcards for file selection dialogs.
// Because thes are static, one should explicitely call wxGetTranslation
@@ -64,7 +65,8 @@ const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) );
const wxString LegacyPcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) );
const wxString EaglePcbFileWildcard( _( "Eagle ver. 6.x XML PCB files (*.brd)|*.brd" ) );
const wxString PcbFileWildcard( _( "KiCad s-expr printed circuit board files (*.kicad_pcb)|*.kicad_pcb" ) );
const wxString FootprintLibFileWildcard( _( "KiCad footprint library file (*.mod)|*.mod" ) );
const wxString FootprintLibFileWildcard( _( "KiCad footprint s-expre library file (*.kicad_mod)|*.kicad_mod" ) );
const wxString LegacyFootprintLibFileWildcard( _( "KiCad footprint library file (*.mod)|*.mod" ) );
const wxString PdfFileWildcard( _( "Portable document format files (*.pdf)|*.pdf" ) );
const wxString MacrosFileWildcard( _( "KiCad recorded macros (*.mcr)|*.mcr" ) );
const wxString AllFilesWildcard( _( "All files (*)|*" ) );
Loading