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.

183 lines
6.2 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2011-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  5. * Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #include <io_mgr.h>
  25. #include <properties.h>
  26. #include <wx/translation.h>
  27. #define FMT_UNIMPLEMENTED "Plugin \"%s\" does not implement the \"%s\" function."
  28. /**
  29. * Throw an #IO_ERROR and complains of an API function not being implemented.
  30. *
  31. * @param aPlugin is a #PLUGIN instance.
  32. * @param aCaller is the name of the unimplemented API function.
  33. */
  34. static void not_implemented( PLUGIN* aPlugin, const char* aCaller )
  35. {
  36. THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED,
  37. aPlugin->PluginName(),
  38. wxString::FromUTF8( aCaller ) ) );
  39. }
  40. BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties,
  41. PROJECT* aProject )
  42. {
  43. not_implemented( this, __FUNCTION__ );
  44. return nullptr;
  45. }
  46. std::vector<FOOTPRINT*> PLUGIN::GetImportedCachedLibraryFootprints()
  47. {
  48. not_implemented( this, __FUNCTION__ );
  49. return std::vector<FOOTPRINT*>();
  50. }
  51. void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties )
  52. {
  53. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  54. not_implemented( this, __FUNCTION__ );
  55. }
  56. void PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
  57. bool aBestEfforts, const PROPERTIES* aProperties )
  58. {
  59. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  60. not_implemented( this, __FUNCTION__ );
  61. }
  62. void PLUGIN::PrefetchLib( const wxString& aLibraryPath, const PROPERTIES* aProperties )
  63. {
  64. (void) aLibraryPath;
  65. (void) aProperties;
  66. }
  67. const FOOTPRINT* PLUGIN::GetEnumeratedFootprint( const wxString& aLibraryPath,
  68. const wxString& aFootprintName,
  69. const PROPERTIES* aProperties )
  70. {
  71. // default implementation
  72. return FootprintLoad( aLibraryPath, aFootprintName, false, aProperties );
  73. }
  74. bool PLUGIN::FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
  75. const PROPERTIES* aProperties )
  76. {
  77. // default implementation
  78. return FootprintLoad( aLibraryPath, aFootprintName, true, aProperties ) != nullptr;
  79. }
  80. FOOTPRINT* PLUGIN::FootprintLoad( const wxString& aLibraryPath,
  81. const wxString& aFootprintName,
  82. bool aKeepUUID,
  83. const PROPERTIES* aProperties )
  84. {
  85. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  86. not_implemented( this, __FUNCTION__ );
  87. return nullptr;
  88. }
  89. void PLUGIN::FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
  90. const PROPERTIES* aProperties )
  91. {
  92. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  93. not_implemented( this, __FUNCTION__ );
  94. }
  95. void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
  96. const PROPERTIES* aProperties )
  97. {
  98. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  99. not_implemented( this, __FUNCTION__ );
  100. }
  101. void PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
  102. {
  103. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  104. not_implemented( this, __FUNCTION__ );
  105. }
  106. bool PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
  107. {
  108. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  109. not_implemented( this, __FUNCTION__ );
  110. return false;
  111. }
  112. bool PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
  113. {
  114. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  115. not_implemented( this, __FUNCTION__ );
  116. return false;
  117. }
  118. void PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const
  119. {
  120. // disable all these in another couple of months, after everyone has seen them:
  121. #if 1
  122. (*aListToAppendTo)["debug_level"] = UTF8( _(
  123. "Enable <b>debug</b> logging for Footprint*() functions in this PLUGIN."
  124. ));
  125. (*aListToAppendTo)["read_filter_regex"] = UTF8( _(
  126. "Regular expression <b>footprint name</b> filter."
  127. ));
  128. (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
  129. "Enable transaction logging. The mere presence of this option turns on the "
  130. "logging, no need to set a Value."
  131. ));
  132. (*aListToAppendTo)["username"] = UTF8( _(
  133. "User name for <b>login</b> to some special library server."
  134. ));
  135. (*aListToAppendTo)["password"] = UTF8( _(
  136. "Password for <b>login</b> to some special library server."
  137. ));
  138. #endif
  139. #if 1
  140. // Suitable for a C++ to python PLUGIN::Footprint*() adapter, move it to the adapter
  141. // if and when implemented.
  142. (*aListToAppendTo)["python_footprint_plugin"] = UTF8( _(
  143. "Enter the python module which implements the PLUGIN::Footprint*() functions."
  144. ));
  145. #endif
  146. }