KiCad PCB EDA Suite
pcb_edit_frame.cpp File Reference
#include <advanced_config.h>
#include <kiface_base.h>
#include <kiway.h>
#include <pgm_base.h>
#include <pcb_edit_frame.h>
#include <3d_viewer/eda_3d_viewer_frame.h>
#include <fp_lib_table.h>
#include <bitmaps.h>
#include <confirm.h>
#include <trace_helpers.h>
#include <pcbnew_id.h>
#include <pcbnew_settings.h>
#include <pcb_layer_box_selector.h>
#include <footprint_edit_frame.h>
#include <dialog_plot.h>
#include <dialog_find.h>
#include <dialog_footprint_properties.h>
#include <dialogs/dialog_exchange_footprints.h>
#include <dialog_board_setup.h>
#include <convert_to_biu.h>
#include <invoke_pcb_dialog.h>
#include <board.h>
#include <board_design_settings.h>
#include <footprint.h>
#include <drawing_sheet/ds_proxy_view_item.h>
#include <connectivity/connectivity_data.h>
#include <wildcards_and_files_ext.h>
#include <pcb_draw_panel_gal.h>
#include <functional>
#include <pcb_painter.h>
#include <project/project_file.h>
#include <project/project_local_settings.h>
#include <project/net_settings.h>
#include <python_scripting.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/action_toolbar.h>
#include <tool/common_control.h>
#include <tool/common_tools.h>
#include <tool/selection.h>
#include <tool/zoom_tool.h>
#include <tools/pcb_selection_tool.h>
#include <tools/pcb_picker_tool.h>
#include <tools/pcb_point_editor.h>
#include <tools/edit_tool.h>
#include <tools/group_tool.h>
#include <tools/drc_tool.h>
#include <tools/global_edit_tool.h>
#include <tools/convert_tool.h>
#include <tools/drawing_tool.h>
#include <tools/pcb_control.h>
#include <tools/board_editor_control.h>
#include <tools/board_inspection_tool.h>
#include <tools/pcb_editor_conditions.h>
#include <tools/pcb_viewer_tools.h>
#include <tools/board_reannotate_tool.h>
#include <tools/placement_tool.h>
#include <tools/pad_tool.h>
#include <microwave/microwave_tool.h>
#include <tools/position_relative_tool.h>
#include <tools/zone_filler_tool.h>
#include <tools/pcb_actions.h>
#include <router/router_tool.h>
#include <router/length_tuner_tool.h>
#include <autorouter/autoplace_tool.h>
#include <python/scripting/pcb_scripting_tool.h>
#include <gestfich.h>
#include <executable_names.h>
#include <netlist_reader/board_netlist_updater.h>
#include <netlist_reader/netlist_reader.h>
#include <netlist_reader/pcb_netlist.h>
#include <wx/socket.h>
#include <wx/wupdlock.h>
#include <dialog_drc.h>
#include <ratsnest/ratsnest_view_item.h>
#include <widgets/appearance_controls.h>
#include <widgets/infobar.h>
#include <widgets/panel_selection_filter.h>
#include <widgets/wx_aui_utils.h>
#include <kiplatform/app.h>
#include <action_plugin.h>
#include "../scripting/python_scripting.h"
#include <wx/filedlg.h>

Go to the source code of this file.

Macros

#define ENABLE(x)   ACTION_CONDITIONS().Enable( x )
 
#define CHECK(x)   ACTION_CONDITIONS().Check( x )
 
#define CURRENT_TOOL(action)   mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
 
#define CURRENT_EDIT_TOOL(action)   mgr->SetConditions( action, ACTION_CONDITIONS().Check( cond.CurrentTool( action ) ).Enable( isDrcRunning ) )
 

Functions

 EVT_MENU_RANGE (ID_POPUP_PCB_SELECT_WIDTH_START_RANGE, ID_POPUP_PCB_SELECT_WIDTH_END_RANGE, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event) EVT_UPDATE_UI_RANGE(ID_POPUP_PCB_SELECT_WIDTH1
 
PCB_EDIT_FRAME::OnUpdateSelectTrackWidth EVT_UPDATE_UI_RANGE (ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_VIASIZE8, PCB_EDIT_FRAME::OnUpdateSelectViaSize) PCB_EDIT_FRAME
 
bool ExportBoardToHyperlynx (BOARD *aBoard, const wxFileName &aPath)
 

Variables

 ID_POPUP_PCB_SELECT_WIDTH8
 

Macro Definition Documentation

◆ CHECK

#define CHECK (   x)    ACTION_CONDITIONS().Check( x )

◆ CURRENT_EDIT_TOOL

#define CURRENT_EDIT_TOOL (   action)    mgr->SetConditions( action, ACTION_CONDITIONS().Check( cond.CurrentTool( action ) ).Enable( isDrcRunning ) )

◆ CURRENT_TOOL

#define CURRENT_TOOL (   action)    mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )

◆ ENABLE

#define ENABLE (   x)    ACTION_CONDITIONS().Enable( x )

Function Documentation

◆ EVT_MENU_RANGE()

◆ EVT_UPDATE_UI_RANGE()

Definition at line 169 of file pcb_edit_frame.cpp.

174  :
175  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_EDITOR, wxT( "PCB Editor" ), wxDefaultPosition,
177  m_exportNetlistAction( nullptr ), m_findDialog( nullptr )
178 {
179  m_maximizeByDefault = true;
180  m_showBorderAndTitleBlock = true; // true to display sheet references
181  m_SelTrackWidthBox = nullptr;
182  m_SelViaSizeBox = nullptr;
183  m_SelLayerBox = nullptr;
184  m_show_layer_manager_tools = true;
185  m_hasAutoSave = true;
186 
187  // We don't know what state board was in when it was last saved, so we have to
188  // assume dirty
189  m_ZoneFillsDirty = true;
190 
191  m_rotationAngle = 900;
192  m_aboutTitle = _( "KiCad PCB Editor" );
193 
194  // Must be created before the menus are created.
195  if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist )
196  m_exportNetlistAction = new TOOL_ACTION( "pcbnew.EditorControl.exportNetlist",
197  AS_GLOBAL, 0, "", _( "Netlist..." ),
198  _( "Export netlist used to update schematics" ) );
199 
200  // Create GAL canvas
201  auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
202  GetGalDisplayOptions(),
204 
205  SetCanvas( canvas );
206 
207  SetBoard( new BOARD() );
208 
209  wxIcon icon;
210  wxIconBundle icon_bundle;
211 
212  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew ) );
213  icon_bundle.AddIcon( icon );
214  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew_32 ) );
215  icon_bundle.AddIcon( icon );
216  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew_16 ) );
217  icon_bundle.AddIcon( icon );
218 
219  SetIcons( icon_bundle );
220 
221  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
222  // initialize parameters in m_LayersManager
223  LoadSettings( config() );
224 
225  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
226 
227  // PCB drawings start in the upper left corner.
228  GetScreen()->m_Center = false;
229 
230  setupTools();
231  setupUIConditions();
232 
233  ReCreateMenuBar();
234  ReCreateHToolbar();
235  ReCreateAuxiliaryToolbar();
236  ReCreateVToolbar();
237  ReCreateOptToolbar();
238 
239  m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
240 
241  m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas() );
242 
243  m_auimgr.SetManagedWindow( this );
244 
245  CreateInfoBar();
246 
247  unsigned int auiFlags = wxAUI_MGR_DEFAULT;
248 #if !defined( _WIN32 )
249  // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds
250  // of graphical glitches.
251  auiFlags |= wxAUI_MGR_LIVE_RESIZE;
252 #endif
253  m_auimgr.SetFlags( auiFlags );
254 
255  // Rows; layers 4 - 6
256  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
257  .Top().Layer( 6 ) );
258  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" )
259  .Top().Layer( 5 ) );
260  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
261  .Bottom().Layer( 6 ) );
262 
263  // Columns; layers 1 - 3
264  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
265  .Left().Layer( 3 ) );
266 
267  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
268  .Right().Layer( 3 ) );
269 
270  m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( "LayersManager" )
271  .Right().Layer( 4 )
272  .Caption( _( "Appearance" ) ).PaneBorder( false )
273  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
274 
275  m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Name( "SelectionFilter" )
276  .Right().Layer( 4 ).Position( 2 )
277  .Caption( _( "Selection Filter" ) ).PaneBorder( false )
278  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
279 
280  // Center
281  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
282  .Center() );
283 
284  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
285  m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
286 
287  // The selection filter doesn't need to grow in the vertical direction when docked
288  m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
289 
290  FinishAUIInitialization();
291 
292  if( PCBNEW_SETTINGS* settings = dynamic_cast<PCBNEW_SETTINGS*>( config() ) )
293  {
294  if( settings->m_AuiPanels.right_panel_width > 0 )
295  {
296  wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
297  SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
298  }
299 
300  m_appearancePanel->SetTabIndex( settings->m_AuiPanels.appearance_panel_tab );
301  }
302 
303  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
304 
305  // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
306  // to calculate the wrong zoom size. See PCB_EDIT_FRAME::onSize().
307  Bind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
308 
309  resolveCanvasType();
310 
311  setupUnits( config() );
312 
313  // Ensure the Python interpreter is up to date with its environment variables
314  PythonSyncEnvironmentVariables();
315  PythonSyncProjectName();
316 
317  GetCanvas()->SwitchBackend( m_canvasType );
318  ActivateGalCanvas();
319 
320  // Default shutdown reason until a file is loaded
321  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New PCB file is unsaved" ) );
322 
323  // disable Export STEP item if kicad2step does not exist
324  wxString strK2S = Pgm().GetExecutablePath();
325 
326 #ifdef __WXMAC__
327  if( strK2S.Find( "pcbnew.app" ) != wxNOT_FOUND )
328  {
329  // On macOS, we have standalone applications inside the main bundle, so we handle that here:
330  strK2S += "../../";
331  }
332 
333  strK2S += "Contents/MacOS/";
334 #endif
335 
336  wxFileName appK2S( strK2S, "kicad2step" );
337 
338  #ifdef _WIN32
339  appK2S.SetExt( "exe" );
340  #endif
341 
342  // Ensure the window is on top
343  Raise();
344 
345 // if( !appK2S.FileExists() )
346  // GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
347 
348  // AUI doesn't refresh properly on wxMac after changes in eb7dc6dd, so force it to
349 #ifdef __WXMAC__
350  if( Kiface().IsSingle() )
351  {
352  CallAfter( [&]()
353  {
354  m_appearancePanel->OnBoardChanged();
355  } );
356  }
357 #endif
358 
359  // Register a call to update the toolbar sizes. It can't be done immediately because
360  // it seems to require some sizes calculated that aren't yet (at least on GTK).
361  CallAfter( [&]()
362  {
363  // Ensure the controls on the toolbars all are correctly sized
364  UpdateToolbarControlSizes();
365  } );
366 }
void SetAuiPaneSize(wxAuiManager &aManager, wxAuiPaneInfo &aPane, int aWidth, int aHeight)
Sets the size of an AUI pane, working around http://trac.wxwidgets.org/ticket/13180.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static constexpr GAL_TYPE GAL_FALLBACK
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:83
#define _(s)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
Specialization of the wxAuiPaneInfo class for KiCad panels.
Common, abstract interface for edit frames.
Global action (toolbar/main menu event, global shortcut)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
Represent a single user action.
Definition: tool_action.h:67
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void onSize(wxSizeEvent &aEvent)
#define PCB_EDIT_FRAME_NAME

References _, AS_GLOBAL, PCAD2KICAD::Center, config, EDA_DRAW_PANEL_GAL::GAL_FALLBACK, ADVANCED_CFG::GetCfg(), icon_pcbnew, icon_pcbnew_16, icon_pcbnew_32, KiBitmap(), Kiface(), PCAD2KICAD::Left, PCB_EDIT_FRAME::onSize(), Pgm(), PCAD2KICAD::Right, SetAuiPaneSize(), KIPLATFORM::APP::SetShutdownBlockReason(), and ACTIONS::zoomFitScreen.

◆ ExportBoardToHyperlynx()

bool ExportBoardToHyperlynx ( BOARD aBoard,
const wxFileName &  aPath 
)

Definition at line 642 of file export_hyperlynx.cpp.

643 {
644  HYPERLYNX_EXPORTER exporter;
645  exporter.SetBoard( aBoard );
646  exporter.SetOutputFilename( aPath );
647  return exporter.Run();
648 }
void SetOutputFilename(const wxFileName &aPath)
void SetBoard(BOARD *aBoard)
virtual bool Run() override

References HYPERLYNX_EXPORTER::Run(), BOARD_EXPORTER_BASE::SetBoard(), and BOARD_EXPORTER_BASE::SetOutputFilename().

Referenced by PCB_EDIT_FRAME::OnExportHyperlynx().

Variable Documentation

◆ ID_POPUP_PCB_SELECT_WIDTH8

ID_POPUP_PCB_SELECT_WIDTH8

Definition at line 167 of file pcb_edit_frame.cpp.

Referenced by PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event().