Commit a42490e0 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

work on footprint plugin API

parent add53213
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -116,15 +116,6 @@ void BASE_SCREEN::SetScalingFactor(double aScale )
}


void BASE_SCREEN::SetZoomList( const wxArrayDouble& zoomlist )
{
    if( !m_ZoomList.IsEmpty() )
        m_ZoomList.Empty();

    m_ZoomList = zoomlist;
}


bool BASE_SCREEN::SetFirstZoom()
{
    if( m_ZoomList.IsEmpty() )
+1 −1
Original line number Diff line number Diff line
@@ -369,7 +369,7 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
    else
    {
        id--;
        int selectedZoom = GetScreen()->m_ZoomList[id];
        double selectedZoom = GetScreen()->m_ZoomList[id];

        if( GetScreen()->GetZoom() == selectedZoom )
            return;
+20 −71
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <richio.h>
#include <filter_reader.h>
#include <footprint_info.h>
#include <io_mgr.h>

#include <class_pad.h>
#include <class_module.h>
@@ -41,7 +42,6 @@
 */
bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
{
    FILE*       file;
    wxFileName  filename;
    wxString    libname;

@@ -50,7 +50,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames )
    m_filesInvalid.Empty();
    m_List.clear();

    /* Parse Libraries Listed */
    PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );

    // Parse Libraries Listed
    for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ )
    {
        filename = aFootprintsLibNames[ii];
@@ -64,82 +66,28 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames )
            continue;
        }

        /* Open library file */
        file = wxFopen( libname, wxT( "rt" ) );

        if( file == NULL )
        {
            m_filesInvalid << libname <<  _(" (file cannot be opened)") << wxT("\n");
            continue;
        }

        FILE_LINE_READER    fileReader( file, libname );
        FILTER_READER       reader( fileReader );

        /* Read header. */
        reader.ReadLine();
        char * line = reader.Line();
        StrPurge( line );

        if( strnicmp( line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) != 0 )
        try
        {
            wxString msg;
            msg.Printf( _( "<%s> is not a valid KiCad PCB footprint library." ),
                        GetChars( libname ) );
            m_filesInvalid << msg << wxT("\n");
            continue;
        }
            wxArrayString fpnames = pi->FootprintEnumerate( libname );

        // Read library
        bool end = false;
        while( !end && reader.ReadLine() )
        {
            line = reader.Line();
            StrPurge( line );
            if( strnicmp( line, "$EndLIBRARY", 11 ) == 0 )
            {
                end = true;
                break;
            }
            if( strnicmp( line, "$MODULE", 7 ) == 0 )
            for( unsigned i=0; i<fpnames.GetCount();  ++i )
            {
                std::auto_ptr<MODULE> m( pi->FootprintLoad( libname, fpnames[i] ) );

                line += 7;
                FOOTPRINT_INFO*  ItemLib = new FOOTPRINT_INFO();
                ItemLib->m_Module = FROM_UTF8( StrPurge( line ) );
                ItemLib->m_LibName = libname;
                AddItem( ItemLib );

                while( reader.ReadLine() )
                {
                    line = reader.Line();
                    StrPurge( line );
                    if( strnicmp( line, "$EndMODULE", 10 ) == 0 )
                        break;
                FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();

                    if( strnicmp( line, "$PAD", 4 ) == 0 )
                        ItemLib->m_padCount++;
                fpinfo->m_Module   = fpnames[i];
                fpinfo->m_LibName  = libname;
                fpinfo->m_padCount = m->GetPadCount();
                fpinfo->m_KeyWord  = m->GetKeywords();
                fpinfo->m_Doc      = m->GetDescription();

                    int id = ((line[0] & 0xFF) << 8) + (line[1] & 0xFF);
                    switch( id )
                    {
                    /* KeyWords */
                    case (('K'<<8) + 'w'):
                        ItemLib->m_KeyWord = FROM_UTF8( StrPurge( line + 3 ) );
                    break;

                    /* Doc */
                    case (('C'<<8) + 'd'):
                        ItemLib->m_Doc = FROM_UTF8( StrPurge( line + 3 ) );
                    break;
                    }
                }
                AddItem( fpinfo );
            }
        }

        if( !end )
        catch( IO_ERROR ioe )
        {
            m_filesInvalid << libname << _(" (Unexpected end of file)") << wxT("\n");
            m_filesInvalid << ioe.errorText << wxT("\n");
        }
    }

@@ -147,3 +95,4 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames )

    return true;
}
+0 −1
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY::~DIALOG_EDIT_COMPONENT_IN_LIBRARY()
*/
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg()
{
    SetFocus();
    m_AliasLocation = -1;

    LIB_COMPONENT* component = m_Parent->GetComponent();
+19 −2
Original line number Diff line number Diff line
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011)
// C++ code generated with wxFormBuilder (version Apr 11 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@@ -9,7 +9,7 @@

///////////////////////////////////////////////////////////////////////////

DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	
@@ -50,6 +50,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
	
	m_OptionsBoxSizer->Add( m_PinsNameInsideButt, 0, wxALL, 5 );
	
	
	bSizerBasicPanel->Add( m_OptionsBoxSizer, 0, 0, 5 );
	
	m_staticline3 = new wxStaticLine( m_PanelBasic, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
@@ -70,6 +71,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
	m_SelNumberOfUnits = new wxSpinCtrl( m_PanelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 26, 1 );
	bSizernbunits->Add( m_SelNumberOfUnits, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
	
	
	bSizerMidBasicPanel->Add( bSizernbunits, 1, wxEXPAND, 5 );
	
	wxBoxSizer* bSizer17;
@@ -84,8 +86,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
	m_SetSkew = new wxSpinCtrl( m_PanelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 100, 0 );
	bSizer17->Add( m_SetSkew, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
	
	
	bSizerMidBasicPanel->Add( bSizer17, 1, wxEXPAND, 5 );
	
	
	bSizerBasicPanel->Add( bSizerMidBasicPanel, 0, wxEXPAND, 5 );
	
	m_staticline1 = new wxStaticLine( m_PanelBasic, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
@@ -101,6 +105,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
	
	bSizerBasicPanel->Add( m_OptionPartsLocked, 0, wxALL, 5 );
	
	
	m_PanelBasic->SetSizer( bSizerBasicPanel );
	m_PanelBasic->Layout();
	bSizerBasicPanel->Fit( m_PanelBasic );
@@ -145,8 +150,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
	m_buttonBrowseDocFiles = new wxButton( m_PanelDoc, ID_BROWSE_DOC_FILES, _("Browse DocFiles"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizerPaneldocbutts->Add( m_buttonBrowseDocFiles, 0, wxALL, 5 );
	
	
	m_PanelDocBoxSizer->Add( bSizerPaneldocbutts, 0, wxALIGN_CENTER_HORIZONTAL, 5 );
	
	
	m_PanelDoc->SetSizer( m_PanelDocBoxSizer );
	m_PanelDoc->Layout();
	m_PanelDocBoxSizer->Fit( m_PanelDoc );
@@ -167,6 +174,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
	m_PartAliasListCtrl = new wxListBox( m_PanelAlias, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); 
	bLeftBoxSizerPanelAlias->Add( m_PartAliasListCtrl, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
	
	
	bSizerMainPanelAlias->Add( bLeftBoxSizerPanelAlias, 1, wxEXPAND, 5 );
	
	wxBoxSizer* bRightBoxSizerPanelAlias;
@@ -181,8 +189,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
	m_ButtonDeleteAllAlias = new wxButton( m_PanelAlias, ID_DELETE_ALL_ALIAS, _("Delete All"), wxDefaultPosition, wxDefaultSize, 0 );
	bRightBoxSizerPanelAlias->Add( m_ButtonDeleteAllAlias, 0, wxALL, 5 );
	
	
	bSizerMainPanelAlias->Add( bRightBoxSizerPanelAlias, 0, wxALIGN_CENTER_VERTICAL, 5 );
	
	
	m_PanelAlias->SetSizer( bSizerMainPanelAlias );
	m_PanelAlias->Layout();
	bSizerMainPanelAlias->Fit( m_PanelAlias );
@@ -203,6 +213,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
	m_FootprintFilterListBox = new wxListBox( m_PanelFootprintFilter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); 
	bFpFilterLeftBoxSizer->Add( m_FootprintFilterListBox, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
	
	
	bPanelFpFilterBoxSizer->Add( bFpFilterLeftBoxSizer, 1, wxEXPAND, 5 );
	
	wxBoxSizer* bFpFilterRightBoxSizer;
@@ -217,8 +228,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
	m_ButtonDeleteAllFootprintFilter = new wxButton( m_PanelFootprintFilter, ID_DELETE_ALL_FOOTPRINT_FILTER, _("Delete All"), wxDefaultPosition, wxDefaultSize, 0 );
	bFpFilterRightBoxSizer->Add( m_ButtonDeleteAllFootprintFilter, 0, wxALL|wxEXPAND, 5 );
	
	
	bPanelFpFilterBoxSizer->Add( bFpFilterRightBoxSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
	
	
	m_PanelFootprintFilter->SetSizer( bPanelFpFilterBoxSizer );
	m_PanelFootprintFilter->Layout();
	bPanelFpFilterBoxSizer->Fit( m_PanelFootprintFilter );
@@ -226,6 +239,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
	
	bUpperSizer->Add( m_NoteBook, 1, wxEXPAND, 5 );
	
	
	bMainSizer->Add( bUpperSizer, 1, wxEXPAND, 5 );
	
	m_stdSizerButton = new wxStdDialogButtonSizer();
@@ -234,10 +248,13 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
	m_stdSizerButtonCancel = new wxButton( this, wxID_CANCEL );
	m_stdSizerButton->AddButton( m_stdSizerButtonCancel );
	m_stdSizerButton->Realize();
	
	bMainSizer->Add( m_stdSizerButton, 0, wxEXPAND|wxALL, 5 );
	
	
	this->SetSizer( bMainSizer );
	this->Layout();
	bMainSizer->Fit( this );
	
	// Connect Events
	m_ButtonCopyDoc->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::CopyDocToAlias ), NULL, this );
Loading