SWIG Improvements
*) Extend SWIG support deeper into the BOARD class. *) Move swig *.i files into a directory identified for SWIG, in preparation for a parallel universe involving Phoenix's SIP. *) Move swig files which will be common to both eeschema and pcbnew into common/swig. *) Sketch out a "common" python module, and plan on dovetailing that into a libkicad_shared.{dll,so} *) Add common/swig/ki_exceptions.i and define a macro HANDLE_EXCEPTIONS() which is to be applied to any function which needs C++ to python exception translation. *) Move the test for SWIG tool into top level CMakeLists.txt file for use in all python modules beyond pcbnew, i.e. eeschema and common. *) Add SWIG_MODULE_pcbnew_EXTRA_DEPS which generates a better Makefile, one which rebuilds the swig generated *.cxx file when one of its dependencies change. *) Re-architect the board.i file so that it can be split into multiple *.i files easily. *) Make some KIWAY from python progress, in preparation for Modular KiCad phase III.
This commit is contained in:
parent
964b5a1830
commit
7311f07eaf
|
@ -574,6 +574,11 @@ set( INC_AFTER
|
||||||
|
|
||||||
# Find Python and other scripting resources
|
# Find Python and other scripting resources
|
||||||
if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
|
if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
|
||||||
|
|
||||||
|
# SWIG 3.0 or later require for C++11 support.
|
||||||
|
find_package( SWIG 3.0 REQUIRED )
|
||||||
|
include( ${SWIG_USE_FILE} )
|
||||||
|
|
||||||
# force a python version < 3.0
|
# force a python version < 3.0
|
||||||
set( PythonInterp_FIND_VERSION 2.6 )
|
set( PythonInterp_FIND_VERSION 2.6 )
|
||||||
set( PythonLibs_FIND_VERSION 2.6 )
|
set( PythonLibs_FIND_VERSION 2.6 )
|
||||||
|
|
|
@ -74,8 +74,8 @@
|
||||||
|
|
||||||
/// A file extension with a leading '.' is a suffix, and this one is used on
|
/// A file extension with a leading '.' is a suffix, and this one is used on
|
||||||
/// top level program modules which implement the KIFACE.
|
/// top level program modules which implement the KIFACE.
|
||||||
#define KIFACE_SUFFIX wxT( "@KIFACE_SUFFIX@" )
|
#define KIFACE_SUFFIX "@KIFACE_SUFFIX@"
|
||||||
#define KIFACE_PREFIX wxT( "@KIFACE_PREFIX@" )
|
#define KIFACE_PREFIX "@KIFACE_PREFIX@"
|
||||||
|
|
||||||
/// Name of repo from which this build came.
|
/// Name of repo from which this build came.
|
||||||
#define KICAD_REPO_NAME "@KICAD_REPO_NAME@"
|
#define KICAD_REPO_NAME "@KICAD_REPO_NAME@"
|
||||||
|
|
|
@ -225,6 +225,7 @@ set( COMMON_SRCS
|
||||||
eda_dde.cpp
|
eda_dde.cpp
|
||||||
eda_doc.cpp
|
eda_doc.cpp
|
||||||
eda_pattern_match.cpp
|
eda_pattern_match.cpp
|
||||||
|
exceptions.cpp
|
||||||
filter_reader.cpp
|
filter_reader.cpp
|
||||||
# findkicadhelppath.cpp.notused deprecated, use searchhelpfilefullpath.cpp
|
# findkicadhelppath.cpp.notused deprecated, use searchhelpfilefullpath.cpp
|
||||||
gbr_metadata.cpp
|
gbr_metadata.cpp
|
||||||
|
@ -507,3 +508,64 @@ target_link_libraries( dsntest common ${wxWidgets_LIBRARIES} rt )
|
||||||
add_dependencies( dsntest lib-dependencies )
|
add_dependencies( dsntest lib-dependencies )
|
||||||
|
|
||||||
target_link_libraries( pcbcommon 3d-viewer )
|
target_link_libraries( pcbcommon 3d-viewer )
|
||||||
|
|
||||||
|
|
||||||
|
# kiway.so
|
||||||
|
if( future AND KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
|
||||||
|
#file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripting )
|
||||||
|
|
||||||
|
set( SWIG_FLAGS
|
||||||
|
-I${CMAKE_CURRENT_SOURCE_DIR}/../include
|
||||||
|
-I${CMAKE_CURRENT_SOURCE_DIR}/swig/wx
|
||||||
|
)
|
||||||
|
|
||||||
|
if( DEBUG )
|
||||||
|
set( SWIG_FLAGS ${SWIG_FLAGS} -DDEBUG )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# call SWIG in C++ mode: https://cmake.org/cmake/help/v3.2/module/UseSWIG.html
|
||||||
|
set_source_files_properties( swig/kiway.i PROPERTIES CPLUSPLUS ON )
|
||||||
|
|
||||||
|
# collect CFLAGS , and pass them to swig later
|
||||||
|
get_directory_property( DirDefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS )
|
||||||
|
foreach( d ${DirDefs} )
|
||||||
|
set( SWIG_FLAGS ${SWIG_FLAGS} -D${d} )
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set( CMAKE_SWIG_FLAGS ${SWIG_FLAGS} )
|
||||||
|
|
||||||
|
#set( SWIG_OPTS -python -c++ -outdir ${CMAKE_CURRENT_BINARY_DIR} ${SWIG_FLAGS} )
|
||||||
|
|
||||||
|
include_directories( BEFORE ${INC_BEFORE} )
|
||||||
|
include_directories(
|
||||||
|
../common
|
||||||
|
${INC_AFTER}
|
||||||
|
)
|
||||||
|
|
||||||
|
set( SWIG_MODULE_kiway_EXTRA_DEPS
|
||||||
|
../common/swig/ki_exception.i
|
||||||
|
../common/swig/kicad.i
|
||||||
|
)
|
||||||
|
|
||||||
|
swig_add_module( kiway python
|
||||||
|
swig/kiway.i
|
||||||
|
#../common/kiway.cpp
|
||||||
|
#../common/project.cpp
|
||||||
|
#../common/pgm_base.cpp
|
||||||
|
#../common/
|
||||||
|
)
|
||||||
|
|
||||||
|
swig_link_libraries( kiway
|
||||||
|
common
|
||||||
|
bitmaps
|
||||||
|
${wxWidgets_LIBRARIES}
|
||||||
|
${PYTHON_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
if( MAKE_LINK_MAPS )
|
||||||
|
set_target_properties( _kiway PROPERTIES
|
||||||
|
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=_kiway.so.map"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
|
@ -306,7 +306,7 @@ void FOOTPRINT_LIST::DisplayErrors( wxTopLevelWindow* aWindow )
|
||||||
|
|
||||||
for( unsigned i = 0; i<m_errors.size(); ++i )
|
for( unsigned i = 0; i<m_errors.size(); ++i )
|
||||||
{
|
{
|
||||||
msg += wxT( "<p>" ) + m_errors[i].errorText + wxT( "</p>" );
|
msg += wxT( "<p>" ) + m_errors[i].Problem() + wxT( "</p>" );
|
||||||
}
|
}
|
||||||
|
|
||||||
dlg.AddHTML_Text( msg );
|
dlg.AddHTML_Text( msg );
|
||||||
|
|
|
@ -93,19 +93,19 @@ void KIWAY::SetTop( wxFrame* aTop )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const wxString KIWAY::dso_full_path( FACE_T aFaceId )
|
const wxString KIWAY::dso_search_path( FACE_T aFaceId )
|
||||||
{
|
{
|
||||||
const wxChar* name;
|
const char* name;
|
||||||
|
|
||||||
switch( aFaceId )
|
switch( aFaceId )
|
||||||
{
|
{
|
||||||
case FACE_SCH: name = KIFACE_PREFIX wxT( "eeschema" ); break;
|
case FACE_SCH: name = KIFACE_PREFIX "eeschema"; break;
|
||||||
case FACE_PCB: name = KIFACE_PREFIX wxT( "pcbnew" ); break;
|
case FACE_PCB: name = KIFACE_PREFIX "pcbnew"; break;
|
||||||
case FACE_CVPCB: name = KIFACE_PREFIX wxT( "cvpcb" ); break;
|
case FACE_CVPCB: name = KIFACE_PREFIX "cvpcb"; break;
|
||||||
case FACE_GERBVIEW: name = KIFACE_PREFIX wxT( "gerbview" ); break;
|
case FACE_GERBVIEW: name = KIFACE_PREFIX "gerbview"; break;
|
||||||
case FACE_PL_EDITOR: name = KIFACE_PREFIX wxT( "pl_editor" ); break;
|
case FACE_PL_EDITOR: name = KIFACE_PREFIX "pl_editor"; break;
|
||||||
case FACE_PCB_CALCULATOR: name = KIFACE_PREFIX wxT( "pcb_calculator" ); break;
|
case FACE_PCB_CALCULATOR: name = KIFACE_PREFIX "pcb_calculator"; break;
|
||||||
case FACE_BMP2CMP: name = KIFACE_PREFIX wxT( "bitmap2component" ); break;
|
case FACE_BMP2CMP: name = KIFACE_PREFIX "bitmap2component"; break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
|
wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
|
||||||
|
@ -113,7 +113,17 @@ const wxString KIWAY::dso_full_path( FACE_T aFaceId )
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __WXMAC__
|
#ifndef __WXMAC__
|
||||||
wxFileName fn = wxStandardPaths::Get().GetExecutablePath();
|
wxString path;
|
||||||
|
|
||||||
|
if( m_ctl & (KFCTL_STANDALONE | KFCTL_CPP_PROJECT_SUITE) )
|
||||||
|
{
|
||||||
|
// The 2 *.cpp program launchers: single_top.cpp and kicad.cpp expect
|
||||||
|
// the *.kiface's to reside in same diretory as their binaries do.
|
||||||
|
// Not so for python launcher, identified by KFCTL_PY_PROJECT_SUITE
|
||||||
|
path = wxStandardPaths::Get().GetExecutablePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFileName fn = path;
|
||||||
#else
|
#else
|
||||||
// we have the dso's in main OSX bundle kicad.app/Contents/PlugIns
|
// we have the dso's in main OSX bundle kicad.app/Contents/PlugIns
|
||||||
wxFileName fn = Pgm().GetExecutablePath();
|
wxFileName fn = Pgm().GetExecutablePath();
|
||||||
|
@ -159,7 +169,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
|
||||||
// DSO with KIFACE has not been loaded yet, does caller want to load it?
|
// DSO with KIFACE has not been loaded yet, does caller want to load it?
|
||||||
if( doLoad )
|
if( doLoad )
|
||||||
{
|
{
|
||||||
wxString dname = dso_full_path( aFaceId );
|
wxString dname = dso_search_path( aFaceId );
|
||||||
|
|
||||||
wxDynamicLibrary dso;
|
wxDynamicLibrary dso;
|
||||||
|
|
||||||
|
|
|
@ -285,7 +285,6 @@ PGM_BASE::PGM_BASE()
|
||||||
m_locale = NULL;
|
m_locale = NULL;
|
||||||
m_common_settings = NULL;
|
m_common_settings = NULL;
|
||||||
|
|
||||||
m_wx_app = NULL;
|
|
||||||
m_show_env_var_dialog = true;
|
m_show_env_var_dialog = true;
|
||||||
|
|
||||||
setLanguageId( wxLANGUAGE_DEFAULT );
|
setLanguageId( wxLANGUAGE_DEFAULT );
|
||||||
|
@ -296,11 +295,11 @@ PGM_BASE::PGM_BASE()
|
||||||
|
|
||||||
PGM_BASE::~PGM_BASE()
|
PGM_BASE::~PGM_BASE()
|
||||||
{
|
{
|
||||||
destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PGM_BASE::destroy()
|
void PGM_BASE::Destroy()
|
||||||
{
|
{
|
||||||
// unlike a normal destructor, this is designed to be called more than once safely:
|
// unlike a normal destructor, this is designed to be called more than once safely:
|
||||||
|
|
||||||
|
@ -315,6 +314,13 @@ void PGM_BASE::destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxApp& PGM_BASE::App()
|
||||||
|
{
|
||||||
|
wxASSERT( wxTheApp );
|
||||||
|
return *wxTheApp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PGM_BASE::SetEditorName( const wxString& aFileName )
|
void PGM_BASE::SetEditorName( const wxString& aFileName )
|
||||||
{
|
{
|
||||||
m_editor_name = aFileName;
|
m_editor_name = aFileName;
|
||||||
|
@ -383,7 +389,7 @@ const wxString PGM_BASE::AskUserForPreferredEditor( const wxString& aDefaultEdit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PGM_BASE::initPgm()
|
bool PGM_BASE::InitPgm()
|
||||||
{
|
{
|
||||||
wxFileName pgm_name( App().argv[0] );
|
wxFileName pgm_name( App().argv[0] );
|
||||||
|
|
||||||
|
@ -609,10 +615,10 @@ void PGM_BASE::loadCommonSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PGM_BASE::saveCommonSettings()
|
void PGM_BASE::SaveCommonSettings()
|
||||||
{
|
{
|
||||||
// m_common_settings is not initialized until fairly late in the
|
// m_common_settings is not initialized until fairly late in the
|
||||||
// process startup: initPgm(), so test before using:
|
// process startup: InitPgm(), so test before using:
|
||||||
if( m_common_settings )
|
if( m_common_settings )
|
||||||
{
|
{
|
||||||
wxString cur_dir = wxGetCwd();
|
wxString cur_dir = wxGetCwd();
|
||||||
|
@ -846,7 +852,7 @@ void PGM_BASE::SetLocalEnvVariables( const ENV_VAR_MAP& aEnvVarMap )
|
||||||
if( m_common_settings )
|
if( m_common_settings )
|
||||||
m_common_settings->DeleteGroup( pathEnvVariables );
|
m_common_settings->DeleteGroup( pathEnvVariables );
|
||||||
|
|
||||||
saveCommonSettings();
|
SaveCommonSettings();
|
||||||
|
|
||||||
// Overwrites externally defined environment variable until the next time the application
|
// Overwrites externally defined environment variable until the next time the application
|
||||||
// is run.
|
// is run.
|
||||||
|
|
|
@ -24,6 +24,13 @@
|
||||||
|
|
||||||
/* DLIST python iteration code, to allow standard iteration over DLIST */
|
/* DLIST python iteration code, to allow standard iteration over DLIST */
|
||||||
|
|
||||||
|
%include <dlist.h>
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <dlist.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
%extend DLIST
|
%extend DLIST
|
||||||
{
|
{
|
||||||
%pythoncode
|
%pythoncode
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
|
* Copyright (C) 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
%warnfilter(511) IO_ERROR;
|
||||||
|
|
||||||
|
%include ki_exception.h
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <ki_exception.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include exception.i
|
||||||
|
|
||||||
|
// Target a specific function with "C++ to python exception handling and
|
||||||
|
// translation code". Invoke this macro separately for each C++ function
|
||||||
|
// that throws. This is a less bulkier scheme than assuming that ALL C++
|
||||||
|
// functions throw, because they do not all throw.
|
||||||
|
%define HANDLE_EXCEPTIONS(function)
|
||||||
|
%exception function {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$action
|
||||||
|
}
|
||||||
|
catch( const IO_ERROR& e )
|
||||||
|
{
|
||||||
|
UTF8 str = e.Problem();
|
||||||
|
|
||||||
|
SWIG_exception( SWIG_IOError, str.c_str() );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
catch( const std::exception& e )
|
||||||
|
{
|
||||||
|
std::string str = e.what();
|
||||||
|
|
||||||
|
SWIG_exception( SWIG_IOError, str.c_str() );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
catch( ... )
|
||||||
|
{
|
||||||
|
SWIG_fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%enddef
|
||||||
|
|
|
@ -0,0 +1,158 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file kicad.i
|
||||||
|
* @brief General wrappers for kicad / wx structures and classes
|
||||||
|
*/
|
||||||
|
|
||||||
|
%include <std_vector.i>
|
||||||
|
%include <std_basic_string.i>
|
||||||
|
%include <std_string.i>
|
||||||
|
%include <std_map.i>
|
||||||
|
%include <std_shared_ptr.i>
|
||||||
|
%include <std_set.i>
|
||||||
|
|
||||||
|
%include "ki_exception.i" // affects all that follow it
|
||||||
|
|
||||||
|
/*
|
||||||
|
http://www.swig.org/Doc3.0/CPlusPlus11.html
|
||||||
|
7.3.3 Hash tables
|
||||||
|
|
||||||
|
The new hash tables in the STL are unordered_set, unordered_multiset,
|
||||||
|
unordered_map, unordered_multimap. These are not available in SWIG, but in
|
||||||
|
principle should be easily implemented by adapting the current STL containers.
|
||||||
|
|
||||||
|
%include <std_unordered_map.i>
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ignore some constructors of EDA_ITEM that will make the build fail
|
||||||
|
|
||||||
|
%nodefaultctor EDA_ITEM;
|
||||||
|
%ignore EDA_ITEM::EDA_ITEM( EDA_ITEM* parent, KICAD_T idType );
|
||||||
|
%ignore EDA_ITEM::EDA_ITEM( KICAD_T idType );
|
||||||
|
%ignore EDA_ITEM::EDA_ITEM( const EDA_ITEM& base );
|
||||||
|
|
||||||
|
|
||||||
|
%warnfilter(401) EDA_ITEM;
|
||||||
|
%warnfilter(509) UTF8;
|
||||||
|
|
||||||
|
/* swig tries to wrap SetBack/SetNext on derived classes, but this method is
|
||||||
|
private for most childs, so if we don't ignore it won't compile */
|
||||||
|
|
||||||
|
%ignore EDA_ITEM::SetBack;
|
||||||
|
%ignore EDA_ITEM::SetNext;
|
||||||
|
|
||||||
|
// ignore other functions that cause trouble
|
||||||
|
|
||||||
|
%ignore InitKiCadAbout;
|
||||||
|
%ignore GetCommandOptions;
|
||||||
|
|
||||||
|
%rename(getWxRect) operator wxRect;
|
||||||
|
%ignore operator <<;
|
||||||
|
%ignore operator=;
|
||||||
|
|
||||||
|
%include dlist.i
|
||||||
|
|
||||||
|
// headers/imports that must be included in the _wrapper.cpp at top
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <macros.h>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <base_struct.h>
|
||||||
|
#include <class_eda_rect.h>
|
||||||
|
#include <common.h>
|
||||||
|
#include <wx_python_helpers.h>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <vector>
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
|
#include <class_title_block.h>
|
||||||
|
#include <class_colors_design_settings.h>
|
||||||
|
#include <class_marker_base.h>
|
||||||
|
#include <eda_text.h>
|
||||||
|
#include <convert_to_biu.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
// all the wx wrappers for wxString, wxPoint, wxRect, wxChar ..
|
||||||
|
%include wx.i
|
||||||
|
|
||||||
|
// header files that must be wrapped
|
||||||
|
|
||||||
|
%include macros.h
|
||||||
|
%include core/typeinfo.h
|
||||||
|
%include base_struct.h
|
||||||
|
%include class_eda_rect.h
|
||||||
|
%include common.h
|
||||||
|
%include class_title_block.h
|
||||||
|
%include class_colors_design_settings.h
|
||||||
|
%include class_marker_base.h
|
||||||
|
%include eda_text.h
|
||||||
|
|
||||||
|
|
||||||
|
// std template mappings
|
||||||
|
%template(intVector) std::vector<int>;
|
||||||
|
%template(str_utf8_Map) std::map< std::string,UTF8 >;
|
||||||
|
|
||||||
|
// wrapper of BASE_SEQ (see typedef std::vector<LAYER_ID> BASE_SEQ;)
|
||||||
|
%template(base_seqVect) std::vector<enum LAYER_ID>;
|
||||||
|
|
||||||
|
// TODO: wrapper of BASE_SET (see std::bitset<LAYER_ID_COUNT> BASE_SET;)
|
||||||
|
|
||||||
|
|
||||||
|
// KiCad plugin handling
|
||||||
|
%include "kicadplugins.i"
|
||||||
|
|
||||||
|
// map CPolyLine and classes used in CPolyLine:
|
||||||
|
#include <../polygon/PolyLine.h>
|
||||||
|
%include <../polygon/PolyLine.h>
|
||||||
|
|
||||||
|
// ignore warning relative to operator = and operator ++:
|
||||||
|
#pragma SWIG nowarn=362,383
|
||||||
|
|
||||||
|
// Rename operators defined in utf8.h
|
||||||
|
%rename(utf8_to_charptr) operator char* () const;
|
||||||
|
%rename(utf8_to_wxstring) operator wxString () const;
|
||||||
|
|
||||||
|
#include <utf8.h>
|
||||||
|
%include <utf8.h>
|
||||||
|
|
||||||
|
%extend UTF8
|
||||||
|
{
|
||||||
|
const char* Cast_to_CChar() { return (self->c_str()); }
|
||||||
|
|
||||||
|
%pythoncode
|
||||||
|
%{
|
||||||
|
|
||||||
|
# Get the char buffer of the UTF8 string
|
||||||
|
def GetChars(self):
|
||||||
|
return self.Cast_to_CChar()
|
||||||
|
|
||||||
|
# Convert the UTF8 string to a python string
|
||||||
|
# Same as GetChars(), but more easy to use in print command
|
||||||
|
def __str__(self):
|
||||||
|
return self.GetChars()
|
||||||
|
|
||||||
|
%}
|
||||||
|
}
|
|
@ -32,6 +32,7 @@
|
||||||
%include <std_string.i>
|
%include <std_string.i>
|
||||||
%include <std_map.i>
|
%include <std_map.i>
|
||||||
%include <std_shared_ptr.i>
|
%include <std_shared_ptr.i>
|
||||||
|
%include <std_set.i>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
http://www.swig.org/Doc3.0/CPlusPlus11.html
|
http://www.swig.org/Doc3.0/CPlusPlus11.html
|
|
@ -0,0 +1,234 @@
|
||||||
|
|
||||||
|
//%module(directors="1") kiway
|
||||||
|
%module kiway
|
||||||
|
|
||||||
|
/*
|
||||||
|
%import _defs.i
|
||||||
|
%import _window.i
|
||||||
|
%import _toplvl.i
|
||||||
|
%threadWrapperOff // _defs.i turns on thread protection, turn it off
|
||||||
|
*/
|
||||||
|
|
||||||
|
%include ki_exception.i // affects all that follow it
|
||||||
|
|
||||||
|
%include pgm_base.h
|
||||||
|
%include frame_type.h
|
||||||
|
%include mail_type.h
|
||||||
|
%include project.h
|
||||||
|
%include kiway.h
|
||||||
|
%include kiway_express.h
|
||||||
|
|
||||||
|
%include kiway_player.i
|
||||||
|
|
||||||
|
|
||||||
|
HANDLE_EXCEPTIONS(KIWAY::Player)
|
||||||
|
|
||||||
|
%constant KIWAY Kiway;
|
||||||
|
|
||||||
|
%pythoncode
|
||||||
|
%{
|
||||||
|
#import wx
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <kiway.h>
|
||||||
|
#include <kiway_express.h>
|
||||||
|
#include <pgm_base.h>
|
||||||
|
|
||||||
|
#include <wx/app.h>
|
||||||
|
#include <wx/stdpaths.h>
|
||||||
|
#include <wx/wxPython/wxPython_int.h>
|
||||||
|
|
||||||
|
|
||||||
|
// Only a single KIWAY is supported in this single_top top level component,
|
||||||
|
// which is dedicated to loading only a single DSO.
|
||||||
|
KIWAY Kiway( &Pgm(), KFCTL_PY_PROJECT_SUITE );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Struct PGM_PYTHON
|
||||||
|
* implements PGM_BASE with its own OnPgmInit() and OnPgmExit().
|
||||||
|
*/
|
||||||
|
static struct PGM_PYTHON : public PGM_BASE
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
bool OnPgmInit( wxApp* aWxApp )
|
||||||
|
{
|
||||||
|
// first thing: set m_wx_app
|
||||||
|
SetApp( aWxApp );
|
||||||
|
|
||||||
|
if( !initPgm() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Use KIWAY to create a top window, which registers its existence also.
|
||||||
|
// "TOP_FRAME" is a macro that is passed on compiler command line from CMake,
|
||||||
|
// and is one of the types in FRAME_T.
|
||||||
|
KIWAY_PLAYER* frame = Kiway.Player( FRAME_PCB, true );
|
||||||
|
|
||||||
|
Kiway.SetTop( frame );
|
||||||
|
|
||||||
|
App().SetTopWindow( frame ); // wxApp gets a face.
|
||||||
|
|
||||||
|
// Open project or file specified on the command line:
|
||||||
|
int argc = App().argc;
|
||||||
|
|
||||||
|
if( argc > 1 )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
gerbview handles multiple project data files, i.e. gerber files on
|
||||||
|
cmd line. Others currently do not, they handle only one. For common
|
||||||
|
code simplicity we simply pass all the arguments in however, each
|
||||||
|
program module can do with them what they want, ignore, complain
|
||||||
|
whatever. We don't establish policy here, as this is a multi-purpose
|
||||||
|
launcher.
|
||||||
|
*/
|
||||||
|
|
||||||
|
std::vector<wxString> argSet;
|
||||||
|
|
||||||
|
for( int i=1; i<argc; ++i )
|
||||||
|
{
|
||||||
|
argSet.push_back( App().argv[i] );
|
||||||
|
}
|
||||||
|
|
||||||
|
// special attention to the first argument: argv[1] (==argSet[0])
|
||||||
|
wxFileName argv1( argSet[0] );
|
||||||
|
|
||||||
|
if( argc == 2 )
|
||||||
|
{
|
||||||
|
#if defined(PGM_DATA_FILE_EXT)
|
||||||
|
// PGM_DATA_FILE_EXT, if present, may be different for each compile,
|
||||||
|
// it may come from CMake on the compiler command line, but often does not.
|
||||||
|
// This facillity is mostly useful for those program modules
|
||||||
|
// supporting a single argv[1].
|
||||||
|
if( !argv1.GetExt() )
|
||||||
|
argv1.SetExt( wxT( PGM_DATA_FILE_EXT ) );
|
||||||
|
#endif
|
||||||
|
argv1.MakeAbsolute();
|
||||||
|
|
||||||
|
argSet[0] = argv1.GetFullPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the KIWAY_PLAYER::OpenProjectFiles() API function:
|
||||||
|
if( !frame->OpenProjectFiles( argSet ) )
|
||||||
|
{
|
||||||
|
// OpenProjectFiles() API asks that it report failure to the UI.
|
||||||
|
// Nothing further to say here.
|
||||||
|
|
||||||
|
// We've already initialized things at this point, but wx won't call OnExit if
|
||||||
|
// we fail out. Call our own cleanup routine here to ensure the relevant resources
|
||||||
|
// are freed at the right time (if they aren't, segfaults will occur).
|
||||||
|
OnPgmExit();
|
||||||
|
|
||||||
|
// Fail the process startup if the file could not be opened,
|
||||||
|
// although this is an optional choice, one that can be reversed
|
||||||
|
// also in the KIFACE specific OpenProjectFiles() return value.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
frame->Show();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnPgmExit()
|
||||||
|
{
|
||||||
|
Kiway.OnKiwayEnd();
|
||||||
|
|
||||||
|
saveCommonSettings();
|
||||||
|
|
||||||
|
// Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl
|
||||||
|
// earlier than wxApp and earlier than static destruction would.
|
||||||
|
PGM_BASE::destroy();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if 0 // multi-project
|
||||||
|
void PGM_KICAD::MacOpenFile( const wxString& aFileName )
|
||||||
|
{
|
||||||
|
#if defined(__WXMAC__)
|
||||||
|
|
||||||
|
KICAD_MANAGER_FRAME* frame = (KICAD_MANAGER_FRAME*) App().GetTopWindow();
|
||||||
|
|
||||||
|
frame->SetProjectFileName( aFileName );
|
||||||
|
|
||||||
|
wxCommandEvent loadEvent( 0, wxID_ANY );
|
||||||
|
|
||||||
|
frame->OnLoadProject( loadEvent );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
void MacOpenFile( const wxString& aFileName ) override
|
||||||
|
{
|
||||||
|
wxFileName filename( aFileName );
|
||||||
|
|
||||||
|
if( filename.FileExists() )
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
// this pulls in EDA_DRAW_FRAME type info, which we don't want in
|
||||||
|
// the link image.
|
||||||
|
KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( App().GetTopWindow() );
|
||||||
|
#else
|
||||||
|
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
|
||||||
|
#endif
|
||||||
|
if( frame )
|
||||||
|
frame->OpenProjectFiles( std::vector<wxString>( 1, aFileName ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} program;
|
||||||
|
|
||||||
|
|
||||||
|
PGM_BASE& Pgm()
|
||||||
|
{
|
||||||
|
return program;
|
||||||
|
}
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
/*
|
||||||
|
import ctypes, os, sys
|
||||||
|
libcef_so = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'libcef.so')
|
||||||
|
if os.path.exists(libcef_so):
|
||||||
|
*/
|
||||||
|
|
||||||
|
%extend PGM_BASE {
|
||||||
|
|
||||||
|
%pythoncode
|
||||||
|
%{
|
||||||
|
|
||||||
|
def OnPgmInit(self):
|
||||||
|
print "hereA"
|
||||||
|
|
||||||
|
if not self.InitPgm():
|
||||||
|
return False;
|
||||||
|
|
||||||
|
print "hereB"
|
||||||
|
|
||||||
|
try:
|
||||||
|
# A KIWAY_PLAYER is a wx.Window
|
||||||
|
frame = Kiway.Player( FRAME_SCH, True )
|
||||||
|
|
||||||
|
print "here0"
|
||||||
|
|
||||||
|
except IOError as e:
|
||||||
|
print 'Player()', e
|
||||||
|
return None
|
||||||
|
|
||||||
|
print "here1"
|
||||||
|
|
||||||
|
Kiway.SetTop(frame)
|
||||||
|
|
||||||
|
print "here2"
|
||||||
|
|
||||||
|
return frame
|
||||||
|
%}
|
||||||
|
};
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
// Swig interface to classes KIWAY_PLAYER and KIWAY_HOLDER
|
||||||
|
|
||||||
|
class wxFrame
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class KIWAY_PLAYER : public wxFrame
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
%ignore wxFrame;
|
||||||
|
%ignore KIWAY_PLAYER;
|
||||||
|
|
||||||
|
//%include kiway_player.h
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <kiway_player.h>
|
||||||
|
%}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __wx_helpers_h
|
#ifndef WX_HELPERS_H_
|
||||||
#define __wx_helpers_h
|
#define WX_HELPERS_H_
|
||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#include <wx/intl.h>
|
#include <wx/intl.h>
|
||||||
|
@ -15,4 +15,4 @@ PyObject* wx2PyString( const wxString& src );
|
||||||
void wxSetDefaultPyEncoding( const char* encoding );
|
void wxSetDefaultPyEncoding( const char* encoding );
|
||||||
const char* wxGetDefaultPyEncoding();
|
const char* wxGetDefaultPyEncoding();
|
||||||
|
|
||||||
#endif
|
#endif // WX_HELPERS_H_
|
|
@ -103,6 +103,7 @@ as such! As such, it is OK to use UTF8 characters:
|
||||||
#include <project.h>
|
#include <project.h>
|
||||||
#include <frame_type.h>
|
#include <frame_type.h>
|
||||||
#include <mail_type.h>
|
#include <mail_type.h>
|
||||||
|
#include <ki_exception.h>
|
||||||
|
|
||||||
|
|
||||||
#define VTBL_ENTRY virtual
|
#define VTBL_ENTRY virtual
|
||||||
|
@ -114,6 +115,7 @@ as such! As such, it is OK to use UTF8 characters:
|
||||||
// be mangled.
|
// be mangled.
|
||||||
#define KIFACE_INSTANCE_NAME_AND_VERSION "KIFACE_1"
|
#define KIFACE_INSTANCE_NAME_AND_VERSION "KIFACE_1"
|
||||||
|
|
||||||
|
#ifndef SWIG
|
||||||
#if defined(__linux__) || defined(__FreeBSD__)
|
#if defined(__linux__) || defined(__FreeBSD__)
|
||||||
#define LIB_ENV_VAR wxT( "LD_LIBRARY_PATH" )
|
#define LIB_ENV_VAR wxT( "LD_LIBRARY_PATH" )
|
||||||
#elif defined(__WXMAC__)
|
#elif defined(__WXMAC__)
|
||||||
|
@ -123,7 +125,7 @@ as such! As such, it is OK to use UTF8 characters:
|
||||||
#else
|
#else
|
||||||
#error Platform support missing
|
#error Platform support missing
|
||||||
#endif
|
#endif
|
||||||
|
#endif // SWIG
|
||||||
|
|
||||||
class wxConfigBase;
|
class wxConfigBase;
|
||||||
class wxWindow;
|
class wxWindow;
|
||||||
|
@ -151,6 +153,8 @@ struct KIFACE
|
||||||
// order of functions in this listing unless you recompile all clients of
|
// order of functions in this listing unless you recompile all clients of
|
||||||
// this interface.
|
// this interface.
|
||||||
|
|
||||||
|
virtual ~KIFACE() throw() {}
|
||||||
|
|
||||||
#define KFCTL_STANDALONE (1<<0) ///< Am running as a standalone Top.
|
#define KFCTL_STANDALONE (1<<0) ///< Am running as a standalone Top.
|
||||||
#define KFCTL_CPP_PROJECT_SUITE (1<<1) ///< Am running under C++ project mgr, possibly with others
|
#define KFCTL_CPP_PROJECT_SUITE (1<<1) ///< Am running under C++ project mgr, possibly with others
|
||||||
#define KFCTL_PY_PROJECT_SUITE (1<<2) ///< Am running under python project mgr, possibly with others
|
#define KFCTL_PY_PROJECT_SUITE (1<<2) ///< Am running under python project mgr, possibly with others
|
||||||
|
@ -269,6 +273,8 @@ public:
|
||||||
KIWAY_FACE_COUNT
|
KIWAY_FACE_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
~KIWAY() throw () {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function KifaceType
|
* Function KifaceType
|
||||||
* is a simple mapping function which returns the FACE_T which is known to
|
* is a simple mapping function which returns the FACE_T which is known to
|
||||||
|
@ -278,7 +284,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static FACE_T KifaceType( FRAME_T aFrameType );
|
static FACE_T KifaceType( FRAME_T aFrameType );
|
||||||
|
|
||||||
|
|
||||||
// If you change the vtable, recompile all of KiCad.
|
// If you change the vtable, recompile all of KiCad.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -303,6 +308,8 @@ public:
|
||||||
*
|
*
|
||||||
* @return KIWAY_PLAYER* - a valid opened KIWAY_PLAYER or NULL if there
|
* @return KIWAY_PLAYER* - a valid opened KIWAY_PLAYER or NULL if there
|
||||||
* is something wrong or doCreate was false and the player has yet to be created.
|
* is something wrong or doCreate was false and the player has yet to be created.
|
||||||
|
*
|
||||||
|
* @throw IO_ERROR if the *.kiface file could not be found, filled with text saying what.
|
||||||
*/
|
*/
|
||||||
VTBL_ENTRY KIWAY_PLAYER* Player( FRAME_T aFrameType, bool doCreate = true, KIWAY_PLAYER* aParent = NULL );
|
VTBL_ENTRY KIWAY_PLAYER* Player( FRAME_T aFrameType, bool doCreate = true, KIWAY_PLAYER* aParent = NULL );
|
||||||
|
|
||||||
|
@ -368,8 +375,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/// Get the full path & name of the DSO holding the requested FACE_T.
|
/// Get the [path &] name of the DSO holding the requested FACE_T.
|
||||||
static const wxString dso_full_path( FACE_T aFaceId );
|
const wxString dso_search_path( FACE_T aFaceId );
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/// hooked into m_top in SetTop(), marks child frame as closed.
|
/// hooked into m_top in SetTop(), marks child frame as closed.
|
||||||
|
@ -400,7 +407,6 @@ private:
|
||||||
|
|
||||||
wxFrame* m_top; // Usually m_top is the Project manager
|
wxFrame* m_top; // Usually m_top is the Project manager
|
||||||
|
|
||||||
|
|
||||||
// a string array ( size KIWAY_PLAYER_COUNT ) to Store the frame name
|
// a string array ( size KIWAY_PLAYER_COUNT ) to Store the frame name
|
||||||
// of PLAYER frames which were run.
|
// of PLAYER frames which were run.
|
||||||
// A non empty name means only a PLAYER was run at least one time.
|
// A non empty name means only a PLAYER was run at least one time.
|
||||||
|
@ -413,20 +419,11 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
#ifndef SWIG
|
||||||
/// Given aProject, return its KIWAY*
|
// provided by single_top.cpp and kicad.cpp;
|
||||||
inline KIWAY* PrjToKiway( PROJECT* aProject )
|
extern KIWAY Kiway;
|
||||||
{
|
// whereas python launchers: single_top.py and project manager instantiate as a python object
|
||||||
// It's ugly, but isolated. The compiler should simply do what's
|
#endif
|
||||||
// it's told to do here and shut up.
|
|
||||||
KIWAY* p = 0;
|
|
||||||
ptrdiff_t offset = (char*) &p->m_project - (char*) p;
|
|
||||||
|
|
||||||
return (KIWAY*) ((char*)aProject - offset);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern KIWAY Kiway; // provided by single_top.cpp and kicad.cpp
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -444,16 +441,18 @@ extern KIWAY Kiway; // provided by single_top.cpp and kicad.cpp
|
||||||
*/
|
*/
|
||||||
typedef KIFACE* KIFACE_GETTER_FUNC( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
|
typedef KIFACE* KIFACE_GETTER_FUNC( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SWIG
|
||||||
|
|
||||||
/// No name mangling. Each KIFACE (DSO/DLL) will implement this once.
|
/// No name mangling. Each KIFACE (DSO/DLL) will implement this once.
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
#if defined(BUILD_KIWAY_DLL)
|
#if defined(BUILD_KIWAY_DLL)
|
||||||
MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
|
MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
|
||||||
#else
|
#else
|
||||||
KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
|
KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // SWIG
|
||||||
|
|
||||||
#endif // KIWAY_H_
|
#endif // KIWAY_H_
|
||||||
|
|
|
@ -105,7 +105,11 @@ class WX_EVENT_LOOP;
|
||||||
* EDA_BASE_FRAME would not have sufficed because BM2CMP_FRAME_BASE is not
|
* EDA_BASE_FRAME would not have sufficed because BM2CMP_FRAME_BASE is not
|
||||||
* derived from it.
|
* derived from it.
|
||||||
*/
|
*/
|
||||||
|
#ifdef SWIG
|
||||||
|
class KIWAY_PLAYER : public wxFrame, public KIWAY_HOLDER
|
||||||
|
#else
|
||||||
class KIWAY_PLAYER : public EDA_BASE_FRAME, public KIWAY_HOLDER
|
class KIWAY_PLAYER : public EDA_BASE_FRAME, public KIWAY_HOLDER
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
|
KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
|
||||||
|
@ -118,7 +122,7 @@ public:
|
||||||
const wxPoint& aPos, const wxSize& aSize, long aStyle,
|
const wxPoint& aPos, const wxSize& aSize, long aStyle,
|
||||||
const wxString& aWdoName = wxFrameNameStr );
|
const wxString& aWdoName = wxFrameNameStr );
|
||||||
|
|
||||||
~KIWAY_PLAYER();
|
~KIWAY_PLAYER() throw();
|
||||||
|
|
||||||
//----<Cross Module API>-----------------------------------------------------
|
//----<Cross Module API>-----------------------------------------------------
|
||||||
|
|
||||||
|
@ -238,7 +242,9 @@ protected:
|
||||||
wxString m_modal_string;
|
wxString m_modal_string;
|
||||||
bool m_modal_ret_val; // true if a selection was made
|
bool m_modal_ret_val; // true if a selection was made
|
||||||
|
|
||||||
|
#ifndef SWIG
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor LSET( const LAYER_ID* aArray, unsigned aCount )
|
* Constructor LSET( const LAYER_ID* aArray, unsigned aCount )
|
||||||
* works well with an arry or LSEQ.
|
* works well with an array or LSEQ.
|
||||||
*/
|
*/
|
||||||
LSET( const LAYER_ID* aArray, unsigned aCount );
|
LSET( const LAYER_ID* aArray, unsigned aCount );
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <wx/wx.h>
|
#include <wx/wx.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <set>
|
||||||
#include <memory> // std::shared_ptr
|
#include <memory> // std::shared_ptr
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,12 +124,14 @@ template <typename T> inline const T& Clamp( const T& lower, const T& value, con
|
||||||
/// Declare a std::vector and also the swig %template in unison
|
/// Declare a std::vector and also the swig %template in unison
|
||||||
#define DECL_VEC_FOR_SWIG(TypeName, MemberType) namespace std { %template(TypeName) vector<MemberType>; } typedef std::vector<MemberType> TypeName;
|
#define DECL_VEC_FOR_SWIG(TypeName, MemberType) namespace std { %template(TypeName) vector<MemberType>; } typedef std::vector<MemberType> TypeName;
|
||||||
#define DECL_MAP_FOR_SWIG(TypeName, KeyType, ValueType) namespace std { %template(TypeName) map<KeyType, ValueType>; } typedef std::map<KeyType, ValueType> TypeName;
|
#define DECL_MAP_FOR_SWIG(TypeName, KeyType, ValueType) namespace std { %template(TypeName) map<KeyType, ValueType>; } typedef std::map<KeyType, ValueType> TypeName;
|
||||||
#define DECL_SPTR_FOR_SWIG(TypeName, MemberType) namespace std { %template(TypeName) std::shared_ptr<MemberType>; } typedef std::shared_ptr<MemberType> TypeName;
|
#define DECL_SPTR_FOR_SWIG(TypeName, MemberType) %shared_ptr(MemberType) namespace std { %template(TypeName) shared_ptr<MemberType>; } typedef std::shared_ptr<MemberType> TypeName;
|
||||||
|
#define DECL_SET_FOR_SWIG(TypeName, MemberType) namespace std { %template(TypeName) set<MemberType>; } typedef std::set<MemberType> TypeName;
|
||||||
#else
|
#else
|
||||||
/// Declare a std::vector but no swig %template
|
/// Declare a std::vector but no swig %template
|
||||||
#define DECL_VEC_FOR_SWIG(TypeName, MemberType) typedef std::vector<MemberType> TypeName;
|
#define DECL_VEC_FOR_SWIG(TypeName, MemberType) typedef std::vector<MemberType> TypeName;
|
||||||
#define DECL_MAP_FOR_SWIG(TypeName, KeyType, ValueType) typedef std::map<KeyType, ValueType> TypeName;
|
#define DECL_MAP_FOR_SWIG(TypeName, KeyType, ValueType) typedef std::map<KeyType, ValueType> TypeName;
|
||||||
#define DECL_SPTR_FOR_SWIG(TypeName, MemberType) typedef std::shared_ptr<MemberType> TypeName;
|
#define DECL_SPTR_FOR_SWIG(TypeName, MemberType) typedef std::shared_ptr<MemberType> TypeName;
|
||||||
|
#define DECL_SET_FOR_SWIG(TypeName, MemberType) typedef std::set<MemberType> TypeName;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // MACROS_H
|
#endif // MACROS_H
|
||||||
|
|
|
@ -64,6 +64,8 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~ENV_VAR_ITEM() throw() {} // tell SWIG no exception
|
||||||
|
|
||||||
bool GetDefinedExternally() const { return m_isDefinedExternally; }
|
bool GetDefinedExternally() const { return m_isDefinedExternally; }
|
||||||
void SetDefinedExternally( bool aIsDefinedExternally )
|
void SetDefinedExternally( bool aIsDefinedExternally )
|
||||||
{
|
{
|
||||||
|
@ -106,16 +108,31 @@ class PGM_BASE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PGM_BASE();
|
PGM_BASE();
|
||||||
~PGM_BASE();
|
virtual ~PGM_BASE();
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/*
|
||||||
|
|
||||||
|
Derived classes must implement these two functions: OnPgmInit() and
|
||||||
|
OnPgmExit(), and since they are only called from same source file as their
|
||||||
|
implementation, these need not be virtual here. In fact, in the case of
|
||||||
|
python project manager's class PGM_PYTHON, these functions are actually
|
||||||
|
written in python. In total there are three implementations, corresponding
|
||||||
|
to the three defines given by kiface.h's KFCTL_* #defines.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function OnPgmInit
|
* Function OnPgmInit
|
||||||
* this is the first executed function (like main() )
|
* this is the first executed function (like main() )
|
||||||
* @return true if the application can be started.
|
* @return true if the application can be started.
|
||||||
*/
|
*/
|
||||||
virtual bool OnPgmInit( wxApp* aWxApp ) = 0; // call this from wxApp::OnInit()
|
virtual bool OnPgmInit() = 0; // call this from wxApp::OnInit()
|
||||||
|
|
||||||
virtual void OnPgmExit() = 0; // call this from wxApp::OnExit()
|
virtual void OnPgmExit() = 0; // call this from wxApp::OnExit()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//----<Cross Module API>-----------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function MacOpenFile
|
* Function MacOpenFile
|
||||||
|
@ -123,9 +140,7 @@ public:
|
||||||
* MacOSX requires it for file association.
|
* MacOSX requires it for file association.
|
||||||
* @see http://wiki.wxwidgets.org/WxMac-specific_topics
|
* @see http://wiki.wxwidgets.org/WxMac-specific_topics
|
||||||
*/
|
*/
|
||||||
virtual void MacOpenFile( const wxString& aFileName ) = 0;
|
VTBL_ENTRY void MacOpenFile( const wxString& aFileName ) = 0;
|
||||||
|
|
||||||
//----<Cross Module API>-----------------------------------------------------
|
|
||||||
|
|
||||||
VTBL_ENTRY wxConfigBase* CommonSettings() const { return m_common_settings; }
|
VTBL_ENTRY wxConfigBase* CommonSettings() const { return m_common_settings; }
|
||||||
|
|
||||||
|
@ -273,20 +288,14 @@ public:
|
||||||
/**
|
/**
|
||||||
* Function App
|
* Function App
|
||||||
* returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP, or kicad.exe.
|
* returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP, or kicad.exe.
|
||||||
* Use this function instead of wxGetApp().
|
* Should return what wxGetApp() returns.
|
||||||
*/
|
*/
|
||||||
VTBL_ENTRY wxApp& App()
|
VTBL_ENTRY wxApp& App();
|
||||||
{
|
|
||||||
wxASSERT( m_wx_app );
|
|
||||||
return *m_wx_app;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----</Cross Module API>----------------------------------------------------
|
//----</Cross Module API>----------------------------------------------------
|
||||||
|
|
||||||
static const wxChar workingDirKey[];
|
static const wxChar workingDirKey[];
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function initPgm
|
* Function initPgm
|
||||||
* initializes this program (process) in a KiCad standard way,
|
* initializes this program (process) in a KiCad standard way,
|
||||||
|
@ -298,7 +307,20 @@ protected:
|
||||||
* But nothing relating to DSOs or projects.
|
* But nothing relating to DSOs or projects.
|
||||||
* @return bool - true if success, false if failure and program is to terminate.
|
* @return bool - true if success, false if failure and program is to terminate.
|
||||||
*/
|
*/
|
||||||
bool initPgm();
|
bool InitPgm();
|
||||||
|
|
||||||
|
// The PGM_* classes can have difficulties at termination if they
|
||||||
|
// are not destroyed soon enough. Relying on a static destructor can be
|
||||||
|
// too late for contained objects like wxSingleInstanceChecker.
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function saveCommonSettings
|
||||||
|
* saves the program (process) settings subset which are stored .kicad_common
|
||||||
|
*/
|
||||||
|
void SaveCommonSettings();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function loadCommonSettings
|
* Function loadCommonSettings
|
||||||
|
@ -306,12 +328,6 @@ protected:
|
||||||
*/
|
*/
|
||||||
void loadCommonSettings();
|
void loadCommonSettings();
|
||||||
|
|
||||||
/**
|
|
||||||
* Function saveCommonSettings
|
|
||||||
* saves the program (process) settings subset which are stored .kicad_common
|
|
||||||
*/
|
|
||||||
void saveCommonSettings();
|
|
||||||
|
|
||||||
/// prevents multiple instances of a program from being run at the same time.
|
/// prevents multiple instances of a program from being run at the same time.
|
||||||
wxSingleInstanceChecker* m_pgm_checker;
|
wxSingleInstanceChecker* m_pgm_checker;
|
||||||
|
|
||||||
|
@ -354,17 +370,11 @@ protected:
|
||||||
|
|
||||||
/// Flag to indicate if the environment variable overwrite warning dialog should be shown.
|
/// Flag to indicate if the environment variable overwrite warning dialog should be shown.
|
||||||
bool m_show_env_var_dialog;
|
bool m_show_env_var_dialog;
|
||||||
|
|
||||||
wxApp* m_wx_app;
|
|
||||||
|
|
||||||
// The PGM_* classes can have difficulties at termination if they
|
|
||||||
// are not destroyed soon enough. Relying on a static destructor can be
|
|
||||||
// too late for contained objects like wxSingleInstanceChecker.
|
|
||||||
void destroy();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// The global Program "get" accessor.
|
/// The global Program "get" accessor.
|
||||||
|
/// Implemented in: 1) common/single_top.cpp, 2) kicad/kicad.cpp, and 3) scripting/kiway.i
|
||||||
extern PGM_BASE& Pgm();
|
extern PGM_BASE& Pgm();
|
||||||
|
|
||||||
#endif // PGM_BASE_H_
|
#endif // PGM_BASE_H_
|
||||||
|
|
|
@ -44,14 +44,15 @@ public:
|
||||||
m_bm( "kicad" ) // indicates a "$HOME/.kicad wxConfig like" config file.
|
m_bm( "kicad" ) // indicates a "$HOME/.kicad wxConfig like" config file.
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~PGM_KICAD()
|
~PGM_KICAD() throw()
|
||||||
{
|
{
|
||||||
destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OnPgmInit( wxApp* aWxApp ); // overload PGM_BASE virtual
|
bool OnPgmInit();
|
||||||
void OnPgmExit(); // overload PGM_BASE virtual
|
void OnPgmExit();
|
||||||
void MacOpenFile( const wxString& aFileName ); // overload PGM_BASE virtual
|
|
||||||
|
void MacOpenFile( const wxString& aFileName );
|
||||||
|
|
||||||
wxFileHistory& GetFileHistory() { return m_bm.m_history; }
|
wxFileHistory& GetFileHistory() { return m_bm.m_history; }
|
||||||
|
|
||||||
|
@ -61,12 +62,12 @@ public:
|
||||||
|
|
||||||
wxString GetHelpFileName() { return m_bm.m_help_file; }
|
wxString GetHelpFileName() { return m_bm.m_help_file; }
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// The PGM_* classes can have difficulties at termination if they
|
// The PGM_* classes can have difficulties at termination if they
|
||||||
// are not destroyed soon enough. Relying on a static destructor can be
|
// are not destroyed soon enough. Relying on a static destructor can be
|
||||||
// too late for contained objects like wxSingleInstanceChecker.
|
// too late for contained objects like wxSingleInstanceChecker.
|
||||||
void destroy();
|
void Destroy();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
BIN_MOD m_bm;
|
BIN_MOD m_bm;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,16 +5,14 @@ add_subdirectory(router)
|
||||||
# psnrouter depends on make_lexer outputs in common (bug # 1285878 )
|
# psnrouter depends on make_lexer outputs in common (bug # 1285878 )
|
||||||
add_dependencies( pnsrouter pcbcommon )
|
add_dependencies( pnsrouter pcbcommon )
|
||||||
|
|
||||||
|
set( WXPYTHON_SWIG_DIR /usr/include/wx-3.0/wx/wxPython/i_files )
|
||||||
|
|
||||||
if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
|
if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
|
||||||
file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripting )
|
file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripting )
|
||||||
|
|
||||||
# SWIG 3.0 or later require for C++11 support.
|
|
||||||
find_package( SWIG 3.0 REQUIRED )
|
|
||||||
include( ${SWIG_USE_FILE} )
|
|
||||||
|
|
||||||
# Infrequently needed headers go at end of search paths, append to INC_AFTER
|
# Infrequently needed headers go at end of search paths, append to INC_AFTER
|
||||||
set( INC_AFTER ${INC_AFTER} ${CMAKE_CURRENT_SOURCE_DIR}/scripting )
|
set( INC_AFTER ${INC_AFTER} swig )
|
||||||
|
set( INC_AFTER ${INC_AFTER} ../common/swig )
|
||||||
|
|
||||||
#message( STATUS "pcbnew INC_AFTER:${INC_AFTER}" )
|
#message( STATUS "pcbnew INC_AFTER:${INC_AFTER}" )
|
||||||
endif()
|
endif()
|
||||||
|
@ -317,10 +315,10 @@ set( PCBNEW_SCRIPTING_DIALOGS
|
||||||
)
|
)
|
||||||
|
|
||||||
set( PCBNEW_SCRIPTING_PYTHON_HELPERS
|
set( PCBNEW_SCRIPTING_PYTHON_HELPERS
|
||||||
../scripting/wx_python_helpers.cpp
|
../common/swig/wx_python_helpers.cpp
|
||||||
../scripting/python_scripting.cpp
|
swig/python_scripting.cpp
|
||||||
scripting/pcbnew_scripting_helpers.cpp
|
swig/pcbnew_scripting_helpers.cpp
|
||||||
scripting/pcbnew_footprint_wizards.cpp
|
swig/pcbnew_footprint_wizards.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if( KICAD_SCRIPTING )
|
if( KICAD_SCRIPTING )
|
||||||
|
@ -335,10 +333,11 @@ endif()
|
||||||
if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
|
if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
|
||||||
|
|
||||||
set( SWIG_FLAGS
|
set( SWIG_FLAGS
|
||||||
-I${CMAKE_CURRENT_SOURCE_DIR}/../..
|
|
||||||
-I${CMAKE_CURRENT_SOURCE_DIR}
|
-I${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
-I${CMAKE_CURRENT_SOURCE_DIR}/../include
|
-I${CMAKE_CURRENT_SOURCE_DIR}/../include
|
||||||
-I${CMAKE_CURRENT_SOURCE_DIR}/../scripting
|
-I${CMAKE_CURRENT_SOURCE_DIR}/../scripting
|
||||||
|
-I${CMAKE_CURRENT_SOURCE_DIR}/../common/swig
|
||||||
|
-I${WXPYTHON_SWIG_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
if( DEBUG )
|
if( DEBUG )
|
||||||
|
@ -346,7 +345,6 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# collect CFLAGS , and pass them to swig later
|
# collect CFLAGS , and pass them to swig later
|
||||||
|
|
||||||
get_directory_property( DirDefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS )
|
get_directory_property( DirDefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS )
|
||||||
foreach( d ${DirDefs} )
|
foreach( d ${DirDefs} )
|
||||||
set( SWIG_FLAGS ${SWIG_FLAGS} -D${d} )
|
set( SWIG_FLAGS ${SWIG_FLAGS} -D${d} )
|
||||||
|
@ -370,21 +368,22 @@ if( KICAD_SCRIPTING )
|
||||||
DEPENDS pcbcommon
|
DEPENDS pcbcommon
|
||||||
DEPENDS plotcontroller.h
|
DEPENDS plotcontroller.h
|
||||||
DEPENDS exporters/gendrill_Excellon_writer.h
|
DEPENDS exporters/gendrill_Excellon_writer.h
|
||||||
DEPENDS scripting/pcbnew.i
|
DEPENDS swig/pcbnew.i
|
||||||
DEPENDS scripting/board.i
|
DEPENDS swig/board.i
|
||||||
DEPENDS scripting/board_item.i
|
DEPENDS swig/board_item.i
|
||||||
DEPENDS scripting/module.i
|
DEPENDS swig/module.i
|
||||||
DEPENDS scripting/plugins.i
|
DEPENDS swig/plugins.i
|
||||||
DEPENDS scripting/units.i
|
DEPENDS swig/units.i
|
||||||
DEPENDS ../scripting/dlist.i
|
DEPENDS ../common/swig/dlist.i
|
||||||
DEPENDS ../scripting/kicad.i
|
DEPENDS ../common/swig/kicad.i
|
||||||
DEPENDS ../scripting/wx.i
|
DEPENDS ../common/swig/wx.i
|
||||||
|
DEPENDS ../common/swig/ki_exception.i
|
||||||
DEPENDS ../scripting/kicadplugins.i
|
DEPENDS ../scripting/kicadplugins.i
|
||||||
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/docstrings
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/docstrings
|
||||||
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/docstrings/docstrings.i # this makes docstrings.i available if it doesn't exist
|
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/docstrings/docstrings.i # this makes docstrings.i available if it doesn't exist
|
||||||
|
|
||||||
COMMAND ${SWIG_EXECUTABLE} ${SWIG_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx scripting/pcbnew.i
|
COMMAND ${SWIG_EXECUTABLE} ${SWIG_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx swig/pcbnew.i
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripting/build_tools/fix_swig_imports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripting/build_tools/fix_swig_imports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
@ -406,11 +405,22 @@ if( KICAD_SCRIPTING_MODULES )
|
||||||
#message( "building pcbnew scripting" )
|
#message( "building pcbnew scripting" )
|
||||||
|
|
||||||
set( CMAKE_SWIG_FLAGS ${SWIG_FLAGS} )
|
set( CMAKE_SWIG_FLAGS ${SWIG_FLAGS} )
|
||||||
set_source_files_properties( scripting/pcbnew.i PROPERTIES CPLUSPLUS ON )
|
set_source_files_properties( swig/pcbnew.i PROPERTIES CPLUSPLUS ON )
|
||||||
|
|
||||||
|
# https://cmake.org/cmake/help/v3.2/module/UseSWIG.html
|
||||||
|
# Set this ..EXTRA_DEPS variable before invoking swig_add_module() macro
|
||||||
|
set( SWIG_MODULE_pcbnew_EXTRA_DEPS
|
||||||
|
swig/board.i
|
||||||
|
swig/board_item.i
|
||||||
|
swig/plugins.i
|
||||||
|
swig/units.i
|
||||||
|
../common/swig/ki_exception.i
|
||||||
|
../common/swig/kicad.i
|
||||||
|
)
|
||||||
|
|
||||||
swig_add_module( pcbnew
|
swig_add_module( pcbnew
|
||||||
python
|
python
|
||||||
scripting/pcbnew.i
|
swig/pcbnew.i
|
||||||
${PCBNEW_SCRIPTING_PYTHON_HELPERS}
|
${PCBNEW_SCRIPTING_PYTHON_HELPERS}
|
||||||
pcbnew.cpp
|
pcbnew.cpp
|
||||||
${PCBNEW_SRCS}
|
${PCBNEW_SRCS}
|
||||||
|
@ -674,14 +684,14 @@ if( KICAD_SCRIPTING )
|
||||||
add_dependencies( ScriptingPcbnewPyCopy ScriptingWxpythonCopy )
|
add_dependencies( ScriptingPcbnewPyCopy ScriptingWxpythonCopy )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# scripting plugins
|
# python plugins
|
||||||
install( DIRECTORY ${PROJECT_SOURCE_DIR}/pcbnew/scripting/plugins/
|
install( DIRECTORY ${PROJECT_SOURCE_DIR}/pcbnew/python/plugins/
|
||||||
DESTINATION ${KICAD_DATA}/scripting/plugins
|
DESTINATION ${KICAD_DATA}/scripting/plugins
|
||||||
FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
|
FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
|
||||||
)
|
)
|
||||||
|
|
||||||
# scripting python shell
|
# python shell
|
||||||
install( DIRECTORY ${PROJECT_SOURCE_DIR}/pcbnew/scripting/kicad_pyshell/
|
install( DIRECTORY ${PROJECT_SOURCE_DIR}/pcbnew/python/kicad_pyshell/
|
||||||
DESTINATION ${KICAD_DATA}/scripting/kicad_pyshell
|
DESTINATION ${KICAD_DATA}/scripting/kicad_pyshell
|
||||||
FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
|
FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
|
||||||
)
|
)
|
||||||
|
@ -724,17 +734,3 @@ if( APPLE )
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if( false ) # haven't been used in years.
|
|
||||||
# This one gets made only when testing.
|
|
||||||
add_executable( specctra_test EXCLUDE_FROM_ALL specctra_test.cpp specctra.cpp )
|
|
||||||
target_link_libraries( specctra_test common ${wxWidgets_LIBRARIES} )
|
|
||||||
|
|
||||||
|
|
||||||
# This one gets made only when testing.
|
|
||||||
add_executable( layer_widget_test WIN32 EXCLUDE_FROM_ALL
|
|
||||||
layer_widget.cpp
|
|
||||||
)
|
|
||||||
target_link_libraries( layer_widget_test common ${wxWidgets_LIBRARIES} )
|
|
||||||
endif()
|
|
||||||
|
|
|
@ -224,7 +224,7 @@ static void otherEnd( const TRACK& aTrack, const wxPoint& aNotThisEnd, wxPoint*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function find_vias_and_tracks_at
|
* Function find_vias_and_tracks_at
|
||||||
* collects TRACKs and VIAs at aPos and returns true if any were VIAs.
|
* collects TRACKs and VIAs at aPos and returns the @a track_count which excludes vias.
|
||||||
*/
|
*/
|
||||||
static int find_vias_and_tracks_at( TRACKS& at_next, TRACKS& in_net, LSET& lset, const wxPoint& next )
|
static int find_vias_and_tracks_at( TRACKS& at_next, TRACKS& in_net, LSET& lset, const wxPoint& next )
|
||||||
{
|
{
|
||||||
|
@ -296,10 +296,13 @@ static void checkConnectedTo( BOARD* aBoard, TRACKS* aList, const TRACKS& aTrack
|
||||||
if( next == aGoal )
|
if( next == aGoal )
|
||||||
return; // success
|
return; // success
|
||||||
|
|
||||||
if( aBoard->GetPad( next, lset ) )
|
// Want an exact match on the position of next, i.e. pad at next,
|
||||||
|
// not a forgiving HitTest() with tolerance type of match, otherwise the overall
|
||||||
|
// algorithm will not work. GetPadFast() is an exact match as I write this.
|
||||||
|
if( aBoard->GetPadFast( next, lset ) )
|
||||||
{
|
{
|
||||||
std::string m = StrPrintf(
|
std::string m = StrPrintf(
|
||||||
"there is an intervening pad at:(xy %s) between start:(xy %s) and goal:(xy %s)",
|
"intervening pad at:(xy %s) between start:(xy %s) and goal:(xy %s)",
|
||||||
BOARD_ITEM::FormatInternalUnits( next ).c_str(),
|
BOARD_ITEM::FormatInternalUnits( next ).c_str(),
|
||||||
BOARD_ITEM::FormatInternalUnits( aStart ).c_str(),
|
BOARD_ITEM::FormatInternalUnits( aStart ).c_str(),
|
||||||
BOARD_ITEM::FormatInternalUnits( aGoal ).c_str()
|
BOARD_ITEM::FormatInternalUnits( aGoal ).c_str()
|
||||||
|
@ -313,13 +316,13 @@ static void checkConnectedTo( BOARD* aBoard, TRACKS* aList, const TRACKS& aTrack
|
||||||
{
|
{
|
||||||
std::string m = StrPrintf(
|
std::string m = StrPrintf(
|
||||||
"found %d tracks intersecting at (xy %s), exactly 2 would be acceptable.",
|
"found %d tracks intersecting at (xy %s), exactly 2 would be acceptable.",
|
||||||
track_count,
|
track_count + aList->size() == 1 ? 1 : 0,
|
||||||
BOARD_ITEM::FormatInternalUnits( next ).c_str()
|
BOARD_ITEM::FormatInternalUnits( next ).c_str()
|
||||||
);
|
);
|
||||||
THROW_IO_ERROR( m );
|
THROW_IO_ERROR( m );
|
||||||
}
|
}
|
||||||
|
|
||||||
// reduce lset down to the layer that the only track at 'next' is on.
|
// reduce lset down to the layer that the last track at 'next' is on.
|
||||||
lset = aList->back()->GetLayerSet();
|
lset = aList->back()->GetLayerSet();
|
||||||
|
|
||||||
otherEnd( *aList->back(), next, &next );
|
otherEnd( *aList->back(), next, &next );
|
||||||
|
@ -334,21 +337,21 @@ static void checkConnectedTo( BOARD* aBoard, TRACKS* aList, const TRACKS& aTrack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TRACKS BOARD::TracksInNetBetweenPoints( const wxPoint& aStartPos, const wxPoint& aEndPos, int aNetCode )
|
TRACKS BOARD::TracksInNetBetweenPoints( const wxPoint& aStartPos, const wxPoint& aGoalPos, int aNetCode )
|
||||||
{
|
{
|
||||||
TRACKS in_between_pts;
|
TRACKS in_between_pts;
|
||||||
TRACKS on_start_pad;
|
TRACKS on_start_point;
|
||||||
TRACKS in_net = TracksInNet( aNetCode ); // a small subset of TRACKs and VIAs
|
TRACKS in_net = TracksInNet( aNetCode ); // a small subset of TRACKs and VIAs
|
||||||
|
|
||||||
for( auto t : in_net )
|
for( auto t : in_net )
|
||||||
{
|
{
|
||||||
if( t->Type() == PCB_TRACE_T && ( t->GetStart() == aStartPos || t->GetEnd() == aStartPos ) )
|
if( t->Type() == PCB_TRACE_T && ( t->GetStart() == aStartPos || t->GetEnd() == aStartPos ) )
|
||||||
on_start_pad.push_back( t );
|
on_start_point.push_back( t );
|
||||||
}
|
}
|
||||||
|
|
||||||
IO_ERROR last_error;
|
wxString per_path_problem_text;
|
||||||
|
|
||||||
for( auto t : on_start_pad )
|
for( auto t : on_start_point ) // explore each trace (path) leaving aStartPos
|
||||||
{
|
{
|
||||||
// checkConnectedTo() fills in_between_pts on every attempt. For failures
|
// checkConnectedTo() fills in_between_pts on every attempt. For failures
|
||||||
// this set needs to be cleared.
|
// this set needs to be cleared.
|
||||||
|
@ -356,11 +359,12 @@ TRACKS BOARD::TracksInNetBetweenPoints( const wxPoint& aStartPos, const wxPoint&
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
checkConnectedTo( this, &in_between_pts, in_net, aEndPos, aStartPos, t );
|
checkConnectedTo( this, &in_between_pts, in_net, aGoalPos, aStartPos, t );
|
||||||
}
|
}
|
||||||
catch( const IO_ERROR& ioe ) // means not connected
|
catch( const IO_ERROR& ioe ) // means not connected
|
||||||
{
|
{
|
||||||
last_error = ioe;
|
per_path_problem_text += "\n\t";
|
||||||
|
per_path_problem_text += ioe.Problem();
|
||||||
continue; // keep trying, there may be other paths leaving from aStartPos
|
continue; // keep trying, there may be other paths leaving from aStartPos
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,17 +373,13 @@ TRACKS BOARD::TracksInNetBetweenPoints( const wxPoint& aStartPos, const wxPoint&
|
||||||
return in_between_pts;
|
return in_between_pts;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( on_start_pad.size() == 1 )
|
wxString m = wxString::Format(
|
||||||
throw last_error;
|
"no clean path connecting start:(xy %s) with goal:(xy %s)",
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string m = StrPrintf(
|
|
||||||
"no path connecting start:(xy %s) with end:(xy %s)",
|
|
||||||
BOARD_ITEM::FormatInternalUnits( aStartPos ).c_str(),
|
BOARD_ITEM::FormatInternalUnits( aStartPos ).c_str(),
|
||||||
BOARD_ITEM::FormatInternalUnits( aEndPos ).c_str()
|
BOARD_ITEM::FormatInternalUnits( aGoalPos ).c_str()
|
||||||
);
|
);
|
||||||
THROW_IO_ERROR( m );
|
|
||||||
}
|
THROW_IO_ERROR( m + per_path_problem_text );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -405,6 +405,8 @@ void BOARD::chainMarkedSegments( wxPoint aPosition, const LSET& aLayerSet, TRACK
|
||||||
*/
|
*/
|
||||||
for( ; ; )
|
for( ; ; )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if( GetPad( aPosition, layer_set ) != NULL )
|
if( GetPad( aPosition, layer_set ) != NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -1309,8 +1309,6 @@ public:
|
||||||
* Function TrackInNet
|
* Function TrackInNet
|
||||||
* collects all the TRACKs and VIAs that are members of a net given by aNetCode.
|
* collects all the TRACKs and VIAs that are members of a net given by aNetCode.
|
||||||
* Used from python.
|
* Used from python.
|
||||||
* @param aList is a non-owning container that is appended to with the TRACKs and VIAs,
|
|
||||||
* and is not initiallly cleared.
|
|
||||||
* @param aNetCode gives the id of the net.
|
* @param aNetCode gives the id of the net.
|
||||||
* @return TRACKS - which are in the net identified by @a aNetCode.
|
* @return TRACKS - which are in the net identified by @a aNetCode.
|
||||||
*/
|
*/
|
||||||
|
@ -1321,17 +1319,19 @@ public:
|
||||||
* collects all the TRACKs and VIAs that are members of a net given by aNetCode and that
|
* collects all the TRACKs and VIAs that are members of a net given by aNetCode and that
|
||||||
* make up a path between two end points. The end points must be carefully chosen,
|
* make up a path between two end points. The end points must be carefully chosen,
|
||||||
* and are typically the locations of two neighboring pads. The function fails if there
|
* and are typically the locations of two neighboring pads. The function fails if there
|
||||||
* is an intervening pad or a 3 way intersection at a track or via.
|
* is an intervening pad or a 3 way intersection at a track or via. The seeking starts
|
||||||
|
* at @a aStartPos and strives to travel to @a aGoalPos.
|
||||||
* Used from python.
|
* Used from python.
|
||||||
* @param aStartPos must correspond to a point on the BOARD which has a TRACK end or start,
|
* @param aStartPos must correspond to a point on the BOARD which has a TRACK end or start,
|
||||||
* typically the location of either a via or pad.
|
* typically the location of either a via or pad.
|
||||||
* @param aEndPos must correspond to a point on the BOARD which has a TRACK end or start,
|
* @param aGoalPos must correspond to a point on the BOARD which has a TRACK end or start,
|
||||||
* typically the location of either a via or pad.
|
* typically the location of either a via or pad.
|
||||||
* @param aNetCode gives the id of the net.
|
* @param aNetCode gives the id of the net.
|
||||||
* @return TRACKS - non empty if success, empty if your aStartPos or aEndPos are bad or
|
* @return TRACKS - non empty if success, empty if your aStartPos or aEndPos are bad or
|
||||||
* the net is interrupted along the way by an intervening D_PAD or a 3 way path.
|
* the net is interrupted along the way by an intervening D_PAD or a 3 way path.
|
||||||
|
* @throw IO_ERROR in order to convey detailed error reason upon failure.
|
||||||
*/
|
*/
|
||||||
TRACKS TracksInNetBetweenPoints( const wxPoint& aStartPos, const wxPoint& aEndPos, int aNetCode );
|
TRACKS TracksInNetBetweenPoints( const wxPoint& aStartPos, const wxPoint& aGoalPos, int aNetCode );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetFootprint
|
* Function GetFootprint
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
|
|
||||||
// This will get mapped to "kicad_default" in the specctra_export.
|
// This will get mapped to "kicad_default" in the specctra_export.
|
||||||
const wxChar NETCLASS::Default[] = wxT( "Default" );
|
const char NETCLASS::Default[] = "Default";
|
||||||
|
|
||||||
// Initial values for netclass initialization
|
// Initial values for netclass initialization
|
||||||
const int NETCLASS::DEFAULT_CLEARANCE = Millimeter2iu( 0.2 ); // track to track and track to pads clearance
|
const int NETCLASS::DEFAULT_CLEARANCE = Millimeter2iu( 0.2 ); // track to track and track to pads clearance
|
||||||
|
|
|
@ -43,6 +43,9 @@ class BOARD;
|
||||||
class BOARD_DESIGN_SETTINGS;
|
class BOARD_DESIGN_SETTINGS;
|
||||||
|
|
||||||
|
|
||||||
|
DECL_SET_FOR_SWIG( STRINGSET, wxString )
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class NETCLASS
|
* Class NETCLASS
|
||||||
* handles a collection of nets and the parameters used to route or
|
* handles a collection of nets and the parameters used to route or
|
||||||
|
@ -66,8 +69,6 @@ protected:
|
||||||
wxString m_Name; ///< Name of the net class
|
wxString m_Name; ///< Name of the net class
|
||||||
wxString m_Description; ///< what this NETCLASS is for.
|
wxString m_Description; ///< what this NETCLASS is for.
|
||||||
|
|
||||||
typedef std::set<wxString> STRINGSET;
|
|
||||||
|
|
||||||
STRINGSET m_Members; ///< names of NET members of this class
|
STRINGSET m_Members; ///< names of NET members of this class
|
||||||
|
|
||||||
/// The units on these parameters is Internal Units (1 nm)
|
/// The units on these parameters is Internal Units (1 nm)
|
||||||
|
@ -86,7 +87,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const wxChar Default[]; ///< the name of the default NETCLASS
|
static const char Default[]; ///< the name of the default NETCLASS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -163,6 +164,8 @@ public:
|
||||||
m_Members.erase( aName );
|
m_Members.erase( aName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STRINGSET& NetNames() { return m_Members; } ///< for SWIG
|
||||||
|
|
||||||
const wxString& GetDescription() const { return m_Description; }
|
const wxString& GetDescription() const { return m_Description; }
|
||||||
void SetDescription( const wxString& aDesc ) { m_Description = aDesc; }
|
void SetDescription( const wxString& aDesc ) { m_Description = aDesc; }
|
||||||
|
|
||||||
|
@ -277,10 +280,10 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Add
|
* Function Add
|
||||||
* takes ownership of \a aNetclass and puts it into this NETCLASSES container.
|
* takes \a aNetclass and puts it into this NETCLASSES container.
|
||||||
* @param aNetclass is netclass to add
|
* @param aNetclass is netclass to add
|
||||||
* @return true if the name within aNetclass is unique and it could be inserted OK,
|
* @return true if the name within aNetclass is unique and it could be inserted OK,
|
||||||
* else false because the name was not unique and caller still owns aNetclass.
|
* else false because the name was not unique.
|
||||||
*/
|
*/
|
||||||
bool Add( NETCLASSPTR aNetclass );
|
bool Add( NETCLASSPTR aNetclass );
|
||||||
|
|
||||||
|
@ -300,6 +303,8 @@ public:
|
||||||
*/
|
*/
|
||||||
NETCLASSPTR Find( const wxString& aName ) const;
|
NETCLASSPTR Find( const wxString& aName ) const;
|
||||||
|
|
||||||
|
/// Provide public access to m_NetClasses so it gets swigged.
|
||||||
|
NETCLASS_MAP& NetClasses() { return m_NetClasses; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CLASS_NETCLASS_H
|
#endif // CLASS_NETCLASS_H
|
||||||
|
|
|
@ -619,8 +619,7 @@ void PCB_PARSER::parseGeneralSection() throw( IO_ERROR, PARSE_ERROR )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: // Skip everything but the board thickness.
|
default: // Skip everything but the board thickness.
|
||||||
wxLogDebug( wxT( "Skipping general section token %s " ),
|
//wxLogDebug( wxT( "Skipping general section token %s " ), GetChars( GetTokenString( token ) ) );
|
||||||
GetChars( GetTokenString( token ) ) );
|
|
||||||
|
|
||||||
while( ( token = NextTok() ) != T_RIGHT )
|
while( ( token = NextTok() ) != T_RIGHT )
|
||||||
{
|
{
|
||||||
|
|
0
pcbnew/scripting/examples/createFPC40.py → pcbnew/python/examples/createFPC40.py
Executable file → Normal file
0
pcbnew/scripting/examples/createFPC40.py → pcbnew/python/examples/createFPC40.py
Executable file → Normal file
0
pcbnew/scripting/examples/createPcb.py → pcbnew/python/examples/createPcb.py
Executable file → Normal file
0
pcbnew/scripting/examples/createPcb.py → pcbnew/python/examples/createPcb.py
Executable file → Normal file
0
pcbnew/scripting/examples/listPcb.py → pcbnew/python/examples/listPcb.py
Executable file → Normal file
0
pcbnew/scripting/examples/listPcb.py → pcbnew/python/examples/listPcb.py
Executable file → Normal file
0
pcbnew/scripting/examples/listPcbLibrary.py → pcbnew/python/examples/listPcbLibrary.py
Executable file → Normal file
0
pcbnew/scripting/examples/listPcbLibrary.py → pcbnew/python/examples/listPcbLibrary.py
Executable file → Normal file
|
@ -28,38 +28,123 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
%extend BOARD
|
/*
|
||||||
{
|
|
||||||
%pythoncode
|
By default we do not translate exceptions for EVERY C++ function since not every
|
||||||
|
C++ function throws, and that would be unused and very bulky mapping code.
|
||||||
|
Therefore please help gather the subset of C++ functions for this class that do
|
||||||
|
throw and add them here, before the class declarations.
|
||||||
|
|
||||||
|
*/
|
||||||
|
HANDLE_EXCEPTIONS(BOARD::TracksInNetBetweenPoints)
|
||||||
|
|
||||||
|
|
||||||
%{
|
%{
|
||||||
def GetModules(self): return self.m_Modules
|
#include <class_board.h>
|
||||||
def GetDrawings(self): return self.m_Drawings
|
|
||||||
def GetTracks(self): return self.m_Track
|
|
||||||
def GetFullRatsnest(self): return self.m_FullRatsnest
|
|
||||||
|
|
||||||
def Save(self,filename):
|
#include <class_board_design_settings.h>
|
||||||
return SaveBoard(filename,self,IO_MGR.KICAD)
|
#include <layers_id_colors_and_visibility.h>
|
||||||
|
|
||||||
#
|
|
||||||
# add function, clears the thisown to avoid python from deleting
|
|
||||||
# the object in the garbage collector
|
|
||||||
#
|
|
||||||
|
|
||||||
def Add(self,item):
|
|
||||||
item.thisown=0
|
|
||||||
self.AddChild(item)
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
}
|
|
||||||
|
%import dlist.h
|
||||||
|
|
||||||
|
// Organize the two forms of include side by side so that it is easier to
|
||||||
|
// migrate each grouping into a separate *.i file later.
|
||||||
|
|
||||||
|
|
||||||
|
%include class_board_item.h
|
||||||
|
%{
|
||||||
|
#include <class_board_item.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include class_board_connected_item.h
|
||||||
|
%{
|
||||||
|
#include <class_board_connected_item.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include pad_shapes.h
|
||||||
|
|
||||||
|
%include class_pad.h
|
||||||
|
%{
|
||||||
|
#include <class_pad.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include class_module.h
|
||||||
|
%{
|
||||||
|
#include <class_module.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include class_track.h
|
||||||
|
%{
|
||||||
|
#include <class_track.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include class_zone.h
|
||||||
|
%include zones.h
|
||||||
|
%{
|
||||||
|
#include <class_zone.h>
|
||||||
|
#include <zones.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
%include layers_id_colors_and_visibility.h
|
||||||
|
|
||||||
|
%include class_pcb_text.h
|
||||||
|
%{
|
||||||
|
#include <class_pcb_text.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include class_dimension.h
|
||||||
|
%{
|
||||||
|
#include <class_dimension.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
%include class_drawsegment.h
|
||||||
|
%{
|
||||||
|
#include <class_drawsegment.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include class_marker_pcb.h
|
||||||
|
%{
|
||||||
|
#include <class_marker_pcb.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
%include class_mire.h
|
||||||
|
%{
|
||||||
|
#include <class_mire.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
%include class_text_mod.h
|
||||||
|
%{
|
||||||
|
#include <class_text_mod.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include class_edge_mod.h
|
||||||
|
%{
|
||||||
|
#include <class_edge_mod.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include class_zone_settings.h
|
||||||
|
|
||||||
|
%include class_netinfo.h
|
||||||
|
%include class_netclass.h
|
||||||
|
%{
|
||||||
|
#include <class_netinfo.h>
|
||||||
|
#include <class_netclass.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
// this is to help python with the * accessor of DLIST templates
|
// this is to help python with the * accessor of DLIST templates
|
||||||
|
|
||||||
%rename(Get) operator BOARD_ITEM*;
|
%rename(Get) operator BOARD_ITEM*;
|
||||||
%rename(Get) operator TRACK*;
|
%rename(Get) operator TRACK*;
|
||||||
%rename(Get) operator D_PAD*;
|
%rename(Get) operator D_PAD*;
|
||||||
%rename(Get) operator MODULE*;
|
%rename(Get) operator MODULE*;
|
||||||
|
|
||||||
|
|
||||||
// we must translate C++ templates to scripting languages
|
// we must translate C++ templates to scripting languages
|
||||||
|
|
||||||
%template(BOARD_ITEM_List) DLIST<BOARD_ITEM>;
|
%template(BOARD_ITEM_List) DLIST<BOARD_ITEM>;
|
||||||
|
@ -73,10 +158,30 @@
|
||||||
%template(RATSNEST_Vector) std::vector<RATSNEST_ITEM>;
|
%template(RATSNEST_Vector) std::vector<RATSNEST_ITEM>;
|
||||||
|
|
||||||
|
|
||||||
|
%include class_board.h
|
||||||
|
|
||||||
|
|
||||||
%extend BOARD
|
%extend BOARD
|
||||||
{
|
{
|
||||||
%pythoncode
|
%pythoncode
|
||||||
{
|
%{
|
||||||
|
|
||||||
|
def GetModules(self): return self.m_Modules
|
||||||
|
def GetDrawings(self): return self.m_Drawings
|
||||||
|
def GetTracks(self): return self.m_Track
|
||||||
|
def GetFullRatsnest(self): return self.m_FullRatsnest
|
||||||
|
|
||||||
|
def Save(self,filename):
|
||||||
|
return SaveBoard(filename,self,IO_MGR.KICAD)
|
||||||
|
|
||||||
|
#
|
||||||
|
# add function, clears the thisown to avoid python from deleting
|
||||||
|
# the object in the garbage collector
|
||||||
|
#
|
||||||
|
def Add(self,item):
|
||||||
|
item.thisown=0
|
||||||
|
self.AddNative(item)
|
||||||
|
|
||||||
def GetNetClasses(self):
|
def GetNetClasses(self):
|
||||||
return self.GetDesignSettings().m_NetClasses
|
return self.GetDesignSettings().m_NetClasses
|
||||||
|
|
||||||
|
@ -88,23 +193,53 @@
|
||||||
|
|
||||||
def GetTrackWidthList(self):
|
def GetTrackWidthList(self):
|
||||||
return self.GetDesignSettings().m_TrackWidthList
|
return self.GetDesignSettings().m_TrackWidthList
|
||||||
}
|
|
||||||
|
def GetNetsByName(self):
|
||||||
|
"""
|
||||||
|
Return a dictionary like object with key:wxString netname and value:NETINFO_ITEM
|
||||||
|
"""
|
||||||
|
return self.GetNetInfo().NetsByName()
|
||||||
|
|
||||||
|
def GetNetsByNetcode(self):
|
||||||
|
"""
|
||||||
|
Return a dictionary like object with key:int netcode and value:NETINFO_ITEM
|
||||||
|
"""
|
||||||
|
return self.GetNetInfo().NetsByNetcode()
|
||||||
|
|
||||||
|
def GetNetcodeFromNetname(self,netname):
|
||||||
|
"""
|
||||||
|
Given a netname, return its netcode
|
||||||
|
"""
|
||||||
|
net = self.GetNetsByName()[netname]
|
||||||
|
return net.GetNet()
|
||||||
|
|
||||||
|
def GetAllNetClasses(self):
|
||||||
|
"""
|
||||||
|
Return a dictionary like object with net_class_name as key and NETCLASSPRT as value
|
||||||
|
GetNetClasses(BOARD self) -> { wxString net_class_name : NETCLASSPTR }
|
||||||
|
Include the "Default" netclass also.
|
||||||
|
"""
|
||||||
|
netclassmap = self.GetNetClasses().NetClasses()
|
||||||
|
# add the Default one too
|
||||||
|
netclassmap[ NETCLASS.Default ] = self.GetNetClasses().GetDefault()
|
||||||
|
return netclassmap
|
||||||
|
%}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
%extend DRAWSEGMENT
|
%extend DRAWSEGMENT
|
||||||
{
|
{
|
||||||
%pythoncode
|
%pythoncode
|
||||||
{
|
%{
|
||||||
def GetShapeStr(self):
|
def GetShapeStr(self):
|
||||||
return self.ShowShape(self.GetShape())
|
return self.ShowShape(self.GetShape())
|
||||||
}
|
%}
|
||||||
}
|
}
|
||||||
|
|
||||||
%extend BOARD_ITEM
|
%extend BOARD_ITEM
|
||||||
{
|
{
|
||||||
%pythoncode
|
%pythoncode
|
||||||
{
|
%{
|
||||||
def SetPos(self,p):
|
def SetPos(self,p):
|
||||||
self.SetPosition(p)
|
self.SetPosition(p)
|
||||||
self.SetPos0(p)
|
self.SetPos0(p)
|
||||||
|
@ -114,7 +249,7 @@
|
||||||
self.SetStart0(start)
|
self.SetStart0(start)
|
||||||
self.SetEnd(end)
|
self.SetEnd(end)
|
||||||
self.SetEnd0(end)
|
self.SetEnd0(end)
|
||||||
}
|
%}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,147 @@
|
||||||
|
--- pcbnew/scripting/board.i
|
||||||
|
+++ pcbnew/swig/board.i
|
||||||
|
@@ -28,38 +28,123 @@
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
-%extend BOARD
|
||||||
|
-{
|
||||||
|
- %pythoncode
|
||||||
|
- %{
|
||||||
|
- def GetModules(self): return self.m_Modules
|
||||||
|
- def GetDrawings(self): return self.m_Drawings
|
||||||
|
- def GetTracks(self): return self.m_Track
|
||||||
|
- def GetFullRatsnest(self): return self.m_FullRatsnest
|
||||||
|
+/*
|
||||||
|
|
||||||
|
- def Save(self,filename):
|
||||||
|
- return SaveBoard(filename,self,IO_MGR.KICAD)
|
||||||
|
+By default we do not translate exceptions for EVERY C++ function since not every
|
||||||
|
+C++ function throws, and that would be unused and very bulky mapping code.
|
||||||
|
+Therefore please help gather the subset of C++ functions for this class that do
|
||||||
|
+throw and add them here, before the class declarations.
|
||||||
|
|
||||||
|
- #
|
||||||
|
- # add function, clears the thisown to avoid python from deleting
|
||||||
|
- # the object in the garbage collector
|
||||||
|
- #
|
||||||
|
+*/
|
||||||
|
+HANDLE_EXCEPTIONS(BOARD::TracksInNetBetweenPoints)
|
||||||
|
|
||||||
|
- def Add(self,item):
|
||||||
|
- item.thisown=0
|
||||||
|
- self.AddNative(item)
|
||||||
|
- %}
|
||||||
|
|
||||||
|
-}
|
||||||
|
+%{
|
||||||
|
+#include <class_board.h>
|
||||||
|
|
||||||
|
-// this is to help python with the * accessor of DLIST templates
|
||||||
|
+#include <class_board_design_settings.h>
|
||||||
|
+#include <layers_id_colors_and_visibility.h>
|
||||||
|
+
|
||||||
|
+%}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+%import dlist.h
|
||||||
|
+
|
||||||
|
+// Organize the two forms of include side by side so that it is easier to
|
||||||
|
+// migrate each grouping into a separate *.i file later.
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+%include class_board_item.h
|
||||||
|
+%{
|
||||||
|
+#include <class_board_item.h>
|
||||||
|
+%}
|
||||||
|
+
|
||||||
|
+%include class_board_connected_item.h
|
||||||
|
+%{
|
||||||
|
+#include <class_board_connected_item.h>
|
||||||
|
+%}
|
||||||
|
+
|
||||||
|
+%include pad_shapes.h
|
||||||
|
+
|
||||||
|
+%include class_pad.h
|
||||||
|
+%{
|
||||||
|
+#include <class_pad.h>
|
||||||
|
+%}
|
||||||
|
+
|
||||||
|
+%include class_module.h
|
||||||
|
+%{
|
||||||
|
+#include <class_module.h>
|
||||||
|
+%}
|
||||||
|
+
|
||||||
|
+%include class_track.h
|
||||||
|
+%{
|
||||||
|
+#include <class_track.h>
|
||||||
|
+%}
|
||||||
|
+
|
||||||
|
+%include class_zone.h
|
||||||
|
+%include zones.h
|
||||||
|
+%{
|
||||||
|
+#include <class_zone.h>
|
||||||
|
+#include <zones.h>
|
||||||
|
+%}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+%include layers_id_colors_and_visibility.h
|
||||||
|
+
|
||||||
|
+%include class_pcb_text.h
|
||||||
|
+%{
|
||||||
|
+#include <class_pcb_text.h>
|
||||||
|
+%}
|
||||||
|
+
|
||||||
|
+%include class_dimension.h
|
||||||
|
+%{
|
||||||
|
+#include <class_dimension.h>
|
||||||
|
+%}
|
||||||
|
|
||||||
|
+
|
||||||
|
+%include class_drawsegment.h
|
||||||
|
+%{
|
||||||
|
+#include <class_drawsegment.h>
|
||||||
|
+%}
|
||||||
|
+
|
||||||
|
+%include class_marker_pcb.h
|
||||||
|
+%{
|
||||||
|
+#include <class_marker_pcb.h>
|
||||||
|
+%}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+%include class_mire.h
|
||||||
|
+%{
|
||||||
|
+#include <class_mire.h>
|
||||||
|
+%}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+%include class_text_mod.h
|
||||||
|
+%{
|
||||||
|
+#include <class_text_mod.h>
|
||||||
|
+%}
|
||||||
|
+
|
||||||
|
+%include class_edge_mod.h
|
||||||
|
+%{
|
||||||
|
+#include <class_edge_mod.h>
|
||||||
|
+%}
|
||||||
|
+
|
||||||
|
+%include class_zone_settings.h
|
||||||
|
+
|
||||||
|
+%include class_netinfo.h
|
||||||
|
+%include class_netclass.h
|
||||||
|
+%{
|
||||||
|
+#include <class_netinfo.h>
|
||||||
|
+#include <class_netclass.h>
|
||||||
|
+%}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+// this is to help python with the * accessor of DLIST templates
|
||||||
|
%rename(Get) operator BOARD_ITEM*;
|
||||||
|
%rename(Get) operator TRACK*;
|
||||||
|
%rename(Get) operator D_PAD*;
|
||||||
|
%rename(Get) operator MODULE*;
|
||||||
|
|
||||||
|
-
|
||||||
|
// we must translate C++ templates to scripting languages
|
||||||
|
|
||||||
|
%template(BOARD_ITEM_List) DLIST<BOARD_ITEM>;
|
|
@ -36,10 +36,15 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
%include "kicad.i"
|
%include kicad.i
|
||||||
|
|
||||||
%include <convert_to_biu.h>
|
%include <convert_to_biu.h>
|
||||||
%include <fpid.h>
|
|
||||||
|
%{
|
||||||
|
#include <fpid.h>
|
||||||
|
%}
|
||||||
|
%include fpid.h
|
||||||
|
|
||||||
|
|
||||||
// ignore a couple of items that generate warnings from swig built code
|
// ignore a couple of items that generate warnings from swig built code
|
||||||
%ignore BOARD_ITEM::ZeroOffset;
|
%ignore BOARD_ITEM::ZeroOffset;
|
||||||
|
@ -54,59 +59,15 @@ class BASE_SET {};
|
||||||
%rename(AddNative) *::Add;
|
%rename(AddNative) *::Add;
|
||||||
|
|
||||||
// fix method names conflicts
|
// fix method names conflicts
|
||||||
%rename(AddChild) BOARD_ITEM_CONTAINER::Add;
|
%rename(AddChild) MODULE::Add;
|
||||||
%rename(RemoveChild) BOARD_ITEM_CONTAINER::Remove;
|
%rename(RemoveChild) MODULE::Remove;
|
||||||
%rename(DeleteChild) BOARD_ITEM_CONTAINER::Delete;
|
%rename(DeleteChild) MODULE::Delete;
|
||||||
|
|
||||||
%exception {
|
|
||||||
try{
|
|
||||||
$action
|
|
||||||
}
|
|
||||||
catch( IO_ERROR e )
|
|
||||||
{
|
|
||||||
std::string str = TO_UTF8( e.errorText );
|
|
||||||
str += '\n';
|
|
||||||
PyErr_SetString( PyExc_IOError, str.c_str() );
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
catch( std::exception &e )
|
|
||||||
{
|
|
||||||
std::string str = e.what();
|
|
||||||
str += '\n';
|
|
||||||
PyErr_SetString( PyExc_IOError, str.c_str() );
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
catch( ... )
|
|
||||||
{
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%include exception.i
|
|
||||||
|
|
||||||
|
|
||||||
// this is what it must be included in the wrapper .cxx code to compile
|
// this is what it must be included in the wrapper .cxx code to compile
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include <wx_python_helpers.h>
|
#include <wx_python_helpers.h>
|
||||||
#include <class_board_item.h>
|
|
||||||
#include <class_board_connected_item.h>
|
|
||||||
#include <class_netinfo.h>
|
|
||||||
#include <class_board_design_settings.h>
|
|
||||||
#include <class_module.h>
|
|
||||||
#include <class_track.h>
|
|
||||||
#include <class_zone.h>
|
|
||||||
#include <zones.h>
|
|
||||||
#include <layers_id_colors_and_visibility.h>
|
|
||||||
#include <class_pad.h>
|
|
||||||
#include <class_pcb_text.h>
|
|
||||||
#include <class_dimension.h>
|
|
||||||
#include <class_drawsegment.h>
|
|
||||||
#include <class_marker_pcb.h>
|
|
||||||
#include <class_mire.h>
|
|
||||||
#include <class_text_mod.h>
|
|
||||||
#include <class_edge_mod.h>
|
|
||||||
|
|
||||||
#include <class_netclass.h>
|
|
||||||
#include <colors.h>
|
#include <colors.h>
|
||||||
|
|
||||||
//#include <dlist.h>
|
//#include <dlist.h>
|
||||||
|
@ -117,8 +78,6 @@ class BASE_SET {};
|
||||||
#include <pcb_plot_params.h>
|
#include <pcb_plot_params.h>
|
||||||
#include <exporters/gendrill_Excellon_writer.h>
|
#include <exporters/gendrill_Excellon_writer.h>
|
||||||
|
|
||||||
#include <class_board.h>
|
|
||||||
|
|
||||||
BOARD *GetBoard(); /* get current editor board */
|
BOARD *GetBoard(); /* get current editor board */
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
@ -128,27 +87,6 @@ class BASE_SET {};
|
||||||
#include <kicad_plugin.h>
|
#include <kicad_plugin.h>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include <class_board_item.h>
|
|
||||||
%include <board_item_container.h>
|
|
||||||
%include <class_board_connected_item.h>
|
|
||||||
%include <pad_shapes.h>
|
|
||||||
%include <class_pad.h>
|
|
||||||
%include <class_netinfo.h>
|
|
||||||
%include <class_module.h>
|
|
||||||
%include <class_track.h>
|
|
||||||
%include <class_zone.h>
|
|
||||||
%include <zones.h>
|
|
||||||
%include <layers_id_colors_and_visibility.h>
|
|
||||||
%include <class_pcb_text.h>
|
|
||||||
%include <class_dimension.h>
|
|
||||||
%include <class_drawsegment.h>
|
|
||||||
%include <class_marker_pcb.h>
|
|
||||||
%include <class_mire.h>
|
|
||||||
%include <class_text_mod.h>
|
|
||||||
%include <class_edge_mod.h>
|
|
||||||
%include <dlist.h>
|
|
||||||
%include <class_zone_settings.h>
|
|
||||||
%include <class_netclass.h>
|
|
||||||
|
|
||||||
%include <class_board_design_settings.h>
|
%include <class_board_design_settings.h>
|
||||||
%include <plotcontroller.h>
|
%include <plotcontroller.h>
|
||||||
|
@ -157,10 +95,6 @@ class BASE_SET {};
|
||||||
%include <exporters/gendrill_Excellon_writer.h>
|
%include <exporters/gendrill_Excellon_writer.h>
|
||||||
%include <colors.h>
|
%include <colors.h>
|
||||||
|
|
||||||
%include <class_board.h>
|
|
||||||
|
|
||||||
%include "board_item.i"
|
|
||||||
|
|
||||||
%include <pcbnew_scripting_helpers.h>
|
%include <pcbnew_scripting_helpers.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,10 +103,10 @@ class BASE_SET {};
|
||||||
%include <io_mgr.h>
|
%include <io_mgr.h>
|
||||||
%include <kicad_plugin.h>
|
%include <kicad_plugin.h>
|
||||||
|
|
||||||
%include "board.i"
|
%include board.i
|
||||||
%include "module.i"
|
%include module.i
|
||||||
%include "plugins.i"
|
%include plugins.i
|
||||||
%include "units.i"
|
%include units.i
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
--- pcbnew/scripting/pcbnew.i
|
||||||
|
+++ pcbnew/swig/pcbnew.i
|
||||||
|
@@ -87,26 +46,6 @@ class BASE_SET {};
|
||||||
|
#include <kicad_plugin.h>
|
||||||
|
%}
|
||||||
|
|
||||||
|
-%include <class_board_item.h>
|
||||||
|
-%include <class_board_connected_item.h>
|
||||||
|
-%include <pad_shapes.h>
|
||||||
|
-%include <class_pad.h>
|
||||||
|
-%include <class_netinfo.h>
|
||||||
|
-%include <class_module.h>
|
||||||
|
-%include <class_track.h>
|
||||||
|
-%include <class_zone.h>
|
||||||
|
-%include <zones.h>
|
||||||
|
-%include <layers_id_colors_and_visibility.h>
|
||||||
|
-%include <class_pcb_text.h>
|
||||||
|
-%include <class_dimension.h>
|
||||||
|
-%include <class_drawsegment.h>
|
||||||
|
-%include <class_marker_pcb.h>
|
||||||
|
-%include <class_mire.h>
|
||||||
|
-%include <class_text_mod.h>
|
||||||
|
-%include <class_edge_mod.h>
|
||||||
|
-%include <dlist.h>
|
||||||
|
-%include <class_zone_settings.h>
|
||||||
|
-%include <class_netclass.h>
|
||||||
|
|
||||||
|
%include <class_board_design_settings.h>
|
||||||
|
%include <plotcontroller.h>
|
|
@ -23,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include <scripting/pcbnew_footprint_wizards.h>
|
#include <pcbnew_footprint_wizards.h>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
class PYTHON_FOOTPRINT_WIZARDS
|
class PYTHON_FOOTPRINT_WIZARDS
|
|
@ -30,7 +30,7 @@
|
||||||
// Unit conversion, between internal units and mm or mils
|
// Unit conversion, between internal units and mm or mils
|
||||||
|
|
||||||
%pythoncode
|
%pythoncode
|
||||||
{
|
%{
|
||||||
def ToMM(iu):
|
def ToMM(iu):
|
||||||
if type(iu) in [int,float]:
|
if type(iu) in [int,float]:
|
||||||
return float(iu) / float(IU_PER_MM)
|
return float(iu) / float(IU_PER_MM)
|
||||||
|
@ -74,5 +74,4 @@
|
||||||
wx = int(FromMils(wx))
|
wx = int(FromMils(wx))
|
||||||
wy = int (FromMils(wy))
|
wy = int (FromMils(wy))
|
||||||
return wxRect(x,y,wx,wy)
|
return wxRect(x,y,wx,wy)
|
||||||
|
%}
|
||||||
}
|
|
|
@ -25,6 +25,7 @@ include_directories(
|
||||||
|
|
||||||
add_library( s3d_plugin_vrml MODULE
|
add_library( s3d_plugin_vrml MODULE
|
||||||
${CMAKE_SOURCE_DIR}/common/richio.cpp
|
${CMAKE_SOURCE_DIR}/common/richio.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/common/exceptions.cpp
|
||||||
vrml.cpp
|
vrml.cpp
|
||||||
x3d.cpp
|
x3d.cpp
|
||||||
wrlproc.cpp
|
wrlproc.cpp
|
||||||
|
|
Loading…
Reference in New Issue