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  m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
390 
391  m_toolManager = new TOOL_MANAGER;
392 
393  SetForceHVLines( true );
394  SetSpiceAjustPassiveValues( false );
395 
396  // Give an icon
397  wxIcon icon;
398  icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
399  SetIcon( icon );
400 
401  // Initialize grid id to the default value (50 mils):
403 
404  LoadSettings( config() );
405 
406  CreateScreens();
407 
408  SetPresetGrid( m_LastGridSizeId );
409 
410  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
411 
412  if( m_canvas )
413  m_canvas->SetEnableBlockCommands( true );
414 
415  ReCreateMenuBar();
416  ReCreateHToolbar();
417  ReCreateVToolbar();
418  ReCreateOptToolbar();
419 
420  // Initialize common print setup dialog settings.
421  m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
422  m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
423  m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
424  m_pageSetupData.GetPrintData().SetNoCopies( 1 );
425 
426  m_auimgr.SetManagedWindow( this );
427  m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
428 
429  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
430  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
431  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
432  m_auimgr.AddPane( m_canvas->GetWindow(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
433  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
434 
435  m_auimgr.Update();
436 
437  Zoom_Automatique( false );
438 
439  if( GetGalCanvas() )
440  GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
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 m_findReplaceData;
462  delete m_findReplaceStatus;
463 
464  delete g_RootSheet;
465  g_RootSheet = NULL;
466 }
467 
468 
470 {
471  // we cannot store a pointer to an item in the display list here since
472  // that item may be deleted, such as part of a line concatonation or other.
473  // So simply always keep a copy of the object which is to be repeated.
474 
475  SCH_ITEM* old = m_item_to_repeat;
476  SCH_ITEM* cur = aItem;
477 
478  if( cur != old )
479  {
480  if( cur )
481  {
482  aItem = (SCH_ITEM*) cur->Clone();
483 
484  // Clone() preserves the flags, we want 'em cleared.
485  aItem->ClearFlags();
486  }
487 
488  m_item_to_repeat = aItem;
489 
490  delete old;
491  }
492 }
493 
494 
496 {
497  SCH_SCREEN* screen;
498  SCH_SCREENS s_list;
499 
500  /* Set the sheet count, and the sheet number (1 for root sheet)
501  */
502  int sheet_count = g_RootSheet->CountSheets();
503  int SheetNumber = 1;
504  wxString current_sheetpath = m_CurrentSheet->Path();
505  SCH_SHEET_LIST sheetList( g_RootSheet );
506 
507  // Examine all sheets path to find the current sheets path,
508  // and count them from root to the current sheet path:
509  for( unsigned i = 0; i < sheetList.size(); i++ )
510  {
511  wxString sheetpath = sheetList[i].Path();
512 
513  if( sheetpath == current_sheetpath ) // Current sheet path found
514  break;
515 
516  SheetNumber++; /* Not found, increment sheet
517  * number before this current
518  * path */
519  }
520 
521  m_CurrentSheet->SetPageNumber( SheetNumber );
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  if( aSheet != *m_CurrentSheet )
588  {
589  *m_CurrentSheet = aSheet;
590 
591  static_cast<SCH_DRAW_PANEL*>( m_canvas )->DisplaySheet( m_CurrentSheet->LastScreen() );
592  }
593 }
594 
595 
597 {
598  static_cast<SCH_DRAW_PANEL*>( m_canvas )->DisplaySheet( m_CurrentSheet->LastScreen() );
599  GetCanvas()->Refresh();
600 }
601 
602 
604 {
605  // if aItem != NULL, delete a previous m_undoItem, if exists
606  // if aItme = NULL, just clear m_undoItem,
607  // because when calling SetUndoItem( NULL ), we only clear m_undoItem,
608  // because the owner of m_undoItem is no more me.
609  if( aItem && m_undoItem )
610  {
611  delete m_undoItem;
612  }
613 
614  m_undoItem = NULL;
615 
616  if( aItem )
617  m_undoItem = (SCH_ITEM*) aItem->Clone();
618 }
619 
620 
622 {
623  wxCHECK_RET( aItem != NULL,
624  wxT( "Cannot swap undo item structures. Bad programmer!." ) );
625  wxCHECK_RET( m_undoItem != NULL,
626  wxT( "Cannot swap undo item structures. Bad programmer!." ) );
627  wxCHECK_RET( aItem->Type() == m_undoItem->Type(),
628  wxT( "Cannot swap undo item structures. Bad programmer!." ) );
629 
630  aItem->SwapData( m_undoItem );
631  SaveCopyInUndoList( aItem, UR_CHANGED );
632  aItem->SwapData( m_undoItem );
633 }
634 
635 
636 void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
637 {
638  if( Kiface().IsSingle() )
639  {
640  LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
641  if( libeditFrame && !libeditFrame->Close() ) // Can close component editor?
642  return;
643 
644  LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
645  if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer?
646  return;
647 
648  viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
649 
650  if( viewlibFrame && !viewlibFrame->Close() ) // Can close modal component viewer?
651  return;
652  }
653 
654  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
655 
656  if( simFrame && !simFrame->Close() ) // Can close the simulator?
657  return;
658 
659  SCH_SHEET_LIST sheetList( g_RootSheet );
660 
661  if( sheetList.IsModified() )
662  {
663  wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
664  wxString msg = _( "Save changes to\n\"%s\"\nbefore closing?" );
665 
666  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName ),
667  [&]()->bool { return SaveProject(); } ) )
668  {
669  aEvent.Veto();
670  return;
671  }
672  }
673 
674  // Close the find dialog and preserve it's setting if it is displayed.
675  if( m_dlgFindReplace )
676  {
677  m_findStringHistoryList = m_dlgFindReplace->GetFindEntries();
678  m_replaceStringHistoryList = m_dlgFindReplace->GetReplaceEntries();
679  m_dlgFindReplace->Destroy();
680  m_dlgFindReplace = NULL;
681  }
682 
683  SCH_SCREENS screens;
684  wxFileName fn;
685 
686  for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
687  {
688  fn = Prj().AbsolutePath( screen->GetFileName() );
689 
690  // Auto save file name is the normal file name prepended with AUTOSAVE_PREFIX_FILENAME.
691  fn.SetName( AUTOSAVE_PREFIX_FILENAME + fn.GetName() );
692 
693  if( fn.FileExists() && fn.IsFileWritable() )
694  wxRemoveFile( fn.GetFullPath() );
695  }
696 
697  sheetList.ClearModifyStatus();
698 
699  wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
700 
701  if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty() &&
702  g_RootSheet->GetScreen()->GetDrawItems() != NULL )
703  {
704  UpdateFileHistory( fileName );
705  }
706 
708 
709  // all sub sheets are deleted, only the main sheet is usable
710  m_CurrentSheet->clear();
711 
712  Destroy();
713 }
714 
715 
717 {
718  double sizeX = (double) GetScreen()->GetPageSettings().GetWidthIU();
719  double sizeY = (double) GetScreen()->GetPageSettings().GetHeightIU();
720  wxPoint centre( wxPoint( sizeX / 2, sizeY / 2 ) );
721 
722  // The sheet boundary already affords us some margin, so add only an
723  // additional 5%.
724  double margin_scale_factor = 1.05;
725 
726  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
727 }
728 
729 
731 {
732  wxFileName fn = GetScreen()->GetFileName();
733 
734  // Name is <root sheet filename>-<sheet path> and has no extension.
735  // However if filename is too long name is <sheet filename>-<sheet number>
736 
737  #define FN_LEN_MAX 80 // A reasonable value for the short filename len
738 
739  wxString filename = fn.GetName();
740  wxString sheetFullName = m_CurrentSheet->PathHumanReadable();
741 
742  // Remove the last '/' of the path human readable
743  // (and for the root sheet, make sheetFullName empty):
744  sheetFullName.RemoveLast();
745 
746  sheetFullName.Trim( true );
747  sheetFullName.Trim( false );
748 
749  // Convert path human readable separator to '-'
750  sheetFullName.Replace( wxT( "/" ), wxT( "-" ) );
751 
752  if( ( filename.Len() + sheetFullName.Len() ) < FN_LEN_MAX )
753  filename += sheetFullName;
754  else
755  filename << wxT( "-" ) << GetScreen()->m_ScreenNumber;
756 
757  return filename;
758 }
759 
760 
762 {
763  GetScreen()->SetModify();
764  GetScreen()->SetSave();
765 
766  m_foundItems.SetForceSearch();
767 
768  m_canvas->Refresh();
769 }
770 
771 
772 void SCH_EDIT_FRAME::OnUpdatePaste( wxUpdateUIEvent& event )
773 {
774  event.Enable( m_blockItems.GetCount() > 0 );
775 }
776 
777 
778 void SCH_EDIT_FRAME::OnUpdateBusOrientation( wxUpdateUIEvent& aEvent )
779 {
780  wxString tool_tip = GetForceHVLines() ?
781  _( "Draw wires and buses in any direction" ) :
782  _( "Draw horizontal and vertical wires and buses only" );
783 
784  aEvent.Check( GetForceHVLines() );
785  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_BUS_WIRES_ORIENT, tool_tip );
786 }
787 
788 
789 void SCH_EDIT_FRAME::OnUpdateHiddenPins( wxUpdateUIEvent& aEvent )
790 {
791  wxString tool_tip = m_showAllPins ? _( "Do not show hidden pins" ) :
792  _( "Show hidden pins" );
793 
794  aEvent.Check( m_showAllPins );
795  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_HIDDEN_PINS, tool_tip );
796 }
797 
798 
799 void SCH_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
800 {
801  SCH_SHEET_LIST sheetList( g_RootSheet );
802 
803  aEvent.Enable( sheetList.IsModified() );
804 }
805 
806 
807 void SCH_EDIT_FRAME::OnUpdateRemapSymbols( wxUpdateUIEvent& aEvent )
808 {
809  SCH_SCREENS schematic;
810 
811  // The remapping can only be performed on legacy projects.
812  aEvent.Enable( schematic.HasNoFullyDefinedLibIds() );
813 }
814 
815 
816 void SCH_EDIT_FRAME::OnUpdateSaveSheet( wxUpdateUIEvent& aEvent )
817 {
818  aEvent.Enable( GetScreen()->IsModify() );
819 
820 }
821 
822 
823 void SCH_EDIT_FRAME::OnUpdateHierarchySheet( wxUpdateUIEvent& aEvent )
824 {
825  aEvent.Enable( m_CurrentSheet->Last() != g_RootSheet );
826 }
827 
828 
829 void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event )
830 {
831  // See if it's already open...
832  wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this );
833 
834  if( erc )
835  // Bring it to the top if already open. Dual monitor users need this.
836  erc->Raise();
837  else
838  InvokeDialogERC( this );
839 }
840 
841 
843 {
844  // Find the ERC dialog if it's open and close it
845  wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this );
846 
847  if( erc )
848  erc->Close( false );
849 }
850 
851 
852 void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
853 {
854  doUpdatePcb( "" );
855 }
856 
857 
858 void SCH_EDIT_FRAME::doUpdatePcb( const wxString& aUpdateOptions )
859 {
860  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
861 
862  fn.SetExt( PcbFileExtension );
863 
864  if( Kiface().IsSingle() )
865  {
866  DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is"
867  " opened in stand-alone mode. In order to create/update"
868  " PCBs from schematics, you need to launch Kicad shell"
869  " and create a PCB project." ) );
870  return;
871  }
872  else
873  {
874  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB, true );
875 
876  // a pcb frame can be already existing, but not yet used.
877  // this is the case when running the footprint editor, or the footprint viewer first
878  // if the frame is not visible, the board is not yet loaded
879  if( !frame->IsVisible() )
880  {
881  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
882  frame->Show( true );
883  }
884 
885  // On Windows, Raise() does not bring the window on screen, when iconized
886  if( frame->IsIconized() )
887  frame->Iconize( false );
888 
889  frame->Raise();
890  }
891 
892  if( aUpdateOptions.Contains( "quiet-annotate" ) )
893  {
894  SCH_SCREENS schematic;
895  schematic.UpdateSymbolLinks();
896  SCH_SHEET_LIST sheets( g_RootSheet );
897  sheets.AnnotatePowerSymbols();
898  AnnotateComponents( true, UNSORTED, INCREMENTAL_BY_REF, 0, false, false, true,
900  }
901 
902  if( !aUpdateOptions.Contains( "no-annotate" ) )
903  {
904  // Ensure the schematic is OK for a netlist creation
905  // (especially all components are annotated):
906  if( !prepareForNetlist() )
907  return;
908  }
909 
910  NETLIST_OBJECT_LIST* net_atoms = BuildNetListBase();
911  NETLIST_EXPORTER_KICAD exporter( this, net_atoms );
912  STRING_FORMATTER formatter;
913 
914  exporter.Format( &formatter, GNL_ALL );
915 
916  auto updateOptions = aUpdateOptions.ToStdString();
917  auto netlistString = formatter.GetString();
918  auto finalNetlist = updateOptions + "\n" + netlistString;
919 
920  // Now, send the "kicad" (s-expr) netlist to Pcbnew
921  Kiway().ExpressMail( FRAME_PCB, MAIL_SCH_PCB_UPDATE, finalNetlist, this );
922 }
923 
924 
925 void SCH_EDIT_FRAME::OnCreateNetlist( wxCommandEvent& event )
926 {
927  int result;
928 
929  do
930  {
931  result = InvokeDialogNetList( this );
932 
933  // If a plugin is removed or added, rebuild and reopen the new dialog
934 
935  } while( result == NET_PLUGIN_CHANGE );
936 }
937 
938 
940 {
941  InvokeDialogCreateBOM( this );
942 }
943 
944 
945 void SCH_EDIT_FRAME::OnLaunchBomManager( wxCommandEvent& event )
946 {
947  DIALOG_FIELDS_EDITOR_GLOBAL dlg( this );
948  dlg.ShowQuasiModal();
949 }
950 
951 
952 void SCH_EDIT_FRAME::OnFindItems( wxCommandEvent& aEvent )
953 {
954  wxCHECK_RET( m_findReplaceData != NULL,
955  wxT( "Forgot to create find/replace data. Bad Programmer!" ) );
956 
957  if( m_dlgFindReplace )
958  {
959  delete m_dlgFindReplace;
960  m_dlgFindReplace = NULL;
961  }
962 
963  int style = 0;
964 
965  if( aEvent.GetId() == wxID_REPLACE )
966  style = wxFR_REPLACEDIALOG;
967 
968  m_dlgFindReplace = new DIALOG_SCH_FIND( this, m_findReplaceData, m_findReplaceStatus,
969  wxDefaultPosition, wxDefaultSize, style );
970 
971  m_dlgFindReplace->SetFindEntries( m_findStringHistoryList );
972  m_dlgFindReplace->SetReplaceEntries( m_replaceStringHistoryList );
973  m_dlgFindReplace->Show( true );
974 }
975 
976 
977 void SCH_EDIT_FRAME::OnFindDialogClose( wxFindDialogEvent& event )
978 {
979  // If the user dismissed the dialog with the mouse, this will send the cursor back
980  // to the last item found.
981  OnFindSchematicItem( event );
982 
983  if( m_dlgFindReplace )
984  {
985  m_findStringHistoryList = m_dlgFindReplace->GetFindEntries();
986  m_replaceStringHistoryList = m_dlgFindReplace->GetReplaceEntries();
987  m_dlgFindReplace->Destroy();
988  m_dlgFindReplace = NULL;
989  }
990 }
991 
992 
993 void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
994 {
995  wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
996 
997  if( fn.size() )
998  OpenProjectFiles( std::vector<wxString>( 1, fn ) );
999 }
1000 
1001 
1003 {
1004  LoadCmpToFootprintLinkFile();
1005  m_canvas->Refresh();
1006 }
1007 
1008 
1009 void SCH_EDIT_FRAME::OnUpdateFields( wxCommandEvent& event )
1010 {
1011  std::list<SCH_COMPONENT*> components;
1012 
1013  for( SCH_ITEM* item = GetScreen()->GetDrawItems(); item; item = item->Next() )
1014  {
1015  if( item->Type() == SCH_COMPONENT_T )
1016  components.push_back( static_cast<SCH_COMPONENT*>( item ) );
1017  }
1018 
1019  if( InvokeDialogUpdateFields( this, components, true ) == wxID_OK )
1020  m_canvas->Refresh();
1021 }
1022 
1023 
1024 void SCH_EDIT_FRAME::OnNewProject( wxCommandEvent& event )
1025 {
1026  wxString pro_dir = m_mruPath;
1027 
1028  wxFileDialog dlg( this, _( "New Schematic" ), pro_dir,
1029  wxEmptyString, SchematicFileWildcard(),
1030  wxFD_SAVE );
1031 
1032  if( dlg.ShowModal() != wxID_CANCEL )
1033  {
1034  // Enforce the extension, wxFileDialog is inept.
1035  wxFileName create_me = dlg.GetPath();
1036  create_me.SetExt( SchematicFileExtension );
1037 
1038  if( create_me.FileExists() )
1039  {
1040  wxString msg;
1041  msg.Printf( _( "Schematic file \"%s\" already exists." ), create_me.GetFullName() );
1042  DisplayError( this, msg );
1043  return ;
1044  }
1045 
1046  // OpenProjectFiles() requires absolute
1047  wxASSERT_MSG( create_me.IsAbsolute(), "wxFileDialog returned non-absolute path" );
1048 
1049  OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
1050  m_mruPath = create_me.GetPath();
1051  }
1052 }
1053 
1054 
1055 void SCH_EDIT_FRAME::OnLoadProject( wxCommandEvent& event )
1056 {
1057  wxString pro_dir = m_mruPath;
1058 
1059  wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir,
1060  wxEmptyString, SchematicFileWildcard(),
1061  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1062 
1063  if( dlg.ShowModal() != wxID_CANCEL )
1064  {
1065  OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
1066  m_mruPath = Prj().GetProjectPath();
1067  }
1068 }
1069 
1070 
1071 void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
1072 {
1073  wxFileName kicad_board = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
1074 
1075  if( kicad_board.IsOk() )
1076  {
1077  kicad_board.SetExt( PcbFileExtension );
1078  wxFileName legacy_board( kicad_board );
1079  legacy_board.SetExt( LegacyPcbFileExtension );
1080  wxFileName& boardfn = ( !legacy_board.FileExists() || kicad_board.FileExists() ) ?
1081  kicad_board : legacy_board;
1082 
1083  if( Kiface().IsSingle() )
1084  {
1085  wxString filename = QuoteFullPath( boardfn );
1086  ExecuteFile( this, PCBNEW_EXE, filename );
1087  }
1088  else
1089  {
1090  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB, true );
1091 
1092  // a pcb frame can be already existing, but not yet used.
1093  // this is the case when running the footprint editor, or the footprint viewer first
1094  // if the frame is not visible, the board is not yet loaded
1095  if( !frame->IsVisible() )
1096  {
1097  frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1098  frame->Show( true );
1099  }
1100 
1101  // On Windows, Raise() does not bring the window on screen, when iconized
1102  if( frame->IsIconized() )
1103  frame->Iconize( false );
1104 
1105  frame->Raise();
1106  }
1107  }
1108  else
1109  {
1110  ExecuteFile( this, PCBNEW_EXE );
1111  }
1112 }
1113 
1114 
1115 void SCH_EDIT_FRAME::OnOpenPcbModuleEditor( wxCommandEvent& event )
1116 {
1117  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
1118 
1119  if( fn.IsOk() )
1120  {
1122 
1123  // On Windows, Raise() does not bring the window on screen, when iconized
1124  if( fp_editor->IsIconized() )
1125  fp_editor->Iconize( false );
1126 
1127  fp_editor->Show( true );
1128  fp_editor->Raise();
1129  }
1130 }
1131 
1132 
1133 void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
1134 {
1135  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
1136  fn.SetExt( NetlistFileExtension );
1137 
1138  if( !prepareForNetlist() )
1139  return;
1140 
1141  try
1142  {
1143  KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1144 
1145  if( !player )
1146  {
1147  player = Kiway().Player( FRAME_CVPCB, true );
1148  player->Show( true );
1149  // player->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1150  }
1151 
1152  sendNetlist();
1153 
1154  player->Raise();
1155  }
1156  catch( const IO_ERROR& )
1157  {
1158  DisplayError( this, _( "Could not open CvPcb" ) );
1159  }
1160 }
1161 
1162 
1163 void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
1164 {
1165  SCH_COMPONENT* component = NULL;
1166 
1167  if( event.GetId() == ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP )
1168  {
1169  // We want to edit a component with Libedit.
1170  // we are here by a hot key, or by a popup menu
1171  SCH_ITEM* item = GetScreen()->GetCurItem();
1172 
1173  if( !item )
1174  {
1175  // If we didn't get here by a hot key, then something has gone wrong.
1176  if( event.GetInt() == 0 )
1177  return;
1178 
1179  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) event.GetClientObject();
1180 
1181  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1182 
1183  // Set the locat filter, according to the edit command
1184  const KICAD_T* filterList = SCH_COLLECTOR::ComponentsOnly;
1185  item = LocateAndShowItem( data->GetPosition(), filterList, event.GetInt() );
1186 
1187  // Exit if no item found at the current location or the item is already being edited.
1188  if( (item == NULL) || (item->GetFlags() != 0) )
1189  return;
1190  }
1191 
1192 
1193  if( !item || (item->GetFlags() != 0) || ( item->Type() != SCH_COMPONENT_T ) )
1194  {
1195  wxMessageBox( _( "Error: not a symbol or no symbol." ) );
1196  return;
1197  }
1198 
1199  component = (SCH_COMPONENT*) item;
1200  }
1201 
1202  LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
1203 
1204  if( !libeditFrame )
1205  {
1206  libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, true );
1207  libeditFrame->Show( true );
1208  }
1209 
1210  libeditFrame->PushPreferences( m_canvas );
1211 
1212  // On Windows, Raise() does not bring the window on screen, when iconized
1213  if( libeditFrame->IsIconized() )
1214  libeditFrame->Iconize( false );
1215 
1216  libeditFrame->Raise();
1217 
1218  if( component )
1219  {
1220  LIB_ID id = component->GetLibId();
1221  LIB_ALIAS* entry = nullptr;
1222 
1223  try
1224  {
1225  entry = Prj().SchSymbolLibTable()->LoadSymbol( id );
1226  }
1227  catch( const IO_ERROR& ioe )
1228  {
1229  wxString msg;
1230 
1231  msg.Printf( _( "Error occurred loading symbol \"%s\" from library \"%s\"." ),
1232  id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
1233  DisplayErrorMessage( this, msg, ioe.What() );
1234  return;
1235  }
1236 
1237  if( !entry ) // Should not occur
1238  return;
1239 
1240  libeditFrame->LoadComponentAndSelectLib( id, component->GetUnit(), component->GetConvert() );
1241  }
1242 
1243  SchematicCleanUp();
1244  m_canvas->Refresh();
1245 }
1246 
1247 
1248 void SCH_EDIT_FRAME::OnRescueProject( wxCommandEvent& event )
1249 {
1250  SCH_SCREENS schematic;
1251 
1252  if( schematic.HasNoFullyDefinedLibIds() )
1253  RescueLegacyProject( true );
1254  else
1255  RescueSymbolLibTableProject( true );
1256 }
1257 
1258 
1259 void SCH_EDIT_FRAME::OnRemapSymbols( wxCommandEvent& event )
1260 {
1261  DIALOG_SYMBOL_REMAP dlgRemap( this );
1262 
1263  dlgRemap.ShowQuasiModal();
1264 
1265  m_canvas->Refresh( true );
1266 }
1267 
1268 
1269 // This method is not the same as OnRemapSymbols.
1270 // It allows renaming the lib id of groups of components when a symbol
1271 // has moved from a library to another library.
1272 // For instance to rename libname1::mysymbol to libname2::mysymbol
1273 // or any other lib id name
1274 void SCH_EDIT_FRAME::OnEditComponentSymbolsId( wxCommandEvent& event )
1275 {
1277  m_canvas->Refresh( true );
1278 }
1279 
1280 
1281 void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1282 {
1283  Close( false );
1284 }
1285 
1286 
1287 void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
1288 {
1290 
1291  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
1292 
1293  if( fn.GetName() != NAMELESS_PROJECT )
1294  {
1295  // was: wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParametersList() );
1296  Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_SCH_EDITOR,
1297  GetProjectFileParametersList() );
1298  }
1299 }
1300 
1301 
1302 void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode,
1303  void* aData )
1304 {
1305  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1306 
1307  GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE );
1308  DrawWorkSheet( aDC, GetScreen(), GetDefaultLineThickness(), IU_PER_MILS, fileName );
1309 }
1310 
1311 
1312 void SCH_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
1313 {
1314  int id = aEvent.GetId();
1315  int index = id - ID_SELECT_ITEM_START;
1316 
1317  if( (id >= ID_SELECT_ITEM_START && id <= ID_SELECT_ITEM_END)
1318  && (index >= 0 && index < m_collectedItems.GetCount()) )
1319  {
1320  SCH_ITEM* item = m_collectedItems[index];
1321  m_canvas->SetAbortRequest( false );
1322  GetScreen()->SetCurItem( item );
1323  }
1324 }
1325 
1326 
1328 {
1329  // In case this event happens before g_RootSheet is initialized which does happen
1330  // on mingw64 builds.
1331 
1332  if( g_RootSheet != NULL )
1333  {
1334  SCH_SCREENS screenList;
1335 
1336  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
1337  {
1338  if( screen->IsSave() )
1339  return true;
1340  }
1341  }
1342 
1343  return false;
1344 }
1345 
1346 
1348 {
1349  SCH_SCREEN* screen = GetScreen();
1350  SCH_ITEM* item = screen->GetCurItem();
1351 
1352  wxCHECK_RET( item != NULL, wxT( "Cannot add current item to list." ) );
1353 
1354  m_canvas->SetAutoPanRequest( false );
1355 
1356  SCH_SHEET* parentSheet = nullptr;
1357  SCH_COMPONENT* parentComponent = nullptr;
1358  SCH_ITEM* undoItem = item;
1359 
1360  if( item->Type() == SCH_SHEET_PIN_T )
1361  {
1362  parentSheet = (SCH_SHEET*) item->GetParent();
1363 
1364  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
1365  wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
1366 
1367  undoItem = parentSheet;
1368  }
1369 
1370  else if( item->Type() == SCH_FIELD_T )
1371  {
1372  parentComponent = (SCH_COMPONENT*) item->GetParent();
1373 
1374  wxCHECK_RET( parentComponent && parentComponent->Type() == SCH_COMPONENT_T,
1375  wxT( "Cannot place field in invalid schematic component object." ) );
1376 
1377  undoItem = parentComponent;
1378  }
1379 
1380  if( item->IsNew() )
1381  {
1382  // When a new sheet is added to the hierarchy, a clear annotation can be needed
1383  // for all new sheet paths added by the new sheet (if this sheet is loaded from
1384  // and existing sheet or a existing file, it can also contain subsheets)
1385  bool doClearAnnotation = false;
1386  SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
1387 
1388  if( item->Type() == SCH_SHEET_T )
1389  {
1390  // Fix the size and position of the new sheet using the last values set by
1391  // the m_mouseCaptureCallback function.
1392  m_canvas->SetMouseCapture( NULL, NULL );
1393 
1394  if( !EditSheet( (SCH_SHEET*)item, m_CurrentSheet, &doClearAnnotation ) )
1395  {
1396  screen->SetCurItem( NULL );
1397  delete item;
1398 
1399  return;
1400  }
1401 
1402  SetSheetNumberAndCount();
1403 
1404  if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
1405  AddToScreen( item );
1406 
1407  SetRepeatItem( item );
1408  SaveCopyInUndoList( undoItem, UR_NEW );
1409  }
1410  else if( item->Type() == SCH_SHEET_PIN_T )
1411  {
1412  // Sheet pins are owned by their parent sheet.
1413  SaveCopyInUndoList( undoItem, UR_CHANGED ); // save the parent sheet
1414 
1415  parentSheet->AddPin( (SCH_SHEET_PIN*) item );
1416  }
1417  else if( item->Type() == SCH_FIELD_T )
1418  {
1419  // Component fields are also owned by their parent, but new component fields
1420  // are handled elsewhere.
1421  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1422  }
1423  else
1424  {
1425  if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
1426  AddToScreen( item );
1427 
1428  SetRepeatItem( item );
1429  SaveCopyInUndoList( undoItem, UR_NEW );
1430  }
1431 
1432  if( doClearAnnotation )
1433  {
1434  // Clear annotation of new sheet paths: the new sheet and its sub-sheets
1435  // If needed the missing alternate references of components will be created
1436  SCH_SCREENS screensList( g_RootSheet );
1437  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
1438  }
1439  }
1440  else
1441  {
1442  SaveUndoItemInUndoList( undoItem );
1443  }
1444 
1445  item->ClearFlags();
1446 
1447  screen->SetModify();
1448  screen->SetCurItem( NULL );
1449  m_canvas->SetMouseCapture( NULL, NULL );
1450  m_canvas->EndMouseCapture();
1451 
1452  RefreshItem( item );
1453 
1454  if( item->IsConnectable() )
1455  {
1456  std::vector< wxPoint > pts;
1457  item->GetConnectionPoints( pts );
1458 
1459  for( auto i = pts.begin(); i != pts.end(); i++ )
1460  {
1461  for( auto j = i + 1; j != pts.end(); j++ )
1462  TrimWire( *i, *j, true );
1463 
1464  if( screen->IsJunctionNeeded( *i, true ) )
1465  AddJunction( *i, true );
1466  }
1467 
1468  TestDanglingEnds();
1469  }
1470 
1471  GetCanvas()->Refresh();
1472 }
1473 
1474 
1476 {
1477  wxString title;
1478 
1479  if( GetScreen()->GetFileName() == m_DefaultSchematicFileName )
1480  {
1481  title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s" ), GetChars( GetScreen()->GetFileName() ) );
1482  }
1483  else
1484  {
1485  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1486  wxFileName fn = fileName;
1487 
1488  title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s [%s] \u2014 %s" ),
1489  GetChars( fn.GetName() ),
1490  GetChars( m_CurrentSheet->PathHumanReadable() ),
1491  GetChars( fn.GetPath() ) );
1492 
1493  if( fn.FileExists() )
1494  {
1495  if( !fn.IsFileWritable() )
1496  title += _( " [Read Only]" );
1497  }
1498  else
1499  title += _( " [no file]" );
1500  }
1501 
1502  SetTitle( title );
1503 }
1504 
1505 
1507 {
1509 
1510  ReCreateHToolbar();
1511  ReCreateVToolbar();
1512  ReCreateOptToolbar();
1513  Layout();
1514  SendSizeEvent();
1515 }
1516 
1517 
1519 {
1520  // Rebuild the sheet view (draw area and any other items):
1521  DisplayCurrentSheet();
1522 }
1523 
1524 
1526 {
1527  // call my base class
1529 
1530  // tooltips in toolbars
1531  ReCreateHToolbar();
1532  ReCreateVToolbar();
1533  ReCreateOptToolbar();
1534 
1535  // status bar
1536  UpdateMsgPanel();
1537 }
1538 
1539 
1541 {
1542  EDA_DRAW_FRAME::SetScreen( aScreen );
1543  auto c = static_cast<SCH_DRAW_PANEL*>(m_canvas);
1544  c->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
1545 }
1546 
1547 
1549 {
1550  int sizeX = GetScreen()->GetPageSettings().GetWidthIU();
1551  int sizeY = GetScreen()->GetPageSettings().GetHeightIU();
1552 
1553  return BOX2I( VECTOR2I(0, 0), VECTOR2I( sizeX, sizeY ) );
1554 }
1555 
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:383
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:178
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:641
#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:185
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:215
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
Definition: id.h:66
void OnPageSettingsChange() override
Called when modifying the page settings.
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)
Definition of file extensions used in Kicad.
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:458
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:484
void OnOpenPcbnew(wxCommandEvent &event)
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:70
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:818
struct EDA_HOTKEY_CONFIG g_Schematic_Hokeys_Descr[]