Support for nanometer build, extra example

This commit is contained in:
Miguel Angel Ajo 2012-07-15 22:01:05 +02:00
parent 974fe74f66
commit 2a9b8df888
5 changed files with 50 additions and 31 deletions

View File

@ -2,15 +2,12 @@ add_definitions(-DPCBNEW)
if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES) if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
EXECUTE_PROCESS(COMMAND python2 -c "import sys;print\"%s.%s\"%sys.version_info[0:2]" OUTPUT_VARIABLE PYTHON_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) EXECUTE_PROCESS(COMMAND python2 -c "import sys;print\"%s.%s\"%sys.version_info[0:2]" OUTPUT_VARIABLE PYTHON_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
SET(PYTHON_DEST "lib/python${PYTHON_VERSION}/dist-packages" ) SET(PYTHON_DEST "lib/python${PYTHON_VERSION}/dist-packages" )
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripting) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripting)
FIND_PACKAGE(SWIG REQUIRED)
FIND_PACKAGE(SWIG REQUIRED) INCLUDE(${SWIG_USE_FILE})
INCLUDE(${SWIG_USE_FILE}) FIND_PACKAGE(PythonLibs)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
FIND_PACKAGE(PythonLibs)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
add_definitions(-DPCBNEW -DKICAD_SCRIPTING) add_definitions(-DPCBNEW -DKICAD_SCRIPTING)
endif() endif()
@ -280,6 +277,9 @@ if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
if ( USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE ) if ( USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE )
SET(SWIG_FLAGS ${SWIG_FLAGS} -DBUILD_WITH_PLUGIN) SET(SWIG_FLAGS ${SWIG_FLAGS} -DBUILD_WITH_PLUGIN)
endif() endif()
if ( USE_PCBNEW_NANOMETRES )
SET(SWIG_FLAGS ${SWIG_FLAGS} -DUSE_PCBNEW_NANOMETRES)
endif()
endif() endif()

View File

@ -0,0 +1,14 @@
#!/usr/bin/env python
import sys
from pcbnew import *
filename=sys.argv[1]
pcb = LoadBoard(filename)
for module in pcb.GetModules():
print "* Module: %s"%module.GetReference()
module.GetValueObj().SetVisible(False) # set Value as Hidden
module.GetReferenceObj().SetVisible(True) # set Reference as Visible
pcb.Save("mod_"+filename)

View File

@ -34,42 +34,42 @@
{ {
def ToMM(iu): def ToMM(iu):
if type(iu) in [int,float]: if type(iu) in [int,float]:
return iu * 0.00254 return float(iu) / float(IU_PER_MM)
elif type(iu) in [wxPoint,wxSize]: elif type(iu) in [wxPoint,wxSize]:
return tuple(map(ToMM,iu)) return tuple(map(ToMM,iu))
def FromMM(iu): def FromMM(mm):
if type(iu) in [int,float]: if type(mm) in [int,float]:
return iu / 0.00254 return int(float(mm) * float(IU_PER_MM))
elif type(iu) in [wxPoint,wxSize]: elif type(mm) in [wxPoint,wxSize]:
return tuple(map(FromMM,iu)) return tuple(map(FromMM,mm))
def ToMils(iu): def ToMils(iu):
if type(iu) in [int,float]: if type(iu) in [int,float]:
return iu / 10.0 return float(iu) / float(IU_PER_MILS)
elif type(iu) in [wxPoint,wxSize]: elif type(iu) in [wxPoint,wxSize]:
return tuple(map(ToMils,iu)) return tuple(map(ToMils,iu))
def FromMils(iu): def FromMils(mils):
if type(iu) in [int,float]: if type(mils) in [int,float]:
return iu*10.0 return int(float(mils)*float(IU_PER_MILS))
elif type(iu) in [wxPoint,wxSize]: elif type(mils) in [wxPoint,wxSize]:
return tuple(map(FromMils,iu)) return tuple(map(FromMils,mils))
def SizeMM(mmx,mmy): return wxSize(FromMM(mmx),FromMM(mmy)) def wxSizeMM(mmx,mmy): return wxSize(FromMM(mmx),FromMM(mmy))
def SizeMils(mmx,mmy): return wxSize(FromMils(mmx),FromMils(mmy)) def wxSizeMils(mmx,mmy): return wxSize(FromMils(mmx),FromMils(mmy))
def PointMM(mmx,mmy): return wxPoint(FromMM(mmx),FromMM(mmy)) def wxPointMM(mmx,mmy): return wxPoint(FromMM(mmx),FromMM(mmy))
def PointMils(mmx,mmy): return wxPoint(FromMils(mmx),FromMils(mmy)) def wxPointMils(mmx,mmy): return wxPoint(FromMils(mmx),FromMils(mmy))
def RectMM(x,y,wx,wy): def wxRectMM(x,y,wx,wy):
x = int(FromMM(x)) x = int(FromMM(x))
y = int(FromMM(y)) y = int(FromMM(y))
wx = int(FromMM(wx)) wx = int(FromMM(wx))
wy = int (FromMM(wy)) wy = int (FromMM(wy))
return wxRect(x,y,wx,wy) return wxRect(x,y,wx,wy)
def RectMils(x,y,wx,wy): def wxRectMils(x,y,wx,wy):
x = int(FromMils(x)) x = int(FromMils(x))
y = int(FromMils(y)) y = int(FromMils(y))
wx = int(FromMils(wx)) wx = int(FromMils(wx))

View File

@ -68,7 +68,9 @@
#include <class_title_block.h> #include <class_title_block.h>
#include <class_colors_design_settings.h> #include <class_colors_design_settings.h>
#include <class_marker_base.h> #include <class_marker_base.h>
#include <eda_text.h> #include <eda_text.h>
#include <convert_from_iu.h>
#include <convert_to_biu.h>
%} %}
@ -100,6 +102,8 @@
%include <class_colors_design_settings.h> %include <class_colors_design_settings.h>
%include <class_marker_base.h> %include <class_marker_base.h>
%include <eda_text.h> %include <eda_text.h>
%include <convert_from_iu.h>
%include <convert_to_biu.h>
/* special iteration wrapper for DLIST objects */ /* special iteration wrapper for DLIST objects */
%include "dlist.i" %include "dlist.i"

View File

@ -68,14 +68,15 @@ static void swigAddBuiltin()
{ {
int i = 0; int i = 0;
while( PyImport_Inittab[i].name ) /* discover the length of the pyimport inittab */
{ while( PyImport_Inittab[i].name ) i++;
i++;
} /* allocate memory for the python module table */
SwigImportInittab = (struct _inittab*) malloc( SwigImportInittab = (struct _inittab*) malloc(
sizeof(struct _inittab)*(i+EXTRA_PYTHON_MODULES)); sizeof(struct _inittab)*(i+EXTRA_PYTHON_MODULES));
/* copy all pre-existing python modules into our newly created table */
i=0;
while( PyImport_Inittab[i].name ) while( PyImport_Inittab[i].name )
{ {
swigAddModule( PyImport_Inittab[i].name, PyImport_Inittab[i].initfunc ); swigAddModule( PyImport_Inittab[i].name, PyImport_Inittab[i].initfunc );