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  auto disp_opts = (PCB_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  SetActiveLayer( F_Cu );
156 
157  // Creates the parameter pages list
158  m_pageList = new wxListBox( this, ID_FOOTPRINT_WIZARD_PAGE_LIST,
159  wxDefaultPosition, wxDefaultSize,
160  0, NULL, wxLB_HSCROLL );
161 
162  // Creates the The list of parameters for the current parameter page
163  initParameterGrid();
164 
165  ReCreatePageList();
166 
167  DisplayWizardInfos();
168 
169  m_auimgr.SetManagedWindow( this );
170 
171  EDA_PANEINFO horiztb;
172  horiztb.HorizontalToolbarPane();
173 
174  EDA_PANEINFO info;
175  info.InfoToolbarPane();
176 
177  EDA_PANEINFO mesg;
178  mesg.MessageToolbarPane();
179 
180  // Manage main toolbal
181  m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiztb ).
182  Name( wxT ("m_mainToolBar" ) ).Top().Row( 0 ) );
183 
184  // Manage the left window (list of parameter pages)
185  EDA_PANEINFO paneList;
186  paneList.InfoToolbarPane().Name( wxT( "m_pageList" ) ).Left().Row( 0 );
187  m_auimgr.AddPane( m_pageList, wxAuiPaneInfo( paneList ) );
188 
189  // Manage the parameters grid editor for the current parameter page
190  EDA_PANEINFO panePrms;
191  panePrms.InfoToolbarPane().Name( wxT( "m_parameterGrid" ) ).Left().Row( 1 );
192  m_auimgr.AddPane( m_parameterGrid, wxAuiPaneInfo( panePrms ) );
193 
194  // Manage the draw panel
195  m_auimgr.AddPane( m_canvas,
196  wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
197 
198  // Manage the message panel
199  m_auimgr.AddPane( m_messagePanel,
200  wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(1) );
201 
202  // Gives a min size and the last saved size to left windows
203  m_auimgr.GetPane( m_pageList ).MinSize( wxSize(60, -1 ) );
204  m_auimgr.GetPane( m_pageList ).BestSize( wxSize(m_pageListWidth, -1) );
205 
206  m_auimgr.GetPane( m_parameterGrid ).MinSize( wxSize( 120, -1 ) );
207  m_auimgr.GetPane( m_parameterGrid ).BestSize( wxSize(m_parameterGridWidth, -1) );
208 
209  m_auimgr.Update();
210 
211  // Now Drawpanel is sized, we can use BestZoom to show the component (if any)
212 #ifdef USE_WX_GRAPHICS_CONTEXT
213  GetScreen()->SetZoom( BestZoom() );
214 #else
215  Zoom_Automatique( false );
216 #endif
217 
218  // Do not Run a dialog here: on some Window Managers, it creates issues.
219  // Reason: the FOOTPRINT_WIZARD_FRAME is run as modal;
220  // It means the call to FOOTPRINT_WIZARD_FRAME::ShowModal will change the
221  // Event Loop Manager, and stop the one created by the dialog.
222  // It does not happen on all W.M., perhaps due to the way the order events are called
223 // SelectFootprintWizard();
224 }
225 
226 
228 {
229  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
230 
231  if( draw3DFrame )
232  draw3DFrame->Destroy();
233 }
234 
235 
236 void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
237 {
238  if( m_messagesFrame )
240 
241  SaveSettings( config() );
242 
243  if( IsModal() )
244  {
245  // Only dismiss a modal frame once, so that the return values set by
246  // the prior DismissModal() are not bashed for ShowModal().
247  if( !IsDismissed() )
248  DismissModal( false );
249  }
250  else
251  {
252  Destroy();
253  }
254 }
255 
256 
258 {
259  DismissModal( true );
260  Close();
261 }
262 
263 void FOOTPRINT_WIZARD_FRAME::OnGridSize( wxSizeEvent& aSizeEvent )
264 {
265  // Resize the parameter columns
267 
268  aSizeEvent.Skip();
269 }
270 
271 void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv )
272 {
273  if( m_auimgr.GetManagedWindow() )
274  m_auimgr.Update();
275 
276  SizeEv.Skip();
277 }
278 
279 
280 void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
281 {
283  UpdateStatusBar();
284 }
285 
287 {
288  // Prepare the grid where parameters are displayed
289  m_parameterGrid = new wxGrid( this, ID_FOOTPRINT_WIZARD_PARAMETER_LIST );
290  m_parameterGrid->CreateGrid( 0, 3 );
291 
292  // Columns
293  m_parameterGrid->SetColLabelValue( WIZ_COL_NAME, _( "Parameter" ) );
294  m_parameterGrid->SetColLabelValue( WIZ_COL_VALUE, _( "Value" ) );
295  m_parameterGrid->SetColLabelValue( WIZ_COL_UNITS, _( "Units" ) );
296 
297  m_parameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
298  m_parameterGrid->AutoSizeColumns();
299 
300  // Rows
301  m_parameterGrid->AutoSizeRows();
302  m_parameterGrid->SetRowLabelSize( 25 );
303  m_parameterGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
304 
305  m_parameterGrid->DisableDragGridSize();
306  m_parameterGrid->DisableDragColSize();
307 
308  m_parameterGrid->Connect( wxEVT_SIZE, wxSizeEventHandler(FOOTPRINT_WIZARD_FRAME::OnGridSize), NULL, this );
309 }
310 
311 
313 {
314  if( m_pageList == NULL )
315  return;
316 
317  FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
318 
319  if( !footprintWizard )
320  return;
321 
322  m_pageList->Clear();
323  int max_page = footprintWizard->GetNumParameterPages();
324 
325  for( int i = 0; i<max_page; i++ )
326  {
327  wxString name = footprintWizard->GetParameterPageName( i );
328  m_pageList->Append( name );
329  }
330 
331  m_pageList->SetSelection( 0, true );
332 
336  m_canvas->Refresh();
337 }
338 
339 
341 {
342  if( m_parameterGrid == NULL )
343  return;
344 
345  FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
346 
347  if( footprintWizard == NULL )
348  return;
349 
350  int page = m_pageList->GetSelection();
351 
352  if( page<0 )
353  return;
354 
355  m_parameterGrid->ClearGrid();
356 
357  // Get the list of names, values, types, hints and designators
358  wxArrayString designatorsList = footprintWizard->GetParameterDesignators( page );
359  wxArrayString namesList = footprintWizard->GetParameterNames( page );
360  wxArrayString valuesList = footprintWizard->GetParameterValues( page );
361  wxArrayString typesList = footprintWizard->GetParameterTypes( page );
362  wxArrayString hintsList = footprintWizard->GetParameterHints( page );
363 
364  // Dimension the wxGrid
365  if( m_parameterGrid->GetNumberRows() > 0 )
366  m_parameterGrid->DeleteRows( 0, m_parameterGrid->GetNumberRows() );
367 
368  m_parameterGrid->AppendRows( namesList.size() );
369 
370  wxString designator, name, value, units, hint;
371 
372  for( unsigned int i = 0; i< namesList.size(); i++ )
373  {
374  designator = designatorsList[i];
375  name = namesList[i];
376  value = valuesList[i];
377  units = typesList[i];
378  hint = hintsList[i];
379 
380  m_parameterGrid->SetRowLabelValue( i, designator );
381 
382  // Set the 'Name'
383  m_parameterGrid->SetCellValue( i, WIZ_COL_NAME, name );
384  m_parameterGrid->SetReadOnly( i, WIZ_COL_NAME );
385  m_parameterGrid->SetCellAlignment( i, WIZ_COL_NAME, wxALIGN_LEFT, wxALIGN_CENTRE );
386 
387  // Set the editor type of the
388 
389  // Boolean parameters can be displayed using a checkbox
390  if( units == WIZARD_PARAM_UNITS_BOOL )
391  {
392  wxGridCellBoolEditor *boolEditor = new wxGridCellBoolEditor;
393  boolEditor->UseStringValues( "1", "0" );
394  m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, boolEditor );
395  m_parameterGrid->SetCellRenderer( i, WIZ_COL_VALUE, new wxGridCellBoolRenderer );
396  }
397  // Parameters that can be selected from a list of multiple options
398  else if( units.Contains( "," ) ) // Indicates list of available options
399  {
400  wxStringTokenizer tokenizer( units, "," );
401  wxArrayString options;
402 
403  while( tokenizer.HasMoreTokens() )
404  {
405  options.Add( tokenizer.GetNextToken() );
406  }
407 
408  m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellChoiceEditor( options ) );
409 
410  units = wxT( "" );
411  }
412  // Integer parameters
413  else if( units == WIZARD_PARAM_UNITS_INTEGER )
414  {
415  m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellNumberEditor );
416  }
417  // Non-integer numerical parameters
418  else if( ( units == WIZARD_PARAM_UNITS_MM ) ||
419  ( units == WIZARD_PARAM_UNITS_MILS ) ||
420  ( units == WIZARD_PARAM_UNITS_FLOAT ) ||
421  ( units == WIZARD_PARAM_UNITS_RADIANS ) ||
422  ( units == WIZARD_PARAM_UNITS_DEGREES ) ||
423  ( units == WIZARD_PARAM_UNITS_PERCENT ) )
424  {
425  m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellFloatEditor );
426 
427  // Convert separators to the locale-specific character
428  value.Replace( ",", wxNumberFormatter::GetDecimalSeparator() );
429  value.Replace( ".", wxNumberFormatter::GetDecimalSeparator() );
430  }
431 
432  // Set the 'Units'
433  m_parameterGrid->SetCellValue( i, WIZ_COL_UNITS, units );
434  m_parameterGrid->SetReadOnly( i, WIZ_COL_UNITS );
435  m_parameterGrid->SetCellAlignment( i, WIZ_COL_UNITS, wxALIGN_LEFT, wxALIGN_CENTRE );
436 
437  // Set the 'Value'
438  m_parameterGrid->SetCellValue( i, WIZ_COL_VALUE, value );
439  m_parameterGrid->SetCellAlignment( i, WIZ_COL_VALUE, wxALIGN_CENTRE, wxALIGN_CENTRE );
440  }
441 
443 }
444 
446 {
447 
448  // Parameter grid is not yet configured
449  if( ( m_parameterGrid == NULL ) || ( m_parameterGrid->GetNumberCols() == 0 ) )
450  return;
451 
452  // first auto-size the columns to ensure enough space around text
453  m_parameterGrid->AutoSizeColumns();
454 
455  // Auto-size the value column
456  int width = m_parameterGrid->GetClientSize().GetWidth() -
457  m_parameterGrid->GetRowLabelSize() -
458  m_parameterGrid->GetColSize( WIZ_COL_NAME ) -
459  m_parameterGrid->GetColSize( WIZ_COL_UNITS );
460 
461  if( width > m_parameterGrid->GetColMinimalAcceptableWidth() )
462  {
463  m_parameterGrid->SetColSize( WIZ_COL_VALUE, width );
464  }
465 }
466 
467 
468 void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event )
469 {
470  int ii = m_pageList->GetSelection();
471 
472  if( ii < 0 )
473  return;
474 
476  m_canvas->Refresh();
478 }
479 
480 
481 #define PAGE_LIST_WIDTH_KEY wxT( "Fpwizard_Pagelist_width" )
482 #define PARAMLIST_WIDTH_KEY wxT( "Fpwizard_Paramlist_width" )
483 
484 
485 void FOOTPRINT_WIZARD_FRAME::LoadSettings( wxConfigBase* aCfg )
486 {
488 
489  aCfg->Read( PAGE_LIST_WIDTH_KEY, &m_pageListWidth, 100 );
490  aCfg->Read( PARAMLIST_WIDTH_KEY, &m_parameterGridWidth, 200 );
491 
492  // Set parameters to a reasonable value.
493  if( m_pageListWidth > m_FrameSize.x / 3 )
495 
496  if( m_parameterGridWidth > m_FrameSize.x / 2 )
498 }
499 
500 
501 void FOOTPRINT_WIZARD_FRAME::SaveSettings( wxConfigBase* aCfg )
502 {
504 
505  aCfg->Write( PAGE_LIST_WIDTH_KEY, m_pageList->GetSize().x );
506  aCfg->Write( PARAMLIST_WIDTH_KEY, m_parameterGrid->GetSize().x );
507 }
508 
509 
510 void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event )
511 {
513 
514  // Ensure we do not have old selection:
515  if( !event.GetActive() )
516  return;
517 
518 #if 0
519  // Currently, we do not have a way to see if a Python wizard has changed,
520  // therefore the lists of parameters and option has to be rebuilt
521  // This code could be enabled when this way exists
522  bool footprintWizardsChanged = false;
523 
524  if( footprintWizardsChanged )
525  {
526  // If we are here, the library list has changed, rebuild it
529  }
530 #endif
531 }
532 
533 
534 bool FOOTPRINT_WIZARD_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
535 {
536  // Filter out the 'fake' mouse motion after a keyboard movement
537  if( !aHotKey && m_movingCursorWithKeyboard )
538  {
540  return false;
541  }
542 
543  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
544  cmd.SetEventObject( this );
545 
546  wxPoint pos = aPosition;
547  wxPoint oldpos = GetCrossHairPosition();
548  bool keyHandled = GeneralControlKeyMovement( aHotKey, &pos, true );
549 
550  switch( aHotKey )
551  {
552  case WXK_F1:
553  cmd.SetId( ID_POPUP_ZOOM_IN );
554  GetEventHandler()->ProcessEvent( cmd );
555  keyHandled = true;
556  break;
557 
558  case WXK_F2:
559  cmd.SetId( ID_POPUP_ZOOM_OUT );
560  GetEventHandler()->ProcessEvent( cmd );
561  keyHandled = true;
562  break;
563 
564  case WXK_F3:
565  cmd.SetId( ID_ZOOM_REDRAW );
566  GetEventHandler()->ProcessEvent( cmd );
567  keyHandled = true;
568  break;
569 
570  case WXK_F4:
571  cmd.SetId( ID_POPUP_ZOOM_CENTER );
572  GetEventHandler()->ProcessEvent( cmd );
573  keyHandled = true;
574  break;
575 
576  case WXK_HOME:
577  cmd.SetId( ID_ZOOM_PAGE );
578  GetEventHandler()->ProcessEvent( cmd );
579  keyHandled = true;
580  break;
581 
582  case ' ':
584  keyHandled = true;
585  break;
586 
587  default:
588  break;
589  }
590 
591  SetCrossHairPosition( pos );
592  RefreshCrossHair( oldpos, aPosition, aDC );
593 
594  UpdateStatusBar(); // Display new cursor coordinates
595 
596  return keyHandled;
597 }
598 
599 
600 void FOOTPRINT_WIZARD_FRAME::Show3D_Frame( wxCommandEvent& event )
601 {
602  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
603 
604  if( draw3DFrame )
605  {
606  // Raising the window does not show the window on Windows if iconized.
607  // This should work on any platform.
608  if( draw3DFrame->IsIconized() )
609  draw3DFrame->Iconize( false );
610 
611  draw3DFrame->Raise();
612 
613  // Raising the window does not set the focus on Linux. This should work on any platform.
614  if( wxWindow::FindFocus() != draw3DFrame )
615  draw3DFrame->SetFocus();
616 
617  return;
618  }
619 
620  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, wxEmptyString );
621  Update3D_Frame( false );
622  draw3DFrame->Raise(); // Needed with some Window Managers
623  draw3DFrame->Show( true );
624 }
625 
626 
632 void FOOTPRINT_WIZARD_FRAME::Update3D_Frame( bool aForceReloadFootprint )
633 {
634  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
635 
636  if( draw3DFrame == NULL )
637  return;
638 
639  wxString frm3Dtitle;
640  frm3Dtitle.Printf( _( "ModView: 3D Viewer [%s]" ), GetChars( m_wizardName ) );
641  draw3DFrame->SetTitle( frm3Dtitle );
642 
643  if( aForceReloadFootprint )
644  {
645  // Force 3D screen refresh immediately
646  draw3DFrame->NewDisplay( true );
647  }
648 }
649 
650 
652 {
653  wxString msg;
654 
655  if( !m_mainToolBar )
656  {
657  m_mainToolBar = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
658  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
659 
660  // Set up toolbar
661  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SELECT_WIZARD, wxEmptyString,
662  KiBitmap( module_wizard_xpm ),
663  _( "Select wizard script to run" ) );
664 
665  m_mainToolBar->AddSeparator();
666 
667  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT, wxEmptyString,
668  KiBitmap( reload_xpm ),
669  _( "Reset wizard parameters to default") );
670 
671  m_mainToolBar->AddSeparator();
672 
673  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_PREVIOUS, wxEmptyString,
674  KiBitmap( lib_previous_xpm ),
675  _( "Select previous parameters page" ) );
676 
677  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_NEXT, wxEmptyString,
678  KiBitmap( lib_next_xpm ),
679  _( "Select next parameters page" ) );
680 
681  m_mainToolBar->AddSeparator();
682  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW, wxEmptyString,
683  KiBitmap( three_d_xpm ),
684  _( "Show footprint in 3D viewer" ) );
685 
686  m_mainToolBar->AddSeparator();
687  msg = AddHotkeyName( _( "Zoom in" ), g_Module_Editor_Hokeys_Descr,
689  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString,
690  KiBitmap( zoom_in_xpm ), msg );
691 
692  msg = AddHotkeyName( _( "Zoom out" ), g_Module_Editor_Hokeys_Descr,
694  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString,
695  KiBitmap( zoom_out_xpm ), msg );
696 
697  msg = AddHotkeyName( _( "Redraw view" ), g_Module_Editor_Hokeys_Descr,
699  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString,
700  KiBitmap( zoom_redraw_xpm ), msg );
701 
702  msg = AddHotkeyName( _( "Zoom auto" ), g_Module_Editor_Hokeys_Descr,
704  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
705  KiBitmap( zoom_fit_in_page_xpm ), msg );
706 
707  // The footprint wizard always can export the current footprint
708  m_mainToolBar->AddSeparator();
709  m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_DONE,
710  wxEmptyString, KiBitmap( export_footprint_names_xpm ),
711  _( "Export footprint to editor" ) );
712 
713  // after adding the buttons to the toolbar, must call Realize() to
714  // reflect the changes
715  m_mainToolBar->Realize();
716  }
717 
718  m_mainToolBar->Refresh();
719 }
720 
721 
723 {
724  // Currently, there is no vertical toolbar
725 }
726 
727 #if defined(KICAD_SCRIPTING)
729 {
730  // Reload the Python plugins
731  // Because the board editor has also a plugin python menu,
732  // call PCB_EDIT_FRAME::PythonPluginsReload() if the board editor
733  // is running
734  PCB_EDIT_FRAME* brd_frame =
735  static_cast<PCB_EDIT_FRAME*>( Kiway().Player( FRAME_PCB, false ) );
736 
737  if( brd_frame )
738  brd_frame->PythonPluginsReload();
739  else
741 }
742 #endif
743 
744 // frame to display messages from footprint builder scripts
746  wxMiniFrame( aParent, wxID_ANY, _( "Footprint Builder Messages" ),
747  wxDefaultPosition, wxDefaultSize,
748  wxCAPTION | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT )
749 {
750  m_canClose = false;
751  wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
752  SetSizer( bSizer );
753 
754  m_messageWindow = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
755  wxDefaultPosition, wxDefaultSize,
756  wxTE_MULTILINE|wxTE_READONLY );
757  bSizer->Add( m_messageWindow, 1, wxEXPAND, 0 );
758 
759  m_config = aCfg;
760 
761  LoadSettings();
762 
763  SetSize( m_position.x, m_position.y, m_size.x, m_size.y );
764 
765  m_messageWindow->SetMinSize( wxSize( 350, 250 ) );
766  Layout();
767 
768  bSizer->SetSizeHints( this );
769 }
770 
771 
773 {
774 }
775 
776 
777 BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_MESSAGES, wxMiniFrame )
778  EVT_CLOSE( FOOTPRINT_WIZARD_MESSAGES::OnCloseMsgWindow )
779 END_EVENT_TABLE()
780 
781 
782 void FOOTPRINT_WIZARD_MESSAGES::OnCloseMsgWindow( wxCloseEvent& aEvent )
783 {
784  if( !m_canClose )
785  aEvent.Veto();
786  else
787  aEvent.Skip();
788 }
789 
790 
791 void FOOTPRINT_WIZARD_MESSAGES::PrintMessage( const wxString& aMessage )
792 {
793  m_messageWindow->SetValue( aMessage );
794 }
795 
796 
798 {
799  m_messageWindow->Clear();
800 }
801 
802 
803 #define MESSAGE_BOX_POSX_KEY wxT( "Fpwizard_Msg_PosX" )
804 #define MESSAGE_BOX_POSY_KEY wxT( "Fpwizard_Msg_PosY" )
805 #define MESSAGE_BOX_SIZEX_KEY wxT( "Fpwizard_Msg_SIZEX" )
806 #define MESSAGE_BOX_SIZEY_KEY wxT( "Fpwizard_Msg_SIZEY" )
807 
809 {
810  if( !IsIconized() )
811  {
812  m_position = GetPosition();
813  m_size = GetSize();
814  }
815 
820 
821  m_canClose = false; // close event now allowed
822 }
823 
824 
826 {
827  m_config->Read( MESSAGE_BOX_POSX_KEY, &m_position.x, -1 );
828  m_config->Read( MESSAGE_BOX_POSY_KEY, &m_position.y, -1 );
829  m_config->Read( MESSAGE_BOX_SIZEX_KEY, &m_size.x, 350 );
830  m_config->Read( MESSAGE_BOX_SIZEY_KEY, &m_size.y, 250 );
831 }
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:487
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Definition: wxstruct.h:55
Class FOOTPRINT_WIZARD_FRAME.
Definition of class FOOTPRINT_EDIT_FRAME.
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.
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
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:332
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.
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
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: basicframe.cpp:380
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:149
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:54
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:746
void ClickOnPageList(wxCommandEvent &event)
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:478
Pcbnew hotkeys.
This file contains miscellaneous commonly used macros and functions.
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:36
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...
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)
Move and refresh the crosshair after movement and call the mouse capture function.
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)
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:259
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:552
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:145
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:716
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:93
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.
Definition: wxstruct.h:524
struct EDA_HOTKEY_CONFIG g_Module_Editor_Hokeys_Descr[]
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.
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: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...
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
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
Definition: wxstruct.h:168
const char * name
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:140
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 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...
Definition: pcbframe.cpp:1210
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:268
bool m_movingCursorWithKeyboard
One-shot to avoid a recursive mouse event during hotkey movement.
Definition: draw_frame.h:139
#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[]