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-2015 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 change_log.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 <wxPcbStruct.h>
35 #include <pcbnew.h>
37 #include <msgpanel.h>
38 #include <macros.h>
39 #include <bitmaps.h>
40 
41 #include <class_board.h>
42 #include <class_module.h>
43 #include <module_editor_frame.h>
44 
45 #include <pcbnew_id.h>
46 #include "footprint_wizard_frame.h"
47 #include <footprint_info.h>
48 #include <wx/grid.h>
49 #include <wx/tokenzr.h>
50 #include <wx/numformatter.h>
51 
52 #include <hotkeys.h>
54 #include <base_units.h>
55 
56 
57 BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
58 
59  // Window events
60  EVT_CLOSE( FOOTPRINT_WIZARD_FRAME::OnCloseWindow )
61  EVT_SIZE( FOOTPRINT_WIZARD_FRAME::OnSize )
62  EVT_ACTIVATE( FOOTPRINT_WIZARD_FRAME::OnActivate )
63 
64  // Toolbar events
66  FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard )
67 
69  FOOTPRINT_WIZARD_FRAME::DefaultParameters )
70 
72  FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
73 
75  FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
76 
78  FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint )
79 
81  FOOTPRINT_WIZARD_FRAME::Show3D_Frame )
82 
83  // listbox events
84 
85  EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList )
87  FOOTPRINT_WIZARD_FRAME::ParametersUpdated )
88 
90 END_EVENT_TABLE()
91 
92 
93 #define FOOTPRINT_WIZARD_FRAME_NAME wxT( "FootprintWizard" )
94 
95 /* Note: our FOOTPRINT_WIZARD_FRAME is always modal.
96  * Note:
97  * On windows, when the frame with type wxFRAME_FLOAT_ON_PARENT is displayed
98  * its parent frame is sometimes brought to the foreground when closing the
99  * LIB_VIEW_FRAME frame.
100  * If it still happens, it could be better to use wxSTAY_ON_TOP
101  * instead of wxFRAME_FLOAT_ON_PARENT
102  */
103 #ifdef __WINDOWS__
104 #define MODAL_MODE_EXTRASTYLE wxFRAME_FLOAT_ON_PARENT // could be wxSTAY_ON_TOP if issues
105 #else
106 #define MODAL_MODE_EXTRASTYLE wxFRAME_FLOAT_ON_PARENT
107 #endif
108 
110  wxWindow* aParent, FRAME_T aFrameType ) :
111  PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ),
112  wxDefaultPosition, wxDefaultSize,
114  : KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
116 {
117  wxASSERT( aFrameType == FRAME_PCB_FOOTPRINT_WIZARD_MODAL );
118 
119  // This frame is always show modal:
120  SetModal( true );
121 
122  m_messagesFrame = NULL; // This windows will be created the first time a wizard is loaded
123  m_showAxis = true; // true to draw axis.
124 
125  // Give an icon
126  wxIcon icon;
127  icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) );
128  SetIcon( icon );
129 
130  m_hotkeysDescrList = g_Module_Viewer_Hokeys_Descr;
131  m_wizardName.Empty();
132 
133  SetBoard( new BOARD() );
134 
135  // Ensure all layers and items are visible:
137  SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
138  GetScreen()->m_Center = true; // Center coordinate origins on screen.
139 
140  LoadSettings( config() );
141 
142  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
143 
144  // Set some display options here, because the FOOTPRINT_WIZARD_FRAME
145  // does not have a config menu to do that:
146  DISPLAY_OPTIONS* disp_opts = (DISPLAY_OPTIONS*) GetDisplayOptions();
147  disp_opts->m_DisplayPadIsol = false;
148  disp_opts->m_DisplayPadNum = true;
150 
151  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
152 
153  ReCreateHToolbar();
154  ReCreateVToolbar();
155 
156  // Creates the parameter pages list
157  m_pageList = new wxListBox( this, ID_FOOTPRINT_WIZARD_PAGE_LIST,
158  wxDefaultPosition, wxDefaultSize,
159  0, NULL, wxLB_HSCROLL );
160 
161  // Creates the The list of parameters for the current parameter page
162  initParameterGrid();
163 
164  ReCreatePageList();
165 
166  DisplayWizardInfos();
167 
168  m_auimgr.SetManagedWindow( this );
169 
170  EDA_PANEINFO horiztb;
171  horiztb.HorizontalToolbarPane();
172 
173  EDA_PANEINFO info;
174  info.InfoToolbarPane();
175 
176  EDA_PANEINFO mesg;
177  mesg.MessageToolbarPane();
178 
179  // Manage main toolbal
180  m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiztb ).
181  Name( wxT ("m_mainToolBar" ) ).Top().Row( 0 ) );
182 
183  // Manage the left window (list of parameter pages)
184  EDA_PANEINFO paneList;
185  paneList.InfoToolbarPane().Name( wxT( "m_pageList" ) ).Left().Row( 0 );
186  m_auimgr.AddPane( m_pageList, wxAuiPaneInfo( paneList ) );
187 
188  // Manage the parameters grid editor for the current parameter page
189  EDA_PANEINFO panePrms;
190  panePrms.InfoToolbarPane().Name( wxT( "m_parameterGrid" ) ).Left().Row( 1 );
191  m_auimgr.AddPane( m_parameterGrid, wxAuiPaneInfo( panePrms ) );
192 
193  // Manage the draw panel
194  m_auimgr.AddPane( m_canvas,
195  wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
196 
197  // Manage the message panel
198  m_auimgr.AddPane( m_messagePanel,
199  wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(1) );
200 
201  // Gives a min size and the last saved size to left windows
202  m_auimgr.GetPane( m_pageList ).MinSize( wxSize(60, -1 ) );
203  m_auimgr.GetPane( m_pageList ).BestSize( wxSize(m_pageListWidth, -1) );
204 
205  m_auimgr.GetPane( m_parameterGrid ).MinSize( wxSize( 120, -1 ) );
206  m_auimgr.GetPane( m_parameterGrid ).BestSize( wxSize(m_parameterGridWidth, -1) );
207 
208  m_auimgr.Update();
209 
210  // Now Drawpanel is sized, we can use BestZoom to show the component (if any)
211 #ifdef USE_WX_GRAPHICS_CONTEXT
212  GetScreen()->SetZoom( BestZoom() );
213 #else
214  Zoom_Automatique( false );
215 #endif
216 
217  // Do not Run a dialog here: on some Window Managers, it creates issues.
218  // Reason: the FOOTPRINT_WIZARD_FRAME is run as modal;
219  // It means the call to FOOTPRINT_WIZARD_FRAME::ShowModal will change the
220  // Event Loop Manager, and stop the one created by the dialog.
221  // It does not happen on all W.M., perhaps due to the way the order events are called
222 // SelectFootprintWizard();
223 }
224 
225 
227 {
228  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
229 
230  if( draw3DFrame )
231  draw3DFrame->Destroy();
232 }
233 
234 
235 void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
236 {
237  if( m_messagesFrame )
239 
240  SaveSettings( config() );
241 
242  if( IsModal() )
243  {
244  // Only dismiss a modal frame once, so that the return values set by
245  // the prior DismissModal() are not bashed for ShowModal().
246  if( !IsDismissed() )
247  DismissModal( false );
248  }
249  else
250  {
251  Destroy();
252  }
253 }
254 
255 
257 {
258  DismissModal( true );
259  Close();
260 }
261 
262 void FOOTPRINT_WIZARD_FRAME::OnGridSize( wxSizeEvent& aSizeEvent )
263 {
264  // Resize the parameter columns
266 
267  aSizeEvent.Skip();
268 }
269 
270 void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv )
271 {
272  if( m_auimgr.GetManagedWindow() )
273  m_auimgr.Update();
274 
275  SizeEv.Skip();
276 }
277 
278 
279 void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
280 {
282  UpdateStatusBar();
283 }
284 
286 {
287  // Prepare the grid where parameters are displayed
288  m_parameterGrid = new wxGrid( this, ID_FOOTPRINT_WIZARD_PARAMETER_LIST );
289  m_parameterGrid->CreateGrid( 0, 3 );
290 
291  // Columns
292  m_parameterGrid->SetColLabelValue( WIZ_COL_NAME, _( "Parameter" ) );
293  m_parameterGrid->SetColLabelValue( WIZ_COL_VALUE, _( "Value" ) );
294  m_parameterGrid->SetColLabelValue( WIZ_COL_UNITS, _( "Units" ) );
295 
296  m_parameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
297  m_parameterGrid->AutoSizeColumns();
298 
299  // Rows
300  m_parameterGrid->AutoSizeRows();
301  m_parameterGrid->SetRowLabelSize( 25 );
302  m_parameterGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
303 
304  m_parameterGrid->DisableDragGridSize();
305  m_parameterGrid->DisableDragColSize();
306 
307  m_parameterGrid->Connect( wxEVT_SIZE, wxSizeEventHandler(FOOTPRINT_WIZARD_FRAME::OnGridSize), NULL, this );
308 }
309 
310 
312 {
313  if( m_pageList == NULL )
314  return;
315 
316  FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
317 
318  if( !footprintWizard )
319  return;
320 
321  m_pageList->Clear();
322  int max_page = footprintWizard->GetNumParameterPages();
323 
324  for( int i = 0; i<max_page; i++ )
325  {
326  wxString name = footprintWizard->GetParameterPageName( i );
327  m_pageList->Append( name );
328  }
329 
330  m_pageList->SetSelection( 0, true );
331 
335  m_canvas->Refresh();
336 }
337 
338 
340 {
341  if( m_parameterGrid == NULL )
342  return;
343 
344  FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
345 
346  if( footprintWizard == NULL )
347  return;
348 
349  int page = m_pageList->GetSelection();
350 
351  if( page<0 )
352  return;
353 
354  m_parameterGrid->ClearGrid();
355 
356  // Get the list of names, values, types, hints and designators
357  wxArrayString designatorsList = footprintWizard->GetParameterDesignators( page );
358  wxArrayString namesList = footprintWizard->GetParameterNames( page );
359  wxArrayString valuesList = footprintWizard->GetParameterValues( page );
360  wxArrayString typesList = footprintWizard->GetParameterTypes( page );
361  wxArrayString hintsList = footprintWizard->GetParameterHints( page );
362 
363  // Dimension the wxGrid
364  if( m_parameterGrid->GetNumberRows() > 0 )
365  m_parameterGrid->DeleteRows( 0, m_parameterGrid->GetNumberRows() );
366 
367  m_parameterGrid->AppendRows( namesList.size() );
368 
369  wxString designator, name, value, units, hint;
370 
371  for( unsigned int i = 0; i< namesList.size(); i++ )
372  {
373  designator = designatorsList[i];
374  name = namesList[i];
375  value = valuesList[i];
376  units = typesList[i];
377  hint = hintsList[i];
378 
379  m_parameterGrid->SetRowLabelValue( i, designator );
380 
381  // Set the 'Name'
382  m_parameterGrid->SetCellValue( i, WIZ_COL_NAME, name );
383  m_parameterGrid->SetReadOnly( i, WIZ_COL_NAME );
384  m_parameterGrid->SetCellAlignment( i, WIZ_COL_NAME, wxALIGN_LEFT, wxALIGN_CENTRE );
385 
386  // Set the editor type of the
387 
388  // Boolean parameters can be displayed using a checkbox
389  if( units == WIZARD_PARAM_UNITS_BOOL )
390  {
391  wxGridCellBoolEditor *boolEditor = new wxGridCellBoolEditor;
392  boolEditor->UseStringValues( "1", "0" );
393  m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, boolEditor );
394  m_parameterGrid->SetCellRenderer( i, WIZ_COL_VALUE, new wxGridCellBoolRenderer );
395  }
396  // Parameters that can be selected from a list of multiple options
397  else if( units.Contains( "," ) ) // Indicates list of available options
398  {
399  wxStringTokenizer tokenizer( units, "," );
400  wxArrayString options;
401 
402  while( tokenizer.HasMoreTokens() )
403  {
404  options.Add( tokenizer.GetNextToken() );
405  }
406 
407  m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellChoiceEditor( options ) );
408 
409  units = wxT( "" );
410  }
411  // Integer parameters
412  else if( units == WIZARD_PARAM_UNITS_INTEGER )
413  {
414  m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellNumberEditor );
415  }
416  // Non-integer numerical parameters
417  else if( ( units == WIZARD_PARAM_UNITS_MM ) ||
418  ( units == WIZARD_PARAM_UNITS_MILS ) ||
419  ( units == WIZARD_PARAM_UNITS_FLOAT ) ||
420  ( units == WIZARD_PARAM_UNITS_RADIANS ) ||
421  ( units == WIZARD_PARAM_UNITS_DEGREES ) ||
422  ( units == WIZARD_PARAM_UNITS_PERCENT ) )
423  {
424  m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellFloatEditor );
425 
426  // Convert separators to the locale-specific character
427  value.Replace( ",", wxNumberFormatter::GetDecimalSeparator() );
428  value.Replace( ".", wxNumberFormatter::GetDecimalSeparator() );
429  }
430 
431  // Set the 'Units'
432  m_parameterGrid->SetCellValue( i, WIZ_COL_UNITS, units );
433  m_parameterGrid->SetReadOnly( i, WIZ_COL_UNITS );
434  m_parameterGrid->SetCellAlignment( i, WIZ_COL_UNITS, wxALIGN_LEFT, wxALIGN_CENTRE );
435 
436  // Set the 'Value'
437  m_parameterGrid->SetCellValue( i, WIZ_COL_VALUE, value );
438  m_parameterGrid->SetCellAlignment( i, WIZ_COL_VALUE, wxALIGN_CENTRE, wxALIGN_CENTRE );
439  }
440 
442 }
443 
445 {
446 
447  // Parameter grid is not yet configured
448  if( ( m_parameterGrid == NULL ) || ( m_parameterGrid->GetNumberCols() == 0 ) )
449  return;
450 
451  // first auto-size the columns to ensure enough space around text
452  m_parameterGrid->AutoSizeColumns();
453 
454  // Auto-size the value column
455  int width = m_parameterGrid->GetClientSize().GetWidth() -
456  m_parameterGrid->GetRowLabelSize() -
457  m_parameterGrid->GetColSize( WIZ_COL_NAME ) -
458  m_parameterGrid->GetColSize( WIZ_COL_UNITS );
459 
460  if( width > m_parameterGrid->GetColMinimalAcceptableWidth() )
461  {
462  m_parameterGrid->SetColSize( WIZ_COL_VALUE, width );
463  }
464 }
465 
466 
467 void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event )
468 {
469  int ii = m_pageList->GetSelection();
470 
471  if( ii < 0 )
472  return;
473 
475  m_canvas->Refresh();
477 }
478 
479 
480 #define PAGE_LIST_WIDTH_KEY wxT( "Fpwizard_Pagelist_width" )
481 #define PARAMLIST_WIDTH_KEY wxT( "Fpwizard_Paramlist_width" )
482 
483 
484 void FOOTPRINT_WIZARD_FRAME::LoadSettings( wxConfigBase* aCfg )
485 {
487 
488  aCfg->Read( PAGE_LIST_WIDTH_KEY, &m_pageListWidth, 100 );
489  aCfg->Read( PARAMLIST_WIDTH_KEY, &m_parameterGridWidth, 200 );
490 
491  // Set parameters to a reasonable value.
492  if( m_pageListWidth > m_FrameSize.x / 3 )
494 
495  if( m_parameterGridWidth > m_FrameSize.x / 2 )
497 }
498 
499 
500 void FOOTPRINT_WIZARD_FRAME::SaveSettings( wxConfigBase* aCfg )
501 {
503 
504  aCfg->Write( PAGE_LIST_WIDTH_KEY, m_pageList->GetSize().x );
505  aCfg->Write( PARAMLIST_WIDTH_KEY, m_parameterGrid->GetSize().x );
506 }
507 
508 
509 void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event )
510 {
512 
513  // Ensure we do not have old selection:
514  if( !event.GetActive() )
515  return;
516 
517 #if 0
518  // Currently, we do not have a way to see if a Python wizard has changed,
519  // therefore the lists of parameters and option has to be rebuilt
520  // This code could be enabled when this way exists
521  bool footprintWizardsChanged = false;
522 
523  if( footprintWizardsChanged )
524  {
525  // If we are here, the library list has changed, rebuild it
528  }
529 #endif
530 }
531 
532 
533 bool FOOTPRINT_WIZARD_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
534 {
535  bool eventHandled = true;
536 
537  // Filter out the 'fake' mouse motion after a keyboard movement
538  if( !aHotKey && m_movingCursorWithKeyboard )
539  {
541  return false;
542  }
543 
544  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
545  cmd.SetEventObject( this );
546 
547  wxPoint pos = aPosition;
548  wxPoint oldpos = GetCrossHairPosition();
549  GeneralControlKeyMovement( aHotKey, &pos, true );
550 
551  switch( aHotKey )
552  {
553  case WXK_F1:
554  cmd.SetId( ID_POPUP_ZOOM_IN );
555  GetEventHandler()->ProcessEvent( cmd );
556  break;
557 
558  case WXK_F2:
559  cmd.SetId( ID_POPUP_ZOOM_OUT );
560  GetEventHandler()->ProcessEvent( cmd );
561  break;
562 
563  case WXK_F3:
564  cmd.SetId( ID_ZOOM_REDRAW );
565  GetEventHandler()->ProcessEvent( cmd );
566  break;
567 
568  case WXK_F4:
569  cmd.SetId( ID_POPUP_ZOOM_CENTER );
570  GetEventHandler()->ProcessEvent( cmd );
571  break;
572 
573  case WXK_HOME:
574  cmd.SetId( ID_ZOOM_PAGE );
575  GetEventHandler()->ProcessEvent( cmd );
576  break;
577 
578  case ' ':
580  break;
581 
582  default:
583  eventHandled = false;
584  }
585 
586  SetCrossHairPosition( pos );
587  RefreshCrossHair( oldpos, aPosition, aDC );
588 
589  UpdateStatusBar(); // Display new cursor coordinates
590 
591  return eventHandled;
592 }
593 
594 
595 void FOOTPRINT_WIZARD_FRAME::Show3D_Frame( wxCommandEvent& event )
596 {
597  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
598 
599  if( draw3DFrame )
600  {
601  // Raising the window does not show the window on Windows if iconized.
602  // This should work on any platform.
603  if( draw3DFrame->IsIconized() )
604  draw3DFrame->Iconize( false );
605 
606  draw3DFrame->Raise();
607 
608  // Raising the window does not set the focus on Linux. This should work on any platform.
609  if( wxWindow::FindFocus() != draw3DFrame )
610  draw3DFrame->SetFocus();
611 
612  return;
613  }
614 
615  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, wxEmptyString );
616  Update3D_Frame( false );
617  draw3DFrame->Raise(); // Needed with some Window Managers
618  draw3DFrame->Show( true );
619 }
620 
621 
627 void FOOTPRINT_WIZARD_FRAME::Update3D_Frame( bool aForceReloadFootprint )
628 {
629  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
630 
631  if( draw3DFrame == NULL )
632  return;
633 
634  wxString frm3Dtitle;
635  frm3Dtitle.Printf( _( "ModView: 3D Viewer [%s]" ), GetChars( m_wizardName ) );
636  draw3DFrame->SetTitle( frm3Dtitle );
637 
638  if( aForceReloadFootprint )
639  {
640  draw3DFrame->ReloadRequest();
641 
642  // Force 3D screen refresh immediately
643  if( GetBoard()->m_Modules )
644  draw3DFrame->NewDisplay();
645  }
646 }
647 
648 
650 {
651  wxString msg;
652 
653  if( !m_mainToolBar )
654  {
655  m_mainToolBar = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
656  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
657 
658  // Set up toolbar
659  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SELECT_WIZARD, wxEmptyString,
660  KiBitmap( module_wizard_xpm ),
661  _( "Select the wizard script to load and run" ) );
662 
663  m_mainToolBar->AddSeparator();
664 
665  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT, wxEmptyString,
666  KiBitmap( reload_xpm ),
667  _( "Reset the wizard parameters to default values ") );
668 
669  m_mainToolBar->AddSeparator();
670 
671  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_PREVIOUS, wxEmptyString,
672  KiBitmap( lib_previous_xpm ),
673  _( "Select previous parameters page" ) );
674 
675  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_NEXT, wxEmptyString,
676  KiBitmap( lib_next_xpm ),
677  _( "Select next parameters page" ) );
678 
679  m_mainToolBar->AddSeparator();
680  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW, wxEmptyString,
681  KiBitmap( three_d_xpm ),
682  _( "Show footprint in 3D viewer" ) );
683 
684  m_mainToolBar->AddSeparator();
685  msg = AddHotkeyName( _( "Zoom in" ), g_Module_Editor_Hokeys_Descr,
687  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString,
688  KiBitmap( zoom_in_xpm ), msg );
689 
690  msg = AddHotkeyName( _( "Zoom out" ), g_Module_Editor_Hokeys_Descr,
692  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString,
693  KiBitmap( zoom_out_xpm ), msg );
694 
695  msg = AddHotkeyName( _( "Redraw view" ), g_Module_Editor_Hokeys_Descr,
697  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString,
698  KiBitmap( zoom_redraw_xpm ), msg );
699 
700  msg = AddHotkeyName( _( "Zoom auto" ), g_Module_Editor_Hokeys_Descr,
702  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
703  KiBitmap( zoom_fit_in_page_xpm ), msg );
704 
705  // The footprint wizard always can export the current footprint
706  m_mainToolBar->AddSeparator();
707  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_DONE,
708  wxEmptyString, KiBitmap( export_footprint_names_xpm ),
709  _( "Export the footprint to the editor" ) );
710 
711  // after adding the buttons to the toolbar, must call Realize() to
712  // reflect the changes
713  m_mainToolBar->Realize();
714  }
715 
716  m_mainToolBar->Refresh();
717 }
718 
719 
721 {
722  // Currently, there is no vertical toolbar
723 }
724 
725 #if defined(KICAD_SCRIPTING)
727 {
728  // Reload the Python plugins
729  // Because the board editor has also a plugin python menu,
730  // call PCB_EDIT_FRAME::PythonPluginsReload() if the board editor
731  // is running
732  PCB_EDIT_FRAME* brd_frame =
733  static_cast<PCB_EDIT_FRAME*>( Kiway().Player( FRAME_PCB, false ) );
734 
735  if( brd_frame )
736  brd_frame->PythonPluginsReload();
737  else
739 }
740 #endif
741 
742 // frame to display messages from footprint builder scripts
744  wxMiniFrame( aParent, wxID_ANY, _( "Footprint Builder Messages" ),
745  wxDefaultPosition, wxDefaultSize,
746  wxCAPTION | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT )
747 {
748  m_canClose = false;
749  wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
750  SetSizer( bSizer );
751 
752  m_messageWindow = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
753  wxDefaultPosition, wxDefaultSize,
754  wxTE_MULTILINE|wxTE_READONLY );
755  bSizer->Add( m_messageWindow, 1, wxEXPAND, 0 );
756 
757  m_config = aCfg;
758 
759  LoadSettings();
760 
761  SetSize( m_position.x, m_position.y, m_size.x, m_size.y );
762 
763  m_messageWindow->SetMinSize( wxSize( 350, 250 ) );
764  Layout();
765 
766  bSizer->SetSizeHints( this );
767 }
768 
769 
771 {
772 }
773 
774 
775 BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_MESSAGES, wxMiniFrame )
776  EVT_CLOSE( FOOTPRINT_WIZARD_MESSAGES::OnCloseMsgWindow )
777 END_EVENT_TABLE()
778 
779 
780 void FOOTPRINT_WIZARD_MESSAGES::OnCloseMsgWindow( wxCloseEvent& aEvent )
781 {
782  if( !m_canClose )
783  aEvent.Veto();
784  else
785  aEvent.Skip();
786 }
787 
788 
789 void FOOTPRINT_WIZARD_MESSAGES::PrintMessage( const wxString& aMessage )
790 {
791  m_messageWindow->SetValue( aMessage );
792 }
793 
794 
796 {
797  m_messageWindow->Clear();
798 }
799 
800 
801 #define MESSAGE_BOX_POSX_KEY wxT( "Fpwizard_Msg_PosX" )
802 #define MESSAGE_BOX_POSY_KEY wxT( "Fpwizard_Msg_PosY" )
803 #define MESSAGE_BOX_SIZEX_KEY wxT( "Fpwizard_Msg_SIZEX" )
804 #define MESSAGE_BOX_SIZEY_KEY wxT( "Fpwizard_Msg_SIZEY" )
805 
807 {
808  if( !IsIconized() )
809  {
810  m_position = GetPosition();
811  m_size = GetSize();
812  }
813 
818 
819  m_canClose = false; // close event now allowed
820 }
821 
822 
824 {
825  m_config->Read( MESSAGE_BOX_POSX_KEY, &m_position.x, -1 );
826  m_config->Read( MESSAGE_BOX_POSY_KEY, &m_position.y, -1 );
827  m_config->Read( MESSAGE_BOX_SIZEX_KEY, &m_size.x, 350 );
828  m_config->Read( MESSAGE_BOX_SIZEY_KEY, &m_size.y, 250 );
829 }
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:474
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Definition: wxstruct.h:55
Class FOOTPRINT_WIZARD_FRAME.
Definition of class FOOTPRINT_EDIT_FRAME.
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
const wxString WIZARD_PARAM_UNITS_MILS
void DisplayWizardInfos()
Function DisplayWizardInfos Shows all the details about the current wizard.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
#define MESSAGE_BOX_POSX_KEY
Implementation of conversion functions that require both schematic and board internal units...
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
Class BOARD to handle a board.
show a marker on pads with no nets
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.
Definition: id.h:232
FOOTPRINT_WIZARD_MESSAGES * m_messagesFrame
virtual wxArrayString GetParameterTypes(int aPage)=0
Function GetParameterTypes.
int m_parameterGridWidth
size of the grid
#define MESSAGE_BOX_SIZEX_KEY
const wxString WIZARD_PARAM_UNITS_BOOL
BOARD * GetBoard() const
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: basicframe.cpp:361
void SetVisibleAlls()
Function SetVisibleAlls changes the bit-mask of visible element categories and layers.
#define MESSAGE_BOX_SIZEY_KEY
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
Definition: wxstruct.h:139
virtual wxArrayString GetParameterNames(int aPage)=0
Function GetParameterNames.
void initParameterGrid()
Function initParameterGrid Prepare the grid where parameters are displayed.
const wxString WIZARD_PARAM_UNITS_RADIANS
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:53
const wxString WIZARD_PARAM_UNITS_PERCENT
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: draw_frame.cpp:713
void ClickOnPageList(wxCommandEvent &event)
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:465
Pcbnew hotkeys.
This file contains miscellaneous commonly used macros and functions.
EVT_MENU(ID_SELECT_PREFERED_PDF_BROWSER_NAME, KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser) EVT_MENU_RANGE(ID_PREFERENCES_HOTKEY_START
void ReCreateParameterList()
Function ReCreateParameterList Creates the list of parameters for the current page.
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:36
wxGrid * m_parameterGrid
The list of parameters.
void ReCreatePageList()
Function ReCreatePageList Creates or recreates the list of parameter pages for the current wizard...
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 wxArrayString GetParameterDesignators(int aPage)=0
Function GetParamaterDesignators.
void RefreshCrossHair(const wxPoint &aOldPos, const wxPoint &aEvtPos, wxDC *aDC)
PCB_VISIBLE
Enum PCB_VISIBLE is a set of visible PCB elements.
FOOTPRINT_WIZARD_FRAME(KIWAY *aKiway, wxWindow *parent, FRAME_T aFrameType)
const wxString WIZARD_PARAM_UNITS_INTEGER
The common library.
int m_pageListWidth
width of the window
void PrintMessage(const wxString &aMessage)
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
#define PARAMLIST_WIDTH_KEY
#define FOOTPRINT_WIZARD_FRAME_NAME
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:216
FOOTPRINT_WIZARD * GetMyWizard()
Function GetMyWizard Reloads the wizard by name.
EDA_PANEINFO & InfoToolbarPane()
Function InfoToolbarPane Change *this to a information panel for for KiCad.
Definition: wxstruct.h:539
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:135
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:686
void OnSize(wxSizeEvent &event) override
Function OnSize recalculates the size of toolbars and display panel when the frame size changes...
void NewDisplay(int dummy=0)
Definition: eda_3d_viewer.h:71
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
BOARD * GetBoard()
void SetElementVisibility(int aPCB_VISIBLE, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:92
void PythonPluginsReloadBase()
Helper function PythonPluginsReloadBase Reload Python plugins if they are newer than the already load...
Definition: pcbnew.cpp:299
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.
Definition: wxstruct.h:511
struct EDA_HOTKEY_CONFIG g_Module_Editor_Hokeys_Descr[]
bool m_DisplayPadIsol
Definition: pcbstruct.h:68
FOOTPRINT_WIZARD_MESSAGES(FOOTPRINT_WIZARD_FRAME *aParent, wxConfigBase *aCfg)
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.
void GeneralControlKeyMovement(int aHotKey, wxPoint *aPos, bool aSnapToGrid)
Function GeneralControlKeyMovement Handle the common part of GeneralControl dedicated to global curso...
const wxString WIZARD_PARAM_UNITS_DEGREES
void DismissModal(bool aRetVal, const wxString &aResult=wxEmptyString)
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
#define MODAL_MODE_EXTRASTYLE
bool m_DisplayPadNum
Definition: pcbstruct.h:67
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...
const wxString WIZARD_PARAM_UNITS_FLOAT
void OnSetRelativeOffset(wxCommandEvent &event)
void OnGridSize(wxSizeEvent &aSizeEvent)
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
const wxString WIZARD_PARAM_UNITS_MM
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.
wxSize m_FrameSize
Definition: wxstruct.h:130
Module description (excepted pads)
#define PAGE_LIST_WIDTH_KEY
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...
Message panel definition file.
void PythonPluginsReload()
Reload the Python plugins if they are newer than the already loaded, and load new plugins if any Do n...
Definition: pcbframe.cpp:1179
void ResizeParamColumns()
Expand the 'Value' 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:257
bool m_movingCursorWithKeyboard
One-shot to avoid a recursive mouse event during hotkey movement.
Definition: draw_frame.h:138
#define MESSAGE_BOX_POSY_KEY
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...
struct EDA_HOTKEY_CONFIG g_Module_Viewer_Hokeys_Descr[]