diff --git a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp index d93711f0f2..798529aa39 100644 --- a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp +++ b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp @@ -55,7 +55,7 @@ void DIALOG_FOOTPRINT_WIZARD_LIST::OnCellWizardClick( wxGridEvent& event ) { int click_row = event.GetRow(); m_FootprintWizard = FOOTPRINT_WIZARDS::GetWizard(click_row); - + m_footprintWizardsGrid->SelectRow(event.GetRow(),false); } FOOTPRINT_WIZARD* DIALOG_FOOTPRINT_WIZARD_LIST::GetWizard() diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 0446804350..9c21caa2fa 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -399,6 +399,18 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnParameterList( wxCommandEvent& event ) SetCurItem( NULL ); // Delete the current footprint GetBoard()->m_Modules.DeleteAll(); + MODULE *m = m_FootprintWizard->GetModule(); + if (m) + { + /* Here we should make a copy of the object before adding to board*/ + m->SetParent(GetBoard()); + GetBoard()->m_Modules.Append(m); + } + else + { + printf ("m_FootprintWizard->GetModule() returns NULL\n"); + } + DisplayWizardInfos(); Zoom_Automatique( false ); m_canvas->Refresh(); diff --git a/pcbnew/scripting/module.i b/pcbnew/scripting/module.i index 6443a630cd..0af8f725c6 100644 --- a/pcbnew/scripting/module.i +++ b/pcbnew/scripting/module.i @@ -95,3 +95,22 @@ def FootprintIsWritable(lpath): } + +%{ + MODULE *PyModule_to_MODULE(PyObject *obj0) + { + void *argp; + int res1 = SWIG_ConvertPtr(obj0, &argp,SWIGTYPE_p_MODULE, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + SWIG_exception_fail(SWIG_ArgError(res1), "Converting object to MODULE*"); + } + + return (MODULE*)argp; + + fail: + return NULL; + + } + +%} \ No newline at end of file diff --git a/pcbnew/scripting/pcbnew_footprint_wizards.cpp b/pcbnew/scripting/pcbnew_footprint_wizards.cpp index f7142a613b..c2052ff582 100644 --- a/pcbnew/scripting/pcbnew_footprint_wizards.cpp +++ b/pcbnew/scripting/pcbnew_footprint_wizards.cpp @@ -176,8 +176,14 @@ wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterNames(int aPage) wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterValues(int aPage) { - wxArrayString a; - return a; + PyObject *arglist; + wxArrayString ret; + + arglist = Py_BuildValue("(i)", aPage); + ret = CallRetArrayStrMethod("GetParameterValues",arglist); + Py_DECREF(arglist); + + return ret; } wxString PYTHON_FOOTPRINT_WIZARD::SetParameterValues(int aPage,wxArrayString& aValues) @@ -186,9 +192,27 @@ wxString PYTHON_FOOTPRINT_WIZARD::SetParameterValues(int aPage,wxArrayString& aV return ret; } +/* this is a SWIG function declaration -from module.i*/ +MODULE *PyModule_to_MODULE(PyObject *obj0); + MODULE *PYTHON_FOOTPRINT_WIZARD::GetModule() { - return NULL; + PyObject *result, *obj; + result = CallMethod("GetModule",NULL); + if (!result) return NULL; + + obj = PyObject_GetAttrString(result, "this"); + if (PyErr_Occurred()) + { + PyObject *t, *v, *b; + PyErr_Fetch(&t, &v, &b); + printf ("calling GetModule()\n"); + printf ("Exception: %s\n",PyString_AsString(PyObject_Str(v))); + printf (" : %s\n",PyString_AsString(PyObject_Str(b))); + } + + + return PyModule_to_MODULE(obj); } diff --git a/pcbnew/scripting/pcbnew_footprint_wizards.h b/pcbnew/scripting/pcbnew_footprint_wizards.h index 5faca66e31..bd951fa4a2 100644 --- a/pcbnew/scripting/pcbnew_footprint_wizards.h +++ b/pcbnew/scripting/pcbnew_footprint_wizards.h @@ -9,6 +9,8 @@ #include #include + + class PYTHON_FOOTPRINT_WIZARD: public FOOTPRINT_WIZARD { diff --git a/pcbnew/scripting/plugins/fpc_footprint_wizard.py b/pcbnew/scripting/plugins/fpc_footprint_wizard.py index 725da1a026..4abd3766fa 100644 --- a/pcbnew/scripting/plugins/fpc_footprint_wizard.py +++ b/pcbnew/scripting/plugins/fpc_footprint_wizard.py @@ -16,11 +16,13 @@ class FPCFootprintWizard(FootprintWizardPlugin): def smdRectPad(self,module,size,pos,name): pad = D_PAD(module) + # print "smdRectPad( size=",size,"pos=",pos,"name=",name,")" pad.SetSize(size) pad.SetShape(PAD_RECT) pad.SetAttribute(PAD_SMD) pad.SetLayerMask(PAD_SMD_DEFAULT_LAYERS) pad.SetPos0(pos) + pad.SetPosition(pos) pad.SetPadName(name) return pad @@ -43,7 +45,7 @@ class FPCFootprintWizard(FootprintWizardPlugin): module = MODULE(None) module.SetReference("FPC"+str(pads)) # give it a reference name module.m_Reference.SetPos0(wxPointMM(-1,-1)) - + module.m_Reference.SetPosition(wxPointMM(-1,-1)) # create a pad array and add it to the module for n in range (0,pads): @@ -75,6 +77,7 @@ class FPCFootprintWizard(FootprintWizardPlugin): module.SetLibRef("FPC"+str(pads)) self.module = module + # print "Module built and set:", module # create our footprint wizard fpc_wizard = FPCFootprintWizard()