Allow plugins to be reloaded without closing/opening pcbnew, next step is plugin editor, just a few lines away...
This commit is contained in:
parent
ecc6a69f4f
commit
9a8baa00f2
|
@ -31,48 +31,73 @@
|
||||||
#include "class_footprint_wizard.h"
|
#include "class_footprint_wizard.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
FOOTPRINT_WIZARD::~FOOTPRINT_WIZARD()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT_WIZARD::register_wizard()
|
void FOOTPRINT_WIZARD::register_wizard()
|
||||||
{
|
{
|
||||||
FOOTPRINT_WIZARDS::register_wizard( this );
|
FOOTPRINT_WIZARDS::register_wizard( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<FOOTPRINT_WIZARD*> FOOTPRINT_WIZARDS::m_FootprintWizards;
|
|
||||||
|
std::vector<FOOTPRINT_WIZARD*> FOOTPRINT_WIZARDS::m_FootprintWizards;
|
||||||
|
|
||||||
FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( int aIndex )
|
FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( int aIndex )
|
||||||
{
|
{
|
||||||
return m_FootprintWizards[aIndex];
|
return m_FootprintWizards[aIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( wxString aName )
|
FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( wxString aName )
|
||||||
{
|
{
|
||||||
int max = GetSize();
|
int max = GetSize();
|
||||||
|
|
||||||
for( int i=0; i<max; i++ )
|
for( int i = 0; i<max; i++ )
|
||||||
{
|
{
|
||||||
FOOTPRINT_WIZARD *wizard = GetWizard( i );
|
FOOTPRINT_WIZARD* wizard = GetWizard( i );
|
||||||
|
|
||||||
wxString name = wizard->GetName();
|
wxString name = wizard->GetName();
|
||||||
|
|
||||||
if ( name.Cmp( aName ) )
|
if( name.Cmp( aName )==0 )
|
||||||
return wizard;
|
return wizard;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int FOOTPRINT_WIZARDS::GetSize()
|
int FOOTPRINT_WIZARDS::GetSize()
|
||||||
{
|
{
|
||||||
return m_FootprintWizards.size();
|
return m_FootprintWizards.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FOOTPRINT_WIZARDS::register_wizard(FOOTPRINT_WIZARD *aWizard)
|
|
||||||
|
void FOOTPRINT_WIZARDS::register_wizard( FOOTPRINT_WIZARD* aWizard )
|
||||||
{
|
{
|
||||||
|
|
||||||
wxString name = aWizard->GetName();
|
wxString name = aWizard->GetName();
|
||||||
m_FootprintWizards.push_back( aWizard );
|
|
||||||
|
|
||||||
|
m_FootprintWizards.push_back( aWizard );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FOOTPRINT_WIZARDS::deregister_object( void* aObject )
|
||||||
|
{
|
||||||
|
int max = GetSize();
|
||||||
|
|
||||||
|
for( int i = 0; i<max; i++ )
|
||||||
|
{
|
||||||
|
FOOTPRINT_WIZARD* wizard = GetWizard( i );
|
||||||
|
|
||||||
|
if( wizard->GetObject() == aObject )
|
||||||
|
{
|
||||||
|
m_FootprintWizards.erase( m_FootprintWizards.begin() + i );
|
||||||
|
delete wizard;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CLASS_FOOTPRINT_WIZARD_H
|
#ifndef CLASS_FOOTPRINT_WIZARD_H
|
||||||
#define CLASS_FOOTPRINT_WIZARD_H
|
#define CLASS_FOOTPRINT_WIZARD_H
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <wxPcbStruct.h>
|
#include <wxPcbStruct.h>
|
||||||
|
|
||||||
|
@ -39,48 +39,47 @@
|
||||||
* derive */
|
* derive */
|
||||||
class FOOTPRINT_WIZARD
|
class FOOTPRINT_WIZARD
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FOOTPRINT_WIZARD() {}
|
FOOTPRINT_WIZARD() {}
|
||||||
~FOOTPRINT_WIZARD() {}
|
virtual ~FOOTPRINT_WIZARD();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetName
|
* Function GetName
|
||||||
* @return the name of the wizard
|
* @return the name of the wizard
|
||||||
*/
|
*/
|
||||||
virtual wxString GetName()=0;
|
virtual wxString GetName() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetImage
|
* Function GetImage
|
||||||
* @return an svg image of the wizard to be rendered
|
* @return an svg image of the wizard to be rendered
|
||||||
*/
|
*/
|
||||||
virtual wxString GetImage()=0;
|
virtual wxString GetImage() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetDescription
|
* Function GetDescription
|
||||||
* @return a description of the footprint wizard
|
* @return a description of the footprint wizard
|
||||||
*/
|
*/
|
||||||
virtual wxString GetDescription()=0;
|
virtual wxString GetDescription() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetNumParameterPages
|
* Function GetNumParameterPages
|
||||||
* @return the number of parameter pages that this wizard will show to the user
|
* @return the number of parameter pages that this wizard will show to the user
|
||||||
*/
|
*/
|
||||||
virtual int GetNumParameterPages()=0;
|
virtual int GetNumParameterPages() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetParameterPageName
|
* Function GetParameterPageName
|
||||||
* @param aPage is the page we want the name of
|
* @param aPage is the page we want the name of
|
||||||
* @return a string with the page name
|
* @return a string with the page name
|
||||||
*/
|
*/
|
||||||
virtual wxString GetParameterPageName(int aPage)=0;
|
virtual wxString GetParameterPageName( int aPage ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetParameterNames
|
* Function GetParameterNames
|
||||||
* @param aPage is the page we want the parameter names of
|
* @param aPage is the page we want the parameter names of
|
||||||
* @return an array string with the parameter names on a certain page
|
* @return an array string with the parameter names on a certain page
|
||||||
*/
|
*/
|
||||||
virtual wxArrayString GetParameterNames(int aPage)=0;
|
virtual wxArrayString GetParameterNames( int aPage ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetParameterTypes
|
* Function GetParameterTypes
|
||||||
|
@ -88,7 +87,7 @@ public:
|
||||||
* @return an array string with the parameter types on a certain page
|
* @return an array string with the parameter types on a certain page
|
||||||
* "IU" for internal units, "UNITS" for units (0,1,2,3...,N)
|
* "IU" for internal units, "UNITS" for units (0,1,2,3...,N)
|
||||||
*/
|
*/
|
||||||
virtual wxArrayString GetParameterTypes(int aPage)=0;
|
virtual wxArrayString GetParameterTypes( int aPage ) = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,14 +95,14 @@ public:
|
||||||
* @param aPage is the page we want the parameter values of
|
* @param aPage is the page we want the parameter values of
|
||||||
* @return an array of parameter values
|
* @return an array of parameter values
|
||||||
*/
|
*/
|
||||||
virtual wxArrayString GetParameterValues(int aPage)=0;
|
virtual wxArrayString GetParameterValues( int aPage ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetParameterErrors
|
* Function GetParameterErrors
|
||||||
* @param aPage is the page we want to know the errors of
|
* @param aPage is the page we want to know the errors of
|
||||||
* @return an array of errors (if any) for the parameters, empty strings for OK parameters
|
* @return an array of errors (if any) for the parameters, empty strings for OK parameters
|
||||||
*/
|
*/
|
||||||
virtual wxArrayString GetParameterErrors(int aPage)=0;
|
virtual wxArrayString GetParameterErrors( int aPage ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SetParameterValues
|
* Function SetParameterValues
|
||||||
|
@ -111,14 +110,21 @@ public:
|
||||||
* @param aValues are the values we want to set into the parameters
|
* @param aValues are the values we want to set into the parameters
|
||||||
* @return an array of parameter values
|
* @return an array of parameter values
|
||||||
*/
|
*/
|
||||||
virtual wxString SetParameterValues(int aPage,wxArrayString& aValues)=0;
|
virtual wxString SetParameterValues( int aPage, wxArrayString& aValues ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetModule
|
* Function GetModule
|
||||||
* This method builds the module itself and returns it to the caller function
|
* This method builds the module itself and returns it to the caller function
|
||||||
* @return PCB module built from the parameters given to the class
|
* @return PCB module built from the parameters given to the class
|
||||||
*/
|
*/
|
||||||
virtual MODULE *GetModule()=0;
|
virtual MODULE* GetModule() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function GetObject
|
||||||
|
* This method gets the pointer to the object from where this wizard constructs
|
||||||
|
* @return it's a void pointer, as it could be a PyObject or any other
|
||||||
|
*/
|
||||||
|
virtual void* GetObject() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function register_wizard
|
* Function register_wizard
|
||||||
|
@ -126,8 +132,7 @@ public:
|
||||||
* the FOOTPRINT_WIZARDS singleton manager
|
* the FOOTPRINT_WIZARDS singleton manager
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void register_wizard();
|
void register_wizard();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,10 +140,9 @@ class FOOTPRINT_WIZARDS
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* FOOTPRINT_WIZARD system wide static list
|
* FOOTPRINT_WIZARD system wide static list
|
||||||
*/
|
*/
|
||||||
static std::vector<FOOTPRINT_WIZARD*> m_FootprintWizards;
|
static std::vector<FOOTPRINT_WIZARD*> m_FootprintWizards;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,7 +153,18 @@ public:
|
||||||
* @param aWizard is the footprint wizard to be registered
|
* @param aWizard is the footprint wizard to be registered
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void register_wizard(FOOTPRINT_WIZARD *aWizard);
|
static void register_wizard( FOOTPRINT_WIZARD* aWizard );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function deregister_object
|
||||||
|
* Anyone calls this method to deregister an object which builds a wizard,
|
||||||
|
* it will lookup on the vector calling GetObject until find, then removed
|
||||||
|
* and deleted
|
||||||
|
*
|
||||||
|
* @param aObject is the footprint wizard object to be deregistered
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static bool deregister_object( void* aObject );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetWizard
|
* Function GetWizard
|
||||||
|
@ -157,7 +172,7 @@ public:
|
||||||
* @return a wizard object by it's name or NULL if it isn't available.
|
* @return a wizard object by it's name or NULL if it isn't available.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static FOOTPRINT_WIZARD* GetWizard(wxString aName);
|
static FOOTPRINT_WIZARD* GetWizard( wxString aName );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetWizard
|
* Function GetWizard
|
||||||
|
@ -165,15 +180,13 @@ public:
|
||||||
* @param aIndex is the wizard index in list
|
* @param aIndex is the wizard index in list
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static FOOTPRINT_WIZARD* GetWizard( int aIndex );
|
static FOOTPRINT_WIZARD* GetWizard( int aIndex );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetSize
|
* Function GetSize
|
||||||
* @return the number of wizards available into the system
|
* @return the number of wizards available into the system
|
||||||
*/
|
*/
|
||||||
static int GetSize();
|
static int GetSize();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PCBNEW_FOOTPRINT_WIZARDS_H */
|
#endif /* PCBNEW_FOOTPRINT_WIZARDS_H */
|
||||||
|
|
||||||
|
|
|
@ -94,13 +94,15 @@ void FOOTPRINT_WIZARD_FRAME::DisplayWizardInfos()
|
||||||
|
|
||||||
void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
|
void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
|
||||||
{
|
{
|
||||||
if( m_FootprintWizard == NULL )
|
FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
|
||||||
|
|
||||||
|
if( !footprintWizard )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
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();
|
MODULE* m = footprintWizard->GetModule();
|
||||||
|
|
||||||
if( m )
|
if( m )
|
||||||
{
|
{
|
||||||
|
@ -112,18 +114,37 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf( "m_FootprintWizard->GetModule() returns NULL\n" );
|
printf( "footprintWizard->GetModule() returns NULL\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FOOTPRINT_WIZARD* FOOTPRINT_WIZARD_FRAME::GetMyWizard()
|
||||||
|
{
|
||||||
|
if( m_wizardName.Length()==0 )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
FOOTPRINT_WIZARD* footprintWizard = FOOTPRINT_WIZARDS::GetWizard( m_wizardName );
|
||||||
|
|
||||||
|
if( !footprintWizard )
|
||||||
|
{
|
||||||
|
wxMessageBox( _( "Couldn't reload footprint wizard" ) );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return footprintWizard;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MODULE* FOOTPRINT_WIZARD_FRAME::GetBuiltFootprint()
|
MODULE* FOOTPRINT_WIZARD_FRAME::GetBuiltFootprint()
|
||||||
{
|
{
|
||||||
if( m_FootprintWizard )
|
FOOTPRINT_WIZARD* footprintWizard = FOOTPRINT_WIZARDS::GetWizard( m_wizardName );
|
||||||
|
|
||||||
|
if( footprintWizard )
|
||||||
{
|
{
|
||||||
return m_FootprintWizard->GetModule();
|
return footprintWizard->GetModule();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -139,12 +160,17 @@ void FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard()
|
||||||
|
|
||||||
selectWizard->ShowModal();
|
selectWizard->ShowModal();
|
||||||
|
|
||||||
m_FootprintWizard = selectWizard->GetWizard();
|
FOOTPRINT_WIZARD* footprintWizard = selectWizard->GetWizard();
|
||||||
|
|
||||||
if( m_FootprintWizard )
|
if( footprintWizard )
|
||||||
{
|
{
|
||||||
m_wizardName = m_FootprintWizard->GetName();
|
m_wizardName = footprintWizard->GetName();
|
||||||
m_wizardDescription = m_FootprintWizard->GetDescription();
|
m_wizardDescription = footprintWizard->GetDescription();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_wizardName = wxT( "" );
|
||||||
|
m_wizardDescription = wxT( "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ReloadFootprint();
|
ReloadFootprint();
|
||||||
|
@ -169,12 +195,17 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event )
|
||||||
{
|
{
|
||||||
int page = m_PageList->GetSelection();
|
int page = m_PageList->GetSelection();
|
||||||
|
|
||||||
|
FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
|
||||||
|
|
||||||
|
if( !footprintWizard )
|
||||||
|
return;
|
||||||
|
|
||||||
if( page<0 )
|
if( page<0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int n = m_ParameterGrid->GetNumberRows();
|
int n = m_ParameterGrid->GetNumberRows();
|
||||||
wxArrayString arr;
|
wxArrayString arr;
|
||||||
wxArrayString ptList = m_FootprintWizard->GetParameterTypes( page );
|
wxArrayString ptList = footprintWizard->GetParameterTypes( page );
|
||||||
|
|
||||||
for( int i = 0; i<n; i++ )
|
for( int i = 0; i<n; i++ )
|
||||||
{
|
{
|
||||||
|
@ -184,8 +215,8 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event )
|
||||||
// unit convert it back from the user format
|
// unit convert it back from the user format
|
||||||
if( ptList[i]==wxT( "IU" ) )
|
if( ptList[i]==wxT( "IU" ) )
|
||||||
{
|
{
|
||||||
LOCALE_IO toggle;
|
LOCALE_IO toggle;
|
||||||
double dValue;
|
double dValue;
|
||||||
|
|
||||||
value.ToDouble( &dValue );
|
value.ToDouble( &dValue );
|
||||||
|
|
||||||
|
@ -205,7 +236,7 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event )
|
||||||
arr.Add( value );
|
arr.Add( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString res = m_FootprintWizard->SetParameterValues( page, arr );
|
wxString res = footprintWizard->SetParameterValues( page, arr );
|
||||||
|
|
||||||
ReloadFootprint();
|
ReloadFootprint();
|
||||||
DisplayWizardInfos();
|
DisplayWizardInfos();
|
||||||
|
|
|
@ -52,37 +52,39 @@
|
||||||
|
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
|
BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
|
||||||
/* Window events */
|
/* Window events */
|
||||||
EVT_CLOSE( FOOTPRINT_WIZARD_FRAME::OnCloseWindow )
|
EVT_CLOSE( FOOTPRINT_WIZARD_FRAME::OnCloseWindow )
|
||||||
EVT_SIZE( FOOTPRINT_WIZARD_FRAME::OnSize )
|
EVT_SIZE( FOOTPRINT_WIZARD_FRAME::OnSize )
|
||||||
EVT_ACTIVATE( FOOTPRINT_WIZARD_FRAME::OnActivate )
|
EVT_ACTIVATE( FOOTPRINT_WIZARD_FRAME::OnActivate )
|
||||||
|
|
||||||
/* Sash drag events */
|
/* Sash drag events */
|
||||||
EVT_SASH_DRAGGED( ID_FOOTPRINT_WIZARD_PAGES, FOOTPRINT_WIZARD_FRAME::OnSashDrag )
|
EVT_SASH_DRAGGED( ID_FOOTPRINT_WIZARD_PAGES, FOOTPRINT_WIZARD_FRAME::OnSashDrag )
|
||||||
EVT_SASH_DRAGGED( ID_FOOTPRINT_WIZARD_PARAMETERS, FOOTPRINT_WIZARD_FRAME::OnSashDrag )
|
EVT_SASH_DRAGGED( ID_FOOTPRINT_WIZARD_PARAMETERS, FOOTPRINT_WIZARD_FRAME::OnSashDrag )
|
||||||
|
|
||||||
/* Toolbar events */
|
/* Toolbar events */
|
||||||
EVT_TOOL( ID_FOOTPRINT_WIZARD_SELECT_WIZARD,
|
EVT_TOOL( ID_FOOTPRINT_WIZARD_SELECT_WIZARD,
|
||||||
FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard )
|
FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard )
|
||||||
|
|
||||||
EVT_TOOL( ID_FOOTPRINT_WIZARD_NEXT,
|
EVT_TOOL( ID_FOOTPRINT_WIZARD_NEXT,
|
||||||
FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
|
FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
|
||||||
|
|
||||||
EVT_TOOL( ID_FOOTPRINT_WIZARD_PREVIOUS,
|
EVT_TOOL( ID_FOOTPRINT_WIZARD_PREVIOUS,
|
||||||
FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
|
FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
|
||||||
|
|
||||||
EVT_TOOL( ID_FOOTPRINT_WIZARD_DONE,
|
EVT_TOOL( ID_FOOTPRINT_WIZARD_DONE,
|
||||||
FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint )
|
FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint )
|
||||||
|
|
||||||
EVT_TOOL( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW,
|
EVT_TOOL( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW,
|
||||||
FOOTPRINT_WIZARD_FRAME::Show3D_Frame )
|
FOOTPRINT_WIZARD_FRAME::Show3D_Frame )
|
||||||
|
|
||||||
/* listbox events */
|
/* listbox events */
|
||||||
EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList )
|
EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList )
|
||||||
EVT_GRID_CMD_CELL_CHANGE( ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
|
EVT_GRID_CMD_CELL_CHANGE( ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
|
||||||
FOOTPRINT_WIZARD_FRAME::ParametersUpdated )
|
FOOTPRINT_WIZARD_FRAME::ParametersUpdated )
|
||||||
|
EVT_GRID_CMD_EDITOR_HIDDEN( ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
|
||||||
|
FOOTPRINT_WIZARD_FRAME::ParametersUpdated )
|
||||||
|
|
||||||
EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset )
|
EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,7 +133,6 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( FOOTPRINT_EDIT_FRAME* parent,
|
||||||
// SetIcon( icon );
|
// SetIcon( icon );
|
||||||
|
|
||||||
m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr;
|
m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr;
|
||||||
m_FootprintWizard = NULL;
|
|
||||||
m_PageList = NULL;
|
m_PageList = NULL;
|
||||||
m_ParameterGrid = NULL;
|
m_ParameterGrid = NULL;
|
||||||
m_PageListWindow = NULL;
|
m_PageListWindow = NULL;
|
||||||
|
@ -386,15 +387,18 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
|
||||||
if( m_PageList == NULL )
|
if( m_PageList == NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( m_FootprintWizard == NULL )
|
FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
|
||||||
|
|
||||||
|
if( !footprintWizard )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
m_PageList->Clear();
|
m_PageList->Clear();
|
||||||
int max_page = m_FootprintWizard->GetNumParameterPages();
|
int max_page = footprintWizard->GetNumParameterPages();
|
||||||
|
|
||||||
for( int i = 0; i<max_page; i++ )
|
for( int i = 0; i<max_page; i++ )
|
||||||
{
|
{
|
||||||
wxString name = m_FootprintWizard->GetParameterPageName( i );
|
wxString name = footprintWizard->GetParameterPageName( i );
|
||||||
m_PageList->Append( name );
|
m_PageList->Append( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,7 +421,9 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
|
||||||
if( m_ParameterGrid == NULL )
|
if( m_ParameterGrid == NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( m_FootprintWizard == NULL )
|
FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
|
||||||
|
|
||||||
|
if( footprintWizard == NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int page = m_PageList->GetSelection();
|
int page = m_PageList->GetSelection();
|
||||||
|
@ -435,9 +441,9 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
|
||||||
m_ParameterGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
|
m_ParameterGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
|
||||||
|
|
||||||
// Get the list of names, values, and types
|
// Get the list of names, values, and types
|
||||||
wxArrayString fpList = m_FootprintWizard->GetParameterNames( page );
|
wxArrayString fpList = footprintWizard->GetParameterNames( page );
|
||||||
wxArrayString fvList = m_FootprintWizard->GetParameterValues( page );
|
wxArrayString fvList = footprintWizard->GetParameterValues( page );
|
||||||
wxArrayString ptList = m_FootprintWizard->GetParameterTypes( page );
|
wxArrayString ptList = footprintWizard->GetParameterTypes( page );
|
||||||
|
|
||||||
// Dimension the wxGrid
|
// Dimension the wxGrid
|
||||||
m_ParameterGrid->DeleteRows( 0, m_ParameterGrid->GetNumberRows() );
|
m_ParameterGrid->DeleteRows( 0, m_ParameterGrid->GetNumberRows() );
|
||||||
|
@ -580,9 +586,9 @@ void FOOTPRINT_WIZARD_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition
|
||||||
|
|
||||||
cmd.SetEventObject( this );
|
cmd.SetEventObject( this );
|
||||||
|
|
||||||
pos = screen->GetNearestGridPosition( pos );
|
pos = screen->GetNearestGridPosition( pos );
|
||||||
oldpos = screen->GetCrossHairPosition();
|
oldpos = screen->GetCrossHairPosition();
|
||||||
gridSize = screen->GetGridSize();
|
gridSize = screen->GetGridSize();
|
||||||
|
|
||||||
switch( aHotKey )
|
switch( aHotKey )
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,17 +55,15 @@ private:
|
||||||
|
|
||||||
wxSashLayoutWindow* m_ParameterGridWindow; // < List of components in the selected library
|
wxSashLayoutWindow* m_ParameterGridWindow; // < List of components in the selected library
|
||||||
wxGrid* m_ParameterGrid; // < The list of parameters
|
wxGrid* m_ParameterGrid; // < The list of parameters
|
||||||
wxSize m_ParameterGridSize; // < size of the window
|
wxSize m_ParameterGridSize; // < size of the window
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
wxSemaphore* m_Semaphore; // < != NULL if the frame must emulate a modal dialog
|
wxSemaphore* m_Semaphore; // < != NULL if the frame must emulate a modal dialog
|
||||||
wxString m_configPath; // < subpath for configuration
|
wxString m_configPath; // < subpath for configuration
|
||||||
|
|
||||||
FOOTPRINT_WIZARD* m_FootprintWizard;
|
|
||||||
protected:
|
protected:
|
||||||
wxString m_wizardName; // < name of the current wizard
|
wxString m_wizardName; // < name of the current wizard
|
||||||
wxString m_wizardDescription; // < description of the wizard
|
wxString m_wizardDescription; // < description of the wizard
|
||||||
wxString m_wizardStatus; // < current wizard status
|
wxString m_wizardStatus; // < current wizard status
|
||||||
public:
|
public:
|
||||||
FOOTPRINT_WIZARD_FRAME( FOOTPRINT_EDIT_FRAME* parent,
|
FOOTPRINT_WIZARD_FRAME( FOOTPRINT_EDIT_FRAME* parent,
|
||||||
wxSemaphore* semaphore = NULL,
|
wxSemaphore* semaphore = NULL,
|
||||||
|
@ -73,70 +71,76 @@ public:
|
||||||
|
|
||||||
~FOOTPRINT_WIZARD_FRAME();
|
~FOOTPRINT_WIZARD_FRAME();
|
||||||
|
|
||||||
MODULE* GetBuiltFootprint( void );
|
MODULE* GetBuiltFootprint( void );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void OnSize( wxSizeEvent& event );
|
void OnSize( wxSizeEvent& event );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ExportSelectedFootprint();
|
* Function ExportSelectedFootprint();
|
||||||
* will let the caller exit from the wait loop, and get the built footprint
|
* will let the caller exit from the wait loop, and get the built footprint
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void ExportSelectedFootprint( wxCommandEvent& aEvent );
|
void ExportSelectedFootprint( wxCommandEvent& aEvent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function OnSashDrag
|
* Function OnSashDrag
|
||||||
* resizes the child windows when dragging a sash window border.
|
* resizes the child windows when dragging a sash window border.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void OnSashDrag( wxSashEvent& event );
|
void OnSashDrag( wxSashEvent& event );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ReCreatePageList
|
* Function ReCreatePageList
|
||||||
* Creates or recreates the list of parameter pages for the current wizard.
|
* Creates or recreates the list of parameter pages for the current wizard.
|
||||||
* This list is sorted
|
* This list is sorted
|
||||||
*/
|
*/
|
||||||
void ReCreatePageList();
|
void ReCreatePageList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ReCreateParameterList
|
* Function ReCreateParameterList
|
||||||
* Creates the list of parameters for the current page
|
* Creates the list of parameters for the current page
|
||||||
*/
|
*/
|
||||||
void ReCreateParameterList();
|
void ReCreateParameterList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SelectFootprintWizard
|
* Function SelectFootprintWizard
|
||||||
* Shows the list of footprint wizards available into the system
|
* Shows the list of footprint wizards available into the system
|
||||||
*/
|
*/
|
||||||
void SelectFootprintWizard();
|
void SelectFootprintWizard();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ReloadFootprint
|
* Function ReloadFootprint
|
||||||
* Reloads the current footprint
|
* Reloads the current footprint
|
||||||
*/
|
*/
|
||||||
void ReloadFootprint();
|
void ReloadFootprint();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function GetMyWizard
|
||||||
|
* Reloads the wizard by name
|
||||||
|
*/
|
||||||
|
FOOTPRINT_WIZARD* GetMyWizard();
|
||||||
|
|
||||||
|
|
||||||
void Process_Special_Functions( wxCommandEvent& event );
|
void Process_Special_Functions( wxCommandEvent& event );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function DisplayWizardInfos
|
* Function DisplayWizardInfos
|
||||||
* Shows all the details about the current wizard
|
* Shows all the details about the current wizard
|
||||||
*/
|
*/
|
||||||
void DisplayWizardInfos();
|
void DisplayWizardInfos();
|
||||||
|
|
||||||
|
|
||||||
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
|
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
|
||||||
void OnCloseWindow( wxCloseEvent& Event );
|
void OnCloseWindow( wxCloseEvent& Event );
|
||||||
void ReCreateHToolbar();
|
void ReCreateHToolbar();
|
||||||
void ReCreateVToolbar();
|
void ReCreateVToolbar();
|
||||||
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
|
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
|
||||||
void ClickOnPageList( wxCommandEvent& event );
|
void ClickOnPageList( wxCommandEvent& event );
|
||||||
void OnSetRelativeOffset( wxCommandEvent& event );
|
void OnSetRelativeOffset( wxCommandEvent& event );
|
||||||
|
|
||||||
void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
|
void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function LoadSettings
|
* Function LoadSettings
|
||||||
|
@ -145,7 +149,7 @@ private:
|
||||||
* Don't forget to call this base method from any derived classes or the
|
* Don't forget to call this base method from any derived classes or the
|
||||||
* settings will not get loaded.
|
* settings will not get loaded.
|
||||||
*/
|
*/
|
||||||
void LoadSettings();
|
void LoadSettings();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SaveSettings
|
* Function SaveSettings
|
||||||
|
@ -154,7 +158,7 @@ private:
|
||||||
* Don't forget to call this base method from any derived classes or the
|
* Don't forget to call this base method from any derived classes or the
|
||||||
* settings will not get saved.
|
* settings will not get saved.
|
||||||
*/
|
*/
|
||||||
void SaveSettings();
|
void SaveSettings();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,20 +166,20 @@ private:
|
||||||
* is called when the frame frame is activate to reload the libraries and component lists
|
* is called when the frame frame is activate to reload the libraries and component lists
|
||||||
* that can be changed by the schematic editor or the library editor.
|
* that can be changed by the schematic editor or the library editor.
|
||||||
*/
|
*/
|
||||||
virtual void OnActivate( wxActivateEvent& event );
|
virtual void OnActivate( wxActivateEvent& event );
|
||||||
|
|
||||||
void SelectCurrentWizard( wxCommandEvent& event );
|
void SelectCurrentWizard( wxCommandEvent& event );
|
||||||
|
|
||||||
void ParametersUpdated( wxGridEvent& event );
|
void ParametersUpdated( wxGridEvent& event );
|
||||||
|
|
||||||
|
|
||||||
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
|
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Show3D_Frame (virtual)
|
* Function Show3D_Frame (virtual)
|
||||||
* displays 3D view of the footprint (module) being edited.
|
* displays 3D view of the footprint (module) being edited.
|
||||||
*/
|
*/
|
||||||
void Show3D_Frame( wxCommandEvent& event );
|
void Show3D_Frame( wxCommandEvent& event );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Update3D_Frame
|
* Function Update3D_Frame
|
||||||
|
@ -184,7 +188,7 @@ private:
|
||||||
* @param aForceReloadFootprint = true to reload data (default)
|
* @param aForceReloadFootprint = true to reload data (default)
|
||||||
* = false to update title only -(aftre creating the 3D viewer)
|
* = false to update title only -(aftre creating the 3D viewer)
|
||||||
*/
|
*/
|
||||||
void Update3D_Frame( bool aForceReloadFootprint = true );
|
void Update3D_Frame( bool aForceReloadFootprint = true );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Virtual functions, not used here, but needed by PCB_BASE_FRAME
|
* Virtual functions, not used here, but needed by PCB_BASE_FRAME
|
||||||
|
|
|
@ -51,10 +51,11 @@ PYTHON_FOOTPRINT_WIZARD::~PYTHON_FOOTPRINT_WIZARD()
|
||||||
|
|
||||||
PyObject* PYTHON_FOOTPRINT_WIZARD::CallMethod( const char* aMethod, PyObject* aArglist )
|
PyObject* PYTHON_FOOTPRINT_WIZARD::CallMethod( const char* aMethod, PyObject* aArglist )
|
||||||
{
|
{
|
||||||
PyLOCK lock;
|
PyLOCK lock;
|
||||||
|
|
||||||
|
PyErr_Clear();
|
||||||
// pFunc is a new reference to the desired method
|
// pFunc is a new reference to the desired method
|
||||||
PyObject* pFunc = PyObject_GetAttrString( this->m_PyWizard, aMethod );
|
PyObject* pFunc = PyObject_GetAttrString( this->m_PyWizard, aMethod );
|
||||||
|
|
||||||
if( pFunc && PyCallable_Check( pFunc ) )
|
if( pFunc && PyCallable_Check( pFunc ) )
|
||||||
{
|
{
|
||||||
|
@ -79,6 +80,8 @@ PyObject* PYTHON_FOOTPRINT_WIZARD::CallMethod( const char* aMethod, PyObject* aA
|
||||||
wxMessageBox( message,
|
wxMessageBox( message,
|
||||||
wxT( "Exception on python footprint wizard code" ),
|
wxT( "Exception on python footprint wizard code" ),
|
||||||
wxICON_ERROR | wxOK );
|
wxICON_ERROR | wxOK );
|
||||||
|
|
||||||
|
PyErr_Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( result )
|
if( result )
|
||||||
|
@ -346,7 +349,10 @@ MODULE* PYTHON_FOOTPRINT_WIZARD::GetModule()
|
||||||
PyObject* obj = PyObject_GetAttrString( result, "this" );
|
PyObject* obj = PyObject_GetAttrString( result, "this" );
|
||||||
|
|
||||||
if( PyErr_Occurred() )
|
if( PyErr_Occurred() )
|
||||||
|
{
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
|
PyErr_Clear();
|
||||||
|
}
|
||||||
|
|
||||||
MODULE* mod = PyModule_to_MODULE( obj );
|
MODULE* mod = PyModule_to_MODULE( obj );
|
||||||
|
|
||||||
|
@ -354,9 +360,22 @@ MODULE* PYTHON_FOOTPRINT_WIZARD::GetModule()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void* PYTHON_FOOTPRINT_WIZARD::GetObject()
|
||||||
|
{
|
||||||
|
return (void*) m_PyWizard;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PYTHON_FOOTPRINT_WIZARDS::register_wizard( PyObject* aPyWizard )
|
void PYTHON_FOOTPRINT_WIZARDS::register_wizard( PyObject* aPyWizard )
|
||||||
{
|
{
|
||||||
PYTHON_FOOTPRINT_WIZARD* fw = new PYTHON_FOOTPRINT_WIZARD( aPyWizard );
|
PYTHON_FOOTPRINT_WIZARD* fw = new PYTHON_FOOTPRINT_WIZARD( aPyWizard );
|
||||||
|
|
||||||
fw->register_wizard();
|
fw->register_wizard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PYTHON_FOOTPRINT_WIZARDS::deregister_wizard( PyObject* aPyWizard )
|
||||||
|
{
|
||||||
|
// deregister also destroyes the previously created "PYTHON_FOOTPRINT_WIZARD object"
|
||||||
|
FOOTPRINT_WIZARDS::deregister_object( (void*) aPyWizard );
|
||||||
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
wxArrayString GetParameterErrors( int aPage );
|
wxArrayString GetParameterErrors( int aPage );
|
||||||
wxString SetParameterValues( int aPage, wxArrayString& aValues ); // < must return "OK" or error description
|
wxString SetParameterValues( int aPage, wxArrayString& aValues ); // < must return "OK" or error description
|
||||||
MODULE* GetModule();
|
MODULE* GetModule();
|
||||||
|
void* GetObject();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ class PYTHON_FOOTPRINT_WIZARDS
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void register_wizard( PyObject* aPyWizard );
|
static void register_wizard( PyObject* aPyWizard );
|
||||||
|
static void deregister_wizard( PyObject* aPyWizard );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PCBNEW_FOOTPRINT_WIZARDS_H */
|
#endif /* PCBNEW_FOOTPRINT_WIZARDS_H */
|
||||||
|
|
|
@ -30,5 +30,6 @@ class PYTHON_FOOTPRINT_WIZARDS
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void register_wizard(PyObject *wizard);
|
static void register_wizard(PyObject *wizard);
|
||||||
|
static void deregister_wizard(PyObject *wizard);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,37 +41,59 @@
|
||||||
%pythoncode
|
%pythoncode
|
||||||
{
|
{
|
||||||
|
|
||||||
|
KICAD_PLUGINS={}
|
||||||
|
|
||||||
|
def ReloadPlugin(name):
|
||||||
|
if not KICAD_PLUGINS.has_key(name):
|
||||||
|
return False
|
||||||
|
|
||||||
|
KICAD_PLUGINS[name]["wizard"].deregister()
|
||||||
|
|
||||||
|
mod = reload(KICAD_PLUGINS[name]["module"])
|
||||||
|
|
||||||
|
KICAD_PLUGINS[name]["wizard"]= mod.register()
|
||||||
|
|
||||||
def LoadPlugins():
|
def LoadPlugins():
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# Use environment variable KICAD_PATH to derive path to plugins as a temporary solution
|
|
||||||
kicad_path = os.environ.get('KICAD_PATH')
|
kicad_path = os.environ.get('KICAD_PATH')
|
||||||
plugin_directories=[]
|
plugin_directories=[]
|
||||||
|
|
||||||
if kicad_path and os.path.isdir(kicad_path):
|
if kicad_path and os.path.isdir(kicad_path):
|
||||||
plugin_directories.append(os.path.join(kicad_path, 'scripting', 'plugins'))
|
plugin_directories.append(os.path.join(kicad_path, 'scripting', 'plugins'))
|
||||||
|
|
||||||
if sys.platform.startswith('linux'):
|
if sys.platform.startswith('linux') or sys.platform.startswith('darwin'):
|
||||||
plugin_directories.append(os.environ['HOME']+'/.kicad_plugins/')
|
plugin_directories.append(os.environ['HOME']+'/.kicad_plugins/')
|
||||||
plugin_directories.append(os.environ['HOME']+'/.kicad/scripting/plugins/')
|
plugin_directories.append(os.environ['HOME']+'/.kicad/scripting/plugins/')
|
||||||
|
|
||||||
# scan all possible directories for plugins, and load them
|
|
||||||
|
|
||||||
for plugins_dir in plugin_directories:
|
for plugins_dir in plugin_directories:
|
||||||
sys.path.append(plugins_dir)
|
sys.path.append(plugins_dir)
|
||||||
if not os.path.isdir(plugins_dir):
|
|
||||||
|
if not os.path.isdir(plugins_dir):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for module in os.listdir(plugins_dir):
|
for module in os.listdir(plugins_dir):
|
||||||
if os.path.isdir(plugins_dir+module):
|
if os.path.isdir(plugins_dir+module):
|
||||||
__import__(module, locals(), globals())
|
__import__(module, locals(), globals())
|
||||||
|
|
||||||
if module == '__init__.py' or module[-3:] != '.py':
|
if module == '__init__.py' or module[-3:] != '.py':
|
||||||
continue
|
continue
|
||||||
__import__(module[:-3], locals(), globals())
|
|
||||||
|
mod = __import__(module[:-3], locals(), globals())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if hasattr(mod,'register'):
|
||||||
|
KICAD_PLUGINS[module]={"filename":plugins_dir+"/"+module,
|
||||||
|
"wizard":mod.register(),
|
||||||
|
"module":mod}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# KiCadPlugin base class will register any plugin into the right place
|
|
||||||
class KiCadPlugin:
|
class KiCadPlugin:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
@ -88,16 +110,27 @@ class KiCadPlugin:
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def deregister(self):
|
||||||
|
if isinstance(self,FilePlugin):
|
||||||
|
pass # register to file plugins in C++
|
||||||
|
if isinstance(self,FootprintWizardPlugin):
|
||||||
|
PYTHON_FOOTPRINT_WIZARDS.deregister_wizard(self)
|
||||||
|
return
|
||||||
|
|
||||||
|
if isinstance(self,ActionPlugin):
|
||||||
|
pass # register to action plugins in C++
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# This will be the file io scripting based plugins class
|
|
||||||
class FilePlugin(KiCadPlugin):
|
class FilePlugin(KiCadPlugin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
KiCadPlugin.__init__(self)
|
KiCadPlugin.__init__(self)
|
||||||
|
|
||||||
|
|
||||||
# Scriping footprint wizards
|
|
||||||
class FootprintWizardPlugin(KiCadPlugin):
|
class FootprintWizardPlugin(KiCadPlugin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
KiCadPlugin.__init__(self)
|
KiCadPlugin.__init__(self)
|
||||||
|
@ -164,7 +197,7 @@ class FootprintWizardPlugin(KiCadPlugin):
|
||||||
print "[%s][%s]<="%(name,key),val
|
print "[%s][%s]<="%(name,key),val
|
||||||
n+=1
|
n+=1
|
||||||
|
|
||||||
# copies the parameter list on parameter_errors but empty
|
|
||||||
def ClearErrors(self):
|
def ClearErrors(self):
|
||||||
errs={}
|
errs={}
|
||||||
|
|
||||||
|
@ -203,6 +236,4 @@ class ActionPlugin(KiCadPlugin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
KiCadPlugin.__init__(self)
|
KiCadPlugin.__init__(self)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue