Eeschema: Eagle plugin: Save symbols to schematic library cache file. Remove unneeded variable. Fix add extension to filename

This commit is contained in:
Russell Oliver 2017-06-18 22:02:04 +10:00 committed by Maciej Suminski
parent ea8f7ed02d
commit 739754cfd6
2 changed files with 20 additions and 4 deletions

View File

@ -29,7 +29,9 @@
#include <sch_sheet.h> #include <sch_sheet.h>
#include <sch_eagle_plugin.h> #include <sch_eagle_plugin.h>
#include <wildcards_and_files_ext.h>
#include <class_sch_screen.h> #include <class_sch_screen.h>
#include <class_library.h>
#include <class_libentry.h> #include <class_libentry.h>
#include <lib_circle.h> #include <lib_circle.h>
#include <lib_rectangle.h> #include <lib_rectangle.h>
@ -189,6 +191,18 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway,
m_rootSheet->SetScreen( screen ); m_rootSheet->SetScreen( screen );
} }
// Create a schematic symbol library
wxFileName libfn = fn;
libfn.SetName(libfn.GetName()+wxString("-cache"));
libfn.SetExt( SchematicLibraryFileExtension );
std::unique_ptr<PART_LIB> lib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, libfn.GetFullPath() ) );
lib->EnableBuffering();
if( !wxFileName::FileExists( lib->GetFullFileName() ) )
{
lib->Create();
}
m_partlib = lib.release();
// Retrieve the root as current node // Retrieve the root as current node
wxXmlNode* currentNode = xmlDocument.GetRoot(); wxXmlNode* currentNode = xmlDocument.GetRoot();
@ -205,6 +219,7 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway,
// Load drawing // Load drawing
loadDrawing( children["drawing"] ); loadDrawing( children["drawing"] );
m_partlib->Save(false);
deleter.release(); deleter.release();
return m_rootSheet; return m_rootSheet;
} }
@ -280,8 +295,7 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode )
if(sheet_count > 1){ if(sheet_count > 1){
// TODO: set up a heirachical sheet for each Eagle sheet. // TODO: set up a heirachical sheet for each Eagle sheet.
int x, y, i; int x, y;
i=1;
x = 1; x = 1;
y = 1; y = 1;
@ -296,6 +310,7 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode )
m_currentSheet = sheet.get(); m_currentSheet = sheet.get();
loadSheet( sheetNode ); loadSheet( sheetNode );
sheet->GetScreen()->SetFileName( sheet->GetFileName() );
m_rootSheet->GetScreen()->Append(sheet.release()); m_rootSheet->GetScreen()->Append(sheet.release());
sheetNode = sheetNode->GetNext(); sheetNode = sheetNode->GetNext();
@ -336,7 +351,7 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode )
ReplaceIllegalFileNameChars(&filename); ReplaceIllegalFileNameChars(&filename);
replace(filename.begin(),filename.end(), ' ', '_'); replace(filename.begin(),filename.end(), ' ', '_');
wxString fn = wxString(filename); wxString fn = wxString(filename+".sch");
m_currentSheet->SetFileName(fn); m_currentSheet->SetFileName(fn);
wxFileName fileName = m_currentSheet->GetFileName(); wxFileName fileName = m_currentSheet->GetFileName();
m_currentSheet->GetScreen()->SetFileName( fileName.GetFullPath() ); m_currentSheet->GetScreen()->SetFileName( fileName.GetFullPath() );
@ -585,7 +600,7 @@ void SCH_EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLibraryNode )
while( symbolNode ) while( symbolNode )
{ {
loadSymbol( symbolNode ); m_partlib->AddPart(loadSymbol( symbolNode ));
symbolNode = symbolNode->GetNext(); symbolNode = symbolNode->GetNext();
} }
} }

View File

@ -132,6 +132,7 @@ private:
SCH_SHEET* m_rootSheet; ///< The root sheet of the schematic being loaded.. SCH_SHEET* m_rootSheet; ///< The root sheet of the schematic being loaded..
SCH_SHEET* m_currentSheet; ///< The current sheet of the schematic being loaded.. SCH_SHEET* m_currentSheet; ///< The current sheet of the schematic being loaded..
wxString m_version; ///< Eagle file version. wxString m_version; ///< Eagle file version.
PART_LIB* m_partlib; ///< symbol library for imported file.
protected: protected:
}; };