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.

171 lines
5.4 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo <miguelangel@nbee.es>
  5. * Copyright (C) 2016 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /**
  26. * @file board.i
  27. * @brief Specific BOARD extensions and templates
  28. */
  29. /*
  30. By default we do not translate exceptions for EVERY C++ function since not every
  31. C++ function throws, and that would be unused and very bulky mapping code.
  32. Therefore please help gather the subset of C++ functions for each class that do
  33. throw and add each in a separate HANDLE_EXCEPTIONS() invocation before its
  34. respective class declaration. i.e. put them inside of their respective *.i
  35. file near the top; only class BOARD functions go in board.i.
  36. */
  37. HANDLE_EXCEPTIONS(BOARD::TracksInNetBetweenPoints)
  38. //%import dlist.h // comes in from kicad.i which wraps & includes board.i
  39. %include board_item.i
  40. %include board_item_container.i
  41. %include board_connected_item.i
  42. %include board_design_settings.i
  43. %include connectivity.i
  44. %include pad.i
  45. %include track.i
  46. %include zone.i
  47. %include zone_settings.i
  48. %include pcb_text.i
  49. %include dimension.i
  50. %include drawsegment.i
  51. %include marker_pcb.i
  52. %include pcb_target.i
  53. %include text_mod.i
  54. %include edge_mod.i
  55. %include netinfo.i
  56. %include netclass.i
  57. %include pcb_plot_params.i
  58. %ignore operator++(SCH_LAYER_ID&);
  59. %ignore operator++(GAL_LAYER_ID&);
  60. %ignore operator+(const GAL_LAYER_ID&, int);
  61. %include layers_id_colors_and_visibility.h
  62. // Extend LSET by 2 methods to add or remove layers from the layer list
  63. // Mainly used to add or remove layers of a pad layer list
  64. %extend LSET
  65. {
  66. LSET addLayer( PCB_LAYER_ID aLayer) { return self->set(aLayer); }
  67. LSET removeLayer( PCB_LAYER_ID aLayer) { return self->reset(aLayer); }
  68. LSET addLayerSet( LSET aLayerSet) { return *self |= aLayerSet; }
  69. LSET removeLayerSet( LSET aLayerSet) { return *self &= ~aLayerSet; }
  70. %pythoncode
  71. %{
  72. def AddLayer(self, layer):
  73. return self.addLayer( layer )
  74. def AddLayerSet(self, layers):
  75. return self.addLayerSet( layers )
  76. def RemoveLayer(self, layer):
  77. return self.removeLayer( layer )
  78. def RemoveLayerSet(self, layers):
  79. return self.removeLayerSet( layers )
  80. %}
  81. }
  82. %{
  83. #include <layers_id_colors_and_visibility.h>
  84. %}
  85. // std::vector templates
  86. %template(VIA_DIMENSION_Vector) std::vector<VIA_DIMENSION>;
  87. %include class_board.h
  88. %{
  89. #include <class_board.h>
  90. %}
  91. %extend BOARD
  92. {
  93. // BOARD_ITEM_CONTAINER's interface functions will be implemented by SWIG
  94. // automatically and inherited by the python wrapper class.
  95. %pythoncode
  96. %{
  97. def GetModules(self): return self.m_Modules
  98. def GetDrawings(self): return self.DrawingsList()
  99. def GetTracks(self): return self.m_Track
  100. def Save(self,filename):
  101. return SaveBoard(filename,self)
  102. def GetNetClasses(self):
  103. return self.GetDesignSettings().m_NetClasses
  104. def GetCurrentNetClassName(self):
  105. return self.GetDesignSettings().m_CurrentNetClassName
  106. def GetViasDimensionsList(self):
  107. return self.GetDesignSettings().m_ViasDimensionsList
  108. def GetTrackWidthList(self):
  109. return self.GetDesignSettings().m_TrackWidthList
  110. def GetNetsByName(self):
  111. """
  112. Return a dictionary like object with key:wxString netname and value:NETINFO_ITEM
  113. """
  114. return self.GetNetInfo().NetsByName()
  115. def GetNetsByNetcode(self):
  116. """
  117. Return a dictionary like object with key:int netcode and value:NETINFO_ITEM
  118. """
  119. return self.GetNetInfo().NetsByNetcode()
  120. def GetNetcodeFromNetname(self,netname):
  121. """
  122. Given a netname, return its netcode
  123. """
  124. net = self.GetNetsByName()[netname]
  125. return net.GetNet()
  126. def GetAllNetClasses(self):
  127. """
  128. Return a dictionary like object with net_class_name as key and NETCLASSPTR as value
  129. GetNetClasses(BOARD self) -> { wxString net_class_name : NETCLASSPTR }
  130. Include the "Default" netclass also.
  131. """
  132. netclassmap = self.GetNetClasses().NetClasses()
  133. # Add the Default one too, but this is probably modifying the NETCLASS_MAP
  134. # in the BOARD. If that causes trouble, could make a deepcopy() here first.
  135. # netclassmap = deepcopy(netclassmap)
  136. netclassmap['Default'] = self.GetNetClasses().GetDefault()
  137. return netclassmap
  138. %}
  139. }