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)
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" )
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripting)
FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})
FIND_PACKAGE(PythonLibs)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})
FIND_PACKAGE(PythonLibs)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
add_definitions(-DPCBNEW -DKICAD_SCRIPTING)
endif()
@ -280,6 +277,9 @@ if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
if ( USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE )
SET(SWIG_FLAGS ${SWIG_FLAGS} -DBUILD_WITH_PLUGIN)
endif()
if ( USE_PCBNEW_NANOMETRES )
SET(SWIG_FLAGS ${SWIG_FLAGS} -DUSE_PCBNEW_NANOMETRES)
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):
if type(iu) in [int,float]:
return iu * 0.00254
return float(iu) / float(IU_PER_MM)
elif type(iu) in [wxPoint,wxSize]:
return tuple(map(ToMM,iu))
def FromMM(iu):
if type(iu) in [int,float]:
return iu / 0.00254
elif type(iu) in [wxPoint,wxSize]:
return tuple(map(FromMM,iu))
def FromMM(mm):
if type(mm) in [int,float]:
return int(float(mm) * float(IU_PER_MM))
elif type(mm) in [wxPoint,wxSize]:
return tuple(map(FromMM,mm))
def ToMils(iu):
if type(iu) in [int,float]:
return iu / 10.0
return float(iu) / float(IU_PER_MILS)
elif type(iu) in [wxPoint,wxSize]:
return tuple(map(ToMils,iu))
def FromMils(iu):
if type(iu) in [int,float]:
return iu*10.0
elif type(iu) in [wxPoint,wxSize]:
return tuple(map(FromMils,iu))
def FromMils(mils):
if type(mils) in [int,float]:
return int(float(mils)*float(IU_PER_MILS))
elif type(mils) in [wxPoint,wxSize]:
return tuple(map(FromMils,mils))
def SizeMM(mmx,mmy): return wxSize(FromMM(mmx),FromMM(mmy))
def SizeMils(mmx,mmy): return wxSize(FromMils(mmx),FromMils(mmy))
def wxSizeMM(mmx,mmy): return wxSize(FromMM(mmx),FromMM(mmy))
def wxSizeMils(mmx,mmy): return wxSize(FromMils(mmx),FromMils(mmy))
def PointMM(mmx,mmy): return wxPoint(FromMM(mmx),FromMM(mmy))
def PointMils(mmx,mmy): return wxPoint(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 RectMM(x,y,wx,wy):
def wxRectMM(x,y,wx,wy):
x = int(FromMM(x))
y = int(FromMM(y))
wx = int(FromMM(wx))
wy = int (FromMM(wy))
return wxRect(x,y,wx,wy)
def RectMils(x,y,wx,wy):
def wxRectMils(x,y,wx,wy):
x = int(FromMils(x))
y = int(FromMils(y))
wx = int(FromMils(wx))

View File

@ -68,7 +68,9 @@
#include <class_title_block.h>
#include <class_colors_design_settings.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_marker_base.h>
%include <eda_text.h>
%include <convert_from_iu.h>
%include <convert_to_biu.h>
/* special iteration wrapper for DLIST objects */
%include "dlist.i"

View File

@ -68,14 +68,15 @@ static void swigAddBuiltin()
{
int i = 0;
while( PyImport_Inittab[i].name )
{
i++;
}
/* discover the length of the pyimport inittab */
while( PyImport_Inittab[i].name ) i++;
/* allocate memory for the python module table */
SwigImportInittab = (struct _inittab*) malloc(
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 )
{
swigAddModule( PyImport_Inittab[i].name, PyImport_Inittab[i].initfunc );