KiCad PCB EDA Suite
sch_edit_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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2018 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 <sch_draw_panel.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 #include <eda_dockart.h>
41 
42 #include <general.h>
43 #include <eeschema_id.h>
44 #include <netlist.h>
45 #include <lib_pin.h>
46 #include <class_library.h>
47 #include <sch_edit_frame.h>
48 #include <sch_component.h>
49 #include <symbol_lib_table.h>
50 
51 #include <dialog_helpers.h>
52 #include <reporter.h>
53 #include <lib_edit_frame.h>
54 #include <viewlib_frame.h>
55 #include <hotkeys.h>
56 #include <eeschema_config.h>
57 #include <sch_sheet.h>
58 #include <sch_sheet_path.h>
59 #include "sim/sim_plot_frame.h"
60 
61 #include <invoke_sch_dialog.h>
63 #include <dialog_symbol_remap.h>
64 #include <view/view.h>
65 #include <tool/tool_manager.h>
66 
67 #include <wx/display.h>
68 #include <build_version.h>
70 
71 #include <netlist_exporter_kicad.h>
72 #include <kiway.h>
74 
75 #include <sch_view.h>
76 #include <sch_painter.h>
77 
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, const SEARCH_STACK& aSrc, int aIndex )
83 {
84  for( unsigned i=0; i<aSrc.GetCount(); ++i )
85  aDst->AddPaths( aSrc[i], aIndex );
86 }
87 
88 
89 // non-member so it can be moved easily, and kept REALLY private.
90 // Do NOT Clear() in here.
91 static void add_search_paths( SEARCH_STACK* aDst, wxConfigBase* aCfg, int aIndex )
92 {
93  for( int i=1; true; ++i )
94  {
95  wxString key = wxString::Format( wxT( "LibraryPath%d" ), i );
96  wxString upath = aCfg->Read( key, wxEmptyString );
97 
98  if( !upath )
99  break;
100 
101  aDst->AddPaths( upath, aIndex );
102  }
103 }
104 
105 //-----<SCH "data on demand" functions>-------------------------------------------
106 
107 SEARCH_STACK* PROJECT::SchSearchS()
108 {
110 
111  wxASSERT( !ss || dynamic_cast<SEARCH_STACK*>( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
112 
113  if( !ss )
114  {
115  ss = new SEARCH_STACK();
116 
117  // Make PROJECT the new SEARCH_STACK owner.
119 
120  // to the empty SEARCH_STACK for SchSearchS(), add project dir as first
121  ss->AddPaths( m_project_name.GetPath() );
122 
123  // next add the paths found in *.pro, variable "LibDir"
124  wxString libDir;
125 
126  try
127  {
128  PART_LIBS::LibNamesAndPaths( this, false, &libDir );
129  }
130  catch( const IO_ERROR& DBG( ioe ) )
131  {
132  DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.What() ) );)
133  }
134 
135  if( !!libDir )
136  {
137  wxArrayString paths;
138 
139  SEARCH_STACK::Split( &paths, libDir );
140 
141  for( unsigned i =0; i<paths.GetCount(); ++i )
142  {
143  wxString path = AbsolutePath( paths[i] );
144 
145  ss->AddPaths( path ); // at the end
146  }
147  }
148 
149  // append all paths from aSList
150  add_search_paths( ss, Kiface().KifaceSearch(), -1 );
151 
152  // addLibrarySearchPaths( SEARCH_STACK* aSP, wxConfigBase* aCfg )
153  // This is undocumented, but somebody wanted to store !schematic!
154  // library search paths in the .kicad_common file?
155  add_search_paths( ss, Pgm().CommonSettings(), -1 );
156  }
157 
158  return ss;
159 }
160 
161 
162 PART_LIBS* PROJECT::SchLibs()
163 {
165 
166  wxASSERT( !libs || libs->Type() == PART_LIBS_T );
167 
168  if( !libs )
169  {
170  libs = new PART_LIBS();
171 
172  // Make PROJECT the new PART_LIBS owner.
174 
175  try
176  {
177  libs->LoadAllLibraries( this );
178  }
179  catch( const PARSE_ERROR& pe )
180  {
181  wxString lib_list = UTF8( pe.inputLine );
182  wxWindow* parent = Pgm().App().GetTopWindow();
183 
184  // parent of this dialog cannot be NULL since that breaks the Kiway() chain.
185  HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
186 
187  dlg.MessageSet( _( "The following libraries were not found:" ) );
188 
189  dlg.ListSet( lib_list );
190 
191  dlg.Layout();
192 
193  dlg.ShowModal();
194  }
195  catch( const IO_ERROR& ioe )
196  {
197  wxWindow* parent = Pgm().App().GetTopWindow();
198 
199  DisplayError( parent, ioe.What() );
200  }
201  }
202 
203  return libs;
204 }
205 
206 /*
207 NETLIST_OBJECT_LIST* PROJECT::Netlist()
208 {
209  NETLIST_OBJECT_LIST* netlist = (NETLIST_OBJECT_LIST*) GetElem( PROJECT::ELEM_SCH_NETLIST );
210 
211  wxASSERT( !libs || dynamic_cast<NETLIST_OBJECT_LIST*>( netlist ) );
212 
213  if( !netlist )
214  {
215  netlist = new NETLIST_OBJECT_LIST();
216 
217  // Make PROJECT the new NETLIST_OBJECT_LIST owner.
218  SetElem( PROJECT::ELEM_SCH_NETLIST, netlist );
219  }
220 }
221 */
222 
223 //-----</SCH "data on demand" functions>------------------------------------------
224 
225 
226 BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
229 
230  EVT_CLOSE( SCH_EDIT_FRAME::OnCloseWindow )
231  EVT_SIZE( SCH_EDIT_FRAME::OnSize )
232 
235 
237 
240 
243 
249  EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
251 
253 
257 
260 
267 
270 
272 
281  EVT_TOOL( wxID_PRINT, SCH_EDIT_FRAME::OnPrint )
288  EVT_TOOL( wxID_REPLACE, SCH_EDIT_FRAME::OnFindItems )
298 
299  // Tools and buttons for vertical toolbar.
307  SCH_EDIT_FRAME::OnSelectTool )
308 
309 #ifdef KICAD_SPICE
311  EVT_TOOL( ID_SIM_PROBE, SCH_EDIT_FRAME::OnSelectTool )
312  EVT_TOOL( ID_SIM_TUNE, SCH_EDIT_FRAME::OnSelectTool )
313 #endif /* KICAD_SPICE */
314 
318  SCH_EDIT_FRAME::OnRotate )
320  SCH_EDIT_FRAME::OnEditItem )
323  SCH_EDIT_FRAME::Process_Special_Functions )
325 
326  EVT_MENU( ID_MENU_CANVAS_CAIRO, SCH_EDIT_FRAME::OnSwitchCanvas )
327  EVT_MENU( ID_MENU_CANVAS_OPENGL, SCH_EDIT_FRAME::OnSwitchCanvas )
328 
329  // Tools and buttons options toolbar
330  EVT_TOOL( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnSelectOptionToolbar )
331  EVT_TOOL( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnSelectOptionToolbar )
332 
334  SCH_EDIT_FRAME::Process_Special_Functions )
336  SCH_EDIT_FRAME::OnSelectUnit )
338  SCH_EDIT_FRAME::OnConvertTextType )
339 
340  // Multple item selection context menu commands.
342 
343  /* Handle user interface update events. */
344  EVT_UPDATE_UI( wxID_PASTE, SCH_EDIT_FRAME::OnUpdatePaste )
345  EVT_UPDATE_UI( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnUpdateHiddenPins )
346  EVT_UPDATE_UI( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnUpdateBusOrientation )
347  EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnUpdateSelectTool )
348  EVT_UPDATE_UI( ID_HIGHLIGHT, SCH_EDIT_FRAME::OnUpdateSelectTool )
349  EVT_UPDATE_UI( ID_ZOOM_SELECTION, SCH_EDIT_FRAME::OnUpdateSelectTool )
351  SCH_EDIT_FRAME::OnUpdateSelectTool )
353  EVT_UPDATE_UI( ID_UPDATE_ONE_SHEET, SCH_EDIT_FRAME::OnUpdateSaveSheet )
354  EVT_UPDATE_UI( ID_POPUP_SCH_LEAVE_SHEET, SCH_EDIT_FRAME::OnUpdateHierarchySheet )
355  EVT_UPDATE_UI( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnUpdateRemapSymbols )
356  EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, SCH_EDIT_FRAME::OnUpdateSwitchCanvas )
357  EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, SCH_EDIT_FRAME::OnUpdateSwitchCanvas )
358 
359  /* Search dialog events. */
360  EVT_FIND_CLOSE( wxID_ANY, SCH_EDIT_FRAME::OnFindDialogClose )
361  EVT_FIND_DRC_MARKER( wxID_ANY, SCH_EDIT_FRAME::OnFindDrcMarker )
362  EVT_FIND( wxID_ANY, SCH_EDIT_FRAME::OnFindSchematicItem )
363  EVT_FIND_REPLACE( wxID_ANY, SCH_EDIT_FRAME::OnFindReplace )
364  EVT_FIND_REPLACE_ALL( wxID_ANY, SCH_EDIT_FRAME::OnFindReplace )
365 
366 END_EVENT_TABLE()
367 
368 
369 SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
370  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ),
371  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ),
372  m_item_to_repeat( 0 )
373 {
374  m_showAxis = false; // true to show axis
375  m_showBorderAndTitleBlock = true; // true to show sheet references
376  m_CurrentSheet = new SCH_SHEET_PATH;
377  m_DefaultSchematicFileName = NAMELESS_PROJECT;
378  m_DefaultSchematicFileName += wxT( ".sch" );
379  m_showAllPins = false;
380  m_printMonochrome = true;
381  m_printSheetReference = true;
382  SetShowPageLimits( true );
383  m_hotkeysDescrList = g_Schematic_Hokeys_Descr;
384  m_dlgFindReplace = NULL;
385  m_findReplaceData = new wxFindReplaceData( wxFR_DOWN );
386  m_findReplaceStatus = new wxString( wxEmptyString );
387  m_undoItem = NULL;
388  m_hasAutoSave = true;
389 
390  m_toolManager = new TOOL_MANAGER;
391 
392  SetForceHVLines( true );
393  SetSpiceAjustPassiveValues( false );
394 
395  // Give an icon
396  wxIcon icon;
397  icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
398  SetIcon( icon );
399 
400  // Initialize grid id to the default value (50 mils):
402 
403  LoadSettings( config() );
404 
405  CreateScreens();
406 
407  SetPresetGrid( m_LastGridSizeId );
408 
409  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
410 
411  if( m_canvas )
412  m_canvas->SetEnableBlockCommands( true );
413 
414  ReCreateMenuBar();
415  ReCreateHToolbar();
416  ReCreateVToolbar();
417  ReCreateOptToolbar();
418 
419  // Initialize common print setup dialog settings.
420  m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
421  m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
422  m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
423  m_pageSetupData.GetPrintData().SetNoCopies( 1 );
424 
425  m_auimgr.SetManagedWindow( this );
426  m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
427 
428  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
429  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
430  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
431  m_auimgr.AddPane( m_canvas->GetWindow(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
432  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
433 
434  m_auimgr.Update();
435 
436  Zoom_Automatique( false );
437 
438  if( GetGalCanvas() )
439  GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
440 
441  // Net list generator
442  DefaultExecFlags();
443 
444  Bind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnEditSymbolLibTable, this,
446 }
447 
448 
450 {
451  Unbind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnEditSymbolLibTable, this,
453 
454  delete m_item_to_repeat; // we own the cloned object, see this->SetRepeatItem()
455 
456  SetScreen( NULL );
457 
458  delete m_CurrentSheet; // a SCH_SHEET_PATH, on the heap.
459  delete m_undoItem;
460  delete m_findReplaceData;
461  delete m_findReplaceStatus;
462 
463  delete g_RootSheet;
464  g_RootSheet = NULL;
465 }
466 
467 
469 {
470  // we cannot store a pointer to an item in the display list here since
471  // that item may be deleted, such as part of a line concatonation or other.
472  // So simply always keep a copy of the object which is to be repeated.
473 
474  SCH_ITEM* old = m_item_to_repeat;
475  SCH_ITEM* cur = aItem;
476 
477  if( cur != old )
478  {
479  if( cur )
480  {
481  aItem = (SCH_ITEM*) cur->Clone();
482 
483  // Clone() preserves the flags, we want 'em cleared.
484  aItem->ClearFlags();
485  }
486 
487  m_item_to_repeat = aItem;
488 
489  delete old;
490  }
491 }
492 
493 
495 {
496  SCH_SCREEN* screen;
497  SCH_SCREENS s_list;
498 
499  /* Set the sheet count, and the sheet number (1 for root sheet)
500  */
501  int sheet_count = g_RootSheet->CountSheets();
502  int SheetNumber = 1;
503  wxString current_sheetpath = m_CurrentSheet->Path();
504  SCH_SHEET_LIST sheetList( g_RootSheet );
505 
506  // Examine all sheets path to find the current sheets path,
507  // and count them from root to the current sheet path:
508  for( unsigned i = 0; i < sheetList.size(); i++ )
509  {
510  wxString sheetpath = sheetList[i].Path();
511 
512  if( sheetpath == current_sheetpath ) // Current sheet path found
513  break;
514 
515  SheetNumber++; /* Not found, increment sheet
516  * number before this current
517  * path */
518  }
519 
520  m_CurrentSheet->SetPageNumber( SheetNumber );
521 
522  for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
523  {
524  screen->m_NumberOfScreens = sheet_count;
525  }
526 
527  GetScreen()->m_ScreenNumber = SheetNumber;
528 }
529 
530 
532 {
533  return m_CurrentSheet->LastScreen();
534 }
535 
536 
538 {
539  wxString s = m_CurrentSheet->PathHumanReadable();
540 
541  return s;
542 }
543 
544 
546 {
547  if( g_RootSheet == NULL )
548  {
549  g_RootSheet = new SCH_SHEET();
550  }
551 
552  if( g_RootSheet->GetScreen() == NULL )
553  {
554  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
555  screen->SetMaxUndoItems( m_UndoRedoCountMax );
556  g_RootSheet->SetScreen( screen );
557  SetScreen( g_RootSheet->GetScreen() );
558  }
559 
560  g_RootSheet->GetScreen()->SetFileName( m_DefaultSchematicFileName );
561 
562  m_CurrentSheet->clear();
563  m_CurrentSheet->push_back( g_RootSheet );
564 
565  if( GetScreen() == NULL )
566  {
567  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
568  screen->SetMaxUndoItems( m_UndoRedoCountMax );
569  SetScreen( screen );
570  }
571 
572  GetScreen()->SetZoom( 32.0 );
573 }
574 
575 
577 {
578  wxASSERT_MSG( m_CurrentSheet != NULL, wxT( "SCH_EDIT_FRAME m_CurrentSheet member is NULL." ) );
579 
580  return *m_CurrentSheet;
581 }
582 
583 
585 {
586  if( aSheet != *m_CurrentSheet )
587  {
588  *m_CurrentSheet = aSheet;
589 
590  static_cast<SCH_DRAW_PANEL*>( m_canvas )->DisplaySheet( m_CurrentSheet->LastScreen() );
591  }
592 }
593 
594 
596 {
597  static_cast<SCH_DRAW_PANEL*>( m_canvas )->DisplaySheet( m_CurrentSheet->LastScreen() );
598  GetCanvas()->Refresh();
599 }
600 
601 
603 {
604  // if aItem != NULL, delete a previous m_undoItem, if exists
605  // if aItme = NULL, just clear m_undoItem,
606  // because when calling SetUndoItem( NULL ), we only clear m_undoItem,
607  // because the owner of m_undoItem is no more me.
608  if( aItem && m_undoItem )
609  {
610  delete m_undoItem;
611  }
612 
613  m_undoItem = NULL;
614 
615  if( aItem )
616  m_undoItem = (SCH_ITEM*) aItem->Clone();
617 }
618 
619 
621 {
622  wxCHECK_RET( aItem != NULL,
623  wxT( "Cannot swap undo item structures. Bad programmer!." ) );
624  wxCHECK_RET( m_undoItem != NULL,
625  wxT( "Cannot swap undo item structures. Bad programmer!." ) );
626  wxCHECK_RET( aItem->Type() == m_undoItem->Type(),
627  wxT( "Cannot swap undo item structures. Bad programmer!." ) );
628 
629  aItem->SwapData( m_undoItem );
630  SaveCopyInUndoList( aItem, UR_CHANGED );
631  aItem->SwapData( m_undoItem );
632 }
633 
634 
635 void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
636 {
637  if( Kiface().IsSingle() )
638  {
639  LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
640  if( libeditFrame && !libeditFrame->Close() ) // Can close component editor?
641  return;
642 
643  LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
644  if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer?
645  return;
646 
647  viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
648 
649  if( viewlibFrame && !viewlibFrame->Close() ) // Can close modal component viewer?
650  return;
651  }
652 
653  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
654 
655  if( simFrame && !simFrame->Close() ) // Can close the simulator?
656  return;
657 
658  SCH_SHEET_LIST sheetList( g_RootSheet );
659 
660  if( sheetList.IsModified() )
661  {
662  wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
663  wxString msg = _( "Save changes to\n\"%s\"\nbefore closing?" );
664 
665  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName ),
666  [&]()->bool { return SaveProject(); } ) )
667  {
668  aEvent.Veto();
669  return;
670  }
671  }
672 
673  // Close the find dialog and preserve it's setting if it is displayed.
674  if( m_dlgFindReplace )
675  {
676  m_findStringHistoryList = m_dlgFindReplace->GetFindEntries();
677  m_replaceStringHistoryList = m_dlgFindReplace->GetReplaceEntries();
678  m_dlgFindReplace->Destroy();
679  m_dlgFindReplace = NULL;
680  }
681 
682  SCH_SCREENS screens;
683  wxFileName fn;
684 
685  for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
686  {
687  fn = Prj().AbsolutePath( screen->GetFileName() );
688 
689  // Auto save file name is the normal file name prepended with AUTOSAVE_PREFIX_FILENAME.
690  fn.SetName( AUTOSAVE_PREFIX_FILENAME + fn.GetName() );
691 
692  if( fn.FileExists() && fn.IsFileWritable() )
693  wxRemoveFile( fn.GetFullPath() );
694  }
695 
696  sheetList.ClearModifyStatus();
697 
698  wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
699 
700  if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty() &&
701  g_RootSheet->GetScreen()->GetDrawItems() != NULL )
702  {
703  UpdateFileHistory( fileName );
704  }
705 
707 
708  // all sub sheets are deleted, only the main sheet is usable
709  m_CurrentSheet->clear();
710 
711  Destroy();
712 }
713 
714 
716 {
717  double sizeX = (double) GetScreen()->GetPageSettings().GetWidthIU();
718  double sizeY = (double) GetScreen()->GetPageSettings().GetHeightIU();
719  wxPoint centre( wxPoint( sizeX / 2, sizeY / 2 ) );
720 
721  // The sheet boundary already affords us some margin, so add only an
722  // additional 5%.
723  double margin_scale_factor = 1.05;
724 
725  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
726 }
727 
728 
730 {
731  wxFileName fn = GetScreen()->GetFileName();
732 
733  // Name is <root sheet filename>-<sheet path> and has no extension.
734  // However if filename is too long name is <sheet filename>-<sheet number>
735 
736  #define FN_LEN_MAX 80 // A reasonable value for the short filename len
737 
738  wxString filename = fn.GetName();
739  wxString sheetFullName = m_CurrentSheet->PathHumanReadable();
740 
741  // Remove the last '/' of the path human readable
742  // (and for the root sheet, make sheetFullName empty):
743  sheetFullName.RemoveLast();
744 
745  sheetFullName.Trim( true );
746  sheetFullName.Trim( false );
747 
748  // Convert path human readable separator to '-'
749  sheetFullName.Replace( wxT( "/" ), wxT( "-" ) );
750 
751  if( ( filename.Len() + sheetFullName.Len() ) < FN_LEN_MAX )
752  filename += sheetFullName;
753  else
754  filename << wxT( "-" ) << GetScreen()->m_ScreenNumber;
755 
756  return filename;
757 }
758 
759 
761 {
762  GetScreen()->SetModify();
763  GetScreen()->SetSave();
764 
765  m_foundItems.SetForceSearch();
766 
767  m_canvas->Refresh();
768 }
769 
770 
771 void SCH_EDIT_FRAME::OnUpdatePaste( wxUpdateUIEvent& event )
772 {
773  event.Enable( m_blockItems.GetCount() > 0 );
774 }
775 
776 
777 void SCH_EDIT_FRAME::OnUpdateBusOrientation( wxUpdateUIEvent& aEvent )
778 {
779  wxString tool_tip = GetForceHVLines() ?
780  _( "Draw wires and buses in any direction" ) :
781  _( "Draw horizontal and vertical wires and buses only" );
782 
783  aEvent.Check( GetForceHVLines() );
784  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_BUS_WIRES_ORIENT, tool_tip );
785 }
786 
787 
788 void SCH_EDIT_FRAME::OnUpdateHiddenPins( wxUpdateUIEvent& aEvent )
789 {
790  wxString tool_tip = m_showAllPins ? _( "Do not show hidden pins" ) :
791  _( "Show hidden pins" );
792 
793  aEvent.Check( m_showAllPins );
794  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_HIDDEN_PINS, tool_tip );
795 }
796 
797 
798 void SCH_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
799 {
800  SCH_SHEET_LIST sheetList( g_RootSheet );
801 
802  aEvent.Enable( sheetList.IsModified() );
803 }
804 
805 
806 void SCH_EDIT_FRAME::OnUpdateRemapSymbols( wxUpdateUIEvent& aEvent )
807 {
808  SCH_SCREENS schematic;
809 
810  // The remapping can only be performed on legacy projects.
811  aEvent.Enable( schematic.HasNoFullyDefinedLibIds() );
812 }
813 
814 
815 void SCH_EDIT_FRAME::OnUpdateSaveSheet( wxUpdateUIEvent& aEvent )
816 {
817  aEvent.Enable( GetScreen()->IsModify() );
818 
819 }
820 
821 
822 void SCH_EDIT_FRAME::OnUpdateHierarchySheet( wxUpdateUIEvent& aEvent )
823 {
824  aEvent.Enable( m_CurrentSheet->Last() != g_RootSheet );
825 }
826 
827 
828 void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event )
829 {
830  // See if it's already open...
831  wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this );
832 
833  if( erc )
834  // Bring it to the top if already open. Dual monitor users need this.
835  erc->Raise();
836  else
837  InvokeDialogERC( this );
838 }
839 
840 
842 {
843  // Find the ERC dialog if it's open and close it
844  wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this );
845 
846  if( erc )
847  erc->Close( false );
848 }
849 
850 
851 void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
852 {
853  doUpdatePcb( "" );
854 }
855 
856 
857 void SCH_EDIT_FRAME::doUpdatePcb( const wxString& aUpdateOptions )
858 {
859  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
860 
861  fn.SetExt( PcbFileExtension );
862 
863  if( Kiface().IsSingle() )
864  {
865  DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is"
866  " opened in stand-alone mode. In order to create/update"
867  " PCBs from schematics, you need to launch Kicad shell"
868  " and create a PCB project." ) );
869  return;
870  }
871  else
872  {
873  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB, true );
874 
875  // a pcb frame can be already existing, but not yet used.
876  // this is the case when running the footprint editor, or the footprint viewer first
877  // if the frame is not visible, the board is not yet loaded
878  if( !frame->IsVisible() )
879  {
880  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
881  frame->Show( true );
882  }
883 
884  // On Windows, Raise() does not bring the window on screen, when iconized
885  if( frame->IsIconized() )
886  frame->Iconize( false );
887 
888  frame->Raise();
889  }
890 
891  if( aUpdateOptions.Contains( "quiet-annotate" ) )
892  {
893  SCH_SCREENS schematic;
894  schematic.UpdateSymbolLinks();
895  SCH_SHEET_LIST sheets( g_RootSheet );
896  sheets.AnnotatePowerSymbols();
897  AnnotateComponents( true, UNSORTED, INCREMENTAL_BY_REF, 0, false, false, true,
899  }
900 
901  if( !aUpdateOptions.Contains( "no-annotate" ) )
902  {
903  // Ensure the schematic is OK for a netlist creation
904  // (especially all components are annotated):
905  if( !prepareForNetlist() )
906  return;
907  }
908 
909  NETLIST_OBJECT_LIST* net_atoms = BuildNetListBase();
910  NETLIST_EXPORTER_KICAD exporter( this, net_atoms );
911  STRING_FORMATTER formatter;
912 
913  exporter.Format( &formatter, GNL_ALL );
914 
915  auto updateOptions = aUpdateOptions.ToStdString();
916  auto netlistString = formatter.GetString();
917  auto finalNetlist = updateOptions + "\n" + netlistString;
918 
919  // Now, send the "kicad" (s-expr) netlist to Pcbnew
920  Kiway().ExpressMail( FRAME_PCB, MAIL_SCH_PCB_UPDATE, finalNetlist, this );
921 }
922 
923 
924 void SCH_EDIT_FRAME::OnCreateNetlist( wxCommandEvent& event )
925 {
926  int result;
927 
928  do
929  {
930  result = InvokeDialogNetList( this );
931 
932  // If a plugin is removed or added, rebuild and reopen the new dialog
933 
934  } while( result == NET_PLUGIN_CHANGE );
935 }
936 
937 
939 {
940  InvokeDialogCreateBOM( this );
941 }
942 
943 
944 void SCH_EDIT_FRAME::OnLaunchBomManager( wxCommandEvent& event )
945 {
946  DIALOG_FIELDS_EDITOR_GLOBAL dlg( this );
947  dlg.ShowQuasiModal();
948 }
949 
950 
951 void SCH_EDIT_FRAME::OnFindItems( wxCommandEvent& aEvent )
952 {
953  wxCHECK_RET( m_findReplaceData != NULL,
954  wxT( "Forgot to create find/replace data. Bad Programmer!" ) );
955 
956  if( m_dlgFindReplace )
957  {
958  delete m_dlgFindReplace;
959  m_dlgFindReplace = NULL;
960  }
961 
962  int style = 0;
963 
964  if( aEvent.GetId() == wxID_REPLACE )
965  style = wxFR_REPLACEDIALOG;
966 
967  m_dlgFindReplace = new DIALOG_SCH_FIND( this, m_findReplaceData, m_findReplaceStatus,
968  wxDefaultPosition, wxDefaultSize, style );
969 
970  m_dlgFindReplace->SetFindEntries( m_findStringHistoryList );
971  m_dlgFindReplace->SetReplaceEntries( m_replaceStringHistoryList );
972  m_dlgFindReplace->Show( true );
973 }
974 
975 
976 void SCH_EDIT_FRAME::OnFindDialogClose( wxFindDialogEvent& event )
977 {
978  // If the user dismissed the dialog with the mouse, this will send the cursor back
979  // to the last item found.
980  OnFindSchematicItem( event );
981 
982  if( m_dlgFindReplace )
983  {
984  m_findStringHistoryList = m_dlgFindReplace->GetFindEntries();
985  m_replaceStringHistoryList = m_dlgFindReplace->GetReplaceEntries();
986  m_dlgFindReplace->Destroy();
987  m_dlgFindReplace = NULL;
988  }
989 }
990 
991 
992 void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
993 {
994  wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
995 
996  if( fn.size() )
997  OpenProjectFiles( std::vector<wxString>( 1, fn ) );
998 }
999 
1000 
1002 {
1003  LoadCmpToFootprintLinkFile();
1004  m_canvas->Refresh();
1005 }
1006 
1007 
1008 void SCH_EDIT_FRAME::OnUpdateFields( wxCommandEvent& event )
1009 {
1010  std::list<SCH_COMPONENT*> components;
1011 
1012  for( SCH_ITEM* item = GetScreen()->GetDrawItems(); item; item = item->Next() )
1013  {
1014  if( item->Type() == SCH_COMPONENT_T )
1015  components.push_back( static_cast<SCH_COMPONENT*>( item ) );
1016  }
1017 
1018  if( InvokeDialogUpdateFields( this, components, true ) == wxID_OK )
1019  m_canvas->Refresh();
1020 }
1021 
1022 
1023 void SCH_EDIT_FRAME::OnNewProject( wxCommandEvent& event )
1024 {
1025  wxString pro_dir = m_mruPath;
1026 
1027  wxFileDialog dlg( this, _( "New Schematic" ), pro_dir,
1028  wxEmptyString, SchematicFileWildcard(),
1029  wxFD_SAVE );
1030 
1031  if( dlg.ShowModal() != wxID_CANCEL )
1032  {
1033  // Enforce the extension, wxFileDialog is inept.
1034  wxFileName create_me = dlg.GetPath();
1035  create_me.SetExt( SchematicFileExtension );
1036 
1037  if( create_me.FileExists() )
1038  {
1039  wxString msg;
1040  msg.Printf( _( "Schematic file \"%s\" already exists." ), create_me.GetFullName() );
1041  DisplayError( this, msg );
1042  return ;
1043  }
1044 
1045  // OpenProjectFiles() requires absolute
1046  wxASSERT_MSG( create_me.IsAbsolute(), "wxFileDialog returned non-absolute path" );
1047 
1048  OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
1049  m_mruPath = create_me.GetPath();
1050  }
1051 }
1052 
1053 
1054 void SCH_EDIT_FRAME::OnLoadProject( wxCommandEvent& event )
1055 {
1056  wxString pro_dir = m_mruPath;
1057 
1058  wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir,
1059  wxEmptyString, SchematicFileWildcard(),
1060  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1061 
1062  if( dlg.ShowModal() != wxID_CANCEL )
1063  {
1064  OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
1065  m_mruPath = Prj().GetProjectPath();
1066  }
1067 }
1068 
1069 
1070 void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
1071 {
1072  wxFileName kicad_board = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
1073 
1074  if( kicad_board.IsOk() )
1075  {
1076  kicad_board.SetExt( PcbFileExtension );
1077  wxFileName legacy_board( kicad_board );
1078  legacy_board.SetExt( LegacyPcbFileExtension );
1079  wxFileName& boardfn = ( !legacy_board.FileExists() || kicad_board.FileExists() ) ?
1080  kicad_board : legacy_board;
1081 
1082  if( Kiface().IsSingle() )
1083  {
1084  wxString filename = QuoteFullPath( boardfn );
1085  ExecuteFile( this, PCBNEW_EXE, filename );
1086  }
1087  else
1088  {
1089  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB, true );
1090 
1091  // a pcb frame can be already existing, but not yet used.
1092  // this is the case when running the footprint editor, or the footprint viewer first
1093  // if the frame is not visible, the board is not yet loaded
1094  if( !frame->IsVisible() )
1095  {
1096  frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1097  frame->Show( true );
1098  }
1099 
1100  // On Windows, Raise() does not bring the window on screen, when iconized
1101  if( frame->IsIconized() )
1102  frame->Iconize( false );
1103 
1104  frame->Raise();
1105  }
1106  }
1107  else
1108  {
1109  ExecuteFile( this, PCBNEW_EXE );
1110  }
1111 }
1112 
1113 
1114 void SCH_EDIT_FRAME::OnOpenPcbModuleEditor( wxCommandEvent& event )
1115 {
1116  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
1117 
1118  if( fn.IsOk() )
1119  {
1121 
1122  // On Windows, Raise() does not bring the window on screen, when iconized
1123  if( fp_editor->IsIconized() )
1124  fp_editor->Iconize( false );
1125 
1126  fp_editor->Show( true );
1127  fp_editor->Raise();
1128  }
1129 }
1130 
1131 
1132 void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
1133 {
1134  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
1135  fn.SetExt( NetlistFileExtension );
1136 
1137  if( !prepareForNetlist() )
1138  return;
1139 
1140  try
1141  {
1142  KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1143 
1144  if( !player )
1145  {
1146  player = Kiway().Player( FRAME_CVPCB, true );
1147  player->Show( true );
1148  // player->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1149  }
1150 
1151  sendNetlist();
1152 
1153  player->Raise();
1154  }
1155  catch( const IO_ERROR& )
1156  {
1157  DisplayError( this, _( "Could not open CvPcb" ) );
1158  }
1159 }
1160 
1161 
1162 void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
1163 {
1164  SCH_COMPONENT* component = NULL;
1165 
1166  if( event.GetId() == ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP )
1167  {
1168  // We want to edit a component with Libedit.
1169  // we are here by a hot key, or by a popup menu
1170  SCH_ITEM* item = GetScreen()->GetCurItem();
1171 
1172  if( !item )
1173  {
1174  // If we didn't get here by a hot key, then something has gone wrong.
1175  if( event.GetInt() == 0 )
1176  return;
1177 
1178  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) event.GetClientObject();
1179 
1180  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1181 
1182  // Set the locat filter, according to the edit command
1183  const KICAD_T* filterList = SCH_COLLECTOR::ComponentsOnly;
1184  item = LocateAndShowItem( data->GetPosition(), filterList, event.GetInt() );
1185 
1186  // Exit if no item found at the current location or the item is already being edited.
1187  if( (item == NULL) || (item->GetFlags() != 0) )
1188  return;
1189  }
1190 
1191 
1192  if( !item || (item->GetFlags() != 0) || ( item->Type() != SCH_COMPONENT_T ) )
1193  {
1194  wxMessageBox( _( "Error: not a symbol or no symbol." ) );
1195  return;
1196  }
1197 
1198  component = (SCH_COMPONENT*) item;
1199  }
1200 
1201  LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
1202 
1203  if( !libeditFrame )
1204  {
1205  libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, true );
1206  libeditFrame->Show( true );
1207  }
1208 
1209  libeditFrame->PushPreferences( m_canvas );
1210 
1211  // On Windows, Raise() does not bring the window on screen, when iconized
1212  if( libeditFrame->IsIconized() )
1213  libeditFrame->Iconize( false );
1214 
1215  libeditFrame->Raise();
1216 
1217  if( component )
1218  {
1219  LIB_ID id = component->GetLibId();
1220  LIB_ALIAS* entry = nullptr;
1221 
1222  try
1223  {
1224  entry = Prj().SchSymbolLibTable()->LoadSymbol( id );
1225  }
1226  catch( const IO_ERROR& ioe )
1227  {
1228  wxString msg;
1229 
1230  msg.Printf( _( "Error occurred loading symbol \"%s\" from library \"%s\"." ),
1231  id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
1232  DisplayErrorMessage( this, msg, ioe.What() );
1233  return;
1234  }
1235 
1236  if( !entry ) // Should not occur
1237  return;
1238 
1239  libeditFrame->LoadComponentAndSelectLib( id, component->GetUnit(), component->GetConvert() );
1240  }
1241 
1242  SchematicCleanUp();
1243  m_canvas->Refresh();
1244 }
1245 
1246 
1247 void SCH_EDIT_FRAME::OnRescueProject( wxCommandEvent& event )
1248 {
1249  SCH_SCREENS schematic;
1250 
1251  if( schematic.HasNoFullyDefinedLibIds() )
1252  RescueLegacyProject( true );
1253  else
1254  RescueSymbolLibTableProject( true );
1255 }
1256 
1257 
1258 void SCH_EDIT_FRAME::OnRemapSymbols( wxCommandEvent& event )
1259 {
1260  DIALOG_SYMBOL_REMAP dlgRemap( this );
1261 
1262  dlgRemap.ShowQuasiModal();
1263 
1264  m_canvas->Refresh( true );
1265 }
1266 
1267 
1268 // This method is not the same as OnRemapSymbols.
1269 // It allows renaming the lib id of groups of components when a symbol
1270 // has moved from a library to another library.
1271 // For instance to rename libname1::mysymbol to libname2::mysymbol
1272 // or any other lib id name
1273 void SCH_EDIT_FRAME::OnEditComponentSymbolsId( wxCommandEvent& event )
1274 {
1276  m_canvas->Refresh( true );
1277 }
1278 
1279 
1280 void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1281 {
1282  Close( false );
1283 }
1284 
1285 
1286 void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
1287 {
1289 
1290  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
1291 
1292  if( fn.GetName() != NAMELESS_PROJECT )
1293  {
1294  // was: wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParametersList() );
1295  Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_SCH_EDITOR,
1296  GetProjectFileParametersList() );
1297  }
1298 }
1299 
1300 
1301 void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode,
1302  void* aData )
1303 {
1304  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1305 
1306  GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE );
1307  DrawWorkSheet( aDC, GetScreen(), GetDefaultLineThickness(), IU_PER_MILS, fileName );
1308 }
1309 
1310 
1311 void SCH_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
1312 {
1313  int id = aEvent.GetId();
1314  int index = id - ID_SELECT_ITEM_START;
1315 
1316  if( (id >= ID_SELECT_ITEM_START && id <= ID_SELECT_ITEM_END)
1317  && (index >= 0 && index < m_collectedItems.GetCount()) )
1318  {
1319  SCH_ITEM* item = m_collectedItems[index];
1320  m_canvas->SetAbortRequest( false );
1321  GetScreen()->SetCurItem( item );
1322  }
1323 }
1324 
1325 
1327 {
1328  // In case this event happens before g_RootSheet is initialized which does happen
1329  // on mingw64 builds.
1330 
1331  if( g_RootSheet != NULL )
1332  {
1333  SCH_SCREENS screenList;
1334 
1335  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
1336  {
1337  if( screen->IsSave() )
1338  return true;
1339  }
1340  }
1341 
1342  return false;
1343 }
1344 
1345 
1347 {
1348  SCH_SCREEN* screen = GetScreen();
1349  SCH_ITEM* item = screen->GetCurItem();
1350 
1351  wxCHECK_RET( item != NULL, wxT( "Cannot add current item to list." ) );
1352 
1353  m_canvas->SetAutoPanRequest( false );
1354 
1355  SCH_SHEET* parentSheet = nullptr;
1356  SCH_COMPONENT* parentComponent = nullptr;
1357  SCH_ITEM* undoItem = item;
1358 
1359  if( item->Type() == SCH_SHEET_PIN_T )
1360  {
1361  parentSheet = (SCH_SHEET*) item->GetParent();
1362 
1363  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
1364  wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
1365 
1366  undoItem = parentSheet;
1367  }
1368 
1369  else if( item->Type() == SCH_FIELD_T )
1370  {
1371  parentComponent = (SCH_COMPONENT*) item->GetParent();
1372 
1373  wxCHECK_RET( parentComponent && parentComponent->Type() == SCH_COMPONENT_T,
1374  wxT( "Cannot place field in invalid schematic component object." ) );
1375 
1376  undoItem = parentComponent;
1377  }
1378 
1379  if( item->IsNew() )
1380  {
1381  // When a new sheet is added to the hierarchy, a clear annotation can be needed
1382  // for all new sheet paths added by the new sheet (if this sheet is loaded from
1383  // and existing sheet or a existing file, it can also contain subsheets)
1384  bool doClearAnnotation = false;
1385  SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
1386 
1387  if( item->Type() == SCH_SHEET_T )
1388  {
1389  // Fix the size and position of the new sheet using the last values set by
1390  // the m_mouseCaptureCallback function.
1391  m_canvas->SetMouseCapture( NULL, NULL );
1392 
1393  if( !EditSheet( (SCH_SHEET*)item, m_CurrentSheet, &doClearAnnotation ) )
1394  {
1395  screen->SetCurItem( NULL );
1396  delete item;
1397 
1398  return;
1399  }
1400 
1401  SetSheetNumberAndCount();
1402 
1403  if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
1404  AddToScreen( item );
1405 
1406  SetRepeatItem( item );
1407  SaveCopyInUndoList( undoItem, UR_NEW );
1408  }
1409  else if( item->Type() == SCH_SHEET_PIN_T )
1410  {
1411  // Sheet pins are owned by their parent sheet.
1412  SaveCopyInUndoList( undoItem, UR_CHANGED ); // save the parent sheet
1413 
1414  parentSheet->AddPin( (SCH_SHEET_PIN*) item );
1415  }
1416  else if( item->Type() == SCH_FIELD_T )
1417  {
1418  // Component fields are also owned by their parent, but new component fields
1419  // are handled elsewhere.
1420  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1421  }
1422  else
1423  {
1424  if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
1425  AddToScreen( item );
1426 
1427  SetRepeatItem( item );
1428  SaveCopyInUndoList( undoItem, UR_NEW );
1429  }
1430 
1431  if( doClearAnnotation )
1432  {
1433  // Clear annotation of new sheet paths: the new sheet and its sub-sheets
1434  // If needed the missing alternate references of components will be created
1435  SCH_SCREENS screensList( g_RootSheet );
1436  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
1437  }
1438  }
1439  else
1440  {
1441  SaveUndoItemInUndoList( undoItem );
1442  }
1443 
1444  item->ClearFlags();
1445 
1446  screen->SetModify();
1447  screen->SetCurItem( NULL );
1448  m_canvas->SetMouseCapture( NULL, NULL );
1449  m_canvas->EndMouseCapture();
1450 
1451  RefreshItem( item );
1452 
1453  if( item->IsConnectable() )
1454  {
1455  std::vector< wxPoint > pts;
1456  item->GetConnectionPoints( pts );
1457 
1458  for( auto i = pts.begin(); i != pts.end(); i++ )
1459  {
1460  for( auto j = i + 1; j != pts.end(); j++ )
1461  TrimWire( *i, *j, true );
1462 
1463  if( screen->IsJunctionNeeded( *i, true ) )
1464  AddJunction( *i, true );
1465  }
1466 
1467  TestDanglingEnds();
1468  }
1469 
1470  GetCanvas()->Refresh();
1471 }
1472 
1473 
1475 {
1476  wxString title;
1477 
1478  if( GetScreen()->GetFileName() == m_DefaultSchematicFileName )
1479  {
1480  title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s" ), GetChars( GetScreen()->GetFileName() ) );
1481  }
1482  else
1483  {
1484  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1485  wxFileName fn = fileName;
1486 
1487  title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s [%s] \u2014 %s" ),
1488  GetChars( fn.GetName() ),
1489  GetChars( m_CurrentSheet->PathHumanReadable() ),
1490  GetChars( fn.GetPath() ) );
1491 
1492  if( fn.FileExists() )
1493  {
1494  if( !fn.IsFileWritable() )
1495  title += _( " [Read Only]" );
1496  }
1497  else
1498  title += _( " [no file]" );
1499  }
1500 
1501  SetTitle( title );
1502 }
1503 
1504 
1506 {
1508 
1509  ReCreateHToolbar();
1510  ReCreateVToolbar();
1511  ReCreateOptToolbar();
1512  Layout();
1513  SendSizeEvent();
1514 }
1515 
1516 
1518 {
1519  // call my base class
1521 
1522  // tooltips in toolbars
1523  ReCreateHToolbar();
1524  ReCreateVToolbar();
1525  ReCreateOptToolbar();
1526 
1527  // status bar
1528  UpdateMsgPanel();
1529 }
1530 
1531 
1533 {
1534  EDA_DRAW_FRAME::SetScreen( aScreen );
1535  auto c = static_cast<SCH_DRAW_PANEL*>(m_canvas);
1536  c->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
1537 }
1538 
1539 
1541 {
1542  int sizeX = GetScreen()->GetPageSettings().GetWidthIU();
1543  int sizeY = GetScreen()->GetPageSettings().GetHeightIU();
1544 
1545  return BOX2I( VECTOR2I(0, 0), VECTOR2I( sizeX, sizeY ) );
1546 }
1547 
const std::string NetlistFileExtension
void OnLoadProject(wxCommandEvent &event)
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
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:201
void OnOpenCvpcb(wxCommandEvent &event)
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Function HandleUnsavedChanges displays a dialog with Save, Cancel and Discard Changes buttons...
Definition: confirm.cpp:213
#define FN_LEN_MAX
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:258
bool IsModified()
Function IsModified checks the entire hierarchy for any modifications.
void CommonSettingsChanged() override
Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have ...
KiCad executable names.
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:120
BOX2< VECTOR2I > BOX2I
Definition: box2.h:520
SCH_EDIT_FRAME::OnSelectTool SCH_EDIT_FRAME::OnEditItem ID_POPUP_GENERAL_END_RANGE
Part library alias object definition.
void Process_Config(wxCommandEvent &event)
SCH_SCREEN * GetNext()
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions EVT_UPDATE_UI(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard) EVT_UPDATE_UI(ID_MODEDIT_INSERT_MODULE_IN_BOARD
void CloseErc()
Close the ERC dialog if it is open.
void OnMoveItem(wxCommandEvent &aEvent)
Handle the ID_SCH_MOVE_ITEM event used to move schematic items.
Definition: schedit.cpp:387
void OnFindItems(wxCommandEvent &event)
wxString SchematicFileWildcard()
void OnLoadFile(wxCommandEvent &event)
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)
virtual void OnEditSymbolLibTable(wxCommandEvent &aEvent)
void OnOpenLibraryViewer(wxCommandEvent &event)
Open the library viewer only to browse library contents.
void OnUpdateHiddenPins(wxUpdateUIEvent &event)
EVT_TOOL_RANGE(ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END, SCH_EDIT_FRAME::OnSelectTool) EVT_TOOL_RANGE(ID_SCHEMATIC_PLACE_MENU_START
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:259
This file is part of the common library TODO brief description.
void OnOpenPcbModuleEditor(wxCommandEvent &event)
void LoadAllLibraries(PROJECT *aProject, bool aShowProgress=true)
Load all of the project&#39;s libraries into this container, which should be cleared before calling it...
void OnPreferencesOptions(wxCommandEvent &event)
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:219
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:325
static void add_search_paths(SEARCH_STACK *aDst, const SEARCH_STACK &aSrc, int aIndex)
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
const wxString PCBNEW_EXE
const std::string LegacyPcbFileExtension
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
void OnSockRequestServer(wxSocketEvent &evt)
Definition: eda_dde.cpp:103
virtual void SetScreen(BASE_SCREEN *aScreen) override
virtual void SetScreen(BASE_SCREEN *aScreen)
Definition: draw_frame.h:181
void OnNewProject(wxCommandEvent &event)
void OnUpdateRemapSymbols(wxUpdateUIEvent &aEvent)
void OnFindDialogClose(wxFindDialogEvent &event)
void OnConfigurePaths(wxCommandEvent &aEvent)
PROJECT & Prj()
Definition: kicad.cpp:292
int CountSheets()
Count the number of sheets found in "this" sheet includeing all of the subsheets. ...
Definition: sch_sheet.cpp:640
#define KICTL_CREATE
caller thinks requested project files may not exist
Definition: kiway_player.h:140
void OnLaunchBomManager(wxCommandEvent &event)
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:104
const wxString & GetFileName() const
Definition: sch_screen.h:131
VTBL_ENTRY wxApp & App()
Function App returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP, or kicad.exe.
Definition: pgm_base.cpp:188
void OnCloseWindow(wxCloseEvent &Event)
EDA_ITEM * GetParent() const
Definition: base_struct.h:211
void UpdateTitle()
Set the main window title bar text.
static const KICAD_T ComponentsOnly[]
A scan list for schematic component items only.
Annotate incrementally using the first free reference number.
void OnAppendProject(wxCommandEvent &event)
void OnPrint(wxCommandEvent &event)
Show the print dialog.
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
Schematic editor (Eeschema) main window.
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
Definition: dialog_bom.cpp:213
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
Definition: id.h:66
ID_SCHEMATIC_PLACE_MENU_END
void OnRescueProject(wxCommandEvent &event)
VTBL_ENTRY _ELEM * GetElem(ELEM_T aIndex)
Typically wrapped somewhere else in a more meaningful function wrapper.
Definition: project.cpp:205
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
#define EVT_FIND_DRC_MARKER(id, fn)
void CopyToClipboard(wxCommandEvent &event)
Copy the current page or the current block to the clipboard.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
The base class for create windows for drawing purpose.
Definition: draw_frame.h:78
void Format(OUTPUTFORMATTER *aOutputFormatter, int aCtl)
Function Format outputs this s-expression netlist into aOutputFormatter.
void PushPreferences(const EDA_DRAW_PANEL *aParentCanvas)
Push preferences from a parent window to a child window.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:279
SCH_ITEM * Next() const
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
Definition: sch_sheet.cpp:177
Implementing DIALOG_SCH_FIND_BASE.
void OnCopySchematicItemRequest(wxCommandEvent &event)
Command event handler for duplicating the item at the current location.
Symbol library viewer main window.
Definition: viewlib_frame.h:44
void OnUpdateHierarchySheet(wxUpdateUIEvent &aEvent)
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.
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:179
SCH_EDIT_FRAME::OnSelectTool SCH_EDIT_FRAME::OnEditItem SCH_EDIT_FRAME::Process_Special_Functions ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT
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...
void GetKicadHelp(wxCommandEvent &event)
void OnUpdateSave(wxUpdateUIEvent &aEvent)
void OnImportProject(wxCommandEvent &event)
Class NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected item...
#define SCH_EDIT_FRAME_NAME
Definition: draw_frame.h:50
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:217
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:386
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual wxString GetScreenDesc() const override
#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
int GetConvert() const
Class TOOL_MANAGER.
Definition: tool_manager.h:49
virtual const BOX2I GetDocumentExtents() const override
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
#define NAMELESS_PROJECT
void ShowChangedLanguage() override
Function ShowChangedLanguage redraws the menus and what not in current language.
double BestZoom() override
Return the zoom level which displays the full page on screen.
Class EDA_HOTKEY_CLIENT_DATA provides client data member for hotkeys to include in command events gen...
SCH_EDIT_FRAME::OnSelectTool EVT_MENU_RANGE(ID_SCH_ROTATE_CLOCKWISE, ID_SCH_ROTATE_COUNTERCLOCKWISE, SCH_EDIT_FRAME::OnRotate) EVT_MENU_RANGE(ID_SCH_EDIT_ITEM
void Save_File(wxCommandEvent &event)
int InvokeDialogPrintUsingPrinter(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_PRINT_USING_PRINTER and return whatever DIALOG_PRINT_USING_PRINTER::ShowModal(...
Class LSET is a set of PCB_LAYER_IDs.
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
virtual void SwapData(SCH_ITEM *aItem)
Function SwapData swap the internal data structures aItem with the schematic item.
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
wxFileName m_project_name
<fullpath>/<basename>.pro
Definition: project.h:322
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void OnUpdatePaste(wxUpdateUIEvent &event)
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: sch_screen.h:196
KICAD_T Type() override
int ShowQuasiModal()
static int Split(wxArrayString *aResult, const wxString &aPathString)
Function Split separates aPathString into individual paths.
Subclass of DIALOG_SCH_FIND_BASE, which is generated by wxFormBuilder.
void ListSet(const wxString &aList)
Function ListSet Add a list of items.
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
const std::string SchematicFileExtension
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item...
Annotate by position of component in the schematic sheet object list.
SCH_SHEET_PATH & GetCurrentSheet()
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&#39;s directory to be an absolu...
Definition: project.cpp:380
Class NETLIST_EXPORTER_KICAD generates the kicad netlist format supported by pcbnew.
void PlotSchematic(wxCommandEvent &event)
void Clear()
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:159
void GetKicadAbout(wxCommandEvent &event)
The common library.
Helper dialog and control classes.
SCH->PCB forward update.
Definition: mail_type.h:43
void OnSaveProject(wxCommandEvent &aEvent)
Command event handler to save the entire project and create a component library archive.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
void OnUpdateFields(wxCommandEvent &event)
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...
void OnAutoplaceFields(wxCommandEvent &aEvent)
Handle the ID_AUTOPLACE_FIELDS event.
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#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.
int GetUnit() const
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)
bool LoadComponentAndSelectLib(const LIB_ID &aLibId, int aUnit, int aConvert)
Selects the currently active library and loads the symbol from aLibId.
Definition: libedit.cpp:103
void OnLoadCmpToFootprintLinkFile(wxCommandEvent &event)
Specialization of the wxAuiPaneInfo class for KiCad panels.
void GetSchematicFromRedoList(wxCommandEvent &event)
Redo the last edit.
int InvokeDialogUpdateFields(SCH_EDIT_FRAME *aCaller, const list< SCH_COMPONENT * > aComponents, bool aCreateUndoEntry)
void MessageSet(const wxString &message)
Function MessageSet adds a message (in bold) to message list.
void OnUpdateBusOrientation(wxUpdateUIEvent &event)
Implementing SIM_PLOT_FRAME_BASE.
void OnOpenLibraryEditor(wxCommandEvent &event)
EDA_PANE & Canvas()
Function Canvas Turn *this into an undecorated pane suitable for a drawing canvas.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar EVT_MENU(ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, FOOTPRINT_EDIT_FRAME::ProcessPreferences) EVT_MENU(ID_PCB_LIB_TABLE_EDIT
void OnCancelCurrentCommand(wxCommandEvent &aEvent)
Definition: schedit.cpp:462
void OnEditComponentSymbolsId(wxCommandEvent &aEvent)
void doUpdatePcb(const wxString &aUpdateOptions="")
Updates netlist and sends it to pcbnew.
bool IsSingle() const
Function IsSingle is this KIFACE_I running under single_top?
Definition: kiface_i.h:115
void OnAnnotate(wxCommandEvent &event)
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)
void OnSockRequest(wxSocketEvent &evt)
Definition: eda_dde.cpp:71
eeschema ERC modeless dialog ID
Definition: id.h:284
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:160
#define GR_DEFAULT_DRAWMODE
Definition: general.h:70
Definition the SCH_COMPONENT class for Eeschema.
SCH_EDIT_FRAME::OnSelectTool ID_SCH_EDIT_COMPONENT_FOOTPRINT
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
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&#39;s report and his call site information: CPP source file, function, and line number.
Definition: ki_exception.h:123
#define AUTOSAVE_PREFIX_FILENAME
Prefix to create filenames for schematic files or other difile when auto-saved to retrieve a crash...
The symbol library editor main window.
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 UpdateSymbolLinks(bool aForce=false)
Initialize or reinitialize the weak reference to the LIB_PART for each SCH_COMPONENT found in the ful...
void OnExit(wxCommandEvent &event)
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
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void GetKicadContribute(wxCommandEvent &event)
wxString QuoteFullPath(wxFileName &fn, wxPathFormat format)
Quote return value of wxFileName::GetFullPath().
Definition: gestfich.cpp:417
void OnErc(wxCommandEvent &event)
#define GROUP_SCH_EDITOR
Definition: config_params.h:45
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:204
size_t i
Definition: json11.cpp:597
#define GNL_ALL
void DisplaySheet(const SCH_SHEET *aSheet)
void OnSelectTool(wxCommandEvent &aEvent)
Definition: schedit.cpp:488
void OnOpenPcbnew(wxCommandEvent &event)
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
void SetMaxUndoItems(int aMax)
Definition: base_screen.h:313
#define NET_PLUGIN_CHANGE
Function InvokeDialogNetList creates and shows NETLIST_DIALOG and returns whatever NETLIST_DIALOG::Sh...
const LIB_ID & GetLibId() const
#define IU_PER_MILS
Definition: plotter.cpp:134
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.
wxString GetUniqueFilenameForCurrentSheet()
void OnCreateNetlist(wxCommandEvent &event)
void Process_PageSettings(wxCommandEvent &event)
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
void OnGridSettings(wxCommandEvent &aEvent) override
int m_NumberOfScreens
Definition: base_screen.h:217
Definition of class LIB_EDIT_FRAME.
void AnnotatePowerSymbols()
Function AnnotatePowerSymbols Silently annotates the not yet annotated power symbols of the entire hi...
#define DBG(x)
Definition: fctsys.h:33
SCH_SCREEN * GetFirst()
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...
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:129
static REPORTER & GetInstance()
Definition: reporter.cpp:104
Definition for part library class.
void ClearAnnotationOfNewSheetPaths(SCH_SHEET_LIST &aInitialSheetPathList)
Clear the annotation for the components inside new sheetpaths when a complex hierarchy is modified an...
void SetModify()
Definition: base_screen.h:324
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
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
void OnSelectItem(wxCommandEvent &aEvent)
void addCurrentItemToScreen()
Add the item currently being edited to the schematic and adds the changes to the undo/redo container...
void OnCreateBillOfMaterials(wxCommandEvent &event)
bool CheckIfOnDrawList(SCH_ITEM *st)
Definition: sch_screen.cpp:205
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.
std::string inputLine
problem line of input [say, from a LINE_READER].
Definition: ki_exception.h:132
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:245
void Process_Special_Functions(wxCommandEvent &event)
Definition: schedit.cpp:55
virtual void ShowChangedLanguage()
Function ShowChangedLanguage redraws the menus and what not in current language.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
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:673
void AddPaths(const wxString &aPaths, int aIndex=-1)
Function AddPaths insert or append path(s)
void CommonSettingsChanged() override
Called after the preferences dialog is run.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:523
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
void GetSchematicFromUndoList(wxCommandEvent &event)
Perform an undo the last edit.
KIWAY Kiway
void SelectAllFromSheet(wxCommandEvent &aEvent)
Handle the ID_POPUP_SCH_SELECT_ON_PCB event used to select items in Pcbnew based on the sheet they ar...
Definition: schedit.cpp:824
struct EDA_HOTKEY_CONFIG g_Schematic_Hokeys_Descr[]