A few enhancements from a larger patch, not yet committed, for footprint wizards
This commit is contained in:
parent
352f1a025c
commit
636e060c99
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012-2014 Miguel Angel Ajo <miguelangel@nbee.es>
|
||||
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -33,9 +33,14 @@
|
|||
#include <kiface_i.h>
|
||||
#include <dialog_footprint_wizard_list.h>
|
||||
#include <class_footprint_wizard.h>
|
||||
#include <python_scripting.h>
|
||||
|
||||
enum FPGeneratorRowNames
|
||||
{
|
||||
FP_GEN_ROW_NAME = 0,
|
||||
FP_GEN_ROW_DESCR,
|
||||
};
|
||||
|
||||
#define ROW_NAME 0
|
||||
#define ROW_DESCR 1
|
||||
#define FPWIZARTDLIST_HEIGHT_KEY wxT( "FpWizardListHeight" )
|
||||
#define FPWIZARTDLIST_WIDTH_KEY wxT( "FpWizardListWidth" )
|
||||
|
||||
|
@ -64,11 +69,21 @@ DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST( wxWindow* aParent )
|
|||
wxString description = wizard->GetDescription();
|
||||
wxString image = wizard->GetImage();
|
||||
|
||||
m_footprintGeneratorsGrid->SetCellValue( i, ROW_NAME, name );
|
||||
m_footprintGeneratorsGrid->SetCellValue( i, ROW_DESCR, description );
|
||||
m_footprintGeneratorsGrid->SetCellValue( i, FP_GEN_ROW_NAME, name );
|
||||
m_footprintGeneratorsGrid->SetCellValue( i, FP_GEN_ROW_DESCR, description );
|
||||
|
||||
}
|
||||
|
||||
m_footprintGeneratorsGrid->AutoSizeColumns();
|
||||
|
||||
// Auto-expand the description column
|
||||
int width = m_footprintGeneratorsGrid->GetClientSize().GetWidth() -
|
||||
m_footprintGeneratorsGrid->GetRowLabelSize() -
|
||||
m_footprintGeneratorsGrid->GetColSize( FP_GEN_ROW_NAME );
|
||||
|
||||
if ( width > m_footprintGeneratorsGrid->GetColMinimalAcceptableWidth() )
|
||||
m_footprintGeneratorsGrid->SetColSize( FP_GEN_ROW_DESCR, width );
|
||||
|
||||
// Select the first row
|
||||
m_footprintGeneratorsGrid->ClearSelection();
|
||||
m_footprintGeneratorsGrid->SelectRow( 0, false );
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo <miguelangel@nbee.es>
|
||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -37,6 +37,8 @@
|
|||
#include <colors.h>
|
||||
#include <macros.h>
|
||||
|
||||
#include <pgm_base.h>
|
||||
|
||||
/* init functions defined by swig */
|
||||
|
||||
extern "C" void init_kicad( void );
|
||||
|
@ -359,3 +361,29 @@ wxString PyErrStringWithTraceback()
|
|||
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the Python scripting path
|
||||
*/
|
||||
wxString PyScriptingPath()
|
||||
{
|
||||
wxString path;
|
||||
|
||||
//TODO should this be a user configurable variable eg KISCRIPT ?
|
||||
#if defined( __WXMAC__ )
|
||||
path = GetOSXKicadDataDir() + wxT( "/scripting" );
|
||||
#else
|
||||
path = Pgm().GetExecutablePath() + wxT( "../share/kicad/scripting" );
|
||||
#endif
|
||||
|
||||
wxFileName scriptPath( path );
|
||||
|
||||
scriptPath.MakeAbsolute();
|
||||
|
||||
return scriptPath.GetFullPath();
|
||||
}
|
||||
|
||||
wxString PyPluginsPath()
|
||||
{
|
||||
return PyScriptingPath() + wxFileName::GetPathSeparator() + "plugins";
|
||||
}
|
||||
|
|
|
@ -1,3 +1,26 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __PYTHON_SCRIPTING_H
|
||||
#define __PYTHON_SCRIPTING_H
|
||||
|
||||
|
@ -59,4 +82,7 @@ public:
|
|||
wxArrayString PyArrayStringToWx( PyObject* arr );
|
||||
wxString PyErrStringWithTraceback();
|
||||
|
||||
wxString PyScriptingPath();
|
||||
wxString PyPluginsPath();
|
||||
|
||||
#endif // __PYTHON_SCRIPTING_H
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo <miguelangel@nbee.es>
|
||||
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -55,11 +55,25 @@
|
|||
elif type(mils) in [wxPoint,wxSize]:
|
||||
return tuple(map(FromMils,mils))
|
||||
|
||||
def wxSizeMM(mmx,mmy): return wxSize(FromMM(mmx),FromMM(mmy))
|
||||
def wxSizeMils(mmx,mmy): return wxSize(FromMils(mmx),FromMils(mmy))
|
||||
def PutOnGridMM(value, gridSizeMM):
|
||||
thresh = FromMM(gridSizeMM)
|
||||
return round(value/thresh)*thresh
|
||||
|
||||
def wxPointMM(mmx,mmy): return wxPoint(FromMM(mmx),FromMM(mmy))
|
||||
def wxPointMils(mmx,mmy): return wxPoint(FromMils(mmx),FromMils(mmy))
|
||||
def PutOnGridMils(value, gridSizeMils):
|
||||
thresh = FromMils(gridSizeMils)
|
||||
return round(value/thresh)*thresh
|
||||
|
||||
def wxSizeMM(mmx,mmy):
|
||||
return wxSize(FromMM(mmx),FromMM(mmy))
|
||||
|
||||
def wxSizeMils(mmx,mmy):
|
||||
return wxSize(FromMils(mmx),FromMils(mmy))
|
||||
|
||||
def wxPointMM(mmx,mmy):
|
||||
return wxPoint(FromMM(mmx),FromMM(mmy))
|
||||
|
||||
def wxPointMils(mmx,mmy):
|
||||
return wxPoint(FromMils(mmx),FromMils(mmy))
|
||||
|
||||
def wxRectMM(x,y,wx,wy):
|
||||
x = int(FromMM(x))
|
||||
|
@ -72,6 +86,6 @@
|
|||
x = int(FromMils(x))
|
||||
y = int(FromMils(y))
|
||||
wx = int(FromMils(wx))
|
||||
wy = int (FromMils(wy))
|
||||
wy = int(FromMils(wy))
|
||||
return wxRect(x,y,wx,wy)
|
||||
%}
|
||||
|
|
|
@ -119,19 +119,23 @@ def LoadPlugins(bundlepath=None):
|
|||
if bundlepath:
|
||||
plugin_directories.append(bundlepath)
|
||||
plugin_directories.append(os.path.join(bundlepath, 'plugins'))
|
||||
plugin_directories.append(os.path.join(bundlepath, 'plugins', 'wizards'))
|
||||
|
||||
if kicad_path:
|
||||
plugin_directories.append(os.path.join(kicad_path, 'scripting'))
|
||||
plugin_directories.append(os.path.join(kicad_path, 'scripting', 'plugins'))
|
||||
plugin_directories.append(os.path.join(kicad_path, 'scripting', 'plugins', 'wizards'))
|
||||
|
||||
if config_path:
|
||||
plugin_directories.append(os.path.join(config_path, 'scripting'))
|
||||
plugin_directories.append(os.path.join(config_path, 'scripting', 'plugins'))
|
||||
plugin_directories.append(os.path.join(config_path, 'scripting', 'plugins', 'wizards'))
|
||||
|
||||
if sys.platform.startswith('linux'):
|
||||
plugin_directories.append(os.environ['HOME']+'/.kicad_plugins/')
|
||||
plugin_directories.append(os.environ['HOME']+'/.kicad/scripting/')
|
||||
plugin_directories.append(os.environ['HOME']+'/.kicad/scripting/plugins/')
|
||||
plugin_directories.append(os.environ['HOME']+'/.kicad/scripting/plugins/wizards')
|
||||
|
||||
for plugins_dir in plugin_directories:
|
||||
if not os.path.isdir(plugins_dir):
|
||||
|
@ -146,15 +150,18 @@ def LoadPlugins(bundlepath=None):
|
|||
if module == '__init__.py' or module[-3:] != '.py':
|
||||
continue
|
||||
|
||||
mod = __import__(module[:-3], locals(), globals())
|
||||
try: # If there is an error loading the script, skip it
|
||||
mod = __import__(module[:-3], locals(), globals())
|
||||
|
||||
module_filename = plugins_dir+"/"+module
|
||||
mtime = os.path.getmtime(module_filename)
|
||||
if hasattr(mod,'register'):
|
||||
KICAD_PLUGINS[module]={"filename":module_filename,
|
||||
"modification_time":mtime,
|
||||
"object":mod.register(),
|
||||
"module":mod}
|
||||
module_filename = plugins_dir+"/"+module
|
||||
mtime = os.path.getmtime(module_filename)
|
||||
if hasattr(mod,'register'):
|
||||
KICAD_PLUGINS[module]={"filename":module_filename,
|
||||
"modification_time":mtime,
|
||||
"object":mod.register(),
|
||||
"module":mod}
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue