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 by 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

◆ GetBoard()

BOARD* GetBoard ( )

Definition at line 48 of file pcbnew_scripting_helpers.cpp.

References PCB_BASE_FRAME::GetBoard(), and s_PcbEditFrame.

Referenced by DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME(), PCB_EDIT_FRAME::DoShowBoardSetupDialog(), EVT_GRID_CMD_CELL_CHANGED(), EVT_UPDATE_UI(), PCB_EDIT_FRAME::ExportSpecctraFile(), PCB_EDIT_FRAME::ExportSVG(), PCB_EDIT_FRAME::ExportToSpecctra(), 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::LoadModuleFromLibrary(), PCB_EDIT_FRAME::LockModule(), FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay(), FOOTPRINT_EDIT_FRAME::moveExact(), PCB_EDIT_FRAME::onBoardLoaded(), PCB_EDIT_FRAME::OnCloseWindow(), 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_BASE_EDIT_FRAME::SaveCopyInUndoList(), PCB_EDIT_FRAME::SetElementVisibility(), PCB_EDIT_FRAME::SetLastNetListRead(), PCB_EDIT_FRAME::SetVisibleAlls(), PCB_EDIT_FRAME::UpdateTitle(), and PCB_EDIT_FRAME::UpdateUserInterface().

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

◆ IsActionRunning()

bool IsActionRunning ( )

Are we currently in an action plugin?

Definition at line 149 of file pcbnew_scripting_helpers.cpp.

References ACTION_PLUGINS::IsActionRunning().

150 {
152 }
static bool IsActionRunning()
Function IsActionRunning.

◆ LoadBoard() [1/2]

BOARD* LoadBoard ( wxString &  aFileName,
IO_MGR::PCB_FILE_T  aFormat 
)

Definition at line 76 of file pcbnew_scripting_helpers.cpp.

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

77 {
78  BOARD* brd = IO_MGR::Load( aFormat, aFileName );
79 
80  if( brd )
81  {
82  brd->BuildConnectivity();
83  brd->BuildListOfNets();
85  }
86 
87 
88  return brd;
89 }
void BuildListOfNets()
Definition: class_board.h:735
void SynchronizeNetsAndNetClasses()
Function SynchronizeNetsAndNetClasses copies NETCLASS info to each NET, based on NET membership in a ...
Definition: netclass.cpp:155
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:173
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:171

◆ LoadBoard() [2/2]

BOARD* LoadBoard ( wxString &  aFileName)

Definition at line 63 of file pcbnew_scripting_helpers.cpp.

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

Referenced by LoadBoard().

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

◆ Refresh()

void Refresh ( )

Update the board display after modifying it by 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 110 of file pcbnew_scripting_helpers.cpp.

References BOARD::BuildConnectivity(), PCB_BASE_FRAME::GetBoard(), EDA_DRAW_FRAME::GetCanvas(), EDA_DRAW_FRAME::GetGalCanvas(), EDA_DRAW_FRAME::IsGalCanvasActive(), EDA_DRAW_PANEL::Refresh(), s_PcbEditFrame, and PCB_EDIT_FRAME::UseGalCanvas().

Referenced by EDA_MSG_PANEL::AppendMessage(), C3D_MODEL_VIEWER::Clear3DModel(), DRCLISTBOX::DeleteAllItems(), DRCLISTBOX::DeleteItem(), LIB_EDIT_FRAME::emptyScreen(), EDA_MSG_PANEL::EraseMsgBox(), PCB_EDIT_FRAME::ImportSpecctraSession(), LIB_EDIT_FRAME::LoadOneLibraryPartAux(), PCB_EDIT_FRAME::onBoardLoaded(), PCB_EDIT_FRAME::OnFlipPcbView(), C3D_MODEL_VIEWER::OnMouseMove(), C3D_MODEL_VIEWER::OnMouseWheel(), FOOTPRINT_PREVIEW_WIDGET::OnStatusChange(), 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(), SCH_DRAW_PANEL::SwitchBackend(), 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().

111 {
112  if( s_PcbEditFrame )
113  {
114  auto board = s_PcbEditFrame->GetBoard();
115  board->BuildConnectivity();
116 
118  {
119  auto gal_canvas = static_cast<PCB_DRAW_PANEL_GAL*>( s_PcbEditFrame->GetGalCanvas() );
120 
121  // Reinit everything: this is the easy way to do that
122  s_PcbEditFrame->UseGalCanvas( true );
123  gal_canvas->Refresh();
124  }
125  else
126  // first argument is erase background, second is a wxRect that
127  // defines a reftresh area (all canvas if null)
128  s_PcbEditFrame->GetCanvas()->Refresh( true, NULL );
129  }
130 }
void UseGalCanvas(bool aEnable) override
>
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:934
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:927
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
virtual EDA_DRAW_PANEL * GetCanvas() const
Definition: draw_frame.h:394
BOARD * GetBoard() const
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
static PCB_EDIT_FRAME * s_PcbEditFrame

◆ SaveBoard()

bool SaveBoard ( wxString &  aFileName,
BOARD aBoard 
)

Definition at line 104 of file pcbnew_scripting_helpers.cpp.

References IO_MGR::KICAD_SEXP, and SaveBoard().

105 {
106  return SaveBoard( aFileName, aBoard, IO_MGR::KICAD_SEXP );
107 }
bool SaveBoard(wxString &aFileName, BOARD *aBoard, IO_MGR::PCB_FILE_T aFormat)
S-expression Pcbnew file format.
Definition: io_mgr.h:57

◆ ScriptingSetPcbEditFrame()

void ScriptingSetPcbEditFrame ( PCB_EDIT_FRAME aPCBEdaFrame)

Definition at line 57 of file pcbnew_scripting_helpers.cpp.

References s_PcbEditFrame.

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

58 {
59  s_PcbEditFrame = aPcbEditFrame;
60 }
static PCB_EDIT_FRAME * s_PcbEditFrame

◆ UpdateUserInterface()

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 142 of file pcbnew_scripting_helpers.cpp.

References s_PcbEditFrame, and PCB_EDIT_FRAME::UpdateUserInterface().

Referenced by PCB_EDIT_FRAME::DoShowBoardSetupDialog(), and PCB_EDIT_FRAME::UseGalCanvas().

143 {
144  if( s_PcbEditFrame )
146 }
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility, colors ...)
static PCB_EDIT_FRAME * s_PcbEditFrame

◆ WindowZoom()

void WindowZoom ( int  xl,
int  yl,
int  width,
int  height 
)

Definition at line 133 of file pcbnew_scripting_helpers.cpp.

References s_PcbEditFrame, and EDA_DRAW_FRAME::Window_Zoom().

134 {
135  EDA_RECT Rect( wxPoint( xl, yl ), wxSize( width, height ) );
136 
137  if( s_PcbEditFrame )
138  s_PcbEditFrame->Window_Zoom( Rect );
139 }
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual void Window_Zoom(EDA_RECT &Rect)
static PCB_EDIT_FRAME * s_PcbEditFrame