Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
ec5757a4
Commit
ec5757a4
authored
Mar 11, 2012
by
Miguel Angel Ajo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code cleanup, io_mgr and kicad_plugin included when enabled in cmake...
parent
562d2461
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
187 additions
and
76 deletions
+187
-76
CMakeLists.txt
pcbnew/CMakeLists.txt
+35
-8
pcbnew.cpp
pcbnew/pcbnew.cpp
+3
-54
kicad.i
pcbnew/scripting/kicad.i
+18
-5
pcbnew.i
pcbnew/scripting/pcbnew.i
+29
-8
python_scripting.cpp
pcbnew/scripting/python_scripting.cpp
+90
-0
python_scripting.h
pcbnew/scripting/python_scripting.h
+11
-0
wx.i
pcbnew/scripting/wx.i
+1
-1
wx_python_helpers.cpp
pcbnew/scripting/wx_python_helpers.cpp
+0
-0
wx_python_helpers.h
pcbnew/scripting/wx_python_helpers.h
+0
-0
No files found.
pcbnew/CMakeLists.txt
View file @
ec5757a4
...
@@ -223,22 +223,49 @@ set(PCBNEW_COMMON_SRCS
...
@@ -223,22 +223,49 @@ set(PCBNEW_COMMON_SRCS
# Scripting sources
# Scripting sources
##
##
set
(
PCBNEW_SCRIPTING_SRCS
set
(
PCBNEW_SCRIPTING_SRCS
kicad_wrap.cxx
#
kicad_wrap.cxx
pcbnew_wrap.cxx
pcbnew_wrap.cxx
scripting/helpers.cpp
scripting/wx_python_helpers.cpp
scripting/python_scripting.cpp
)
)
##
##
# Scripting build
# Scripting build
##
##
SET
(
SWIG_OPTS -python -c++ -outdir
${
CMAKE_CURRENT_BINARY_DIR
}
-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/../.. -I
${
CMAKE_CURRENT_SOURCE_DIR
}
-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/../include -DKICAD_TESTING_VERSION -D_FILE_OFFSET_BITS=64 -DPCBNEW -D_LARGE_FILES -D__WXGTK__ -DHAVE_SVN_VERSION -DDEBUG
)
add_custom_command
(
OUTPUT
${
CMAKE_CURRENT_BINARY_DIR
}
/kicad_wrap.cxx
SET
(
SWIG_OPTS -python -c++ -outdir
${
CMAKE_CURRENT_BINARY_DIR
}
-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/../.. -I
${
CMAKE_CURRENT_SOURCE_DIR
}
-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/../include -DDEBUG
)
COMMAND
${
SWIG_EXECUTABLE
}
${
SWIG_OPTS
}
-o
${
CMAKE_CURRENT_BINARY_DIR
}
/kicad_wrap.cxx scripting/kicad.i
WORKING_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
# collect CFLAGS , and pass them to swig later
)
get_directory_property
(
DirDefs DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
COMPILE_DEFINITIONS
)
foreach
(
d
${
DirDefs
}
)
SET
(
SWIG_OPTS
${
SWIG_OPTS
}
-D
${
d
}
)
endforeach
()
# check if we have IO_MGR and KICAD_PLUGIN available
if
(
USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE
)
SET
(
SWIG_OPTS
${
SWIG_OPTS
}
-DBUILD_WITH_PLUGIN
)
endif
()
foreach
(
d
${
SWIG_OPTS
}
)
message
(
STATUS
"Swig options:"
${
d
}
)
endforeach
()
if
(
USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE
)
endif
()
#add_custom_command(
# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/kicad_wrap.cxx
# COMMAND ${SWIG_EXECUTABLE} ${SWIG_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/kicad_wrap.cxx scripting/kicad.i
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
#)
add_custom_command
(
add_custom_command
(
OUTPUT
${
CMAKE_CURRENT_BINARY_DIR
}
/pcbnew_wrap.cxx
OUTPUT
${
CMAKE_CURRENT_BINARY_DIR
}
/pcbnew_wrap.cxx
COMMAND
${
SWIG_EXECUTABLE
}
${
SWIG_OPTS
}
-o
${
CMAKE_CURRENT_BINARY_DIR
}
/pcbnew_wrap.cxx scripting/pcbnew.i
COMMAND
${
SWIG_EXECUTABLE
}
${
SWIG_OPTS
}
-o
${
CMAKE_CURRENT_BINARY_DIR
}
/pcbnew_wrap.cxx scripting/pcbnew.i
...
...
pcbnew/pcbnew.cpp
View file @
ec5757a4
...
@@ -45,11 +45,10 @@
...
@@ -45,11 +45,10 @@
#include <protos.h>
#include <protos.h>
#include <hotkeys.h>
#include <hotkeys.h>
#include <wildcards_and_files_ext.h>
#include <wildcards_and_files_ext.h>
#include <Python.h>
#include <class_board.h>
#include <class_board.h>
#include <dialogs/dialog_scripting.h>
#include <dialogs/dialog_scripting.h>
#include <scripting/python_scripting.h>
// Colors for layers and items
// Colors for layers and items
COLORS_DESIGN_SETTINGS
g_ColorsSettings
;
COLORS_DESIGN_SETTINGS
g_ColorsSettings
;
...
@@ -108,64 +107,14 @@ void EDA_APP::MacOpenFile( const wxString& fileName )
...
@@ -108,64 +107,14 @@ void EDA_APP::MacOpenFile( const wxString& fileName )
}
}
struct
_inittab
SWIG_Import_Inittab
[
1000
];
static
int
swig_num_modules
=
0
;
static
void
swig_add_module
(
char
*
name
,
void
(
*
initfunc
)())
{
SWIG_Import_Inittab
[
swig_num_modules
].
name
=
name
;
SWIG_Import_Inittab
[
swig_num_modules
].
initfunc
=
initfunc
;
swig_num_modules
++
;
SWIG_Import_Inittab
[
swig_num_modules
].
name
=
(
char
*
)
0
;
SWIG_Import_Inittab
[
swig_num_modules
].
initfunc
=
0
;
}
extern
"C"
void
init_kicad
(
void
);
extern
"C"
void
init_pcbnew
(
void
);
static
void
swig_add_builtin
()
{
int
i
=
0
;
while
(
PyImport_Inittab
[
i
].
name
)
{
swig_add_module
(
PyImport_Inittab
[
i
].
name
,
PyImport_Inittab
[
i
].
initfunc
);
i
++
;
}
swig_add_module
(
"_kicad"
,
init_kicad
);
swig_add_module
(
"_pcbnew"
,
init_pcbnew
);
PyImport_Inittab
=
SWIG_Import_Inittab
;
}
static
BOARD
*
st_board
;
BOARD
*
GetBoard
()
{
return
st_board
;
}
bool
EDA_APP
::
OnInit
()
bool
EDA_APP
::
OnInit
()
{
{
wxFileName
fn
;
wxFileName
fn
;
PCB_EDIT_FRAME
*
frame
=
NULL
;
PCB_EDIT_FRAME
*
frame
=
NULL
;
int
i
=
0
;
int
i
=
0
;
swig_add_builtin
();
pcbnewInitPythonScripting
();
#if 0
while(PyImport_Inittab[i].name)
{
printf("name[%d]=>%s\n",i,PyImport_Inittab[i].name);
i++;
}
#endif
Py_Initialize
();
PyRun_SimpleString
(
"import sys
\n
"
"sys.path.append(
\"
.
\"
)
\n
"
"import kicad,pcbnew
\n
"
"from time import time,ctime
\n
"
"print 'Today is',ctime(time())
\n
"
);
InitEDA_Appl
(
wxT
(
"Pcbnew"
),
APP_PCBNEW_T
);
InitEDA_Appl
(
wxT
(
"Pcbnew"
),
APP_PCBNEW_T
);
...
@@ -253,7 +202,7 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
...
@@ -253,7 +202,7 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
*/
*/
frame
->
SetFocus
();
frame
->
SetFocus
();
frame
->
GetCanvas
()
->
SetFocus
();
frame
->
GetCanvas
()
->
SetFocus
();
st_board
=
frame
->
GetBoard
(
);
pythonSetPcbEditFrame
(
frame
);
DIALOG_SCRIPTING
*
sw
=
new
DIALOG_SCRIPTING
(
frame
);
DIALOG_SCRIPTING
*
sw
=
new
DIALOG_SCRIPTING
(
frame
);
sw
->
Show
(
true
);
sw
->
Show
(
true
);
return
true
;
return
true
;
...
...
pcbnew/scripting/kicad.i
View file @
ec5757a4
%module kicad
//
%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;
%nodefaultctor EDA_ITEM;
...
@@ -17,7 +23,10 @@
...
@@ -17,7 +23,10 @@
#include <dlist.h>
#include <dlist.h>
#include <base_struct.h>
#include <base_struct.h>
#include <common.h>
#include <common.h>
#include <wx_helpers.h>
#include <wx_python_helpers.h>
#include <cstddef>
#include <vector>
using namespace std;
%}
%}
...
@@ -25,8 +34,12 @@
...
@@ -25,8 +34,12 @@
%include <base_struct.h>
%include <base_struct.h>
%include <common.h>
%include <common.h>
/* all the wx wrappers for wxString, wxPoint, wxRect, wxChar .. */
%include <wx.i>
%include <wx.i>
/*
namespace std
{
%template(intVector) vector<int>;
}
*/
pcbnew/scripting/pcbnew.i
View file @
ec5757a4
%module pcbnew
%module pcbnew
%import "kicad.i"
%include "kicad.i"
%{
%{
#include <wx_python_helpers.h>
#include <class_board_item.h>
#include <class_board_item.h>
#include <class_board.h>
#include <class_board.h>
#include <class_module.h>
#include <class_module.h>
#include <class_track.h>
#include <class_track.h>
#include <class_pad.h>
#include <class_pad.h>
#include <class_netinfo.h>
#include <class_pcb_text.h>
#include <class_dimension.h>
#include <dlist.h>
#include <dlist.h>
#include <wx_helpers.h>
BOARD *GetBoard();
BOARD *GetBoard();
%}
%}
#ifdef BUILD_WITH_PLUGIN
%{
#include <io_mgr.h>
#include <kicad_plugin.h>
%}
#endif
%include <class_board_item.h>
%include <class_board_item.h>
%include <class_board.h>
%include <class_board.h>
%include <class_module.h>
%include <class_module.h>
%include <class_track.h>
%include <class_track.h>
%include <class_pad.h>
%include <class_pad.h>
%include <class_netinfo.h>
%include <class_pcb_text.h>
%include <class_dimension.h>
%include <dlist.h>
%include <dlist.h>
%rename(item) operator BOARD_ITEM*;
#ifdef BUILD_WITH_PLUGIN
%
rename(item) operator TRACK*;
%
include <io_mgr.h>
%
rename(item) operator D_PAD*;
%
include <kicad_plugin.h>
%rename(item) operator MODULE*;
#endif
%rename(Get) operator BOARD_ITEM*;
%rename(Get) operator TRACK*;
%rename(Get) operator D_PAD*;
%rename(Get) operator MODULE*;
BOARD *GetBoard();
BOARD *GetBoard();
// se must translate C++ templates to scripting languages
%template(BOARD_ITEM_List) DLIST<BOARD_ITEM>;
%template(BOARD_ITEM_List) DLIST<BOARD_ITEM>;
%template(MODULE_List) DLIST<MODULE>;
%template(MODULE_List) DLIST<MODULE>;
...
@@ -37,4 +59,3 @@ BOARD *GetBoard();
...
@@ -37,4 +59,3 @@ BOARD *GetBoard();
%template(PAD_List) DLIST<D_PAD>;
%template(PAD_List) DLIST<D_PAD>;
pcbnew/scripting/python_scripting.cpp
0 → 100644
View file @
ec5757a4
#include <python_scripting.h>
/* init functions defined by swig */
extern
"C"
void
init_kicad
(
void
);
extern
"C"
void
init_pcbnew
(
void
);
/* python inittab that links module names to module init functions
* we will rebuild it to include the original python modules plus
* our own ones
*/
struct
_inittab
SwigImportInittab
[
1000
];
static
int
SwigNumModules
=
0
;
/* Add a name + initfuction to our SwigImportInittab */
static
void
swigAddModule
(
const
char
*
name
,
void
(
*
initfunc
)())
{
SwigImportInittab
[
SwigNumModules
].
name
=
(
char
*
)
name
;
SwigImportInittab
[
SwigNumModules
].
initfunc
=
initfunc
;
SwigNumModules
++
;
SwigImportInittab
[
SwigNumModules
].
name
=
(
char
*
)
0
;
SwigImportInittab
[
SwigNumModules
].
initfunc
=
0
;
}
/* Add the builting python modules */
static
void
swigAddBuiltin
()
{
int
i
=
0
;
while
(
PyImport_Inittab
[
i
].
name
)
{
swigAddModule
(
PyImport_Inittab
[
i
].
name
,
PyImport_Inittab
[
i
].
initfunc
);
i
++
;
}
}
static
void
swigAddModules
()
{
//swigAddModule("_kicad",init_kicad);
swigAddModule
(
"_pcbnew"
,
init_pcbnew
);
}
static
void
swigSwitchPythonBuiltin
()
{
PyImport_Inittab
=
SwigImportInittab
;
}
static
PCB_EDIT_FRAME
*
PcbEditFrame
=
NULL
;
BOARD
*
GetBoard
()
{
if
(
PcbEditFrame
)
return
PcbEditFrame
->
GetBoard
();
else
return
NULL
;
}
void
pythonSetPcbEditFrame
(
PCB_EDIT_FRAME
*
aPCBEdaFrame
)
{
PcbEditFrame
=
aPCBEdaFrame
;
}
void
pcbnewInitPythonScripting
()
{
swigAddBuiltin
();
swigAddModules
();
swigSwitchPythonBuiltin
();
#if 0
/* print the list of modules available from python */
while(PyImport_Inittab[i].name)
{
printf("name[%d]=>%s\n",i,PyImport_Inittab[i].name);
i++;
}
#endif
Py_Initialize
();
/* setup the scripting path, we may need to add the installation path
of kicad here */
PyRun_SimpleString
(
"import sys
\n
"
"sys.path.append(
\"
.
\"
)
\n
"
"import pcbnew
\n
"
);
}
pcbnew/scripting/python_scripting.h
0 → 100644
View file @
ec5757a4
#ifndef __PYTHON_SCRIPTING_H
#define __PYTHON_SCRIPTING_H
#include <wxPcbStruct.h>
#include <Python.h>
void
pythonSetPcbEditFrame
(
PCB_EDIT_FRAME
*
aPCBEdaFrame
);
void
pcbnewInitPythonScripting
(
void
);
#endif
pcbnew/scripting/wx.i
View file @
ec5757a4
%{
%{
#include <wx_helpers.h>
#include <wx_
python_
helpers.h>
%}
%}
// encoding setup, ascii by default ///////////////////////////////////////////
// encoding setup, ascii by default ///////////////////////////////////////////
...
...
pcbnew/scripting/helpers.cpp
→
pcbnew/scripting/
wx_python_
helpers.cpp
View file @
ec5757a4
File moved
pcbnew/scripting/wx_helpers.h
→
pcbnew/scripting/wx_
python_
helpers.h
View file @
ec5757a4
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment