KiCad PCB EDA Suite
schframe.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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
29 #include <fctsys.h>
30 #include <kiface_i.h>
31 #include <pgm_base.h>
32 #include <gr_basic.h>
33 #include <class_drawpanel.h>
34 #include <gestfich.h>
35 #include <confirm.h>
36 #include <base_units.h>
37 #include <msgpanel.h>
38 #include <html_messagebox.h>
39 #include <executable_names.h>
40 
41 #include <general.h>
42 #include <eeschema_id.h>
43 #include <netlist.h>
44 #include <lib_pin.h>
45 #include <class_library.h>
46 #include <schframe.h>
47 #include <sch_component.h>
48 #include <symbol_lib_table.h>
49 
50 #include <dialog_helpers.h>
51 #include <libeditframe.h>
52 #include <viewlib_frame.h>
53 #include <hotkeys.h>
54 #include <eeschema_config.h>
55 #include <sch_sheet.h>
56 #include <sch_sheet_path.h>
57 #include "sim/sim_plot_frame.h"
58 
59 #include <invoke_sch_dialog.h>
61 #include <dialog_symbol_remap.h>
62 
63 #include <wx/display.h>
64 #include <build_version.h>
66 
67 #include <netlist_exporter_kicad.h>
68 #include <kiway.h>
69 
70 
71 // non-member so it can be moved easily, and kept REALLY private.
72 // Do NOT Clear() in here.
73 static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
74 {
75  for( unsigned i=0; i<aSrc.GetCount(); ++i )
76  aDst->AddPaths( aSrc[i], aIndex );
77 }
78 
79 
80 // non-member so it can be moved easily, and kept REALLY private.
81 // Do NOT Clear() in here.
82 static void add_search_paths( SEARCH_STACK* aDst, wxConfigBase* aCfg, int aIndex )
83 {
84  for( int i=1; true; ++i )
85  {
86  wxString key = wxString::Format( wxT( "LibraryPath%d" ), i );
87  wxString upath = aCfg->Read( key, wxEmptyString );
88 
89  if( !upath )
90  break;
91 
92  aDst->AddPaths( upath, aIndex );
93  }
94 }
95 
96 //-----<SCH "data on demand" functions>-------------------------------------------
97 
98 SEARCH_STACK* PROJECT::SchSearchS()
99 {
101 
102  wxASSERT( !ss || dynamic_cast<SEARCH_STACK*>( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
103 
104  if( !ss )
105  {
106  ss = new SEARCH_STACK();
107 
108  // Make PROJECT the new SEARCH_STACK owner.
110 
111  // to the empty SEARCH_STACK for SchSearchS(), add project dir as first
112  ss->AddPaths( m_project_name.GetPath() );
113 
114  // next add the paths found in *.pro, variable "LibDir"
115  wxString libDir;
116 
117  try
118  {
119  PART_LIBS::LibNamesAndPaths( this, false, &libDir );
120  }
121  catch( const IO_ERROR& DBG( ioe ) )
122  {
123  DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.What() ) );)
124  }
125 
126  if( !!libDir )
127  {
128  wxArrayString paths;
129 
130  SEARCH_STACK::Split( &paths, libDir );
131 
132  for( unsigned i =0; i<paths.GetCount(); ++i )
133  {
134  wxString path = AbsolutePath( paths[i] );
135 
136  ss->AddPaths( path ); // at the end
137  }
138  }
139 
140  // append all paths from aSList
141  add_search_paths( ss, Kiface().KifaceSearch(), -1 );
142 
143  // addLibrarySearchPaths( SEARCH_STACK* aSP, wxConfigBase* aCfg )
144  // This is undocumented, but somebody wanted to store !schematic!
145  // library search paths in the .kicad_common file?
146  add_search_paths( ss, Pgm().CommonSettings(), -1 );
147  }
148 
149  return ss;
150 }
151 
152 
153 PART_LIBS* PROJECT::SchLibs()
154 {
156 
157  wxASSERT( !libs || dynamic_cast<PART_LIBS*>( libs ) );
158 
159  if( !libs )
160  {
161  libs = new PART_LIBS();
162 
163  // Make PROJECT the new PART_LIBS owner.
165 
166  try
167  {
168  libs->LoadAllLibraries( this );
169  }
170  catch( const PARSE_ERROR& pe )
171  {
172  wxString lib_list = UTF8( pe.inputLine );
173  wxWindow* parent = 0; // Pgm().App().GetTopWindow();
174 
175  // parent of this dialog cannot be NULL since that breaks the Kiway() chain.
176  HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
177 
178  dlg.MessageSet( _( "The following libraries were not found:" ) );
179 
180  dlg.ListSet( lib_list );
181 
182  dlg.Layout();
183 
184  dlg.ShowModal();
185  }
186  catch( const IO_ERROR& ioe )
187  {
188  DisplayError( NULL, ioe.What() );
189  }
190  }
191 
192  return libs;
193 }
194 
195 /*
196 NETLIST_OBJECT_LIST* PROJECT::Netlist()
197 {
198  NETLIST_OBJECT_LIST* netlist = (NETLIST_OBJECT_LIST*) GetElem( PROJECT::ELEM_SCH_NETLIST );
199 
200  wxASSERT( !libs || dynamic_cast<NETLIST_OBJECT_LIST*>( netlist ) );
201 
202  if( !netlist )
203  {
204  netlist = new NETLIST_OBJECT_LIST();
205 
206  // Make PROJECT the new NETLIST_OBJECT_LIST owner.
207  SetElem( PROJECT::ELEM_SCH_NETLIST, netlist );
208  }
209 }
210 */
211 
212 //-----</SCH "data on demand" functions>------------------------------------------
213 
214 
215 BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
216  EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, EDA_DRAW_FRAME::OnSockRequestServer )
217  EVT_SOCKET( ID_EDA_SOCKET_EVENT, EDA_DRAW_FRAME::OnSockRequest )
218 
219  EVT_CLOSE( SCH_EDIT_FRAME::OnCloseWindow )
220  EVT_SIZE( SCH_EDIT_FRAME::OnSize )
221 
222  EVT_MENU( ID_NEW_PROJECT, SCH_EDIT_FRAME::OnNewProject )
223  EVT_MENU( ID_LOAD_PROJECT, SCH_EDIT_FRAME::OnLoadProject )
224 
225  EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, SCH_EDIT_FRAME::OnLoadFile )
226 
227  EVT_MENU( ID_APPEND_PROJECT, SCH_EDIT_FRAME::OnAppendProject )
228  EVT_MENU( ID_IMPORT_NON_KICAD_SCH, SCH_EDIT_FRAME::OnImportProject )
229 
230  EVT_TOOL( ID_NEW_PROJECT, SCH_EDIT_FRAME::OnNewProject )
231  EVT_TOOL( ID_LOAD_PROJECT, SCH_EDIT_FRAME::OnLoadProject )
232 
233  EVT_MENU( ID_SAVE_PROJECT, SCH_EDIT_FRAME::OnSaveProject )
238  EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
239  EVT_MENU( ID_POPUP_SCH_SELECT_ON_PCB, SCH_EDIT_FRAME::SelectAllFromSheet )
240 
241  EVT_MENU( ID_POPUP_SCH_DUPLICATE_ITEM, SCH_EDIT_FRAME::OnCopySchematicItemRequest )
242 
243  EVT_MENU( ID_CONFIG_SAVE, SCH_EDIT_FRAME::Process_Config )
244  EVT_MENU( ID_CONFIG_READ, SCH_EDIT_FRAME::Process_Config )
246  SCH_EDIT_FRAME::Process_Config )
247 
248  EVT_TOOL( wxID_PREFERENCES, SCH_EDIT_FRAME::OnPreferencesOptions )
249 
250  EVT_TOOL( ID_RUN_LIBRARY, SCH_EDIT_FRAME::OnOpenLibraryEditor )
252  EVT_TOOL( ID_TO_LIBVIEW, SCH_EDIT_FRAME::OnOpenLibraryViewer )
253  EVT_TOOL( ID_RESCUE_CACHED, SCH_EDIT_FRAME::OnRescueProject )
254  EVT_MENU( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnRemapSymbols )
255  EVT_MENU( ID_EDIT_COMPONENTS_TO_SYMBOLS_LIB_ID, SCH_EDIT_FRAME::OnEditComponentSymbolsId )
256 
257  EVT_TOOL( ID_RUN_PCB, SCH_EDIT_FRAME::OnOpenPcbnew )
258  EVT_TOOL( ID_RUN_PCB_MODULE_EDITOR, SCH_EDIT_FRAME::OnOpenPcbModuleEditor )
259 
260  EVT_TOOL( ID_RUN_CVPCB, SCH_EDIT_FRAME::OnOpenCvpcb )
261 
262  EVT_TOOL( ID_SHEET_SET, EDA_DRAW_FRAME::Process_PageSettings )
263  EVT_TOOL( ID_HIERARCHY, SCH_EDIT_FRAME::Process_Special_Functions )
264  EVT_TOOL( wxID_CUT, SCH_EDIT_FRAME::Process_Special_Functions )
265  EVT_TOOL( wxID_COPY, SCH_EDIT_FRAME::Process_Special_Functions )
266  EVT_TOOL( wxID_PASTE, SCH_EDIT_FRAME::Process_Special_Functions )
267  EVT_TOOL( wxID_UNDO, SCH_EDIT_FRAME::GetSchematicFromUndoList )
268  EVT_TOOL( wxID_REDO, SCH_EDIT_FRAME::GetSchematicFromRedoList )
269  EVT_TOOL( ID_GET_ANNOTATE, SCH_EDIT_FRAME::OnAnnotate )
270  EVT_TOOL( wxID_PRINT, SCH_EDIT_FRAME::OnPrint )
272  EVT_TOOL( ID_GET_NETLIST, SCH_EDIT_FRAME::OnCreateNetlist )
274  EVT_TOOL( ID_GET_TOOLS, SCH_EDIT_FRAME::OnCreateBillOfMaterials )
275  EVT_TOOL( ID_OPEN_CMP_TABLE, SCH_EDIT_FRAME::OnLaunchBomManager )
276  EVT_TOOL( ID_FIND_ITEMS, SCH_EDIT_FRAME::OnFindItems )
277  EVT_TOOL( wxID_REPLACE, SCH_EDIT_FRAME::OnFindItems )
278  EVT_TOOL( ID_BACKANNO_ITEMS, SCH_EDIT_FRAME::OnLoadCmpToFootprintLinkFile )
279  EVT_TOOL( ID_UPDATE_FIELDS, SCH_EDIT_FRAME::OnUpdateFields )
281  EVT_TOOL( ID_AUTOPLACE_FIELDS, SCH_EDIT_FRAME::OnAutoplaceFields )
282  EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
283  EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp )
284  EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
285  EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout )
286 
287  // Tools and buttons for vertical toolbar.
289  EVT_TOOL( ID_HIGHLIGHT, SCH_EDIT_FRAME::OnSelectTool )
290  EVT_TOOL( ID_ZOOM_SELECTION, SCH_EDIT_FRAME::OnSelectTool )
292  SCH_EDIT_FRAME::OnSelectTool )
293 
294 #ifdef KICAD_SPICE
296  EVT_TOOL( ID_SIM_PROBE, SCH_EDIT_FRAME::OnSelectTool )
297  EVT_TOOL( ID_SIM_TUNE, SCH_EDIT_FRAME::OnSelectTool )
298 #endif /* KICAD_SPICE */
299 
303  SCH_EDIT_FRAME::OnRotate )
305  SCH_EDIT_FRAME::OnEditItem )
308  SCH_EDIT_FRAME::Process_Special_Functions )
309 
310  // Tools and buttons options toolbar
311  EVT_TOOL( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnSelectOptionToolbar )
312  EVT_TOOL( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnSelectOptionToolbar )
313 
315  SCH_EDIT_FRAME::Process_Special_Functions )
317  SCH_EDIT_FRAME::OnSelectUnit )
319  SCH_EDIT_FRAME::OnConvertTextType )
320 
321  // Multple item selection context menu commands.
323 
324  /* Handle user interface update events. */
325  EVT_UPDATE_UI( wxID_PASTE, SCH_EDIT_FRAME::OnUpdatePaste )
326  EVT_UPDATE_UI( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnUpdateHiddenPins )
327  EVT_UPDATE_UI( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnUpdateBusOrientation )
328  EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnUpdateSelectTool )
329  EVT_UPDATE_UI( ID_HIGHLIGHT, SCH_EDIT_FRAME::OnUpdateSelectTool )
330  EVT_UPDATE_UI( ID_ZOOM_SELECTION, SCH_EDIT_FRAME::OnUpdateSelectTool )
331  EVT_UPDATE_UI_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
332  SCH_EDIT_FRAME::OnUpdateSelectTool )
333  EVT_UPDATE_UI( ID_SAVE_PROJECT, SCH_EDIT_FRAME::OnUpdateSave )
334  EVT_UPDATE_UI( ID_UPDATE_ONE_SHEET, SCH_EDIT_FRAME::OnUpdateSaveSheet )
335  EVT_UPDATE_UI( ID_POPUP_SCH_LEAVE_SHEET, SCH_EDIT_FRAME::OnUpdateHierarchySheet )
336  EVT_UPDATE_UI( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnUpdateRemapSymbols )
337 
338  /* Search dialog events. */
339  EVT_FIND_CLOSE( wxID_ANY, SCH_EDIT_FRAME::OnFindDialogClose )
340  EVT_FIND_DRC_MARKER( wxID_ANY, SCH_EDIT_FRAME::OnFindDrcMarker )
341  EVT_FIND( wxID_ANY, SCH_EDIT_FRAME::OnFindSchematicItem )
342  EVT_FIND_REPLACE( wxID_ANY, SCH_EDIT_FRAME::OnFindReplace )
343  EVT_FIND_REPLACE_ALL( wxID_ANY, SCH_EDIT_FRAME::OnFindReplace )
344 
345 END_EVENT_TABLE()
346 
347 
348 SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
349  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ),
350  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ),
351  m_item_to_repeat( 0 )
352 {
353  m_showAxis = false; // true to show axis
354  m_showBorderAndTitleBlock = true; // true to show sheet references
355  m_CurrentSheet = new SCH_SHEET_PATH;
356  m_DefaultSchematicFileName = NAMELESS_PROJECT;
357  m_DefaultSchematicFileName += wxT( ".sch" );
358  m_showAllPins = false;
359  m_previewPosition = wxDefaultPosition;
360  m_previewSize = wxDefaultSize;
361  m_printMonochrome = true;
362  m_printSheetReference = true;
363  SetShowPageLimits( true );
364  m_hotkeysDescrList = g_Schematic_Hokeys_Descr;
365  m_dlgFindReplace = NULL;
366  m_findReplaceData = new wxFindReplaceData( wxFR_DOWN );
367  m_undoItem = NULL;
368  m_hasAutoSave = true;
369 
370  SetForceHVLines( true );
371  SetSpiceAjustPassiveValues( false );
372 
373  // Give an icon
374  wxIcon icon;
375  icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
376  SetIcon( icon );
377 
378  // Initialize grid id to the default value (50 mils):
379  const int default_grid = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
380  m_LastGridSizeId = default_grid;
381 
382  LoadSettings( config() );
383 
384  CreateScreens();
385 
386  // Ensure m_LastGridSizeId is an offset inside the allowed schematic grid range
387  if( !GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) )
388  m_LastGridSizeId = default_grid;
389 
390  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
391 
392  if( m_canvas )
393  m_canvas->SetEnableBlockCommands( true );
394 
395  ReCreateMenuBar();
396  ReCreateHToolbar();
397  ReCreateVToolbar();
398  ReCreateOptToolbar();
399 
400  // Initialize common print setup dialog settings.
401  m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
402  m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
403  m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
404  m_pageSetupData.GetPrintData().SetNoCopies( 1 );
405 
406  m_auimgr.SetManagedWindow( this );
407 
408  EDA_PANEINFO horiz;
409  horiz.HorizontalToolbarPane();
410 
411  EDA_PANEINFO vert;
412  vert.VerticalToolbarPane();
413 
414  EDA_PANEINFO mesg;
415  mesg.MessageToolbarPane();
416 
417  if( m_mainToolBar )
418  m_auimgr.AddPane( m_mainToolBar,
419  wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) );
420 
421  if( m_drawToolBar )
422  m_auimgr.AddPane( m_drawToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_drawToolBar" ) ).Right() );
423 
424  if( m_optionsToolBar )
425  m_auimgr.AddPane( m_optionsToolBar,
426  wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left() );
427 
428  if( m_canvas )
429  m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
430 
431  if( m_messagePanel )
432  m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().
433  Layer(10) );
434 
435  m_auimgr.Update();
436 
437  // Now Drawpanel is sized, we can use BestZoom to show the component (if any)
438  GetScreen()->SetZoom( BestZoom() );
439 
440  Zoom_Automatique( false );
441 
442  // Net list generator
443  DefaultExecFlags();
444 
445  Bind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnEditSymbolLibTable, this,
447 }
448 
449 
451 {
452  Unbind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnEditSymbolLibTable, this,
454 
455  delete m_item_to_repeat; // we own the cloned object, see this->SetRepeatItem()
456 
457  SetScreen( NULL );
458 
459  delete m_CurrentSheet; // a SCH_SHEET_PATH, on the heap.
460  delete m_undoItem;
461  delete g_RootSheet;
462  delete m_findReplaceData;
463 
464  m_CurrentSheet = NULL;
465  m_undoItem = NULL;
466  g_RootSheet = NULL;
467  m_findReplaceData = NULL;
468 }
469 
470 
472 {
473  // we cannot store a pointer to an item in the display list here since
474  // that item may be deleted, such as part of a line concatonation or other.
475  // So simply always keep a copy of the object which is to be repeated.
476 
477  SCH_ITEM* old = m_item_to_repeat;
478  SCH_ITEM* cur = aItem;
479 
480  if( cur != old )
481  {
482  if( cur )
483  {
484  aItem = (SCH_ITEM*) cur->Clone();
485 
486  // Clone() preserves the flags, we want 'em cleared.
487  aItem->ClearFlags();
488  }
489 
490  m_item_to_repeat = aItem;
491 
492  delete old;
493  }
494 }
495 
496 
498 {
499  SCH_SCREEN* screen;
500  SCH_SCREENS s_list;
501 
502  /* Set the sheet count, and the sheet number (1 for root sheet)
503  */
504  int sheet_count = g_RootSheet->CountSheets();
505  int SheetNumber = 1;
506  wxString current_sheetpath = m_CurrentSheet->Path();
507  SCH_SHEET_LIST sheetList( g_RootSheet );
508 
509  // Examine all sheets path to find the current sheets path,
510  // and count them from root to the current sheet path:
511  for( unsigned i = 0; i < sheetList.size(); i++ )
512  {
513  wxString sheetpath = sheetList[i].Path();
514 
515  if( sheetpath == current_sheetpath ) // Current sheet path found
516  break;
517 
518  SheetNumber++; /* Not found, increment sheet
519  * number before this current
520  * path */
521  }
522 
523  for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
524  {
525  screen->m_NumberOfScreens = sheet_count;
526  }
527 
528  GetScreen()->m_ScreenNumber = SheetNumber;
529 }
530 
531 
533 {
534  return m_CurrentSheet->LastScreen();
535 }
536 
537 
539 {
540  wxString s = m_CurrentSheet->PathHumanReadable();
541 
542  return s;
543 }
544 
545 
547 {
548  if( g_RootSheet == NULL )
549  {
550  g_RootSheet = new SCH_SHEET();
551  }
552 
553  if( g_RootSheet->GetScreen() == NULL )
554  {
555  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
556  screen->SetMaxUndoItems( m_UndoRedoCountMax );
557  g_RootSheet->SetScreen( screen );
558  SetScreen( g_RootSheet->GetScreen() );
559  }
560 
561  g_RootSheet->GetScreen()->SetFileName( m_DefaultSchematicFileName );
562 
563  m_CurrentSheet->clear();
564  m_CurrentSheet->push_back( g_RootSheet );
565 
566  if( GetScreen() == NULL )
567  {
568  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
569  screen->SetMaxUndoItems( m_UndoRedoCountMax );
570  SetScreen( screen );
571  }
572 
573  GetScreen()->SetZoom( 32.0 );
574 }
575 
576 
578 {
579  wxASSERT_MSG( m_CurrentSheet != NULL, wxT( "SCH_EDIT_FRAME m_CurrentSheet member is NULL." ) );
580 
581  return *m_CurrentSheet;
582 }
583 
584 
586 {
587  *m_CurrentSheet = aSheet;
588 }
589 
590 
592 {
593  // if aItem != NULL, delete a previous m_undoItem, if exists
594  // if aItme = NULL, just clear m_undoItem,
595  // because when calling SetUndoItem( NULL ), we only clear m_undoItem,
596  // because the owner of m_undoItem is no more me.
597  if( aItem && m_undoItem )
598  {
599  delete m_undoItem;
600  }
601 
602  m_undoItem = NULL;
603 
604  if( aItem )
605  m_undoItem = (SCH_ITEM*) aItem->Clone();
606 }
607 
608 
610 {
611  wxCHECK_RET( aItem != NULL,
612  wxT( "Cannot swap undo item structures. Bad programmer!." ) );
613  wxCHECK_RET( m_undoItem != NULL,
614  wxT( "Cannot swap undo item structures. Bad programmer!." ) );
615  wxCHECK_RET( aItem->Type() == m_undoItem->Type(),
616  wxT( "Cannot swap undo item structures. Bad programmer!." ) );
617 
618  aItem->SwapData( m_undoItem );
619  SaveCopyInUndoList( aItem, UR_CHANGED );
620  aItem->SwapData( m_undoItem );
621 }
622 
623 
624 void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
625 {
626  if( Kiface().IsSingle() )
627  {
628  LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
629  if( libeditFrame && !libeditFrame->Close() ) // Can close component editor?
630  return;
631 
632  LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
633  if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer?
634  return;
635 
636  viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
637  if( viewlibFrame && !viewlibFrame->Close() ) // Can close modal component viewer?
638  return;
639  }
640 
641  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
642 
643  if( simFrame && !simFrame->Close() ) // Can close the simulator?
644  return;
645 
646  SCH_SHEET_LIST sheetList( g_RootSheet );
647 
648  if( sheetList.IsModified() )
649  {
650  wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
651  wxString msg = wxString::Format( _(
652  "Save the changes in\n\"%s\"\nbefore closing?"),
653  GetChars( fileName )
654  );
655 
656  int ii = DisplayExitDialog( this, msg );
657 
658  switch( ii )
659  {
660  case wxID_CANCEL:
661  aEvent.Veto();
662  return;
663 
664  case wxID_NO:
665  break;
666 
667  case wxID_YES:
668  wxCommandEvent tmp( ID_SAVE_PROJECT );
669  OnSaveProject( tmp );
670  break;
671  }
672  }
673 
674  // Close the find dialog and preserve it's setting if it is displayed.
675  if( m_dlgFindReplace )
676  {
677  m_findDialogPosition = m_dlgFindReplace->GetPosition();
678  m_findDialogSize = m_dlgFindReplace->GetSize();
679  m_findStringHistoryList = m_dlgFindReplace->GetFindEntries();
680  m_replaceStringHistoryList = m_dlgFindReplace->GetReplaceEntries();
681  m_dlgFindReplace->Destroy();
682  m_dlgFindReplace = NULL;
683  }
684 
685  SCH_SCREENS screens;
686  wxFileName fn;
687 
688  for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
689  {
690  fn = Prj().AbsolutePath( screen->GetFileName() );
691 
692  // Auto save file name is the normal file name prepended with AUTOSAVE_PREFIX_FILENAME.
693  fn.SetName( AUTOSAVE_PREFIX_FILENAME + fn.GetName() );
694 
695  if( fn.FileExists() && fn.IsFileWritable() )
696  wxRemoveFile( fn.GetFullPath() );
697  }
698 
699  sheetList.ClearModifyStatus();
700 
701  wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
702 
703  if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty() &&
704  g_RootSheet->GetScreen()->GetDrawItems() != NULL )
705  {
706  UpdateFileHistory( fileName );
707  }
708 
710 
711  // all sub sheets are deleted, only the main sheet is usable
712  m_CurrentSheet->clear();
713 
714  Destroy();
715 }
716 
717 
719 {
720  int dx, dy;
721  wxSize size;
722 
723  dx = GetScreen()->GetPageSettings().GetWidthIU();
724  dy = GetScreen()->GetPageSettings().GetHeightIU();
725 
726  size = m_canvas->GetClientSize();
727 
728  // Reserve no margin because best zoom shows the full page
729  // and margins are already included in function that draws the sheet refernces
730  double margin_scale_factor = 1.0;
731  double zx =(double) dx / ( margin_scale_factor * (double)size.x );
732  double zy = (double) dy / ( margin_scale_factor * (double)size.y );
733 
734  double bestzoom = std::max( zx, zy );
735 
736  SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) );
737 
738  return bestzoom;
739 }
740 
741 
743 {
744  wxFileName fn = GetScreen()->GetFileName();
745 
746  // Name is <root sheet filename>-<sheet path> and has no extension.
747  // However if filename is too long name is <sheet filename>-<sheet number>
748 
749  #define FN_LEN_MAX 80 // A reasonable value for the short filename len
750 
751  wxString filename = fn.GetName();
752  wxString sheetFullName = m_CurrentSheet->PathHumanReadable();
753 
754  // Remove the last '/' of the path human readable
755  // (and for the root sheet, make sheetFullName empty):
756  sheetFullName.RemoveLast();
757 
758  sheetFullName.Trim( true );
759  sheetFullName.Trim( false );
760 
761  // Convert path human readable separator to '-'
762  sheetFullName.Replace( wxT( "/" ), wxT( "-" ) );
763 
764  if( ( filename.Len() + sheetFullName.Len() ) < FN_LEN_MAX )
765  filename += sheetFullName;
766  else
767  filename << wxT( "-" ) << GetScreen()->m_ScreenNumber;
768 
769  return filename;
770 }
771 
772 
774 {
775  GetScreen()->SetModify();
776  GetScreen()->SetSave();
777 
778  m_foundItems.SetForceSearch();
779 
780  m_canvas->Refresh();
781 }
782 
783 
784 void SCH_EDIT_FRAME::OnUpdatePaste( wxUpdateUIEvent& event )
785 {
786  event.Enable( m_blockItems.GetCount() > 0 );
787 }
788 
789 
790 void SCH_EDIT_FRAME::OnUpdateBusOrientation( wxUpdateUIEvent& aEvent )
791 {
792  wxString tool_tip = GetForceHVLines() ?
793  _( "Draw wires and buses in any direction" ) :
794  _( "Draw horizontal and vertical wires and buses only" );
795 
796  aEvent.Check( GetForceHVLines() );
797  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_BUS_WIRES_ORIENT, tool_tip );
798 }
799 
800 
801 void SCH_EDIT_FRAME::OnUpdateHiddenPins( wxUpdateUIEvent& aEvent )
802 {
803  wxString tool_tip = m_showAllPins ? _( "Do not show hidden pins" ) :
804  _( "Show hidden pins" );
805 
806  aEvent.Check( m_showAllPins );
807  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_HIDDEN_PINS, tool_tip );
808 }
809 
810 
811 void SCH_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
812 {
813  SCH_SHEET_LIST sheetList( g_RootSheet );
814 
815  aEvent.Enable( sheetList.IsModified() );
816 }
817 
818 
819 void SCH_EDIT_FRAME::OnUpdateRemapSymbols( wxUpdateUIEvent& aEvent )
820 {
821  SCH_SCREENS schematic;
822 
823  // The remapping can only be performed on legacy projects.
824  aEvent.Enable( schematic.HasNoFullyDefinedLibIds() );
825 }
826 
827 
828 void SCH_EDIT_FRAME::OnUpdateSaveSheet( wxUpdateUIEvent& aEvent )
829 {
830  aEvent.Enable( GetScreen()->IsModify() );
831 
832 }
833 
834 
835 void SCH_EDIT_FRAME::OnUpdateHierarchySheet( wxUpdateUIEvent& aEvent )
836 {
837  aEvent.Enable( m_CurrentSheet->Last() != g_RootSheet );
838 }
839 
840 
841 void SCH_EDIT_FRAME::OnAnnotate( wxCommandEvent& event )
842 {
843  InvokeDialogAnnotate( this );
844 }
845 
846 
847 void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event )
848 {
849  // See if it's already open...
850  wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this );
851 
852  if( erc )
853  // Bring it to the top if already open. Dual monitor users need this.
854  erc->Raise();
855  else
856  InvokeDialogERC( this );
857 }
858 
859 
860 void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
861 {
862  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
863 
864  fn.SetExt( PcbFileExtension );
865 
866  if( Kiface().IsSingle() )
867  {
868  DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is"
869  " opened in stand-alone mode. In order to create/update"
870  " PCBs from schematics, you need to launch Kicad shell"
871  " and create a PCB project." ) );
872  return;
873  }
874  else
875  {
876  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB, true );
877 
878  // a pcb frame can be already existing, but not yet used.
879  // this is the case when running the footprint editor, or the footprint viewer first
880  // if the frame is not visible, the board is not yet loaded
881  if( !frame->IsVisible() )
882  {
883  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
884  frame->Show( true );
885  }
886 
887  // On Windows, Raise() does not bring the window on screen, when iconized
888  if( frame->IsIconized() )
889  frame->Iconize( false );
890 
891  frame->Raise();
892  }
893 
894  // Ensure the schematic is OK for a netlist creation
895  // (especially all components are annotated):
896  bool success = prepareForNetlist();
897 
898  if( !success )
899  return;
900 
901  NETLIST_OBJECT_LIST* net_atoms = BuildNetListBase();
902  NETLIST_EXPORTER_KICAD exporter( net_atoms, Prj().SchSymbolLibTable() );
903  STRING_FORMATTER formatter;
904 
905  exporter.Format( &formatter, GNL_ALL );
906 
907  // Now, send the "kicad" (s-expr) netlist to Pcbnew
909  formatter.GetString(), this );
910 }
911 
912 
913 void SCH_EDIT_FRAME::OnCreateNetlist( wxCommandEvent& event )
914 {
915  int result;
916 
917  do
918  {
919  result = InvokeDialogNetList( this );
920 
921  // If a plugin is removed or added, rebuild and reopen the new dialog
922 
923  } while( result == NET_PLUGIN_CHANGE );
924 }
925 
926 
928 {
929  InvokeDialogCreateBOM( this );
930 }
931 
932 
933 void SCH_EDIT_FRAME::OnLaunchBomManager( wxCommandEvent& event )
934 {
935  // First ensure that entire schematic is annotated
936  if( !prepareForNetlist() )
937  return;
938 
940 }
941 
942 
943 void SCH_EDIT_FRAME::OnFindItems( wxCommandEvent& aEvent )
944 {
945  wxCHECK_RET( m_findReplaceData != NULL,
946  wxT( "Forgot to create find/replace data. Bad Programmer!" ) );
947 
948  if( m_dlgFindReplace )
949  {
950  delete m_dlgFindReplace;
951  m_dlgFindReplace = NULL;
952  }
953 
954  // Verify the find dialog is not drawn off the visible display area in case the
955  // display configuration has changed since the last time the dialog position was
956  // saved.
957  wxRect displayRect = wxDisplay().GetGeometry();
958  wxRect dialogRect = wxRect( m_findDialogPosition, m_findDialogSize );
959 
960  wxPoint position = m_findDialogPosition;
961 
962  if( !displayRect.Contains( dialogRect ) )
963  {
964  position = wxDefaultPosition;
965  }
966 
967  int style = 0;
968 
969  if( aEvent.GetId() == wxID_REPLACE )
970  style = wxFR_REPLACEDIALOG;
971 
972  m_dlgFindReplace = new DIALOG_SCH_FIND( this, m_findReplaceData, position, m_findDialogSize,
973  style );
974 
975  m_dlgFindReplace->SetFindEntries( m_findStringHistoryList );
976  m_dlgFindReplace->SetReplaceEntries( m_replaceStringHistoryList );
977  m_dlgFindReplace->Show( true );
978 }
979 
980 
981 void SCH_EDIT_FRAME::OnFindDialogClose( wxFindDialogEvent& event )
982 {
983  // If the user dismissed the dialog with the mouse, this will send the cursor back
984  // to the last item found.
985  OnFindSchematicItem( event );
986 
987  if( m_dlgFindReplace )
988  {
989  m_findDialogPosition = m_dlgFindReplace->GetPosition();
990  m_findDialogSize = m_dlgFindReplace->GetSize();
991  m_findStringHistoryList = m_dlgFindReplace->GetFindEntries();
992  m_replaceStringHistoryList = m_dlgFindReplace->GetReplaceEntries();
993  m_dlgFindReplace->Destroy();
994  m_dlgFindReplace = NULL;
995  }
996 }
997 
998 
999 void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
1000 {
1001  wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
1002 
1003  if( fn.size() )
1004  OpenProjectFiles( std::vector<wxString>( 1, fn ) );
1005 }
1006 
1007 
1009 {
1010  LoadCmpToFootprintLinkFile();
1011  m_canvas->Refresh();
1012 }
1013 
1014 
1015 void SCH_EDIT_FRAME::OnUpdateFields( wxCommandEvent& event )
1016 {
1017  std::list<SCH_COMPONENT*> components;
1018 
1019  for( SCH_ITEM* item = GetScreen()->GetDrawItems(); item; item = item->Next() )
1020  {
1021  if( item->Type() == SCH_COMPONENT_T )
1022  components.push_back( static_cast<SCH_COMPONENT*>( item ) );
1023  }
1024 
1025  if( InvokeDialogUpdateFields( this, components, true ) == wxID_OK )
1026  m_canvas->Refresh();
1027 }
1028 
1029 
1030 void SCH_EDIT_FRAME::OnNewProject( wxCommandEvent& event )
1031 {
1032  wxString pro_dir = m_mruPath;
1033 
1034  wxFileDialog dlg( this, _( "New Schematic" ), pro_dir,
1035  wxEmptyString, SchematicFileWildcard(),
1036  wxFD_SAVE );
1037 
1038  if( dlg.ShowModal() != wxID_CANCEL )
1039  {
1040  // Enforce the extension, wxFileDialog is inept.
1041  wxFileName create_me = dlg.GetPath();
1042  create_me.SetExt( SchematicFileExtension );
1043 
1044  if( create_me.FileExists() )
1045  {
1046  wxString msg = wxString::Format( _(
1047  "Schematic file \"%s\" already exists, use Open instead" ),
1048  GetChars( create_me.GetFullName() )
1049  );
1050  DisplayError( this, msg );
1051  return ;
1052  }
1053 
1054  // OpenProjectFiles() requires absolute
1055  wxASSERT_MSG( create_me.IsAbsolute(), wxT( "wxFileDialog returned non-absolute" ) );
1056 
1057  OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
1058  m_mruPath = create_me.GetPath();
1059  }
1060 }
1061 
1062 
1063 void SCH_EDIT_FRAME::OnLoadProject( wxCommandEvent& event )
1064 {
1065 // wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
1066  wxString pro_dir = m_mruPath;
1067 
1068  wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir,
1069  wxEmptyString, SchematicFileWildcard(),
1070  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1071 
1072  if( dlg.ShowModal() != wxID_CANCEL )
1073  {
1074  OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
1075  m_mruPath = Prj().GetProjectPath();
1076  }
1077 }
1078 
1079 
1080 void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
1081 {
1082  wxFileName kicad_board = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
1083 
1084  if( kicad_board.IsOk() )
1085  {
1086  kicad_board.SetExt( PcbFileExtension );
1087  wxFileName legacy_board( kicad_board );
1088  legacy_board.SetExt( LegacyPcbFileExtension );
1089  wxFileName& boardfn = ( !legacy_board.FileExists() || kicad_board.FileExists() ) ?
1090  kicad_board : legacy_board;
1091 
1092  if( Kiface().IsSingle() )
1093  {
1094  wxString filename = QuoteFullPath( boardfn );
1095  ExecuteFile( this, PCBNEW_EXE, filename );
1096  }
1097  else
1098  {
1099  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB, true );
1100 
1101  // a pcb frame can be already existing, but not yet used.
1102  // this is the case when running the footprint editor, or the footprint viewer first
1103  // if the frame is not visible, the board is not yet loaded
1104  if( !frame->IsVisible() )
1105  {
1106  frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1107  frame->Show( true );
1108  }
1109 
1110  // On Windows, Raise() does not bring the window on screen, when iconized
1111  if( frame->IsIconized() )
1112  frame->Iconize( false );
1113 
1114  frame->Raise();
1115  }
1116  }
1117  else
1118  {
1119  ExecuteFile( this, PCBNEW_EXE );
1120  }
1121 }
1122 
1123 
1124 void SCH_EDIT_FRAME::OnOpenPcbModuleEditor( wxCommandEvent& event )
1125 {
1126  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
1127 
1128  if( fn.IsOk() )
1129  {
1131 
1132  // On Windows, Raise() does not bring the window on screen, when iconized
1133  if( fp_editor->IsIconized() )
1134  fp_editor->Iconize( false );
1135 
1136  fp_editor->Show( true );
1137  fp_editor->Raise();
1138  }
1139 }
1140 
1141 
1142 void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
1143 {
1144  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
1145  fn.SetExt( NetlistFileExtension );
1146 
1147  if( !prepareForNetlist() )
1148  return;
1149 
1150  try
1151  {
1152  KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1153 
1154  if( !player )
1155  {
1156  player = Kiway().Player( FRAME_CVPCB, true );
1157  player->Show( true );
1158  // player->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1159  }
1160 
1161  sendNetlist();
1162 
1163  player->Raise();
1164  }
1165  catch( const IO_ERROR& e )
1166  {
1167  DisplayError( this, _( "Could not open CvPcb" ) );
1168  }
1169 }
1170 
1171 
1172 void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
1173 {
1174  SCH_COMPONENT* component = NULL;
1175 
1176  if( event.GetId() == ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP )
1177  {
1178  // We want to edit a component with Libedit.
1179  // we are here by a hot key, or by a popup menu
1180  SCH_ITEM* item = GetScreen()->GetCurItem();
1181 
1182  if( !item )
1183  {
1184  // If we didn't get here by a hot key, then something has gone wrong.
1185  if( event.GetInt() == 0 )
1186  return;
1187 
1188  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) event.GetClientObject();
1189 
1190  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1191 
1192  // Set the locat filter, according to the edit command
1193  const KICAD_T* filterList = SCH_COLLECTOR::ComponentsOnly;
1194  item = LocateAndShowItem( data->GetPosition(), filterList, event.GetInt() );
1195 
1196  // Exit if no item found at the current location or the item is already being edited.
1197  if( (item == NULL) || (item->GetFlags() != 0) )
1198  return;
1199  }
1200 
1201 
1202  if( !item || (item->GetFlags() != 0) || ( item->Type() != SCH_COMPONENT_T ) )
1203  {
1204  wxMessageBox( _( "Error: not a component or no component" ) );
1205  return;
1206  }
1207 
1208  component = (SCH_COMPONENT*) item;
1209  }
1210 
1211  LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
1212 
1213  if( !libeditFrame )
1214  {
1215  libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, true );
1216  libeditFrame->Show( true );
1217  }
1218 
1219  libeditFrame->PushPreferences( m_canvas );
1220 
1221  // On Windows, Raise() does not bring the window on screen, when iconized
1222  if( libeditFrame->IsIconized() )
1223  libeditFrame->Iconize( false );
1224 
1225  libeditFrame->Raise();
1226 
1227  if( component )
1228  {
1229  LIB_ID id = component->GetLibId();
1230  LIB_ALIAS* entry = nullptr;
1231 
1232  try
1233  {
1234  entry = Prj().SchSymbolLibTable()->LoadSymbol( id );
1235  }
1236  catch( const IO_ERROR& ioe )
1237  {
1238  wxString msg;
1239 
1240  msg.Printf( _( "Error occurred loading symbol \"%s\" from library \"%s\"." ),
1241  id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
1242  DisplayErrorMessage( this, msg, ioe.What() );
1243  return;
1244  }
1245 
1246  if( !entry ) // Should not occur
1247  return;
1248 
1249  libeditFrame->LoadComponentAndSelectLib( id );
1250  }
1251 
1252  SchematicCleanUp();
1253  m_canvas->Refresh();
1254 }
1255 
1256 
1257 void SCH_EDIT_FRAME::OnRescueProject( wxCommandEvent& event )
1258 {
1259  SCH_SCREENS schematic;
1260 
1261  if( schematic.HasNoFullyDefinedLibIds() )
1262  RescueLegacyProject( true );
1263  else
1264  RescueSymbolLibTableProject( true );
1265 }
1266 
1267 
1268 void SCH_EDIT_FRAME::OnRemapSymbols( wxCommandEvent& event )
1269 {
1270  DIALOG_SYMBOL_REMAP dlgRemap( this );
1271 
1272  dlgRemap.ShowQuasiModal();
1273 
1274  m_canvas->Refresh( true );
1275 }
1276 
1277 
1278 // This method is not the same as OnRemapSymbols.
1279 // It allows renaming the lib id of groups of components when a symbol
1280 // has moved from a library to an other library.
1281 // For instance to rename libname1::mysymbol to libname2::mysymbol
1282 // or any other lib id name
1283 void SCH_EDIT_FRAME::OnEditComponentSymbolsId( wxCommandEvent& event )
1284 {
1286  m_canvas->Refresh( true );
1287 }
1288 
1289 
1290 void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1291 {
1292  Close( false );
1293 }
1294 
1295 
1296 void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
1297 {
1299 
1300  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
1301 
1302  if( fn.GetName() != NAMELESS_PROJECT )
1303  {
1304  // was: wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParametersList() );
1305  Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_SCH_EDITOR,
1306  GetProjectFileParametersList() );
1307  }
1308 }
1309 
1310 
1311 void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode,
1312  void* aData )
1313 {
1314  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1315 
1316  GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE );
1317  DrawWorkSheet( aDC, GetScreen(), GetDefaultLineThickness(), IU_PER_MILS, fileName );
1318 }
1319 
1320 
1321 void SCH_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
1322 {
1323  int id = aEvent.GetId();
1324  int index = id - ID_SELECT_ITEM_START;
1325 
1326  if( (id >= ID_SELECT_ITEM_START && id <= ID_SELECT_ITEM_END)
1327  && (index >= 0 && index < m_collectedItems.GetCount()) )
1328  {
1329  SCH_ITEM* item = m_collectedItems[index];
1330  m_canvas->SetAbortRequest( false );
1331  GetScreen()->SetCurItem( item );
1332  }
1333 }
1334 
1335 
1337 {
1338  // In case this event happens before g_RootSheet is initialized which does happen
1339  // on mingw64 builds.
1340 
1341  if( g_RootSheet != NULL )
1342  {
1343  SCH_SCREENS screenList;
1344 
1345  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
1346  {
1347  if( screen->IsSave() )
1348  return true;
1349  }
1350  }
1351 
1352  return false;
1353 }
1354 
1355 
1357 {
1358  SCH_SCREEN* screen = GetScreen();
1359  SCH_ITEM* item = screen->GetCurItem();
1360 
1361  wxCHECK_RET( item != NULL, wxT( "Cannot add current item to list." ) );
1362 
1363  m_canvas->SetAutoPanRequest( false );
1364 
1365  SCH_ITEM* undoItem = item;
1366 
1367  if( item->Type() == SCH_SHEET_PIN_T )
1368  {
1369  SCH_SHEET* sheet = (SCH_SHEET*) item->GetParent();
1370 
1371  wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T),
1372  wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
1373 
1374  undoItem = sheet;
1375  }
1376 
1377  else if( item->Type() == SCH_FIELD_T )
1378  {
1379  SCH_COMPONENT* cmp = (SCH_COMPONENT*) item->GetParent();
1380 
1381  wxCHECK_RET( (cmp != NULL) && (cmp->Type() == SCH_COMPONENT_T),
1382  wxT( "Cannot place field in invalid schematic component object." ) );
1383 
1384  undoItem = cmp;
1385  }
1386 
1387  if( item->IsNew() )
1388  {
1389  if( item->Type() == SCH_SHEET_T )
1390  {
1391  // Fix the size and position of the new sheet using the last values set by
1392  // the m_mouseCaptureCallback function.
1393  m_canvas->SetMouseCapture( NULL, NULL );
1394 
1395  if( !EditSheet( (SCH_SHEET*)item, m_CurrentSheet ) )
1396  {
1397  screen->SetCurItem( NULL );
1398  delete item;
1399 
1400  if( aRedraw )
1401  GetCanvas()->Refresh();
1402 
1403  return;
1404  }
1405 
1406  SetSheetNumberAndCount();
1407  }
1408 
1409  if( undoItem == item )
1410  {
1411  if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
1412  screen->Append( item );
1413 
1414  SetRepeatItem( item );
1415 
1416  SaveCopyInUndoList( undoItem, UR_NEW );
1417  }
1418  else
1419  {
1420  // Here, item is not a basic schematic item, but an item inside
1421  // a parent basic schematic item,
1422  // currently: sheet pin or component field.
1423  // currently, only a sheet pin can be found as new item,
1424  // because new component fields have a specific handling, and do not appears here
1425  SaveCopyInUndoList( undoItem, UR_CHANGED );
1426 
1427  if( item->Type() == SCH_SHEET_PIN_T )
1428  ( (SCH_SHEET*)undoItem )->AddPin( (SCH_SHEET_PIN*) item );
1429  else
1430  wxLogMessage( wxT( "addCurrentItemToList: expected type = SCH_SHEET_PIN_T, actual type = %d" ),
1431  item->Type() );
1432  }
1433  }
1434  else
1435  {
1436  SaveUndoItemInUndoList( undoItem );
1437  }
1438 
1439  item->ClearFlags();
1440  screen->SetModify();
1441  screen->SetCurItem( NULL );
1442  m_canvas->SetMouseCapture( NULL, NULL );
1443  m_canvas->EndMouseCapture();
1444 
1445  if( item->IsConnectable() )
1446  {
1447  std::vector< wxPoint > pts;
1448  item->GetConnectionPoints( pts );
1449  for( auto i = pts.begin(); i != pts.end(); i++ )
1450  {
1451  for( auto j = i + 1; j != pts.end(); j++ )
1452  TrimWire( *i, *j, true );
1453 
1454  if( screen->IsJunctionNeeded( *i, true ) )
1455  AddJunction( *i, true );
1456  }
1457  screen->TestDanglingEnds();
1458  }
1459 
1460  if( aRedraw )
1461  GetCanvas()->Refresh();
1462 }
1463 
1464 
1466 {
1467  wxString title;
1468 
1469  if( GetScreen()->GetFileName() == m_DefaultSchematicFileName )
1470  {
1471  title.Printf( L"Eeschema \u2014 %s", GetChars( GetScreen()->GetFileName() ) );
1472  }
1473  else
1474  {
1475  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1476  wxFileName fn = fileName;
1477 
1478  title.Printf( L"Eeschema \u2014 %s [%s] \u2014 %s",
1479  GetChars( fn.GetName() ),
1480  GetChars( m_CurrentSheet->PathHumanReadable() ),
1481  GetChars( fn.GetPath() ) );
1482 
1483  if( fn.FileExists() )
1484  {
1485  if( !fn.IsFileWritable() )
1486  title += _( " [Read Only]" );
1487  }
1488  else
1489  title += _( " [no file]" );
1490  }
1491 
1492  SetTitle( title );
1493 }
void OnLoadProject(wxCommandEvent &event)
Definition: schframe.cpp:1063
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
Definition: schframe.cpp:585
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:487
Definition of the SCH_SHEET class for Eeschema.
Class UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion supp...
Definition: utf8.h:73
Class SCH_SHEET_LIST.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Definition: wxstruct.h:55
void OnOpenCvpcb(wxCommandEvent &event)
Definition: schframe.cpp:1142
VTBL_ENTRY void ConfigSave(const SEARCH_STACK &aSList, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aFileName=wxEmptyString)
Function ConfigSave saves the current "project" parameters into the wxConfigBase* derivative...
Definition: project.cpp:318
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:282
bool IsModified()
Function IsModified checks the entire hierarchy for any modifications.
KiCad executable names.
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:111
Part library alias object definition.
SCH_SCREEN * GetNext()
void OnFindItems(wxCommandEvent &event)
Definition: schframe.cpp:943
wxString SchematicFileWildcard()
void OnLoadFile(wxCommandEvent &event)
Definition: schframe.cpp:999
static void LibNamesAndPaths(PROJECT *aProject, bool doSave, wxString *aPaths, wxArrayString *aNames=NULL)
Save or load the names of the currently configured part libraries (without paths).
void OnUpdateSaveSheet(wxUpdateUIEvent &aEvent)
Definition: schframe.cpp:828
SCH_EDIT_FRAME::OnSelectTool SCH_EDIT_FRAME::OnEditItem SCH_EDIT_FRAME::Process_Special_Functions ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT
Definition: schframe.cpp:318
ID_SCHEMATIC_VERTICAL_TOOLBAR_END
Definition: schframe.cpp:291
virtual void OnEditSymbolLibTable(wxCommandEvent &aEvent)
void OnUpdateHiddenPins(wxUpdateUIEvent &event)
Definition: schframe.cpp:801
This file is part of the common library TODO brief description.
void OnOpenPcbModuleEditor(wxCommandEvent &event)
Definition: schframe.cpp:1124
void LoadAllLibraries(PROJECT *aProject, bool aShowProgress=true)
Load all of the project's libraries into this container, which should be cleared before calling it...
Implementation of conversion functions that require both schematic and board internal units...
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:243
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:350
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
Definition: schframe.cpp:773
const wxString PCBNEW_EXE
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
void OnNewProject(wxCommandEvent &event)
Definition: schframe.cpp:1030
void OnUpdateRemapSymbols(wxUpdateUIEvent &aEvent)
Definition: schframe.cpp:819
void OnFindDialogClose(wxFindDialogEvent &event)
Definition: schframe.cpp:981
PROJECT & Prj()
Definition: kicad.cpp:270
int CountSheets()
Count the number of sheets found in "this" sheet includeing all of the subsheets. ...
Definition: sch_sheet.cpp:624
#define KICTL_CREATE
caller thinks requested project files may not exist
Definition: kiway_player.h:131
const wxString LegacyPcbFileExtension
void OnLaunchBomManager(wxCommandEvent &event)
Definition: schframe.cpp:933
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i...
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:103
const wxString & GetFileName() const
void OnCloseWindow(wxCloseEvent &Event)
Definition: schframe.cpp:624
void addCurrentItemToList(bool aRedraw=true)
Add the item currently being edited to the schematic and adds the changes to the undo/redo container...
Definition: schframe.cpp:1356
EDA_ITEM * GetParent() const
Definition: base_struct.h:235
void UpdateTitle()
Set the main window title bar text.
Definition: schframe.cpp:1465
static const KICAD_T ComponentsOnly[]
A scan list for schematic component items only.
void OnPrint(wxCommandEvent &event)
Show the print dialog.
Definition: schframe.cpp:1296
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
Schematic editor (Eeschema) main window.
Definition: schframe.h:118
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
Definition: dialog_bom.cpp:223
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
Definition: id.h:66
void OnRescueProject(wxCommandEvent &event)
Definition: schframe.cpp:1257
VTBL_ENTRY _ELEM * GetElem(ELEM_T aIndex)
Typically wrapped somewhere else in a more meaningful function wrapper.
Definition: project.cpp:207
#define EVT_FIND_DRC_MARKER(id, fn)
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:54
void Format(OUTPUTFORMATTER *aOutputFormatter, int aCtl)
Function Format outputs this s-expression netlist into aOutputFormatter.
void PushPreferences(const EDA_DRAW_PANEL *aParentCanvas)
Function PushPreferences Pushes a few preferences from a parent window to a child window...
Definition: draw_frame.cpp:817
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:279
SCH_ITEM * Next() const
Implementing DIALOG_SCH_FIND_BASE.
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:478
Symbol library viewer main window.
Definition: viewlib_frame.h:49
void OnUpdateHierarchySheet(wxUpdateUIEvent &aEvent)
Definition: schframe.cpp:835
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Definition: schframe.cpp:471
VTBL_ENTRY bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList...
Definition: kiway_player.h:170
void SaveUndoItemInUndoList(SCH_ITEM *aItem)
Swap the cloned item in member variable m_undoItem with aItem and saves it to the undo list then swap...
Definition: schframe.cpp:609
void OnUpdateSave(wxUpdateUIEvent &aEvent)
Definition: schframe.cpp:811
Class NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected item...
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:219
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:532
int InvokeDialogPrintUsingPrinter(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_PRINT_USING_PRINTER and return whatever DIALOG_PRINT_USING_PRINTER::ShowModal(...
virtual wxString GetScreenDesc() const override
Definition: schframe.cpp:538
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
double BestZoom() override
Return the zoom level which displays the full page on screen.
Definition: schframe.cpp:718
Class EDA_HOTKEY_CLIENT_DATA provides client data member for hotkeys to include in command events gen...
EDA_PANEINFO & VerticalToolbarPane()
Function VerticalToolbarPane Change *this to a vertical toolbar for KiCad.
Definition: wxstruct.h:505
void InvokeDialogCreateBOMEditor(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM_EDITOR.
FOOTPRINT_EDIT_FRAME::Process_Special_Functions EVT_TOOL_RANGE(ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL, FOOTPRINT_EDIT_FRAME::OnVerticalToolbar) EVT_MENU(ID_PREFERENCES_HOTKEY_EXPORT_CONFIG
const wxString NetlistFileExtension
Class LSET is a set of PCB_LAYER_IDs.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:87
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
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
virtual void SwapData(SCH_ITEM *aItem)
Function SwapData swap the internal data structures aItem with the schematic item.
wxFileName m_project_name
/.pro
Definition: project.h:317
void OnUpdatePaste(wxUpdateUIEvent &event)
Definition: schframe.cpp:784
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
int ShowQuasiModal()
Subclass of DIALOG_SCH_FIND_BASE, which is generated by wxFormBuilder.
static int Split(wxArrayString *aResult, const wxString aPathString)
Function Split separates aPathString into individual paths.
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item...
EVT_MENU(ID_SELECT_PREFERED_PDF_BROWSER_NAME, KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser) EVT_MENU_RANGE(ID_LANGUAGE_CHOICE
SCH_SHEET_PATH & GetCurrentSheet()
Definition: schframe.cpp:577
Subclass of DIALOG_DISPLAY_HTML_TEXT_BASE, which is generated by wxFormBuilder.
VTBL_ENTRY const wxString AbsolutePath(const wxString &aFileName) const
Function AbsolutePath fixes up aFileName if it is relative to the project's directory to be an absolu...
Definition: project.cpp:382
Class NETLIST_EXPORTER_KICAD generates the kicad netlist format supported by pcbnew.
void Clear()
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:154
The common library.
Helper dialog and control classes.
Sch->PCB forward update.
Definition: mail_type.h:42
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:257
static void add_search_paths(SEARCH_STACK *aDst, const SEARCH_STACK &aSrc, int aIndex)
Definition: schframe.cpp:73
void OnUpdateFields(wxCommandEvent &event)
Definition: schframe.cpp:1015
int InvokeDialogAnnotate(SCH_EDIT_FRAME *aCaller, wxString message)
Create and show DIALOG_ANNOTATE and return whatever DIALOG_ANNOTATE::ShowModal() returns.
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
bool InvokeDialogEditComponentsLibId(SCH_EDIT_FRAME *aCaller)
Run a dialog to modify the LIB_ID of components for instance when a symbol has moved from a symbol li...
#define PcbFileExtension
const std::string & GetString()
Definition: richio.h:475
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:61
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set...
virtual bool isAutoSaveRequired() const override
Returns true if the schematic has been modified.
Definition: schframe.cpp:1336
Class SCH_SHEET_PATH.
EVT_TOOL(ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard) EVT_TOOL(ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT
Class HTML_MESSAGE_BOX.
void OnUpdatePCB(wxCommandEvent &event)
Definition: schframe.cpp:860
void OnLoadCmpToFootprintLinkFile(wxCommandEvent &event)
Definition: schframe.cpp:1008
int InvokeDialogUpdateFields(SCH_EDIT_FRAME *aCaller, const list< SCH_COMPONENT * > aComponents, bool aCreateUndoEntry)
void OnUpdateBusOrientation(wxUpdateUIEvent &event)
Definition: schframe.cpp:790
Implementing SIM_PLOT_FRAME_BASE.
void OnOpenLibraryEditor(wxCommandEvent &event)
Definition: schframe.cpp:1172
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
void OnCancelCurrentCommand(wxCommandEvent &aEvent)
Definition: schedit.cpp:471
void OnEditComponentSymbolsId(wxCommandEvent &aEvent)
Definition: schframe.cpp:1283
ID_PREFERENCES_HOTKEY_END
void CreateScreens()
Definition: schframe.cpp:546
SCH_EDIT_FRAME::OnSelectTool SCH_EDIT_FRAME::OnEditItem SCH_EDIT_FRAME::Process_Special_Functions SCH_EDIT_FRAME::OnConvertTextType EVT_UPDATE_UI_RANGE(ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END, SCH_EDIT_FRAME::OnUpdateSelectTool) SCH_EDIT_FRAME
Definition: schframe.cpp:331
EVT_MENU_RANGE(ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END, SCH_EDIT_FRAME::Process_Config) EVT_TOOL_RANGE(ID_SCHEMATIC_VERTICAL_TOOLBAR_START
bool IsSingle() const
Function IsSingle is this KIFACE_I running under single_top?
Definition: kiface_i.h:115
void OnAnnotate(wxCommandEvent &event)
Definition: schframe.cpp:841
A collection of PART_LIB objects.
virtual void GetConnectionPoints(std::vector< wxPoint > &aPoints) const
Function GetConnectionPoints add all the connection points for this item to aPoints.
void OnRemapSymbols(wxCommandEvent &aEvent)
Definition: schframe.cpp:1268
eeschema ERC modeless dialog ID
Definition: id.h:272
SCH_ITEM * GetDrawItems() const
#define GR_DEFAULT_DRAWMODE
Definition: general.h:70
Definition the SCH_COMPONENT class for Eeschema.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
Definition: wxstruct.h:524
int DisplayExitDialog(wxWindow *parent, const wxString &aMessage)
Function DisplayExitDialog displays a dialog with 3 buttons: Save and Exit Cancel Exit without save...
Definition: confirm.cpp:61
Struct PARSE_ERROR contains a filename or source description, a problem input line, a line number, a byte offset, and an error message which contains the the caller's report and his call site information: CPP source file, function, and line number.
Definition: ki_exception.h:94
The symbol library editor main window.
Definition: libeditframe.h:58
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
see class PGM_BASE
void OnExit(wxCommandEvent &event)
Definition: schframe.cpp:1290
#define FN_LEN_MAX
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
SCH_EDIT_FRAME::OnSelectTool SCH_EDIT_FRAME::OnEditItem ID_POPUP_GENERAL_END_RANGE
Definition: schframe.cpp:314
void Append(SCH_ITEM *aItem)
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schframe.cpp:497
#define max(a, b)
Definition: auxiliary.h:86
wxString QuoteFullPath(wxFileName &fn, wxPathFormat format)
Quote return value of wxFileName::GetFullPath().
Definition: gestfich.cpp:417
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, const std::string &aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:387
KICAD_MANAGER_FRAME::language_change KICAD_MANAGER_FRAME::OnChangeIconsOptions EVT_UPDATE_UI(ID_SELECT_PREFERED_PDF_BROWSER, KICAD_MANAGER_FRAME::OnUpdatePreferredPdfBrowser) EVT_UPDATE_UI_RANGE(ID_TO_SCH
void OnErc(wxCommandEvent &event)
Definition: schframe.cpp:847
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
Definition: sch_screen.cpp:879
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
Definition: wxstruct.h:117
#define GROUP_SCH_EDITOR
Definition: config_params.h:45
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
#define GNL_ALL
void OnOpenPcbnew(wxCommandEvent &event)
Definition: schframe.cpp:1080
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
void SetMaxUndoItems(int aMax)
#define NET_PLUGIN_CHANGE
Function InvokeDialogNetList creates and shows NETLIST_DIALOG and returns whatever NETLIST_DIALOG::Sh...
const LIB_ID & GetLibId() const
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
virtual void PrintPage(wxDC *aDC, LSET aPrintMask, bool aPrintMirrorMode, void *aData=NULL) override
Plot or print the current sheet to the clipboard.
Definition: schframe.cpp:1311
wxString GetUniqueFilenameForCurrentSheet()
Definition: schframe.cpp:742
void OnCreateNetlist(wxCommandEvent &event)
Definition: schframe.cpp:913
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:281
#define DBG(x)
Definition: fctsys.h:33
SCH_SCREEN * GetFirst()
bool cmp(const Point *a, const Point *b)
Definition: shapes.h:221
void OnSimulate(wxCommandEvent &event)
Definition: simulate.cpp:29
void SetUndoItem(const SCH_ITEM *aItem)
Clone aItem which can be used to restore the state of the item being edited when the user cancels the...
Definition: schframe.cpp:591
SCH_EDIT_FRAME::OnSelectTool ID_SCH_EDIT_COMPONENT_FOOTPRINT
Definition: schframe.cpp:304
void SetFileName(const wxString &aFileName)
bool LoadComponentAndSelectLib(const LIB_ID &aLibId)
Selects the currently active library and loads the symbol from aLibId.
Definition: libedit.cpp:94
Definition for part library class.
#define NAMELESS_PROJECT
default name for nameless projects
Definition: common.h:73
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
void OnSelectItem(wxCommandEvent &aEvent)
Definition: schframe.cpp:1321
#define AUTOSAVE_PREFIX_FILENAME
Prefix to create filenames for schematic files or other difile when auto-saved to retrieve a crash...
Definition: wxstruct.h:71
void OnCreateBillOfMaterials(wxCommandEvent &event)
Definition: schframe.cpp:927
bool CheckIfOnDrawList(SCH_ITEM *st)
Definition: sch_screen.cpp:200
Message panel definition file.
Class STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:445
int ExecuteFile(wxWindow *frame, const wxString &ExecFile, const wxString &param, wxProcess *callback)
Function ExecuteFile calls the executable file ExecFile with the command line parameters param...
Definition: gestfich.cpp:208
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME, and it brings in a common way of handling the provided virtual functions for the derived classes.
#define SCH_EDIT_FRAME_NAME
Definition: schframe.h:113
std::string inputLine
problem line of input [say, from a LINE_READER].
Definition: ki_exception.h:103
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:73
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
wxDialog * InvokeDialogERC(SCH_EDIT_FRAME *aCaller)
Create the modeless DIALOG_ERC and show it, return something to destroy or close it.
Definition: dialog_erc.cpp:604
void AddPaths(const wxString &aPaths, int aIndex=-1)
Function AddPaths insert or append path(s)
Definition of class LIB_EDIT_FRAME.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
const wxString SchematicFileExtension
KIWAY Kiway
struct EDA_HOTKEY_CONFIG g_Schematic_Hokeys_Descr[]