Commit 9c16a218 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Pcbnew s-expression file format changes.

* Save dialog now supports saving boards to new file format.
* Add CMake option to build s-expression file save.
* Add check to main CMakeList.txt file to make sure nanometers are
  enables when the new file format is built.
* Minor tweaks to object format functions for improved output.
* Rename kicad_plugin.h/cpp to legacy_plugin.h/cpp.
parent 6976d253
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
# reports.
#

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

option(USE_NEW_PCBNEW_LOAD "use new plugin support for legacy file format" ON)
option(USE_NEW_PCBNEW_SAVE "use new plugin support for legacy file format" ON)
option(USE_PCBNEW_NANOMETRES
@@ -68,7 +71,12 @@ else (KICAD_STABLE_VERSION )
    endif(KICAD_TESTING_VERSION )
endif(KICAD_STABLE_VERSION )


# Nanometers must be enabled when USE_PCBNEW_SEXPR_FILE_FORMAT=ON.
if( USE_PCBNEW_SEXPR_FILE_FORMAT AND NOT USE_PCBNEW_NANOMETRES )
    set( TMP "The Pcbnew s-expression file format requires nano-meter internal units to be " )
    set( TMP "${TMP} enabled using -DUSE_PCBNEW_NANOMETRES=ON." )
    message( FATAL_ERROR ${TMP} )
endif( USE_PCBNEW_SEXPR_FILE_FORMAT AND NOT USE_PCBNEW_NANOMETRES )

#================================================
# Set flags for GCC.
+6 −5
Original line number Diff line number Diff line
@@ -57,13 +57,14 @@

#cmakedefine USE_NEW_PCBNEW_LOAD
#cmakedefine USE_NEW_PCBNEW_SAVE
#cmakedefine USE_PCBNEW_NANAMETERS
#cmakedefine USE_PCBNEW_NANOMETRES
#cmakedefine USE_PCBNEW_SEXPR_FILE_FORMAT

/// The file format revision of the *.brd file created by this build
#if defined(KICAD_NANOMETRE)
#define BOARD_FILE_VERSION          2
/// The legacy file format revision of the *.brd file created by this build
#if defined(USE_PCBNEW_NANOMETRES)
#define LEGACY_BOARD_FILE_VERSION          2
#else
#define BOARD_FILE_VERSION          1
#define LEGACY_BOARD_FILE_VERSION          1
#endif

#endif  // CONFIG_H_
+8 −2
Original line number Diff line number Diff line
@@ -119,7 +119,13 @@ set(PCB_COMMON_SRCS
)

if( USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE )
    set( PCB_COMMON_SRCS ${PCB_COMMON_SRCS} ../pcbnew/item_io.cpp ../pcbnew/io_mgr.cpp ../pcbnew/kicad_plugin.cpp )
    set( PCB_COMMON_SRCS
         ${PCB_COMMON_SRCS}
         ../pcbnew/item_io.cpp
         ../pcbnew/io_mgr.cpp
         ../pcbnew/legacy_plugin.cpp
         ../pcbnew/kicad_plugin.cpp
       )
else()
    set( PCB_COMMON_SRCS ${PCB_COMMON_SRCS} ../pcbnew/item_io.cpp )
endif()
+13 −15
Original line number Diff line number Diff line
@@ -574,12 +574,12 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
    throw( IO_ERROR )
{
    aFormatter->Print( aNestLevel, "(text %s (at %s",
                       EscapedUTF8( m_Text ).c_str(), FormatBIU( m_Pos ).c_str() );
                       aFormatter->Quotew( m_Text ).c_str(), FormatBIU( m_Pos ).c_str() );

    if( m_Orient != 0.0 )
        aFormatter->Print( aNestLevel, "%0.1f", m_Orient );
        aFormatter->Print( 0, " %0.1f", m_Orient );

    aFormatter->Print( aNestLevel, ")\n" );
    aFormatter->Print( 0, ")\n" );

    if( !IsDefaultFormatting() )
    {
@@ -593,15 +593,15 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
            // Add font support here at some point in the future.

            if( ( m_Size.x != DEFAULT_SIZE_TEXT ) || ( m_Size.y != DEFAULT_SIZE_TEXT ) )
                aFormatter->Print( aNestLevel+2, " (size %s)", FormatBIU( m_Size ).c_str() );
                aFormatter->Print( 0, " (size %s)", FormatBIU( m_Size ).c_str() );

            if( m_Bold )
                aFormatter->Print( aNestLevel+2, " bold" );
                aFormatter->Print( 0, " bold" );

            if( m_Bold )
                aFormatter->Print( aNestLevel+2, " italic" );
                aFormatter->Print( 0, " italic" );

            aFormatter->Print( aNestLevel+1, ")\n");
            aFormatter->Print( 0, ")\n");
        }

        if( m_Mirror || ( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
@@ -610,24 +610,22 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
            aFormatter->Print( aNestLevel+2, "(justify");

            if( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
                aFormatter->Print( aNestLevel+2,
                                   (m_HJustify == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
                aFormatter->Print( 0, (m_HJustify == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );

            if( m_VJustify != GR_TEXT_VJUSTIFY_CENTER )
                aFormatter->Print( aNestLevel+2,
                                   (m_VJustify == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
                aFormatter->Print( 0, (m_VJustify == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );

            if( m_Mirror )
                aFormatter->Print( aNestLevel+2, " mirror" );
                aFormatter->Print( 0, " mirror" );

            aFormatter->Print( aNestLevel+2, ")\n" );
            aFormatter->Print( 0, ")\n" );
        }

        // As of now the only place this is used is in Eeschema to hide or show the text.
        if( m_Attributs )
            aFormatter->Print( aNestLevel+2, "hide" );
            aFormatter->Print( aNestLevel+2, "hide\n" );

        aFormatter->Print( aNestLevel+1, "\n)\n" );
        aFormatter->Print( aNestLevel+1, ")\n" );
    }

    aFormatter->Print( aNestLevel, ")\n" );
+2 −1
Original line number Diff line number Diff line
@@ -54,7 +54,8 @@ const wxString ProjectFileWildcard( _( "KiCad project files (*.pro)|*.pro" ) );
const wxString SchematicFileWildcard( _( "KiCad schematic files (*.sch)|*.sch" ) );
const wxString NetlistFileWildcard( _( "KiCad netlist files (*.net)|*.net" ) );
const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) );
const wxString PcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) );
const wxString LegacyPcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) );
const wxString PcbFileWildcard( _( "KiCad s-expr printed circuit board files (*.kicad_brd)|*.kicad_brd" ) );
const wxString FootprintLibFileWildcard( _( "KiCad footprint library file (*.mod)|*.mod" ) );
const wxString PdfFileWildcard( _( "Portable document format files (*.pdf)|*.pdf" ) );
const wxString MacrosFileWildcard( _( "KiCad recorded macros (*.mcr)|*.mcr" ) );
Loading