You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
4.8 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2016 CERN
  5. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * @author Wayne Stambaugh <stambaughw@gmail.com>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. #include <unordered_set>
  23. #include <ki_exception.h>
  24. #include <sch_io/sch_io.h>
  25. #include <sch_io/sch_io_mgr.h>
  26. #include <wx/translation.h>
  27. #include <wx/filename.h>
  28. #include <wx/dir.h>
  29. #define FMT_UNIMPLEMENTED wxT( "Plugin \"%s\" does not implement the \"%s\" function." )
  30. #define NOT_IMPLEMENTED( aCaller ) \
  31. THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, \
  32. GetName().GetData(), \
  33. wxString::FromUTF8( aCaller ).GetData() ) );
  34. const IO_BASE::IO_FILE_DESC SCH_IO::GetSchematicFileDesc() const
  35. {
  36. return IO_BASE::IO_FILE_DESC( wxEmptyString, {} );
  37. }
  38. bool SCH_IO::CanReadSchematicFile( const wxString& aFileName ) const
  39. {
  40. const std::vector<std::string>& exts = GetSchematicFileDesc().m_FileExtensions;
  41. wxString fileExt = wxFileName( aFileName ).GetExt().MakeLower();
  42. for( const std::string& ext : exts )
  43. {
  44. if( fileExt == wxString( ext ).Lower() )
  45. return true;
  46. }
  47. return false;
  48. }
  49. void SCH_IO::SaveLibrary( const wxString& aFileName, const std::map<std::string, UTF8>* aProperties )
  50. {
  51. NOT_IMPLEMENTED( __FUNCTION__ );
  52. }
  53. SCH_SHEET* SCH_IO::LoadSchematicFile( const wxString& aFileName, SCHEMATIC* aSchematic,
  54. SCH_SHEET* aAppendToMe, const std::map<std::string, UTF8>* aProperties )
  55. {
  56. NOT_IMPLEMENTED( __FUNCTION__ );
  57. }
  58. void SCH_IO::SaveSchematicFile( const wxString& aFileName, SCH_SHEET* aSheet, SCHEMATIC* aSchematic,
  59. const std::map<std::string, UTF8>* aProperties )
  60. {
  61. // not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
  62. NOT_IMPLEMENTED( __FUNCTION__ );
  63. }
  64. void SCH_IO::EnumerateSymbolLib( wxArrayString& aAliasNameList,
  65. const wxString& aLibraryPath,
  66. const std::map<std::string, UTF8>* aProperties )
  67. {
  68. // not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
  69. NOT_IMPLEMENTED( __FUNCTION__ );
  70. }
  71. void SCH_IO::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
  72. const wxString& aLibraryPath,
  73. const std::map<std::string, UTF8>* aProperties )
  74. {
  75. // not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
  76. NOT_IMPLEMENTED( __FUNCTION__ );
  77. }
  78. LIB_SYMBOL* SCH_IO::LoadSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
  79. const std::map<std::string, UTF8>* aProperties )
  80. {
  81. // not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
  82. NOT_IMPLEMENTED( __FUNCTION__ );
  83. }
  84. void SCH_IO::SaveSymbol( const wxString& aLibraryPath, const LIB_SYMBOL* aSymbol,
  85. const std::map<std::string, UTF8>* aProperties )
  86. {
  87. // not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
  88. NOT_IMPLEMENTED( __FUNCTION__ );
  89. }
  90. void SCH_IO::DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
  91. const std::map<std::string, UTF8>* aProperties )
  92. {
  93. // not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
  94. NOT_IMPLEMENTED( __FUNCTION__ );
  95. }
  96. void SCH_IO::GetLibraryOptions( std::map<std::string, UTF8>* aListToAppendTo ) const
  97. {
  98. // Get base options first
  99. IO_BASE::GetLibraryOptions( aListToAppendTo );
  100. // Empty for most plugins
  101. //
  102. // To add a new option override and use example code below:
  103. //
  104. //(*aListToAppendTo)["new_option_name"] = UTF8( _(
  105. // "A nice descrtiption with possibility for <b>bold</b> and other formatting."
  106. // ) );
  107. }
  108. const wxString& SCH_IO::GetError() const
  109. {
  110. // not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
  111. NOT_IMPLEMENTED( __FUNCTION__ );
  112. }