2012-03-19 11:21:29 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo <miguelangel@nbee.es>
|
2016-09-21 01:07:41 +00:00
|
|
|
* Copyright (C) 2016 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2020-10-07 16:46:50 +00:00
|
|
|
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-03-19 11:21:29 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file board.i
|
|
|
|
* @brief Specific BOARD extensions and templates
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-09-20 15:59:43 +00:00
|
|
|
/*
|
2014-09-30 18:23:27 +00:00
|
|
|
|
2016-09-20 15:59:43 +00:00
|
|
|
By default we do not translate exceptions for EVERY C++ function since not every
|
|
|
|
C++ function throws, and that would be unused and very bulky mapping code.
|
2016-09-23 00:12:36 +00:00
|
|
|
Therefore please help gather the subset of C++ functions for each class that do
|
|
|
|
throw and add each in a separate HANDLE_EXCEPTIONS() invocation before its
|
|
|
|
respective class declaration. i.e. put them inside of their respective *.i
|
|
|
|
file near the top; only class BOARD functions go in board.i.
|
2014-02-13 17:27:48 +00:00
|
|
|
|
2016-09-20 15:59:43 +00:00
|
|
|
*/
|
|
|
|
HANDLE_EXCEPTIONS(BOARD::TracksInNetBetweenPoints)
|
2014-02-13 17:27:48 +00:00
|
|
|
|
|
|
|
|
2021-07-29 09:47:43 +00:00
|
|
|
%include layer_ids.i
|
2016-09-21 01:07:41 +00:00
|
|
|
%include board_item.i
|
|
|
|
%include board_item_container.i
|
2016-09-23 00:12:36 +00:00
|
|
|
%include board_connected_item.i
|
|
|
|
%include board_design_settings.i
|
2017-11-15 13:16:21 +00:00
|
|
|
%include connectivity.i
|
2021-06-04 11:49:11 +00:00
|
|
|
%include pcb_item_containers.i
|
2016-09-21 01:07:41 +00:00
|
|
|
%include pad.i
|
|
|
|
%include track.i
|
|
|
|
%include zone.i
|
2016-09-23 00:12:36 +00:00
|
|
|
%include zone_settings.i
|
|
|
|
%include pcb_text.i
|
2021-06-11 16:59:28 +00:00
|
|
|
%include pcb_dimension.i
|
2020-10-05 14:52:41 +00:00
|
|
|
%include pcb_shape.i
|
2021-06-11 16:59:28 +00:00
|
|
|
%include pcb_marker.i
|
2017-10-31 15:38:10 +00:00
|
|
|
%include pcb_target.i
|
2020-10-05 14:52:41 +00:00
|
|
|
%include fp_shape.i
|
|
|
|
%include fp_text.i
|
2016-09-23 00:12:36 +00:00
|
|
|
%include netinfo.i
|
|
|
|
%include netclass.i
|
2018-12-08 17:30:35 +00:00
|
|
|
%include pcb_plot_params.i
|
2021-03-03 11:48:48 +00:00
|
|
|
%include pcb_group.i
|
2016-09-20 15:59:43 +00:00
|
|
|
|
2014-02-13 17:27:48 +00:00
|
|
|
// std::vector templates
|
2012-03-19 11:21:29 +00:00
|
|
|
%template(VIA_DIMENSION_Vector) std::vector<VIA_DIMENSION>;
|
2020-05-31 21:42:04 +00:00
|
|
|
|
|
|
|
// Do not permit default BOARD ctor since it won't initialize the project
|
|
|
|
%ignore BOARD::BOARD();
|
|
|
|
|
2021-02-27 13:53:59 +00:00
|
|
|
// Do not wrap internal-only structures
|
2021-02-27 23:56:47 +00:00
|
|
|
%ignore BOARD::m_CachesMutex;
|
2021-02-27 13:53:59 +00:00
|
|
|
%ignore BOARD::m_InsideCourtyardCache;
|
|
|
|
%ignore BOARD::m_InsideAreaCache;
|
|
|
|
%ignore BOARD::m_CopperZoneRTrees;
|
|
|
|
|
2020-11-12 20:19:22 +00:00
|
|
|
%include board.h
|
2016-09-23 00:12:36 +00:00
|
|
|
%{
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2016-09-23 00:12:36 +00:00
|
|
|
%}
|
|
|
|
|
2019-06-04 06:49:58 +00:00
|
|
|
%extend std::deque<BOARD_ITEM *>
|
|
|
|
{
|
|
|
|
%pythoncode
|
|
|
|
%{
|
|
|
|
def __iter__(self):
|
|
|
|
it = self.iterator()
|
|
|
|
try:
|
|
|
|
while True:
|
|
|
|
item = it.next() # throws StopIteration when iterator reached the end.
|
|
|
|
yield item.Cast()
|
|
|
|
except StopIteration:
|
|
|
|
return
|
|
|
|
%}
|
|
|
|
}
|
2021-07-26 22:27:19 +00:00
|
|
|
%extend std::deque<PCB_TRACK *>
|
2021-02-28 00:18:56 +00:00
|
|
|
{
|
|
|
|
%pythoncode
|
|
|
|
%{
|
|
|
|
def __iter__(self):
|
|
|
|
it = self.iterator()
|
|
|
|
try:
|
|
|
|
while True:
|
|
|
|
item = it.next() # throws StopIteration when iterator reached the end.
|
|
|
|
yield item.Cast()
|
|
|
|
except StopIteration:
|
|
|
|
return
|
|
|
|
%}
|
|
|
|
}
|
2019-06-04 06:49:58 +00:00
|
|
|
|
2014-09-30 18:23:27 +00:00
|
|
|
%extend BOARD
|
|
|
|
{
|
2020-05-31 21:42:04 +00:00
|
|
|
// NOTE: this does not generate a ctor, despite swig docs saying it should. Not sure why.
|
|
|
|
// Because of this, we use the __init__ override hack below.
|
|
|
|
// BOARD()
|
|
|
|
// {
|
|
|
|
// return CreateEmptyBoard();
|
|
|
|
// }
|
|
|
|
|
2016-09-23 00:12:36 +00:00
|
|
|
// BOARD_ITEM_CONTAINER's interface functions will be implemented by SWIG
|
|
|
|
// automatically and inherited by the python wrapper class.
|
|
|
|
|
2014-10-02 17:09:32 +00:00
|
|
|
%pythoncode
|
2016-09-20 15:59:43 +00:00
|
|
|
%{
|
2020-05-31 21:42:04 +00:00
|
|
|
def __init__(self, *args):
|
|
|
|
this = CreateEmptyBoard()
|
|
|
|
|
|
|
|
try:
|
|
|
|
self.this.append(this)
|
|
|
|
except:
|
|
|
|
self.this = this
|
2016-09-20 15:59:43 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
def GetFootprints(self): return self.Footprints()
|
2019-05-31 02:30:28 +00:00
|
|
|
def GetDrawings(self): return self.Drawings()
|
|
|
|
def GetTracks(self): return self.Tracks()
|
2016-09-20 15:59:43 +00:00
|
|
|
|
|
|
|
def Save(self,filename):
|
2017-11-18 16:00:24 +00:00
|
|
|
return SaveBoard(filename,self)
|
2016-09-20 15:59:43 +00:00
|
|
|
|
2014-10-02 17:09:32 +00:00
|
|
|
def GetNetClasses(self):
|
|
|
|
return self.GetDesignSettings().m_NetClasses
|
2014-09-30 18:23:27 +00:00
|
|
|
|
2014-10-02 17:09:32 +00:00
|
|
|
def GetCurrentNetClassName(self):
|
|
|
|
return self.GetDesignSettings().m_CurrentNetClassName
|
2014-09-30 18:23:27 +00:00
|
|
|
|
2014-10-02 17:09:32 +00:00
|
|
|
def GetViasDimensionsList(self):
|
|
|
|
return self.GetDesignSettings().m_ViasDimensionsList
|
2014-09-30 18:23:27 +00:00
|
|
|
|
2014-10-02 17:09:32 +00:00
|
|
|
def GetTrackWidthList(self):
|
|
|
|
return self.GetDesignSettings().m_TrackWidthList
|
2016-09-20 15:59:43 +00:00
|
|
|
|
|
|
|
def GetNetsByName(self):
|
|
|
|
"""
|
|
|
|
Return a dictionary like object with key:wxString netname and value:NETINFO_ITEM
|
|
|
|
"""
|
|
|
|
return self.GetNetInfo().NetsByName()
|
|
|
|
|
|
|
|
def GetNetsByNetcode(self):
|
|
|
|
"""
|
|
|
|
Return a dictionary like object with key:int netcode and value:NETINFO_ITEM
|
|
|
|
"""
|
|
|
|
return self.GetNetInfo().NetsByNetcode()
|
|
|
|
|
|
|
|
def GetNetcodeFromNetname(self,netname):
|
|
|
|
"""
|
|
|
|
Given a netname, return its netcode
|
|
|
|
"""
|
|
|
|
net = self.GetNetsByName()[netname]
|
2020-12-11 21:58:57 +00:00
|
|
|
return net.GetNetCode()
|
2016-09-20 15:59:43 +00:00
|
|
|
|
|
|
|
def GetAllNetClasses(self):
|
|
|
|
"""
|
2016-09-21 21:26:44 +00:00
|
|
|
Return a dictionary like object with net_class_name as key and NETCLASSPTR as value
|
2016-09-20 15:59:43 +00:00
|
|
|
GetNetClasses(BOARD self) -> { wxString net_class_name : NETCLASSPTR }
|
|
|
|
Include the "Default" netclass also.
|
|
|
|
"""
|
2016-09-21 21:26:44 +00:00
|
|
|
|
2019-07-06 14:17:51 +00:00
|
|
|
# Copy the NETCLASS_MAP so the one in the BOARD isn't modified
|
|
|
|
# when we add the Default net class.
|
|
|
|
netclassmap = {k:v for k,v in self.GetNetClasses().NetClasses().items()}
|
2016-09-21 21:26:44 +00:00
|
|
|
netclassmap['Default'] = self.GetNetClasses().GetDefault()
|
2016-09-20 15:59:43 +00:00
|
|
|
return netclassmap
|
|
|
|
%}
|
2014-09-30 18:23:27 +00:00
|
|
|
}
|