Commit 7c86749c authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Add Pcbnew GEDA PCB module plugin support.

* Create new GEDA PCB plug in.
* Add support for opening GEDA PCB footprints with module editor.
* Make import footprint file dialog remember last selected footprint
  type during current session.
* Update module editor file import to use new GEDA PCB plug in.
* Let IO_MGR know about GEDA PCB plug in.
* Create a WHITESPACE_FILTER_READER to simplify parsing GEDA PCB footprint
  files.
parent d2126baf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ set(PCB_COMMON_SRCS
    ../pcbnew/eagle_plugin.cpp
    ../pcbnew/legacy_plugin.cpp
    ../pcbnew/kicad_plugin.cpp
    ../pcbnew/gpcb_plugin.cpp
    pcb_plot_params_keywords.cpp
    pcb_keywords.cpp
    ../pcbnew/pcb_parser.cpp
+40 −0
Original line number Diff line number Diff line
@@ -65,3 +65,43 @@ char* FILTER_READER::ReadLine() throw( IO_ERROR )
    return length ? line : NULL;
}


WHITESPACE_FILTER_READER::WHITESPACE_FILTER_READER( LINE_READER& aReader ) :
    LINE_READER( 1 ),
    reader( aReader )
{
    // Not using our own line buffer, will be using aReader's.  This changes
    // the meaning of this->line to be merely a pointer to aReader's line, which of course
    // is not owned here.
    delete [] line;

    line = 0;
}


WHITESPACE_FILTER_READER::~WHITESPACE_FILTER_READER()
{
    // Our 'line' points to aReader's, and he will delete that buffer.
    // Prevent subsequent call to ~LINE_READER() from deleting a buffer we do not own.
    line = 0;
}


char* WHITESPACE_FILTER_READER::ReadLine() throw( IO_ERROR )
{
    char* s;

    while( ( s = reader.ReadLine() ) != NULL )
    {
        while( s != NULL && strchr( " \t", *s ) )
            s++;

        if( s != NULL && !strchr( "#\n\r", *s ) )
            break;
    }

    line   = s;
    length = reader.Length();

    return length ? line : NULL;
}
+2 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ const wxString FootprintPlaceFileExtension( wxT( "pos" ) );

const wxString KiCadFootprintLibPathExtension( wxT( "pretty" ) );    ///< KICAD PLUGIN libpath
const wxString KiCadFootprintFileExtension( wxT( "kicad_mod" ) );
const wxString GedaPcbFootprintLibFileExtension( wxT( "fp" ) );

// These strings are wildcards for file selection dialogs.
// Because these are static, one should explicitly call wxGetTranslation
@@ -73,6 +74,7 @@ const wxString PcbFileWildcard( _( "KiCad s-expr printed circuit board files (*.
const wxString KiCadFootprintLibFileWildcard( _( "KiCad footprint s-expre library file (*.kicad_mod)|*.kicad_mod" ) );
const wxString KiCadFootprintLibPathWildcard( _( "KiCad footprint s-expre library path (*.pretty)|*.pretty" ) );
const wxString LegacyFootprintLibPathWildcard( _( "Legacy footprint library file (*.mod)|*.mod" ) );
const wxString GedaPcbFootprintLibFileWildcard( _( "Geda PCB footprint library file (*.fp)|*.fp" ) );
const wxString MacrosFileWildcard( _( "KiCad recorded macros (*.mcr)|*.mcr" ) );

// generic:
+34 −0
Original line number Diff line number Diff line
@@ -62,4 +62,38 @@ public:
    }
};


/**
 * Class WHITESPACE_FILTER_READER
 * reads lines of text from another LINE_READER, but only returns non-comment
 * lines and non-blank lines with leading whitespace characters (space and tab)
 * removed from its ReadLine() function.
 */
class WHITESPACE_FILTER_READER : public LINE_READER
{
    LINE_READER&  reader;

public:

    /**
     * Constructor ( LINE_READER& )
     * does not take ownership over @a aReader, so will not destroy it.
     */
    WHITESPACE_FILTER_READER( LINE_READER& aReader );

    ~WHITESPACE_FILTER_READER();

    char* ReadLine() throw( IO_ERROR );

    const wxString& GetSource() const
    {
        return reader.GetSource();
    }

    unsigned LineNumber() const
    {
        return reader.LineNumber();
    }
};

#endif // FILTER_READER_H_
+2 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ extern const wxString ReportFileExtension;
extern const wxString FootprintPlaceFileExtension;
extern const wxString KiCadFootprintFileExtension;
extern const wxString KiCadFootprintLibPathExtension;
extern const wxString GedaPcbFootprintLibFileExtension;

/// Proper wxFileDialog wild card definitions.
extern const wxString SchematicSymbolFileWildcard;
@@ -92,5 +93,6 @@ extern const wxString DocModulesFileName;
extern const wxString LegacyFootprintLibPathWildcard;
extern const wxString KiCadFootprintLibFileWildcard;
extern const wxString KiCadFootprintLibPathWildcard;
extern const wxString GedaPcbFootprintLibFileWildcard;

#endif  // INCLUDE_WILDCARDS_AND_FILES_EXT_H_
Loading