KiCad PCB EDA Suite
pcb_edit_frame.cpp File Reference
#include <fctsys.h>
#include <kiface_i.h>
#include <pgm_base.h>
#include <confirm.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.h>
#include <pcbnew_id.h>
#include <tools/drc.h>
#include <layer_widget.h>
#include <pcb_layer_widget.h>
#include <config_params.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 <view/view_controls.h>
#include <pcb_painter.h>
#include <invoke_pcb_dialog.h>
#include <class_track.h>
#include <class_board.h>
#include <class_module.h>
#include <ws_proxy_view_item.h>
#include <connectivity/connectivity_data.h>
#include <ratsnest_viewitem.h>
#include <wildcards_and_files_ext.h>
#include <kicad_string.h>
#include <pcb_draw_panel_gal.h>
#include <functional>
#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/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/global_edit_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/placement_tool.h>
#include <tools/pad_tool.h>
#include <tools/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/autoplacer_tool.h>
#include <gestfich.h>
#include <executable_names.h>
#include <board_netlist_updater.h>
#include <netlist_reader.h>
#include <pcb_netlist.h>
#include <wx/wupdlock.h>
#include <dialog_drc.h>

Go to the source code of this file.

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
 
static const wxString PlotLineWidthEntry = "PlotLineWidth_mm"
 
static const wxString ShowMicrowaveEntry = "ShowMicrowaveTools"
 
static const wxString ShowLayerManagerEntry = "ShowLayerManagerTools"
 
static const wxString ShowPageLimitsEntry = "ShowPageLimits"
 

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  m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
189 
190  // We don't know what state board was in when it was lasat saved, so we have to
191  // assume dirty
192  m_ZoneFillsDirty = true;
193 
194  m_rotationAngle = 900;
195  m_AboutTitle = "Pcbnew";
196 
197  // Create GAL canvas
198  auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
199  GetGalDisplayOptions(),
201 
202  SetCanvas( canvas );
203 
204  SetBoard( new BOARD() );
205 
206  // Create the PCB_LAYER_WIDGET *after* SetBoard():
207  m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas() );
208 
209  wxIcon icon;
210  icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) );
211  SetIcon( icon );
212 
213  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
214  // initialize parameters in m_LayersManager
215  LoadSettings( config() );
216 
217  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
218  GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
219 
220  // PCB drawings start in the upper left corner.
221  GetScreen()->m_Center = false;
222 
223  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
224 
225  GetScreen()->AddGrid( m_UserGridSize, EDA_UNITS_T::UNSCALED_UNITS, ID_POPUP_GRID_USER );
226  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
227 
228  setupTools();
229  ReCreateMenuBar();
230  ReCreateHToolbar();
231  ReCreateAuxiliaryToolbar();
232  ReCreateVToolbar();
233  ReCreateOptToolbar();
234  ReCreateMicrowaveVToolbar();
235 
236  m_auimgr.SetManagedWindow( this );
237 
238  // Horizontal items; layers 4 - 6
239  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
240  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(4) );
241  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
242 
243  // Vertical items; layers 1 - 3
244  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
245 
246  m_auimgr.AddPane( m_microWaveToolBar, EDA_PANE().VToolbar().Name( "MicrowaveToolbar" ).Right().Layer(1) );
247  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(2) );
248  m_auimgr.AddPane( m_Layers, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
249  .Caption( _( "Layers Manager" ) ).PaneBorder( false )
250  .MinSize( 80, -1 ).BestSize( m_Layers->GetBestSize() ) );
251 
252  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
253 
254  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
255  m_auimgr.GetPane( "MicrowaveToolbar" ).Show( m_show_microwave_tools );
256 
257  m_Layers->ReFillRender(); // Update colors in Render after the config is read
258  ReFillLayerWidget(); // this is near end and after ReFillRender()
259  // because contents establish size
260  syncLayerWidgetLayer();
261 
262  m_auimgr.Update();
263  GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId );
264  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
265 
266  m_canvasType = LoadCanvasTypeSetting();
267 
268  // Nudge user to switch to OpenGL if they are on Cairo
269  if( m_firstRunDialogSetting < 1 )
270  {
271  if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
272  {
273  wxString msg = _( "KiCad can use your graphics card to give you a smoother "
274  "and faster experience. This option is turned off by "
275  "default since it is not compatible with all computers.\n\n"
276  "Would you like to try enabling graphics acceleration?\n\n"
277  "If you'd like to choose later, select Accelerated Graphics "
278  "in the Preferences menu." );
279 
280  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
281 
282  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
283 
284  if( dlg.ShowModal() == wxID_YES )
285  {
286  // Save Cairo as default in case OpenGL crashes
287  saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
288 
289  // Switch to OpenGL, which will save the new setting if successful
290  GetToolManager()->RunAction( ACTIONS::acceleratedGraphics, true );
291 
292  // Switch back to Cairo if OpenGL is not supported
293  if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
294  GetToolManager()->RunAction( ACTIONS::standardGraphics, true );
295  }
296  else
297  {
298  // If they were on legacy, switch to Cairo
299  GetToolManager()->RunAction( ACTIONS::standardGraphics, true );
300  }
301  }
302 
303  m_firstRunDialogSetting = 1;
304  SaveSettings( config() );
305  }
306 
307  InitExitKey();
308 
309  GetCanvas()->SwitchBackend( m_canvasType );
310  GetCanvas()->GetView()->SetScale( GetZoomLevelCoeff() / GetScreen()->GetZoom() );
311  ActivateGalCanvas();
312 
313  // disable Export STEP item if kicad2step does not exist
314  wxString strK2S = Pgm().GetExecutablePath();
315 
316 #ifdef __WXMAC__
317  if (strK2S.find( "pcbnew.app" ) != wxNOT_FOUND )
318  {
319  // On macOS, we have standalone applications inside the main bundle, so we handle that here:
320  strK2S += "../../";
321  }
322 
323  strK2S += "Contents/MacOS/";
324 #endif
325 
326  wxFileName appK2S( strK2S, "kicad2step" );
327 
328  #ifdef _WIN32
329  appK2S.SetExt( "exe" );
330  #endif
331 
332 // if( !appK2S.FileExists() )
333  // GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
334 }
Class PCB_LAYER_WIDGET is here to implement the abstract functions of LAYER_WIDGET so they may be tie...
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
static TOOL_ACTION standardGraphics
Definition: actions.h:155
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
static TOOL_ACTION gridPreset
Definition: actions.h:131
GAL not used (the legacy wxDC engine is used)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define _(s)
Specialization of the wxAuiPaneInfo class for KiCad panels.
Common, abstract interface for edit frames.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:161
VTBL_ENTRY const wxString & GetExecutablePath() const
Definition: pgm_base.h:232
static TOOL_ACTION acceleratedGraphics
Definition: actions.h:154
#define PCB_EDIT_FRAME_NAME

References _, ACTIONS::acceleratedGraphics, PCAD2KICAD::Center, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO, EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL, PGM_BASE::GetExecutablePath(), ACTIONS::gridPreset, ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER, KiBitmap(), PCAD2KICAD::Left, Pgm(), PCAD2KICAD::Right, ACTIONS::standardGraphics, UNSCALED_UNITS, and ACTIONS::zoomFitScreen.

◆ ExportBoardToHyperlynx()

bool ExportBoardToHyperlynx ( BOARD aBoard,
const wxFileName &  aPath 
)

Definition at line 591 of file export_hyperlynx.cpp.

592 {
593  HYPERLYNX_EXPORTER exporter;
594  exporter.SetBoard( aBoard );
595  exporter.SetOutputFilename( aPath );
596  return exporter.Run();
597 }
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().