KiCad PCB EDA Suite
pcbnew_scripting_helpers.h File Reference
#include <pcb_edit_frame.h>
#include <io_mgr.h>

Go to the source code of this file.

Functions

void ScriptingSetPcbEditFrame (PCB_EDIT_FRAME *aPCBEdaFrame)
 
BOARDGetBoard ()
 
BOARDLoadBoard (wxString &aFileName, IO_MGR::PCB_FILE_T aFormat)
 
BOARDLoadBoard (wxString &aFileName)
 
bool SaveBoard (wxString &aFileName, BOARD *aBoard)
 
void Refresh ()
 Update the board display after modifying it bu a python script (note: it is automatically called by action plugins, after running the plugin, so call this function is usually not needed inside action plugins. More...
 
void WindowZoom (int xl, int yl, int width, int height)
 
void UpdateUserInterface ()
 Update the layer manager and other widgets from the board setup (layer and items visibility, colors ...) (note: it is automatically called by action plugins, after running the plugin, so call this function is usually not needed inside action plugins. More...
 
bool IsActionRunning ()
 Are we currently in an action plugin? More...
 

Function Documentation

BOARD* GetBoard ( )

Definition at line 47 of file pcbnew_scripting_helpers.cpp.

References PCB_BASE_FRAME::GetBoard().

Referenced by PCB_BASE_FRAME::AddModuleToBoard(), PCB_EDIT_FRAME::Clean_Pcb(), PCB_EDIT_FRAME::CreateTarget(), PYTHON_ACTION_PLUGINS::deregister_action(), PCB_EDIT_FRAME::DoGenFootprintsPositionFile(), PCB_EDIT_FRAME::DoGenFootprintsReport(), D_PAD::Draw(), PCB_EDIT_FRAME::EditDimension(), EVT_GRID_CMD_CELL_CHANGED(), EVT_TOOL(), EVT_UPDATE_UI(), PCB_EDIT_FRAME::Exchange_Module(), PCB_EDIT_FRAME::ExportSpecctraFile(), PCB_EDIT_FRAME::ExportToSpecctra(), PCB_EDIT_FRAME::ExportVRML_File(), PCB_EDIT_FRAME::GenD356File(), PCB_EDIT_FRAME::GenFootprintsReport(), PCB_EDIT_FRAME::GetLastNetListRead(), PCB_DRAW_PANEL_GAL::GetMsgPanelInfo(), PCB_EDIT_FRAME::ImportSpecctraSession(), PCB_EDIT_FRAME::IsElementVisible(), PCB_EDIT_FRAME::IsMicroViaAcceptable(), PCB_EDIT_FRAME::ListAndSelectModuleName(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay(), FOOTPRINT_EDIT_FRAME::moveExact(), PCB_EDIT_FRAME::onBoardLoaded(), PCB_EDIT_FRAME::OnCloseWindow(), PCB_EDIT_FRAME::OnExportIDF3(), PCB_EDIT_FRAME::OnExportSTEP(), PCB_EDIT_FRAME::OnExportVRML(), FOOTPRINT_EDIT_FRAME::OnVerticalToolbar(), FOOTPRINT_EDIT_FRAME::OpenProjectFiles(), FOOTPRINT_EDIT_FRAME::Process_Special_Functions(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), PCB_EDIT_FRAME::ReadPcbNetlist(), PCB_EDIT_FRAME::RecreateBOMFileFromBoard(), PCB_EDIT_FRAME::RecreateCmpFileFromBoard(), PCB_EDIT_FRAME::RemoveMisConnectedTracks(), PCB_BASE_FRAME::ResetModuleTextSizes(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), PCB_BASE_FRAME::SelectCopperLayerPair(), PCB_BASE_FRAME::SelectLayer(), PCB_EDIT_FRAME::SetElementVisibility(), PCB_EDIT_FRAME::SetLastNetListRead(), PCB_EDIT_FRAME::SetVisibleAlls(), PCB_EDIT_FRAME::Show3D_Frame(), PCB_EDIT_FRAME::SpreadFootprints(), PCB_EDIT_FRAME::SVG_Print(), PCB_EDIT_FRAME::Swap_Layers(), PCB_EDIT_FRAME::UpdateTitle(), and PCB_EDIT_FRAME::UpdateUserInterface().

48 {
49  if( s_PcbEditFrame )
50  return s_PcbEditFrame->GetBoard();
51  else
52  return NULL;
53 }
BOARD * GetBoard() const
static PCB_EDIT_FRAME * s_PcbEditFrame
bool IsActionRunning ( )

Are we currently in an action plugin?

Definition at line 141 of file pcbnew_scripting_helpers.cpp.

References ACTION_PLUGINS::IsActionRunning().

142 {
144 }
static bool IsActionRunning()
Function IsActionRunning.
BOARD* LoadBoard ( wxString &  aFileName,
IO_MGR::PCB_FILE_T  aFormat 
)

Definition at line 75 of file pcbnew_scripting_helpers.cpp.

References BOARD::BuildConnectivity(), and IO_MGR::Load().

76 {
77  BOARD* brd = IO_MGR::Load( aFormat, aFileName );
78 
79  if( brd )
80  brd->BuildConnectivity();
81 
82  return brd;
83 }
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:171
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
BOARD* LoadBoard ( wxString &  aFileName)

Definition at line 62 of file pcbnew_scripting_helpers.cpp.

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

Referenced by LoadBoard().

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

Update the board display after modifying it bu a python script (note: it is automatically called by action plugins, after running the plugin, so call this function is usually not needed inside action plugins.

Could be deprecated because modifying a board (especially deleting items) outside a action plugin can crash Pcbnew.

Definition at line 104 of file pcbnew_scripting_helpers.cpp.

References BOARD::BuildConnectivity(), PCB_DRAW_PANEL_GAL::DisplayBoard(), PCB_BASE_FRAME::GetBoard(), EDA_DRAW_FRAME::GetCanvas(), EDA_DRAW_FRAME::GetGalCanvas(), EDA_DRAW_FRAME::IsGalCanvasActive(), EDA_DRAW_PANEL_GAL::Refresh(), and EDA_DRAW_PANEL::Refresh().

Referenced by EDA_MSG_PANEL::AppendMessage(), C3D_MODEL_VIEWER::Clear3DModel(), DRCLISTBOX::DeleteAllItems(), DRCLISTBOX::DeleteItem(), PYTHON_ACTION_PLUGINS::deregister_action(), LIB_EDIT_FRAME::emptyScreen(), EDA_MSG_PANEL::EraseMsgBox(), EDA_DRAW_PANEL_GAL::GetViewControls(), PCB_EDIT_FRAME::ImportSpecctraSession(), LIB_EDIT_FRAME::InstallFieldsEditorDialog(), LIB_EDIT_FRAME::LoadOneLibraryPartAux(), PCB_EDIT_FRAME::onBoardLoaded(), PCB_EDIT_FRAME::OnFlipPcbView(), C3D_MODEL_VIEWER::OnMouseMove(), C3D_MODEL_VIEWER::OnMouseWheel(), DIALOG_LAYERS_SETUP::OnSize(), FOOTPRINT_PREVIEW_WIDGET::OnStatusChange(), DIALOG_FP_LIB_TABLE::optionsEditor(), EDA_DRAW_PANEL::Refresh(), DIALOG_EDIT_LINE_STYLE::resetDefaults(), TEMPLATE_WIDGET::Select(), C3D_MODEL_VIEWER::Set3DModel(), WIDGET_EESCHEMA_COLOR_CONFIG::SetColor(), DRCLISTBOX::SetList(), EDA_MSG_PANEL::SetMessage(), FOOTPRINTS_LISTBOX::SetSelection(), LIBRARY_LISTBOX::SetSelection(), EDA_3D_VIEWER::takeScreenshot(), TEMPLATE_WIDGET::Unselect(), mpWindow::UpdateAll(), DIALOG_EDIT_LINE_STYLE::updateColorButton(), KIGFX::OPENGL_GAL::updatedGalDisplayOptions(), KIGFX::CAIRO_GAL::updatedGalDisplayOptions(), DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample(), and PCB_EDIT_FRAME::UseGalCanvas().

105 {
106  if( s_PcbEditFrame )
107  {
108  auto board = s_PcbEditFrame->GetBoard();
109  board->BuildConnectivity();
110 
112  {
113  auto panel = static_cast<PCB_DRAW_PANEL_GAL*>( s_PcbEditFrame->GetGalCanvas() );
114  panel->DisplayBoard(board);
116  }
117  else
118  // first argument is erase background, second is a wxRect that
119  // defines a reftresh area (all canvas if null)
120  s_PcbEditFrame->GetCanvas()->Refresh( true, NULL );
121  }
122 }
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:338
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:351
BOARD * GetBoard() const
void DisplayBoard(BOARD *aBoard)
Function DisplayBoard adds all items from the current board to the VIEW, so they can be displayed by ...
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:887
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:895
static PCB_EDIT_FRAME * s_PcbEditFrame
bool SaveBoard ( wxString &  aFileName,
BOARD aBoard 
)

Definition at line 98 of file pcbnew_scripting_helpers.cpp.

References IO_MGR::KICAD_SEXP, and SaveBoard().

99 {
100  return SaveBoard( aFileName, aBoard, IO_MGR::KICAD_SEXP );
101 }
bool SaveBoard(wxString &aFileName, BOARD *aBoard, IO_MGR::PCB_FILE_T aFormat)
S-expression Pcbnew file format.
Definition: io_mgr.h:55
void ScriptingSetPcbEditFrame ( PCB_EDIT_FRAME aPCBEdaFrame)

Definition at line 56 of file pcbnew_scripting_helpers.cpp.

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

57 {
58  s_PcbEditFrame = aPcbEditFrame;
59 }
static PCB_EDIT_FRAME * s_PcbEditFrame
void UpdateUserInterface ( )

Update the layer manager and other widgets from the board setup (layer and items visibility, colors ...) (note: it is automatically called by action plugins, after running the plugin, so call this function is usually not needed inside action plugins.

Definition at line 134 of file pcbnew_scripting_helpers.cpp.

References PCB_EDIT_FRAME::UpdateUserInterface().

Referenced by PYTHON_ACTION_PLUGINS::deregister_action(), and PCB_EDIT_FRAME::UseGalCanvas().

135 {
136  if( s_PcbEditFrame )
138 }
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility, colors ...)
static PCB_EDIT_FRAME * s_PcbEditFrame
void WindowZoom ( int  xl,
int  yl,
int  width,
int  height 
)

Definition at line 125 of file pcbnew_scripting_helpers.cpp.

References EDA_DRAW_FRAME::Window_Zoom().

126 {
127  EDA_RECT Rect( wxPoint( xl, yl ), wxSize( width, height )) ;
128 
129  if( s_PcbEditFrame )
130  s_PcbEditFrame->Window_Zoom( Rect );
131 }
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void Window_Zoom(EDA_RECT &Rect)
Definition: zoom.cpp:124
static PCB_EDIT_FRAME * s_PcbEditFrame