KiCad PCB EDA Suite
footprint_wizard_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) 2012-2015 Miguel Angel Ajo Pelayo <miguelangel@nbee.es>
5  * Copyright (C) 2012-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
6  * Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 2004-2017 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 
31 #include <fctsys.h>
32 #include <kiface_i.h>
33 #include <class_drawpanel.h>
34 #include <pcb_edit_frame.h>
35 #include <pcbnew.h>
37 #include <msgpanel.h>
38 #include <macros.h>
39 #include <bitmaps.h>
40 #include <grid_tricks.h>
41 
42 #include <class_board.h>
43 #include <class_module.h>
44 #include <footprint_edit_frame.h>
45 
46 #include <pcbnew_id.h>
47 #include "footprint_wizard_frame.h"
48 #include <footprint_info.h>
49 #include <wx/grid.h>
50 #include <wx/tokenzr.h>
51 #include <wx/numformatter.h>
52 
53 #include <hotkeys.h>
55 #include <base_units.h>
56 
57 
58 BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
59 
60  // Window events
61  EVT_CLOSE( FOOTPRINT_WIZARD_FRAME::OnCloseWindow )
62  EVT_SIZE( FOOTPRINT_WIZARD_FRAME::OnSize )
63  EVT_ACTIVATE( FOOTPRINT_WIZARD_FRAME::OnActivate )
64 
65  // Toolbar events
67  FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard )
68 
70  FOOTPRINT_WIZARD_FRAME::DefaultParameters )
71 
73  FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
74 
76  FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
77 
79  FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint )
80 
82  FOOTPRINT_WIZARD_FRAME::Show3D_Frame )
83 
84  // listbox events
85 
86  EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList )
88  FOOTPRINT_WIZARD_FRAME::ParametersUpdated )
89 
91 END_EVENT_TABLE()
92 
93 
94 /* Note: our FOOTPRINT_WIZARD_FRAME is always modal.
95  * Note:
96  * On windows, when the frame with type wxFRAME_FLOAT_ON_PARENT is displayed
97  * its parent frame is sometimes brought to the foreground when closing the
98  * LIB_VIEW_FRAME frame.
99  * If it still happens, it could be better to use wxSTAY_ON_TOP
100  * instead of wxFRAME_FLOAT_ON_PARENT
101  */
102 #ifdef __WINDOWS__
103 #define MODAL_MODE_EXTRASTYLE wxFRAME_FLOAT_ON_PARENT // could be wxSTAY_ON_TOP if issues
104 #else
105 #define MODAL_MODE_EXTRASTYLE wxFRAME_FLOAT_ON_PARENT
106 #endif
107 
109  wxWindow* aParent, FRAME_T aFrameType ) :
110  PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ),
111  wxDefaultPosition, wxDefaultSize,
113  : KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
115 {
116  wxASSERT( aFrameType == FRAME_PCB_FOOTPRINT_WIZARD_MODAL );
117 
118  // This frame is always show modal:
119  SetModal( true );
120 
121  m_showAxis = true; // true to draw axis.
122 
123  // Give an icon
124  wxIcon icon;
125  icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) );
126  SetIcon( icon );
127 
128  m_hotkeysDescrList = g_Module_Viewer_Hotkeys_Descr;
129  m_wizardName.Empty();
130 
131  SetBoard( new BOARD() );
132 
133  // Ensure all layers and items are visible:
135  SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
136  GetScreen()->m_Center = true; // Center coordinate origins on screen.
137 
138  LoadSettings( config() );
139 
140  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
141 
142  // Set some display options here, because the FOOTPRINT_WIZARD_FRAME
143  // does not have a config menu to do that:
144  auto disp_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
145  disp_opts->m_DisplayPadIsol = false;
146  disp_opts->m_DisplayPadNum = true;
148 
149  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
150 
151  ReCreateHToolbar();
152  ReCreateVToolbar();
153  SetActiveLayer( F_Cu );
154 
155  // Create the parameters panel
156  m_parametersPanel = new wxPanel( this, wxID_ANY );
157 
158  m_pageList = new wxListBox( m_parametersPanel, ID_FOOTPRINT_WIZARD_PAGE_LIST,
159  wxDefaultPosition, wxDefaultSize,
160  0, NULL, wxLB_HSCROLL );
161 
162  m_parameterGrid = new wxGrid( m_parametersPanel, ID_FOOTPRINT_WIZARD_PARAMETER_LIST );
163  initParameterGrid();
164  m_parameterGrid->PushEventHandler( new GRID_TRICKS( m_parameterGrid ) );
165 
166  ReCreatePageList();
167 
168  wxBoxSizer* parametersSizer = new wxBoxSizer( wxHORIZONTAL );
169  parametersSizer->Add( m_pageList, 0, wxEXPAND|wxALL, 5 );
170  parametersSizer->Add( m_parameterGrid, 1, wxEXPAND|wxALL, 5 );
171  m_parametersPanel->SetSizer( parametersSizer );
172  m_parametersPanel->Layout();
173 
174  // Create the build message box
175  m_buildMessageBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
176  wxDefaultPosition, wxDefaultSize,
177  wxTE_MULTILINE|wxTE_READONLY );
178 
179  DisplayWizardInfos();
180 
181  m_auimgr.SetManagedWindow( this );
182 
183  EDA_PANEINFO horiztb;
184  horiztb.HorizontalToolbarPane();
185 
186  EDA_PANEINFO info;
187  info.InfoToolbarPane();
188 
189  EDA_PANEINFO mesg;
190  mesg.MessageToolbarPane();
191 
192  // Manage main toolbal
193  m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiztb ).
194  Name( wxT ("m_mainToolBar" ) ).Top().Row( 0 ) );
195 
196  // Manage the parameters panel
197  EDA_PANEINFO parametersPaneInfo;
198  parametersPaneInfo.InfoToolbarPane().Name( wxT( "m_parametersPanel" ) ).Left().Position( 0 );
199  m_auimgr.AddPane( m_parametersPanel, wxAuiPaneInfo( parametersPaneInfo ) );
200 
201  // Manage the build message box
202  EDA_PANEINFO buildMessageBoxInfo;
203  buildMessageBoxInfo.InfoToolbarPane().Name( wxT( "m_buildMessageBox" ) ).Left().Position( 1 );
204  m_auimgr.AddPane( m_buildMessageBox, wxAuiPaneInfo( buildMessageBoxInfo ) );
205 
206  // Manage the draw panel
207  m_auimgr.AddPane( m_canvas,
208  wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
209 
210  // Manage the message panel
211  m_auimgr.AddPane( m_messagePanel,
212  wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(1) );
213 
214  // Give a min size to the parameters
215  m_auimgr.GetPane( m_parametersPanel ).MinSize( wxSize( 360, 180 ) );
216 
217  m_auimgr.LoadPerspective( m_auiPerspective );
218 
219  // Now Drawpanel is sized, we can use BestZoom to show the component (if any)
220 #ifdef USE_WX_GRAPHICS_CONTEXT
221  GetScreen()->SetScalingFactor( BestZoom() );
222 #else
223  Zoom_Automatique( false );
224 #endif
225 
226  // Do not Run a dialog here: on some Window Managers, it creates issues.
227  // Reason: the FOOTPRINT_WIZARD_FRAME is run as modal;
228  // It means the call to FOOTPRINT_WIZARD_FRAME::ShowModal will change the
229  // Event Loop Manager, and stop the one created by the dialog.
230  // It does not happen on all W.M., perhaps due to the way the order events are called
231 // SelectFootprintWizard();
232 }
233 
234 
236 {
237  // Delete the GRID_TRICKS.
238  m_parameterGrid->PopEventHandler( true );
239 
240  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
241 
242  if( draw3DFrame )
243  draw3DFrame->Destroy();
244 }
245 
246 
247 void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
248 {
249  SaveSettings( config() );
250 
251  if( IsModal() )
252  {
253  // Only dismiss a modal frame once, so that the return values set by
254  // the prior DismissModal() are not bashed for ShowModal().
255  if( !IsDismissed() )
256  DismissModal( false );
257  }
258  else
259  {
260  Destroy();
261  }
262 }
263 
264 
266 {
267  DismissModal( true );
268  Close();
269 }
270 
271 
272 void FOOTPRINT_WIZARD_FRAME::OnGridSize( wxSizeEvent& aSizeEvent )
273 {
274  // Resize the parameter columns
276 
277  aSizeEvent.Skip();
278 }
279 
280 
281 void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv )
282 {
283  if( m_auimgr.GetManagedWindow() )
284  m_auimgr.Update();
285 
286  SizeEv.Skip();
287 }
288 
289 
290 void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
291 {
293  UpdateStatusBar();
294 }
295 
296 
298 {
299  m_parameterGridPage = -1;
300 
301  // Prepare the grid where parameters are displayed
302 
303  m_parameterGrid->CreateGrid( 0, 3 );
304 
305  m_parameterGrid->SetColLabelValue( WIZ_COL_NAME, _( "Parameter" ) );
306  m_parameterGrid->SetColLabelValue( WIZ_COL_VALUE, _( "Value" ) );
307  m_parameterGrid->SetColLabelValue( WIZ_COL_UNITS, _( "Units" ) );
308 
309  m_parameterGrid->SetColLabelSize( 22 );
310  m_parameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
311  m_parameterGrid->AutoSizeColumns();
312 
313  m_parameterGrid->AutoSizeRows();
314  m_parameterGrid->SetRowLabelSize( 0 );
315 
316  m_parameterGrid->DisableDragGridSize();
317  m_parameterGrid->DisableDragColSize();
318 
319  m_parameterGrid->Connect( wxEVT_SIZE,
320  wxSizeEventHandler( FOOTPRINT_WIZARD_FRAME::OnGridSize ),
321  NULL, this );
322 }
323 
324 
326 {
327  if( m_pageList == NULL )
328  return;
329 
330  FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
331 
332  if( !footprintWizard )
333  return;
334 
335  m_pageList->Clear();
336  int max_page = footprintWizard->GetNumParameterPages();
337 
338  for( int i = 0; i<max_page; i++ )
339  {
340  wxString name = footprintWizard->GetParameterPageName( i );
341  m_pageList->Append( name );
342  }
343 
344  m_pageList->SetSelection( 0, true );
345 
349  m_canvas->Refresh();
350 }
351 
352 
354 {
355  if( m_parameterGrid == NULL )
356  return;
357 
358  FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
359 
360  if( footprintWizard == NULL )
361  return;
362 
363  m_parameterGrid->ClearGrid();
364  m_parameterGridPage = m_pageList->GetSelection();
365 
366  if( m_parameterGridPage < 0 ) // Should not happen
367  return;
368 
369  // Get the list of names, values, types, hints and designators
370  wxArrayString designatorsList = footprintWizard->GetParameterDesignators( m_parameterGridPage );
371  wxArrayString namesList = footprintWizard->GetParameterNames( m_parameterGridPage );
372  wxArrayString valuesList = footprintWizard->GetParameterValues( m_parameterGridPage );
373  wxArrayString typesList = footprintWizard->GetParameterTypes( m_parameterGridPage );
374  wxArrayString hintsList = footprintWizard->GetParameterHints( m_parameterGridPage );
375 
376  // Dimension the wxGrid
377  if( m_parameterGrid->GetNumberRows() > 0 )
378  m_parameterGrid->DeleteRows( 0, m_parameterGrid->GetNumberRows() );
379 
380  m_parameterGrid->AppendRows( namesList.size() );
381 
382  wxString designator, name, value, units, hint;
383 
384  for( unsigned int i = 0; i< namesList.size(); i++ )
385  {
386  designator = designatorsList[i];
387  name = namesList[i];
388  value = valuesList[i];
389  units = typesList[i];
390  hint = hintsList[i];
391 
392  m_parameterGrid->SetRowLabelValue( i, designator );
393 
394  // Set the 'Name'
395  m_parameterGrid->SetCellValue( i, WIZ_COL_NAME, name );
396  m_parameterGrid->SetReadOnly( i, WIZ_COL_NAME );
397 
398  // Boolean parameters are displayed using a checkbox
399  if( units == WIZARD_PARAM_UNITS_BOOL )
400  {
401  // Set to ReadOnly as we delegate interactivity to GRID_TRICKS
402  m_parameterGrid->SetReadOnly( i, WIZ_COL_VALUE );
403  m_parameterGrid->SetCellRenderer( i, WIZ_COL_VALUE, new wxGridCellBoolRenderer );
404  }
405  // Parameters that can be selected from a list of multiple options
406  else if( units.Contains( "," ) ) // Indicates list of available options
407  {
408  wxStringTokenizer tokenizer( units, "," );
409  wxArrayString options;
410 
411  while( tokenizer.HasMoreTokens() )
412  {
413  options.Add( tokenizer.GetNextToken() );
414  }
415 
416  m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellChoiceEditor( options ) );
417 
418  units = wxT( "" );
419  }
420  // Integer parameters
421  else if( units == WIZARD_PARAM_UNITS_INTEGER )
422  {
423  m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellNumberEditor );
424  }
425  // Non-integer numerical parameters
426  else if( ( units == WIZARD_PARAM_UNITS_MM ) ||
427  ( units == WIZARD_PARAM_UNITS_MILS ) ||
428  ( units == WIZARD_PARAM_UNITS_FLOAT ) ||
429  ( units == WIZARD_PARAM_UNITS_RADIANS ) ||
430  ( units == WIZARD_PARAM_UNITS_DEGREES ) ||
431  ( units == WIZARD_PARAM_UNITS_PERCENT ) )
432  {
433  m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellFloatEditor );
434 
435  // Convert separators to the locale-specific character
436  value.Replace( ",", wxNumberFormatter::GetDecimalSeparator() );
437  value.Replace( ".", wxNumberFormatter::GetDecimalSeparator() );
438  }
439 
440  // Set the 'Units'
441  m_parameterGrid->SetCellValue( i, WIZ_COL_UNITS, units );
442  m_parameterGrid->SetReadOnly( i, WIZ_COL_UNITS );
443 
444  // Set the 'Value'
445  m_parameterGrid->SetCellValue( i, WIZ_COL_VALUE, value );
446  }
447 
449 }
450 
452 {
453 
454  // Parameter grid is not yet configured
455  if( ( m_parameterGrid == NULL ) || ( m_parameterGrid->GetNumberCols() == 0 ) )
456  return;
457 
458  // first auto-size the columns to ensure enough space around text
459  m_parameterGrid->AutoSizeColumns();
460 
461  // Auto-size the value column
462  int width = m_parameterGrid->GetClientSize().GetWidth() -
463  m_parameterGrid->GetRowLabelSize() -
464  m_parameterGrid->GetColSize( WIZ_COL_NAME ) -
465  m_parameterGrid->GetColSize( WIZ_COL_UNITS );
466 
467  if( width > m_parameterGrid->GetColMinimalAcceptableWidth() )
468  {
469  m_parameterGrid->SetColSize( WIZ_COL_VALUE, width );
470  }
471 }
472 
473 
474 void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event )
475 {
476  int ii = m_pageList->GetSelection();
477 
478  if( ii < 0 )
479  return;
480 
482  m_canvas->Refresh();
484 }
485 
486 
487 #define AUI_PERSPECTIVE_KEY wxT( "Fpwizard_auiPerspective" )
488 
489 
490 void FOOTPRINT_WIZARD_FRAME::LoadSettings( wxConfigBase* aCfg )
491 {
493 
494  aCfg->Read( AUI_PERSPECTIVE_KEY, &m_auiPerspective );
495 }
496 
497 
498 void FOOTPRINT_WIZARD_FRAME::SaveSettings( wxConfigBase* aCfg )
499 {
501 
502  aCfg->Write( AUI_PERSPECTIVE_KEY, m_auimgr.SavePerspective() );
503 }
504 
505 
506 void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event )
507 {
509 
510  // Ensure we do not have old selection:
511  if( !event.GetActive() )
512  return;
513 
514 #if 0
515  // Currently, we do not have a way to see if a Python wizard has changed,
516  // therefore the lists of parameters and option has to be rebuilt
517  // This code could be enabled when this way exists
518  bool footprintWizardsChanged = false;
519 
520  if( footprintWizardsChanged )
521  {
522  // If we are here, the library list has changed, rebuild it
525  }
526 #endif
527 }
528 
529 
530 bool FOOTPRINT_WIZARD_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
531 {
532  // Filter out the 'fake' mouse motion after a keyboard movement
533  if( !aHotKey && m_movingCursorWithKeyboard )
534  {
536  return false;
537  }
538 
539  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
540  cmd.SetEventObject( this );
541 
542  wxPoint pos = aPosition;
543  wxPoint oldpos = GetCrossHairPosition();
544  bool keyHandled = GeneralControlKeyMovement( aHotKey, &pos, true );
545 
546  switch( aHotKey )
547  {
548  case WXK_F1:
549  cmd.SetId( ID_KEY_ZOOM_IN );
550  GetEventHandler()->ProcessEvent( cmd );
551  keyHandled = true;
552  break;
553 
554  case WXK_F2:
555  cmd.SetId( ID_KEY_ZOOM_OUT );
556  GetEventHandler()->ProcessEvent( cmd );
557  keyHandled = true;
558  break;
559 
560  case WXK_F3:
561  cmd.SetId( ID_ZOOM_REDRAW );
562  GetEventHandler()->ProcessEvent( cmd );
563  keyHandled = true;
564  break;
565 
566  case WXK_F4:
567  cmd.SetId( ID_POPUP_ZOOM_CENTER );
568  GetEventHandler()->ProcessEvent( cmd );
569  keyHandled = true;
570  break;
571 
572  case WXK_HOME:
573  cmd.SetId( ID_ZOOM_PAGE );
574  GetEventHandler()->ProcessEvent( cmd );
575  keyHandled = true;
576  break;
577 
578  case ' ':
580  keyHandled = true;
581  break;
582 
583  default:
584  break;
585  }
586 
587  SetCrossHairPosition( pos );
588  RefreshCrossHair( oldpos, aPosition, aDC );
589 
590  UpdateStatusBar(); // Display new cursor coordinates
591 
592  return keyHandled;
593 }
594 
595 
596 void FOOTPRINT_WIZARD_FRAME::Show3D_Frame( wxCommandEvent& event )
597 {
598  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
599 
600  // We can probably remove this for 6.0, but just to be safe we'll stick to
601  // one 3DFrame at a time for 5.0
602  if( draw3DFrame )
603  draw3DFrame->Close( true );
604 
605  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
606  Update3D_Frame( false );
607 
608 #ifdef __WXMAC__
609  // A stronger version of Raise() which promotes the window to its parent's level.
610  draw3DFrame->ReparentQuasiModal();
611 #else
612  draw3DFrame->Raise(); // Needed with some Window Managers
613 #endif
614 
615  draw3DFrame->Show( true );
616 }
617 
618 
624 void FOOTPRINT_WIZARD_FRAME::Update3D_Frame( bool aForceReloadFootprint )
625 {
626  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
627 
628  if( draw3DFrame == NULL )
629  return;
630 
631  wxString frm3Dtitle;
632  frm3Dtitle.Printf( _( "ModView: 3D Viewer [%s]" ), GetChars( m_wizardName ) );
633  draw3DFrame->SetTitle( frm3Dtitle );
634 
635  if( aForceReloadFootprint )
636  {
637  // Force 3D screen refresh immediately
638  draw3DFrame->NewDisplay( true );
639  }
640 }
641 
642 
644 {
645  wxString msg;
646 
647  if( !m_mainToolBar )
648  {
649  m_mainToolBar = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
650  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
651 
652  // Set up toolbar
653  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SELECT_WIZARD, wxEmptyString,
654  KiBitmap( module_wizard_xpm ),
655  _( "Select wizard script to run" ) );
656 
657  m_mainToolBar->AddSeparator();
658 
659  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT, wxEmptyString,
660  KiBitmap( reload_xpm ),
661  _( "Reset wizard parameters to default") );
662 
663  m_mainToolBar->AddSeparator();
664 
665  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_PREVIOUS, wxEmptyString,
666  KiBitmap( lib_previous_xpm ),
667  _( "Select previous parameters page" ) );
668 
669  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_NEXT, wxEmptyString,
670  KiBitmap( lib_next_xpm ),
671  _( "Select next parameters page" ) );
672 
673  m_mainToolBar->AddSeparator();
674  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW, wxEmptyString,
675  KiBitmap( three_d_xpm ),
676  _( "Show footprint in 3D viewer" ) );
677 
678  m_mainToolBar->AddSeparator();
679  msg = AddHotkeyName( _( "Zoom in" ), g_Module_Editor_Hotkeys_Descr,
681  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString,
682  KiBitmap( zoom_in_xpm ), msg );
683 
684  msg = AddHotkeyName( _( "Zoom out" ), g_Module_Editor_Hotkeys_Descr,
686  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString,
687  KiBitmap( zoom_out_xpm ), msg );
688 
689  msg = AddHotkeyName( _( "Redraw view" ), g_Module_Editor_Hotkeys_Descr,
691  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString,
692  KiBitmap( zoom_redraw_xpm ), msg );
693 
694  msg = AddHotkeyName( _( "Zoom auto" ), g_Module_Editor_Hotkeys_Descr,
696  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
697  KiBitmap( zoom_fit_in_page_xpm ), msg );
698 
699  // The footprint wizard always can export the current footprint
700  m_mainToolBar->AddSeparator();
701  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_DONE,
702  wxEmptyString, KiBitmap( export_footprint_names_xpm ),
703  _( "Export footprint to editor" ) );
704 
705  // after adding the buttons to the toolbar, must call Realize() to
706  // reflect the changes
707  m_mainToolBar->Realize();
708  }
709 
710  m_mainToolBar->Refresh();
711 }
712 
713 
715 {
716  // Currently, there is no vertical toolbar
717 }
718 
719 #if defined(KICAD_SCRIPTING)
721 {
722  // Reload the Python plugins
723  // Because the board editor has also a plugin python menu,
724  // call PCB_EDIT_FRAME::PythonPluginsReload() if the board editor
725  // is running
726  PCB_EDIT_FRAME* brd_frame =
727  static_cast<PCB_EDIT_FRAME*>( Kiway().Player( FRAME_PCB, false ) );
728 
729  if( brd_frame )
730  brd_frame->PythonPluginsReload();
731  else
733 }
734 #endif
735 
736 
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
#define AUI_PERSPECTIVE_KEY
Class FOOTPRINT_WIZARD_FRAME.
struct EDA_HOTKEY_CONFIG g_Module_Viewer_Hotkeys_Descr[]
show a marker on pads with no nets
wxString m_wizardName
name of the current wizard
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
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
void DisplayWizardInfos()
Function DisplayWizardInfos Shows all the details about the current wizard.
const wxString WIZARD_PARAM_UNITS_MM
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:338
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Implementation of conversion functions that require both schematic and board internal units...
wxString m_auiPerspective
Encoded string describing the AUI layout.
bool IsDismissed()
Function IsDismissed returns false only if both the frame is acting in modal mode and it has not been...
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
wxListBox * m_pageList
The list of pages.
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
struct EDA_HOTKEY_CONFIG g_Module_Editor_Hotkeys_Descr[]
Class BOARD to handle a board.
void ExportSelectedFootprint(wxCommandEvent &aEvent)
Function ExportSelectedFootprint(); will let the caller exit from the wait loop, and get the built fo...
virtual wxString GetParameterPageName(int aPage)=0
Function GetParameterPageName.
int m_parameterGridPage
the page currently displayed by m_parameterGrid it is most of time the m_pageList selection...
Definition: id.h:242
Class GRID_TRICKS is used to add cut, copy, and paste to an otherwise unmodied wxGrid instance...
Definition: grid_tricks.h:34
virtual wxArrayString GetParameterTypes(int aPage)=0
Function GetParameterTypes.
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
void SetVisibleAlls()
Function SetVisibleAlls changes the bit-mask of visible element categories and layers.
#define FOOTPRINT_WIZARD_FRAME_NAME
Definition: draw_frame.h:52
void Update3D_Frame(bool aForceReloadFootprint=true)
Function Update3D_Frame must be called after a footprint selection Updates the 3D view and 3D frame t...
wxAuiManager m_auimgr
virtual wxArrayString GetParameterNames(int aPage)=0
Function GetParameterNames.
void initParameterGrid()
Function initParameterGrid Prepare the grid where parameters are displayed.
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:63
const wxString WIZARD_PARAM_UNITS_DEGREES
Definition of class FOOTPRINT_EDIT_FRAME.
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: draw_frame.cpp:793
void ClickOnPageList(wxCommandEvent &event)
Specialization of the wxAuiPaneInfo class for KiCad panels.
Pcbnew hotkeys.
This file contains miscellaneous commonly used macros and functions.
const wxString WIZARD_PARAM_UNITS_RADIANS
void ReCreateParameterList()
Function ReCreateParameterList Creates the list of parameters for the current page.
bool GeneralControlKeyMovement(int aHotKey, wxPoint *aPos, bool aSnapToGrid)
Function GeneralControlKeyMovement Handle the common part of GeneralControl dedicated to global curso...
virtual void OnActivate(wxActivateEvent &event) override
Function OnActivate is called when the frame frame is activate to reload the libraries and component ...
FOOTPRINT_WIZARD_FRAME::DefaultParameters FOOTPRINT_WIZARD_FRAME::Process_Special_Functions FOOTPRINT_WIZARD_FRAME::Show3D_Frame EVT_GRID_CMD_CELL_CHANGED(ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ParametersUpdated) FOOTPRINT_WIZARD_FRAME
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
const wxString WIZARD_PARAM_UNITS_INTEGER
wxGrid * m_parameterGrid
The list of parameters.
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
void ReCreatePageList()
Function ReCreatePageList Creates or recreates the list of parameter pages for the current wizard...
virtual wxArrayString GetParameterDesignators(int aPage)=0
Function GetParamaterDesignators.
void RefreshCrossHair(const wxPoint &aOldPos, const wxPoint &aEvtPos, wxDC *aDC)
Move and refresh the crosshair after movement and call the mouse capture function.
const wxString WIZARD_PARAM_UNITS_MILS
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
const wxString WIZARD_PARAM_UNITS_FLOAT
EVT_MENU(ID_SELECT_PREFERED_PDF_BROWSER_NAME, KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser) EVT_MENU_RANGE(ID_LANGUAGE_CHOICE
FOOTPRINT_WIZARD_FRAME(KIWAY *aKiway, wxWindow *parent, FRAME_T aFrameType)
The common library.
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:52
const wxString WIZARD_PARAM_UNITS_PERCENT
#define KICAD_DEFAULT_DRAWFRAME_STYLE
EVT_TOOL(ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard) EVT_TOOL(ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT
bool IsModal()
Definition: kiway_player.h:217
FOOTPRINT_WIZARD * GetMyWizard()
Function GetMyWizard Reloads the wizard by name.
EDA_PANEINFO & InfoToolbarPane()
Function InfoToolbarPane Change *this to a information panel for for KiCad.
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
void PythonPluginsReload()
Reload the Python plugins if they are newer than the already loaded, and load new plugins if any Do n...
void Show3D_Frame(wxCommandEvent &event) override
Function Show3D_Frame (virtual) displays 3D view of the footprint (module) being edited.
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: draw_frame.cpp:761
void OnSize(wxSizeEvent &event) override
Function OnSize recalculates the size of toolbars and display panel when the frame size changes...
BOARD * GetBoard()
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:106
void PythonPluginsReloadBase()
Helper function PythonPluginsReloadBase Reload Python plugins if they are newer than the already load...
Definition: pcbnew.cpp:289
virtual int GetNumParameterPages()=0
Function GetNumParameterPages.
virtual void UpdateStatusBar() override
Function UpdateStatusBar updates the status bar information.
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
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
wxString AddHotkeyName(const wxString &aText, EDA_HOTKEY **aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType)
Function AddHotkeyName Add the key name from the Command id value ( m_Idcommand member value) ...
Declaration of the eda_3d_viewer class.
const char * name
Definition: DXF_plotter.cpp:61
void DismissModal(bool aRetVal, const wxString &aResult=wxEmptyString)
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
#define MODAL_MODE_EXTRASTYLE
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...
size_t i
Definition: json11.cpp:597
void OnSetRelativeOffset(wxCommandEvent &event)
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
void OnGridSize(wxSizeEvent &aSizeEvent)
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
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
virtual wxArrayString GetParameterValues(int aPage)=0
Function GetParameterValues.
Module description (excepted pads)
void OnCloseWindow(wxCloseEvent &Event) override
virtual wxArrayString GetParameterHints(int aPage)=0
Function GetParameterHints.
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
const wxString WIZARD_PARAM_UNITS_BOOL
Message panel definition file.
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
void PythonPluginsReload()
Reload the Python plugins if they are newer than the already loaded, and load new plugins if any Do n...
void ResizeParamColumns()
Expand the &#39;Value&#39; column to fill available.
EDA_3D_VIEWER * Get3DViewerFrame()
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
virtual void OnActivate(wxActivateEvent &event)
Function OnActivate (virtual) is called when activating the frame.
Definition: draw_frame.cpp:282
bool m_movingCursorWithKeyboard
One-shot to avoid a recursive mouse event during hotkey movement.
Definition: draw_frame.h:159
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
Class FOOTPRINT_WIZARD This is the parent class from where any footprint wizard class must derive...