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
3dacab96
Commit
3dacab96
authored
Mar 05, 2012
by
Miguel Angel Ajo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wxPoint + more lists
parent
b21dbd95
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
3 deletions
+98
-3
kicad.i
pcbnew/scripting/kicad.i
+12
-0
pcbnew.i
pcbnew/scripting/pcbnew.i
+14
-3
test1.py
pcbnew/scripting/tests/test1.py
+14
-0
wx.i
pcbnew/scripting/wx.i
+58
-0
No files found.
pcbnew/scripting/kicad.i
View file @
3dacab96
%module kicad
%module kicad
%nodefaultctor EDA_ITEM;
%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 InitKiCadAbout;
%ignore GetCommandOptions;
%ignore GetCommandOptions;
...
@@ -16,4 +25,7 @@
...
@@ -16,4 +25,7 @@
%include <common.h>
%include <common.h>
%include <wx.i>
pcbnew/scripting/pcbnew.i
View file @
3dacab96
%module pcbnew
%module pcbnew
%import "kicad.i"
%import "kicad.i"
%{
%{
#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 <dlist.h>
BOARD *GetBoard();
BOARD *GetBoard();
...
@@ -17,12 +17,23 @@
...
@@ -17,12 +17,23 @@
%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 <dlist.h>
%rename(item) operator BOARD_ITEM*;
%rename(item) operator TRACK*;
%rename(item) operator D_PAD*;
%rename(item) operator MODULE*;
BOARD *GetBoard();
BOARD *GetBoard();
/*%template(BOARD_ITEM_List) DLIST<BOARD_ITEM>;
%template(BOARD_ITEM_List) DLIST<BOARD_ITEM>;
%template(MODULE_List) DLIST<MODULE>;
%template(MODULE_List) DLIST<MODULE>;
%template(TRACK_List) DLIST<TRACK>;
%template(TRACK_List) DLIST<TRACK>;
%template(PAD_List) DLIST<D_PAD>;
%template(PAD_List) DLIST<D_PAD>;
*/
pcbnew/scripting/tests/test1.py
0 → 100644
View file @
3dacab96
pcb
=
pcbnew
.
GetBoard
()
m
=
pcb
.
m_Modules
.
item
()
while
m
:
print
m
.
GetPosition
()
p
=
m
.
m_Pads
.
item
()
while
p
:
print
"p=>"
,
p
.
GetPosition
(),
p
.
GetPadName
()
print
p
.
GetPosition
()
p
=
p
.
Next
()
m
=
m
.
Next
()
pcbnew/scripting/wx.i
0 → 100644
View file @
3dacab96
class wxPoint
{
public:
int x, y;
wxPoint(int xx, int yy);
~wxPoint();
%extend {
wxPoint __add__(const wxPoint& pt) {
return *self + pt;
}
wxPoint __sub__(const wxPoint& pt) {
return *self - pt;
}
void Set(long x, long y) {
self->x = x;
self->y = y;
}
PyObject* Get() {
//wxPyBlock_t blocked = wxPyBeginBlockThreads();
PyObject* tup = PyTuple_New(2);
PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
//wxPyEndBlockThreads(blocked);
return tup;
}
}
%pythoncode {
def __eq__(self,other): return (self.x==other.x and self.y==other.y)
def __ne__(self,other): return not (self==other)
def __str__(self): return str(self.Get())
def __repr__(self): return 'wx.Point'+str(self.Get())
def __len__(self): return len(self.Get())
def __getitem__(self, index): return self.Get()[index]
def __setitem__(self, index, val):
if index == 0: self.x = val
elif index == 1: self.y = val
else: raise IndexError
def __nonzero__(self): return self.Get() != (0,0)
__safe_for_unpickling__ = True
}
};
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