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>
|
2012-03-19 11:21:29 +00:00
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
|
|
|
2016-09-23 00:12:36 +00:00
|
|
|
//%import dlist.h // comes in from kicad.i which wraps & includes board.i
|
2016-09-20 15:59:43 +00:00
|
|
|
|
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
|
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
|
|
|
|
%include dimension.i
|
|
|
|
%include drawsegment.i
|
|
|
|
%include marker_pcb.i
|
|
|
|
%include mire.i
|
|
|
|
%include text_mod.i
|
|
|
|
%include edge_mod.i
|
|
|
|
%include netinfo.i
|
|
|
|
%include netclass.i
|
2016-09-20 15:59:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
%include layers_id_colors_and_visibility.h
|
2016-09-21 01:07:41 +00:00
|
|
|
// Extend LSET by 2 methods to add or remove layers from the layer list
|
|
|
|
// Mainly used to add or remove layers of a pad layer list
|
|
|
|
%extend LSET
|
|
|
|
{
|
|
|
|
LSET addLayer( LAYER_ID aLayer) { return self->set(aLayer); }
|
|
|
|
LSET removeLayer( LAYER_ID aLayer) { return self->reset(aLayer); }
|
|
|
|
LSET addLayerSet( LSET aLayerSet) { return *self |= aLayerSet; }
|
|
|
|
LSET removeLayerSet( LSET aLayerSet) { return *self &= ~aLayerSet; }
|
2016-09-20 15:59:43 +00:00
|
|
|
|
2016-09-21 01:07:41 +00:00
|
|
|
%pythoncode
|
|
|
|
%{
|
|
|
|
def AddLayer(self, layer):
|
|
|
|
return self.addLayer( layer )
|
2016-09-20 15:59:43 +00:00
|
|
|
|
2016-09-21 01:07:41 +00:00
|
|
|
def AddLayerSet(self, layers):
|
|
|
|
return self.addLayerSet( layers )
|
2016-09-20 15:59:43 +00:00
|
|
|
|
2016-09-21 01:07:41 +00:00
|
|
|
def RemoveLayer(self, layer):
|
|
|
|
return self.removeLayer( layer )
|
2016-09-20 15:59:43 +00:00
|
|
|
|
2016-09-21 01:07:41 +00:00
|
|
|
def RemoveLayerSet(self, layers):
|
|
|
|
return self.removeLayerSet( layers )
|
|
|
|
%}
|
|
|
|
}
|
2016-09-20 15:59:43 +00:00
|
|
|
%{
|
2016-09-21 01:07:41 +00:00
|
|
|
#include <layers_id_colors_and_visibility.h>
|
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>;
|
Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.
* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
and C++ so that the resultant type name is common in both languages, and
the types AGREE.
* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.
* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.
* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
Having the name consistent between like types is helpful, and between
languages. std::map<> ends up as SOMETHING_MAP.
* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
instead of hashtables, because swig does not yet support std::unordered_map.
* You can now get to any netclass or net info. NETNAMES_MAP and NETCODES_MAP
are traversable basically the same as a python dictionary using a python
string (not wsString) as the key! The wxString typemap converts python
string to wxString before the lookup happens. Iteration also works.
2016-07-18 17:23:09 +00:00
|
|
|
%template(RATSNEST_Vector) std::vector<RATSNEST_ITEM>;
|
2016-09-20 15:59:43 +00:00
|
|
|
%include class_board.h
|
2016-09-23 00:12:36 +00:00
|
|
|
%{
|
|
|
|
#include <class_board.h>
|
|
|
|
%}
|
|
|
|
|
2014-09-30 18:23:27 +00:00
|
|
|
%extend BOARD
|
|
|
|
{
|
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
|
|
|
%{
|
|
|
|
|
|
|
|
def GetModules(self): return self.m_Modules
|
|
|
|
def GetDrawings(self): return self.m_Drawings
|
|
|
|
def GetTracks(self): return self.m_Track
|
|
|
|
def GetFullRatsnest(self): return self.m_FullRatsnest
|
|
|
|
|
|
|
|
def Save(self,filename):
|
|
|
|
return SaveBoard(filename,self,IO_MGR.KICAD)
|
|
|
|
|
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]
|
|
|
|
return net.GetNet()
|
|
|
|
|
|
|
|
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.
|
|
|
|
"""
|
|
|
|
netclassmap = self.GetNetClasses().NetClasses()
|
2016-09-21 21:26:44 +00:00
|
|
|
|
2016-09-23 00:12:36 +00:00
|
|
|
# Add the Default one too, but this is probably modifying the NETCLASS_MAP
|
|
|
|
# in the BOARD. If that causes trouble, could make a deepcopy() here first.
|
|
|
|
# netclassmap = deepcopy(netclassmap)
|
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
|
|
|
}
|