Commit a42490e0 authored by Dick Hollenbeck's avatar Dick Hollenbeck

work on footprint plugin API

parent add53213
...@@ -116,15 +116,6 @@ void BASE_SCREEN::SetScalingFactor(double aScale ) ...@@ -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() bool BASE_SCREEN::SetFirstZoom()
{ {
if( m_ZoomList.IsEmpty() ) if( m_ZoomList.IsEmpty() )
......
...@@ -369,7 +369,7 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) ...@@ -369,7 +369,7 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
else else
{ {
id--; id--;
int selectedZoom = GetScreen()->m_ZoomList[id]; double selectedZoom = GetScreen()->m_ZoomList[id];
if( GetScreen()->GetZoom() == selectedZoom ) if( GetScreen()->GetZoom() == selectedZoom )
return; return;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <richio.h> #include <richio.h>
#include <filter_reader.h> #include <filter_reader.h>
#include <footprint_info.h> #include <footprint_info.h>
#include <io_mgr.h>
#include <class_pad.h> #include <class_pad.h>
#include <class_module.h> #include <class_module.h>
...@@ -39,9 +40,8 @@ ...@@ -39,9 +40,8 @@
* ...... other data (pads, outlines ..) * ...... other data (pads, outlines ..)
* $Endmodule * $Endmodule
*/ */
bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames ) bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
{ {
FILE* file;
wxFileName filename; wxFileName filename;
wxString libname; wxString libname;
...@@ -50,7 +50,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames ) ...@@ -50,7 +50,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames )
m_filesInvalid.Empty(); m_filesInvalid.Empty();
m_List.clear(); 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++ ) for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ )
{ {
filename = aFootprintsLibNames[ii]; filename = aFootprintsLibNames[ii];
...@@ -64,82 +66,28 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames ) ...@@ -64,82 +66,28 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames )
continue; continue;
} }
/* Open library file */ try
file = wxFopen( libname, wxT( "rt" ) );
if( file == NULL )
{ {
m_filesInvalid << libname << _(" (file cannot be opened)") << wxT("\n"); wxArrayString fpnames = pi->FootprintEnumerate( libname );
continue;
}
FILE_LINE_READER fileReader( file, libname ); for( unsigned i=0; i<fpnames.GetCount(); ++i )
FILTER_READER reader( fileReader ); {
std::auto_ptr<MODULE> m( pi->FootprintLoad( libname, fpnames[i] ) );
/* Read header. */ FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();
reader.ReadLine();
char * line = reader.Line();
StrPurge( line );
if( strnicmp( line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) != 0 ) fpinfo->m_Module = fpnames[i];
{ fpinfo->m_LibName = libname;
wxString msg; fpinfo->m_padCount = m->GetPadCount();
msg.Printf( _( "<%s> is not a valid KiCad PCB footprint library." ), fpinfo->m_KeyWord = m->GetKeywords();
GetChars( libname ) ); fpinfo->m_Doc = m->GetDescription();
m_filesInvalid << msg << wxT("\n");
continue;
}
// Read library AddItem( fpinfo );
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 )
{
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;
if( strnicmp( line, "$PAD", 4 ) == 0 )
ItemLib->m_padCount++;
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;
}
}
} }
} }
catch( IO_ERROR ioe )
if( !end )
{ {
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 ) ...@@ -147,3 +95,4 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames )
return true; return true;
} }
...@@ -39,7 +39,6 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY::~DIALOG_EDIT_COMPONENT_IN_LIBRARY() ...@@ -39,7 +39,6 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY::~DIALOG_EDIT_COMPONENT_IN_LIBRARY()
*/ */
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg() void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg()
{ {
SetFocus();
m_AliasLocation = -1; m_AliasLocation = -1;
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011) // C++ code generated with wxFormBuilder (version Apr 11 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -9,7 +9,7 @@ ...@@ -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 ); this->SetSizeHints( wxDefaultSize, wxDefaultSize );
...@@ -50,6 +50,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx ...@@ -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 ); m_OptionsBoxSizer->Add( m_PinsNameInsideButt, 0, wxALL, 5 );
bSizerBasicPanel->Add( m_OptionsBoxSizer, 0, 0, 5 ); bSizerBasicPanel->Add( m_OptionsBoxSizer, 0, 0, 5 );
m_staticline3 = new wxStaticLine( m_PanelBasic, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); 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 ...@@ -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 ); 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 ); bSizernbunits->Add( m_SelNumberOfUnits, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bSizerMidBasicPanel->Add( bSizernbunits, 1, wxEXPAND, 5 ); bSizerMidBasicPanel->Add( bSizernbunits, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer17; wxBoxSizer* bSizer17;
...@@ -84,8 +86,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx ...@@ -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 ); 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 ); bSizer17->Add( m_SetSkew, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMidBasicPanel->Add( bSizer17, 1, wxEXPAND, 5 ); bSizerMidBasicPanel->Add( bSizer17, 1, wxEXPAND, 5 );
bSizerBasicPanel->Add( bSizerMidBasicPanel, 0, wxEXPAND, 5 ); bSizerBasicPanel->Add( bSizerMidBasicPanel, 0, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( m_PanelBasic, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); 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 ...@@ -101,6 +105,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
bSizerBasicPanel->Add( m_OptionPartsLocked, 0, wxALL, 5 ); bSizerBasicPanel->Add( m_OptionPartsLocked, 0, wxALL, 5 );
m_PanelBasic->SetSizer( bSizerBasicPanel ); m_PanelBasic->SetSizer( bSizerBasicPanel );
m_PanelBasic->Layout(); m_PanelBasic->Layout();
bSizerBasicPanel->Fit( m_PanelBasic ); bSizerBasicPanel->Fit( m_PanelBasic );
...@@ -145,8 +150,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx ...@@ -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 ); m_buttonBrowseDocFiles = new wxButton( m_PanelDoc, ID_BROWSE_DOC_FILES, _("Browse DocFiles"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerPaneldocbutts->Add( m_buttonBrowseDocFiles, 0, wxALL, 5 ); bSizerPaneldocbutts->Add( m_buttonBrowseDocFiles, 0, wxALL, 5 );
m_PanelDocBoxSizer->Add( bSizerPaneldocbutts, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); m_PanelDocBoxSizer->Add( bSizerPaneldocbutts, 0, wxALIGN_CENTER_HORIZONTAL, 5 );
m_PanelDoc->SetSizer( m_PanelDocBoxSizer ); m_PanelDoc->SetSizer( m_PanelDocBoxSizer );
m_PanelDoc->Layout(); m_PanelDoc->Layout();
m_PanelDocBoxSizer->Fit( m_PanelDoc ); m_PanelDocBoxSizer->Fit( m_PanelDoc );
...@@ -167,6 +174,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx ...@@ -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 ); m_PartAliasListCtrl = new wxListBox( m_PanelAlias, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
bLeftBoxSizerPanelAlias->Add( m_PartAliasListCtrl, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); bLeftBoxSizerPanelAlias->Add( m_PartAliasListCtrl, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMainPanelAlias->Add( bLeftBoxSizerPanelAlias, 1, wxEXPAND, 5 ); bSizerMainPanelAlias->Add( bLeftBoxSizerPanelAlias, 1, wxEXPAND, 5 );
wxBoxSizer* bRightBoxSizerPanelAlias; wxBoxSizer* bRightBoxSizerPanelAlias;
...@@ -181,8 +189,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx ...@@ -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 ); m_ButtonDeleteAllAlias = new wxButton( m_PanelAlias, ID_DELETE_ALL_ALIAS, _("Delete All"), wxDefaultPosition, wxDefaultSize, 0 );
bRightBoxSizerPanelAlias->Add( m_ButtonDeleteAllAlias, 0, wxALL, 5 ); bRightBoxSizerPanelAlias->Add( m_ButtonDeleteAllAlias, 0, wxALL, 5 );
bSizerMainPanelAlias->Add( bRightBoxSizerPanelAlias, 0, wxALIGN_CENTER_VERTICAL, 5 ); bSizerMainPanelAlias->Add( bRightBoxSizerPanelAlias, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_PanelAlias->SetSizer( bSizerMainPanelAlias ); m_PanelAlias->SetSizer( bSizerMainPanelAlias );
m_PanelAlias->Layout(); m_PanelAlias->Layout();
bSizerMainPanelAlias->Fit( m_PanelAlias ); bSizerMainPanelAlias->Fit( m_PanelAlias );
...@@ -203,6 +213,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx ...@@ -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 ); m_FootprintFilterListBox = new wxListBox( m_PanelFootprintFilter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
bFpFilterLeftBoxSizer->Add( m_FootprintFilterListBox, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); bFpFilterLeftBoxSizer->Add( m_FootprintFilterListBox, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bPanelFpFilterBoxSizer->Add( bFpFilterLeftBoxSizer, 1, wxEXPAND, 5 ); bPanelFpFilterBoxSizer->Add( bFpFilterLeftBoxSizer, 1, wxEXPAND, 5 );
wxBoxSizer* bFpFilterRightBoxSizer; wxBoxSizer* bFpFilterRightBoxSizer;
...@@ -217,8 +228,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx ...@@ -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 ); m_ButtonDeleteAllFootprintFilter = new wxButton( m_PanelFootprintFilter, ID_DELETE_ALL_FOOTPRINT_FILTER, _("Delete All"), wxDefaultPosition, wxDefaultSize, 0 );
bFpFilterRightBoxSizer->Add( m_ButtonDeleteAllFootprintFilter, 0, wxALL|wxEXPAND, 5 ); bFpFilterRightBoxSizer->Add( m_ButtonDeleteAllFootprintFilter, 0, wxALL|wxEXPAND, 5 );
bPanelFpFilterBoxSizer->Add( bFpFilterRightBoxSizer, 0, wxALIGN_CENTER_VERTICAL, 5 ); bPanelFpFilterBoxSizer->Add( bFpFilterRightBoxSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_PanelFootprintFilter->SetSizer( bPanelFpFilterBoxSizer ); m_PanelFootprintFilter->SetSizer( bPanelFpFilterBoxSizer );
m_PanelFootprintFilter->Layout(); m_PanelFootprintFilter->Layout();
bPanelFpFilterBoxSizer->Fit( m_PanelFootprintFilter ); bPanelFpFilterBoxSizer->Fit( m_PanelFootprintFilter );
...@@ -226,6 +239,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx ...@@ -226,6 +239,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
bUpperSizer->Add( m_NoteBook, 1, wxEXPAND, 5 ); bUpperSizer->Add( m_NoteBook, 1, wxEXPAND, 5 );
bMainSizer->Add( bUpperSizer, 1, wxEXPAND, 5 ); bMainSizer->Add( bUpperSizer, 1, wxEXPAND, 5 );
m_stdSizerButton = new wxStdDialogButtonSizer(); m_stdSizerButton = new wxStdDialogButtonSizer();
...@@ -234,10 +248,13 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx ...@@ -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_stdSizerButtonCancel = new wxButton( this, wxID_CANCEL );
m_stdSizerButton->AddButton( m_stdSizerButtonCancel ); m_stdSizerButton->AddButton( m_stdSizerButtonCancel );
m_stdSizerButton->Realize(); m_stdSizerButton->Realize();
bMainSizer->Add( m_stdSizerButton, 0, wxEXPAND|wxALL, 5 ); bMainSizer->Add( m_stdSizerButton, 0, wxEXPAND|wxALL, 5 );
this->SetSizer( bMainSizer ); this->SetSizer( bMainSizer );
this->Layout(); this->Layout();
bMainSizer->Fit( this );
// Connect Events // Connect Events
m_ButtonCopyDoc->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::CopyDocToAlias ), NULL, this ); m_ButtonCopyDoc->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::CopyDocToAlias ), NULL, this );
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011) // C++ code generated with wxFormBuilder (version Apr 11 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
#include "dialog_shim.h"
#include <wx/string.h> #include <wx/string.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
...@@ -47,7 +48,7 @@ ...@@ -47,7 +48,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE /// Class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public wxDialog class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public DIALOG_SHIM
{ {
private: private:
...@@ -106,7 +107,7 @@ class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public wxDialog ...@@ -106,7 +107,7 @@ class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public wxDialog
public: public:
DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id = ID_LIBEDIT_NOTEBOOK, const wxString& title = _("Lib Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 465,384 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id = ID_LIBEDIT_NOTEBOOK, const wxString& title = _("Lib Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE(); ~DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE();
}; };
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008) // C++ code generated with wxFormBuilder (version Apr 11 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#include "dialog_lib_new_component_base.h" #include "dialog_lib_new_component_base.h"
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
DIALOG_LIB_NEW_COMPONENT_BASE::DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) DIALOG_LIB_NEW_COMPONENT_BASE::DIALOG_LIB_NEW_COMPONENT_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 ); this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* mainSizer; wxBoxSizer* mainSizer;
mainSizer = new wxBoxSizer( wxHORIZONTAL ); mainSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizer5; wxBoxSizer* bSizer5;
bSizer5 = new wxBoxSizer( wxVERTICAL ); bSizer5 = new wxBoxSizer( wxVERTICAL );
m_staticText6 = new wxStaticText( this, wxID_ANY, _("General Settings"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText6 = new wxStaticText( this, wxID_ANY, _("General Settings"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText6->Wrap( -1 ); m_staticText6->Wrap( -1 );
m_staticText6->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); m_staticText6->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
bSizer5->Add( m_staticText6, 0, wxALIGN_LEFT, 3 ); bSizer5->Add( m_staticText6, 0, wxALIGN_LEFT, 3 );
wxBoxSizer* bSizer2; wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxHORIZONTAL ); bSizer2 = new wxBoxSizer( wxHORIZONTAL );
bSizer2->Add( 12, 0, 0, wxEXPAND, 3 ); bSizer2->Add( 12, 0, 0, wxEXPAND, 3 );
m_staticText2 = new wxStaticText( this, wxID_ANY, _("Component &name:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText2 = new wxStaticText( this, wxID_ANY, _("Component &name:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText2->Wrap( -1 ); m_staticText2->Wrap( -1 );
m_staticText2->SetToolTip( _("This is the component name in library,\nand also the default component value when loaded in the schematic.") ); m_staticText2->SetToolTip( _("This is the component name in library,\nand also the default component value when loaded in the schematic.") );
bSizer2->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); bSizer2->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
bSizer2->Add( 0, 0, 1, wxEXPAND, 3 ); bSizer2->Add( 0, 0, 1, wxEXPAND, 3 );
m_textName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 100,-1 ), 0 ); m_textName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 100,-1 ), 0 );
bSizer2->Add( m_textName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); bSizer2->Add( m_textName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
bSizer2->Add( 30, 0, 0, wxEXPAND, 3 ); bSizer2->Add( 30, 0, 0, wxEXPAND, 3 );
bSizer5->Add( bSizer2, 0, wxALL|wxEXPAND, 0 );
bSizer5->Add( bSizer2, 0, wxALL|wxEXPAND, 0 );
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxHORIZONTAL );
bSizer3->Add( 12, 0, 0, wxEXPAND, 3 );
bSizer3->Add( 12, 0, 0, wxEXPAND, 3 );
m_staticText3 = new wxStaticText( this, wxID_ANY, _("Default &reference designator:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText3->Wrap( -1 ); m_staticText3 = new wxStaticText( this, wxID_ANY, _("Default &reference designator:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText3->SetToolTip( _("This is the reference used in schematic for annotation.\nDo not use digits in reference.") ); m_staticText3->Wrap( -1 );
m_staticText3->SetToolTip( _("This is the reference used in schematic for annotation.\nDo not use digits in reference.") );
bSizer3->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
bSizer3->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
bSizer3->Add( 0, 0, 1, wxEXPAND, 5 );
bSizer3->Add( 0, 0, 1, wxEXPAND, 5 );
m_textReference = new wxTextCtrl( this, wxID_ANY, _("U"), wxDefaultPosition, wxSize( 100,-1 ), 0 );
bSizer3->Add( m_textReference, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_textReference = new wxTextCtrl( this, wxID_ANY, _("U"), wxDefaultPosition, wxSize( 100,-1 ), 0 );
bSizer3->Add( m_textReference, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
bSizer3->Add( 30, 0, 0, wxEXPAND, 5 );
bSizer3->Add( 30, 0, 0, wxEXPAND, 5 );
bSizer5->Add( bSizer3, 0, wxALL|wxEXPAND, 0 );
wxBoxSizer* bSizer4; bSizer5->Add( bSizer3, 0, wxALL|wxEXPAND, 0 );
bSizer4 = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxHORIZONTAL );
bSizer4->Add( 12, 0, 0, wxEXPAND, 3 );
m_staticText4 = new wxStaticText( this, wxID_ANY, _("Number of &parts per package:"), wxDefaultPosition, wxDefaultSize, 0 ); bSizer4->Add( 12, 0, 0, wxEXPAND, 3 );
m_staticText4->Wrap( -1 );
m_staticText4->SetToolTip( _("This is the number of parts in this component package.\nA 74LS00 gate has 4 parts per packages.") ); m_staticText4 = new wxStaticText( this, wxID_ANY, _("Number of &parts per package:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText4->Wrap( -1 );
bSizer4->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_staticText4->SetToolTip( _("This is the number of parts in this component package.\nA 74LS00 gate has 4 parts per packages.") );
bSizer4->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
bSizer4->Add( 0, 0, 1, wxEXPAND, 3 );
m_spinPartCount = new wxSpinCtrl( this, wxID_ANY, wxT("1"), wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 1, 26, 0 ); bSizer4->Add( 0, 0, 1, wxEXPAND, 3 );
bSizer4->Add( m_spinPartCount, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_spinPartCount = new wxSpinCtrl( this, wxID_ANY, wxT("1"), wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 1, 26, 0 );
bSizer4->Add( m_spinPartCount, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
bSizer4->Add( 30, 0, 0, wxEXPAND, 3 );
bSizer5->Add( bSizer4, 0, wxALL|wxEXPAND, 0 ); bSizer4->Add( 30, 0, 0, wxEXPAND, 3 );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxHORIZONTAL ); bSizer5->Add( bSizer4, 0, wxALL|wxEXPAND, 0 );
wxBoxSizer* bSizer7;
bSizer7->Add( 12, 0, 0, wxEXPAND, 3 ); bSizer7 = new wxBoxSizer( wxHORIZONTAL );
m_checkHasConversion = new wxCheckBox( this, wxID_ANY, _("Create component with &alternate body style (DeMorgan)"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer7->Add( 12, 0, 0, wxEXPAND, 3 );
m_checkHasConversion->SetToolTip( _("Check this option for components that have a De Morgan representation.\nThis is usual for gates.") );
m_checkHasConversion = new wxCheckBox( this, wxID_ANY, _("Create component with &alternate body style (DeMorgan)"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer7->Add( m_checkHasConversion, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_checkHasConversion->SetToolTip( _("Check this option for components that have a De Morgan representation.\nThis is usual for gates.") );
bSizer5->Add( bSizer7, 0, wxALL|wxEXPAND, 0 ); bSizer7->Add( m_checkHasConversion, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
wxBoxSizer* bSizer8;
bSizer8 = new wxBoxSizer( wxHORIZONTAL ); bSizer5->Add( bSizer7, 0, wxALL|wxEXPAND, 0 );
wxBoxSizer* bSizer8;
bSizer8->Add( 12, 0, 0, wxEXPAND, 3 ); bSizer8 = new wxBoxSizer( wxHORIZONTAL );
m_checkIsPowerSymbol = new wxCheckBox( this, wxID_ANY, _("Create component as power &symbol"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer8->Add( 12, 0, 0, wxEXPAND, 3 );
m_checkIsPowerSymbol->SetToolTip( _("Check this option for power symbols.\nPower symbols have specific properties for Eeschema:\n- Value cannot be edited (to avoid mistakes) because this is the pin name that is important for a power symbol\n- Reference is updated automatically when a netlist is created (no need to run Annotate)") );
m_checkIsPowerSymbol = new wxCheckBox( this, wxID_ANY, _("Create component as power &symbol"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer8->Add( m_checkIsPowerSymbol, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_checkIsPowerSymbol->SetToolTip( _("Check this option for power symbols.\nPower symbols have specific properties for Eeschema:\n- Value cannot be edited (to avoid mistakes) because this is the pin name that is important for a power symbol\n- Reference is updated automatically when a netlist is created (no need to run Annotate)") );
bSizer5->Add( bSizer8, 0, wxALL|wxEXPAND, 0 ); bSizer8->Add( m_checkIsPowerSymbol, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
wxBoxSizer* bSizer9;
bSizer9 = new wxBoxSizer( wxHORIZONTAL ); bSizer5->Add( bSizer8, 0, wxALL|wxEXPAND, 0 );
wxBoxSizer* bSizer9;
bSizer9->Add( 12, 0, 0, wxEXPAND, 3 ); bSizer9 = new wxBoxSizer( wxHORIZONTAL );
m_checkLockItems = new wxCheckBox( this, wxID_ANY, _("Parts in package locked (cannot be swapped)"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer9->Add( 12, 0, 0, wxEXPAND, 3 );
m_checkLockItems->SetToolTip( _("Check this option if Eeschema cannot change parts selections inside a given package\nThis happens when parts are different in this package.\nWhen this option is not checked, Eeschema automatically choose the parts in packages to minimize packages count") );
m_checkLockItems = new wxCheckBox( this, wxID_ANY, _("Parts in package locked (cannot be swapped)"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer9->Add( m_checkLockItems, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_checkLockItems->SetToolTip( _("Check this option if Eeschema cannot change parts selections inside a given package\nThis happens when parts are different in this package.\nWhen this option is not checked, Eeschema automatically choose the parts in packages to minimize packages count") );
bSizer5->Add( bSizer9, 0, wxALL|wxEXPAND, 0 ); bSizer9->Add( m_checkLockItems, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
bSizer5->Add( 0, 0, 0, wxALL|wxEXPAND, 10 ); bSizer5->Add( bSizer9, 0, wxALL|wxEXPAND, 0 );
m_staticText7 = new wxStaticText( this, wxID_ANY, _("Global Pin Settings"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText7->Wrap( -1 ); bSizer5->Add( 0, 0, 0, wxALL|wxEXPAND, 10 );
m_staticText7->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
m_staticText7 = new wxStaticText( this, wxID_ANY, _("Global Pin Settings"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer5->Add( m_staticText7, 0, wxALIGN_LEFT|wxBOTTOM, 3 ); m_staticText7->Wrap( -1 );
m_staticText7->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxHORIZONTAL ); bSizer5->Add( m_staticText7, 0, wxALIGN_LEFT|wxBOTTOM, 3 );
wxBoxSizer* bSizer6;
bSizer6->Add( 12, 0, 0, wxEXPAND, 3 ); bSizer6 = new wxBoxSizer( wxHORIZONTAL );
m_staticText41 = new wxStaticText( this, wxID_ANY, _("Pin text position &offset:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText41->Wrap( -1 ); bSizer6->Add( 12, 0, 0, wxEXPAND, 3 );
m_staticText41->SetToolTip( _("Margin (in 0.001 inches) between a pin name position and the component body.\nA value from 10 to 40 is usually good.") );
m_staticText41 = new wxStaticText( this, wxID_ANY, _("Pin text position &offset:"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( m_staticText41, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_staticText41->Wrap( -1 );
m_staticText41->SetToolTip( _("Margin (in 0.001 inches) between a pin name position and the component body.\nA value from 10 to 40 is usually good.") );
bSizer6->Add( 0, 0, 1, wxEXPAND, 3 ); bSizer6->Add( m_staticText41, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_spinPinTextPosition = new wxSpinCtrl( this, wxID_ANY, wxT("40"), wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 1, 100, 40 );
bSizer6->Add( m_spinPinTextPosition, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); bSizer6->Add( 0, 0, 1, wxEXPAND, 3 );
m_staticText5 = new wxStaticText( this, wxID_ANY, _("mils"), wxDefaultPosition, wxSize( 30,-1 ), 0 ); m_spinPinTextPosition = new wxSpinCtrl( this, wxID_ANY, wxT("40"), wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 1, 100, 40 );
m_staticText5->Wrap( -1 ); bSizer6->Add( m_spinPinTextPosition, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
bSizer6->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL, 3 );
m_staticText5 = new wxStaticText( this, wxID_ANY, _("mils"), wxDefaultPosition, wxSize( 30,-1 ), 0 );
bSizer5->Add( bSizer6, 1, wxALL|wxEXPAND, 0 ); m_staticText5->Wrap( -1 );
bSizer6->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL, 3 );
wxBoxSizer* bSizer10;
bSizer10 = new wxBoxSizer( wxHORIZONTAL );
bSizer5->Add( bSizer6, 1, wxALL|wxEXPAND, 0 );
bSizer10->Add( 12, 0, 0, wxEXPAND, 3 ); wxBoxSizer* bSizer10;
bSizer10 = new wxBoxSizer( wxHORIZONTAL );
m_checkShowPinNumber = new wxCheckBox( this, wxID_ANY, _("Show pin n&umber text"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkShowPinNumber->SetValue(true);
bSizer10->Add( 12, 0, 0, wxEXPAND, 3 );
bSizer10->Add( m_checkShowPinNumber, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_checkShowPinNumber = new wxCheckBox( this, wxID_ANY, _("Show pin n&umber text"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer5->Add( bSizer10, 0, wxALL|wxEXPAND, 0 ); m_checkShowPinNumber->SetValue(true);
bSizer10->Add( m_checkShowPinNumber, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
wxBoxSizer* bSizer12;
bSizer12 = new wxBoxSizer( wxHORIZONTAL );
bSizer5->Add( bSizer10, 0, wxALL|wxEXPAND, 0 );
bSizer12->Add( 12, 0, 0, wxEXPAND, 3 ); wxBoxSizer* bSizer12;
bSizer12 = new wxBoxSizer( wxHORIZONTAL );
m_checkShowPinName = new wxCheckBox( this, wxID_ANY, _("Show pin name te&xt"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkShowPinName->SetValue(true);
bSizer12->Add( 12, 0, 0, wxEXPAND, 3 );
bSizer12->Add( m_checkShowPinName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_checkShowPinName = new wxCheckBox( this, wxID_ANY, _("Show pin name te&xt"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer5->Add( bSizer12, 0, wxALL|wxEXPAND, 0 ); m_checkShowPinName->SetValue(true);
bSizer12->Add( m_checkShowPinName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
wxBoxSizer* bSizer121;
bSizer121 = new wxBoxSizer( wxHORIZONTAL );
bSizer5->Add( bSizer12, 0, wxALL|wxEXPAND, 0 );
bSizer121->Add( 12, 0, 0, wxEXPAND, 3 ); wxBoxSizer* bSizer121;
bSizer121 = new wxBoxSizer( wxHORIZONTAL );
m_checkShowPinNameInside = new wxCheckBox( this, wxID_ANY, _("Pin name &inside"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkShowPinNameInside->SetValue(true);
bSizer121->Add( 12, 0, 0, wxEXPAND, 3 );
bSizer121->Add( m_checkShowPinNameInside, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_checkShowPinNameInside = new wxCheckBox( this, wxID_ANY, _("Pin name &inside"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer5->Add( bSizer121, 1, wxEXPAND, 5 ); m_checkShowPinNameInside->SetValue(true);
bSizer121->Add( m_checkShowPinNameInside, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
bSizer5->Add( 0, 5, 0, wxALL|wxEXPAND, 10 );
bSizer5->Add( bSizer121, 1, wxEXPAND, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK ); bSizer5->Add( 0, 5, 0, wxALL|wxEXPAND, 10 );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel ); m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizer->Realize(); m_sdbSizerOK = new wxButton( this, wxID_OK );
bSizer5->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 0 ); m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
mainSizer->Add( bSizer5, 1, wxALL|wxEXPAND, 12 ); m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
this->SetSizer( mainSizer );
this->Layout(); bSizer5->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 0 );
mainSizer->Fit( this );
this->Centre( wxBOTH ); mainSizer->Add( bSizer5, 1, wxALL|wxEXPAND, 12 );
}
DIALOG_LIB_NEW_COMPONENT_BASE::~DIALOG_LIB_NEW_COMPONENT_BASE() this->SetSizer( mainSizer );
{ this->Layout();
} mainSizer->Fit( this );
this->Centre( wxBOTH );
}
DIALOG_LIB_NEW_COMPONENT_BASE::~DIALOG_LIB_NEW_COMPONENT_BASE()
{
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008) // C++ code generated with wxFormBuilder (version Apr 11 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_lib_new_component_base__ #ifndef __DIALOG_LIB_NEW_COMPONENT_BASE_H__
#define __dialog_lib_new_component_base__ #define __DIALOG_LIB_NEW_COMPONENT_BASE_H__
#include <wx/intl.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/string.h> #include <wx/intl.h>
#include <wx/stattext.h> #include "dialog_shim.h"
#include <wx/gdicmn.h> #include <wx/string.h>
#include <wx/font.h> #include <wx/stattext.h>
#include <wx/colour.h> #include <wx/gdicmn.h>
#include <wx/settings.h> #include <wx/font.h>
#include <wx/textctrl.h> #include <wx/colour.h>
#include <wx/sizer.h> #include <wx/settings.h>
#include <wx/spinctrl.h> #include <wx/textctrl.h>
#include <wx/checkbox.h> #include <wx/sizer.h>
#include <wx/button.h> #include <wx/spinctrl.h>
#include <wx/dialog.h> #include <wx/checkbox.h>
#include <wx/button.h>
/////////////////////////////////////////////////////////////////////////// #include <wx/dialog.h>
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/// Class DIALOG_LIB_NEW_COMPONENT_BASE
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class DIALOG_LIB_NEW_COMPONENT_BASE : public wxDialog /// Class DIALOG_LIB_NEW_COMPONENT_BASE
{ ///////////////////////////////////////////////////////////////////////////////
private: class DIALOG_LIB_NEW_COMPONENT_BASE : public DIALOG_SHIM
{
protected: private:
wxStaticText* m_staticText6;
protected:
wxStaticText* m_staticText2; wxStaticText* m_staticText6;
wxStaticText* m_staticText2;
wxTextCtrl* m_textName; wxTextCtrl* m_textName;
wxStaticText* m_staticText3;
wxTextCtrl* m_textReference;
wxStaticText* m_staticText3; wxStaticText* m_staticText4;
wxSpinCtrl* m_spinPartCount;
wxTextCtrl* m_textReference; wxCheckBox* m_checkHasConversion;
wxCheckBox* m_checkIsPowerSymbol;
wxCheckBox* m_checkLockItems;
wxStaticText* m_staticText4; wxStaticText* m_staticText7;
wxStaticText* m_staticText41;
wxSpinCtrl* m_spinPartCount; wxSpinCtrl* m_spinPinTextPosition;
wxStaticText* m_staticText5;
wxCheckBox* m_checkShowPinNumber;
wxCheckBox* m_checkHasConversion; wxCheckBox* m_checkShowPinName;
wxCheckBox* m_checkShowPinNameInside;
wxCheckBox* m_checkIsPowerSymbol; wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxCheckBox* m_checkLockItems; wxButton* m_sdbSizerCancel;
wxStaticText* m_staticText7; public:
wxStaticText* m_staticText41; DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_LIB_NEW_COMPONENT_BASE();
wxSpinCtrl* m_spinPinTextPosition;
wxStaticText* m_staticText5; };
wxCheckBox* m_checkShowPinNumber; #endif //__DIALOG_LIB_NEW_COMPONENT_BASE_H__
wxCheckBox* m_checkShowPinName;
wxCheckBox* m_checkShowPinNameInside;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
public:
DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_LIB_NEW_COMPONENT_BASE();
};
#endif //__dialog_lib_new_component_base__
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#include <dialogs/dialog_edit_component_in_lib.h> #include <dialogs/dialog_edit_component_in_lib.h>
#include <dialogs/dialog_libedit_dimensions.h> #include <dialogs/dialog_libedit_dimensions.h>
#include <dialog_helpers.h> //#include <dialog_helpers.h>
#include <menus_helpers.h> #include <menus_helpers.h>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
...@@ -296,13 +296,6 @@ public: ...@@ -296,13 +296,6 @@ public:
*/ */
bool SetZoom( double coeff ); bool SetZoom( double coeff );
/**
* Function SetZoomList
* sets the list of zoom factors.
* @param aZoomList An array of zoom factors in ascending order, zero terminated
*/
void SetZoomList( const wxArrayDouble& aZoomList );
bool SetNextZoom(); bool SetNextZoom();
bool SetPreviousZoom(); bool SetPreviousZoom();
bool SetFirstZoom(); bool SetFirstZoom();
......
...@@ -182,72 +182,4 @@ public: ...@@ -182,72 +182,4 @@ public:
} }
}; };
/**
* Template DIALOG_SHIM
* is a way to have a common way of handling KiCad dialog windows:
* <ul>
* <li>class specific: static s_LastPos and static s_LastSize for retentative
* dialog window positioning, per class.
* <li> invocation of SetFocus() to allow ESC key to work on Linux.
* <li> future others...
* </ul>
* by wedging in a class (a SHIM) between the wxFormbuilder coded base class and
* our derived dialog classes. Use it via the macro named DIALOG_EXTEND_WITH_SHIM
* and be sure to code your constructor to invoke *_SHIM() base class constructor,
* not the one from wxFormbuilder.
* @author Dick Hollenbeck
*/
template <class T>
class DIALOG_SHIM : public T
{
public:
DIALOG_SHIM( wxFrame* aParent ) :
T( aParent )
{
wxDialog::SetFocus();
}
// overload wxDialog::Show
bool Show( bool show )
{
bool ret;
if( show )
{
ret = wxDialog::Show( show );
if( s_LastPos.x != -1 )
wxDialog::SetSize( s_LastPos.x, s_LastPos.y, s_LastSize.x, s_LastSize.y, 0 );
}
else
{
// Save the dialog's position before hiding
s_LastPos = wxDialog::GetPosition();
s_LastSize = wxDialog::GetSize();
ret = wxDialog::Show( show );
}
return ret;
}
private:
static wxPoint s_LastPos;
static wxSize s_LastSize;
};
template<class T>
wxPoint DIALOG_SHIM<T>::s_LastPos( -1, -1 );
template<class T>
wxSize DIALOG_SHIM<T>::s_LastSize( 0, 0 );
/**
* Macro DIALOG_EXTEND_WITH_SHIM
* instantiates the template DIALOG_SHIM<> and thereby declares a shim class.
* @author Dick Hollenbeck
*/
#define DIALOG_EXTEND_WITH_SHIM( DERRIVED, BASE ) \
typedef DIALOG_SHIM<BASE> BASE##_SHIM; \
class DERRIVED : public BASE##_SHIM
#endif // DIALOG_HELPERS_H_ #endif // DIALOG_HELPERS_H_
...@@ -32,6 +32,7 @@ public: ...@@ -32,6 +32,7 @@ public:
} }
}; };
class FOOTPRINT_LIST class FOOTPRINT_LIST
{ {
public: public:
......
...@@ -3,13 +3,8 @@ ...@@ -3,13 +3,8 @@
* @brief Classes and definitions used in Pcbnew. * @brief Classes and definitions used in Pcbnew.
*/ */
#ifndef PCBSTRUCT_H #ifndef PCBSTRUCT_H_
#define PCBSTRUCT_H #define PCBSTRUCT_H_
// Definitions relatives aux libraries
#define FOOTPRINT_LIBRARY_HEADER "PCBNEW-LibModule-V1"
#define FOOTPRINT_LIBRARY_HEADER_CNT 18
/// Values for m_DisplayViaMode member: /// Values for m_DisplayViaMode member:
...@@ -83,4 +78,4 @@ public: ...@@ -83,4 +78,4 @@ public:
DISPLAY_OPTIONS(); DISPLAY_OPTIONS();
}; };
#endif // PCBSTRUCT_H #endif // PCBSTRUCT_H_
...@@ -96,7 +96,7 @@ set(PCBNEW_SRCS ...@@ -96,7 +96,7 @@ set(PCBNEW_SRCS
block.cpp block.cpp
block_module_editor.cpp block_module_editor.cpp
build_BOM_from_board.cpp build_BOM_from_board.cpp
class_footprint_library.cpp # class_footprint_library.cpp
class_pcb_layer_widget.cpp class_pcb_layer_widget.cpp
clean.cpp clean.cpp
connect.cpp connect.cpp
......
...@@ -11,15 +11,16 @@ class FOOTPRINT_LIBRARY ...@@ -11,15 +11,16 @@ class FOOTPRINT_LIBRARY
public: public:
wxArrayString m_List; // list of footprints, used to read/write INDEX section wxArrayString m_List; // list of footprints, used to read/write INDEX section
wxString m_LibraryName; // the full library name wxString m_LibraryName; // the full library name
int m_LineNum; // the line count
private: private:
FILTER_READER * m_reader; // FILTER_READER to read file. If NULL, use m_file FILTER_READER * m_reader; // FILTER_READER to read file. If NULL, use m_file
FILE * m_file; // footprint file to read/write. FILE * m_file; // footprint file to read/write.
int m_LineNum; // the line count
public: public:
/** /**
* ctor * Constructor FOOTPRINT_LIBRARY
* @param aFile = a FILE * pointer used for write operations, * @param aFile = a FILE * pointer used for write operations,
* and read operations when aReader = NULL * and read operations when aReader = NULL
* @param aReader = a FILTER_READER pointer used for read operations * @param aReader = a FILTER_READER pointer used for read operations
...@@ -27,7 +28,11 @@ public: ...@@ -27,7 +28,11 @@ public:
*/ */
FOOTPRINT_LIBRARY( FILE * aFile, FILTER_READER * aReader = NULL ); FOOTPRINT_LIBRARY( FILE * aFile, FILTER_READER * aReader = NULL );
~FOOTPRINT_LIBRARY() { } FOOTPRINT_LIBRARY() :
m_reader( 0 ),
m_file( 0 ),
m_LineNum( 0 )
{}
/** /**
* function IsLibrary * function IsLibrary
......
...@@ -332,6 +332,12 @@ public: ...@@ -332,6 +332,12 @@ public:
*/ */
D_PAD* GetPad( const wxPoint& aPosition, int aLayerMask = ALL_LAYERS ); D_PAD* GetPad( const wxPoint& aPosition, int aLayerMask = ALL_LAYERS );
/**
* GetPadCount
* returns the number of pads.
*/
unsigned GetPadCount() const { return m_Pads.GetCount() ; }
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData, SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ); const KICAD_T scanTypes[] );
......
...@@ -18,23 +18,40 @@ ...@@ -18,23 +18,40 @@
#include <pcbnew_id.h> #include <pcbnew_id.h>
/* Default Pcbnew zoom values. /**
* Limited to 19 values to keep a decent size to menus Default Pcbnew zoom values.
* 15 it better but does not allow a sufficient number of values Limited to 19 values to keep a decent size to menus.
* roughtly a 1.5 progression. Roughly a 1.5 progression.
* The last 2 values is handy when somebody uses a library import of a module The last 2 values are handy when somebody uses a library import of a module
* (or foreign data) which has a bad coordinate (or foreign data) which has a bad coordinate.
* Also useful in GerbView for this reason. Also useful in GerbView for this reason.
* Zoom 5 and 10 can create artefacts when drawing (integer overflow in low level graphic Zoom 5 and 10 can create artefacts when drawing (integer overflow in low level graphic
* functions ) functions )
*/ */
static const double pcbZoomList[] = static const double pcbZoomList[] =
{ {
0.5, 1.0, 1.5, 2.0, 3.0, 4.5, 7.0, 0.5,
10.0, 15.0, 22.0, 35.0, 50.0, 80.0, 120.0, 1.0,
200.0, 350.0, 500.0, 1000.0, 2000.0 1.5,
2.0,
3.0,
4.5,
7.0,
10.0,
15.0,
22.0,
35.0,
50.0,
80.0,
120.0,
200.0,
350.0,
500.0,
1000.0,
2000.0
}; };
#define MM_TO_PCB_UNITS (10000.0 / 25.4) #define MM_TO_PCB_UNITS (10000.0 / 25.4)
...@@ -63,9 +80,9 @@ static GRID_TYPE pcbGridList[] = ...@@ -63,9 +80,9 @@ static GRID_TYPE pcbGridList[] =
{ ID_POPUP_GRID_LEVEL_0_25MM, wxRealPoint( MM_TO_PCB_UNITS * 0.25, MM_TO_PCB_UNITS * 0.25 ) }, { ID_POPUP_GRID_LEVEL_0_25MM, wxRealPoint( MM_TO_PCB_UNITS * 0.25, MM_TO_PCB_UNITS * 0.25 ) },
{ ID_POPUP_GRID_LEVEL_0_2MM, wxRealPoint( MM_TO_PCB_UNITS * 0.2, MM_TO_PCB_UNITS * 0.2 ) }, { ID_POPUP_GRID_LEVEL_0_2MM, wxRealPoint( MM_TO_PCB_UNITS * 0.2, MM_TO_PCB_UNITS * 0.2 ) },
{ ID_POPUP_GRID_LEVEL_0_1MM, wxRealPoint( MM_TO_PCB_UNITS * 0.1, MM_TO_PCB_UNITS * 0.1 ) }, { ID_POPUP_GRID_LEVEL_0_1MM, wxRealPoint( MM_TO_PCB_UNITS * 0.1, MM_TO_PCB_UNITS * 0.1 ) },
{ ID_POPUP_GRID_LEVEL_0_0_5MM, wxRealPoint( MM_TO_PCB_UNITS * 0.05, MM_TO_PCB_UNITS * 0.05 ) }, { ID_POPUP_GRID_LEVEL_0_0_5MM, wxRealPoint( MM_TO_PCB_UNITS * 0.05, MM_TO_PCB_UNITS * 0.05 ) },
{ ID_POPUP_GRID_LEVEL_0_0_25MM, wxRealPoint( MM_TO_PCB_UNITS * 0.025, MM_TO_PCB_UNITS * 0.025 ) }, { ID_POPUP_GRID_LEVEL_0_0_25MM, wxRealPoint( MM_TO_PCB_UNITS * 0.025, MM_TO_PCB_UNITS * 0.025 ) },
{ ID_POPUP_GRID_LEVEL_0_0_1MM, wxRealPoint( MM_TO_PCB_UNITS * 0.01, MM_TO_PCB_UNITS * 0.01 ) } { ID_POPUP_GRID_LEVEL_0_0_1MM, wxRealPoint( MM_TO_PCB_UNITS * 0.01, MM_TO_PCB_UNITS * 0.01 ) }
}; };
......
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
#include <kicad_plugin.h> #include <kicad_plugin.h>
#define FMT_UNIMPLEMENTED _( "Plugin '%s' does not implement the '%s' function." )
#define FMT_NOTFOUND _( "Plugin type '%s' is not found." )
// Some day plugins might be in separate DLL/DSOs, simply because of numbers of them // Some day plugins might be in separate DLL/DSOs, simply because of numbers of them
// and code size. Until then, use the simplest method: // and code size. Until then, use the simplest method:
...@@ -40,8 +44,8 @@ ...@@ -40,8 +44,8 @@
// plugins coexisting. // plugins coexisting.
// static LEGACY_PLUGIN kicad_plugin; // a secret // static LEGACY_PLUGIN kicad_plugin;
//static EAGLE_PLUGIN eagle_plugin; // static EAGLE_PLUGIN eagle_plugin;
PLUGIN* IO_MGR::PluginFind( PCB_FILE_T aFileType ) PLUGIN* IO_MGR::PluginFind( PCB_FILE_T aFileType )
{ {
...@@ -118,7 +122,7 @@ BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName, ...@@ -118,7 +122,7 @@ BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName,
return pi->Load( aFileName, aAppendToMe, aProperties ); // virtual return pi->Load( aFileName, aAppendToMe, aProperties ); // virtual
} }
THROW_IO_ERROR( wxString::Format( _( "Plugin type '%s' is not found." ), ShowType( aFileType ).GetData() ) ); THROW_IO_ERROR( wxString::Format( FMT_NOTFOUND, ShowType( aFileType ).GetData() ) );
} }
...@@ -133,25 +137,56 @@ void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoar ...@@ -133,25 +137,56 @@ void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoar
return; return;
} }
THROW_IO_ERROR( wxString::Format( _( "Plugin type '%s' is not found." ), ShowType( aFileType ).GetData() ) ); THROW_IO_ERROR( wxString::Format( FMT_NOTFOUND, ShowType( aFileType ).GetData() ) );
} }
BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties ) BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties )
{ {
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface, // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
// e.g. Load() or Save() but not both. THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData(), __FUNCTION__ ) );
THROW_IO_ERROR( wxString::Format(
_( "Plugin %s does not implement the BOARD Load() function." ), PluginName().GetData() ) );
} }
void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties ) void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties )
{ {
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface, // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
// e.g. Load() or Save() but not both. THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData(), __FUNCTION__ ) );
}
wxArrayString PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
THROW_IO_ERROR( wxString::Format( MODULE* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
_( "Plugin %s does not implement the BOARD Save() function." ), PluginName().GetData() ) ); PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
} }
void PLUGIN::FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint, PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
bool PLUGIN::IsLibraryWritable( const wxString& aLibraryPath )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
class BOARD; class BOARD;
class PLUGIN; class PLUGIN;
class MODULE;
/** /**
...@@ -237,13 +238,102 @@ public: ...@@ -237,13 +238,102 @@ public:
virtual void Save( const wxString& aFileName, BOARD* aBoard, virtual void Save( const wxString& aFileName, BOARD* aBoard,
PROPERTIES* aProperties = NULL ); PROPERTIES* aProperties = NULL );
/**
* Function FootprintEnumerate
* returns a list of footprint names contained within the library at @a aLibraryPath.
*
* @param aLibraryPath is locator for the "library", usually a directory
* or file containing several footprints.
*
* @param aProperties is an associative array that can be used to tell the
* plugin how to access the library.
* The caller continues to own this object (plugin may not delete it), and
* plugins should expect it to be optionally NULL.
*
* @return wxArrayString - is the array of available footprint names inside
* a library
*
* @throw IO_ERROR if the library cannot be found, or footprint cannot be loaded.
*/
virtual wxArrayString FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL);
/**
* Function FootprintLoad
* loads a MODULE having @a aFootprintName from the @a aLibraryPath containing
* a library format that this PLUGIN knows about.
*
* @param aLibraryPath is locator for the "library", usually a directory
* or file containing several footprints.
*
* @param aFootprintName is the name of the footprint to load.
*
* @param aProperties is an associative array that can be used to tell the
* saver how to save the file, because it can take any number of
* additional named tuning arguments that the plugin is known to support.
* The caller continues to own this object (plugin may not delete it), and
* plugins should expect it to be optionally NULL.
*
* @return MODULE* - caller owns it. Never NULL because exception thrown if error.
*
* @throw IO_ERROR if the PLUGIN cannot be found, library cannot be found,
* or footprint cannot be loaded.
*/
virtual MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
PROPERTIES* aProperties = NULL );
/**
* Function FootprintSave
* will write @a aModule to an existing library located at @a aLibraryPath,
* and create the library if it doesn't exist then perform the write. If a
* footprint by the same name already exists, it is replaced.
*
* @param aLibraryPath is locator for the "library", usually a directory
* or file containing several footprints. This is where the footprint is
* to be stored.
*
* @param aFootprint is what to store in the library.
* The caller continues to own the footprint.
*
* @param aProperties is an associative array that can be used to tell the
* saver how to save the file, because it can take any number of
* additional named tuning arguments that the plugin is known to support.
* The caller continues to own this object (plugin may not delete it), and
* plugins should expect it to be optionally NULL.
*
* @throw IO_ERROR if there is a problem saving.
*/
virtual void FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint,
PROPERTIES* aProperties = NULL );
/**
* Function FootprintDelete
* deletes the @a aFootprintName from the library at @a aLibraryPath.
*
* @param aLibraryPath is locator for the "library", usually a directory
* or file containing several footprints.
*
* @param aFootprintName is the name of a footprint to delete from the specificed library.
*
* @throw IO_ERROR if there is a problem finding the footprint or the library, or deleting it.
*/
virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName );
/**
* Function IsLibraryWritable
* returns true iff the library at @a aLibraryPath is writable. (Often
* system libraries are read only because of where they are installed.)
*/
virtual bool IsLibraryWritable( const wxString& aLibraryPath );
//-----</PUBLIC PLUGIN API>------------------------------------------------ //-----</PUBLIC PLUGIN API>------------------------------------------------
/* The compiler writes the "zero argument" constructor for a PLUGIN /* The compiler writes the "zero argument" constructor for a PLUGIN
automatically if you do not provide one. If you decide you need to automatically if you do not provide one. If you decide you need to
provide a zero argument constructor of your own design, that is allowed. provide a zero argument constructor of your own design, that is allowed.
It must be public, and it is what the IO_MGR uses. Parameters may be It must be public, and it is what the IO_MGR uses. Parameters may be
passed into a PLUGIN via the PROPERTIES variable for either Save() and Load(). passed into a PLUGIN via the PROPERTIES variable for any of the public
API functions which take one.
*/ */
virtual ~PLUGIN() {} virtual ~PLUGIN() {}
......
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
#if 1 #if 1
#define READLINE() m_reader->ReadLine() #define READLINE( rdr ) rdr->ReadLine()
#else #else
/// The function and macro which follow comprise a shim which can be a /// The function and macro which follow comprise a shim which can be a
...@@ -128,7 +128,7 @@ static inline unsigned ReadLine( LINE_READER* rdr, const char* caller ) ...@@ -128,7 +128,7 @@ static inline unsigned ReadLine( LINE_READER* rdr, const char* caller )
return ret; return ret;
} }
#define READLINE() ReadLine( m_reader, __FUNCTION__ ) #define READLINE( rdr ) ReadLine( rdr, __FUNCTION__ )
#endif #endif
static const char delims[] = " \t\r\n"; static const char delims[] = " \t\r\n";
...@@ -167,12 +167,14 @@ BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE ...@@ -167,12 +167,14 @@ BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE
{ {
LOCALE_IO toggle; // toggles on, then off, the C locale. LOCALE_IO toggle; // toggles on, then off, the C locale.
init( aProperties );
m_board = aAppendToMe ? aAppendToMe : new BOARD(); m_board = aAppendToMe ? aAppendToMe : new BOARD();
// delete on exception, iff I own m_board, according to aAppendToMe // delete on exception, iff I own m_board, according to aAppendToMe
auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board ); auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board );
FILE* fp = wxFopen( aFileName, wxT( "rt" ) ); FILE* fp = wxFopen( aFileName, wxT( "r" ) );
if( !fp ) if( !fp )
{ {
m_error.Printf( _( "Unable to open file '%s'" ), aFileName.GetData() ); m_error.Printf( _( "Unable to open file '%s'" ), aFileName.GetData() );
...@@ -184,8 +186,6 @@ BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE ...@@ -184,8 +186,6 @@ BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE
m_reader = &reader; // member function accessibility m_reader = &reader; // member function accessibility
init( aProperties );
checkVersion(); checkVersion();
loadAllSections( bool( aAppendToMe ) ); loadAllSections( bool( aAppendToMe ) );
...@@ -205,7 +205,7 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend ) ...@@ -205,7 +205,7 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend )
// Then follows $EQUIPOT and all the rest // Then follows $EQUIPOT and all the rest
while( READLINE() ) while( READLINE( m_reader ) )
{ {
char* line = m_reader->Line(); char* line = m_reader->Line();
...@@ -213,7 +213,8 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend ) ...@@ -213,7 +213,8 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend )
if( TESTLINE( "$MODULE" ) ) if( TESTLINE( "$MODULE" ) )
{ {
loadMODULE(); MODULE* m = LoadMODULE();
m_board->Add( m, ADD_APPEND );
} }
else if( TESTLINE( "$DRAWSEGMENT" ) ) else if( TESTLINE( "$DRAWSEGMENT" ) )
...@@ -281,7 +282,7 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend ) ...@@ -281,7 +282,7 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend )
} }
else else
{ {
while( READLINE() ) while( READLINE( m_reader ) )
{ {
line = m_reader->Line(); // gobble until $EndSetup line = m_reader->Line(); // gobble until $EndSetup
...@@ -332,7 +333,7 @@ void LEGACY_PLUGIN::checkVersion() ...@@ -332,7 +333,7 @@ void LEGACY_PLUGIN::checkVersion()
void LEGACY_PLUGIN::loadGENERAL() void LEGACY_PLUGIN::loadGENERAL()
{ {
while( READLINE() ) while( READLINE( m_reader ) )
{ {
char* line = m_reader->Line(); char* line = m_reader->Line();
const char* data; const char* data;
...@@ -460,7 +461,7 @@ void LEGACY_PLUGIN::loadSHEET() ...@@ -460,7 +461,7 @@ void LEGACY_PLUGIN::loadSHEET()
char buf[260]; char buf[260];
TITLE_BLOCK tb; TITLE_BLOCK tb;
while( READLINE() ) while( READLINE( m_reader ) )
{ {
char* line = m_reader->Line(); char* line = m_reader->Line();
...@@ -575,7 +576,7 @@ void LEGACY_PLUGIN::loadSETUP() ...@@ -575,7 +576,7 @@ void LEGACY_PLUGIN::loadSETUP()
BOARD_DESIGN_SETTINGS bds = m_board->GetDesignSettings(); BOARD_DESIGN_SETTINGS bds = m_board->GetDesignSettings();
ZONE_SETTINGS zs = m_board->GetZoneSettings(); ZONE_SETTINGS zs = m_board->GetZoneSettings();
while( READLINE() ) while( READLINE( m_reader ) )
{ {
const char* data; const char* data;
char* line = m_reader->Line(); char* line = m_reader->Line();
...@@ -863,15 +864,16 @@ void LEGACY_PLUGIN::loadSETUP() ...@@ -863,15 +864,16 @@ void LEGACY_PLUGIN::loadSETUP()
} }
void LEGACY_PLUGIN::loadMODULE() MODULE* LEGACY_PLUGIN::LoadMODULE()
{ {
auto_ptr<MODULE> module( new MODULE( m_board ) ); auto_ptr<MODULE> module( new MODULE( m_board ) );
while( READLINE() ) while( READLINE( m_reader ) )
{ {
const char* data;
char* line = m_reader->Line(); char* line = m_reader->Line();
const char* data;
// most frequently encountered ones at the top // most frequently encountered ones at the top
if( TESTSUBSTR( "D" ) ) // read a drawing item, e.g. "DS" if( TESTSUBSTR( "D" ) ) // read a drawing item, e.g. "DS"
...@@ -1053,9 +1055,7 @@ void LEGACY_PLUGIN::loadMODULE() ...@@ -1053,9 +1055,7 @@ void LEGACY_PLUGIN::loadMODULE()
{ {
module->CalculateBoundingBox(); module->CalculateBoundingBox();
m_board->Add( module.release(), ADD_APPEND ); return module.release(); // preferred exit
return; // preferred exit
} }
} }
...@@ -1067,7 +1067,7 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) ...@@ -1067,7 +1067,7 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule )
{ {
auto_ptr<D_PAD> pad( new D_PAD( aModule ) ); auto_ptr<D_PAD> pad( new D_PAD( aModule ) );
while( READLINE() ) while( READLINE( m_reader ) )
{ {
const char* data; const char* data;
char* line = m_reader->Line(); char* line = m_reader->Line();
...@@ -1288,8 +1288,8 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) ...@@ -1288,8 +1288,8 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule )
void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule ) void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
{ {
STROKE_T shape; STROKE_T shape;
char* line = m_reader->Line(); // obtain current (old) line char* line = m_reader->Line(); // obtain current (old) line
switch( line[1] ) switch( line[1] )
{ {
...@@ -1371,7 +1371,7 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule ) ...@@ -1371,7 +1371,7 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
for( int ii = 0; ii<ptCount; ++ii ) for( int ii = 0; ii<ptCount; ++ii )
{ {
if( !READLINE() ) if( !READLINE( m_reader ) )
{ {
THROW_IO_ERROR( "S_POLGON point count mismatch." ); THROW_IO_ERROR( "S_POLGON point count mismatch." );
} }
...@@ -1542,7 +1542,7 @@ void LEGACY_PLUGIN::load3D( MODULE* aModule ) ...@@ -1542,7 +1542,7 @@ void LEGACY_PLUGIN::load3D( MODULE* aModule )
t3D = n3D; t3D = n3D;
} }
while( READLINE() ) while( READLINE( m_reader ) )
{ {
char* line = m_reader->Line(); char* line = m_reader->Line();
...@@ -1596,7 +1596,7 @@ void LEGACY_PLUGIN::loadPCB_LINE() ...@@ -1596,7 +1596,7 @@ void LEGACY_PLUGIN::loadPCB_LINE()
auto_ptr<DRAWSEGMENT> dseg( new DRAWSEGMENT( m_board ) ); auto_ptr<DRAWSEGMENT> dseg( new DRAWSEGMENT( m_board ) );
while( READLINE() ) while( READLINE( m_reader ) )
{ {
const char* data; const char* data;
char* line = m_reader->Line(); char* line = m_reader->Line();
...@@ -1704,7 +1704,7 @@ void LEGACY_PLUGIN::loadNETINFO_ITEM() ...@@ -1704,7 +1704,7 @@ void LEGACY_PLUGIN::loadNETINFO_ITEM()
NETINFO_ITEM* net = new NETINFO_ITEM( m_board ); NETINFO_ITEM* net = new NETINFO_ITEM( m_board );
m_board->AppendNet( net ); m_board->AppendNet( net );
while( READLINE() ) while( READLINE( m_reader ) )
{ {
const char* data; const char* data;
char* line = m_reader->Line(); char* line = m_reader->Line();
...@@ -1756,7 +1756,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT() ...@@ -1756,7 +1756,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT()
TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_board ); TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_board );
m_board->Add( pcbtxt, ADD_APPEND ); m_board->Add( pcbtxt, ADD_APPEND );
while( READLINE() ) while( READLINE( m_reader ) )
{ {
const char* data; const char* data;
char* line = m_reader->Line(); char* line = m_reader->Line();
...@@ -1866,7 +1866,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT() ...@@ -1866,7 +1866,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT()
void LEGACY_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType ) void LEGACY_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType )
{ {
while( READLINE() ) while( READLINE( m_reader ) )
{ {
// read two lines per loop iteration, each loop is one TRACK or VIA // read two lines per loop iteration, each loop is one TRACK or VIA
// example first line: // example first line:
...@@ -1899,7 +1899,7 @@ void LEGACY_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType ) ...@@ -1899,7 +1899,7 @@ void LEGACY_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType )
// differentiates between PCB_TRACE_T and PCB_VIA_T. With virtual // differentiates between PCB_TRACE_T and PCB_VIA_T. With virtual
// functions in use, it is critical to instantiate the PCB_VIA_T // functions in use, it is critical to instantiate the PCB_VIA_T
// exactly. // exactly.
READLINE(); READLINE( m_reader );
line = m_reader->Line(); line = m_reader->Line();
...@@ -1989,7 +1989,7 @@ void LEGACY_PLUGIN::loadNETCLASS() ...@@ -1989,7 +1989,7 @@ void LEGACY_PLUGIN::loadNETCLASS()
// just before returning. // just before returning.
auto_ptr<NETCLASS> nc( new NETCLASS( m_board, wxEmptyString ) ); auto_ptr<NETCLASS> nc( new NETCLASS( m_board, wxEmptyString ) );
while( READLINE() ) while( READLINE( m_reader ) )
{ {
char* line = m_reader->Line(); char* line = m_reader->Line();
...@@ -2082,7 +2082,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() ...@@ -2082,7 +2082,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
bool sawCorner = false; bool sawCorner = false;
char buf[1024]; char buf[1024];
while( READLINE() ) while( READLINE( m_reader ) )
{ {
const char* data; const char* data;
char* line = m_reader->Line(); char* line = m_reader->Line();
...@@ -2233,7 +2233,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() ...@@ -2233,7 +2233,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
{ {
// Read the PolysList (polygons used for fill areas in the zone) // Read the PolysList (polygons used for fill areas in the zone)
while( READLINE() ) while( READLINE( m_reader ) )
{ {
line = m_reader->Line(); line = m_reader->Line();
...@@ -2253,7 +2253,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() ...@@ -2253,7 +2253,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
else if( TESTLINE( "$FILLSEGMENTS" ) ) else if( TESTLINE( "$FILLSEGMENTS" ) )
{ {
while( READLINE() ) while( READLINE( m_reader ) )
{ {
line = m_reader->Line(); line = m_reader->Line();
...@@ -2304,7 +2304,7 @@ void LEGACY_PLUGIN::loadDIMENSION() ...@@ -2304,7 +2304,7 @@ void LEGACY_PLUGIN::loadDIMENSION()
{ {
auto_ptr<DIMENSION> dim( new DIMENSION( m_board ) ); auto_ptr<DIMENSION> dim( new DIMENSION( m_board ) );
while( READLINE() ) while( READLINE( m_reader ) )
{ {
const char* data; const char* data;
char* line = m_reader->Line(); char* line = m_reader->Line();
...@@ -2498,7 +2498,7 @@ void LEGACY_PLUGIN::loadDIMENSION() ...@@ -2498,7 +2498,7 @@ void LEGACY_PLUGIN::loadDIMENSION()
void LEGACY_PLUGIN::loadPCB_TARGET() void LEGACY_PLUGIN::loadPCB_TARGET()
{ {
while( READLINE() ) while( READLINE( m_reader ) )
{ {
const char* data; const char* data;
char* line = m_reader->Line(); char* line = m_reader->Line();
...@@ -2675,6 +2675,7 @@ double LEGACY_PLUGIN::degParse( const char* aValue, const char** nptrptr ) ...@@ -2675,6 +2675,7 @@ double LEGACY_PLUGIN::degParse( const char* aValue, const char** nptrptr )
void LEGACY_PLUGIN::init( PROPERTIES* aProperties ) void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
{ {
m_board = NULL;
m_props = aProperties; m_props = aProperties;
// conversion factor for saving RAM BIUs to KICAD legacy file format. // conversion factor for saving RAM BIUs to KICAD legacy file format.
...@@ -2706,9 +2707,11 @@ void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* ...@@ -2706,9 +2707,11 @@ void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES*
{ {
LOCALE_IO toggle; // toggles on, then off, the C locale. LOCALE_IO toggle; // toggles on, then off, the C locale.
init( aProperties );
m_board = aBoard; m_board = aBoard;
FILE* fp = wxFopen( aFileName, wxT( "wt" ) ); FILE* fp = wxFopen( aFileName, wxT( "w" ) );
if( !fp ) if( !fp )
{ {
m_error.Printf( _( "Unable to open file '%s'" ), aFileName.GetData() ); m_error.Printf( _( "Unable to open file '%s'" ), aFileName.GetData() );
...@@ -2722,8 +2725,6 @@ void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* ...@@ -2722,8 +2725,6 @@ void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES*
m_fp = fp; // member function accessibility m_fp = fp; // member function accessibility
init( aProperties );
if( m_props ) if( m_props )
{ {
wxString header = (*m_props)["header"]; wxString header = (*m_props)["header"];
...@@ -2751,8 +2752,6 @@ do { \ ...@@ -2751,8 +2752,6 @@ do { \
void LEGACY_PLUGIN::saveAllSections() const void LEGACY_PLUGIN::saveAllSections() const
{ {
saveGENERAL(); saveGENERAL();
saveSHEET(); saveSHEET();
...@@ -3698,3 +3697,371 @@ void LEGACY_PLUGIN::savePCB_TEXT( const TEXTE_PCB* me ) const ...@@ -3698,3 +3697,371 @@ void LEGACY_PLUGIN::savePCB_TEXT( const TEXTE_PCB* me ) const
fprintf( m_fp, "$EndTEXTPCB\n" ); fprintf( m_fp, "$EndTEXTPCB\n" );
} }
//-----<FOOTPRINT LIBRARY FUNCTIONS>--------------------------------------------
/*
The legacy file format is being obsoleted and this code will have a short
lifetime, so it only needs to be good enough for a short duration of time.
Caching all the MODULEs is a bit memory intensive, but it is a considerably
faster way of fulfilling the API contract. Otherwise, without the cache, you
would have to re-read the file when searching for any MODULE, and this would
be very problematic filling a FOOTPRINT_LIST via this PLUGIN API. If memory
becomes a concern, consider the cache lifetime policy, which determines the
time that a FPL_CACHE is in RAM. Note PLUGIN lifetime also plays a role in
cache lifetime.
*/
#include <boost/ptr_container/ptr_map.hpp>
typedef boost::ptr_map< wxString, MODULE > MODULE_MAP;
typedef MODULE_MAP::iterator MODULE_ITER;
typedef MODULE_MAP::const_iterator MODULE_CITER;
#define FOOTPRINT_LIBRARY_HEADER "PCBNEW-LibModule-V1"
/**
* Class FPL_CACHE
* assists only for the footprint portion of the PLUGIN API, and only for the
* LEGACY_PLUGIN, so therefore is private to this implementation file, i.e. not placed
* into a header.
*/
struct FPL_CACHE
{
LEGACY_PLUGIN* m_owner; // my owner, I need its LEGACY_PLUGIN::LoadMODULE()
wxString m_lib_name;
wxDateTime m_mod_time;
MODULE_MAP m_modules; // tuple of footprint name vs. MODULE*
bool m_writable;
FPL_CACHE( LEGACY_PLUGIN* aOwner, const wxString& aLibraryPath );
// Most all functions in this class throw IO_ERROR exceptions. There is no
// error codes nor user interface calls from here.
// Catch these exceptions higher up please.
/// save the entire legacy library to m_lib_name;
void Save();
void SaveHeader( FILE* aFile );
void SaveIndex( FILE* aFile );
void SaveModules( FILE* aFile );
void SaveEndOfFile( FILE* aFile );
void Load( LINE_READER* aReader );
void ReadAndVerifyHeader( LINE_READER* aReader );
void SkipIndex( LINE_READER* aReader );
void LoadModules( LINE_READER* aReader );
wxDateTime GetLibModificationTime();
};
FPL_CACHE::FPL_CACHE( LEGACY_PLUGIN* aOwner, const wxString& aLibraryPath ) :
m_owner( aOwner ),
m_lib_name( aLibraryPath ),
m_writable( false )
{
FILE* fp = wxFopen( aLibraryPath, wxT( "r" ) );
if( !fp )
{
THROW_IO_ERROR( wxString::Format(
_( "Unable to open legacy library file '%s'" ), aLibraryPath.GetData() ) );
}
// reader now owns fp, will close on exception or return
FILE_LINE_READER reader( fp, aLibraryPath );
Load( &reader );
}
wxDateTime FPL_CACHE::GetLibModificationTime()
{
wxFileName fn( m_lib_name );
m_writable = fn.IsFileWritable();
return fn.GetModificationTime();
}
void FPL_CACHE::Load( LINE_READER* aReader )
{
ReadAndVerifyHeader( aReader );
SkipIndex( aReader );
LoadModules( aReader );
// Remember the file modification time of library file when the
// cache snapshot was made, so that in a networked environment we will
// reload the cache as needed.
m_mod_time = GetLibModificationTime();
}
void FPL_CACHE::ReadAndVerifyHeader( LINE_READER* aReader )
{
if( !aReader->ReadLine() )
{
L_not_library:
THROW_IO_ERROR( wxString::Format( _( "File %s is empty or is not a legacy library" ),
m_lib_name.GetData() ) );
}
char* line = aReader->Line();
if( !TESTLINE( "PCBNEW-LibModule-V1" ) )
goto L_not_library;
}
void FPL_CACHE::SkipIndex( LINE_READER* aReader )
{
// Some broken INDEX sections have more than one section, due to prior bugs.
// So we must read the next line after $EndINDEX tag,
// to see if this is not a new $INDEX tag.
bool exit = false;
while( aReader->ReadLine() )
{
char* line = aReader->Line();
if( TESTLINE( "$INDEX" ) )
{
exit = false;
while( aReader->ReadLine() )
{
line = aReader->Line();
if( TESTLINE( "$EndINDEX" ) )
{
exit = true;
break;
}
}
}
else if( exit )
break;
}
}
void FPL_CACHE::LoadModules( LINE_READER* aReader )
{
m_owner->SetReader( aReader );
do
{
// test first for the $MODULE, even before reading because of INDEX bug.
char* line = aReader->Line();
if( TESTLINE( "$MODULE" ) )
{
MODULE* m = m_owner->LoadMODULE();
wxString reference = m->GetReference();
MODULE_CITER it = m_modules.find( reference );
if( it != m_modules.end() )
{
THROW_IO_ERROR( wxString::Format(
_( "library %s has a duplicate footprint named %s" ),
m_lib_name.GetData(), reference.GetData() ) );
}
m_modules.insert( reference, m );
}
} while( aReader->ReadLine() );
}
void FPL_CACHE::Save()
{
if( !m_writable )
{
THROW_IO_ERROR( wxString::Format(
_( "Legacy library file '%s' is read only" ), m_lib_name.GetData() ) );
}
wxString tempFileName = wxFileName::CreateTempFileName( m_lib_name );
wxLogDebug( "tempFileName:'%s'\n", TO_UTF8( tempFileName ) );
FILE* fp = wxFopen( tempFileName, wxT( "w" ) );
if( !fp )
{
THROW_IO_ERROR( wxString::Format(
_( "Unable to open legacy library file '%s'" ), m_lib_name.GetData() ) );
}
// wxf now owns fp, will close on exception or return
wxFFile wxf( fp );
SaveHeader( fp );
SaveIndex( fp );
SaveModules( fp );
SaveEndOfFile( fp );
wxRemoveFile( m_lib_name );
wxRenameFile( tempFileName, m_lib_name );
}
void FPL_CACHE::SaveHeader( FILE* aFile )
{
fprintf( aFile, "%s %s\n", FOOTPRINT_LIBRARY_HEADER, TO_UTF8( DateAndTime() ) );
fprintf( aFile, "# encoding utf-8\n" );
}
void FPL_CACHE::SaveIndex( FILE* aFile )
{
fprintf( aFile, "$INDEX\n" );
for( MODULE_CITER it = m_modules.begin(); it != m_modules.end(); ++it )
{
fprintf( aFile, "%s\n", TO_UTF8( it->first ) );
}
fprintf( aFile, "$EndINDEX\n" );
}
void FPL_CACHE::SaveModules( FILE* aFile )
{
}
void LEGACY_PLUGIN::cacheLib( const wxString& aLibraryPath )
{
if( !m_cache || m_cache->m_lib_name != aLibraryPath ||
m_cache->m_mod_time != m_cache->GetLibModificationTime() )
{
// a spectacular episode in memory management.
delete m_cache;
m_cache = new FPL_CACHE( this, aLibraryPath );
}
}
wxArrayString LEGACY_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties )
{
wxArrayString ret;
init( aProperties );
cacheLib( aLibraryPath );
const MODULE_MAP& mods = m_cache->m_modules;
for( MODULE_CITER it = mods.begin(); it != mods.end(); ++it )
{
ret.Add( it->first );
}
return ret;
}
MODULE* LEGACY_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
PROPERTIES* aProperties )
{
init( aProperties );
cacheLib( aLibraryPath );
const MODULE_MAP& mods = m_cache->m_modules;
MODULE_CITER it = mods.find( aFootprintName );
if( it == mods.end() )
{
THROW_IO_ERROR( wxString::Format( _( "No '%s' footprint in library '%s'" ),
aFootprintName.GetData(), aLibraryPath.GetData() ) );
}
// copy constructor to clone the already loaded MODULE
return new MODULE( *it->second );
}
void LEGACY_PLUGIN::FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint, PROPERTIES* aProperties )
{
init( aProperties );
cacheLib( aLibraryPath );
if( !m_cache->m_writable )
{
}
wxString reference = aFootprint->GetReference();
MODULE_MAP& mods = m_cache->m_modules;
// quietly overwrite any by same name.
MODULE_CITER it = mods.find( reference );
if( it != mods.end() )
{
mods.erase( reference );
}
aFootprint->SetParent( 0 );
mods.insert( reference, aFootprint );
m_cache->Save();
}
void LEGACY_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName )
{
init( NULL );
cacheLib( aLibraryPath );
if( !m_cache->m_writable )
{
}
size_t erasedCount = m_cache->m_modules.erase( aFootprintName );
if( erasedCount != 1 )
{
THROW_IO_ERROR( wxString::Format(
_( "library '%s' has no footprint '%s' to delete" ),
aLibraryPath.GetData(), aFootprintName.GetData() ) );
}
m_cache->Save();
}
bool LEGACY_PLUGIN::IsLibraryWritable( const wxString& aLibraryPath )
{
init( NULL );
cacheLib( aLibraryPath );
return m_cache->m_writable;
}
LEGACY_PLUGIN::~LEGACY_PLUGIN()
{
delete m_cache;
}
...@@ -44,6 +44,8 @@ class EDGE_MODULE; ...@@ -44,6 +44,8 @@ class EDGE_MODULE;
class TRACK; class TRACK;
class SEGZONE; class SEGZONE;
class D_PAD; class D_PAD;
class FPL_CACHE;
/** /**
* Class LEGACY_PLUGIN * Class LEGACY_PLUGIN
...@@ -55,7 +57,7 @@ class LEGACY_PLUGIN : public PLUGIN ...@@ -55,7 +57,7 @@ class LEGACY_PLUGIN : public PLUGIN
public: public:
//-----<PLUGIN>------------------------------------------------------------- //-----<PLUGIN IMPLEMENTATION>----------------------------------------------
const wxString& PluginName() const const wxString& PluginName() const
{ {
...@@ -73,7 +75,35 @@ public: ...@@ -73,7 +75,35 @@ public:
void Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL ); // overload void Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL ); // overload
//-----</PLUGIN>------------------------------------------------------------ wxArrayString FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL);
MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
PROPERTIES* aProperties = NULL );
void FootprintSave( const wxString& aLibraryPath, MODULE* aFootprint,
PROPERTIES* aProperties = NULL );
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName );
bool IsLibraryWritable( const wxString& aLibraryPath );
//-----</PLUGIN IMPLEMENTATION>---------------------------------------------
LEGACY_PLUGIN() :
m_board( 0 ),
m_props( 0 ),
m_reader( 0 ),
m_fp( 0 ),
m_cache( 0 )
{}
~LEGACY_PLUGIN();
void SetReader( LINE_READER* aReader ) { m_reader = aReader; }
void SetFilePtr( FILE* aFile ) { m_fp = aFile; }
MODULE* LoadMODULE();
protected: protected:
...@@ -87,6 +117,8 @@ protected: ...@@ -87,6 +117,8 @@ protected:
wxString m_field; ///< reused to stuff MODULE fields. wxString m_field; ///< reused to stuff MODULE fields.
int m_loading_format_version; ///< which BOARD_FORMAT_VERSION am I Load()ing? int m_loading_format_version; ///< which BOARD_FORMAT_VERSION am I Load()ing?
FPL_CACHE* m_cache;
/// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed. /// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
void init( PROPERTIES* aProperties ); void init( PROPERTIES* aProperties );
...@@ -131,11 +163,11 @@ protected: ...@@ -131,11 +163,11 @@ protected:
void loadAllSections( bool doAppend ); void loadAllSections( bool doAppend );
void loadGENERAL(); void loadGENERAL();
void loadSETUP(); void loadSETUP();
void loadSHEET(); void loadSHEET();
void loadMODULE();
void load3D( MODULE* aModule ); void load3D( MODULE* aModule );
void loadPAD( MODULE* aModule ); void loadPAD( MODULE* aModule );
void loadMODULE_TEXT( TEXTE_MODULE* aText ); void loadMODULE_TEXT( TEXTE_MODULE* aText );
...@@ -235,6 +267,8 @@ protected: ...@@ -235,6 +267,8 @@ protected:
//-----</save functions>---------------------------------------------------- //-----</save functions>----------------------------------------------------
/// we only cache one footprint library for now, this determines which one.
void cacheLib( const wxString& aLibraryPath );
}; };
#endif // LEGACY_PLUGIN_H_ #endif // LEGACY_PLUGIN_H_
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <class_module.h> #include <class_module.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <class_footprint_library.h>
#include <module_editor_frame.h> #include <module_editor_frame.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
...@@ -225,122 +224,15 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname ) ...@@ -225,122 +224,15 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname )
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
return; return;
oldFileName = aLibname; try
if( ( lib_module = wxFopen( oldFileName.GetFullPath(), wxT( "rt" ) ) ) == NULL )
{
wxString msg;
msg.Printf( _( "Library <%s> not found" ), GetChars(oldFileName.GetFullPath() ) );
DisplayError( NULL, msg );
return;
}
FOOTPRINT_LIBRARY input_lib( lib_module );
// Read header.
if( ! input_lib.IsLibrary() )
{
fclose( lib_module );
wxString msg;
msg.Printf( _( "<%s> is not a valid footprint library file" ),
GetChars( oldFileName.GetFullPath() ) );
DisplayError( NULL, msg );
return;
}
// Read module names.
input_lib.RebuildIndex();
bool found = input_lib.FindInList( CmpName );
if( !found )
{
fclose( lib_module );
msg.Printf( _( "Module [%s] not found" ), GetChars( CmpName ) );
DisplayError( NULL, msg );
return;
}
// Create new library.
newFileName = oldFileName;
newFileName.SetExt( FILETMP_EXT );
if( ( out_file = wxFopen( newFileName.GetFullPath(), wxT( "wt" ) ) ) == NULL )
{
fclose( lib_module );
msg.Printf( _( "Unable to create %s" ), GetChars( newFileName.GetFullPath() ) );
DisplayError( NULL, msg );
return;
}
wxBeginBusyCursor();
FOOTPRINT_LIBRARY output_lib( out_file );
output_lib.m_List = input_lib.m_List;
output_lib.WriteHeader();
output_lib.RemoveFromList( CmpName );
output_lib.SortList();
output_lib.WriteSectionIndex();
// Copy modules.
rewind( lib_module );
LineNum = input_lib.m_LineNum;
bool copylines = false;
while( GetLine( lib_module, Line, &LineNum ) )
{ {
StrPurge( Line ); PLUGIN::HOLDER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
if( strnicmp( Line, "$MODULE", 7 ) == 0 )
{
copylines = true;
sscanf( Line + 7, " %s", Name );
msg = FROM_UTF8( Name );
if( msg.CmpNoCase( CmpName ) == 0 )
{
// Delete old module (i.e. do not copy description to out_file).
while( GetLine( lib_module, Line, &LineNum ) )
{
if( strnicmp( Line, "$EndMODULE", 9 ) == 0 )
break;
}
continue;
}
}
if( copylines )
fprintf( out_file, "%s\n", Line );
}
fclose( lib_module );
fclose( out_file );
wxEndBusyCursor();
// The old library file is renamed .bak pi->FootprintDelete( aLibname, CmpName );
wxFileName backupFileName = oldFileName;
backupFileName.SetExt( BACKUP_EXT );
if( backupFileName.FileExists() )
wxRemoveFile( backupFileName.GetFullPath() );
if( !wxRenameFile( oldFileName.GetFullPath(), backupFileName.GetFullPath() ) )
{
msg.Printf( _( "Could not create library back up file <%s>." ),
GetChars( backupFileName.GetFullName() ) );
DisplayError( this, msg );
return;
} }
catch( IO_ERROR ioe )
// The temporary file is renamed as the previous library.
if( !wxRenameFile( newFileName.GetFullPath(), oldFileName.GetFullPath() ) )
{ {
msg.Printf( _("Could not create temporary library file <%s>."), DisplayError( NULL, ioe.errorText );
GetChars( oldFileName.GetFullName() ) );
DisplayError( this, msg );
return; return;
} }
......
...@@ -153,7 +153,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -153,7 +153,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
static wxArrayString HistoryList; static wxArrayString HistoryList;
static wxString lastComponentName; static wxString lastComponentName;
/* Ask for a component name or key words */ // Ask for a component name or key words
DIALOG_GET_COMPONENT dlg( this, GetComponentDialogPosition(), HistoryList, DIALOG_GET_COMPONENT dlg( this, GetComponentDialogPosition(), HistoryList,
_( "Load Module" ), aUseFootprintViewer ); _( "Load Module" ), aUseFootprintViewer );
...@@ -171,7 +171,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -171,7 +171,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
moduleName = dlg.GetComponentName(); moduleName = dlg.GetComponentName();
} }
if( moduleName.IsEmpty() ) /* Cancel command */ if( moduleName.IsEmpty() ) // Cancel command
{ {
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
return NULL; return NULL;
...@@ -185,7 +185,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -185,7 +185,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
keys = moduleName; keys = moduleName;
moduleName = Select_1_Module_From_List( this, aLibrary, wxEmptyString, keys ); moduleName = Select_1_Module_From_List( this, aLibrary, wxEmptyString, keys );
if( moduleName.IsEmpty() ) /* Cancel command */ if( moduleName.IsEmpty() ) // Cancel command
{ {
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
return NULL; return NULL;
...@@ -200,13 +200,13 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -200,13 +200,13 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
if( moduleName.IsEmpty() ) if( moduleName.IsEmpty() )
{ {
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
return NULL; /* Cancel command. */ return NULL; // Cancel command.
} }
} }
module = GetModuleLibrary( aLibrary, moduleName, false ); module = GetModuleLibrary( aLibrary, moduleName, false );
if( ( module == NULL ) && AllowWildSeach ) /* Search with wild card */ if( ( module == NULL ) && AllowWildSeach ) // Search with wild card
{ {
AllowWildSeach = false; AllowWildSeach = false;
wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' ); wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' );
...@@ -216,7 +216,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -216,7 +216,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
if( moduleName.IsEmpty() ) if( moduleName.IsEmpty() )
{ {
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
return NULL; /* Cancel command. */ return NULL; // Cancel command.
} }
else else
{ {
...@@ -376,7 +376,7 @@ wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow, ...@@ -376,7 +376,7 @@ wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow,
const wxString& aMask, const wxString& aMask,
const wxString& aKeyWord ) const wxString& aKeyWord )
{ {
static wxString OldName; /* Save the name of the last module loaded. */ static wxString OldName; // Save the name of the last module loaded.
wxString CmpName; wxString CmpName;
wxString msg; wxString msg;
wxArrayString libnames_list; wxArrayString libnames_list;
...@@ -386,7 +386,7 @@ wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow, ...@@ -386,7 +386,7 @@ wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow,
else else
libnames_list.Add( aLibraryFullFilename ); libnames_list.Add( aLibraryFullFilename );
/* Find modules in libraries. */ // Find modules in libraries.
MList.ReadFootprintFiles( libnames_list ); MList.ReadFootprintFiles( libnames_list );
wxArrayString footprint_names_list; wxArrayString footprint_names_list;
...@@ -461,7 +461,7 @@ static void DisplayCmpDoc( wxString& Name ) ...@@ -461,7 +461,7 @@ static void DisplayCmpDoc( wxString& Name )
MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb ) MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb )
{ {
MODULE* module; MODULE* module;
static wxString OldName; /* Save name of last module selected. */ static wxString OldName; // Save name of last module selected.
wxString CmpName, msg; wxString CmpName, msg;
wxArrayString listnames; wxArrayString listnames;
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <class_board.h> #include <class_board.h>
#include <class_module.h> #include <class_module.h>
#include <class_footprint_library.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <pcbnew_id.h> #include <pcbnew_id.h>
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
class wxSashLayoutWindow; class wxSashLayoutWindow;
class wxListBox; class wxListBox;
class wxSemaphore; class wxSemaphore;
class FOOTPRINT_LIBRARY;
/** /**
......
...@@ -543,7 +543,6 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) ...@@ -543,7 +543,6 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
/// data type used to ensure unique-ness of pin names, holding (wxString and int) /// data type used to ensure unique-ness of pin names, holding (wxString and int)
//typedef std::map<wxString, int, wxString_less_than> PINMAP;
typedef std::map<wxString, int> PINMAP; typedef std::map<wxString, int> PINMAP;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment