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_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectZoom )
96  EVT_CHOICE( 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_DXF_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 
167  EVT_MENU( ID_PCB_USER_GRID_SETUP, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
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_DXF_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 
224  // Give an icon
225  wxIcon icon;
226  icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
227  SetIcon( icon );
228 
229  // Create GAL canvas
230  PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
231  GetGalDisplayOptions(), aBackend );
232  SetGalCanvas( drawPanel );
233 
234  SetBoard( new BOARD() );
235  // In modedit, the default net clearance is not known.
236  // (it depends on the actual board)
237  // So we do not show the default clearance, by setting it to 0
238  // The footprint or pad specific clearance will be shown
239  GetBoard()->GetDesignSettings().GetDefault()->SetClearance( 0 );
240 
241  // Don't show the default board solder mask clearance in the footprint editor. Only the
242  // footprint or pad clearance setting should be shown if it is not 0.
244 
245  // restore the last footprint from the project, if any
246  restoreLastFootprint();
247 
248  // Ensure all layers and items are visible:
249  // In footprint editor, some layers have no meaning or
250  // cannot be used, but we show all of them, at least to be able
251  // to edit a bad layer
253 
254  // However the "no net" mark on pads is useless, because there is
255  // no net in footprint editor: make it non visible
257 
258  m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), true );
259 
260  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
261  // initialize parameters in m_LayersManager
262  LoadSettings( config() );
263  GetGalDisplayOptions().m_axesEnabled = true;
264 
265  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
266  GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
267  GetScreen()->SetCurItem( NULL );
268 
269  GetScreen()->AddGrid( m_UserGridSize, EDA_UNITS_T::UNSCALED_UNITS, ID_POPUP_GRID_USER );
270  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
271 
272  // In modedit, set the default paper size to A4:
273  // this should be OK for all footprint to plot/print
274  SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
275 
276  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
277 
278  initLibraryTree();
279  m_treePane = new FOOTPRINT_TREE_PANE( this );
280 
281  // ReCreateMenuBar(); // UseGalCanvas() will do this for us.
282  ReCreateHToolbar();
283  ReCreateVToolbar();
284  ReCreateOptToolbar();
285 
286  m_Layers->ReFill();
287  m_Layers->ReFillRender();
288 
289  GetScreen()->m_Active_Layer = F_SilkS;
290  m_Layers->SelectLayer( F_SilkS );
291  m_Layers->OnLayerSelected();
292 
293  if( m_canvas )
294  m_canvas->SetEnableBlockCommands( true );
295 
296  m_auimgr.SetManagedWindow( this );
297  m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
298 
299  // Horizontal items; layers 4 - 6
300  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
301  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
302 
303  // Vertical items; layers 1 - 3
304  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
305  m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" ).Left().Layer(1)
306  .Caption( _( "Libraries" ) ).MinSize( 250, 400 ) );
307 
308  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
309  m_auimgr.AddPane( m_Layers, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
310  .Caption( _( "Layers Manager" ) ).PaneBorder( false )
311  .MinSize( 80, -1 ).BestSize( m_Layers->GetBestSize() ) );
312 
313  m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
314  m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrameGal" ).Center().Hide() );
315 
316  // Create the manager and dispatcher & route draw panel events to the dispatcher
317  setupTools();
318  GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
319  UseGalCanvas( aBackend != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
320 
321  m_auimgr.Update();
322  updateTitle();
323 
324  Raise(); // On some window managers, this is needed
325  Show( true );
326 
327  Zoom_Automatique( false );
328 }
329 
330 
332 {
333  // save the footprint in the PROJECT
335 
336  delete m_Layers;
337 }
338 
339 
340 
341 void FOOTPRINT_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
342 {
343  // switches currently used canvas (default / Cairo / OpenGL).
345 
346  // The base class method *does not reinit* the layers manager.
347  // We must upate the layer widget to match board visibility states,
348  // both layers and render columns, and and some settings dependent on the canvas.
350 }
351 
352 
353 void FOOTPRINT_EDIT_FRAME::OnToggleSearchTree( wxCommandEvent& event )
354 {
355  auto& treePane = m_auimgr.GetPane( m_treePane );
356  treePane.Show( !IsSearchTreeShown() );
357  m_auimgr.Update();
358 }
359 
360 
362 {
363  return m_auimgr.GetPane( m_treePane ).IsShown();
364 }
365 
366 
368 {
369  return GetBoard()->m_Modules;
370 }
371 
372 
374 {
376  wxString nickname = id.GetLibNickname();
377 
378  if( nickname.IsEmpty() )
379  return GetLoadedFPID();
380 
381  return id;
382 }
383 
384 
386 {
387  MODULE* module = GetBoard()->m_Modules;
388 
389  if( module )
391  else
392  return LIB_ID();
393 }
394 
395 
397 {
398  MODULE* module = GetBoard()->m_Modules;
399 
400  return ( module && module->GetLink() > 0 );
401 }
402 
403 
405 {
406  LIB_ID id = GetLoadedFPID();
407 
408  if( id.IsValid() )
409  {
410  Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_NICKNAME, id.GetLibNickname() );
411  Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FPNAME, id.GetLibItemName() );
412  }
413 }
414 
415 
417 {
418  const wxString& curFootprintName = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FPNAME );
419  const wxString& curNickname = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_NICKNAME );
420 
421  if( curNickname.Length() && curFootprintName.Length() )
422  {
423  LIB_ID id;
424  id.SetLibNickname( curNickname );
425  id.SetLibItemName( curFootprintName );
426 
427  MODULE* module = loadFootprint( id );
428 
429  if( module )
430  AddModuleToBoard( module );
431  }
432 }
433 
434 
436 {
437  m_revertModule.reset( (MODULE*) aFootprint->Clone() );
438 
440 
441  // Pads are always editable in Footprint Editor
442  aFootprint->SetPadsLocked( false );
443 
445 }
446 
447 
449 {
451 }
452 
453 
455 {
456  return GetBoard()->GetDesignSettings();
457 }
458 
459 
461 {
462  GetBoard()->SetDesignSettings( aSettings );
463 }
464 
465 
467 {
468  // get the settings from the parent editor, not our BOARD.
469 
470  // @todo(DICK) change the routing to some default or the board directly, parent may not exist
471  PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) Kiway().Player( FRAME_PCB, true );
472  wxASSERT( parentFrame );
473 
474  return parentFrame->GetPlotSettings();
475 }
476 
477 
479 {
480  // set the settings into parent editor, not our BOARD.
481 
482  // @todo(DICK) change the routing to some default or the board directly, parent may not exist
483  PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) Kiway().Player( FRAME_PCB, true );
484  wxASSERT( parentFrame );
485 
486  parentFrame->SetPlotSettings( aSettings );
487 }
488 
489 
490 void FOOTPRINT_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
491 {
494 
495  m_configSettings.Load( aCfg ); // mainly, load the color config
496 
497  // Ensure some params are valid
499 
500  // Usually, graphic items are drawn on F_SilkS or F_Fab layer
501  // Force these layers if not default
502  if( ( settings.m_RefDefaultlayer != F_SilkS ) && ( settings.m_RefDefaultlayer != F_Fab ) )
503  settings.m_RefDefaultlayer = F_SilkS;
504 
505  if( ( settings.m_ValueDefaultlayer != F_SilkS ) && ( settings.m_ValueDefaultlayer != F_Fab ) )
506  settings.m_ValueDefaultlayer = F_Fab;
507 }
508 
509 
510 void FOOTPRINT_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
511 {
512  m_configSettings.Save( aCfg );
513 
516 }
517 
518 
520 {
521  EDA_RECT ibbbox = GetBoardBoundingBox();
522 
523  double sizeX = (double) ibbbox.GetWidth();
524  double sizeY = (double) ibbbox.GetHeight();
525 
526  wxPoint centre = ibbbox.Centre();
527 
528  // Reserve a 20% margin around "board" bounding box.
529  double margin_scale_factor = 1.2;
530  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
531 }
532 
533 
534 void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
535 {
536  if( GetScreen()->IsModify() && GetBoard()->m_Modules )
537  {
538  if( !HandleUnsavedChanges( this, _( "Save changes to footprint before closing?" ),
539  [&]()->bool { return SaveFootprint( GetBoard()->m_Modules ); } ) )
540  {
541  Event.Veto();
542  return;
543  }
544  }
545 
546  if( IsGalCanvasActive() )
547  {
548  GetGalCanvas()->SetEventDispatcher( NULL );
550  }
551 
552  // Do not show the layer manager during closing to avoid flicker
553  // on some platforms (Windows) that generate useless redraw of items in
554  // the Layer Manger
555  m_auimgr.GetPane( "LayersManager" ).Show( false );
556 
557  Clear_Pcb( false );
558 
559  //close the editor
560  Destroy();
561 }
562 
563 
564 void FOOTPRINT_EDIT_FRAME::CloseModuleEditor( wxCommandEvent& Event )
565 {
566  Close();
567 }
568 
569 
570 void FOOTPRINT_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
571 {
572  if( aEvent.GetEventObject() == m_drawToolBar || aEvent.GetEventObject() == m_mainToolBar )
573  aEvent.Check( GetToolId() == aEvent.GetId() );
574 }
575 
576 
577 void FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
578 {
579  aEvent.Enable( GetBoard()->m_Modules != NULL );
580 
581  if( aEvent.GetEventObject() == m_drawToolBar )
582  aEvent.Check( GetToolId() == aEvent.GetId() );
583 }
584 
585 
586 void FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar( wxUpdateUIEvent& aEvent )
587 {
588  int id = aEvent.GetId();
589  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
590 
591  bool state = false;
592 
593  switch( id )
594  {
596  state = displ_opts->m_ContrastModeDisplay;
597  break;
598 
600  state = IsSearchTreeShown();
601  break;
602 
603  default:
604  wxMessageBox( "FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar error" );
605  break;
606  }
607 
608  aEvent.Check( state );
609 }
610 
611 
612 void FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent )
613 {
614  aEvent.Enable( GetBoard()->m_Modules != NULL );
615 }
616 
617 
618 void FOOTPRINT_EDIT_FRAME::OnUpdateModuleTargeted( wxUpdateUIEvent& aEvent )
619 {
620  aEvent.Enable( getTargetFPID().IsValid() );
621 }
622 
623 
624 void FOOTPRINT_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
625 {
626  aEvent.Enable( GetBoard()->m_Modules && GetScreen()->IsModify() );
627 }
628 
629 
630 void FOOTPRINT_EDIT_FRAME::OnUpdateSaveAs( wxUpdateUIEvent& aEvent )
631 {
632  LIB_ID libId = getTargetFPID();
633  const wxString& libName = libId.GetLibNickname();
634  const wxString& partName = libId.GetLibItemName();
635 
636  aEvent.Enable( !libName.IsEmpty() || !partName.IsEmpty() );
637 }
638 
639 
641 {
642  PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
643 
644  aEvent.Enable( frame && frame->GetBoard()->m_Modules != NULL );
645 }
646 
647 
649 {
650  PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
651 
652  MODULE* module_in_edit = GetBoard()->m_Modules;
653  bool canInsert = frame && module_in_edit && !module_in_edit->GetLink();
654 
655  // If the source was deleted, the module can inserted but not updated in the board.
656  if( frame && module_in_edit && module_in_edit->GetLink() ) // this is not a new module
657  {
658  BOARD* mainpcb = frame->GetBoard();
659  MODULE* source_module = mainpcb->m_Modules;
660 
661  // search if the source module was not deleted:
662  for( ; source_module != NULL; source_module = source_module->Next() )
663  {
664  if( module_in_edit->GetLink() == source_module->GetTimeStamp() )
665  break;
666  }
667 
668  canInsert = ( source_module == NULL );
669  }
670 
671  aEvent.Enable( canInsert );
672 }
673 
674 
676 {
677 
678  m_Layers->Freeze();
679  m_Layers->ReFill();
680  m_Layers->Thaw();
681 
682  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_Layers );
683 
684  wxSize bestz = m_Layers->GetBestSize();
685 
686  lyrs.MinSize( bestz );
687  lyrs.BestSize( bestz );
688  lyrs.FloatingSize( bestz );
689 
690  if( lyrs.IsDocked() )
691  m_auimgr.Update();
692  else
693  m_Layers->SetSize( bestz );
694 }
695 
696 
698 {
699  // call my base class
701 
702  // We have 2 panes to update.
703  // For some obscure reason, the AUI manager hides the first modified pane.
704  // So force show panes
705  wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
706  bool tree_shown = tree_pane_info.IsShown();
707  tree_pane_info.Caption( _( "Libraries" ) );
708 
709  wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_Layers );
710  bool lm_shown = lm_pane_info.IsShown();
711  lm_pane_info.Caption( _( "Layers Manager" ) );
712 
713  // update the layer manager
716 
717  // Now restore the visibility:
718  lm_pane_info.Show( lm_shown );
719  tree_pane_info.Show( tree_shown );
720  m_auimgr.Update();
721 }
722 
723 
724 void FOOTPRINT_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
725 {
726  bool forceRecreateIfNotOwner = true;
727  CreateAndShow3D_Frame( forceRecreateIfNotOwner );
728 }
729 
730 
731 bool FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
732 {
733  // Filter out the 'fake' mouse motion after a keyboard movement
734  if( !aHotKey && m_movingCursorWithKeyboard )
735  {
737  return false;
738  }
739 
740  // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
741  // for next cursor position
742  // ( shift or ctrl key down are PAN command with mouse wheel)
743  bool snapToGrid = true;
744 
745  if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
746  snapToGrid = false;
747 
748  wxPoint oldpos = GetCrossHairPosition();
749  wxPoint pos = aPosition;
750  bool keyHandled = GeneralControlKeyMovement( aHotKey, &pos, snapToGrid );
751 
752  SetCrossHairPosition( pos, snapToGrid );
753  RefreshCrossHair( oldpos, aPosition, aDC );
754 
755  if( aHotKey && OnHotKey( aDC, aHotKey, aPosition ) )
756  {
757  keyHandled = true;
758  }
759 
760  UpdateStatusBar();
761 
762  return keyHandled;
763 }
764 
765 
767 {
769  Update3DView();
770  m_treePane->GetLibTree()->Refresh();
771 }
772 
773 
775 {
776  wxString title = _( "Footprint Editor" );
777  LIB_ID fpid = GetLoadedFPID();
778  bool writable = true;
779 
780  if( IsCurrentFPFromBoard() )
781  {
782  title += wxString::Format( wxT( " \u2014 %s [from %s.%s]" ),
783  GetBoard()->m_Modules->GetReference(),
785  }
786  else if( fpid.IsValid() )
787  {
788  try
789  {
790  writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( fpid.GetLibNickname() );
791  }
792  catch( const IO_ERROR& )
793  {
794  // best efforts...
795  }
796 
797  // Note: don't used GetLoadedFPID(); footprint name may have been edited
798  title += wxString::Format( wxT( " \u2014 %s %s" ),
799  FROM_UTF8( GetBoard()->m_Modules->GetFPID().Format().c_str() ),
800  writable ? wxString( wxEmptyString ) : _( "[Read Only]" ) );
801  }
802  else if( !fpid.GetLibItemName().empty() )
803  {
804  // Note: don't used GetLoadedFPID(); footprint name may have been edited
805  title += wxString::Format( wxT( " \u2014 %s %s" ),
806  FROM_UTF8( GetBoard()->m_Modules->GetFPID().GetLibItemName().c_str() ),
807  _( "[Unsaved]" ) );
808  }
809 
810  SetTitle( title );
811 }
812 
813 
815 {
816  // Update the layer manager and other widgets from the board setup
817  // (layer and items visibility, colors ...)
818 
819  // Update the layer manager
820  m_Layers->Freeze();
823 
824  // update the layer widget to match board visibility states.
826  static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( m_Pcb );
829 
830  m_Layers->Thaw();
831 }
832 
833 
835 {
836  auto dp = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
837  dp->UseColorScheme( &Settings().Colors() );
838  dp->DisplayBoard( GetBoard() );
841  updateTitle();
842 }
843 
844 
846 {
847  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
848 
849  WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
850  GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
851  progressReporter.Show( false );
852 
855 
857  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
858 
859  adapter->AddLibraries();
860 }
861 
862 
864 {
865  FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
866  auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
867  LIB_ID target = getTargetFPID();
868  bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
869 
870  // Sync FOOTPRINT_INFO list to the libraries on disk
871  if( aProgress )
872  {
873  WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
874  GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
875  progressReporter.Show( false );
876  }
877  else
878  {
879  GFootprintList.ReadFootprintFiles( fpTable, NULL, NULL );
880  }
881 
882  // Sync the LIB_TREE to the FOOTPRINT_INFO list
883  adapter->Sync();
884 
887 
888  if( target.IsValid() )
889  {
890  if( adapter->FindItem( target ) )
891  {
892  if( targetSelected )
893  m_treePane->GetLibTree()->SelectLibId( target );
894  else
895  m_treePane->GetLibTree()->CenterLibId( target );
896  }
897  else
898  {
899  // Try to focus on parent
900  target.SetLibItemName( wxEmptyString );
901  m_treePane->GetLibTree()->CenterLibId( target );
902  }
903  }
904 }
905 
906 
908 {
909  return IsElementVisible( LAYER_GRID );
910 }
911 
912 
914 {
915  SetElementVisibility( LAYER_GRID, aVisible );
916 }
917 
918 
920 {
921  return GetBoard()->IsElementVisible( aElement );
922 }
923 
924 
926 {
927  GetGalCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
928  GetBoard()->SetElementVisibility( aElement, aNewState );
929  m_Layers->SetRenderState( aElement, aNewState );
930 }
931 
932 
934 {
936 }
937 
938 
939 void FOOTPRINT_EDIT_FRAME::ProcessPreferences( wxCommandEvent& event )
940 {
941  int id = event.GetId();
942 
943  switch( id )
944  {
945  // Hotkey IDs
947  // Display current hotkey list for the footprint editor.
949  break;
950 
952  InvokePcbLibTableEditor( &Kiway(), this );
953  break;
954 
955  case wxID_PREFERENCES:
957  wxT( "pcbnew" ) );
958  break;
959 
960  default:
961  DisplayError( this, "FOOTPRINT_EDIT_FRAME::ProcessPreferences error" );
962  }
963 }
964 
965 
967 {
968  wxTreebook* book = aParent->GetTreebook();
969 
970  book->AddPage( new PANEL_MODEDIT_SETTINGS( this, aParent ), _( "Footprint Editor" ) );
971  book->AddSubPage( new PANEL_MODEDIT_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
972  book->AddSubPage( new PANEL_MODEDIT_DEFAULTS( this, aParent ), _( "Default Values" ) );
973 }
974 
975 
976 void FOOTPRINT_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
977 {
978  DIALOG_CONFIGURE_PATHS dlg( this, Prj().Get3DCacheManager()->GetResolver() );
979  dlg.ShowModal();
980 }
981 
982 
984 {
985  PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
986 
987  // Create the manager and dispatcher & route draw panel events to the dispatcher
989  m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
990  drawPanel->GetViewControls(), this );
991  m_actions = new PCB_ACTIONS();
993 
994  drawPanel->SetEventDispatcher( m_toolDispatcher );
995 
1008 
1009  m_toolManager->GetTool<PAD_TOOL>()->SetEditModules( true );
1010  m_toolManager->GetTool<SELECTION_TOOL>()->SetEditModules( true );
1011  m_toolManager->GetTool<EDIT_TOOL>()->SetEditModules( true );
1012  m_toolManager->GetTool<DRAWING_TOOL>()->SetEditModules( true );
1013 
1015 
1016  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
1017 }
1018 
1019 
1021 {
1023 
1024  if( aEnable )
1025  {
1026  // Be sure the axis are enabled:
1027  GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
1028  updateView();
1029  }
1030 
1031  ReCreateMenuBar();
1032 
1033  // Ensure the m_Layers settings are using the canvas type:
1035 }
1036 
1037 
1039 {
1041 
1042  Layout();
1043  SendSizeEvent();
1044 }
1045 
1046 
1048 {
1049  // If a item is currently selected, displays the item info.
1050  // If nothing selected, display the current footprint info
1051  BOARD_ITEM* item = GetScreen()->GetCurItem();
1052 
1053  if( !item )
1054  item = GetBoard()->m_Modules;
1055 
1056  MSG_PANEL_ITEMS items;
1057 
1058  if( item )
1059  {
1060  item->GetMsgPanelInfo( m_UserUnits, items );
1061  SetMsgPanel( items );
1062  }
1063  else
1064  ClearMsgPanel();
1065 }
1066 
1067 
1068 void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
1069 {
1070  wxString fullFileName;
1071 
1072  LIB_ID id = GetLoadedFPID();
1073 
1074  if( id.empty() )
1075  {
1076  wxMessageBox( _( "No footprint selected." ) );
1077  return;
1078  }
1079 
1080  wxFileName fn( id.GetLibItemName() );
1081  fn.SetExt( "png" );
1082 
1083  wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
1084 
1085  wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
1086  fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1087 
1088  if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
1089  return;
1090 
1091  // calling wxYield is mandatory under Linux, after closing the file selector dialog
1092  // to refresh the screen before creating the PNG or JPEG image from screen
1093  wxYield();
1094  saveCanvasImageToFile( dlg.GetPath() );
1095 }
void OnUpdateVerticalToolbar(wxUpdateUIEvent &aEvent)
Handle most of tools og the vertical right toolbar ("Tools" toolbar)
timestamp_t GetLink() const
Definition: class_module.h:577
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:123
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:193
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.
The common library.
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:538
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:73
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:911
static const wxChar A4[]
Definition: page_info.h:64
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aDesignSettings)
Function SetDesignSettings.
Definition: class_board.h:548
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:306
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:170
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:248
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:519
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:918
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.