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 <profile.h>
#include <view/wx_view_controls.h>
#include <footprint_viewer_frame.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 172 of file pcb_edit_frame.cpp.

177  :
178  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_EDITOR, _( "PCB Editor" ), wxDefaultPosition,
180  m_exportNetlistAction( nullptr ), m_findDialog( nullptr )
181 {
182  m_maximizeByDefault = true;
183  m_showBorderAndTitleBlock = true; // true to display sheet references
184  m_SelTrackWidthBox = nullptr;
185  m_SelViaSizeBox = nullptr;
186  m_SelLayerBox = nullptr;
187  m_show_layer_manager_tools = true;
188  m_hasAutoSave = true;
189 
190  // We don't know what state board was in when it was last saved, so we have to
191  // assume dirty
192  m_ZoneFillsDirty = true;
193 
194  m_rotationAngle = 900;
195  m_aboutTitle = _( "KiCad PCB Editor" );
196 
197  // Must be created before the menus are created.
198  if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist )
199  m_exportNetlistAction = new TOOL_ACTION( "pcbnew.EditorControl.exportNetlist",
200  AS_GLOBAL, 0, "", _( "Netlist..." ),
201  _( "Export netlist used to update schematics" ) );
202 
203  // Create GAL canvas
204  auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
205  GetGalDisplayOptions(),
207 
208  SetCanvas( canvas );
209 
210  SetBoard( new BOARD() );
211 
212  wxIcon icon;
213  wxIconBundle icon_bundle;
214 
215  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew ) );
216  icon_bundle.AddIcon( icon );
217  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew_32 ) );
218  icon_bundle.AddIcon( icon );
219  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew_16 ) );
220  icon_bundle.AddIcon( icon );
221 
222  SetIcons( icon_bundle );
223 
224  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
225  // initialize parameters in m_LayersManager
226  LoadSettings( config() );
227 
228  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
229 
230  // PCB drawings start in the upper left corner.
231  GetScreen()->m_Center = false;
232 
233  setupTools();
234  setupUIConditions();
235 
236  ReCreateMenuBar();
237  ReCreateHToolbar();
238  ReCreateAuxiliaryToolbar();
239  ReCreateVToolbar();
240  ReCreateOptToolbar();
241 
242  m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
243 
244  m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas() );
245 
246  m_auimgr.SetManagedWindow( this );
247 
248  CreateInfoBar();
249 
250  unsigned int auiFlags = wxAUI_MGR_DEFAULT;
251 #if !defined( _WIN32 )
252  // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds
253  // of graphical glitches.
254  auiFlags |= wxAUI_MGR_LIVE_RESIZE;
255 #endif
256  m_auimgr.SetFlags( auiFlags );
257 
258  // Rows; layers 4 - 6
259  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
260  .Top().Layer( 6 ) );
261  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" )
262  .Top().Layer( 5 ) );
263  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
264  .Bottom().Layer( 6 ) );
265 
266  // Columns; layers 1 - 3
267  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
268  .Left().Layer( 3 ) );
269 
270  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
271  .Right().Layer( 3 ) );
272 
273  m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( "LayersManager" )
274  .Right().Layer( 4 )
275  .Caption( _( "Appearance" ) ).PaneBorder( false )
276  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
277 
278  m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Name( "SelectionFilter" )
279  .Right().Layer( 4 ).Position( 2 )
280  .Caption( _( "Selection Filter" ) ).PaneBorder( false )
281  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
282 
283  // Center
284  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
285  .Center() );
286 
287  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
288  m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
289 
290  // The selection filter doesn't need to grow in the vertical direction when docked
291  m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
292 
293  FinishAUIInitialization();
294 
295  if( PCBNEW_SETTINGS* settings = dynamic_cast<PCBNEW_SETTINGS*>( config() ) )
296  {
297  if( settings->m_AuiPanels.right_panel_width > 0 )
298  {
299  wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
300  SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
301  }
302 
303  m_appearancePanel->SetTabIndex( settings->m_AuiPanels.appearance_panel_tab );
304  }
305 
306  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
307 
308  // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
309  // to calculate the wrong zoom size. See PCB_EDIT_FRAME::onSize().
310  Bind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
311 
312  resolveCanvasType();
313 
314  setupUnits( config() );
315 
316  // Ensure the Python interpreter is up to date with its environment variables
317  PythonSyncEnvironmentVariables();
318  PythonSyncProjectName();
319 
320  // Sync action plugins in case they changed since the last time the frame opened
321  GetToolManager()->RunAction( PCB_ACTIONS::pluginsReload, true );
322 
323  GetCanvas()->SwitchBackend( m_canvasType );
324  ActivateGalCanvas();
325 
326  // Default shutdown reason until a file is loaded
327  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New PCB file is unsaved" ) );
328 
329  // disable Export STEP item if kicad2step does not exist
330  wxString strK2S = Pgm().GetExecutablePath();
331 
332 #ifdef __WXMAC__
333  if( strK2S.Find( wxT( "pcbnew.app" ) ) != wxNOT_FOUND )
334  {
335  // On macOS, we have standalone applications inside the main bundle, so we handle that here:
336  strK2S += wxT( "../../" );
337  }
338 
339  strK2S += wxT( "Contents/MacOS/" );
340 #endif
341 
342  wxFileName appK2S( strK2S, wxT( "kicad2step" ) );
343 
344  #ifdef _WIN32
345  appK2S.SetExt( wxT( "exe" ) );
346  #endif
347 
348  // Ensure the window is on top
349  Raise();
350 
351 // if( !appK2S.FileExists() )
352  // GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
353 
354  // AUI doesn't refresh properly on wxMac after changes in eb7dc6dd, so force it to
355 #ifdef __WXMAC__
356  if( Kiface().IsSingle() )
357  {
358  CallAfter( [&]()
359  {
360  m_appearancePanel->OnBoardChanged();
361  } );
362  }
363 #endif
364 
365  // Register a call to update the toolbar sizes. It can't be done immediately because
366  // it seems to require some sizes calculated that aren't yet (at least on GTK).
367  CallAfter( [&]()
368  {
369  // Ensure the controls on the toolbars all are correctly sized
370  UpdateToolbarControlSizes();
371  } );
372 
374  {
375  m_eventCounterTimer = new wxTimer( this );
376 
377  Bind( wxEVT_TIMER,
378  [&]( wxTimerEvent& aEvent )
379  {
380  GetCanvas()->m_PaintEventCounter->Show();
381  GetCanvas()->m_PaintEventCounter->Reset();
382 
384  static_cast<KIGFX::WX_VIEW_CONTROLS*>( GetCanvas()->GetViewControls() );
385  vc->m_MotionEventCounter->Show();
386  vc->m_MotionEventCounter->Reset();
387 
388  },
389  m_eventCounterTimer->GetId() );
390 
391  m_eventCounterTimer->Start( 1000 );
392  }
393 }
bool m_ShowEventCounters
Shows debugging event counters in various places.
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.
An implementation of class VIEW_CONTROLS for wxWidgets library.
static TOOL_ACTION pluginsReload
Scripting Actions.
Definition: pcb_actions.h:312
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.
std::unique_ptr< PROF_COUNTER > m_MotionEventCounter
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:191
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, KIGFX::WX_VIEW_CONTROLS::m_MotionEventCounter, ADVANCED_CFG::m_ShowEventCounters, PCB_EDIT_FRAME::onSize(), Pgm(), PCB_ACTIONS::pluginsReload, PCAD2KICAD::Right, SetAuiPaneSize(), KIPLATFORM::APP::SetShutdownBlockReason(), and ACTIONS::zoomFitScreen.

◆ ExportBoardToHyperlynx()

bool ExportBoardToHyperlynx ( BOARD aBoard,
const wxFileName &  aPath 
)

Definition at line 655 of file export_hyperlynx.cpp.

656 {
657  HYPERLYNX_EXPORTER exporter;
658  exporter.SetBoard( aBoard );
659  exporter.SetOutputFilename( aPath );
660  return exporter.Run();
661 }
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 170 of file pcb_edit_frame.cpp.

Referenced by PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event().