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

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

parent eff50232
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -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()
+12 −0
Original line number Original line Diff line number Diff line
@@ -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();
+19 −0
Original line number Original line Diff line number Diff line
@@ -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
+27 −3
Original line number Original line Diff line number Diff line
@@ -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
    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);
}
}




+2 −0
Original line number Original line Diff line number Diff line
@@ -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
{
{


Loading