wxPoint + more lists
This commit is contained in:
parent
b21dbd9561
commit
3dacab9691
|
@ -1,6 +1,15 @@
|
|||
%module kicad
|
||||
|
||||
%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;
|
||||
|
||||
|
@ -16,4 +25,7 @@
|
|||
%include <common.h>
|
||||
|
||||
|
||||
%include <wx.i>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
%module pcbnew
|
||||
%import "kicad.i"
|
||||
|
||||
|
||||
%{
|
||||
#include <class_board_item.h>
|
||||
#include <class_board.h>
|
||||
#include <class_module.h>
|
||||
#include <class_track.h>
|
||||
#include <class_pad.h>
|
||||
#include <dlist.h>
|
||||
|
||||
|
||||
BOARD *GetBoard();
|
||||
|
@ -17,12 +17,23 @@
|
|||
%include <class_board.h>
|
||||
%include <class_module.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();
|
||||
|
||||
/*%template(BOARD_ITEM_List) DLIST<BOARD_ITEM>;
|
||||
|
||||
|
||||
%template(BOARD_ITEM_List) DLIST<BOARD_ITEM>;
|
||||
%template(MODULE_List) DLIST<MODULE>;
|
||||
%template(TRACK_List) DLIST<TRACK>;
|
||||
%template(PAD_List) DLIST<D_PAD>;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
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()
|
||||
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
|
||||
|
||||
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
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue