From 2403f2b55878529b62a1f8f17a163d556106175b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Garc=C3=ADa=20Montoro?= Date: Mon, 27 Feb 2017 11:07:52 +0100 Subject: [PATCH] Adds necessary structure to implement and test Eagle schematich plugin --- eeschema/CMakeLists.txt | 4 +- eeschema/qa/CMakeLists.txt | 44 ++++++ eeschema/qa/data/eagle_schematics/empty.sch | 48 +++++++ eeschema/qa/data/fixtures_eagle_plugin.h | 0 eeschema/qa/test_basic.cpp | 44 ++++++ eeschema/qa/test_module.cpp | 32 +++++ eeschema/sch_eagle_plugin.cpp | 143 ++++++++++++++++++++ eeschema/sch_eagle_plugin.h | 111 +++++++++++++++ eeschema/sch_io_mgr.cpp | 8 ++ eeschema/sch_io_mgr.h | 1 + 10 files changed, 434 insertions(+), 1 deletion(-) create mode 100644 eeschema/qa/CMakeLists.txt create mode 100644 eeschema/qa/data/eagle_schematics/empty.sch create mode 100644 eeschema/qa/data/fixtures_eagle_plugin.h create mode 100644 eeschema/qa/test_basic.cpp create mode 100644 eeschema/qa/test_module.cpp create mode 100644 eeschema/sch_eagle_plugin.cpp create mode 100644 eeschema/sch_eagle_plugin.h diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index c5552187c9..69a0bf0831 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -168,6 +168,7 @@ set( EESCHEMA_SRCS sch_bus_entry.cpp sch_collectors.cpp sch_component.cpp + sch_eagle_plugin.cpp sch_field.cpp sch_io_mgr.cpp sch_item_struct.cpp @@ -299,7 +300,7 @@ target_link_libraries( eeschema ) # the DSO (KIFACE) housing the main eeschema code: -add_library( eeschema_kiface MODULE +add_library( eeschema_kiface STATIC ${EESCHEMA_SRCS} ${EESCHEMA_COMMON_SRCS} ) @@ -437,3 +438,4 @@ add_custom_target( add_dependencies( eeschema_kiface dialog_bom_cfg_lexer_source_files ) add_subdirectory( plugins ) +add_subdirectory( qa ) diff --git a/eeschema/qa/CMakeLists.txt b/eeschema/qa/CMakeLists.txt new file mode 100644 index 0000000000..4c5b8675fd --- /dev/null +++ b/eeschema/qa/CMakeLists.txt @@ -0,0 +1,44 @@ +# +# This program source code file is part of KiCad, a free EDA CAD application. +# +# Copyright (C) 2017 CERN +# @author Alejandro García Montoro +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +find_package(Boost COMPONENTS unit_test_framework REQUIRED) + +include_directories( BEFORE ${INC_BEFORE} ) +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${INC_AFTER} + ) + +add_executable( qa_eagle_plugin + test_module.cpp + test_basic.cpp +) + +add_dependencies( qa_eagle_plugin eeschema ) + +target_link_libraries( qa_eagle_plugin + eeschema + eeschema_kiface + ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} + ${wxWidgets_LIBRARIES} +) diff --git a/eeschema/qa/data/eagle_schematics/empty.sch b/eeschema/qa/data/eagle_schematics/empty.sch new file mode 100644 index 0000000000..f452a832b6 --- /dev/null +++ b/eeschema/qa/data/eagle_schematics/empty.sch @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eeschema/qa/data/fixtures_eagle_plugin.h b/eeschema/qa/data/fixtures_eagle_plugin.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/eeschema/qa/test_basic.cpp b/eeschema/qa/test_basic.cpp new file mode 100644 index 0000000000..315e5b4ca4 --- /dev/null +++ b/eeschema/qa/test_basic.cpp @@ -0,0 +1,44 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2017 CERN + * @author Alejandro García Montoro + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include + +#include + +// /** +// * Declares the IteratorFixture as the boost test suite fixture. +// */ +// BOOST_FIXTURE_TEST_SUITE( SegmentReference, CommonTestData ) + +/** + * Checks the XML tree load + */ +BOOST_AUTO_TEST_CASE( Load ) +{ + SCH_EAGLE_PLUGIN plugin; + // + // plugin.Load( "data/eagle_schematics/empty.sch", NULL ); +} diff --git a/eeschema/qa/test_module.cpp b/eeschema/qa/test_module.cpp new file mode 100644 index 0000000000..69417ab09c --- /dev/null +++ b/eeschema/qa/test_module.cpp @@ -0,0 +1,32 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2017 CERN + * @author Alejandro García Montoro + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * Main file for the schematic eagle plugin tests to be compiled + */ + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE "Schematic Eagle plugin" + +#include diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp new file mode 100644 index 0000000000..cb29143695 --- /dev/null +++ b/eeschema/sch_eagle_plugin.cpp @@ -0,0 +1,143 @@ +/* +* This program source code file is part of KiCad, a free EDA CAD application. +* +* Copyright (C) 2017 CERN +* +* @author Alejandro García Montoro +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program. If not, see . +*/ + +#include + +#include + +// #include +#include + + +SCH_EAGLE_PLUGIN::SCH_EAGLE_PLUGIN() +{ +} + +SCH_EAGLE_PLUGIN::~SCH_EAGLE_PLUGIN() +{ +} + +const wxString SCH_EAGLE_PLUGIN::GetName() const +{ + return wxT( "EAGLE" ); +} + + +const wxString SCH_EAGLE_PLUGIN::GetFileExtension() const +{ + return wxT( "sch" ); +} + + + +int SCH_EAGLE_PLUGIN::GetModifyHash() const +{ + return 0; +} + + +void SCH_EAGLE_PLUGIN::SaveLibrary( const wxString& aFileName, const PROPERTIES* aProperties ) +{ +} + + +SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway, + SCH_SHEET* aAppendToMe, const PROPERTIES* aProperties ) +{ + wxASSERT( !aFileName || aKiway != NULL ); + + SCH_SHEET* sheet = nullptr; + + wxFileName fn = aFileName; + + // if( !m_xmlTree.Load( fn.GetFullPath() ) ) + // THROW_IO_ERROR( wxString::Format( _( "Unable to read file '%s'" ), fn.GetFullPath() ) ); + + return sheet; +} + + +void SCH_EAGLE_PLUGIN::Save( const wxString& aFileName, SCH_SCREEN* aSchematic, KIWAY* aKiway, + const PROPERTIES* aProperties ) +{ +} + + +size_t SCH_EAGLE_PLUGIN::GetSymbolLibCount( const wxString& aLibraryPath, + const PROPERTIES* aProperties ) +{ + return 0; +} + + +void SCH_EAGLE_PLUGIN::EnumerateSymbolLib( wxArrayString& aAliasNameList, + const wxString& aLibraryPath, + const PROPERTIES* aProperties ) +{ +} + + +LIB_ALIAS* SCH_EAGLE_PLUGIN::LoadSymbol( const wxString& aLibraryPath, const wxString& aSymbolName, + const PROPERTIES* aProperties ) +{ + return nullptr; +} + + +void SCH_EAGLE_PLUGIN::SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol, + const PROPERTIES* aProperties ) +{ +} + + +void SCH_EAGLE_PLUGIN::DeleteAlias( const wxString& aLibraryPath, const wxString& aAliasName, + const PROPERTIES* aProperties ) +{ +} + + +void SCH_EAGLE_PLUGIN::DeleteSymbol( const wxString& aLibraryPath, const wxString& aAliasName, + const PROPERTIES* aProperties ) +{ +} + + +void SCH_EAGLE_PLUGIN::CreateSymbolLib( const wxString& aLibraryPath, + const PROPERTIES* aProperties ) +{ +} + + +bool SCH_EAGLE_PLUGIN::DeleteSymbolLib( const wxString& aLibraryPath, + const PROPERTIES* aProperties ) +{ + return false; +} + + +bool SCH_EAGLE_PLUGIN::IsSymbolLibWritable( const wxString& aLibraryPath ) +{ + return false; +} + +void SCH_EAGLE_PLUGIN::SymbolLibOptions( PROPERTIES* aListToAppendTo ) const +{ +} diff --git a/eeschema/sch_eagle_plugin.h b/eeschema/sch_eagle_plugin.h new file mode 100644 index 0000000000..39f5d3c9b1 --- /dev/null +++ b/eeschema/sch_eagle_plugin.h @@ -0,0 +1,111 @@ +/* +* This program source code file is part of KiCad, a free EDA CAD application. +* +* Copyright (C) 2017 CERN +* +* @author Alejandro García Montoro +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program. If not, see . +*/ + +#ifndef _SCH_EAGLE_PLUGIN_H_ +#define _SCH_EAGLE_PLUGIN_H_ + +#include + +#include + +// class KIWAY; +// class LINE_READER; +// class SCH_SCREEN; +// class SCH_SHEET; +// class SCH_BITMAP; +// class SCH_JUNCTION; +// class SCH_NO_CONNECT; +// class SCH_LINE; +// class SCH_BUS_ENTRY_BASE; +// class SCH_TEXT; +// class SCH_COMPONENT; +// class SCH_FIELD; +// class PROPERTIES; +// class SCH_EAGLE_PLUGIN_CACHE; +// class LIB_PART; +// class PART_LIB; +// class LIB_ALIAS; + + +/** + * Class SCH_EAGLE_PLUGIN + * is a #SCH_PLUGIN derivation for loading Autodesk Eagle schematic files. + * + * + * As with all SCH_PLUGINs there is no UI dependencies i.e. windowing + * calls allowed. + */ +class SCH_EAGLE_PLUGIN : public SCH_PLUGIN +{ +public: + + SCH_EAGLE_PLUGIN(); + ~SCH_EAGLE_PLUGIN(); + + const wxString GetName() const override; + + const wxString GetFileExtension() const override; + + int GetModifyHash() const override; + + void SaveLibrary( const wxString& aFileName, const PROPERTIES* aProperties = NULL ) override; + + SCH_SHEET* Load( const wxString& aFileName, KIWAY* aKiway, SCH_SHEET* aAppendToMe = NULL, + const PROPERTIES* aProperties = NULL ) override; + + void Save( const wxString& aFileName, SCH_SCREEN* aSchematic, KIWAY* aKiway, + const PROPERTIES* aProperties = NULL ) override; + + size_t GetSymbolLibCount( const wxString& aLibraryPath, + const PROPERTIES* aProperties = NULL ) override; + + void EnumerateSymbolLib( wxArrayString& aAliasNameList, const wxString& aLibraryPath, + const PROPERTIES* aProperties = NULL ) override; + + LIB_ALIAS* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName, + const PROPERTIES* aProperties = NULL ) override; + + void SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol, + const PROPERTIES* aProperties = NULL ) override; + + void DeleteAlias( const wxString& aLibraryPath, const wxString& aAliasName, + const PROPERTIES* aProperties = NULL ) override; + + void DeleteSymbol( const wxString& aLibraryPath, const wxString& aAliasName, + const PROPERTIES* aProperties = NULL ) override; + + void CreateSymbolLib( const wxString& aLibraryPath, + const PROPERTIES* aProperties = NULL ) override; + + bool DeleteSymbolLib( const wxString& aLibraryPath, + const PROPERTIES* aProperties = NULL ) override; + + bool IsSymbolLibWritable( const wxString& aLibraryPath ) override; + + void SymbolLibOptions( PROPERTIES* aListToAppendTo ) const override; + + +private: + wxXmlDocument m_xmlTree; +protected: +}; + +#endif // _SCH_EAGLE_PLUGIN_H_ diff --git a/eeschema/sch_io_mgr.cpp b/eeschema/sch_io_mgr.cpp index e33eaa1b15..e78d10d840 100644 --- a/eeschema/sch_io_mgr.cpp +++ b/eeschema/sch_io_mgr.cpp @@ -25,6 +25,7 @@ #include #include +#include #include @@ -54,6 +55,8 @@ SCH_PLUGIN* SCH_IO_MGR::FindPlugin( SCH_FILE_T aFileType ) { case SCH_LEGACY: return new SCH_LEGACY_PLUGIN(); + case SCH_EAGLE: + return new SCH_EAGLE_PLUGIN(); case SCH_KICAD: return NULL; } @@ -85,6 +88,9 @@ const wxString SCH_IO_MGR::ShowType( SCH_FILE_T aType ) case SCH_LEGACY: return wxString( wxT( "Legacy" ) ); + + case SCH_EAGLE: + return wxString( wxT( "EAGLE" ) ); } } @@ -97,6 +103,8 @@ SCH_IO_MGR::SCH_FILE_T SCH_IO_MGR::EnumFromStr( const wxString& aType ) if( aType == wxT( "Legacy" ) ) return SCH_LEGACY; + else if( aType == wxT( "EAGLE" ) ) + return SCH_EAGLE; // wxASSERT( blow up here ) diff --git a/eeschema/sch_io_mgr.h b/eeschema/sch_io_mgr.h index 9734762e43..d7a2bcff3e 100644 --- a/eeschema/sch_io_mgr.h +++ b/eeschema/sch_io_mgr.h @@ -53,6 +53,7 @@ public: { SCH_LEGACY, ///< Legacy Eeschema file formats prior to s-expression. SCH_KICAD, ///< The s-expression version of the schematic file formats. + SCH_EAGLE, ///< Autodesk Eagle file format // Add your schematic type here. // ALTIUM,