Browse Source
pcbnew_scripting_helpers.cpp/h to handle generic scripting tools
pcbnew_scripting_helpers.cpp/h to handle generic scripting tools
CMakeLists.txt options to build scripting or scripting modulespull/1/head
9 changed files with 249 additions and 107 deletions
-
10CMakeLists.txt
-
140pcbnew/CMakeLists.txt
-
13pcbnew/pcbnew.cpp
-
12pcbnew/scripting/kicad.i
-
59pcbnew/scripting/pcbnew.i
-
72pcbnew/scripting/pcbnew_scripting_helpers.cpp
-
16pcbnew/scripting/pcbnew_scripting_helpers.h
-
31pcbnew/scripting/python_scripting.cpp
-
3pcbnew/scripting/python_scripting.h
@ -0,0 +1,72 @@ |
|||
#include <pcbnew_scripting_helpers.h>
|
|||
#include <pcbnew.h>
|
|||
#include <pcbnew_id.h>
|
|||
#include <build_version.h>
|
|||
#include <class_board.h>
|
|||
#include <kicad_string.h>
|
|||
#include <io_mgr.h>
|
|||
|
|||
static PCB_EDIT_FRAME *PcbEditFrame=NULL; |
|||
|
|||
BOARD *GetBoard() |
|||
{ |
|||
if (PcbEditFrame) return PcbEditFrame->GetBoard(); |
|||
else return NULL; |
|||
} |
|||
|
|||
void ScriptingSetPcbEditFrame(PCB_EDIT_FRAME *aPCBEdaFrame) |
|||
{ |
|||
PcbEditFrame = aPCBEdaFrame; |
|||
} |
|||
|
|||
|
|||
BOARD* LoadBoard(wxString aFileName) |
|||
{ |
|||
#ifdef USE_NEW_PCBNEW_LOAD
|
|||
try{ |
|||
return IO_MGR::Load(IO_MGR::KICAD,aFileName); |
|||
} catch (IO_ERROR) |
|||
{ |
|||
return NULL; |
|||
} |
|||
#else
|
|||
fprintf(stderr,"Warning, LoadBoard not implemented without USE_NEW_PCBNEW_LOAD\n"); |
|||
return NULL; |
|||
#endif
|
|||
} |
|||
|
|||
bool SaveBoard(wxString aFileName, BOARD* aBoard) |
|||
{ |
|||
|
|||
#ifdef USE_NEW_PCBNEW_LOAD
|
|||
aBoard->m_Status_Pcb &= ~CONNEXION_OK; |
|||
aBoard->SynchronizeNetsAndNetClasses(); |
|||
aBoard->SetCurrentNetClass( aBoard->m_NetClasses.GetDefault()->GetName() ); |
|||
|
|||
wxString header = wxString::Format( |
|||
wxT( "PCBNEW-BOARD Version %d date %s\n\n# Created by Pcbnew%s\n\n" ), |
|||
BOARD_FILE_VERSION, DateAndTime().GetData(), |
|||
GetBuildVersion().GetData() ); |
|||
|
|||
PROPERTIES props; |
|||
|
|||
props["header"] = header; |
|||
|
|||
try |
|||
{ |
|||
IO_MGR::Save( IO_MGR::KICAD, aFileName, aBoard, &props ); |
|||
return true; |
|||
} |
|||
catch (IO_ERROR) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
#else
|
|||
fprintf(stderr,"Warning, SaveBoard not implemented without USE_NEW_PCBNEW_LOAD\n"); |
|||
return false; |
|||
#endif
|
|||
|
|||
} |
|||
|
|||
|
@ -0,0 +1,16 @@ |
|||
#ifndef __PCBNEW_SCRIPTING_HELPERS_H |
|||
#define __PCBNEW_SCRIPTING_HELPERS_H |
|||
|
|||
#include <wxPcbStruct.h> |
|||
|
|||
/* we could be including all these methods as static in a class, but |
|||
* we want plain pcbnew.<method_name> access from python */ |
|||
|
|||
#ifndef SWIG |
|||
void ScriptingSetPcbEditFrame(PCB_EDIT_FRAME *aPCBEdaFrame); |
|||
#endif |
|||
|
|||
BOARD* LoadBoard(wxString aFileName); |
|||
bool SaveBoard(wxString aFileName, BOARD* aBoard); |
|||
|
|||
#endif |
@ -1,11 +1,8 @@ |
|||
#ifndef __PYTHON_SCRIPTING_H |
|||
#define __PYTHON_SCRIPTING_H |
|||
|
|||
#include <wxPcbStruct.h> |
|||
#include <Python.h> |
|||
|
|||
void pythonSetPcbEditFrame(PCB_EDIT_FRAME *aPCBEdaFrame); |
|||
void pcbnewInitPythonScripting(void); |
|||
|
|||
|
|||
#endif |
Write
Preview
Loading…
Cancel
Save
Reference in new issue