Commit 351e08c8 authored by Miguel Angel Ajo's avatar Miguel Angel Ajo

Footprint wizard UI gets the module from python wizard, and show it

parent eff50232
...@@ -55,7 +55,7 @@ void DIALOG_FOOTPRINT_WIZARD_LIST::OnCellWizardClick( wxGridEvent& event ) ...@@ -55,7 +55,7 @@ void DIALOG_FOOTPRINT_WIZARD_LIST::OnCellWizardClick( wxGridEvent& event )
{ {
int click_row = event.GetRow(); int click_row = event.GetRow();
m_FootprintWizard = FOOTPRINT_WIZARDS::GetWizard(click_row); m_FootprintWizard = FOOTPRINT_WIZARDS::GetWizard(click_row);
m_footprintWizardsGrid->SelectRow(event.GetRow(),false);
} }
FOOTPRINT_WIZARD* DIALOG_FOOTPRINT_WIZARD_LIST::GetWizard() FOOTPRINT_WIZARD* DIALOG_FOOTPRINT_WIZARD_LIST::GetWizard()
......
...@@ -399,6 +399,18 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnParameterList( wxCommandEvent& event ) ...@@ -399,6 +399,18 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnParameterList( wxCommandEvent& event )
SetCurItem( NULL ); SetCurItem( NULL );
// Delete the current footprint // Delete the current footprint
GetBoard()->m_Modules.DeleteAll(); 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(); DisplayWizardInfos();
Zoom_Automatique( false ); Zoom_Automatique( false );
m_canvas->Refresh(); m_canvas->Refresh();
......
...@@ -95,3 +95,22 @@ def FootprintIsWritable(lpath): ...@@ -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
...@@ -176,8 +176,14 @@ wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterNames(int aPage) ...@@ -176,8 +176,14 @@ wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterNames(int aPage)
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterValues(int aPage) wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterValues(int aPage)
{ {
wxArrayString a; PyObject *arglist;
return a; 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) wxString PYTHON_FOOTPRINT_WIZARD::SetParameterValues(int aPage,wxArrayString& aValues)
...@@ -186,9 +192,27 @@ wxString PYTHON_FOOTPRINT_WIZARD::SetParameterValues(int aPage,wxArrayString& aV ...@@ -186,9 +192,27 @@ wxString PYTHON_FOOTPRINT_WIZARD::SetParameterValues(int aPage,wxArrayString& aV
return ret; return ret;
} }
/* this is a SWIG function declaration -from module.i*/
MODULE *PyModule_to_MODULE(PyObject *obj0);
MODULE *PYTHON_FOOTPRINT_WIZARD::GetModule() 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);
} }
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include <vector> #include <vector>
#include <class_footprint_wizard.h> #include <class_footprint_wizard.h>
class PYTHON_FOOTPRINT_WIZARD: public FOOTPRINT_WIZARD class PYTHON_FOOTPRINT_WIZARD: public FOOTPRINT_WIZARD
{ {
......
...@@ -16,11 +16,13 @@ class FPCFootprintWizard(FootprintWizardPlugin): ...@@ -16,11 +16,13 @@ class FPCFootprintWizard(FootprintWizardPlugin):
def smdRectPad(self,module,size,pos,name): def smdRectPad(self,module,size,pos,name):
pad = D_PAD(module) pad = D_PAD(module)
# print "smdRectPad( size=",size,"pos=",pos,"name=",name,")"
pad.SetSize(size) pad.SetSize(size)
pad.SetShape(PAD_RECT) pad.SetShape(PAD_RECT)
pad.SetAttribute(PAD_SMD) pad.SetAttribute(PAD_SMD)
pad.SetLayerMask(PAD_SMD_DEFAULT_LAYERS) pad.SetLayerMask(PAD_SMD_DEFAULT_LAYERS)
pad.SetPos0(pos) pad.SetPos0(pos)
pad.SetPosition(pos)
pad.SetPadName(name) pad.SetPadName(name)
return pad return pad
...@@ -43,7 +45,7 @@ class FPCFootprintWizard(FootprintWizardPlugin): ...@@ -43,7 +45,7 @@ class FPCFootprintWizard(FootprintWizardPlugin):
module = MODULE(None) module = MODULE(None)
module.SetReference("FPC"+str(pads)) # give it a reference name module.SetReference("FPC"+str(pads)) # give it a reference name
module.m_Reference.SetPos0(wxPointMM(-1,-1)) module.m_Reference.SetPos0(wxPointMM(-1,-1))
module.m_Reference.SetPosition(wxPointMM(-1,-1))
# create a pad array and add it to the module # create a pad array and add it to the module
for n in range (0,pads): for n in range (0,pads):
...@@ -75,6 +77,7 @@ class FPCFootprintWizard(FootprintWizardPlugin): ...@@ -75,6 +77,7 @@ class FPCFootprintWizard(FootprintWizardPlugin):
module.SetLibRef("FPC"+str(pads)) module.SetLibRef("FPC"+str(pads))
self.module = module self.module = module
# print "Module built and set:", module
# create our footprint wizard # create our footprint wizard
fpc_wizard = FPCFootprintWizard() fpc_wizard = FPCFootprintWizard()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment