KiCad PCB EDA Suite
pcbnew_scripting_helpers.cpp File Reference

Scripting helper functions for pcbnew functionality. More...

#include <Python.h>
#include <pcbnew_scripting_helpers.h>
#include <pcbnew.h>
#include <pcbnew_id.h>
#include <build_version.h>
#include <class_board.h>
#include <class_drawpanel.h>
#include <kicad_string.h>
#include <io_mgr.h>
#include <macros.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

BOARDGetBoard ()
 
void ScriptingSetPcbEditFrame (PCB_EDIT_FRAME *aPCBEdaFrame)
 
BOARDLoadBoard (wxString &aFileName)
 
BOARDLoadBoard (wxString &aFileName, IO_MGR::PCB_FILE_T aFormat)
 
bool SaveBoard (wxString &aFileName, BOARD *aBoard, IO_MGR::PCB_FILE_T aFormat)
 
bool SaveBoard (wxString &aFileName, BOARD *aBoard)
 
void Refresh ()
 
void WindowZoom (int xl, int yl, int width, int height)
 

Variables

static PCB_EDIT_FRAMEPcbEditFrame = NULL
 

Detailed Description

Scripting helper functions for pcbnew functionality.

Definition in file pcbnew_scripting_helpers.cpp.

Function Documentation

BOARD* LoadBoard ( wxString &  aFileName)

Definition at line 60 of file pcbnew_scripting_helpers.cpp.

References IO_MGR::KICAD, IO_MGR::LEGACY, and LoadBoard().

Referenced by LoadBoard().

61 {
62  if( aFileName.EndsWith( wxT( ".kicad_pcb" ) ) )
63  return LoadBoard( aFileName, IO_MGR::KICAD );
64 
65  else if( aFileName.EndsWith( wxT( ".brd" ) ) )
66  return LoadBoard( aFileName, IO_MGR::LEGACY );
67 
68  // as fall back for any other kind use the legacy format
69  return LoadBoard( aFileName, IO_MGR::LEGACY );
70 }
BOARD * LoadBoard(wxString &aFileName)
S-expression Pcbnew file format.
Definition: io_mgr.h:54
Legacy Pcbnew file formats prior to s-expression.
Definition: io_mgr.h:53
BOARD* LoadBoard ( wxString &  aFileName,
IO_MGR::PCB_FILE_T  aFormat 
)

Definition at line 73 of file pcbnew_scripting_helpers.cpp.

References IO_MGR::Load().

74 {
75  return IO_MGR::Load( aFormat, aFileName );
76 }
static BOARD * Load(PCB_FILE_T aFileType, const wxString &aFileName, BOARD *aAppendToMe=NULL, const PROPERTIES *aProperties=NULL)
Function Load finds the requested PLUGIN and if found, calls the PLUGIN->Load(..) funtion on it using...
Definition: io_mgr.cpp:229
void Refresh ( )

Definition at line 96 of file pcbnew_scripting_helpers.cpp.

References EDA_DRAW_FRAME::GetCanvas(), and EDA_DRAW_PANEL::Refresh().

Referenced by EDA_MSG_PANEL::AppendMessage(), C3D_MODEL_VIEWER::Clear3DModel(), DRCLISTBOX::DeleteAllItems(), DRCLISTBOX::DeleteItem(), EDA_MSG_PANEL::EraseMsgBox(), PCB_EDIT_FRAME::ImportSpecctraSession(), LIB_EDIT_FRAME::InstallFieldsEditorDialog(), PCB_EDIT_FRAME::OnFlipPcbView(), C3D_MODEL_VIEWER::OnMouseMove(), C3D_MODEL_VIEWER::OnMouseWheel(), FOOTPRINT_PREVIEW_WIDGET::OnStatusChange(), DIALOG_FP_LIB_TABLE::optionsEditor(), EDA_DRAW_PANEL::Refresh(), TEMPLATE_WIDGET::Select(), C3D_MODEL_VIEWER::Set3DModel(), WIDGET_EESCHEMA_COLOR_CONFIG::SetColor(), DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::SetGroupingColumn(), DRCLISTBOX::SetList(), EDA_MSG_PANEL::SetMessage(), FOOTPRINTS_LISTBOX::SetSelection(), LIBRARY_LISTBOX::SetSelection(), EDA_3D_VIEWER::takeScreenshot(), TEMPLATE_WIDGET::Unselect(), mpWindow::UpdateAll(), KIGFX::OPENGL_GAL::updatedGalDisplayOptions(), KIGFX::CAIRO_GAL::updatedGalDisplayOptions(), DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample(), and PCB_EDIT_FRAME::UseGalCanvas().

97 {
98  // first argument is erase background, second is a wxRect
99  PcbEditFrame->GetCanvas()->Refresh( true, NULL );
100 }
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:299
static PCB_EDIT_FRAME * PcbEditFrame
bool SaveBoard ( wxString &  aFileName,
BOARD aBoard,
IO_MGR::PCB_FILE_T  aFormat 
)

Definition at line 79 of file pcbnew_scripting_helpers.cpp.

References NETCLASS::Default, BOARD::GetDesignSettings(), IO_MGR::Save(), BOARD_DESIGN_SETTINGS::SetCurrentNetClass(), and BOARD::SynchronizeNetsAndNetClasses().

Referenced by SaveBoard().

80 {
83 
84  IO_MGR::Save( aFormat, aFileName, aBoard, NULL );
85 
86  return true;
87 }
void SynchronizeNetsAndNetClasses()
Function SynchronizeNetsAndNetClasses copies NETCLASS info to each NET, based on NET membership in a ...
static const char Default[]
the name of the default NETCLASS
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:524
static void Save(PCB_FILE_T aFileType, const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=NULL)
Function Save will write either a full aBoard to a storage file in a format that this implementation ...
Definition: io_mgr.cpp:244
bool SetCurrentNetClass(const wxString &aNetClassName)
Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter ...
bool SaveBoard ( wxString &  aFileName,
BOARD aBoard 
)

Definition at line 90 of file pcbnew_scripting_helpers.cpp.

References IO_MGR::KICAD, and SaveBoard().

91 {
92  return SaveBoard( aFileName, aBoard, IO_MGR::KICAD );
93 }
S-expression Pcbnew file format.
Definition: io_mgr.h:54
bool SaveBoard(wxString &aFileName, BOARD *aBoard, IO_MGR::PCB_FILE_T aFormat)
void ScriptingSetPcbEditFrame ( PCB_EDIT_FRAME aPCBEdaFrame)

Definition at line 54 of file pcbnew_scripting_helpers.cpp.

Referenced by PCB::IFACE::CreateWindow().

55 {
56  PcbEditFrame = aPCBEdaFrame;
57 }
static PCB_EDIT_FRAME * PcbEditFrame
void WindowZoom ( int  xl,
int  yl,
int  width,
int  height 
)

Definition at line 103 of file pcbnew_scripting_helpers.cpp.

References EDA_DRAW_FRAME::Window_Zoom().

104 {
105  EDA_RECT Rect( wxPoint( xl, yl ), wxSize( width, height )) ;
106  PcbEditFrame->Window_Zoom( Rect );
107 }
static PCB_EDIT_FRAME * PcbEditFrame
Class EDA_RECT handles the component boundary box.
void Window_Zoom(EDA_RECT &Rect)
Compute the zoom factor and the new draw offset to draw the selected area (Rect) in full window scree...
Definition: zoom.cpp:103

Variable Documentation

PCB_EDIT_FRAME* PcbEditFrame = NULL
static

Definition at line 43 of file pcbnew_scripting_helpers.cpp.