KiCad PCB EDA Suite
moduleframe.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-2016 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
32 #include <fctsys.h>
33 #include <pgm_base.h>
34 #include <kiway.h>
35 #include <project.h>
36 #include <kicad_plugin.h>
37 #include <class_drawpanel.h>
38 #include <pcb_draw_panel_gal.h>
39 #include <confirm.h>
40 #include <wxPcbStruct.h>
41 #include <dialog_helpers.h>
43 #include <msgpanel.h>
44 #include <fp_lib_table.h>
45 #include <bitmaps.h>
47 
48 #include <class_board.h>
49 #include <class_module.h>
50 
51 #include <pcbnew.h>
52 #include <pcbnew_id.h>
53 #include <hotkeys.h>
55 #include <dialog_hotkeys_editor.h>
56 #include <module_editor_frame.h>
57 #include <modview_frame.h>
59 #include <class_pcb_layer_widget.h>
60 #include <invoke_pcb_dialog.h>
61 
62 #include <tool/tool_manager.h>
63 #include <tool/common_tools.h>
64 #include <tool/tool_dispatcher.h>
65 #include <tool/zoom_tool.h>
66 
67 #include "tools/selection_tool.h"
68 #include "tools/edit_tool.h"
69 #include "tools/drawing_tool.h"
70 #include "tools/point_editor.h"
71 #include "tools/pcbnew_control.h"
73 #include "tools/placement_tool.h"
74 #include "tools/picker_tool.h"
75 #include "tools/pad_tool.h"
76 #include "tools/pcb_actions.h"
77 
78 
79 BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
81  PCB_BASE_FRAME::ProcessItemSelection )
82  EVT_CLOSE( FOOTPRINT_EDIT_FRAME::OnCloseWindow )
83  EVT_MENU( wxID_EXIT, FOOTPRINT_EDIT_FRAME::CloseModuleEditor )
84 
85  EVT_SIZE( FOOTPRINT_EDIT_FRAME::OnSize )
86 
87  EVT_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectZoom )
88  EVT_CHOICE( ID_ON_GRID_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectGrid )
89 
90  EVT_TOOL( ID_MODEDIT_SELECT_CURRENT_LIB, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
91 
93 
94  EVT_TOOL( ID_MODEDIT_SAVE_LIBMODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
95  EVT_TOOL( ID_OPEN_MODULE_VIEWER, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
96 
97  EVT_TOOL( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
98  EVT_TOOL( ID_MODEDIT_NEW_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
100  EVT_TOOL( ID_MODEDIT_IMPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
101  EVT_TOOL( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
103  FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
104  EVT_TOOL( ID_MODEDIT_SHEET_SET, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
105  EVT_TOOL( ID_GEN_IMPORT_DXF_FILE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
106  EVT_TOOL( wxID_PRINT, FOOTPRINT_EDIT_FRAME::ToPrinter )
107  EVT_TOOL( ID_MODEDIT_LOAD_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
108  EVT_TOOL( ID_MODEDIT_CHECK, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
109  EVT_TOOL( ID_MODEDIT_PAD_SETTINGS, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
114  EVT_TOOL( wxID_UNDO, FOOTPRINT_EDIT_FRAME::RestoreCopyFromUndoList )
115  EVT_TOOL( wxID_REDO, FOOTPRINT_EDIT_FRAME::RestoreCopyFromRedoList )
116 
117  // Vertical tool bar button click event handler.
118  EVT_TOOL( ID_NO_TOOL_SELECTED, FOOTPRINT_EDIT_FRAME::OnVerticalToolbar )
119  EVT_TOOL( ID_ZOOM_SELECTION, FOOTPRINT_EDIT_FRAME::OnVerticalToolbar )
121  FOOTPRINT_EDIT_FRAME::OnVerticalToolbar )
122 
123  // Options Toolbar (ID_TB_OPTIONS_SHOW_PADS_SKETCH id is managed in PCB_BASE_FRAME)
127 
128  // Preferences and option menus
130  FOOTPRINT_EDIT_FRAME::ProcessPreferences )
132  FOOTPRINT_EDIT_FRAME::ProcessPreferences )
134  FOOTPRINT_EDIT_FRAME::ProcessPreferences )
136  FOOTPRINT_EDIT_FRAME::ProcessPreferences )
138  FOOTPRINT_EDIT_FRAME::ProcessPreferences )
140  FOOTPRINT_EDIT_FRAME::ProcessPreferences )
141  EVT_MENU( wxID_PREFERENCES,
142  FOOTPRINT_EDIT_FRAME::ProcessPreferences )
144  FOOTPRINT_EDIT_FRAME::ProcessPreferences )
146 
147  // popup commands
149  FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
150 
152  FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
153 
155  FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
157  FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
159  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_DRAWINGS_WIDTHS_SETUP, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
168  EVT_MENU( ID_PCB_PAD_SETUP, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
169  EVT_MENU( ID_PCB_USER_GRID_SETUP, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
170 
171  // Menu Help
172  EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
173  EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp )
174  EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
175  EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout )
176 
177  // Menu 3D Frame
179 
180  // Switching canvases
184 
185  // UI update events.
186  EVT_UPDATE_UI( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::OnUpdateLibSelected )
187  EVT_UPDATE_UI( ID_MODEDIT_SELECT_CURRENT_LIB, FOOTPRINT_EDIT_FRAME::OnUpdateSelectCurrentLib )
188  EVT_UPDATE_UI( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
189  EVT_UPDATE_UI( ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,
190  FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
191  EVT_UPDATE_UI( ID_MODEDIT_SAVE_LIBMODULE, FOOTPRINT_EDIT_FRAME::OnUpdateLibAndModuleSelected )
192  EVT_UPDATE_UI( ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
193  FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard )
194  EVT_UPDATE_UI( ID_MODEDIT_INSERT_MODULE_IN_BOARD,
195  FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard )
196  EVT_UPDATE_UI( ID_MODEDIT_UPDATE_MODULE_IN_BOARD,
197  FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard )
198  EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, FOOTPRINT_EDIT_FRAME::OnUpdateSelectTool )
199  EVT_UPDATE_UI( ID_ZOOM_SELECTION, FOOTPRINT_EDIT_FRAME::OnUpdateSelectTool )
200 
201  EVT_UPDATE_UI_RANGE( ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL,
202  FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar )
203 
204  // Option toolbar:
205  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH,
206  FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar )
207  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH,
208  FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar )
209  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
210  FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar )
211 
212  EVT_UPDATE_UI( ID_GEN_IMPORT_DXF_FILE,
213  FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
214 
215 END_EVENT_TABLE()
216 
217 #define FOOTPRINT_EDIT_FRAME_NAME wxT( "ModEditFrame" )
218 
219 FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
220  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_MODULE_EDITOR, wxEmptyString,
221  wxDefaultPosition, wxDefaultSize,
222  KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() )
223 {
224  m_showBorderAndTitleBlock = false; // true to show the frame references
225  m_showAxis = true; // true to show X and Y axis on screen
226  m_showGridAxis = true; // show the grid origin axis
227  m_hotkeysDescrList = g_Module_Editor_Hokeys_Descr;
228 
229  // Give an icon
230  wxIcon icon;
231  icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
232  SetIcon( icon );
233 
234  // Show a title (frame title + footprint name):
235  updateTitle();
236 
237  // Create GAL canvas
238  PCB_BASE_FRAME* parentFrame = static_cast<PCB_BASE_FRAME*>( Kiway().Player( FRAME_PCB, true ) );
239  PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
240  GetGalDisplayOptions(),
241  parentFrame->GetGalCanvas()->GetBackend() );
242  SetGalCanvas( drawPanel );
243 
244  SetBoard( new BOARD() );
245  // In modedit, the default net clearance is not known.
246  // (it depends on the actual board)
247  // So we do not show the default clearance, by setting it to 0
248  // The footprint or pad specific clearance will be shown
249  GetBoard()->GetDesignSettings().GetDefault()->SetClearance( 0 );
250 
251  // Don't show the default board solder mask clearance in the footprint editor. Only the
252  // footprint or pad clearance setting should be shown if it is not 0.
254 
255  // restore the last footprint from the project, if any
256  restoreLastFootprint();
257 
258  // Ensure all layers and items are visible:
259  // In footprint editor, some layers have no meaning or
260  // cannot be used, but we show all of them, at least to be able
261  // to edit a bad layer
263 
264  // However the "no net" mark on pads is useless, because there is
265  // no net in footprint editor: make it non visible
267 
268  wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
269  m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), font.GetPointSize(), true );
270 
271  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
272  // initialize parameters in m_LayersManager
273  LoadSettings( config() );
274 
275  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
276  GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
277  GetScreen()->SetCurItem( NULL );
278 
279  GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
280  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
281 
282  // In modedit, set the default paper size to A4:
283  // this should be OK for all footprint to plot/print
284  SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
285 
286  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
287  ReCreateMenuBar();
288  ReCreateHToolbar();
289  ReCreateAuxiliaryToolbar();
290  ReCreateVToolbar();
291  ReCreateOptToolbar();
292 
293  if( m_canvas )
294  m_canvas->SetEnableBlockCommands( true );
295 
296  m_auimgr.SetManagedWindow( this );
297 
298  EDA_PANEINFO horiz;
299  horiz.HorizontalToolbarPane();
300 
301  EDA_PANEINFO vert;
302  vert.VerticalToolbarPane();
303 
304  EDA_PANEINFO mesg_pane;
305  mesg_pane.MessageToolbarPane();
306 
307  // Create a wxAuiPaneInfo for the Layers Manager, not derived from the template.
308  // LAYER_WIDGET is floatable, but initially docked at far right
309  EDA_PANEINFO lyrs;
310  lyrs.LayersToolbarPane();
311  lyrs.MinSize( m_Layers->GetBestSize() ); // updated in ReFillLayerWidget
312  lyrs.BestSize( m_Layers->GetBestSize() );
313  lyrs.Caption( _( "Visibles" ) );
314 
315  m_auimgr.AddPane( m_mainToolBar,
316  wxAuiPaneInfo( horiz ).Name( "m_mainToolBar" ).Top(). Row( 0 ) );
317 
318  m_auimgr.AddPane( m_auxiliaryToolBar,
319  wxAuiPaneInfo( horiz ).Name( "m_auxiliaryToolBar" ).Top().Row( 1 ) );
320 
321  // The main right vertical toolbar
322  m_auimgr.AddPane( m_drawToolBar,
323  wxAuiPaneInfo( vert ).Name( "m_VToolBar" ).Right().Layer(1) );
324 
325  // Add the layer manager ( most right side of pcbframe )
326  m_auimgr.AddPane( m_Layers, lyrs.Name( "m_LayersManagerToolBar" ).Right().Layer( 2 ) );
327  // Layers manager is visible
328  m_auimgr.GetPane( "m_LayersManagerToolBar" ).Show( true );
329 
330  // The left vertical toolbar (fast acces to display options)
331  m_auimgr.AddPane( m_optionsToolBar,
332  wxAuiPaneInfo( vert ).Name( "m_optionsToolBar" ). Left().Layer(1) );
333 
334  m_auimgr.AddPane( m_canvas,
335  wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
336  m_auimgr.AddPane( (wxWindow*) GetGalCanvas(),
337  wxAuiPaneInfo().Name( "DrawFrameGal" ).CentrePane().Hide() );
338 
339  m_auimgr.AddPane( m_messagePanel,
340  wxAuiPaneInfo( mesg_pane ).Name( "MsgPanel" ).Bottom().Layer(10) );
341 
342  // Create the manager and dispatcher & route draw panel events to the dispatcher
343  setupTools();
344  GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
345  UseGalCanvas( parentFrame->IsGalCanvasActive() );
346 
347  if( m_auimgr.GetPane( "m_LayersManagerToolBar" ).IsShown() )
348  {
349  m_Layers->ReFill();
350  m_Layers->ReFillRender();
351 
352  GetScreen()->m_Active_Layer = F_SilkS;
353  m_Layers->SelectLayer( F_SilkS );
354  m_Layers->OnLayerSelected();
355  }
356 
357  m_auimgr.Update();
358 
359  Raise(); // On some window managers, this is needed
360  Show( true );
361 
362  Zoom_Automatique( false );
363 }
364 
365 
367 {
368  // save the footprint in the PROJECT
370 
371  delete m_Layers;
372 }
373 
374 
376 {
377  return GetBoard()->m_Modules;
378 }
379 
380 
382 {
383  try
384  {
385  const wxString& nickname = GetCurrentLib();
386 
387  const FP_LIB_TABLE_ROW* row = Prj().PcbFootprintLibs()->FindRow( nickname );
388 
389  return row->GetFullURI( true );
390  }
391  catch( const IO_ERROR& )
392  {
393  return wxEmptyString;
394  }
395 }
396 
397 
399 {
401 }
402 
403 
405 {
406  PCB_IO pcb_io;
407  MODULE* module = GetBoard()->m_Modules;
408 
409  if( module )
410  {
411  pcb_io.Format( module );
412 
413  wxString pretty = FROM_UTF8( pcb_io.GetStringOutput( true ).c_str() );
414 
415  // save the footprint in the RSTRING facility.
417  }
418 }
419 
420 
422 {
423  wxString pretty = Prj().GetRString( PROJECT::PCB_FOOTPRINT );
424 
425  if( !!pretty )
426  {
427  PCB_IO pcb_io;
428  MODULE* module = NULL;
429 
430  try
431  {
432  module = (MODULE*) pcb_io.Parse( pretty );
433  }
434  catch( const PARSE_ERROR& )
435  {
436  // unlikely to be a problem, since we produced the pretty string.
437  wxLogError( "PARSE_ERROR" );
438  }
439  catch( const IO_ERROR& )
440  {
441  // unlikely to be a problem, since we produced the pretty string.
442  wxLogError( "IO_ERROR" );
443  }
444 
445  if( module )
446  {
447  // assumes BOARD is empty.
448  wxASSERT( GetBoard()->m_Modules == NULL );
449 
450  // no idea, its monkey see monkey do. I would encapsulate this into
451  // a member function if its actually necessary.
452  module->SetParent( GetBoard() );
453  module->SetLink( 0 );
454 
455  GetBoard()->Add( module );
456  }
457  }
458 }
459 
460 
462 {
464 }
465 
466 
468 {
469  return GetBoard()->GetDesignSettings();
470 }
471 
472 
474 {
475  GetBoard()->SetDesignSettings( aSettings );
476 }
477 
478 
480 {
481  // get the settings from the 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  return parentFrame->GetPlotSettings();
488 }
489 
490 
492 {
493  // set the settings into parent editor, not our BOARD.
494 
495  // @todo(DICK) change the routing to some default or the board directly, parent may not exist
496  PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) Kiway().Player( FRAME_PCB, true );
497  wxASSERT( parentFrame );
498 
499  parentFrame->SetPlotSettings( aSettings );
500 }
501 
502 
503 void FOOTPRINT_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
504 {
507 
508  m_configSettings.Load( aCfg ); // mainly, load the color config
509 
510  // Ensure some params are valid
512 
513  // Usually, graphic items are drawn on F_SilkS or F_Fab layer
514  // Force these layers if not default
515  if( ( settings.m_RefDefaultlayer != F_SilkS ) && ( settings.m_RefDefaultlayer != F_Fab ) )
516  settings.m_RefDefaultlayer = F_SilkS;
517 
518  if( ( settings.m_ValueDefaultlayer != F_SilkS ) && ( settings.m_ValueDefaultlayer != F_Fab ) )
519  settings.m_ValueDefaultlayer = F_Fab;
520 }
521 
522 
523 void FOOTPRINT_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
524 {
525  m_configSettings.Save( aCfg );
526 
529 }
530 
531 
532 void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
533 {
534  if( GetScreen()->IsModify() )
535  {
536  int ii = DisplayExitDialog( this, _( "Save the changes to the footprint before closing?" ) );
537 
538  switch( ii )
539  {
540  case wxID_NO:
541  break;
542 
543  case wxID_YES:
544  // code from FOOTPRINT_EDIT_FRAME::Process_Special_Functions,
545  // at case ID_MODEDIT_SAVE_LIBMODULE
546  if( GetBoard()->m_Modules && GetCurrentLib().size() )
547  {
548  if( SaveFootprintInLibrary( GetCurrentLib(), GetBoard()->m_Modules, true, true ) )
549  {
550  // save was correct
551  GetScreen()->ClrModify();
552  break;
553  }
554  }
555  else
556  {
557  DisplayError( this, _( "Library is not set, the footprint could not be saved." ) );
558  }
559  // fall through: cancel the close because of an error
560 
561  case wxID_CANCEL:
562  Event.Veto();
563  return;
564  }
565  }
566 
567  if( IsGalCanvasActive() )
569 
570  //close the editor
571  Destroy();
572 }
573 
574 
575 void FOOTPRINT_EDIT_FRAME::CloseModuleEditor( wxCommandEvent& Event )
576 {
577  Close();
578 }
579 
580 
581 void FOOTPRINT_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
582 {
583  aEvent.Check( GetToolId() == aEvent.GetId() );
584 }
585 
586 
587 void FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
588 {
589  aEvent.Enable( GetBoard()->m_Modules != NULL );
590 
591  if( aEvent.GetEventObject() == m_drawToolBar )
592  aEvent.Check( GetToolId() == aEvent.GetId() );
593 }
594 
595 
596 void FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar( wxUpdateUIEvent& aEvent )
597 {
598  int id = aEvent.GetId();
599  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
600 
601  bool state = false;
602 
603  switch( id )
604  {
605  case ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH:
606  state = displ_opts->m_DisplayModTextFill == SKETCH;
607  break;
608 
609  case ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH:
610  state = displ_opts->m_DisplayModEdgeFill == SKETCH;
611  break;
612 
613  case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
614  state = displ_opts->m_ContrastModeDisplay;
615  break;
616 
617  default:
618  wxMessageBox( "FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar error" );
619  break;
620  }
621 
622  aEvent.Check( state );
623 }
624 
625 
626 void FOOTPRINT_EDIT_FRAME::OnUpdateLibSelected( wxUpdateUIEvent& aEvent )
627 {
628  bool enable = getLibPath() != wxEmptyString;
629  aEvent.Enable( enable );
630  GetMenuBar()->Enable( ID_MODEDIT_SAVE_LIBRARY_AS, enable );
631 }
632 
633 
634 void FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent )
635 {
636  aEvent.Enable( GetBoard()->m_Modules != NULL );
637 }
638 
639 
641 {
642  aEvent.Enable( getLibPath() != wxEmptyString && GetBoard()->m_Modules != NULL );
643 }
644 
645 
647 {
648  PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
649 
650  aEvent.Enable( frame && frame->GetBoard()->m_Modules != NULL );
651 }
652 
653 
655 {
656  PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
657 
658  MODULE* module_in_edit = GetBoard()->m_Modules;
659  bool canInsert = frame && module_in_edit && !module_in_edit->GetLink();
660 
661  // If the source was deleted, the module can inserted but not updated in the board.
662  if( frame && module_in_edit && module_in_edit->GetLink() ) // this is not a new module
663  {
664  BOARD* mainpcb = frame->GetBoard();
665  MODULE* source_module = mainpcb->m_Modules;
666 
667  // search if the source module was not deleted:
668  for( ; source_module != NULL; source_module = source_module->Next() )
669  {
670  if( module_in_edit->GetLink() == source_module->GetTimeStamp() )
671  break;
672  }
673 
674  canInsert = ( source_module == NULL );
675  }
676 
677  aEvent.Enable( canInsert );
678 }
679 
680 
682 {
683  PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
684 
685  MODULE* module_in_edit = GetBoard()->m_Modules;
686  bool canReplace = frame && module_in_edit && module_in_edit->GetLink();
687 
688  if( canReplace ) // this is not a new module, but verify if the source is still on board
689  {
690  BOARD* mainpcb = frame->GetBoard();
691  MODULE* source_module = mainpcb->m_Modules;
692 
693  // search if the source module was not deleted:
694  for( ; source_module != NULL; source_module = source_module->Next() )
695  {
696  if( module_in_edit->GetLink() == source_module->GetTimeStamp() )
697  break;
698  }
699 
700  canReplace = ( source_module != NULL );
701  }
702 
703  aEvent.Enable( canReplace );
704 }
705 
706 
707 void FOOTPRINT_EDIT_FRAME::OnUpdateSelectCurrentLib( wxUpdateUIEvent& aEvent )
708 {
709  FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
710 
711  aEvent.Enable( fptbl && !fptbl->IsEmpty() );
712 }
713 
714 
715 void FOOTPRINT_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
716 {
717  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
718 
719  if( draw3DFrame )
720  {
721  // Raising the window does not show the window on Windows if iconized.
722  // This should work on any platform.
723  if( draw3DFrame->IsIconized() )
724  draw3DFrame->Iconize( false );
725 
726  draw3DFrame->Raise();
727 
728  // Raising the window does not set the focus on Linux. This should work on any platform.
729  if( wxWindow::FindFocus() != draw3DFrame )
730  draw3DFrame->SetFocus();
731 
732  return;
733  }
734 
735  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
736  draw3DFrame->Raise(); // Needed with some Window Managers
737  draw3DFrame->Show( true );
738 }
739 
740 
741 bool FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
742 {
743  // Filter out the 'fake' mouse motion after a keyboard movement
744  if( !aHotKey && m_movingCursorWithKeyboard )
745  {
747  return false;
748  }
749 
750  // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
751  // for next cursor position
752  // ( shift or ctrl key down are PAN command with mouse wheel)
753  bool snapToGrid = true;
754 
755  if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
756  snapToGrid = false;
757 
758  wxPoint oldpos = GetCrossHairPosition();
759  wxPoint pos = aPosition;
760  bool keyHandled = GeneralControlKeyMovement( aHotKey, &pos, snapToGrid );
761 
762  SetCrossHairPosition( pos, snapToGrid );
763  RefreshCrossHair( oldpos, aPosition, aDC );
764 
765  if( aHotKey && OnHotKey( aDC, aHotKey, aPosition ) )
766  {
767  keyHandled = true;
768  }
769 
770  UpdateStatusBar();
771 
772  return keyHandled;
773 }
774 
775 
777 {
779 
780  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
781 
782  if( draw3DFrame )
783  {
784  draw3DFrame->NewDisplay( true );
785  }
786 }
787 
788 
790 {
791  wxString nickname = GetCurrentLib();
792  wxString nickname_display = _( "no active library" );
793  bool writable = true;
794 
795  if( !!nickname )
796  {
797  try
798  {
799  writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( nickname );
800 
801  nickname_display = nickname;
802  }
803  catch( const IO_ERROR& )
804  {
805  // user may be bewildered as to why after selecting a library it is not showing up
806  // in the title, we could show an error message, but that should have been done at time
807  // of libary selection UI.
808  }
809  }
810 
811  wxString path_display;
812  if( nickname.size() )
813  {
814  FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
815  const FP_LIB_TABLE_ROW* row = libtable->FindRow( nickname );
816 
817  if( row )
818  path_display = L" \u2014 " + row->GetFullURI( true );
819  }
820 
821  wxString title;
822  title.Printf( _( "Footprint Editor" ) + L" \u2014 %s%s%s",
823  nickname_display,
824  writable ? wxString( wxEmptyString ) : _( " [Read Only]" ),
825  path_display );
826 
827  SetTitle( title );
828 }
829 
830 
832 {
833  auto dp = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
834  dp->UseColorScheme( &Settings().Colors() );
835  dp->DisplayBoard( GetBoard() );
838 }
839 
840 
842 {
843  return IsElementVisible( LAYER_GRID );
844 }
845 
846 
848 {
849  SetElementVisibility( LAYER_GRID, aVisible );
850 }
851 
852 
854 {
855  return GetBoard()->IsElementVisible( aElement );
856 }
857 
858 
860 {
861  GetGalCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
862  GetBoard()->SetElementVisibility( aElement, aNewState );
863  m_Layers->SetRenderState( aElement, aNewState );
864 }
865 
866 
867 void FOOTPRINT_EDIT_FRAME::ProcessPreferences( wxCommandEvent& event )
868 {
869  int id = event.GetId();
870 
871  switch( id )
872  {
873  // Hotkey IDs
874  case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
876  break;
877 
878  case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
880  break;
881 
882  case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
884  break;
885 
886  case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
887  // Display current hotkey list for the footprint editor.
889  break;
890 
891  case ID_PCB_LIB_WIZARD:
892  case ID_PCB_LIB_TABLE_EDIT:
893  {
894  bool tableChanged = false;
895  int r = 0;
896 
897  if( id == ID_PCB_LIB_TABLE_EDIT )
898  r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() );
899  else
900  r = InvokeFootprintWizard( this, &GFootprintTable, Prj().PcbFootprintLibs() );
901 
902  if( r & 1 )
903  {
904  try
905  {
907 
908  GFootprintTable.Format( &sf, 0 );
909  tableChanged = true;
910  }
911  catch( const IO_ERROR& ioe )
912  {
913  wxString msg = wxString::Format( _(
914  "Error occurred saving the global footprint library "
915  "table:\n\n%s" ),
916  GetChars( ioe.What().GetData() )
917  );
918  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
919  }
920  }
921 
922  if( r & 2 )
923  {
924  wxString tblName = Prj().FootprintLibTblName();
925 
926  try
927  {
928  Prj().PcbFootprintLibs()->Save( tblName );
929  tableChanged = true;
930  }
931  catch( const IO_ERROR& ioe )
932  {
933  wxString msg = wxString::Format( _(
934  "Error occurred saving project specific footprint library "
935  "table:\n\n%s" ),
936  GetChars( ioe.What() )
937  );
938  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
939  }
940  }
941 
942  FOOTPRINT_VIEWER_FRAME* viewer;
944 
945  if( tableChanged && viewer != NULL )
946  viewer->ReCreateLibraryList();
947  }
948  break;
949 
950  case wxID_PREFERENCES:
951  InvokeFPEditorPrefsDlg( this );
952  break;
953 
954  case ID_PCB_DISPLAY_OPTIONS_SETUP:
956  break;
957 
958  default:
959  DisplayError( this, "FOOTPRINT_EDIT_FRAME::ProcessPreferences error" );
960  }
961 }
962 
963 
964 void FOOTPRINT_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
965 {
966  Pgm().ConfigurePaths( this );
967 }
968 
969 
971 {
972  PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
973 
974  // Create the manager and dispatcher & route draw panel events to the dispatcher
976  m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
977  drawPanel->GetViewControls(), this );
978  m_actions = new PCB_ACTIONS();
980 
981  drawPanel->SetEventDispatcher( m_toolDispatcher );
982 
994 
995  m_toolManager->GetTool<PAD_TOOL>()->SetEditModules( true );
996  m_toolManager->GetTool<SELECTION_TOOL>()->SetEditModules( true );
997  m_toolManager->GetTool<EDIT_TOOL>()->SetEditModules( true );
998  m_toolManager->GetTool<DRAWING_TOOL>()->SetEditModules( true );
999 
1001 
1002  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
1003 }
1004 
1005 
1007 {
1009 
1010  if( aEnable )
1011  {
1012  // Be sure the axis are enabled:
1013  GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
1014  updateView();
1015  }
1016 
1017  ReCreateMenuBar();
1018 }
void OnUpdateVerticalToolbar(wxUpdateUIEvent &aEvent)
handle most of tools og the vertical right toolbar ("Tools" toolbar)
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:487
timestamp_t GetLink() const
Definition: class_module.h:547
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:95
int m_SolderMaskMargin
Solder mask margin.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Definition: wxstruct.h:55
bool IsFootprintLibWritable(const wxString &aNickname)
Function IsFootprintLibWritable.
Definition of class FOOTPRINT_EDIT_FRAME.
show a marker on pads with no nets
void OnConfigurePaths(wxCommandEvent &aEvent)
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
BOARD_ITEM * Parse(const wxString &aClipboardSourceInput)
Class PCB_IO is a PLUGIN derivation for saving and loading Pcbnew s-expression formatted files...
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
BOARD_DESIGN_SETTINGS & GetDesignSettings() const override
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
Class FP_LIB_TABLE_ROW.
Definition: fp_lib_table.h:42
Model changes (required full reload)
Definition: tool_base.h:83
GAL_TYPE GetBackend() const
Function GetBackend Returns the type of backend currently used by GAL canvas.
This file is part of the common library.
TOOL_DISPATCHER * m_toolDispatcher
Definition: draw_frame.h:96
void Load(wxConfigBase *aCfg) override
Class PCB_LAYER_WIDGET is here to implement the abstract functions of LAYER_WIDGET so they may be tie...
Class SELECTION_TOOL.
Class BOARD to handle a board.
void OnUpdateLibAndModuleSelected(wxUpdateUIEvent &aEvent)
void ExportHotkeyConfigToFile(EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
Function ExportHotkeyConfigToFile Prompt the user for an old hotkey file to read, and read it...
Component library viewer main window.
Definition: modview_frame.h:44
MODULE * Next() const
Definition: class_module.h:120
PCB_LAYER_WIDGET * m_Layers
the layer manager
void OnCloseWindow(wxCloseEvent &Event) override
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences ID_POPUP_PCB_END_RANGE
Class PAD_TOOL.
Definition: pad_tool.h:37
static TOOL_ACTION zoomFitScreen
Definition: actions.h:56
void OnUpdateReplaceModuleInBoard(wxUpdateUIEvent &aEvent)
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
Function SetGridVisibility() , virtual It may be overloaded by derived classes if you want to store/r...
BOARD * GetBoard() const
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
void SetVisibleAlls()
Function SetVisibleAlls changes the bit-mask of visible element categories and layers.
int m_ValueDefaultlayer
Default value text layer on fp creation.
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences 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::OnUpdateLoadModuleFromBoard FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard EVT_UPDATE_UI_RANGE(ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL, FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar) EVT_UPDATE_UI(ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH
#define FOOTPRINT_EDIT_FRAME_NAME
void OnUpdateLoadModuleFromBoard(wxUpdateUIEvent &aEvent)
int InvokeFootprintWizard(wxTopLevelWindow *aParent, FP_LIB_TABLE *aGlobal, FP_LIB_TABLE *aProject)
Function InvokeFootprintWizard Runs the footprint library wizard for easy library addition...
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:54
EDA_PANEINFO & LayersToolbarPane()
Function LayersToolbarPane Change *this to a layers toolbar for KiCad.
Definition: wxstruct.h:539
void OnUpdateLibSelected(wxUpdateUIEvent &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.
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:478
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
Pcbnew hotkeys.
void UseGalCanvas(bool aEnable) override
>
bool InvokeFPEditorPrefsDlg(FOOTPRINT_EDIT_FRAME *aCaller)
Function InvokeSVGPrint shows the SVG print dialog.
Class PCBNEW_CONTROL.
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: pcbnew.cpp:311
const wxString GetCurrentLib() const
Return the current library nickname.
Generic tool for picking a point.
Definition: picker_tool.h:34
virtual void UseGalCanvas(bool aEnable) override
>
bool GeneralControlKeyMovement(int aHotKey, wxPoint *aPos, bool aSnapToGrid)
Function GeneralControlKeyMovement Handle the common part of GeneralControl dedicated to global curso...
VTBL_ENTRY void ConfigurePaths(wxWindow *aParent=NULL)
Function ConfigurePaths.
Definition: pgm_base.cpp:905
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences 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_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected) EVT_UPDATE_UI(ID_MODEDIT_LOAD_MODULE_FROM_BOARD
bool IsElementVisible(GAL_LAYER_ID aElement) const
Function IsElementVisible tests 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)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
EDA_PANEINFO & VerticalToolbarPane()
Function VerticalToolbarPane Change *this to a vertical toolbar for KiCad.
Definition: wxstruct.h:505
void ReCreateMenuBar() override
(Re)Create the menubar for the module editor frame
void DisplayHotkeyList(EDA_BASE_FRAME *aFrame, struct EDA_HOTKEY_CONFIG *aDescList)
Function DisplayHotkeyList Displays the current hotkey list.
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...
FOOTPRINT_EDIT_FRAME::Process_Special_Functions EVT_TOOL_RANGE(ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL, FOOTPRINT_EDIT_FRAME::OnVerticalToolbar) EVT_MENU(ID_PREFERENCES_HOTKEY_EXPORT_CONFIG
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, KIWAY_PLAYER *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:302
virtual bool IsGridVisible() const override
Function IsGridVisible() , virtual.
void RefreshCrossHair(const wxPoint &aOldPos, const wxPoint &aEvtPos, wxDC *aDC)
Move and refresh the crosshair after movement and call the mouse capture function.
void SetLink(timestamp_t aLink)
Definition: class_module.h:548
virtual void OnModify() override
Virtual Function OnModify() Must be called after a footprint change in order to set the "modify" flag...
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.
std::string GetStringOutput(bool doClear)
Class DRAWING_TOOL.
Definition: drawing_tool.h:49
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:240
PCB_GENERAL_SETTINGS & Settings()
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
bool Enable(bool enable) override
Definition: basicframe.cpp:211
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences EVT_MENU(ID_PREFERENCES_HOTKEY_IMPORT_CONFIG, FOOTPRINT_EDIT_FRAME::ProcessPreferences) EVT_MENU(ID_PREFERENCES_HOTKEY_SHOW_EDITOR
int InvokePcbLibTableEditor(wxTopLevelWindow *aCaller, FP_LIB_TABLE *aGlobal, FP_LIB_TABLE *aProject)
Function InvokePcbLibTableEditor shows the modal DIALOG_FP_LIB_TABLE for purposes of editing two lib ...
void Show3D_Frame(wxCommandEvent &event) override
Function Show3D_Frame displays 3D view of the footprint (module) being edited.
The common library.
Helper dialog and control classes.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
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:257
uint32_t EDA_KEY
Definition: common.h:52
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:856
static const wxChar A4[]
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aDesignSettings)
Function SetDesignSettings.
Definition: class_board.h:542
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:387
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
PCB_GENERAL_SETTINGS m_configSettings
EVT_TOOL(ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard) EVT_TOOL(ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT
void ProcessPreferences(wxCommandEvent &event)
ID_POPUP_GRID_USER
Definition: draw_frame.cpp:108
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
VTBL_ENTRY const wxString FootprintLibTblName() const
Function FootprintLibTblName returns the path and filename of this project's fp-lib-table, i.e.
Definition: project.cpp:120
static bool Invoke(FOOTPRINT_EDIT_FRAME &aCaller)
FOOTPRINT_EDIT_FRAME(KIWAY *aKiway, wxWindow *aParent)
protected so only friend PCB::IFACE::CreateWindow() can act as sole factory.
Class PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board...
void Format(BOARD_ITEM *aItem, int aNestLevel=0) const
Function Format outputs aItem to aFormatter in s-expression format.
void SetAxesEnabled(bool aAxesEnabled)
Enables drawing the axes.
Class EDIT_TOOL.
Definition: edit_tool.h:45
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:123
const PCB_PLOT_PARAMS & GetPlotSettings() const override
Function GetPlotSettings returns the PCB_PLOT_PARAMS for the BOARD owned by this frame.
void UseColorScheme(const COLORS_DESIGN_SETTINGS *aSettings)
Function UseColorScheme Applies layer color settings.
Class COMMON_TOOLS.
Definition: common_tools.h:38
Class TOOL_DISPATCHER.
virtual void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const override
Generate the table in s-expression format to aOutput with an indention level of aIndentLevel.
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:173
bool OnHotKey(wxDC *aDC, int aHotKey, const wxPoint &aPosition, EDA_ITEM *aItem=NULL) override
Function OnHotKey handle hot key events.
BOARD * GetBoard()
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName)
Function FindRow.
void InstallHotkeyFrame(EDA_BASE_FRAME *aParent, EDA_HOTKEY_CONFIG *aHotkeys)
Function InstallHotkeyFrame Create a hotkey editor dialog window with the provided hotkey configurati...
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aSettings) override
void updateTitle()
Function UpdateTitle updates window title according to getLibNickName().
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:188
virtual void UpdateStatusBar() override
Function UpdateStatusBar updates the status bar information.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
Definition: wxstruct.h:524
int DisplayExitDialog(wxWindow *parent, const wxString &aMessage)
Function DisplayExitDialog displays a dialog with 3 buttons: Save and Exit Cancel Exit without save...
Definition: confirm.cpp:61
Class PCB_ACTIONS.
Definition: pcb_actions.h:42
void OnUpdateSelectCurrentLib(wxUpdateUIEvent &aEvent)
struct EDA_HOTKEY_CONFIG g_Module_Editor_Hokeys_Descr[]
Struct PARSE_ERROR contains a filename or source description, a problem input line, a line number, a byte offset, and an error message which contains the the caller's report and his call site information: CPP source file, function, and line number.
Definition: ki_exception.h:94
void wxConfigSaveSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigSaveSetups writes aList of PARAM_CFG_ARRAY elements to save configuration values to ...
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
see class PGM_BASE
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
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
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()
Function GetConfigurationSettings returns the footpr�int editor settings list.
DLIST< MODULE > m_Modules
Definition: class_board.h:245
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
Function GeneralControl performs application specific control using aDC at aPosition in logical units...
void OnUpdateInsertModuleInBoard(wxUpdateUIEvent &aEvent)
int GetToolId() const
Definition: draw_frame.h:465
const wxString getLibPath()
The libPath is not publicly visible, grab it from the FP_LIB_TABLE if we must.
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
Definition: wxstruct.h:117
BOARD_ITEM_CONTAINER * GetModel() const override
>
void ReCreateLibraryList()
Function ReCreateLibraryList.
void updateView()
Reloads displayed items and sets view.
EVT_MENU_RANGE(ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END, PCB_BASE_FRAME::ProcessItemSelection) EVT_TOOL(ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART
Class POINT_EDITOR.
Definition: point_editor.h:41
int m_RefDefaultlayer
Default ref text layer on fp creation.
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Class FILE_OUTPUTFORMATTER may be used for text file output.
Definition: richio.h:492
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel...
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:864
PCB_EDIT_FRAME::OnResetModuleTextSizes PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectTool PCB_EDIT_FRAME::Process_Special_Functions ID_POPUP_GENERAL_END_RANGE
Definition: pcbframe.cpp:278
Class EDA_3D_VIEWER Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard...
Definition: eda_3d_viewer.h:50
void CloseModuleEditor(wxCommandEvent &Event)
Module description (excepted pads)
void InitTools()
Function InitTools() Initializes all registered tools.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
bool SaveFootprintInLibrary(const wxString &aLibName, MODULE *aModule, bool aOverwrite, bool aDisplayDialog)
Function SaveFootprintInLibrary Save in an existing library a given footprint.
Definition: librairi.cpp:656
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
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...
void ImportHotkeyConfigFromFile(EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
Function ImportHotkeyConfigFromFile Prompt the user for an old hotkey file to read, and read it.
ACTIONS * m_actions
Definition: draw_frame.h:97
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
void wxConfigLoadSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigLoadSetups uses aList of PARAM_CFG_ARRAY elements to load configuration values from ...
EDA_3D_VIEWER * Get3DViewerFrame()
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:73
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition 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:47
bool m_movingCursorWithKeyboard
One-shot to avoid a recursive mouse event during hotkey movement.
Definition: draw_frame.h:139
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 wxString GetGlobalTableFileName()
Function GetGlobalTableFileName.
static const wxChar * GetFootprintEditorFrameName()
Function GetFootprintEditorFrameName (static)
timestamp_t GetTimeStamp() const
Definition: base_struct.h:231
bool IsEmpty(bool aIncludeFallback=true)
Return true if the table is empty.
void RegisterTool(TOOL_BASE *aTool)
Function RegisterTool() Adds a tool to the manager set and sets it up.
void Save(wxConfigBase *aCfg) override
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
KIWAY Kiway