KiCad PCB EDA Suite
footprint_edit_frame.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2015-2016 Wayne Stambaugh <stambaughw@gmail.com>
7  * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software: you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by the
11  * Free Software Foundation, either version 3 of the License, or (at your
12  * option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
28 #include <fctsys.h>
29 #include <kiface_i.h>
30 #include <kiway.h>
31 #include <project.h>
32 #include <kicad_plugin.h>
33 #include <class_drawpanel.h>
34 #include <pcb_draw_panel_gal.h>
35 #include <confirm.h>
36 #include <pcb_edit_frame.h>
37 #include <dialog_helpers.h>
39 #include <msgpanel.h>
40 #include <fp_lib_table.h>
41 #include <bitmaps.h>
43 #include <eda_dockart.h>
44 
45 #include <class_board.h>
46 #include <class_module.h>
47 
48 #include <pcbnew.h>
49 #include <pcbnew_id.h>
50 #include <hotkeys.h>
51 #include <footprint_edit_frame.h>
52 #include <footprint_viewer_frame.h>
54 #include <pcb_layer_widget.h>
55 #include <invoke_pcb_dialog.h>
56 
57 #include <tool/tool_manager.h>
58 #include <tool/common_tools.h>
59 #include <tool/tool_dispatcher.h>
60 #include <tool/zoom_tool.h>
61 
62 #include <footprint_tree_pane.h>
63 #include <widgets/lib_tree.h>
64 #include <fp_lib_table.h>
65 #include <footprint_info_impl.h>
66 
67 #include <widgets/paged_dialog.h>
71 #include <dialog_configure_paths.h>
72 
75 #include "tools/selection_tool.h"
76 #include "tools/edit_tool.h"
77 #include "tools/drawing_tool.h"
78 #include "tools/point_editor.h"
79 #include "tools/pcbnew_control.h"
81 #include "tools/placement_tool.h"
82 #include "tools/picker_tool.h"
83 #include "tools/pad_tool.h"
84 #include "tools/pcb_actions.h"
85 
86 
87 BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
89  PCB_BASE_FRAME::ProcessItemSelection )
90  EVT_CLOSE( FOOTPRINT_EDIT_FRAME::OnCloseWindow )
91  EVT_MENU( wxID_EXIT, FOOTPRINT_EDIT_FRAME::CloseModuleEditor )
92 
93  EVT_SIZE( FOOTPRINT_EDIT_FRAME::OnSize )
94 
95  EVT_COMBOBOX( ID_ON_ZOOM_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectZoom )
96  EVT_COMBOBOX( ID_ON_GRID_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectGrid )
97 
98  EVT_TOOL( ID_MODEDIT_SAVE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
99  EVT_TOOL( ID_MODEDIT_SAVE_AS, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
100  EVT_TOOL( ID_MODEDIT_REVERT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
101  EVT_TOOL( ID_OPEN_MODULE_VIEWER, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
102  EVT_TOOL( ID_MODEDIT_SAVE_PNG, FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng )
103 
104  EVT_TOOL( ID_MODEDIT_CUT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
105  EVT_TOOL( ID_MODEDIT_COPY_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
106  EVT_TOOL( ID_MODEDIT_PASTE_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
107  EVT_TOOL( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
108  EVT_TOOL( ID_MODEDIT_NEW_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
110  EVT_TOOL( ID_MODEDIT_IMPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
111  EVT_TOOL( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
112  EVT_TOOL( ID_MODEDIT_CREATE_NEW_LIB, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
113  EVT_TOOL( ID_MODEDIT_ADD_LIBRARY, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
114  EVT_TOOL( ID_MODEDIT_SHEET_SET, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
115  EVT_TOOL( ID_GEN_IMPORT_GRAPHICS_FILE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
116  EVT_TOOL( wxID_PRINT, FOOTPRINT_EDIT_FRAME::ToPrinter )
117  EVT_TOOL( ID_MODEDIT_EDIT_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
118  EVT_TOOL( ID_MODEDIT_CHECK, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
119  EVT_TOOL( ID_MODEDIT_PAD_SETTINGS, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
123  EVT_TOOL( wxID_UNDO, FOOTPRINT_EDIT_FRAME::RestoreCopyFromUndoList )
124  EVT_TOOL( wxID_REDO, FOOTPRINT_EDIT_FRAME::RestoreCopyFromRedoList )
125 
126  // Vertical tool bar button click event handler.
127  EVT_TOOL( ID_NO_TOOL_SELECTED, FOOTPRINT_EDIT_FRAME::OnVerticalToolbar )
128  EVT_TOOL( ID_ZOOM_SELECTION, FOOTPRINT_EDIT_FRAME::OnVerticalToolbar )
130  FOOTPRINT_EDIT_FRAME::OnVerticalToolbar )
131 
132  // Options Toolbar
133  // ID_TB_OPTIONS_SHOW_PADS_SKETCH id is managed in PCB_BASE_FRAME
134  // ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH id is managed in PCB_BASE_FRAME
135  // ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH id is managed in PCB_BASE_FRAME
138 
139  // Preferences and option menus
141  FOOTPRINT_EDIT_FRAME::ProcessPreferences )
143  FOOTPRINT_EDIT_FRAME::ProcessPreferences )
144  EVT_MENU( wxID_PREFERENCES,
145  FOOTPRINT_EDIT_FRAME::ProcessPreferences )
147 
148  // popup commands
150  FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
151 
153  FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
154 
156  FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
158  FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
160  FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
161 
162  // Module transformations
163  EVT_MENU( ID_MODEDIT_MODULE_ROTATE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
164  EVT_MENU( ID_MODEDIT_MODULE_MIRROR, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
165  EVT_MENU( ID_MODEDIT_MODULE_MOVE_EXACT, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
166 
168 
169  // Menu Help
170  EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
171  EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp )
172  EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
173  EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout )
174 
175  // Menu 3D Frame
177 
178  // Switching canvases
182 
183  // UI update events.
184  EVT_UPDATE_UI( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::OnUpdateSaveAs )
185  EVT_UPDATE_UI( ID_MODEDIT_SAVE, FOOTPRINT_EDIT_FRAME::OnUpdateSave )
186  EVT_UPDATE_UI( ID_MODEDIT_SAVE_AS, FOOTPRINT_EDIT_FRAME::OnUpdateSaveAs )
187  EVT_UPDATE_UI( ID_MODEDIT_REVERT_PART, FOOTPRINT_EDIT_FRAME::OnUpdateSave )
188  EVT_UPDATE_UI( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleTargeted )
189  EVT_UPDATE_UI( ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
190  FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard )
191  EVT_UPDATE_UI( ID_MODEDIT_INSERT_MODULE_IN_BOARD,
192  FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard )
193  EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, FOOTPRINT_EDIT_FRAME::OnUpdateSelectTool )
194  EVT_UPDATE_UI( ID_ZOOM_SELECTION, FOOTPRINT_EDIT_FRAME::OnUpdateSelectTool )
195 
196  EVT_UPDATE_UI_RANGE( ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL,
197  FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar )
198 
199  EVT_UPDATE_UI( ID_MODEDIT_EDIT_MODULE_PROPERTIES, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
200  EVT_UPDATE_UI( ID_MODEDIT_PAD_SETTINGS, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
201 
202  // Option toolbar:
203  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
204  FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar )
205  EVT_UPDATE_UI( ID_MODEDIT_SHOW_HIDE_SEARCH_TREE,
206  FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar )
207 
208  EVT_UPDATE_UI( ID_GEN_IMPORT_GRAPHICS_FILE, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
209 
210 END_EVENT_TABLE()
211 
212 
213 FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
214  EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend ) :
215  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_MODULE_EDITOR, wxEmptyString,
216  wxDefaultPosition, wxDefaultSize,
217  KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() )
218 {
219  m_showBorderAndTitleBlock = false; // true to show the frame references
220  m_showAxis = true; // true to show X and Y axis on screen
221  m_showGridAxis = true; // show the grid origin axis
222  m_hotkeysDescrList = g_Module_Editor_Hotkeys_Descr;
223  m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
224 
225  // Give an icon
226  wxIcon icon;
227  icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
228  SetIcon( icon );
229 
230  // Create GAL canvas
231  PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
232  GetGalDisplayOptions(), aBackend );
233  SetGalCanvas( drawPanel );
234 
235  SetBoard( new BOARD() );
236  // In modedit, the default net clearance is not known.
237  // (it depends on the actual board)
238  // So we do not show the default clearance, by setting it to 0
239  // The footprint or pad specific clearance will be shown
240  GetBoard()->GetDesignSettings().GetDefault()->SetClearance( 0 );
241 
242  // Don't show the default board solder mask clearance in the footprint editor. Only the
243  // footprint or pad clearance setting should be shown if it is not 0.
245 
246  // restore the last footprint from the project, if any
247  restoreLastFootprint();
248 
249  // Ensure all layers and items are visible:
250  // In footprint editor, some layers have no meaning or
251  // cannot be used, but we show all of them, at least to be able
252  // to edit a bad layer
254 
255  // However the "no net" mark on pads is useless, because there is
256  // no net in footprint editor: make it non visible
258 
259  m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), true );
260 
261  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
262  // initialize parameters in m_LayersManager
263  LoadSettings( config() );
264  GetGalDisplayOptions().m_axesEnabled = true;
265 
266  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
267  GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
268  GetScreen()->SetCurItem( NULL );
269 
270  GetScreen()->AddGrid( m_UserGridSize, EDA_UNITS_T::UNSCALED_UNITS, ID_POPUP_GRID_USER );
271  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
272 
273  // In modedit, set the default paper size to A4:
274  // this should be OK for all footprint to plot/print
275  SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
276 
277  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
278 
279  initLibraryTree();
280  m_treePane = new FOOTPRINT_TREE_PANE( this );
281 
282  // ReCreateMenuBar(); // UseGalCanvas() will do this for us.
283  ReCreateHToolbar();
284  ReCreateVToolbar();
285  ReCreateOptToolbar();
286 
287  m_Layers->ReFill();
288  m_Layers->ReFillRender();
289 
290  GetScreen()->m_Active_Layer = F_SilkS;
291  m_Layers->SelectLayer( F_SilkS );
292  m_Layers->OnLayerSelected();
293 
294  if( m_canvas )
295  m_canvas->SetEnableBlockCommands( true );
296 
297  m_auimgr.SetManagedWindow( this );
298  m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
299 
300  // Horizontal items; layers 4 - 6
301  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
302  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
303 
304  // Vertical items; layers 1 - 3
305  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
306  m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" ).Left().Layer(1)
307  .Caption( _( "Libraries" ) ).MinSize( 250, 400 ) );
308 
309  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
310  m_auimgr.AddPane( m_Layers, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
311  .Caption( _( "Layers Manager" ) ).PaneBorder( false )
312  .MinSize( 80, -1 ).BestSize( m_Layers->GetBestSize() ) );
313 
314  m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
315  m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrameGal" ).Center().Hide() );
316 
317  // Create the manager and dispatcher & route draw panel events to the dispatcher
318  setupTools();
319  GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
320  UseGalCanvas( aBackend != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
321 
322  m_auimgr.Update();
323  updateTitle();
324 
325  Raise(); // On some window managers, this is needed
326  Show( true );
327 
328  Zoom_Automatique( false );
329 }
330 
331 
333 {
334  // save the footprint in the PROJECT
336 
337  delete m_Layers;
338 }
339 
340 
341 
342 void FOOTPRINT_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
343 {
344  // switches currently used canvas (default / Cairo / OpenGL).
346 
347  // The base class method *does not reinit* the layers manager.
348  // We must upate the layer widget to match board visibility states,
349  // both layers and render columns, and and some settings dependent on the canvas.
351 }
352 
353 
354 void FOOTPRINT_EDIT_FRAME::OnToggleSearchTree( wxCommandEvent& event )
355 {
356  auto& treePane = m_auimgr.GetPane( m_treePane );
357  treePane.Show( !IsSearchTreeShown() );
358  m_auimgr.Update();
359 }
360 
361 
363 {
364  return m_auimgr.GetPane( m_treePane ).IsShown();
365 }
366 
367 
369 {
370  return GetBoard()->m_Modules;
371 }
372 
373 
375 {
377  wxString nickname = id.GetLibNickname();
378 
379  if( nickname.IsEmpty() )
380  return GetLoadedFPID();
381 
382  return id;
383 }
384 
385 
387 {
388  MODULE* module = GetBoard()->m_Modules;
389 
390  if( module )
392  else
393  return LIB_ID();
394 }
395 
396 
398 {
399  MODULE* module = GetBoard()->m_Modules;
400 
401  return ( module && module->GetLink() > 0 );
402 }
403 
404 
406 {
407  LIB_ID id = GetLoadedFPID();
408 
409  if( id.IsValid() )
410  {
411  Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_NICKNAME, id.GetLibNickname() );
412  Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FPNAME, id.GetLibItemName() );
413  }
414 }
415 
416 
418 {
419  const wxString& curFootprintName = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FPNAME );
420  const wxString& curNickname = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_NICKNAME );
421 
422  if( curNickname.Length() && curFootprintName.Length() )
423  {
424  LIB_ID id;
425  id.SetLibNickname( curNickname );
426  id.SetLibItemName( curFootprintName );
427 
428  MODULE* module = loadFootprint( id );
429 
430  if( module )
431  AddModuleToBoard( module );
432  }
433 }
434 
435 
437 {
438  m_revertModule.reset( (MODULE*) aFootprint->Clone() );
439 
441 
442  // Pads are always editable in Footprint Editor
443  aFootprint->SetPadsLocked( false );
444 
446 }
447 
448 
450 {
452 }
453 
454 
456 {
457  return GetBoard()->GetDesignSettings();
458 }
459 
460 
462 {
463  GetBoard()->SetDesignSettings( aSettings );
464 }
465 
466 
468 {
469  // get the settings from the parent editor, not our BOARD.
470 
471  // @todo(DICK) change the routing to some default or the board directly, parent may not exist
472  PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) Kiway().Player( FRAME_PCB, true );
473  wxASSERT( parentFrame );
474 
475  return parentFrame->GetPlotSettings();
476 }
477 
478 
480 {
481  // set the settings into parent editor, not our BOARD.
482 
483  // @todo(DICK) change the routing to some default or the board directly, parent may not exist
484  PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) Kiway().Player( FRAME_PCB, true );
485  wxASSERT( parentFrame );
486 
487  parentFrame->SetPlotSettings( aSettings );
488 }
489 
490 
491 void FOOTPRINT_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
492 {
495 
496  m_configSettings.Load( aCfg ); // mainly, load the color config
497 
498  // Ensure some params are valid
500 
501  // Usually, graphic items are drawn on F_SilkS or F_Fab layer
502  // Force these layers if not default
503  if( ( settings.m_RefDefaultlayer != F_SilkS ) && ( settings.m_RefDefaultlayer != F_Fab ) )
504  settings.m_RefDefaultlayer = F_SilkS;
505 
506  if( ( settings.m_ValueDefaultlayer != F_SilkS ) && ( settings.m_ValueDefaultlayer != F_Fab ) )
507  settings.m_ValueDefaultlayer = F_Fab;
508 }
509 
510 
511 void FOOTPRINT_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
512 {
513  m_configSettings.Save( aCfg );
514 
517 }
518 
519 
521 {
522  EDA_RECT ibbbox = GetBoardBoundingBox();
523 
524  double sizeX = (double) ibbbox.GetWidth();
525  double sizeY = (double) ibbbox.GetHeight();
526 
527  wxPoint centre = ibbbox.Centre();
528 
529  // Reserve a 20% margin around "board" bounding box.
530  double margin_scale_factor = 1.2;
531  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
532 }
533 
534 
535 void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
536 {
537  if( GetScreen()->IsModify() && GetBoard()->m_Modules )
538  {
539  if( !HandleUnsavedChanges( this, _( "Save changes to footprint before closing?" ),
540  [&]()->bool { return SaveFootprint( GetBoard()->m_Modules ); } ) )
541  {
542  Event.Veto();
543  return;
544  }
545  }
546 
547  if( IsGalCanvasActive() )
548  {
549  GetGalCanvas()->SetEventDispatcher( NULL );
551  }
552 
553  // Do not show the layer manager during closing to avoid flicker
554  // on some platforms (Windows) that generate useless redraw of items in
555  // the Layer Manger
556  m_auimgr.GetPane( "LayersManager" ).Show( false );
557 
558  Clear_Pcb( false );
559 
560  //close the editor
561  Destroy();
562 }
563 
564 
565 void FOOTPRINT_EDIT_FRAME::CloseModuleEditor( wxCommandEvent& Event )
566 {
567  Close();
568 }
569 
570 
571 void FOOTPRINT_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
572 {
573  if( aEvent.GetEventObject() == m_drawToolBar || aEvent.GetEventObject() == m_mainToolBar )
574  aEvent.Check( GetToolId() == aEvent.GetId() );
575 }
576 
577 
578 void FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
579 {
580  aEvent.Enable( GetBoard()->m_Modules != NULL );
581 
582  if( aEvent.GetEventObject() == m_drawToolBar )
583  aEvent.Check( GetToolId() == aEvent.GetId() );
584 }
585 
586 
587 void FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar( wxUpdateUIEvent& aEvent )
588 {
589  int id = aEvent.GetId();
590  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
591 
592  bool state = false;
593 
594  switch( id )
595  {
597  state = displ_opts->m_ContrastModeDisplay;
598  break;
599 
601  state = IsSearchTreeShown();
602  break;
603 
604  default:
605  wxMessageBox( "FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar error" );
606  break;
607  }
608 
609  aEvent.Check( state );
610 }
611 
612 
613 void FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent )
614 {
615  aEvent.Enable( GetBoard()->m_Modules != NULL );
616 }
617 
618 
619 void FOOTPRINT_EDIT_FRAME::OnUpdateModuleTargeted( wxUpdateUIEvent& aEvent )
620 {
621  aEvent.Enable( getTargetFPID().IsValid() );
622 }
623 
624 
625 void FOOTPRINT_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
626 {
627  aEvent.Enable( GetBoard()->m_Modules && GetScreen()->IsModify() );
628 }
629 
630 
631 void FOOTPRINT_EDIT_FRAME::OnUpdateSaveAs( wxUpdateUIEvent& aEvent )
632 {
633  LIB_ID libId = getTargetFPID();
634  const wxString& libName = libId.GetLibNickname();
635  const wxString& partName = libId.GetLibItemName();
636 
637  aEvent.Enable( !libName.IsEmpty() || !partName.IsEmpty() );
638 }
639 
640 
642 {
643  PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
644 
645  aEvent.Enable( frame && frame->GetBoard()->m_Modules != NULL );
646 }
647 
648 
650 {
651  PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
652 
653  MODULE* module_in_edit = GetBoard()->m_Modules;
654  bool canInsert = frame && module_in_edit && !module_in_edit->GetLink();
655 
656  // If the source was deleted, the module can inserted but not updated in the board.
657  if( frame && module_in_edit && module_in_edit->GetLink() ) // this is not a new module
658  {
659  BOARD* mainpcb = frame->GetBoard();
660  MODULE* source_module = mainpcb->m_Modules;
661 
662  // search if the source module was not deleted:
663  for( ; source_module != NULL; source_module = source_module->Next() )
664  {
665  if( module_in_edit->GetLink() == source_module->GetTimeStamp() )
666  break;
667  }
668 
669  canInsert = ( source_module == NULL );
670  }
671 
672  aEvent.Enable( canInsert );
673 }
674 
675 
677 {
678 
679  m_Layers->Freeze();
680  m_Layers->ReFill();
681  m_Layers->Thaw();
682 
683  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_Layers );
684 
685  wxSize bestz = m_Layers->GetBestSize();
686 
687  lyrs.MinSize( bestz );
688  lyrs.BestSize( bestz );
689  lyrs.FloatingSize( bestz );
690 
691  if( lyrs.IsDocked() )
692  m_auimgr.Update();
693  else
694  m_Layers->SetSize( bestz );
695 }
696 
697 
699 {
700  // call my base class
702 
703  // We have 2 panes to update.
704  // For some obscure reason, the AUI manager hides the first modified pane.
705  // So force show panes
706  wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
707  bool tree_shown = tree_pane_info.IsShown();
708  tree_pane_info.Caption( _( "Libraries" ) );
709 
710  wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_Layers );
711  bool lm_shown = lm_pane_info.IsShown();
712  lm_pane_info.Caption( _( "Layers Manager" ) );
713 
714  // update the layer manager
717 
718  // Now restore the visibility:
719  lm_pane_info.Show( lm_shown );
720  tree_pane_info.Show( tree_shown );
721  m_auimgr.Update();
722 }
723 
724 
725 void FOOTPRINT_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
726 {
727  bool forceRecreateIfNotOwner = true;
728  CreateAndShow3D_Frame( forceRecreateIfNotOwner );
729 }
730 
731 
732 bool FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
733 {
734  // Filter out the 'fake' mouse motion after a keyboard movement
735  if( !aHotKey && m_movingCursorWithKeyboard )
736  {
738  return false;
739  }
740 
741  // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
742  // for next cursor position
743  // ( shift or ctrl key down are PAN command with mouse wheel)
744  bool snapToGrid = true;
745 
746  if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
747  snapToGrid = false;
748 
749  wxPoint oldpos = GetCrossHairPosition();
750  wxPoint pos = aPosition;
751  bool keyHandled = GeneralControlKeyMovement( aHotKey, &pos, snapToGrid );
752 
753  SetCrossHairPosition( pos, snapToGrid );
754  RefreshCrossHair( oldpos, aPosition, aDC );
755 
756  if( aHotKey && OnHotKey( aDC, aHotKey, aPosition ) )
757  {
758  keyHandled = true;
759  }
760 
761  UpdateStatusBar();
762 
763  return keyHandled;
764 }
765 
766 
768 {
770  Update3DView();
771  m_treePane->GetLibTree()->Refresh();
772 }
773 
774 
776 {
777  wxString title = _( "Footprint Editor" );
778  LIB_ID fpid = GetLoadedFPID();
779  bool writable = true;
780 
781  if( IsCurrentFPFromBoard() )
782  {
783  title += wxString::Format( wxT( " \u2014 %s [from %s.%s]" ),
784  GetBoard()->m_Modules->GetReference(),
786  }
787  else if( fpid.IsValid() )
788  {
789  try
790  {
791  writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( fpid.GetLibNickname() );
792  }
793  catch( const IO_ERROR& )
794  {
795  // best efforts...
796  }
797 
798  // Note: don't used GetLoadedFPID(); footprint name may have been edited
799  title += wxString::Format( wxT( " \u2014 %s %s" ),
800  FROM_UTF8( GetBoard()->m_Modules->GetFPID().Format().c_str() ),
801  writable ? wxString( wxEmptyString ) : _( "[Read Only]" ) );
802  }
803  else if( !fpid.GetLibItemName().empty() )
804  {
805  // Note: don't used GetLoadedFPID(); footprint name may have been edited
806  title += wxString::Format( wxT( " \u2014 %s %s" ),
807  FROM_UTF8( GetBoard()->m_Modules->GetFPID().GetLibItemName().c_str() ),
808  _( "[Unsaved]" ) );
809  }
810 
811  SetTitle( title );
812 }
813 
814 
816 {
817  // Update the layer manager and other widgets from the board setup
818  // (layer and items visibility, colors ...)
819 
820  // Update the layer manager
821  m_Layers->Freeze();
824 
825  // update the layer widget to match board visibility states.
827  static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( m_Pcb );
830 
831  m_Layers->Thaw();
832 }
833 
834 
836 {
837  auto dp = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
838  dp->UseColorScheme( &Settings().Colors() );
839  dp->DisplayBoard( GetBoard() );
842  updateTitle();
843 }
844 
845 
847 {
848  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
849 
850  WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
851  GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
852  progressReporter.Show( false );
853 
856 
858  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
859 
860  adapter->AddLibraries();
861 }
862 
863 
865 {
866  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
867  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
868  LIB_ID target = getTargetFPID();
869  bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
870 
871  // Sync FOOTPRINT_INFO list to the libraries on disk
872  if( aProgress )
873  {
874  WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
875  GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
876  progressReporter.Show( false );
877  }
878  else
879  {
880  GFootprintList.ReadFootprintFiles( fpTable, NULL, NULL );
881  }
882 
883  // Sync the LIB_TREE to the FOOTPRINT_INFO list
884  adapter->Sync();
885 
888 
889  if( target.IsValid() )
890  {
891  if( adapter->FindItem( target ) )
892  {
893  if( targetSelected )
894  m_treePane->GetLibTree()->SelectLibId( target );
895  else
896  m_treePane->GetLibTree()->CenterLibId( target );
897  }
898  else
899  {
900  // Try to focus on parent
901  target.SetLibItemName( wxEmptyString );
902  m_treePane->GetLibTree()->CenterLibId( target );
903  }
904  }
905 }
906 
907 
909 {
910  return IsElementVisible( LAYER_GRID );
911 }
912 
913 
915 {
916  SetElementVisibility( LAYER_GRID, aVisible );
917 }
918 
919 
921 {
922  return GetBoard()->IsElementVisible( aElement );
923 }
924 
925 
927 {
928  GetGalCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
929  GetBoard()->SetElementVisibility( aElement, aNewState );
930  m_Layers->SetRenderState( aElement, aNewState );
931 }
932 
933 
935 {
937 }
938 
939 
940 void FOOTPRINT_EDIT_FRAME::ProcessPreferences( wxCommandEvent& event )
941 {
942  int id = event.GetId();
943 
944  switch( id )
945  {
946  // Hotkey IDs
948  // Display current hotkey list for the footprint editor.
950  break;
951 
953  InvokePcbLibTableEditor( &Kiway(), this );
954  break;
955 
956  case wxID_PREFERENCES:
958  wxT( "pcbnew" ) );
959  break;
960 
961  default:
962  DisplayError( this, "FOOTPRINT_EDIT_FRAME::ProcessPreferences error" );
963  }
964 }
965 
966 
968 {
969  wxTreebook* book = aParent->GetTreebook();
970 
971  book->AddPage( new PANEL_MODEDIT_SETTINGS( this, aParent ), _( "Footprint Editor" ) );
972  book->AddSubPage( new PANEL_MODEDIT_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
973  book->AddSubPage( new PANEL_MODEDIT_DEFAULTS( this, aParent ), _( "Default Values" ) );
974 }
975 
976 
977 void FOOTPRINT_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
978 {
979  DIALOG_CONFIGURE_PATHS dlg( this, Prj().Get3DCacheManager()->GetResolver() );
980  dlg.ShowModal();
981 }
982 
983 
985 {
986  PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
987 
988  // Create the manager and dispatcher & route draw panel events to the dispatcher
990  m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
991  drawPanel->GetViewControls(), this );
992  m_actions = new PCB_ACTIONS();
994 
995  drawPanel->SetEventDispatcher( m_toolDispatcher );
996 
1009 
1010  m_toolManager->GetTool<PAD_TOOL>()->SetEditModules( true );
1011  m_toolManager->GetTool<SELECTION_TOOL>()->SetEditModules( true );
1012  m_toolManager->GetTool<EDIT_TOOL>()->SetEditModules( true );
1013  m_toolManager->GetTool<DRAWING_TOOL>()->SetEditModules( true );
1014 
1016 
1017  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
1018 }
1019 
1020 
1022 {
1024 
1025  if( aEnable )
1026  {
1027  // Be sure the axis are enabled:
1028  GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
1029  updateView();
1030  }
1031 
1032  ReCreateMenuBar();
1033 
1034  // Ensure the m_Layers settings are using the canvas type:
1036 }
1037 
1038 
1040 {
1042 
1043  Layout();
1044  SendSizeEvent();
1045 }
1046 
1047 
1049 {
1050  // If a item is currently selected, displays the item info.
1051  // If nothing selected, display the current footprint info
1052  BOARD_ITEM* item = GetScreen()->GetCurItem();
1053 
1054  if( !item )
1055  item = GetBoard()->m_Modules;
1056 
1057  MSG_PANEL_ITEMS items;
1058 
1059  if( item )
1060  {
1061  item->GetMsgPanelInfo( m_UserUnits, items );
1062  SetMsgPanel( items );
1063  }
1064  else
1065  ClearMsgPanel();
1066 }
1067 
1068 
1069 void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
1070 {
1071  wxString fullFileName;
1072 
1073  LIB_ID id = GetLoadedFPID();
1074 
1075  if( id.empty() )
1076  {
1077  wxMessageBox( _( "No footprint selected." ) );
1078  return;
1079  }
1080 
1081  wxFileName fn( id.GetLibItemName() );
1082  fn.SetExt( "png" );
1083 
1084  wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
1085 
1086  wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
1087  fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1088 
1089  if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
1090  return;
1091 
1092  // calling wxYield is mandatory under Linux, after closing the file selector dialog
1093  // to refresh the screen before creating the PNG or JPEG image from screen
1094  wxYield();
1095  saveCanvasImageToFile( dlg.GetPath() );
1096 }
void OnUpdateVerticalToolbar(wxUpdateUIEvent &aEvent)
Handle most of tools og the vertical right toolbar ("Tools" toolbar)
timestamp_t GetLink() const
Definition: class_module.h:576
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:125
bool IsValid() const
Definition: lib_id.h:171
Class POSITION_RELATIVE_TOOL.
int m_SolderMaskMargin
Solder mask margin.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Function HandleUnsavedChanges displays a dialog with Save, Cancel and Discard Changes buttons...
Definition: confirm.cpp:213
bool IsFootprintLibWritable(const wxString &aNickname)
Function IsFootprintLibWritable.
SCH_EDIT_FRAME::OnSelectTool SCH_EDIT_FRAME::OnEditItem ID_POPUP_GENERAL_END_RANGE
show a marker on pads with no nets
virtual void ShowChangedLanguage() override
Function ShowChangedLanguage redraws the menus and what not in current language.
void OnConfigurePaths(wxCommandEvent &aEvent)
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions EVT_UPDATE_UI(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard) EVT_UPDATE_UI(ID_MODEDIT_INSERT_MODULE_IN_BOARD
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
NETCLASSPTR GetDefault() const
Function GetDefault.
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
void OnUpdateLayerAlpha(wxUpdateUIEvent &aEvent) override
>
BOARD_DESIGN_SETTINGS & GetDesignSettings() const override
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
virtual void AddModuleToBoard(MODULE *module)
Adds the given module to the board.
Model changes (required full reload)
Definition: tool_base.h:83
This file is part of the common library.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
TOOL_DISPATCHER * m_toolDispatcher
Definition: draw_frame.h:126
void Load(wxConfigBase *aCfg) override
Class PCB_LAYER_WIDGET is here to implement the abstract functions of LAYER_WIDGET so they may be tie...
double bestZoom(double sizeX, double sizeY, double scaleFactor, wxPoint centre)
Class SELECTION_TOOL.
struct EDA_HOTKEY_CONFIG g_Module_Editor_Hotkeys_Descr[]
virtual void OnSwitchCanvas(wxCommandEvent &aEvent) override
switches currently used canvas (default / Cairo / OpenGL).
Class BOARD to handle a board.
void initLibraryTree()
Make sure the footprint info list is loaded (with a progress dialog) and then initialize the footprin...
MODULE * Next() const
Definition: class_module.h:122
void InstallPreferences(PAGED_DIALOG *aParent) override
Allows Modedit to install its preferences panel into the preferences dialog.
void DisplayErrors(wxTopLevelWindow *aCaller=NULL)
PCB_LAYER_WIDGET * m_Layers
the layer manager
void OnCloseWindow(wxCloseEvent &Event) override
Class PAD_TOOL.
Definition: pad_tool.h:37
int GetHeight() const
Definition: eda_rect.h:118
static TOOL_ACTION zoomFitScreen
Definition: actions.h:56
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
virtual void SetGridVisibility(bool aVisible) override
It may be overloaded by derived classes if you want to store/retrieve the grid visibility in configur...
BOARD * GetBoard() const
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility, colors ...)
void SetVisibleAlls()
Function SetVisibleAlls changes the bit-mask of visible element categories and layers.
bool OnLayerSelected()
Function OnLayerSelected ensure the active layer is visible, and other layers not visible when m_alwa...
int m_ValueDefaultlayer
Default value text layer on fp creation.
wxAuiManager m_auimgr
void OnToggleSearchTree(wxCommandEvent &event)
void CommonSettingsChanged() override
Called after the preferences dialog is run.
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
wxSize GetBestSize() const
Function GetBestSize returns the preferred minimum size, taking into consideration the dynamic conten...
void OnUpdateLoadModuleFromBoard(wxUpdateUIEvent &aEvent)
The base class for create windows for drawing purpose.
Definition: draw_frame.h:78
struct EDA_HOTKEY_CONFIG g_Pcbnew_Editor_Hotkeys_Descr[]
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar FOOTPRINT_EDIT_FRAME::ProcessPreferences ID_POPUP_PCB_END_RANGE
Definition of class FOOTPRINT_EDIT_FRAME.
virtual void OnSwitchCanvas(wxCommandEvent &aEvent)
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
virtual const PCB_PLOT_PARAMS & GetPlotSettings() const
Function GetPlotSettings returns the PCB_PLOT_PARAMS for the BOARD owned by this frame.
void SetLayersManagerTabsText()
Function SetLayersManagerTabsText Update the layer manager tabs labels Useful when changing Language ...
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
Pcbnew hotkeys.
void UseGalCanvas(bool aEnable) override
>
Class PCBNEW_CONTROL.
Generic tool for picking a point.
Definition: picker_tool.h:34
bool saveCanvasImageToFile(const wxString &aFileName, wxBitmapType aBitmapType=wxBITMAP_TYPE_PNG)
virtual void UseGalCanvas(bool aEnable) override
>
bool GeneralControlKeyMovement(int aHotKey, wxPoint *aPos, bool aSnapToGrid)
Handle the common part of GeneralControl dedicated to global cursor keys (i.e.
void InvokePcbLibTableEditor(KIWAY *aKiway, wxWindow *aCaller)
Function InvokePcbLibTableEditor shows the modal DIALOG_FP_LIB_TABLE for purposes of editing the glob...
wxTreebook * GetTreebook()
Definition: paged_dialog.h:43
void OnUpdateModuleTargeted(wxUpdateUIEvent &aEvent)
FOOTPRINT_LIST_IMPL GFootprintList
The global footprint info table.
Definition: pcbnew.cpp:338
const LIB_ID & GetFPID() const
Definition: class_module.h:192
bool IsElementVisible(GAL_LAYER_ID aElement) const
Test whether a given element category is visible.
Class TOOL_MANAGER.
Definition: tool_manager.h:49
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
void ReCreateMenuBar() override
(Re)Create the menubar for the module editor frame
void SyncLibraryTree(bool aProgress)
Synchronize the footprint library tree to the current state of the footprint library table...
void DisplayHotkeyList(EDA_BASE_FRAME *aFrame, struct EDA_HOTKEY_CONFIG *aDescList)
Function DisplayHotkeyList Displays the current hotkey list.
std::unique_ptr< MODULE > m_revertModule
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
void OnUpdateOptionsToolbar(wxUpdateUIEvent &aEvent)
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
bool Clear_Pcb(bool aQuery)
Delete all and reinitialize the current board.
Definition: initpcb.cpp:94
void CommonSettingsChanged() override
Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have ...
void Regenerate()
Updates the footprint tree
BOARD_ITEM * GetCurItem() const
Function GetCurItem returns the currently selected BOARD_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: pcb_screen.h:72
virtual bool IsGridVisible() const override
void RefreshCrossHair(const wxPoint &aOldPos, const wxPoint &aEvtPos, wxDC *aDC)
Move and refresh the crosshair after movement and call the mouse capture function.
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
#define FOOTPRINT_EDIT_FRAME_NAME
Definition: draw_frame.h:53
bool empty() const
Definition: utf8.h:108
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void OnModify() override
Must be called after a footprint change in order to set the "modify" flag of the current screen and p...
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, wxWindow *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Class DRAWING_TOOL.
Definition: drawing_tool.h:49
PCB_GENERAL_SETTINGS & Settings()
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard EVT_UPDATE_UI_RANGE(ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL, FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar) EVT_UPDATE_UI(ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit components, if the user selects the component itself rather than picking an individual...
Definition: lib_tree.cpp:144
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
void ReFillRender()
Function ReFillRender rebuilds Render for instance after the config is read.
LIB_ID GetLoadedFPID() const
Return the LIB_ID of the part being edited.
void Show3D_Frame(wxCommandEvent &event) override
Display 3D view of the footprint (module) being edited.
Definition of file extensions used in Kicad.
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:174
Helper dialog and control classes.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:539
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
uint32_t EDA_KEY
Definition: common.h:74
virtual void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings)
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:918
static const wxChar A4[]
Definition: page_info.h:64
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aDesignSettings)
Function SetDesignSettings.
Definition: class_board.h:549
void OnUpdateSelectTool(wxUpdateUIEvent &aEvent)
Handle ID_ZOOM_SELECTION and ID_NO_TOOL_SELECTED tools.
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:410
#define KICAD_DEFAULT_DRAWFRAME_STYLE
void SetPadsLocked(bool aPadsLocked)
Definition: class_module.h:305
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
#define PcbFileExtension
PCB_GENERAL_SETTINGS m_configSettings
EVT_TOOL(ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard) EVT_TOOL(ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT
PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar EVT_TOOL_RANGE(ID_TB_OPTIONS_SHOW_ZONES, ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY, PCB_EDIT_FRAME::OnSelectOptionToolbar) EVT_TOOL(ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR
wxPoint Centre() const
Definition: eda_rect.h:60
void ProcessPreferences(wxCommandEvent &event)
virtual void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList)
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it&#39;s internal state for displ...
Definition: base_struct.h:297
Footprint Editor pane with footprint library tree.
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Class PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board...
void SetAxesEnabled(bool aAxesEnabled)
Enables drawing the axes.
LIB_ID getTargetFPID() const
Return the LIB_ID of the part selected in the footprint or the part being edited. ...
virtual bool CreateAndShow3D_Frame(bool aForceRecreateIfNotOwner)
Shows the 3D view frame.
Class EDIT_TOOL.
Definition: edit_tool.h:59
Specialization of the wxAuiPaneInfo class for KiCad panels.
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:157
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
EVT_MENU_RANGE(ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END, PCB_BASE_FRAME::ProcessItemSelection) EVT_TOOL_RANGE(ID_MODEDIT_PAD_TOOL
const PCB_PLOT_PARAMS & GetPlotSettings() const override
Function GetPlotSettings returns the PCB_PLOT_PARAMS for the BOARD owned by this frame.
int SetLibItemName(const UTF8 &aLibItemName, bool aTestForRev=true)
Override the library item name portion of the LIB_ID to aLibItemName.
Definition: lib_id.cpp:206
void SyncLayerAlphaIndicators()
Function SyncLayerAlphaIndicators updates each "Layer"s alpha indicator to show if the board is curre...
void UseColorScheme(const COLORS_DESIGN_SETTINGS *aSettings)
Function UseColorScheme Applies layer color settings.
Class COMMON_TOOLS.
Definition: common_tools.h:38
Class TOOL_DISPATCHER.
wxString PngFileWildcard()
VTBL_ENTRY void SetRString(RSTRING_T aStringId, const wxString &aString)
Function SetRString stores a "retained string", which is any session and project specific string iden...
Definition: project.cpp:171
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar EVT_MENU(ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, FOOTPRINT_EDIT_FRAME::ProcessPreferences) EVT_MENU(ID_PCB_LIB_TABLE_EDIT
LIB_TREE * GetLibTree() const
bool OnHotKey(wxDC *aDC, int aHotKey, const wxPoint &aPosition, EDA_ITEM *aItem=NULL) override
Handle hot key events.
BOARD * GetBoard()
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:193
ID_MODEDIT_MEASUREMENT_TOOL
double BestZoom() override
Function BestZoom.
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aSettings) override
void OnUpdateSaveAs(wxUpdateUIEvent &aEvent)
void updateTitle()
Updates window title according to getLibNickName().
EDA_RECT GetBoardBoundingBox(bool aBoardEdgesOnly=false) const
Function GetBoardBoundingBox calculates the bounding box containing all board items (or board edge se...
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
VTBL_ENTRY const wxString & GetRString(RSTRING_T aStringId)
Function GetRString returns a "retained string", which is any session and project specific string ide...
Definition: project.cpp:186
virtual void UpdateStatusBar() override
Update the status bar information.
LIB_TREE_MODEL_ADAPTER::PTR m_adapter
Class PCB_ACTIONS.
Definition: pcb_actions.h:42
void SyncLayerVisibilities()
Function SyncLayerVisibilities updates each "Layer" checkbox in this layer widget according to each l...
void wxConfigSaveSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigSaveSetups writes aList of PARAM_CFG_ARRAY elements to save configuration values to ...
void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings) override
Declaration of the eda_3d_viewer class.
Common, abstract interface for edit frames.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void UpdateMsgPanel() override
Redraw the message panel.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:171
Class MODULE_EDITOR_TOOLS.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools...
PARAM_CFG_ARRAY & GetConfigurationSettings()
Return the footprint editor settings list.
DLIST< MODULE > m_Modules
Definition: class_board.h:249
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
bool GeneralControl(wxDC *aDC, const wxPoint &aPosition, EDA_KEY aHotKey=0) override
Perform application specific control using aDC at aPosition in logical units.
void OnUpdateInsertModuleInBoard(wxUpdateUIEvent &aEvent)
int GetToolId() const
Definition: draw_frame.h:516
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
BOARD_ITEM_CONTAINER * GetModel() const override
>
void updateView()
Reloads displayed items and sets view.
bool SaveFootprint(MODULE *aModule)
Save in an existing library a given footprint.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
FOOTPRINT_TREE_PANE * m_treePane
Class POINT_EDITOR.
Definition: point_editor.h:43
static bool empty(const wxTextEntryBase *aCtrl)
int m_RefDefaultlayer
Default ref text layer on fp creation.
unsigned GetErrorCount() const
int GetWidth() const
Definition: eda_rect.h:117
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
bool ReadFootprintFiles(FP_LIB_TABLE *aTable, const wxString *aNickname=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Read all the footprints provided by the combination of aTable and aNickname.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel...
void ShowChangedLanguage() override
Update visible items after a language change.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:925
static PTR Create(FOOTPRINT_EDIT_FRAME *aFrame, FP_LIB_TABLE *aLibs)
void OnUpdateSave(wxUpdateUIEvent &aEvent)
void AddModuleToBoard(MODULE *module) override
Override from PCB_BASE_EDIT_FRAME which adds a module to the editor&#39;s dummy board, NOT to the user&#39;s PCB.
void CloseModuleEditor(wxCommandEvent &Event)
bool ShowPreferences(EDA_HOTKEY_CONFIG *aHotkeys, EDA_HOTKEY_CONFIG *aShowHotkeys, const wxString &aHotkeysNickname)
Module description (excepted pads)
void InitTools()
Function InitTools() Initializes all registered tools.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Set the screen cross hair position to aPosition in logical (drawing) units.
void OnUpdateModuleSelected(wxUpdateUIEvent &aEvent)
Message panel definition file.
void SetRenderState(int aId, bool isSet)
Function SetRenderState sets the state of the checkbox associated with aId within the Render tab grou...
EDA_UNITS_T m_UserUnits
Definition: draw_frame.h:120
ACTIONS * m_actions
Definition: draw_frame.h:127
void wxConfigLoadSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigLoadSetups uses aList of PARAM_CFG_ARRAY elements to load configuration values from ...
void SelectLayer(LAYER_NUM aLayer)
Function SelectLayer changes the row selection in the layer list to aLayer provided.
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:245
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
MODULE * loadFootprint(const LIB_ID &aFootprintId)
Function loadFootprint attempts to load aFootprintId from the footprint library table.
bool m_movingCursorWithKeyboard
One-shot to avoid a recursive mouse event during hotkey movement.
Definition: draw_frame.h:173
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
void ClearMsgPanel(void)
Clear all messages from the message panel.
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
void StopDrawing()
Function StopDrawing() Prevents the GAL canvas from further drawing till it is recreated or StartDraw...
static const wxChar * GetFootprintEditorFrameName()
Function GetFootprintEditorFrameName (static)
timestamp_t GetTimeStamp() const
Definition: base_struct.h:207
bool Update3DView(const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
VTBL_ENTRY const wxString GetProjectName() const
Function GetProjectName returns the short name of the project.
Definition: project.cpp:108
void RegisterTool(TOOL_BASE *aTool)
Function RegisterTool() Adds a tool to the manager set and sets it up.
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferrably centered).
Definition: lib_tree.cpp:168
void OnSaveFootprintAsPng(wxCommandEvent &event)
void Save(wxConfigBase *aCfg) override
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:162
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.