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>
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
%extend BOARD
|
2014-02-13 17:27:48 +00:00
|
|
|
{
|
2012-03-19 11:21:29 +00:00
|
|
|
%pythoncode
|
2015-01-04 07:19:04 +00:00
|
|
|
%{
|
2012-03-19 11:21:29 +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
|
2014-09-30 18:23:27 +00:00
|
|
|
|
|
|
|
def Save(self,filename):
|
|
|
|
return SaveBoard(filename,self,IO_MGR.KICAD)
|
2014-02-13 17:27:48 +00:00
|
|
|
|
2012-04-06 19:46:45 +00:00
|
|
|
#
|
|
|
|
# add function, clears the thisown to avoid python from deleting
|
|
|
|
# the object in the garbage collector
|
|
|
|
#
|
2014-02-13 17:27:48 +00:00
|
|
|
|
|
|
|
def Add(self,item):
|
2014-10-02 17:09:32 +00:00
|
|
|
item.thisown=0
|
|
|
|
self.AddNative(item)
|
2015-01-04 07:19:04 +00:00
|
|
|
%}
|
2014-02-13 17:27:48 +00:00
|
|
|
|
2012-03-19 11:21:29 +00:00
|
|
|
}
|
|
|
|
|
2014-02-13 17:27:48 +00:00
|
|
|
// this is to help python with the * accessor of DLIST templates
|
2012-03-19 11:21:29 +00:00
|
|
|
|
2014-02-13 17:27:48 +00:00
|
|
|
%rename(Get) operator BOARD_ITEM*;
|
|
|
|
%rename(Get) operator TRACK*;
|
|
|
|
%rename(Get) operator D_PAD*;
|
|
|
|
%rename(Get) operator MODULE*;
|
2012-03-19 11:21:29 +00:00
|
|
|
|
2012-04-06 19:46:45 +00:00
|
|
|
|
2012-03-19 11:21:29 +00:00
|
|
|
// we must translate C++ templates to scripting languages
|
|
|
|
|
|
|
|
%template(BOARD_ITEM_List) DLIST<BOARD_ITEM>;
|
|
|
|
%template(MODULE_List) DLIST<MODULE>;
|
|
|
|
%template(TRACK_List) DLIST<TRACK>;
|
|
|
|
%template(PAD_List) DLIST<D_PAD>;
|
|
|
|
|
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>;
|
|
|
|
|
2012-03-19 11:21:29 +00:00
|
|
|
|
2014-09-30 18:23:27 +00:00
|
|
|
%extend BOARD
|
|
|
|
{
|
2014-10-02 17:09:32 +00:00
|
|
|
%pythoncode
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
2014-09-30 18:23:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-19 11:21:29 +00:00
|
|
|
%extend DRAWSEGMENT
|
|
|
|
{
|
2014-10-02 17:09:32 +00:00
|
|
|
%pythoncode
|
|
|
|
{
|
|
|
|
def GetShapeStr(self):
|
|
|
|
return self.ShowShape(self.GetShape())
|
|
|
|
}
|
2012-04-22 11:14:58 +00:00
|
|
|
}
|
2012-05-10 20:49:07 +00:00
|
|
|
|
|
|
|
%extend BOARD_ITEM
|
|
|
|
{
|
2014-10-02 17:09:32 +00:00
|
|
|
%pythoncode
|
|
|
|
{
|
|
|
|
def SetPos(self,p):
|
|
|
|
self.SetPosition(p)
|
|
|
|
self.SetPos0(p)
|
|
|
|
|
|
|
|
def SetStartEnd(self,start,end):
|
|
|
|
self.SetStart(start)
|
|
|
|
self.SetStart0(start)
|
|
|
|
self.SetEnd(end)
|
|
|
|
self.SetEnd0(end)
|
|
|
|
}
|
2012-05-10 20:49:07 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
|
|
|
|
%feature("notabstract") NETINFO_ITEM;
|
|
|
|
|
|
|
|
// http://swig.10945.n7.nabble.com/std-containers-and-pointers-td3728.html
|
|
|
|
%{
|
|
|
|
namespace swig {
|
|
|
|
template <> struct traits<NETINFO_ITEM> {
|
|
|
|
typedef pointer_category category;
|
|
|
|
static const char* type_name() { return "NETINFO_ITEM"; }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
%}
|