Add vector3 to swig
Fixes regression in 7.0 making fp 3d model offsets not accessible in python Fixes https://gitlab.com/kicad/code/kicad/-/issues/14179
This commit is contained in:
parent
10d1ba59d8
commit
88062c5fc3
|
@ -34,13 +34,18 @@
|
||||||
|
|
||||||
%rename(getWxPoint) operator wxPoint;
|
%rename(getWxPoint) operator wxPoint;
|
||||||
%rename(getWxSize) operator wxSize;
|
%rename(getWxSize) operator wxSize;
|
||||||
|
%{
|
||||||
#include <math/vector2d.h>
|
#include <math/vector2d.h>
|
||||||
%include <math/vector2d.h>
|
#include <math/vector3.h>
|
||||||
#include <math/box2.h>
|
#include <math/box2.h>
|
||||||
|
%}
|
||||||
|
%include <math/vector2d.h>
|
||||||
|
%include <math/vector3.h>
|
||||||
%include <math/box2.h>
|
%include <math/box2.h>
|
||||||
|
|
||||||
%template(VECTOR2I) VECTOR2<int>;
|
%template(VECTOR2I) VECTOR2<int>;
|
||||||
%template(VECTOR2I_EXTENDED_TYPE) VECTOR2_TRAITS<int>;
|
%template(VECTOR2I_EXTENDED_TYPE) VECTOR2_TRAITS<int>;
|
||||||
|
%template(VECTOR3D) VECTOR3<double>;
|
||||||
%template(BOX2I) BOX2<VECTOR2I>;
|
%template(BOX2I) BOX2<VECTOR2I>;
|
||||||
|
|
||||||
%extend VECTOR2<int>
|
%extend VECTOR2<int>
|
||||||
|
@ -74,3 +79,38 @@
|
||||||
|
|
||||||
%}
|
%}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%extend VECTOR3<double>
|
||||||
|
{
|
||||||
|
void Set(double x, double y, double z) { self->x = x; self->y = y; self->z = z; }
|
||||||
|
|
||||||
|
PyObject* Get()
|
||||||
|
{
|
||||||
|
PyObject* tup = PyTuple_New(3);
|
||||||
|
PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
|
||||||
|
PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
|
||||||
|
PyTuple_SET_ITEM(tup, 2, PyFloat_FromDouble(self->z));
|
||||||
|
return tup;
|
||||||
|
}
|
||||||
|
|
||||||
|
%pythoncode
|
||||||
|
%{
|
||||||
|
def __eq__(self,other): return (self.x==other.x and self.y==other.y and self.z==other.z)
|
||||||
|
def __ne__(self,other): return not (self==other)
|
||||||
|
def __str__(self): return str(self.Get())
|
||||||
|
def __repr__(self): return 'VECTOR3D'+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
|
||||||
|
elif index == 2:
|
||||||
|
self.z = val
|
||||||
|
else:
|
||||||
|
raise IndexError
|
||||||
|
def __nonzero__(self): return self.Get() != (0, 0, 0)
|
||||||
|
|
||||||
|
%}
|
||||||
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
%rename(GetPropertiesNative) FOOTPRINT::GetProperties;
|
%rename(GetPropertiesNative) FOOTPRINT::GetProperties;
|
||||||
%rename(GetPropertyNative) FOOTPRINT::GetProperty;
|
%rename(GetPropertyNative) FOOTPRINT::GetProperty;
|
||||||
%rename(SetPropertiesNative) FOOTPRINT::SetProperties;
|
%rename(SetPropertiesNative) FOOTPRINT::SetProperties;
|
||||||
%rename(MODULE_3D_SETTINGS_VECTOR3D) MODULE_3D_SETTINGS::VECTOR3D;
|
|
||||||
%feature("flatnested");
|
%feature("flatnested");
|
||||||
%include footprint.h
|
%include footprint.h
|
||||||
%feature("flatnested", "");
|
%feature("flatnested", "");
|
||||||
|
|
Loading…
Reference in New Issue