Browse Source
* More cleanup (common wrappers moved to scripting, instead of pcbnew/scripting)
* More cleanup (common wrappers moved to scripting, instead of pcbnew/scripting)
* Added a first test 'testLoadSave.py'pull/1/head
13 changed files with 263 additions and 58 deletions
-
9pcbnew/CMakeLists.txt
-
4pcbnew/pcbnew.cpp
-
51pcbnew/scripting/kicad.i
-
30pcbnew/scripting/pcbnew.i
-
30pcbnew/scripting/pcbnew_scripting_helpers.cpp
-
4pcbnew/scripting/tests/test1.py
-
29pcbnew/scripting/tests/testLoadSave.py
-
79scripting/kicad.i
-
28scripting/python_scripting.cpp
-
0scripting/python_scripting.h
-
28scripting/wx.i
-
29scripting/wx_python_helpers.cpp
-
0scripting/wx_python_helpers.h
@ -1,51 +0,0 @@ |
|||
//%module kicad |
|||
|
|||
/* OFF NOW, it triggers an error with GCC 4.6 and swig-2.0.4 or trunk.. |
|||
http://sourceforge.net/tracker/index.php?func=detail&aid=3391906&group_id=1645&atid=101645 |
|||
|
|||
%include <std_vector.i> |
|||
%include <std_string.i> |
|||
*/ |
|||
%nodefaultctor EDA_ITEM; |
|||
|
|||
|
|||
/* swig tries to wrap SetBack/SetNext on derived classes, but this method is |
|||
private for most childs, so if we don't ignore it it won't compile */ |
|||
|
|||
%ignore EDA_ITEM::SetBack; |
|||
%ignore EDA_ITEM::SetNext; |
|||
|
|||
|
|||
%ignore InitKiCadAbout; |
|||
%ignore GetCommandOptions; |
|||
|
|||
%{ |
|||
#include <dlist.h> |
|||
#include <base_struct.h> |
|||
#include <common.h> |
|||
#include <wx_python_helpers.h> |
|||
#include <cstddef> |
|||
#include <vector> |
|||
using namespace std; |
|||
#include <class_title_block.h> |
|||
#include <class_colors_design_settings.h> |
|||
|
|||
%} |
|||
|
|||
/* all the wx wrappers for wxString, wxPoint, wxRect, wxChar .. */ |
|||
%include <wx.i> |
|||
|
|||
|
|||
%include <dlist.h> |
|||
%include <base_struct.h> |
|||
%include <common.h> |
|||
%include <class_title_block.h> |
|||
%include <class_colors_design_settings.h> |
|||
|
|||
|
|||
/* |
|||
namespace std |
|||
{ |
|||
%template(intVector) vector<int>; |
|||
} |
|||
*/ |
|||
@ -0,0 +1,29 @@ |
|||
from pcbnew import * |
|||
import unittest |
|||
|
|||
class TestLoadSave(unittest.TestCase): |
|||
|
|||
def setUp(self): |
|||
self.TITLE="Test Board" |
|||
self.COMMENT1="For load/save test" |
|||
self.FILENAME="/tmp/test.brd" |
|||
|
|||
def test_00_save(self): |
|||
pcb = BOARD() |
|||
pcb.GetTitleBlock().SetTitle(self.TITLE) |
|||
pcb.GetTitleBlock().SetComment1(self.COMMENT1) |
|||
result = SaveBoard(self.FILENAME,pcb) |
|||
self.assertTrue(result) |
|||
|
|||
def test_01_load(self): |
|||
pcb2 = LoadBoard(self.FILENAME) |
|||
self.assertIsNotNone(pcb2) |
|||
|
|||
def test_02_titleblock_ok(self): |
|||
pcb2 = LoadBoard(self.FILENAME) |
|||
tb = pcb2.GetTitleBlock() |
|||
self.assertEqual(tb.GetTitle(),self.TITLE) |
|||
self.assertEqual(tb.GetComment1(),self.COMMENT1) |
|||
|
|||
if __name__ == '__main__': |
|||
unittest.main() |
|||
@ -0,0 +1,79 @@ |
|||
/* |
|||
* 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 kicad.i |
|||
* @brief General wrappers for kicad / wx structures and classes |
|||
*/ |
|||
|
|||
|
|||
/* OFF NOW, it triggers an error with GCC 4.6 and swig-2.0.4 or trunk.. |
|||
http://sourceforge.net/tracker/index.php?func=detail&aid=3391906&group_id=1645&atid=101645 |
|||
|
|||
%include <std_vector.i> |
|||
%include <std_string.i> |
|||
*/ |
|||
%nodefaultctor EDA_ITEM; |
|||
|
|||
|
|||
/* swig tries to wrap SetBack/SetNext on derived classes, but this method is |
|||
private for most childs, so if we don't ignore it it won't compile */ |
|||
|
|||
%ignore EDA_ITEM::SetBack; |
|||
%ignore EDA_ITEM::SetNext; |
|||
|
|||
|
|||
%ignore InitKiCadAbout; |
|||
%ignore GetCommandOptions; |
|||
|
|||
%{ |
|||
#include <dlist.h> |
|||
#include <base_struct.h> |
|||
#include <common.h> |
|||
#include <wx_python_helpers.h> |
|||
#include <cstddef> |
|||
#include <vector> |
|||
using namespace std; |
|||
#include <class_title_block.h> |
|||
#include <class_colors_design_settings.h> |
|||
|
|||
%} |
|||
|
|||
/* all the wx wrappers for wxString, wxPoint, wxRect, wxChar .. */ |
|||
%include <wx.i> |
|||
|
|||
|
|||
%include <dlist.h> |
|||
%include <base_struct.h> |
|||
%include <common.h> |
|||
%include <class_title_block.h> |
|||
%include <class_colors_design_settings.h> |
|||
|
|||
|
|||
/* |
|||
namespace std |
|||
{ |
|||
%template(intVector) vector<int>; |
|||
} |
|||
*/ |
|||
@ -1,3 +1,31 @@ |
|||
/*
|
|||
* 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 python_scripting.cpp |
|||
* @brief methods to add scripting capabilities inside pcbnew |
|||
*/ |
|||
|
|||
#include <python_scripting.h>
|
|||
|
|||
@ -1,3 +1,31 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2012 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 wx.i |
|||
* @brief wx wrappers for basic things, wxString, wxPoint, wxRect, etc.. |
|||
*/ |
|||
|
|||
%{ |
|||
#include <wx_python_helpers.h> |
|||
@ -1,3 +1,32 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2012 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 wx_python_helpers.cpp |
|||
* @brief Python wrapping helpers for wx structures/objects |
|||
*/ |
|||
|
|||
#include <Python.h>
|
|||
#include <wx/intl.h>
|
|||
#include <wx/string.h>
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue