KiCad PCB EDA Suite
pcb_edit_frame.cpp File Reference
#include <fctsys.h>
#include <kiface_i.h>
#include <kiway.h>
#include <pgm_base.h>
#include <pcb_edit_frame.h>
#include <3d_viewer/eda_3d_viewer.h>
#include <fp_lib_table.h>
#include <bitmaps.h>
#include <trace_helpers.h>
#include <pcbnew_id.h>
#include <pcbnew_settings.h>
#include <pcb_layer_box_selector.h>
#include <pcb_layer_widget.h>
#include <footprint_edit_frame.h>
#include <dialog_plot.h>
#include <dialog_edit_footprint_for_BoardEditor.h>
#include <dialogs/dialog_exchange_footprints.h>
#include <dialog_board_setup.h>
#include <convert_to_biu.h>
#include <invoke_pcb_dialog.h>
#include <class_board.h>
#include <class_module.h>
#include <ws_proxy_view_item.h>
#include <connectivity/connectivity_data.h>
#include <wildcards_and_files_ext.h>
#include <pcb_draw_panel_gal.h>
#include <functional>
#include <project/project_file.h>
#include <project/project_local_settings.h>
#include <project/net_settings.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/selection_tool.h>
#include <tools/pcbnew_picker_tool.h>
#include <tools/point_editor.h>
#include <tools/edit_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/pcbnew_control.h>
#include <tools/pcb_editor_control.h>
#include <tools/pcb_inspection_tool.h>
#include <tools/pcb_editor_conditions.h>
#include <tools/pcb_viewer_tools.h>
#include <tools/pcb_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 <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/wupdlock.h>
#include <dialog_drc.h>
#include <ratsnest/ratsnest_viewitem.h>
#include <widgets/appearance_controls.h>
#include <widgets/panel_selection_filter.h>
#include <kiplatform/app.h>
#include <widgets/infobar.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 168 of file pcb_edit_frame.cpp.

175  :
176  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_EDITOR, wxT( "Pcbnew" ), wxDefaultPosition,
178 {
179  m_showBorderAndTitleBlock = true; // true to display sheet references
180  m_SelTrackWidthBox = NULL;
181  m_SelViaSizeBox = NULL;
182  m_SelLayerBox = NULL;
183  m_show_microwave_tools = false;
184  m_show_layer_manager_tools = true;
185  m_hasAutoSave = true;
186  m_microWaveToolBar = NULL;
187  m_Layers = nullptr;
188 
189  // We don't know what state board was in when it was lasat saved, so we have to
190  // assume dirty
191  m_ZoneFillsDirty = true;
192 
193  m_rotationAngle = 900;
194  m_AboutTitle = "Pcbnew";
195 
196  // Create GAL canvas
197  auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
198  GetGalDisplayOptions(),
200 
201  SetCanvas( canvas );
202 
203  SetBoard( new BOARD() );
204 
205  wxIcon icon;
206  icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) );
207  SetIcon( icon );
208 
209  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
210  // initialize parameters in m_LayersManager
211  LoadSettings( config() );
212 
213  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
214 
215  // PCB drawings start in the upper left corner.
216  GetScreen()->m_Center = false;
217 
218  setupTools();
219  ReCreateMenuBar();
220  ReCreateHToolbar();
221  ReCreateAuxiliaryToolbar();
222  ReCreateVToolbar();
223  ReCreateOptToolbar();
224  ReCreateMicrowaveVToolbar();
225 
226  // We call this after the toolbars have been created to ensure the layer widget button handler
227  // doesn't cause problems
228  setupUIConditions();
229 
230  m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
231 
232  // Create the infobar
233  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
234 
235  m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas() );
236 
237  m_auimgr.SetManagedWindow( this );
238  m_auimgr.SetFlags( wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE );
239 
240  // Horizontal items; layers 4 - 6
241  m_auimgr.AddPane( m_mainToolBar,
242  EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
243  m_auimgr.AddPane( m_auxiliaryToolBar,
244  EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(5) );
245  m_auimgr.AddPane( m_messagePanel,
246  EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
247  m_auimgr.AddPane( m_infoBar,
248  EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
249 
250  // Vertical items; layers 1 - 3
251  m_auimgr.AddPane( m_optionsToolBar,
252  EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
253 
254  m_auimgr.AddPane( m_microWaveToolBar,
255  EDA_PANE().VToolbar().Name( "MicrowaveToolbar" ).Right().Layer(2) );
256  m_auimgr.AddPane( m_drawToolBar,
257  EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(3) );
258 
259  m_auimgr.AddPane( m_appearancePanel,
260  EDA_PANE().Name( "LayersManager" ).Right().Layer( 4 )
261  .Caption( _( "Appearance" ) ).PaneBorder( false )
262  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
263 
264  m_auimgr.AddPane( m_selectionFilterPanel,
265  EDA_PANE().Name( "SelectionFilter" ).Right().Layer( 4 )
266  .Caption( _( "Selection Filter" ) ).PaneBorder( false ).Position( 2 )
267  .MinSize( 180, -1 ).BestSize( 180, -1 ) );
268 
269  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
270 
271  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
272  m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
273  m_auimgr.GetPane( "MicrowaveToolbar" ).Show( m_show_microwave_tools );
274 
275  // The selection filter doesn't need to grow in the vertical direction when docked
276  m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
277 
278  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
279  // hidding it.
280  m_auimgr.Update();
281 
282  if( PCBNEW_SETTINGS* settings = dynamic_cast<PCBNEW_SETTINGS*>( config() ) )
283  {
284  if( settings->m_AuiPanels.right_panel_width > 0 )
285  {
286  wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
287 
288  // wxAUI hack: force width by setting MinSize() and then Fixed()
289  // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
290  layersManager.MinSize( settings->m_AuiPanels.right_panel_width, -1 );
291  layersManager.Fixed();
292  m_auimgr.Update();
293 
294  // now make it resizable again
295  layersManager.MinSize( 180, -1 );
296  layersManager.Resizable();
297  m_auimgr.Update();
298  }
299 
300  m_appearancePanel->SetTabIndex( settings->m_AuiPanels.appearance_panel_tab );
301  }
302 
303  // We don't want the infobar displayed right away
304  m_auimgr.GetPane( "InfoBar" ).Hide();
305  m_auimgr.Update();
306 
307  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
308 
309  // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
310  // to calculate the wrong zoom size. See PCB_EDIT_FRAME::onSize().
311  Bind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
312 
313  m_canvasType = LoadCanvasTypeSetting();
314 
315  // Nudge user to switch to OpenGL if they are on Cairo
316  if( m_firstRunDialogSetting < 1 )
317  {
318  if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
319  {
320  wxString msg = _( "KiCad can use your graphics card to give you a smoother "
321  "and faster experience. This option is turned off by "
322  "default since it is not compatible with all computers.\n\n"
323  "Would you like to try enabling graphics acceleration?\n\n"
324  "If you'd like to choose later, select Accelerated Graphics "
325  "in the Preferences menu." );
326 
327  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
328 
329  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
330 
331  if( dlg.ShowModal() == wxID_YES )
332  {
333  // Save Cairo as default in case OpenGL crashes
334  saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
335 
336  // Switch to OpenGL, which will save the new setting if successful
337  GetToolManager()->RunAction( ACTIONS::acceleratedGraphics, true );
338 
339  // Switch back to Cairo if OpenGL is not supported
340  if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
341  GetToolManager()->RunAction( ACTIONS::standardGraphics, true );
342  }
343  else
344  {
345  // If they were on legacy, switch to Cairo
346  GetToolManager()->RunAction( ACTIONS::standardGraphics, true );
347  }
348  }
349 
350  m_firstRunDialogSetting = 1;
351  SaveSettings( config() );
352  }
353 
354  InitExitKey();
355 
356  // Ensure the Python interpreter is up to date with its environment variables
357  PythonSyncEnvironmentVariables();
358  PythonSyncProjectName();
359 
360  GetCanvas()->SwitchBackend( m_canvasType );
361  ActivateGalCanvas();
362 
363  // Default shutdown reason until a file is loaded
364  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New PCB file is unsaved" ) );
365 
366  // disable Export STEP item if kicad2step does not exist
367  wxString strK2S = Pgm().GetExecutablePath();
368 
369 #ifdef __WXMAC__
370  if( strK2S.Find( "pcbnew.app" ) != wxNOT_FOUND )
371  {
372  // On macOS, we have standalone applications inside the main bundle, so we handle that here:
373  strK2S += "../../";
374  }
375 
376  strK2S += "Contents/MacOS/";
377 #endif
378 
379  wxFileName appK2S( strK2S, "kicad2step" );
380 
381  #ifdef _WIN32
382  appK2S.SetExt( "exe" );
383  #endif
384 
385  // Ensure the window is on top
386  Raise();
387 
388 // if( !appK2S.FileExists() )
389  // GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
390 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
static constexpr GAL_TYPE GAL_FALLBACK
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
static TOOL_ACTION standardGraphics
Definition: actions.h:162
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:51
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
#define NULL
GAL not used (the legacy wxDC engine is used)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Specialization of the wxAuiPaneInfo class for KiCad panels.
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:68
Common, abstract interface for edit frames.
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:178
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION acceleratedGraphics
Definition: actions.h:161
void onSize(wxSizeEvent &aEvent)
#define PCB_EDIT_FRAME_NAME
const BITMAP_OPAQUE icon_pcbnew_xpm[1]
Definition: icon_pcbnew.cpp:49

References _, ACTIONS::acceleratedGraphics, PCAD2KICAD::Center, EDA_DRAW_PANEL_GAL::GAL_FALLBACK, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO, EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL, icon_pcbnew_xpm, KiBitmap(), PCAD2KICAD::Left, NULL, PCB_EDIT_FRAME::onSize(), Pgm(), PCAD2KICAD::Right, KIPLATFORM::APP::SetShutdownBlockReason(), ACTIONS::standardGraphics, and ACTIONS::zoomFitScreen.

◆ ExportBoardToHyperlynx()

bool ExportBoardToHyperlynx ( BOARD aBoard,
const wxFileName &  aPath 
)

Definition at line 638 of file export_hyperlynx.cpp.

639 {
640  HYPERLYNX_EXPORTER exporter;
641  exporter.SetBoard( aBoard );
642  exporter.SetOutputFilename( aPath );
643  return exporter.Run();
644 }
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 166 of file pcb_edit_frame.cpp.

Referenced by PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event().