Commit e88bc8e5 authored by Dick Hollenbeck's avatar Dick Hollenbeck

LEGACY_PLUGIN is now in full use:

*) for footprint access into *.mod files and 
*) BOARD save/load

The item_io.cpp and ioascii.cpp have been set off to the side for reference
as *.notused, for awhile.

The CMake options USE_NEW_PCBNEW_LOAD and USE_NEW_PCBNEW_SAVE are gone,
this is now the mandatory usage of the LEGACY_PLUGIN.  This should reduce
code maintenance for awhile until the s-expression plugin comes into 
play.  But at least for legacy format, there is not two code bodies
to maintain any more.

A new LEGACY_PLUGIN footprint library caching scheme is in place which 
needs some testing.  It should not be any faster, but might give better 
results in a networked environment if there is *.mod files on the server.
parents bf5802f1 51a83a7a
......@@ -23,8 +23,6 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
option(USE_PCBNEW_SEXPR_FILE_FORMAT
"Use s-expression Pcbnew file format support (default OFF)." )
option(USE_NEW_PCBNEW_LOAD "use new plugin support for legacy file format" ON)
option(USE_NEW_PCBNEW_SAVE "use new plugin support for legacy file format" ON)
option(USE_PCBNEW_NANOMETRES
"Use nanometers for Pcbnew internal units instead of deci-mils (default OFF).")
......
......@@ -55,8 +55,6 @@
#cmakedefine USE_IMAGES_IN_MENUS 1
#cmakedefine USE_NEW_PCBNEW_LOAD
#cmakedefine USE_NEW_PCBNEW_SAVE
#cmakedefine USE_PCBNEW_NANOMETRES
#cmakedefine USE_PCBNEW_SEXPR_FILE_FORMAT
......
......@@ -116,21 +116,13 @@ set(PCB_COMMON_SRCS
../pcbnew/collectors.cpp
../pcbnew/sel_layer.cpp
../pcbnew/pcb_plot_params.cpp
../pcbnew/io_mgr.cpp
../pcbnew/legacy_plugin.cpp
../pcbnew/kicad_plugin.cpp
pcb_plot_params_keywords.cpp
dialogs/dialog_page_settings.cpp
)
if( USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE )
set( PCB_COMMON_SRCS
${PCB_COMMON_SRCS}
../pcbnew/item_io.cpp
../pcbnew/io_mgr.cpp
../pcbnew/legacy_plugin.cpp
../pcbnew/kicad_plugin.cpp
)
else()
set( PCB_COMMON_SRCS ${PCB_COMMON_SRCS} ../pcbnew/item_io.cpp )
endif()
# add -DPCBNEW to compilation of these PCBNEW sources
set_source_files_properties( ${PCB_COMMON_SRCS} PROPERTIES
......
......@@ -111,15 +111,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() )
......
......@@ -368,7 +368,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;
......
......@@ -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>
......@@ -39,9 +40,8 @@
* ...... other data (pads, outlines ..)
* $Endmodule
*/
bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames )
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 )
try
{
m_filesInvalid << libname << _(" (file cannot be opened)") << wxT("\n");
continue;
}
wxArrayString fpnames = pi->FootprintEnumerate( libname );
FILE_LINE_READER fileReader( file, libname );
FILTER_READER reader( fileReader );
for( unsigned i=0; i<fpnames.GetCount(); ++i )
{
std::auto_ptr<MODULE> m( pi->FootprintLoad( libname, fpnames[i] ) );
/* Read header. */
reader.ReadLine();
char * line = reader.Line();
StrPurge( line );
FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();
if( strnicmp( line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) != 0 )
{
wxString msg;
msg.Printf( _( "<%s> is not a valid KiCad PCB footprint library." ),
GetChars( libname ) );
m_filesInvalid << msg << wxT("\n");
continue;
}
fpinfo->m_Module = fpnames[i];
fpinfo->m_LibName = libname;
fpinfo->m_padCount = m->GetPadCount();
fpinfo->m_KeyWord = m->GetKeywords();
fpinfo->m_Doc = m->GetDescription();
// 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 )
{
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;
}
}
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;
}
......@@ -17,8 +17,7 @@
#include <cvpcb.h>
#include <cvpcb_mainframe.h>
#include <class_DisplayFootprintsFrame.h>
#include <richio.h>
#include <filter_reader.h>
#include <io_mgr.h>
#include <wildcards_and_files_ext.h>
......@@ -29,122 +28,50 @@
* @param CmpName - Module name
* @return - a pointer to the loaded module or NULL.
*/
MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& CmpName )
MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
{
int Found = 0;
unsigned ii;
char* Line;
char Name[255];
wxString tmp, msg;
wxFileName fn;
MODULE* Module = NULL;
CVPCB_MAINFRAME* parent = ( CVPCB_MAINFRAME* ) GetParent();
for( ii = 0; ii < parent->m_ModuleLibNames.GetCount(); ii++ )
try
{
fn = parent->m_ModuleLibNames[ii];
fn.SetExt( FootprintLibFileExtension );
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
tmp = wxGetApp().FindLibraryPath( fn );
if( !tmp )
{
msg.Printf( _( "PCB foot print library file <%s> could not be \
found in the default search paths." ),
GetChars( fn.GetFullName() ) );
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
continue;
}
FILE* file = wxFopen( tmp, wxT( "rt" ) );
if( file == NULL )
for( unsigned i = 0; i < parent->m_ModuleLibNames.GetCount(); ++i )
{
msg.Printf( _( "Could not open PCB foot print library file <%s>." ),
GetChars( tmp ) );
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
continue;
}
wxFileName fn = parent->m_ModuleLibNames[i];
FILE_LINE_READER fileReader( file, tmp );
fn.SetExt( FootprintLibFileExtension );
FILTER_READER reader( fileReader );
wxString libPath = wxGetApp().FindLibraryPath( fn );
/* Read header. */
reader.ReadLine();
Line = reader.Line();
StrPurge( Line );
if( strnicmp( Line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) != 0 )
{
msg.Printf( _( "<%s> is not a valid KiCad PCB foot print library." ),
GetChars( tmp ) );
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
fclose( file );
return NULL;
}
Found = 0;
while( !Found && reader.ReadLine() )
{
Line = reader.Line();
if( strncmp( Line, "$MODULE", 6 ) == 0 )
break;
if( strnicmp( Line, "$INDEX", 6 ) == 0 )
if( !libPath )
{
while( reader.ReadLine() )
{
Line = reader.Line();
if( strnicmp( Line, "$EndINDEX", 9 ) == 0 )
break;
StrPurge( Line );
wxString msg = wxString::Format(
_("PCB foot print library file <%s> could not be found in the default search paths." ),
fn.GetFullName().GetData() );
if( stricmp( Line, TO_UTF8( CmpName ) ) == 0 )
{
Found = 1;
break;
}
}
}
}
while( Found && reader.ReadLine() )
{
Line = reader.Line();
if( Line[0] != '$' )
continue;
if( Line[1] != 'M' )
continue;
if( strnicmp( Line, "$MODULE", 7 ) != 0 )
// @todo we should not be using wxMessageBox directly.
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
continue;
}
/* Read component name. */
sscanf( Line + 7, " %s", Name );
MODULE* footprint = pi->FootprintLoad( libPath, aFootprintName );
if( stricmp( Name, TO_UTF8( CmpName ) ) == 0 )
if( footprint )
{
Module = new MODULE( GetBoard() );
// Switch the locale to standard C (needed to print floating
// point numbers like 1.3)
SetLocaleTo_C_standard();
Module->ReadDescr( &reader );
SetLocaleTo_Default(); // revert to the current locale
Module->SetPosition( wxPoint( 0, 0 ) );
return Module;
footprint->SetPosition( wxPoint( 0, 0 ) );
return footprint;
}
}
file = NULL;
}
catch( IO_ERROR ioe )
{
DisplayError( this, ioe.errorText );
return NULL;
}
msg.Printf( _( "Module %s not found" ), CmpName.GetData() );
wxString msg = wxString::Format( _( "Footprint '%s' not found" ), aFootprintName.GetData() );
DisplayError( this, msg );
return NULL;
}
......@@ -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();
......
///////////////////////////////////////////////////////////////////////////
// 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 );
......
///////////////////////////////////////////////////////////////////////////
// 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!
......@@ -11,6 +11,7 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/checkbox.h>
#include <wx/gdicmn.h>
......@@ -47,7 +48,7 @@
///////////////////////////////////////////////////////////////////////////////
/// 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:
......@@ -106,7 +107,7 @@ class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public wxDialog
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();
};
......
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)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_lib_new_component_base__
#define __dialog_lib_new_component_base__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/spinctrl.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
{
private:
protected:
wxStaticText* m_staticText6;
wxStaticText* m_staticText2;
wxTextCtrl* m_textName;
wxStaticText* m_staticText3;
wxTextCtrl* m_textReference;
wxStaticText* m_staticText4;
wxSpinCtrl* m_spinPartCount;
wxCheckBox* m_checkHasConversion;
wxCheckBox* m_checkIsPowerSymbol;
wxCheckBox* m_checkLockItems;
wxStaticText* m_staticText7;
wxStaticText* m_staticText41;
wxSpinCtrl* m_spinPinTextPosition;
wxStaticText* m_staticText5;
wxCheckBox* m_checkShowPinNumber;
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__
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 11 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_LIB_NEW_COMPONENT_BASE_H__
#define __DIALOG_LIB_NEW_COMPONENT_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/spinctrl.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 DIALOG_SHIM
{
private:
protected:
wxStaticText* m_staticText6;
wxStaticText* m_staticText2;
wxTextCtrl* m_textName;
wxStaticText* m_staticText3;
wxTextCtrl* m_textReference;
wxStaticText* m_staticText4;
wxSpinCtrl* m_spinPartCount;
wxCheckBox* m_checkHasConversion;
wxCheckBox* m_checkIsPowerSymbol;
wxCheckBox* m_checkLockItems;
wxStaticText* m_staticText7;
wxStaticText* m_staticText41;
wxSpinCtrl* m_spinPinTextPosition;
wxStaticText* m_staticText5;
wxCheckBox* m_checkShowPinNumber;
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_H__
......@@ -50,7 +50,7 @@
#include <dialogs/dialog_edit_component_in_lib.h>
#include <dialogs/dialog_libedit_dimensions.h>
#include <dialog_helpers.h>
//#include <dialog_helpers.h>
#include <menus_helpers.h>
#include <boost/foreach.hpp>
......
......@@ -15,6 +15,7 @@
#include <../pcbnew/class_track.h>
#include <../pcbnew/class_drawsegment.h>
#include <io_mgr.h>
#include <gerbview.h>
#include <class_board_design_settings.h>
#include <class_gerber_draw_item.h>
......@@ -26,32 +27,35 @@
*/
class GBR_TO_PCB_EXPORTER
{
GERBVIEW_FRAME* m_gerbview_frame; // the maint gerber frame
FILE * m_file; // .brd file to write to
BOARD* m_pcb; // the board to populate and export
public:
GBR_TO_PCB_EXPORTER(GERBVIEW_FRAME * aFrame, FILE * aFile );
GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME* aFrame, const wxString& aFileName );
~GBR_TO_PCB_EXPORTER();
/**
* Function ExportPcb
* saves a board from a gerber load.
*/
bool ExportPcb( int* LayerLookUpTable );
BOARD* GetBoard() { return m_pcb; }
private:
bool WriteSetup( ); // Write the SETUP section data file
bool WriteGeneralDescrPcb( );
void export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
void export_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
void export_flashed_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
void export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
void export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
void cleanBoard();
GERBVIEW_FRAME* m_gerbview_frame; // the maint gerber frame
wxString m_file_name; // BOARD file to write to
BOARD* m_pcb; // the board to populate and export
};
GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME * aFrame, FILE * aFile )
GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME* aFrame, const wxString& aFileName )
{
m_gerbview_frame = aFrame;
m_file = aFile;
m_file_name = aFileName;
m_pcb = new BOARD();
}
......@@ -84,12 +88,12 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
return;
}
wxString FullFileName, msg;
wxString fileName, msg;
wxString PcbExt( wxT( ".brd" ) );
msg = wxT( "*" ) + PcbExt;
FullFileName = EDA_FileSelector( _( "Board file name:" ),
fileName = EDA_FileSelector( _( "Board file name:" ),
wxEmptyString,
wxEmptyString,
PcbExt,
......@@ -98,7 +102,7 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
wxFD_SAVE,
false
);
if( FullFileName == wxEmptyString )
if( fileName == wxEmptyString )
return;
/* Install a dialog frame to choose the mapping
......@@ -111,24 +115,15 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
if( ok != wxID_OK )
return;
if( wxFileExists( FullFileName ) )
if( wxFileExists( fileName ) )
{
if( !IsOK( this, _( "Ok to change the existing file ?" ) ) )
return;
}
FILE * file = wxFopen( FullFileName, wxT( "wt" ) );
if( file == NULL )
{
msg = _( "Unable to create " ) + FullFileName;
DisplayError( this, msg );
return;
}
GBR_TO_PCB_EXPORTER gbr_exporter( this, fileName );
GBR_TO_PCB_EXPORTER gbr_exporter( this, file );
gbr_exporter.ExportPcb( dlg->GetLayersLookUpTable() );
fclose( file );
}
......@@ -162,54 +157,6 @@ void GBR_TO_PCB_EXPORTER::cleanBoard()
}
bool GBR_TO_PCB_EXPORTER::WriteSetup( )
{
fprintf( m_file, "$SETUP\n" );
fprintf( m_file, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT );
fprintf( m_file, "Layers %d\n", m_pcb->GetCopperLayerCount() );
fprintf( m_file, "$EndSETUP\n\n" );
return true;
}
bool GBR_TO_PCB_EXPORTER::WriteGeneralDescrPcb( )
{
int nbLayers;
// Print the copper layer count
nbLayers = m_pcb->GetCopperLayerCount();
if( nbLayers <= 1 ) // Minimal layers count in Pcbnew is 2
{
nbLayers = 2;
m_pcb->SetCopperLayerCount(2);
}
fprintf( m_file, "$GENERAL\n" );
fprintf( m_file, "encoding utf-8\n");
fprintf( m_file, "LayerCount %d\n", nbLayers );
// Compute and print the board bounding box
EDA_RECT bbbox = m_pcb->ComputeBoundingBox();
fprintf( m_file, "Di %d %d %d %d\n",
bbbox.GetX(), bbbox.GetY(),
bbbox.GetRight(),
bbbox.GetBottom() );
fprintf( m_file, "$EndGENERAL\n\n" );
return true;
}
/* Routine to save the board
* @param frame = pointer to the main frame
* @param File = FILE * pointer to an already opened file
* @param LayerLookUpTable = look up table: Pcbnew layer for each gerber layer
* @return 1 if OK, 0 if fail
*/
bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
{
BOARD* gerberPcb = m_gerbview_frame->GetBoard();
......@@ -235,22 +182,21 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
cleanBoard();
m_pcb->SetCopperLayerCount( LayerLookUpTable[32] );
// Switch the locale to standard C (needed to print floating point numbers)
SetLocaleTo_C_standard();
// write PCB header
fprintf( m_file, "PCBNEW-BOARD Version %d date %s\n\n", LEGACY_BOARD_FILE_VERSION,
TO_UTF8( DateAndTime() ) );
WriteGeneralDescrPcb( );
WriteSetup( );
// write items on file
m_pcb->Save( m_file );
try
{
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
pi->Save( m_file_name, m_pcb );
}
catch( IO_ERROR ioe )
{
DisplayError( m_gerbview_frame, ioe.errorText );
return false;
}
SetLocaleTo_Default(); // revert to the current locale
return true;
}
void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
{
DRAWSEGMENT* drawitem = new DRAWSEGMENT( m_pcb, PCB_LINE_T );
......
......@@ -296,13 +296,6 @@ public:
*/
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 SetPreviousZoom();
bool SetFirstZoom();
......
......@@ -98,26 +98,6 @@ public:
BOARD_ITEM* Back() const { return (BOARD_ITEM*) Pback; }
BOARD_ITEM* GetParent() const { return (BOARD_ITEM*) m_Parent; }
#if 0
// DICK: there is no value in having a polymorphic {Get,Set}Position(). We never
// call GetPosition() using a generic pointer, and the virtual is slower and
// can never be inlined.
/**
* Function GetPosition
* returns the position of this object.
* @return const wxPoint - The position of this object
*/
virtual const wxPoint GetPosition() const = 0;
/**
* Function SetPosition
* sets the position of this object.
* @param aPos is the new position of this object
*/
virtual void SetPosition( const wxPoint& aPos ) = 0;
#endif
/**
* Function GetLayer
* returns the layer this item is on.
......@@ -173,7 +153,6 @@ public:
return false; // only MODULEs can be locked at this time.
}
/**
* Function UnLink
* detaches this object from its owner. This base class implementation
......@@ -191,21 +170,12 @@ public:
delete this;
}
/**
* Function ShowShape
* converts the enum STROKE_T integer value to a wxString.
*/
static wxString ShowShape( STROKE_T aShape );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
virtual bool Save( FILE* aFile ) const = 0;
// Some geometric transforms, that must be rewritten for derived classes
/**
* Function Move
......
......@@ -172,72 +172,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_
......@@ -32,6 +32,7 @@ public:
}
};
class FOOTPRINT_LIST
{
public:
......
......@@ -3,13 +3,8 @@
* @brief Classes and definitions used in Pcbnew.
*/
#ifndef PCBSTRUCT_H
#define PCBSTRUCT_H
// Definitions relatives aux libraries
#define FOOTPRINT_LIBRARY_HEADER "PCBNEW-LibModule-V1"
#define FOOTPRINT_LIBRARY_HEADER_CNT 18
#ifndef PCBSTRUCT_H_
#define PCBSTRUCT_H_
/// Values for m_DisplayViaMode member:
......@@ -83,4 +78,4 @@ public:
DISPLAY_OPTIONS();
};
#endif // PCBSTRUCT_H
#endif // PCBSTRUCT_H_
......@@ -373,20 +373,45 @@ public:
// loading footprints
/**
* Function GetModuleLibrary
* Function loadFootprintFromLibrary
* loads @a aFootprintName from @a aLibraryPath.
* If found add the module is also added to the BOARD, just for good measure.
*
* Read active libraries or one library to find and load a given module
* If found the module is linked to the tail of linked list of modules
* @param aLibraryFullFilename - the full filename of the library to read. If empty,
* all active libraries are read
* @param aModuleName = module name to load
* @param aDisplayMessageError = true to display an error message if any.
*
* @param aFootprintName is the footprint to load
*
* @param aDisplayError = true to display an error message if any.
*
* @return MODULE* - new module, or NULL
*/
MODULE* loadFootprintFromLibrary( const wxString& aLibraryPath,
const wxString& aFootprintName, bool aDisplayError );
MODULE* loadFootprintFromLibraries( const wxString& aFootprintName,
bool aDisplayError );
/**
* Function GetModuleLibrary
* scans active libraries to find and load @a aFootprintName.
* If found add the module is also added to the BOARD, just for good measure.
*
* @param aFootprintName is the footprint to load
*
* @param aDisplayError = true to display an error message if any.
*
* @return a pointer to the new module, or NULL
*
*/
MODULE* GetModuleLibrary( const wxString& aLibraryFullFilename,
const wxString& aModuleName,
bool aDisplayMessageError );
MODULE* GetModuleLibrary( const wxString& aLibraryPath, const wxString& aFootprintName,
bool aDisplayError )
{
if( !aLibraryPath )
return loadFootprintFromLibraries( aFootprintName, aDisplayError );
else
return loadFootprintFromLibrary( aLibraryPath, aFootprintName, aDisplayError );
}
/**
* Function Select_1_Module_From_List
......@@ -409,7 +434,8 @@ public:
/**
* Function Load_Module_From_Library
* Open a dialog to select a footprint, and load in in current board
* opens a dialog to select a footprint, and loads it into current board.
*
* @param aLibrary = the library name to use, or empty string to search
* in all loaded libraries
* @param aUseFootprintViewer = true to show the option
......
......@@ -96,7 +96,7 @@ set(PCBNEW_SRCS
block.cpp
block_module_editor.cpp
build_BOM_from_board.cpp
class_footprint_library.cpp
# class_footprint_library.cpp
class_pcb_layer_widget.cpp
clean.cpp
connect.cpp
......@@ -136,7 +136,6 @@ set(PCBNEW_SRCS
hotkeys_board_editor.cpp
hotkeys_module_editor.cpp
initpcb.cpp
ioascii.cpp
layer_widget.cpp
librairi.cpp
loadcmp.cpp
......
......@@ -848,7 +848,7 @@ public:
* ( using the default netclass value or a preset value )
* the default netclass is always in m_TrackWidthList[0]
*/
int GetCurrentTrackWidth()
int GetCurrentTrackWidth() const
{
return m_TrackWidthList[m_TrackWidthSelector];
}
......@@ -892,8 +892,6 @@ public:
/***************************************************************************/
bool Save( FILE* aFile ) const;
wxString GetClass() const
{
return wxT( "BOARD" );
......
......@@ -135,14 +135,8 @@ public:
*/
}
bool Save( FILE* aFile ) const
{
return true;
}
//-----</ satisfy some virtual functions >-----------------------------
/**
* Function GetCount
* returns the number of BOARD_ITEMs.
......
......@@ -88,10 +88,6 @@ public:
*/
void AdjustDimensionDetails( bool aDoNotChangeText = false );
bool ReadDimensionDescr( LINE_READER* aReader );
bool Save( FILE* aFile ) const;
void SetText( const wxString& NewText );
const wxString GetText() const;
......
......@@ -152,10 +152,6 @@ public:
m_PolyPoints = aPoints;
}
bool Save( FILE* aFile ) const;
bool ReadDrawSegmentDescr( LINE_READER* aReader );
void Copy( DRAWSEGMENT* source );
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
......
......@@ -64,10 +64,6 @@ public:
void SetEnd0( const wxPoint& aPoint ) { m_End0 = aPoint; }
const wxPoint& GetEnd0() const { return m_End0; }
bool Save( FILE* aFile ) const;
int ReadDescr( LINE_READER* aReader );
void SetDrawCoord();
/* drawing functions */
......
......@@ -11,15 +11,16 @@ class FOOTPRINT_LIBRARY
public:
wxArrayString m_List; // list of footprints, used to read/write INDEX section
wxString m_LibraryName; // the full library name
int m_LineNum; // the line count
private:
FILTER_READER * m_reader; // FILTER_READER to read file. If NULL, use m_file
FILE * m_file; // footprint file to read/write.
int m_LineNum; // the line count
public:
/**
* ctor
* Constructor FOOTPRINT_LIBRARY
* @param aFile = a FILE * pointer used for write operations,
* and read operations when aReader = NULL
* @param aReader = a FILTER_READER pointer used for read operations
......@@ -27,7 +28,11 @@ public:
*/
FOOTPRINT_LIBRARY( FILE * aFile, FILTER_READER * aReader = NULL );
~FOOTPRINT_LIBRARY() { }
FOOTPRINT_LIBRARY() :
m_reader( 0 ),
m_file( 0 ),
m_LineNum( 0 )
{}
/**
* function IsLibrary
......
......@@ -70,13 +70,6 @@ public:
void DisplayInfo( EDA_DRAW_FRAME* frame );
bool Save( FILE* aFile ) const
{
// not implemented, this is here to satisfy BOARD_ITEM::Save()
// "pure" virtual-ness
return true;
}
wxString GetSelectMenuText() const;
BITMAP_DEF GetMenuImage() const { return drc_xpm; }
......
......@@ -86,10 +86,6 @@ public:
void Flip( const wxPoint& aCentre );
bool Save( FILE* aFile ) const;
bool ReadMirePcbDescr( LINE_READER* aReader );
void Copy( PCB_TARGET* source );
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode,
......
......@@ -111,6 +111,7 @@ MODULE::MODULE( const MODULE& aModule ) :
// Copy reference and value.
m_Reference = new TEXTE_MODULE( *aModule.m_Reference );
m_Reference->SetParent( this );
m_Value = new TEXTE_MODULE( *aModule.m_Value );
m_Value->SetParent( this );
......
......@@ -108,16 +108,6 @@ public:
wxString m_Doc; // Module Description (info for users)
wxString m_KeyWord; // Keywords to select the module in lib
// Local tolerances. When zero, this means the corresponding netclass value
// is used. Usually theses local tolerances zero, in deference to the
// corresponding netclass values.
int m_LocalClearance;
int m_LocalSolderMaskMargin; ///< Solder mask margin
int m_LocalSolderPasteMargin; ///< Solder paste margin
///< absolute value
double m_LocalSolderPasteMarginRatio; ///< Solder mask margin ratio
///< value of pad size
// The final margin is the sum of these 2 values
ZoneConnection m_ZoneConnection;
......@@ -236,14 +226,6 @@ public:
void SetLastEditTime( long aTime ) { m_LastEdit_Time = aTime; }
long GetLastEditTime() const { return m_LastEdit_Time; }
/* Reading and writing data on files */
bool Save( FILE* aFile ) const;
int Write_3D_Descr( FILE* File ) const;
int ReadDescr( LINE_READER* aReader );
/**
* Function Read_GPCB_Descr
* reads a footprint description in GPCB format (newlib version)
......@@ -332,6 +314,12 @@ public:
*/
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,
const KICAD_T scanTypes[] );
......@@ -352,7 +340,18 @@ public:
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload
#endif
};
private:
// Local tolerances. When zero, this means the corresponding netclass value
// is used. Usually theses local tolerances zero, in deference to the
// corresponding netclass values.
int m_LocalClearance;
int m_LocalSolderMaskMargin; ///< Solder mask margin
int m_LocalSolderPasteMargin; ///< Solder paste margin
///< absolute value
double m_LocalSolderPasteMarginRatio; ///< Solder mask margin ratio
///< value of pad size
};
#endif // MODULE_H_
......@@ -198,22 +198,6 @@ public:
*/
void SetParams( const NETCLASS* defaults = NULL );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
/**
* Function ReadDescr
* reads the data structures for this object from a LINE_READER in "*.brd" format.
* @param aReader is a pointer to a LINE_READER to read from.
* @return bool - true if success reading else false.
*/
bool ReadDescr( LINE_READER* aReader );
/**
* Function Format
* outputs the net class to \a aFormatter in s-expression form.
......
......@@ -342,18 +342,6 @@ public:
#endif
/* Reading and writing data on files */
int ReadDescr( LINE_READER* aReader );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
/**
* Function Draw
* @todo we actually could show a NET, simply show all the tracks and
......
......@@ -332,9 +332,10 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
int clearance = m_LocalClearance;
if( clearance == 0 )
{ // If local clearance is 0, use the parent footprint clearance value
if( GetParent() && ( (MODULE*) GetParent() )->m_LocalClearance )
clearance = ( (MODULE*) GetParent() )->m_LocalClearance;
{
// If local clearance is 0, use the parent footprint clearance value
if( GetParent() && GetParent()->GetLocalClearance() )
clearance = GetParent()->GetLocalClearance();
}
if( clearance == 0 ) // If the parent footprint clearance value = 0, use NETCLASS value
......@@ -367,14 +368,14 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
int D_PAD::GetSolderMaskMargin()
{
int margin = m_LocalSolderMaskMargin;
MODULE* module = (MODULE*) GetParent();
MODULE* module = GetParent();
if( module )
{
if( margin == 0 )
{
if( module->m_LocalSolderMaskMargin )
margin = module->m_LocalSolderMaskMargin;
if( module->GetLocalSolderMaskMargin() )
margin = module->GetLocalSolderMaskMargin();
}
if( margin == 0 )
......@@ -408,26 +409,26 @@ int D_PAD::GetSolderMaskMargin()
*/
wxSize D_PAD::GetSolderPasteMargin()
{
int margin = m_LocalSolderPasteMargin;
double mratio = m_LocalSolderPasteMarginRatio;
MODULE * module = (MODULE*) GetParent();
int margin = m_LocalSolderPasteMargin;
double mratio = m_LocalSolderPasteMarginRatio;
MODULE* module = GetParent();
if( module )
{
if( margin == 0 )
margin = module->m_LocalSolderPasteMargin;
if( margin == 0 )
margin = module->GetLocalSolderPasteMargin();
BOARD * brd = GetBoard();
if( margin == 0 )
if( margin == 0 )
margin = brd->GetDesignSettings().m_SolderPasteMargin;
if( mratio == 0.0 )
mratio = module->m_LocalSolderPasteMarginRatio;
mratio = module->GetLocalSolderPasteMarginRatio();
if( mratio == 0.0 )
{
mratio = brd->GetDesignSettings().m_SolderPasteMarginRatio;
mratio = brd->GetDesignSettings().m_SolderPasteMarginRatio;
}
}
......
......@@ -267,12 +267,6 @@ public:
void SetThermalGap( int aGap ) { m_ThermalGap = aGap; }
int GetThermalGap() const;
/* Reading and writing data on files */
int ReadDescr( LINE_READER* aReader );
bool Save( FILE* aFile ) const;
/* drawing functions */
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
int aDrawMode, const wxPoint& aOffset = ZeroOffset );
......
......@@ -73,11 +73,6 @@ public:
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode,
const wxPoint& offset = ZeroOffset );
// File Operations:
int ReadTextePcbDescr( LINE_READER* aReader );
bool Save( FILE* aFile ) const;
void DisplayInfo( EDA_DRAW_FRAME* frame );
bool HitTest( const wxPoint& aPosition )
......
......@@ -116,16 +116,6 @@ public:
void SetLocalCoord(); // Set relative coordinates.
bool Save( FILE* aFile ) const;
/**
* Function ReadDescr
* Read description from a given line in "*.brd" format.
* @param aReader is a pointer to a LINE_READER to read from.
* @return int - > 0 if success reading else 0.
*/
int ReadDescr( LINE_READER* aReader );
/* drawing functions */
void Draw( EDA_DRAW_PANEL* panel,
wxDC* DC,
......
......@@ -125,8 +125,6 @@ public:
EDA_RECT GetBoundingBox() const;
bool Save( FILE* aFile ) const;
/**
* Function GetBestInsertPoint
* searches the "best" insertion point within the track linked list.
......
......@@ -135,16 +135,6 @@ public:
~ZONE_CONTAINER();
bool Save( FILE* aFile ) const;
/**
* Function ReadDescr
* reads the data structures for this object from a LINE_READER in "*.brd" format.
* @param aReader is a pointer to a LINE_READER to read from.
* @return int - 1 if success, 0 if not.
*/
int ReadDescr( LINE_READER* aReader );
/**
* Function GetPosition
* @return a wxPoint, position of the first point of the outline
......
......@@ -30,18 +30,16 @@
#endif
/* Default Pcbnew zoom values.
* Limited to 19 values to keep a decent size to menus
* 15 it better but does not allow a sufficient number of values
* roughtly a 1.5 progression.
* The last 2 values is handy when somebody uses a library import of a module
* (or foreign data) which has a bad coordinate
* Also useful in GerbView for this reason.
* Zoom 5 and 10 can create artefacts when drawing (integer overflow in low level graphic
* functions )
*/
/**
Default Pcbnew zoom values.
Limited to 19 values to keep a decent size to menus.
Roughly a 1.5 progression.
The last 2 values are handy when somebody uses a library import of a module
(or foreign data) which has a bad coordinate.
Also useful in GerbView for this reason.
Zoom 5 and 10 can create artefacts when drawing (integer overflow in low level graphic
functions )
*/
static const double pcbZoomList[] =
{
ZOOM_FACTOR( 0.5 ),
......
......@@ -110,8 +110,8 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->m_LocalClearance );
PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->m_LocalSolderMaskMargin );
PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->GetLocalClearance() );
PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->GetLocalSolderMaskMargin() );
// These 2 parameters are usually < 0, so prepare entering a negative
// value, if current is 0
......
......@@ -149,8 +149,9 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()
m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
wxString msg;
PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->m_LocalClearance );
PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->m_LocalSolderMaskMargin );
PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->GetLocalClearance() );
PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->GetLocalSolderMaskMargin() );
// These 2 parameters are usually < 0, so prepare entering a negative value, if current is 0
PutValueInLocalUnits( *m_SolderPasteMarginCtrl, m_CurrentModule->GetLocalSolderPasteMargin() );
......
......@@ -202,70 +202,6 @@ the changes?" ) ) )
GetScreen()->SetFileName( fileName.GetFullPath() );
#if !defined(USE_NEW_PCBNEW_LOAD)
// Start read PCB file
FILE* source = wxFopen( GetScreen()->GetFileName(), wxT( "rt" ) );
if( source == NULL )
{
msg.Printf( _( "File <%s> not found" ), GetChars( GetScreen()->GetFileName() ) );
DisplayError( this, msg );
return false;
}
FILE_LINE_READER fileReader( source, GetScreen()->GetFileName() );
FILTER_READER reader( fileReader );
// Read header and TEST if it is a PCB file format
reader.ReadLine();
if( strncmp( reader.Line(), "PCBNEW-BOARD", 12 ) != 0 )
{
DisplayError( this, wxT( "Unknown file type" ) );
return false;
}
int ver;
sscanf( reader.Line() , "PCBNEW-BOARD Version %d date", &ver );
if ( ver > LEGACY_BOARD_FILE_VERSION )
{
DisplayInfoMessage( this, _( "This file was created by a more recent \
version of Pcbnew and may not load correctly. Please consider updating!" ) );
}
else if ( ver < LEGACY_BOARD_FILE_VERSION )
{
DisplayInfoMessage( this, _( "This file was created by an older \
version of Pcbnew. It will be stored in the new file format when you save \
this file again." ) );
}
// Reload the corresponding configuration file:
wxSetWorkingDirectory( wxPathOnly( GetScreen()->GetFileName() ) );
if( aAppend )
{
ReadPcbFile( &reader, true );
}
else
{
// Update the option toolbar
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
m_DisplayModText = DisplayOpt.DisplayModText;
m_DisplayModEdge = DisplayOpt.DisplayModEdge;
m_DisplayPadFill = DisplayOpt.DisplayPadFill;
m_DisplayViaFill = DisplayOpt.DisplayViaFill;
// load project settings before BOARD, in case BOARD file has overrides.
LoadProjectSettings( GetScreen()->GetFileName() );
ReadPcbFile( &reader, false );
}
#else
if( !aAppend )
{
// Update the option toolbar
......@@ -321,8 +257,6 @@ this file again." ) );
BestZoom();
}
#endif
GetScreen()->ClrModify();
// If append option: change the initial board name to <oldname>-append.brd
......@@ -456,10 +390,8 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
pcbFileName = GetScreen()->GetFileName();
#if defined( USE_NEW_PCBNEW_LOAD ) || defined( USE_NEW_PCBNEW_SAVE )
if( pcbFileName.GetExt().IsEmpty() )
pcbFileName.SetExt( IO_MGR::GetFileExtension( (IO_MGR::PCB_FILE_T) wildcardIndex ) );
#endif
if( !IsWritable( pcbFileName ) )
return false;
......@@ -493,8 +425,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
}
}
#if defined(USE_NEW_PCBNEW_SAVE)
GetBoard()->m_Status_Pcb &= ~CONNEXION_OK;
GetBoard()->SynchronizeNetsAndNetClasses();
......@@ -535,29 +465,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
UpdateTitle();
}
#else
// Create the file
FILE* dest;
dest = wxFopen( pcbFileName.GetFullPath(), wxT( "wt" ) );
if( dest == 0 )
{
msg = _( "Unable to create " ) + pcbFileName.GetFullPath();
DisplayError( this, msg );
saveok = false;
}
if( dest )
{
GetScreen()->SetFileName( pcbFileName.GetFullPath() );
UpdateTitle();
SavePcbFormatAscii( dest );
fclose( dest );
}
#endif
// Display the file names:
m_messagePanel->EraseMsgBox();
......
......@@ -42,6 +42,7 @@
#include <class_board.h>
#include <class_module.h>
#include <class_drawsegment.h>
#include <legacy_plugin.h>
#include <pcbnew.h>
#include <pcb_plot_params.h>
......@@ -532,7 +533,6 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event )
*/
bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool aUnitsMM )
{
MODULE* Module;
D_PAD* pad;
char line[1024];
wxString fnFront, msg;
......@@ -550,9 +550,7 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
double conv_unit = aUnitsMM ? conv_unit_mm : conv_unit_inch;
const char *unit_text = aUnitsMM ? unit_text_mm : unit_text_inch;
// Switch the locale to standard C (needed to print floating point
// numbers like 1.3)
SetLocaleTo_C_standard();
LOCALE_IO toggle;
// Generate header file comments.)
sprintf( line, "## Module report - date %s\n", TO_UTF8( DateAndTime() ) );
......@@ -584,103 +582,114 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
fputs( "$EndBOARD\n\n", rptfile );
Module = (MODULE*) GetBoard()->m_Modules;
for( ; Module != NULL; Module = Module->Next() )
try
{
sprintf( line, "$MODULE %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() );
fputs( line, rptfile );
sprintf( line, "reference %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() );
fputs( line, rptfile );
sprintf( line, "value %s\n", EscapedUTF8( Module->m_Value->m_Text ).c_str() );
fputs( line, rptfile );
sprintf( line, "footprint %s\n", EscapedUTF8( Module->m_LibRef ).c_str() );
fputs( line, rptfile );
msg = wxT( "attribut" );
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
if( Module->m_Attributs & MOD_VIRTUAL )
msg += wxT( " virtual" );
LEGACY_PLUGIN* legacy = (LEGACY_PLUGIN*) (PLUGIN*) pi;
if( Module->m_Attributs & MOD_CMS )
msg += wxT( " smd" );
legacy->SetFilePtr( rptfile );
if( ( Module->m_Attributs & (MOD_VIRTUAL | MOD_CMS) ) == 0 )
msg += wxT( " none" );
for( MODULE* Module = GetBoard()->m_Modules; Module; Module = Module->Next() )
{
sprintf( line, "$MODULE %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() );
fputs( line, rptfile );
msg += wxT( "\n" );
fputs( TO_UTF8( msg ), rptfile );
sprintf( line, "reference %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() );
fputs( line, rptfile );
sprintf( line, "value %s\n", EscapedUTF8( Module->m_Value->m_Text ).c_str() );
fputs( line, rptfile );
sprintf( line, "footprint %s\n", EscapedUTF8( Module->m_LibRef ).c_str() );
fputs( line, rptfile );
module_pos = Module->m_Pos;
module_pos.x -= File_Place_Offset.x;
module_pos.y -= File_Place_Offset.y;
msg = wxT( "attribut" );
sprintf( line, "position %9.6f %9.6f\n",
module_pos.x * conv_unit,
module_pos.y * conv_unit );
fputs( line, rptfile );
if( Module->m_Attributs & MOD_VIRTUAL )
msg += wxT( " virtual" );
sprintf( line, "orientation %.2f\n", (double) Module->m_Orient / 10 );
if( Module->m_Attributs & MOD_CMS )
msg += wxT( " smd" );
if( Module->GetLayer() == LAYER_N_FRONT )
strcat( line, "layer component\n" );
else if( Module->GetLayer() == LAYER_N_BACK )
strcat( line, "layer copper\n" );
else
strcat( line, "layer other\n" );
if( ( Module->m_Attributs & (MOD_VIRTUAL | MOD_CMS) ) == 0 )
msg += wxT( " none" );
fputs( line, rptfile );
msg += wxT( "\n" );
fputs( TO_UTF8( msg ), rptfile );
Module->Write_3D_Descr( rptfile );
module_pos = Module->m_Pos;
module_pos.x -= File_Place_Offset.x;
module_pos.y -= File_Place_Offset.y;
for( pad = Module->m_Pads; pad != NULL; pad = pad->Next() )
{
fprintf( rptfile, "$PAD \"%s\"\n", TO_UTF8( pad->GetPadName() ) );
sprintf( line, "position %9.6f %9.6f\n",
pad->GetPos0().x * conv_unit,
pad->GetPos0().y * conv_unit );
module_pos.x * conv_unit,
module_pos.y * conv_unit );
fputs( line, rptfile );
sprintf( line, "size %9.6f %9.6f\n",
pad->GetSize().x * conv_unit,
pad->GetSize().y * conv_unit );
fputs( line, rptfile );
sprintf( line, "orientation %.2f\n", (double) Module->m_Orient / 10 );
sprintf( line, "drill %9.6f\n", pad->GetDrillSize().x * conv_unit );
fputs( line, rptfile );
if( Module->GetLayer() == LAYER_N_FRONT )
strcat( line, "layer component\n" );
else if( Module->GetLayer() == LAYER_N_BACK )
strcat( line, "layer copper\n" );
else
strcat( line, "layer other\n" );
sprintf( line, "shape_offset %9.6f %9.6f\n",
pad->GetOffset().x * conv_unit,
pad->GetOffset().y * conv_unit );
fputs( line, rptfile );
sprintf( line, "orientation %.2f\n",
double(pad->GetOrientation() - Module->GetOrientation()) / 10 );
fputs( line, rptfile );
legacy->SaveModule3D( Module );
static const char* shape_name[6] = { "??? ", "Circ", "Rect", "Oval", "trap", "spec" };
for( pad = Module->m_Pads; pad != NULL; pad = pad->Next() )
{
fprintf( rptfile, "$PAD \"%s\"\n", TO_UTF8( pad->GetPadName() ) );
sprintf( line, "position %9.6f %9.6f\n",
pad->GetPos0().x * conv_unit,
pad->GetPos0().y * conv_unit );
fputs( line, rptfile );
sprintf( line, "Shape %s\n", shape_name[pad->GetShape()] );
fputs( line, rptfile );
sprintf( line, "size %9.6f %9.6f\n",
pad->GetSize().x * conv_unit,
pad->GetSize().y * conv_unit );
fputs( line, rptfile );
int layer = 0;
sprintf( line, "drill %9.6f\n", pad->GetDrillSize().x * conv_unit );
fputs( line, rptfile );
if( pad->GetLayerMask() & LAYER_BACK )
layer = 1;
sprintf( line, "shape_offset %9.6f %9.6f\n",
pad->GetOffset().x * conv_unit,
pad->GetOffset().y * conv_unit );
fputs( line, rptfile );
if( pad->GetLayerMask() & LAYER_FRONT )
layer |= 2;
sprintf( line, "orientation %.2f\n",
double(pad->GetOrientation() - Module->GetOrientation()) / 10 );
fputs( line, rptfile );
static const char* layer_name[4] = { "??? ", "copper", "component", "all" };
static const char* shape_name[6] = { "??? ", "Circ", "Rect", "Oval", "trap", "spec" };
sprintf( line, "Layer %s\n", layer_name[layer] );
fputs( line, rptfile );
fprintf( rptfile, "$EndPAD\n" );
}
sprintf( line, "Shape %s\n", shape_name[pad->GetShape()] );
fputs( line, rptfile );
int layer = 0;
if( pad->GetLayerMask() & LAYER_BACK )
layer = 1;
fprintf( rptfile, "$EndMODULE %s\n\n",
TO_UTF8(Module->m_Reference->m_Text ) );
if( pad->GetLayerMask() & LAYER_FRONT )
layer |= 2;
static const char* layer_name[4] = { "??? ", "copper", "component", "all" };
sprintf( line, "Layer %s\n", layer_name[layer] );
fputs( line, rptfile );
fprintf( rptfile, "$EndPAD\n" );
}
fprintf( rptfile, "$EndMODULE %s\n\n",
TO_UTF8(Module->m_Reference->m_Text ) );
}
}
catch( IO_ERROR ioe )
{
DisplayError( NULL, ioe.errorText );
}
// Write board Edges
......@@ -700,7 +709,6 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
// Generate EOF.
fputs( "$EndDESCRIPTION\n", rptfile );
fclose( rptfile );
SetLocaleTo_Default( ); // revert to the current locale
return true;
}
......
......@@ -28,6 +28,10 @@
#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
// and code size. Until then, use the simplest method:
......@@ -40,8 +44,8 @@
// plugins coexisting.
// static LEGACY_PLUGIN kicad_plugin; // a secret
//static EAGLE_PLUGIN eagle_plugin;
// static LEGACY_PLUGIN kicad_plugin;
// static EAGLE_PLUGIN eagle_plugin;
PLUGIN* IO_MGR::PluginFind( PCB_FILE_T aFileType )
{
......@@ -118,7 +122,7 @@ BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName,
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,70 @@ void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoar
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 )
{
// 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(
_( "Plugin %s does not implement the BOARD Load() function." ), PluginName().GetData() ) );
// 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::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface,
// e.g. Load() or Save() but not both.
// 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__ ) );
}
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__ ) );
}
MODULE* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
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(
_( "Plugin %s does not implement the BOARD Save() function." ), PluginName().GetData() ) );
void PLUGIN::FootprintSave( const wxString& aLibraryPath, const 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__ ) );
}
void PLUGIN::FootprintLibCreate( 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__ ) );
}
void PLUGIN::FootprintLibDelete( 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__ ) );
}
bool PLUGIN::IsFootprintLibWritable( 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 @@
class BOARD;
class PLUGIN;
class MODULE;
/**
......@@ -152,7 +153,9 @@ public:
* is a base class that BOARD loading and saving plugins should derive from.
* Implementations can provide either Load() or Save() functions, or both.
* PLUGINs throw exceptions, so it is best that you wrap your calls to these
* functions in a try catch block.
* functions in a try catch block. Plugins throw exceptions because it is illegal
* for them to have any user interface calls in them whatsoever, i.e. no windowing
* or screen printing at all.
*
* <pre>
* try
......@@ -187,9 +190,9 @@ public:
/**
* Function Load
* loads a board file, or a portion of one, from some input file format
* that this PLUGIN implementation knows about. This may be used to load an
* entire new BOARD, or to augment an existing one if \a aAppendToMe is not NULL.
* loads information from some input file format that this PLUGIN implementation
* knows about, into either a new BOARD or an existing one. This may be used to load an
* entire new BOARD, or to augment an existing one if @a aAppendToMe is not NULL.
*
* @param aFileName is the name of the file to use as input and may be foreign in
* nature or native in nature.
......@@ -216,7 +219,7 @@ public:
/**
* Function Save
* will write a full aBoard to a storage file in a format that this
* will write @a aBoard to a storage file in a format that this
* PLUGIN implementation knows about, or it can be used to write a portion of
* aBoard to a special kind of export file.
*
......@@ -237,13 +240,138 @@ public:
virtual void Save( const wxString& aFileName, BOARD* aBoard,
PROPERTIES* aProperties = NULL );
/**
* Function FootprintEnumerate
* returns a list of footprint names contained within the library at @a aLibraryPath.
*
* @param aLibraryPath is a 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 a 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* - if found caller owns it, else NULL if not found.
*
* @throw IO_ERROR if the library cannot be found or read. No exception
* is thrown in the case where aFootprintName cannot be found.
*/
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.
* If a footprint by the same name already exists, it is replaced.
*
* @param aLibraryPath is a 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, const MODULE* aFootprint,
PROPERTIES* aProperties = NULL );
/**
* Function FootprintDelete
* deletes the @a aFootprintName from the library at @a aLibraryPath.
*
* @param aLibraryPath is a 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 FootprintLibCreate
* creates a new empty footprint library at @a aLibraryPath empty. It is an
* error to attempt to create an existing library or to attempt to create
* on a "read only" location.
*
* @param aLibraryPath is a locator for the "library", usually a directory
* or file which will contain footprints.
*
* @param aProperties is an associative array that can be used to tell the
* library create function anything special, 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 finding the library, or creating it.
*/
virtual void FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
/**
* Function FootprintLibDelete
* deletes an existing footprint library, or complains if it cannot delete it or if it
* does not exist.
*
* @param aLibraryPath is a locator for the "library", usually a directory
* or file which will contain footprints.
*
* @param aProperties is an associative array that can be used to tell the
* library create function anything special, 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 finding the library, or deleting it.
*/
virtual void FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
/**
* Function IsFootprintLibWritable
* returns true iff the library at @a aLibraryPath is writable. (Often
* system libraries are read only because of where they are installed.)
*/
virtual bool IsFootprintLibWritable( const wxString& aLibraryPath );
//-----</PUBLIC PLUGIN API>------------------------------------------------
/* The compiler writes the "zero argument" constructor for a PLUGIN
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.
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() {}
......
This diff is collapsed.
......@@ -27,6 +27,10 @@
#include <io_mgr.h>
#include <string>
#define FOOTPRINT_LIBRARY_HEADER "PCBNEW-LibModule-V1"
#define FOOTPRINT_LIBRARY_HEADER_CNT 18
typedef int BIU;
class PCB_TARGET;
......@@ -36,6 +40,7 @@ class NETINFO;
class TEXTE_PCB;
class TRACK;
class NETCLASS;
class NETCLASSES;
class ZONE_CONTAINER;
class DIMENSION;
class NETINFO_ITEM;
......@@ -44,6 +49,8 @@ class EDGE_MODULE;
class TRACK;
class SEGZONE;
class D_PAD;
struct FPL_CACHE;
/**
* Class LEGACY_PLUGIN
......@@ -52,10 +59,11 @@ class D_PAD;
*/
class LEGACY_PLUGIN : public PLUGIN
{
friend struct FPL_CACHE;
public:
//-----<PLUGIN>-------------------------------------------------------------
//-----<PLUGIN IMPLEMENTATION>----------------------------------------------
const wxString& PluginName() const
{
......@@ -73,7 +81,42 @@ public:
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, const MODULE* aFootprint,
PROPERTIES* aProperties = NULL );
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName );
void FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
void FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
bool IsFootprintLibWritable( 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();
void SaveMODULE( const MODULE* aModule ) const;
void SaveModule3D( const MODULE* aModule ) const;
void SaveBOARD( const BOARD* aBoard ) const;
protected:
......@@ -87,6 +130,8 @@ protected:
wxString m_field; ///< reused to stuff MODULE fields.
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.
void init( PROPERTIES* aProperties );
......@@ -131,11 +176,11 @@ protected:
void loadAllSections( bool doAppend );
void loadGENERAL();
void loadSETUP();
void loadSHEET();
void loadMODULE();
void load3D( MODULE* aModule );
void loadPAD( MODULE* aModule );
void loadMODULE_TEXT( TEXTE_MODULE* aText );
......@@ -205,20 +250,17 @@ protected:
*/
std::string fmtDEG( double aAngle ) const;
void saveAllSections() const;
void saveGENERAL() const;
void saveSHEET() const;
void saveSETUP() const;
void saveBOARD() const;
void saveGENERAL( const BOARD* aBoard ) const;
void saveSHEET( const BOARD* aBoard ) const;
void saveSETUP( const BOARD* aBoard ) const;
void saveBOARD_ITEMS( const BOARD* aBoard ) const;
void saveMODULE( const MODULE* aModule ) const;
void saveMODULE_TEXT( const TEXTE_MODULE* aText ) const;
void saveMODULE_EDGE( const EDGE_MODULE* aGraphic ) const;
void savePAD( const D_PAD* aPad ) const;
void save3D( const MODULE* aModule ) const;
void saveNETINFO_ITEM( const NETINFO_ITEM* aNet ) const;
void saveNETCLASSES() const;
void saveNETCLASSES( const NETCLASSES* aNetClasses ) const;
void saveNETCLASS( const NETCLASS* aNetclass ) const;
void savePCB_TEXT( const TEXTE_PCB* aText ) const;
......@@ -235,6 +277,8 @@ protected:
//-----</save functions>----------------------------------------------------
/// we only cache one footprint library for now, this determines which one.
void cacheLib( const wxString& aLibraryPath );
};
#endif // LEGACY_PLUGIN_H_
This diff is collapsed.
This diff is collapsed.
......@@ -12,7 +12,6 @@
#include <class_board.h>
#include <class_module.h>
#include <class_footprint_library.h>
#include <pcbnew.h>
#include <pcbnew_id.h>
......
......@@ -35,7 +35,6 @@
class wxSashLayoutWindow;
class wxListBox;
class wxSemaphore;
class FOOTPRINT_LIBRARY;
/**
......
......@@ -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)
//typedef std::map<wxString, int, wxString_less_than> 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