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.

181 lines
6.1 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, 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, aProperties ) != nullptr;
  79. }
  80. FOOTPRINT* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
  81. const PROPERTIES* aProperties )
  82. {
  83. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  84. not_implemented( this, __FUNCTION__ );
  85. return nullptr;
  86. }
  87. void PLUGIN::FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
  88. const PROPERTIES* aProperties )
  89. {
  90. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  91. not_implemented( this, __FUNCTION__ );
  92. }
  93. void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
  94. const PROPERTIES* aProperties )
  95. {
  96. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  97. not_implemented( this, __FUNCTION__ );
  98. }
  99. void PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
  100. {
  101. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  102. not_implemented( this, __FUNCTION__ );
  103. }
  104. bool PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
  105. {
  106. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  107. not_implemented( this, __FUNCTION__ );
  108. return false;
  109. }
  110. bool PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
  111. {
  112. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  113. not_implemented( this, __FUNCTION__ );
  114. return false;
  115. }
  116. void PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const
  117. {
  118. // disable all these in another couple of months, after everyone has seen them:
  119. #if 1
  120. (*aListToAppendTo)["debug_level"] = UTF8( _(
  121. "Enable <b>debug</b> logging for Footprint*() functions in this PLUGIN."
  122. ));
  123. (*aListToAppendTo)["read_filter_regex"] = UTF8( _(
  124. "Regular expression <b>footprint name</b> filter."
  125. ));
  126. (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
  127. "Enable transaction logging. The mere presence of this option turns on the "
  128. "logging, no need to set a Value."
  129. ));
  130. (*aListToAppendTo)["username"] = UTF8( _(
  131. "User name for <b>login</b> to some special library server."
  132. ));
  133. (*aListToAppendTo)["password"] = UTF8( _(
  134. "Password for <b>login</b> to some special library server."
  135. ));
  136. #endif
  137. #if 1
  138. // Suitable for a C++ to python PLUGIN::Footprint*() adapter, move it to the adapter
  139. // if and when implemented.
  140. (*aListToAppendTo)["python_footprint_plugin"] = UTF8( _(
  141. "Enter the python module which implements the PLUGIN::Footprint*() functions."
  142. ));
  143. #endif
  144. }