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-2020 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 
25 #include <base_units.h>
26 #include <class_library.h>
27 #include <confirm.h>
28 #include <connection_graph.h>
30 #include <eeschema_id.h>
31 #include <executable_names.h>
32 #include <gestfich.h>
33 #include <hierarch.h>
35 #include <invoke_sch_dialog.h>
36 #include <kicad_string.h>
37 #include <kiface_i.h>
38 #include <kiplatform/app.h>
39 #include <kiway.h>
40 #include <symbol_edit_frame.h>
41 #include <symbol_viewer_frame.h>
42 #include <pgm_base.h>
43 #include <profile.h>
44 #include <project.h>
45 #include <project/project_file.h>
46 #include <project/net_settings.h>
47 #include <sch_edit_frame.h>
48 #include <sch_painter.h>
49 #include <sch_sheet.h>
50 #include <sch_marker.h>
51 #include <schematic.h>
53 #include <advanced_config.h>
54 #include <sim/sim_plot_frame.h>
55 #include <tool/action_manager.h>
56 #include <tool/action_toolbar.h>
57 #include <tool/common_control.h>
58 #include <tool/common_tools.h>
59 #include <tool/editor_conditions.h>
60 #include <tool/picker_tool.h>
61 #include <tool/selection.h>
62 #include <tool/tool_dispatcher.h>
63 #include <tool/tool_manager.h>
64 #include <tool/zoom_tool.h>
65 #include <tools/ee_actions.h>
67 #include <tools/ee_point_editor.h>
70 #include <tools/sch_edit_tool.h>
73 #include <tools/sch_move_tool.h>
75 #include <view/view_controls.h>
76 #include <widgets/infobar.h>
78 #include <wx/cmdline.h>
81 
82 // non-member so it can be moved easily, and kept REALLY private.
83 // Do NOT Clear() in here.
84 static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
85 {
86  for( unsigned i=0; i<aSrc.GetCount(); ++i )
87  aDst->AddPaths( aSrc[i], aIndex );
88 }
89 
90 
91 //-----<SCH "data on demand" functions>-------------------------------------------
92 
93 SEARCH_STACK* PROJECT::SchSearchS()
94 {
96 
97  wxASSERT( !ss || dynamic_cast<SEARCH_STACK*>( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
98 
99  if( !ss )
100  {
101  ss = new SEARCH_STACK();
102 
103  // Make PROJECT the new SEARCH_STACK owner.
105 
106  // to the empty SEARCH_STACK for SchSearchS(), add project dir as first
107  ss->AddPaths( m_project_name.GetPath() );
108 
109  // next add the paths found in *.pro, variable "LibDir"
110  wxString libDir;
111 
112  try
113  {
114  PART_LIBS::LibNamesAndPaths( this, false, &libDir );
115  }
116  catch( const IO_ERROR& )
117  {
118  }
119 
120  if( !!libDir )
121  {
122  wxArrayString paths;
123 
124  SEARCH_STACK::Split( &paths, libDir );
125 
126  for( unsigned i =0; i<paths.GetCount(); ++i )
127  {
128  wxString path = AbsolutePath( paths[i] );
129 
130  ss->AddPaths( path ); // at the end
131  }
132  }
133 
134  // append all paths from aSList
135  add_search_paths( ss, Kiface().KifaceSearch(), -1 );
136  }
137 
138  return ss;
139 }
140 
141 
142 PART_LIBS* PROJECT::SchLibs()
143 {
145 
146  wxASSERT( !libs || libs->Type() == PART_LIBS_T );
147 
148  if( !libs )
149  {
150  libs = new PART_LIBS();
151 
152  // Make PROJECT the new PART_LIBS owner.
154 
155  try
156  {
157  libs->LoadAllLibraries( this );
158  }
159  catch( const PARSE_ERROR& pe )
160  {
161  wxString lib_list = UTF8( pe.inputLine );
162  wxWindow* parent = Pgm().App().GetTopWindow();
163 
164  // parent of this dialog cannot be NULL since that breaks the Kiway() chain.
165  HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
166 
167  dlg.MessageSet( _( "The following libraries were not found:" ) );
168 
169  dlg.ListSet( lib_list );
170 
171  dlg.Layout();
172 
173  dlg.ShowModal();
174  }
175  catch( const IO_ERROR& ioe )
176  {
177  wxWindow* parent = Pgm().App().GetTopWindow();
178 
179  DisplayError( parent, ioe.What() );
180  }
181  }
182 
183  return libs;
184 }
185 
186 //-----</SCH "data on demand" functions>------------------------------------------
187 
188 
189 BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
192 
193  EVT_SIZE( SCH_EDIT_FRAME::OnSize )
194 
197 
200 
201  EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
202  EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
203 
205 END_EVENT_TABLE()
206 
207 
208 SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
209  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
211  m_highlightedConn( nullptr ),
212  m_item_to_repeat( nullptr )
213 {
214  m_maximizeByDefault = true;
215  m_schematic = new SCHEMATIC( nullptr );
216 
217  m_showBorderAndTitleBlock = true; // true to show sheet references
218  m_hasAutoSave = true;
219  m_aboutTitle = "Eeschema";
220 
221  m_findReplaceDialog = nullptr;
222 
223  // Give an icon
224  wxIcon icon;
225  wxIconBundle icon_bundle;
226 
227  icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
228  icon_bundle.AddIcon( icon );
229  icon.CopyFromBitmap( KiBitmap( icon_eeschema_32_xpm ) );
230  icon_bundle.AddIcon( icon );
231  icon.CopyFromBitmap( KiBitmap( icon_eeschema_16_xpm ) );
232  icon_bundle.AddIcon( icon );
233 
234  SetIcons( icon_bundle );
235 
236  LoadSettings( eeconfig() );
237 
238  // Also links the schematic to the loaded project
239  CreateScreens();
240 
241  // After schematic has been linked to project, SCHEMATIC_SETTINGS works
242  m_defaults = &m_schematic->Settings();
243  LoadProjectSettings();
244 
245  setupTools();
246  setupUIConditions();
247  ReCreateMenuBar();
248  ReCreateHToolbar();
249  ReCreateVToolbar();
250  ReCreateOptToolbar();
251 
252  // Initialize common print setup dialog settings.
253  m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
254  m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
255  m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
256  m_pageSetupData.GetPrintData().SetNoCopies( 1 );
257 
258  m_auimgr.SetManagedWindow( this );
259 
260  CreateInfoBar();
261  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
262  .Top().Layer( 6 ) );
263  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
264  .Left().Layer( 3 ) );
265  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
266  .Right().Layer( 2 ) );
267  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
268  .Center() );
269  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
270  .Bottom().Layer( 6 ) );
271 
272  FinishAUIInitialization();
273 
274  resolveCanvasType();
275  SwitchCanvas( m_canvasType );
276 
277  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
278 
279  // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
280  // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
281  Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
282 
283  if( GetCanvas() )
284  {
285  GetCanvas()->GetGAL()->SetAxesEnabled( false );
286 
287  if( auto p = dynamic_cast<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() ) )
288  p->SetSchematic( m_schematic );
289  }
290 
291  initExitKey();
292  setupUnits( eeconfig() );
293 
294  // Net list generator
295  DefaultExecFlags();
296 
297  UpdateTitle();
298 
299  // Default shutdown reason until a file is loaded
300  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
301 
302  // Ensure the window is on top
303  Raise();
304 }
305 
306 
308 {
309  // Shutdown all running tools
310  if( m_toolManager )
311  {
313  delete m_toolManager;
314  m_toolManager = nullptr;
315  }
316 
317  delete m_item_to_repeat; // we own the cloned object, see this->SaveCopyForRepeatItem()
318 
319  SetScreen( NULL );
320 
321  delete m_schematic;
322  m_schematic = nullptr;
323 
324  // Close the project if we are standalone, so it gets cleaned up properly
325  if( Kiface().IsSingle() )
327 }
328 
329 
331 {
332  // Create the manager and dispatcher & route draw panel events to the dispatcher
334  m_toolManager->SetEnvironment( &Schematic(), GetCanvas()->GetView(),
335  GetCanvas()->GetViewControls(), config(), this );
336  m_actions = new EE_ACTIONS();
338 
339  // Register tools
354 
355  // Run the selection tool, it is supposed to be always active
357 
359 }
360 
361 
363 {
365 
367  EDITOR_CONDITIONS cond( this );
368 
369  wxASSERT( mgr );
370 
371  auto hasElements =
372  [ this ] ( const SELECTION& aSel )
373  {
374  return !GetScreen()->Items().empty();
375  };
376 
377 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
378 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
379 
381  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
382  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
383 
391 
398  mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
399 
402 
403  auto showHiddenPinsCond =
404  [this] ( const SELECTION& )
405  {
406  return GetShowAllPins();
407  };
408 
409  auto forceHVCond =
410  [this] ( const SELECTION& )
411  {
412  return eeconfig()->m_Drawing.hv_lines_only;
413  };
414 
415  auto remapSymbolsCondition =
416  [&]( const SELECTION& aSel )
417  {
418  SCH_SCREENS schematic( Schematic().Root() );
419 
420  // The remapping can only be performed on legacy projects.
421  return schematic.HasNoFullyDefinedLibIds();
422  };
423 
424  auto belowRootSheetCondition =
425  [this]( const SELECTION& aSel )
426  {
427  return GetCurrentSheet().Last() != &Schematic().Root();
428  };
429 
430  mgr->SetConditions( EE_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
431  mgr->SetConditions( EE_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
432  mgr->SetConditions( EE_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
433  mgr->SetConditions( EE_ACTIONS::toggleForceHV, CHECK( forceHVCond ) );
434 
435 
436 #define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
437 
455 
456 #undef CURRENT_TOOL
457 #undef CHECK
458 #undef ENABLE
459 }
460 
461 
463 {
464  // we cannot store a pointer to an item in the display list here since
465  // that item may be deleted, such as part of a line concatenation or other.
466  // So simply always keep a copy of the object which is to be repeated.
467 
468  if( aItem )
469  {
470  delete m_item_to_repeat;
471 
472  m_item_to_repeat = (SCH_ITEM*) aItem->Clone();
473  // Clone() preserves the flags, we want 'em cleared.
475  }
476 }
477 
478 
480 {
481  return Schematic().GetSheets().GetItem( aId );
482 }
483 
484 
486 {
487  SCH_SCREEN* screen;
488  SCH_SCREENS s_list( Schematic().Root() );
489 
490  // Set the sheet count, and the sheet number (1 for root sheet)
491  int sheet_count = Schematic().Root().CountSheets();
492  int sheet_number = 1;
493  const KIID_PATH& current_sheetpath = GetCurrentSheet().Path();
494 
495  // @todo Remove all psuedo page number system is left over from prior to real page number
496  // implementation.
497  for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
498  {
499  if( sheet.Path() == current_sheetpath ) // Current sheet path found
500  break;
501 
502  sheet_number++; // Not found, increment before this current path
503  }
504 
505  for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
506  screen->SetPageCount( sheet_count );
507 
508  GetCurrentSheet().SetVirtualPageNumber( sheet_number );
509  GetScreen()->SetVirtualPageNumber( sheet_number );
510  GetScreen()->SetPageNumber( GetCurrentSheet().GetPageNumber() );
511 }
512 
513 
515 {
516  return GetCurrentSheet().LastScreen();
517 }
518 
519 
521 {
522  return *m_schematic;
523 }
524 
525 
527 {
528  wxString s = GetCurrentSheet().PathHumanReadable();
529 
530  return s;
531 }
532 
533 
535 {
536  m_schematic->Reset();
537  m_schematic->SetProject( &Prj() );
538 
540 
542 
543  SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
544  m_schematic->Root().SetScreen( rootScreen );
545  SetScreen( Schematic().RootScreen() );
546 
547  m_schematic->RootScreen()->SetFileName( wxEmptyString );
548 
549  if( GetScreen() == NULL )
550  {
551  SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
552  SetScreen( screen );
553  }
554 }
555 
556 
558 {
559  return m_schematic->CurrentSheet();
560 }
561 
562 
564 {
565  if( aSheet != GetCurrentSheet() )
566  {
567  FocusOnItem( nullptr );
568 
569  Schematic().SetCurrentSheet( aSheet );
570  GetCanvas()->DisplaySheet( aSheet.LastScreen() );
571  }
572 }
573 
574 
576 {
578 
579  FocusOnItem( nullptr );
580 
581  GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
582  GetCanvas()->ForceRefresh();
583 }
584 
585 
586 bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
587 {
588  // Exit interactive editing
589  // Note this this will commit *some* pending changes. For instance, the EE_POINT_EDITOR
590  // will cancel any drag currently in progress, but commit all changes from previous drags.
591  if( m_toolManager )
593 
594  // Shutdown blocks must be determined and vetoed as early as possible
595  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
596  && Schematic().GetSheets().IsModified() )
597  {
598  return false;
599  }
600 
601  if( Kiface().IsSingle() )
602  {
603  auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
604 
605  if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
606  return false;
607 
608  auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
609 
610  if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
611  return false;
612 
613  symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
614 
615  if( symbolViewer && !symbolViewer->Close() ) // Can close modal symbol viewer?
616  return false;
617  }
618 
619  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
620 
621  if( simFrame && !simFrame->Close() ) // Can close the simulator?
622  return false;
623 
624  // We may have gotten multiple events; don't clean up twice
625  if( !Schematic().IsValid() )
626  return false;
627 
628  SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
629 
630  if( sheetlist.IsModified() )
631  {
632  wxFileName fileName = Schematic().RootScreen()->GetFileName();
633  wxString msg = _( "Save changes to \"%s\" before closing?" );
634 
635  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
636  [&]()->bool { return SaveProject(); } ) )
637  {
638  return false;
639  }
640  }
641 
642  return true;
643 }
644 
645 
647 {
648  SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
649 
650  // Shutdown all running tools
651  if( m_toolManager )
653 
655 
656  // Close the find dialog and preserve it's setting if it is displayed.
657  if( m_findReplaceDialog )
658  {
661 
662  m_findReplaceDialog->Destroy();
663  m_findReplaceDialog = nullptr;
664  }
665 
666  if( FindHierarchyNavigator() )
667  FindHierarchyNavigator()->Close( true );
668 
669  SCH_SCREENS screens( Schematic().Root() );
670  wxFileName fn;
671 
672  for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
673  {
674  fn = Prj().AbsolutePath( screen->GetFileName() );
675 
676  // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
677  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
678 
679  if( fn.FileExists() && fn.IsFileWritable() )
680  wxRemoveFile( fn.GetFullPath() );
681  }
682 
683  sheetlist.ClearModifyStatus();
684 
685  wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
686 
687  if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
688  UpdateFileHistory( fileName );
689 
690  Schematic().RootScreen()->Clear();
691 
692  // all sub sheets are deleted, only the main sheet is usable
694 
695  // Clear view before destroying schematic as repaints depend on schematic being valid
696  SetScreen( nullptr );
697 
699  Schematic().Reset();
700 
701  Destroy();
702 }
703 
704 
706 {
707  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
708  ERC_SETTINGS& ercSettings = Schematic().ErcSettings();
709 
710  ercSettings.m_ErcExclusions.clear();
711 
712  for( unsigned i = 0; i < sheetList.size(); i++ )
713  {
714  for( SCH_ITEM* item : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) )
715  {
716  SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
717 
718  if( marker->IsExcluded() )
719  ercSettings.m_ErcExclusions.insert( marker->Serialize() );
720  }
721  }
722 }
723 
724 
726 {
727  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
728 
729  for( SCH_MARKER* marker : Schematic().ResolveERCExclusions() )
730  {
731  SCH_SHEET_PATH errorPath;
732  (void) sheetList.GetItem( marker->GetRCItem()->GetMainItemID(), &errorPath );
733 
734  if( errorPath.LastScreen() )
735  errorPath.LastScreen()->Append( marker );
736  else
737  Schematic().RootScreen()->Append( marker );
738  }
739 }
740 
741 
743 {
744  // Filename is rootSheetName-sheetName-...-sheetName
745  // Note that we need to fetch the rootSheetName out of its filename, as the root SCH_SHEET's
746  // name is just a timestamp.
747 
748  wxFileName rootFn( GetCurrentSheet().at( 0 )->GetFileName() );
749  wxString filename = rootFn.GetName();
750 
751  for( unsigned i = 1; i < GetCurrentSheet().size(); i++ )
752  filename += wxT( "-" ) + GetCurrentSheet().at( i )->GetName();
753 
754  return filename;
755 }
756 
757 
759 {
760  wxASSERT( GetScreen() );
761 
762  if( !GetScreen() )
763  return;
764 
765  GetScreen()->SetModify();
766  GetScreen()->SetSave();
767 
768  if( ADVANCED_CFG::GetCfg().m_RealTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime )
770 
772  []( KIGFX::VIEW_ITEM* aItem )
773  {
774  SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
775  SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
776 
777  if( connection && connection->HasDriverChanged() )
778  {
779  connection->ClearDriverChanged();
780  return true;
781  }
782 
783  return false;
784  } );
785 
786  GetCanvas()->Refresh();
788 }
789 
790 
791 void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
792 {
793  if( Kiface().IsSingle() )
794  {
795  DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
796  " in stand-alone mode. In order to create/update PCBs from"
797  " schematics, launch the Kicad shell and create a project." ) );
798  return;
799  }
800 
801  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
802 
803  if( !frame )
804  {
805  wxFileName fn = Prj().GetProjectFullName();
806  fn.SetExt( PcbFileExtension );
807 
808  frame = Kiway().Player( FRAME_PCB_EDITOR, true );
809  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
810  }
811 
812  if( !frame->IsVisible() )
813  frame->Show( true );
814 
815  // On Windows, Raise() does not bring the window on screen, when iconized
816  if( frame->IsIconized() )
817  frame->Iconize( false );
818 
819  frame->Raise();
820 
821  std::string payload;
822  Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_PCB_UPDATE, payload, this );
823 }
824 
825 
827 {
828  if( m_findReplaceDialog && m_findReplaceDialog->IsVisible()
829  && !m_findReplaceData->GetFindString().IsEmpty() )
830  {
831  return m_findReplaceData;
832  }
833 
834  return nullptr;
835 }
836 
837 
839 {
840  wxWindow* navigator = wxWindow::FindWindowByName( HIERARCHY_NAVIG_DLG_WNAME );
841 
842  return static_cast< HIERARCHY_NAVIG_DLG* >( navigator );
843 }
844 
845 
847 {
848  if( aForceUpdate )
849  {
850  if( FindHierarchyNavigator() )
851  FindHierarchyNavigator()->Close();
852 
853  HIERARCHY_NAVIG_DLG* hierarchyDialog = new HIERARCHY_NAVIG_DLG( this );
854 
855  hierarchyDialog->Show( true );
856  }
857  else
858  {
859  if( FindHierarchyNavigator() )
861  }
862 }
863 
864 
866 {
867  if( m_findReplaceDialog )
868  m_findReplaceDialog->Destroy();
869 
870  m_findReplaceDialog= new DIALOG_SCH_FIND( this, m_findReplaceData, wxDefaultPosition,
871  wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
872 
875  m_findReplaceDialog->Show( true );
876 }
877 
878 
879 void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime )
880 {
881  // Prepare the infobar, since we don't know its state
884 
885  m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
886 }
887 
888 
890 {
891  m_infoBar->Dismiss();
892 }
893 
894 
896 {
899 
900  m_findReplaceDialog->Destroy();
901  m_findReplaceDialog = nullptr;
902 
904 }
905 
906 
907 void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
908 {
909  wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
910 
911  if( fn.size() )
912  OpenProjectFiles( std::vector<wxString>( 1, fn ) );
913 }
914 
915 
916 void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
917 {
919 }
920 
921 
923 {
924  wxString pro_dir = m_mruPath;
925 
926  wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
927  KiCadSchematicFileWildcard(), wxFD_SAVE );
928 
929  if( dlg.ShowModal() != wxID_CANCEL )
930  {
931  // Enforce the extension, wxFileDialog is inept.
932  wxFileName create_me = dlg.GetPath();
933  create_me.SetExt( KiCadSchematicFileExtension );
934 
935  if( create_me.FileExists() )
936  {
937  wxString msg;
938  msg.Printf( _( "Schematic file \"%s\" already exists." ), create_me.GetFullName() );
939  DisplayError( this, msg );
940  return ;
941  }
942 
943  // OpenProjectFiles() requires absolute
944  wxASSERT_MSG( create_me.IsAbsolute(), "wxFileDialog returned non-absolute path" );
945 
946  OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
947  m_mruPath = create_me.GetPath();
948  }
949 }
950 
951 
953 {
954  wxString pro_dir = m_mruPath;
955  wxString wildcards = KiCadSchematicFileWildcard();
956 
957  wildcards += "|" + LegacySchematicFileWildcard();
958 
959  wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
960  wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
961 
962  if( dlg.ShowModal() != wxID_CANCEL )
963  {
964  OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
966  }
967 }
968 
969 
970 void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
971 {
972  wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
973 
974  if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() )
975  {
976  kicad_board.SetExt( PcbFileExtension );
977  wxFileName legacy_board( kicad_board );
978  legacy_board.SetExt( LegacyPcbFileExtension );
979  wxFileName& boardfn = legacy_board;
980 
981  if( !legacy_board.FileExists() || kicad_board.FileExists() )
982  boardfn = kicad_board;
983 
984  if( Kiface().IsSingle() )
985  {
986  wxString filename = QuoteFullPath( boardfn );
987  ExecuteFile( this, PCBNEW_EXE, filename );
988  }
989  else
990  {
991  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
992 
993  if( !frame )
994  {
995  frame = Kiway().Player( FRAME_PCB_EDITOR, true );
996  frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
997  }
998 
999  if( !frame->IsVisible() )
1000  frame->Show( true );
1001 
1002  // On Windows, Raise() does not bring the window on screen, when iconized
1003  if( frame->IsIconized() )
1004  frame->Iconize( false );
1005 
1006  frame->Raise();
1007  }
1008  }
1009  else
1010  {
1011  // If we are running inside a project, it should be impossible for this case to happen
1012  wxASSERT( Kiface().IsSingle() );
1013  ExecuteFile( this, PCBNEW_EXE );
1014  }
1015 }
1016 
1017 
1018 void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
1019 {
1020  wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
1021  fn.SetExt( NetlistFileExtension );
1022 
1023  if( !ReadyToNetlist() )
1024  return;
1025 
1026  try
1027  {
1028  KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1029 
1030  if( !player )
1031  {
1032  player = Kiway().Player( FRAME_CVPCB, true );
1033  player->Show( true );
1034  }
1035 
1037 
1038  player->Raise();
1039  }
1040  catch( const IO_ERROR& )
1041  {
1042  DisplayError( this, _( "Could not open CvPcb" ) );
1043  }
1044 }
1045 
1046 
1047 void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1048 {
1049  if( event.GetId() == wxID_EXIT )
1050  Kiway().OnKiCadExit();
1051 
1052  if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1053  Close( false );
1054 }
1055 
1056 
1058 {
1059  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1060 
1061  aSettings->GetPrintDC()->SetLogicalFunction( wxCOPY );
1062  GetScreen()->Print( aSettings );
1063  PrintWorkSheet( aSettings, GetScreen(), IU_PER_MILS, fileName );
1064 }
1065 
1066 
1068 {
1069  // In case this event happens before g_RootSheet is initialized which does happen
1070  // on mingw64 builds.
1071 
1072  if( Schematic().IsValid() )
1073  {
1074  SCH_SCREENS screenList( Schematic().Root() );
1075 
1076  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
1077  {
1078  if( screen->IsSave() )
1079  return true;
1080  }
1081  }
1082 
1083  return false;
1084 }
1085 
1086 
1087 static void inheritNetclass( const SCH_SHEET_PATH& aSheetPath, SCH_TEXT* aItem )
1088 {
1089  // Netclasses are assigned to subgraphs by association with their netname. However, when
1090  // a new label is attached to an existing subgraph (with an existing netclass association),
1091  // the association will be lost as the label will drive its name on to the graph.
1092  //
1093  // Here we find the previous driver of the subgraph and if it had a netclass we associate
1094  // the new netname with that netclass as well.
1095  //
1096  SCHEMATIC* schematic = aItem->Schematic();
1097  CONNECTION_SUBGRAPH* subgraph = schematic->ConnectionGraph()->GetSubgraphForItem( aItem );
1098 
1099  std::map<wxString, wxString>& netclassAssignments =
1101 
1102  if( subgraph )
1103  {
1104  SCH_ITEM* previousDriver = nullptr;
1106 
1107  for( SCH_ITEM* item : subgraph->m_drivers )
1108  {
1109  if( item == aItem )
1110  continue;
1111 
1113 
1114  if( p > priority )
1115  {
1116  priority = p;
1117  previousDriver = item;
1118  }
1119  }
1120 
1121  if( previousDriver )
1122  {
1123  wxString path = aSheetPath.PathHumanReadable();
1124  wxString oldDrivenName = path + subgraph->GetNameForDriver( previousDriver );
1125  wxString drivenName = path + subgraph->GetNameForDriver( aItem );
1126 
1127  if( netclassAssignments.count( oldDrivenName ) )
1128  netclassAssignments[ drivenName ] = netclassAssignments[ oldDrivenName ];
1129  }
1130  }
1131 }
1132 
1133 
1135  bool aUndoAppend )
1136 {
1137  wxCHECK_RET( aItem != NULL, wxT( "Cannot add null item to list." ) );
1138 
1139  SCH_SHEET* parentSheet = nullptr;
1140  SCH_COMPONENT* parentSymbol = nullptr;
1141  SCH_ITEM* undoItem = aItem;
1142 
1143  if( aItem->Type() == SCH_SHEET_PIN_T )
1144  {
1145  parentSheet = (SCH_SHEET*) aItem->GetParent();
1146 
1147  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
1148  wxT( "Cannot place sheet pin in invalid schematic sheet." ) );
1149 
1150  undoItem = parentSheet;
1151  }
1152 
1153  else if( aItem->Type() == SCH_FIELD_T )
1154  {
1155  parentSymbol = (SCH_COMPONENT*) aItem->GetParent();
1156 
1157  wxCHECK_RET( parentSymbol && parentSymbol->Type() == SCH_COMPONENT_T,
1158  wxT( "Cannot place field in invalid schematic symbol." ) );
1159 
1160  undoItem = parentSymbol;
1161  }
1162 
1163  if( aItem->IsNew() )
1164  {
1165  if( aItem->Type() == SCH_SHEET_PIN_T )
1166  {
1167  // Sheet pins are owned by their parent sheet.
1168  SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::CHANGED, aUndoAppend );
1169 
1170  parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
1171  }
1172  else if( aItem->Type() == SCH_FIELD_T )
1173  {
1174  // Symbol fields are also owned by their parent, but new symbol fields are
1175  // handled elsewhere.
1176  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1177  }
1178  else
1179  {
1180  if( !aScreen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
1181  AddToScreen( aItem, aScreen );
1182 
1183  SaveCopyForRepeatItem( aItem );
1184  SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::NEWITEM, aUndoAppend );
1185  }
1186 
1187  // Update connectivity info for new item
1188  if( !aItem->IsMoving() )
1189  {
1191 
1192  if( SCH_TEXT* textItem = dynamic_cast<SCH_TEXT*>( aItem ) )
1193  inheritNetclass( GetCurrentSheet(), textItem );
1194  }
1195  }
1196 
1197  aItem->ClearFlags( IS_NEW );
1198 
1199  aScreen->SetModify();
1200  UpdateItem( aItem );
1201 
1202  if( !aItem->IsMoving() && aItem->IsConnectable() )
1203  {
1204  std::vector< wxPoint > pts = aItem->GetConnectionPoints();
1205 
1206  for( auto i = pts.begin(); i != pts.end(); i++ )
1207  {
1208  for( auto j = i + 1; j != pts.end(); j++ )
1209  TrimWire( *i, *j );
1210 
1211  if( aScreen->IsJunctionNeeded( *i, true ) )
1212  AddJunction( aScreen, *i, true, false );
1213  }
1214 
1215  TestDanglingEnds();
1216 
1217  for( SCH_ITEM* item : aItem->ConnectedItems( GetCurrentSheet() ) )
1218  UpdateItem( item );
1219  }
1220 
1221  aItem->ClearEditFlags();
1222  GetCanvas()->Refresh();
1223 }
1224 
1225 
1227 {
1228  wxString title;
1229  wxString nofile = _( "[no file]" ) + wxS(" ");
1230  wxString app = _( "Eeschema" );
1231 
1232  if( GetScreen()->GetFileName().IsEmpty() )
1233  {
1234  title = nofile + wxT( "\u2014 " ) + app;
1235  }
1236  else
1237  {
1238  wxFileName fn( Prj().AbsolutePath( GetScreen()->GetFileName() ) );
1239  wxString append;
1240 
1241  if( fn.FileExists() )
1242  {
1243  if( !fn.IsFileWritable() )
1244  append = _( "[Read Only]" ) + wxS( " " );
1245  }
1246  else
1247  append = nofile;
1248 
1249  title.Printf( wxT( "%s [%s] %s\u2014 " ) + app,
1250  fn.GetName(),
1252  append );
1253  }
1254 
1255  SetTitle( title );
1256 }
1257 
1258 
1260 {
1261  SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1262  SCH_SHEET_LIST list = Schematic().GetSheets();
1263  PROF_COUNTER timer;
1264 
1265  // Ensure schematic graph is accurate
1266  if( aCleanupFlags == LOCAL_CLEANUP )
1267  {
1269  }
1270  else if( aCleanupFlags == GLOBAL_CLEANUP )
1271  {
1272  for( const auto& sheet : list )
1273  SchematicCleanUp( sheet.LastScreen() );
1274  }
1275 
1276  timer.Stop();
1277  wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
1278 
1279  if( settings.m_IntersheetRefsShow )
1281 
1282  std::function<void( SCH_ITEM* )> changeHandler =
1283  [&]( SCH_ITEM* aChangedItem ) -> void
1284  {
1285  GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1286  };
1287 
1288  Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler );
1289 }
1290 
1291 
1293 {
1294  std::map<wxString, std::set<wxString>>& pageRefsMap = Schematic().GetPageRefsMap();
1295 
1296  pageRefsMap.clear();
1297 
1298  SCH_SCREENS screens( Schematic().Root() );
1299  std::vector<wxString> pageNumbers;
1300 
1301  /* Iterate over screens */
1302  for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
1303  {
1304  pageNumbers.clear();
1305 
1306  /* Find in which sheets this screen is used */
1307  for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
1308  {
1309  if( sheet.LastScreen() == screen )
1310  pageNumbers.push_back( sheet.GetPageNumber() );
1311  }
1312 
1313  for( SCH_ITEM* item : screen->Items() )
1314  {
1315  if( item->Type() == SCH_GLOBAL_LABEL_T )
1316  {
1317  SCH_GLOBALLABEL* globalLabel = static_cast<SCH_GLOBALLABEL*>( item );
1318  std::set<wxString>& pageList = pageRefsMap[ globalLabel->GetText() ];
1319 
1320  for( const wxString& pageNo : pageNumbers )
1321  pageList.insert( pageNo );
1322  }
1323  }
1324  }
1325 
1326  bool show = Schematic().Settings().m_IntersheetRefsShow;
1327 
1328  /* Refresh all global labels */
1329  for( EDA_ITEM* item : GetScreen()->Items() )
1330  {
1331  if( item->Type() == SCH_GLOBAL_LABEL_T )
1332  {
1333  SCH_GLOBALLABEL* global = static_cast<SCH_GLOBALLABEL*>( item );
1334 
1335  global->GetIntersheetRefs()->SetVisible( show );
1336 
1337  if( show )
1338  GetCanvas()->GetView()->Update( global );
1339  }
1340  }
1341 }
1342 
1343 
1345 {
1346  if( aShow )
1348 
1349  SCH_SCREENS screens( Schematic().Root() );
1350 
1351  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
1352  {
1353  for( SCH_ITEM* item : screen->Items() )
1354  {
1355  if( item->Type() == SCH_GLOBAL_LABEL_T )
1356  {
1357  SCH_GLOBALLABEL* gLabel = (SCH_GLOBALLABEL*)( item );
1358  SCH_FIELD* intersheetRef = gLabel->GetIntersheetRefs();
1359 
1360  intersheetRef->SetVisible( aShow );
1361 
1362  if( aShow )
1363  AddToScreen( intersheetRef, screen );
1364  else
1365  RemoveFromScreen( intersheetRef, screen );
1366  }
1367  }
1368  }
1369 }
1370 
1371 
1372 void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1373 {
1374  SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1375  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1376 
1378 
1379  RecreateToolbars();
1380  Layout();
1381  SendSizeEvent();
1382 }
1383 
1384 
1386 {
1387  // Rebuild the sheet view (draw area and any other items):
1389 }
1390 
1391 
1393 {
1394  // call my base class
1396 
1397  // tooltips in toolbars
1398  RecreateToolbars();
1399 
1400  // status bar
1401  UpdateMsgPanel();
1402 
1403  // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
1404  // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
1405  // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
1406  // toolbar to update correctly.
1407 #if defined( __WXMSW__ )
1408  PostSizeEvent();
1409 #endif
1410 }
1411 
1412 
1414 {
1415  if( const SCH_CONNECTION* conn = GetHighlightedConnection() )
1416  {
1417  SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
1418  UnescapeString( conn->Name() ) ) );
1419  }
1420  else
1421  {
1422  SetStatusText( wxT( "" ) );
1423  }
1424 }
1425 
1426 
1428 {
1429  if( m_toolManager )
1431 
1432  SCH_BASE_FRAME::SetScreen( aScreen );
1433  GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
1434 }
1435 
1436 
1437 const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
1438 {
1439  BOX2I bBoxDoc;
1440 
1441  if( aIncludeAllVisible )
1442  {
1443  // Get the whole page size and return that
1444  int sizeX = GetScreen()->GetPageSettings().GetWidthIU();
1445  int sizeY = GetScreen()->GetPageSettings().GetHeightIU();
1446  bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
1447  }
1448  else
1449  {
1450  // Get current worksheet in a form we can compare to an EDA_ITEM
1452  EDA_ITEM* currWsAsItem = static_cast<EDA_ITEM*>( currWs );
1453 
1454  // Need an EDA_RECT so the first ".Merge" sees it's uninitialized
1455  EDA_RECT bBoxItems;
1456 
1457  // Calc the bounding box of all items on screen except the page border
1458  for( EDA_ITEM* item : GetScreen()->Items() )
1459  {
1460  if( item != currWsAsItem ) // Ignore the worksheet itself
1461  {
1462  if( item->Type() == SCH_COMPONENT_T )
1463  {
1464  // For symbols we need to get the bounding box without invisible text
1465  SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( item );
1466  bBoxItems.Merge( symbol->GetBoundingBox( false ) );
1467  }
1468  else
1469  bBoxItems.Merge( item->GetBoundingBox() );
1470  }
1471  bBoxDoc = bBoxItems;
1472  }
1473  }
1474  return bBoxDoc;
1475 }
1476 
1477 
1479 {
1480  // Save the current sheet, to retrieve it later
1481  SCH_SHEET_PATH oldsheetpath = GetCurrentSheet();
1482 
1483  bool modified = false;
1484 
1485  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1486 
1487  for( const SCH_SHEET_PATH& sheet : sheetList )
1488  {
1489  // We require a set here to avoid adding multiple junctions to the same spot
1490  std::set<wxPoint> junctions;
1491 
1492  SetCurrentSheet( sheet );
1494 
1495  SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
1496 
1497  for( auto aItem : screen->Items().OfType( SCH_COMPONENT_T ) )
1498  {
1499  auto cmp = static_cast<SCH_COMPONENT*>( aItem );
1500 
1501  for( const SCH_PIN* pin : cmp->GetPins( &sheet ) )
1502  {
1503  auto pos = pin->GetPosition();
1504 
1505  // Test if a _new_ junction is needed, and add it if missing
1506  if( screen->IsJunctionNeeded( pos, true ) )
1507  junctions.insert( pos );
1508  }
1509  }
1510 
1511  for( const wxPoint& pos : junctions )
1512  AddJunction( screen, pos, false, false );
1513 
1514  if( junctions.size() )
1515  modified = true;
1516  }
1517 
1518  if( modified )
1519  OnModify();
1520 
1521  // Reselect the initial sheet:
1522  SetCurrentSheet( oldsheetpath );
1524  SetScreen( GetCurrentSheet().LastScreen() );
1525 }
1526 
1527 
1529 {
1530  return Schematic().GetSheets().IsModified();
1531 }
1532 
1533 
1535 {
1536  EESCHEMA_SETTINGS* cfg = eeconfig();
1537  return cfg->m_Appearance.show_hidden_pins;
1538 }
1539 
1540 
1542 {
1543  static KIID lastBrightenedItemID( niluuid );
1544 
1545  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1547  SCH_ITEM* lastItem = sheetList.GetItem( lastBrightenedItemID, &dummy );
1548 
1549  if( lastItem && lastItem != aItem )
1550  {
1551  lastItem->ClearBrightened();
1552 
1553  UpdateItem( lastItem );
1554  lastBrightenedItemID = niluuid;
1555  }
1556 
1557  if( aItem )
1558  {
1559  aItem->SetBrightened();
1560 
1561  UpdateItem( aItem );
1562  lastBrightenedItemID = aItem->m_Uuid;
1563 
1564  FocusOnLocation( aItem->GetFocusPosition() );
1565  }
1566 }
1567 
1568 
1570 {
1571  return Schematic().GetFileName();
1572 }
1573 
1574 
1576 {
1577  return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1578 }
1579 
1580 
1581 void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
1582 {
1583  if( IsShown() )
1584  {
1585  // We only need this until the frame is done resizing and the final client size is
1586  // established.
1587  Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
1589  }
1590 
1591  // Skip() is called in the base class.
1592  EDA_DRAW_FRAME::OnSize( aEvent );
1593 }
1594 
1595 
1597 {
1598  wxString msg;
1599  bool appendToUndo = false;
1600 
1601  wxCHECK( m_toolManager, /* void */ );
1602 
1604 
1605  wxCHECK( selectionTool, /* void */ );
1606 
1607  EE_SELECTION& selection = selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
1608 
1609  if( selection.Empty() )
1610  return;
1611 
1612  SCH_SCREEN* currentScreen = GetScreen();
1613 
1614  wxCHECK( currentScreen, /* void */ );
1615 
1616  // This should work for multiple selections of the same symbol even though the editor
1617  // only works for a single symbol selection.
1618  for( auto item : selection )
1619  {
1620  SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( item );
1621 
1622  wxCHECK( symbol, /* void */ );
1623 
1624  // This needs to be done before the LIB_PART is changed to prevent stale library symbols in
1625  // the schematic file.
1626  currentScreen->Remove( symbol );
1627 
1628  if( !symbol->IsNew() )
1629  {
1630  SaveCopyInUndoList( currentScreen, symbol, UNDO_REDO::CHANGED, appendToUndo );
1631  appendToUndo = true;
1632  }
1633 
1634  symbol->SetLibSymbol( aSymbol.Flatten().release() );
1635  symbol->UpdateFields( true, true );
1636 
1637  currentScreen->Append( symbol );
1638  selectionTool->SelectHighlightItem( symbol );
1639  GetCanvas()->GetView()->Update( symbol );
1640  }
1641 
1642  if( selection.IsHover() )
1644 
1645  GetCanvas()->Refresh();
1646  OnModify();
1647 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
const std::string NetlistFileExtension
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
void UpdateFields(bool aResetStyle, bool aResetRef=false)
Restores fields to the original library values.
void Stop()
Save the time when this function was called, and set the counter stane to stop.
Definition: profile.h:85
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:253
bool empty() const
Definition: sch_rtree.h:166
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:112
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:70
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:219
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void ShowFindReplaceStatus(const wxString &aMsg, int aStatusTime)
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
Definition: kiway_player.h:114
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
void OnOpenCvpcb(wxCommandEvent &event)
void onSize(wxSizeEvent &aEvent)
std::map< wxString, wxString > m_NetClassAssignments
Definition: net_settings.h:43
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:208
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
const BITMAP_OPAQUE icon_eeschema_32_xpm[1]
bool IsModified()
Check the entire hierarchy for any modifications.
SCHEMATIC * m_schematic
The currently loaded schematic.
const wxString & GetFileName() const
Definition: sch_screen.h:186
KiCad executable names.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:61
BOX2< VECTOR2I > BOX2I
Definition: box2.h:522
wxString LegacySchematicFileWildcard()
bool Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:241
SCH_SCREEN * GetNext()
void SetLibSymbol(LIB_PART *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
void OnKiCadExit()
Definition: kiway.cpp:587
void UpdateNetHighlightStatus()
virtual bool IsConnectable() const
Definition: sch_item.h:383
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
HIERARCHY_NAVIG_DLG * FindHierarchyNavigator()
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:56
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
void ForceRefresh()
Force a redraw.
KIID niluuid(0)
void OnLoadFile(wxCommandEvent &event)
wxFindReplaceData * GetFindReplaceData()
Get the find criteria (as set by the dialog).
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 Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:431
wxString m_mruPath
void SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:83
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
Definition: view.cpp:1431
void SetVirtualPageNumber(int aPageNumber)
Definition: base_screen.h:80
wxArrayString GetFindEntries() const
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:97
virtual std::vector< wxPoint > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:397
This file is part of the common library TODO brief description.
SETTINGS_MANAGER * GetSettingsManager() const
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generates the connection data for the entire schematic hierarchy.
virtual void PrintPage(const RENDER_SETTINGS *aSettings) override
Plot or print the current sheet to the clipboard.
void LoadAllLibraries(PROJECT *aProject, bool aShowProgress=true)
Load all of the project's libraries into this container, which should be cleared before calling it.
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr)
Fetch a SCH_ITEM by ID.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetSave()
Definition: base_screen.h:61
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:44
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:137
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
Implementation of conversion functions that require both schematic and board internal units.
This file is part of the common library.
static TOOL_ACTION doDelete
Definition: actions.h:75
const BITMAP_OPAQUE icon_eeschema_16_xpm[1]
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:371
SCH_DRAWING_TOOLS.
static void add_search_paths(SEARCH_STACK *aDst, const SEARCH_STACK &aSrc, int aIndex)
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
double msecs(bool aSinceLast=false)
Definition: profile.h:146
const wxString PCBNEW_EXE
Definition: id.h:88
const std::string LegacyPcbFileExtension
void OnSockRequestServer(wxSocketEvent &evt)
Definition: eda_dde.cpp:102
void SetScreen(BASE_SCREEN *aScreen) override
const SCH_CONNECTION * GetHighlightedConnection() const
virtual void SetScreen(BASE_SCREEN *aScreen)
static TOOL_ACTION zoomTool
Definition: actions.h:102
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
wxString PathHumanReadable(bool aUseShortRootName=true) const
Return the sheet path in a human readable form made from thesheet names.
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
#define KICTL_CREATE
caller thinks requested project files may not exist.
Definition: kiway_player.h:79
SCH_NAVIGATE_TOOL.
bool IsMoving() const
Definition: eda_item.h:168
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:125
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:87
static TOOL_ACTION placeJunction
Definition: ee_actions.h:83
virtual const wxPoint GetFocusPosition() const
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: eda_item.h:307
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:151
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:116
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
wxString KiCadSchematicFileWildcard()
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:97
void SetVisible(bool aVisible)
Definition: eda_text.h:192
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
void SetBrightened()
Definition: eda_item.h:178
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:159
void ResolveERCExclusions()
Update markers to match recorded exclusions.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
EDA_ITEM * GetItem(const KIID &aId) override
Fetch an item by KIID.
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
wxArrayString m_findStringHistoryList
void UpdateTitle()
Set the main window title bar text.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
void OnAppendProject(wxCommandEvent &event)
static TOOL_ACTION standardGraphics
Definition: actions.h:169
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
NET_SETTINGS & NetSettings()
Definition: project_file.h:92
WS_PROXY_VIEW_ITEM * GetWorksheet() const
Definition: sch_view.h:97
Symbol library viewer main window.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:345
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:439
SELECTION_CONDITION CanvasType(EDA_DRAW_PANEL_GAL::GAL_TYPE aType)
Create a functor testing if the specified canvas is active in the frame.
SCH_CLEANUP_FLAGS
Schematic editor (Eeschema) main window.
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr)
Updates the connection graph for the given list of sheets.
Look for files in a number of paths.
Definition: search_stack.h:41
static TOOL_ACTION placeBusWireEntry
Definition: ee_actions.h:84
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
void OnPageSettingsChange() override
Called when modifying the page settings.
bool ReadyToNetlist(bool aSilent=false, bool aSilentAnnotate=false)
Checks if we are ready to write a netlist file for the current schematic.
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:47
Manage TOOL_ACTION objects.
virtual _ELEM * GetElem(ELEM_T aIndex)
Get and set the elements for this project.
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:285
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:81
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:119
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
The base class for create windows for drawing purpose.
void OnFindDialogClose()
Notification that the Find dialog has closed.
bool HasDriverChanged() const
VECTOR2< int > VECTOR2I
Definition: vector2d.h:628
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
A small class to help profiling.
Definition: profile.h:45
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:181
EESCHEMA_SETTINGS * eeconfig()
A subgraph is a set of items that are electrically connected on a single sheet.
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
Definition: sch_sheet.cpp:280
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
virtual const wxString GetProjectPath() const
Return the full path of the project.
Class that groups generic conditions for editor states.
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
std::set< wxString > m_ErcExclusions
Definition: erc_settings.h:158
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:97
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:196
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
bool IsNew() const
Definition: eda_item.h:167
void OnImportProject(wxCommandEvent &event)
SCH_JUNCTION * AddJunction(SCH_SCREEN *aScreen, const wxPoint &aPos, bool aAppendToUndo, bool aFinal=true)
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:187
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
void ClearBrightened()
Definition: eda_item.h:181
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetches the file name from the file history list.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:131
static TOOL_ACTION updateFind
Definition: actions.h:85
EESCHEMA_SETTINGS * eeconfig() const
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:51
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetRoot(SCH_SHEET *aRootSheet)
Initializes the schematic with a new root sheet.
Definition: schematic.cpp:100
wxString GetScreenDesc() const override
Return a human-readable description of the current screen.
SCH_EDITOR_CONTROL.
static TOOL_ACTION drawSheet
Definition: ee_actions.h:88
Master controller class:
Definition: tool_manager.h:52
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:82
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
void OnClearFileHistory(wxCommandEvent &aEvent)
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
const BITMAP_OPAQUE icon_eeschema_xpm[1]
Definition: kiid.h:44
static TOOL_ACTION copy
Definition: actions.h:70
void doCloseWindow() override
wxArrayString GetReplaceEntries() const
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:220
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:143
Item needs to be redrawn.
Definition: view_item.h:57
static TOOL_ACTION placePower
Definition: ee_actions.h:78
void UpdateSymbolFromEditor(const LIB_PART &aSymbol)
Update the LIB_PART of the currently selected symbol.
void DisplaySheet(SCH_SCREEN *aScreen)
const wxString & GetNameForDriver(SCH_ITEM *aItem)
Returns the candidate net name for a driver.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
#define SCH_EDIT_FRAME_NAME
wxString GetName() const
Definition: sch_sheet.h:283
#define NULL
bool IsSingle() const
Is this KIFACE_I running under single_top?
Definition: kiface_i.h:104
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
wxArrayString m_replaceStringHistoryList
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
void UpdateHierarchyTree()
Update the hierarchical tree of the schematic.
Definition: hierarch.cpp:212
static TOOL_ACTION drawWire
Definition: ee_actions.h:79
size_t size() const
Forwarded method from std::vector.
SCH_LINE_DRAWING_TOOL.
wxFileName m_project_name
<fullpath>/<basename>.pro
Definition: project.h:342
void HardRedraw() override
Rebuild the GAL and redraw the screen.
static TOOL_ACTION toggleGrid
Definition: actions.h:143
void SetVirtualPageNumber(int aPageNumber)
Set the sheet instance virtual page number.
KICAD_T Type() override
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
static int Split(wxArrayString *aResult, const wxString &aPathString)
Separate aPathString into individual paths.
static void inheritNetclass(const SCH_SHEET_PATH &aSheetPath, SCH_TEXT *aItem)
static TOOL_ACTION inchesUnits
Definition: actions.h:147
Subclass of DIALOG_SCH_FIND_BASE, which is generated by wxFormBuilder.
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:40
static TOOL_ACTION save
Definition: actions.h:54
void SelectHighlightItem(EDA_ITEM *aItem)
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:91
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
static TOOL_ACTION placeImage
Definition: ee_actions.h:93
void ShowAllIntersheetRefs(bool aShow)
ACTIONS * m_actions
Definition: tools_holder.h:158
static TOOL_ACTION cut
Definition: actions.h:69
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
Define a library symbol object.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
Definition of file extensions used in Kicad.
void SaveCopyForRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
void PrintWorkSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the page layout with the frame and the basic inscriptions.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
EDA_ITEM * GetParent() const
Definition: eda_item.h:163
SCH_ITEM * m_item_to_repeat
Last item to insert by the repeat command.
DIALOG_SCH_FIND * m_findReplaceDialog
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
#define HIERARCHY_NAVIG_DLG_WNAME
Definition: hierarch.h:36
bool IsExcluded() const
Definition: marker_base.h:94
std::vector< SCH_ITEM * > m_drivers
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
wxDC * GetPrintDC() const
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:40
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define PcbFileExtension
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:85
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
static TOOL_ACTION importSheetPin
Definition: ee_actions.h:90
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:77
bool isAutoSaveRequired() const override
Returns true if the schematic has been modified.
Container for ERC settings.
Definition: erc_settings.h:97
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
HTML_MESSAGE_BOX.
SCHEMATIC_SETTINGS * m_defaults
void SetReplaceEntries(const wxArrayString &aEntries)
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
wxString Serialize() const
Definition: sch_marker.cpp:66
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:73
Handle actions that are shared between different applications.
void OnUpdatePCB(wxCommandEvent &event)
void clear()
Forwarded method from std::vector.
void SetFindEntries(const wxArrayString &aEntries)
Specialization of the wxAuiPaneInfo class for KiCad panels.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:254
static TOOL_ACTION milsUnits
Definition: actions.h:148
bool Show(bool show) override
virtual 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...
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:159
EESCHEMA_ACTIONS.
Definition: ee_actions.h:41
Handles action that are shared between different applications.
Definition: common_tools.h:37
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:122
static TOOL_ACTION drawBus
Definition: ee_actions.h:80
Implementing SIM_PLOT_FRAME_BASE.
SELECTION_CONDITION ContentModified()
Create a functor that tests if the content of the frame is modified.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:219
static TOOL_ACTION pasteSpecial
Definition: actions.h:72
const KIID m_Uuid
Definition: eda_item.h:523
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Removes all files from the file history.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static bool m_allowRealTime
static TOOL_ACTION placeLabel
Definition: ee_actions.h:85
A collection of PART_LIB objects.
static wxString GetAutoSaveFilePrefix()
SCH_FIELD * GetIntersheetRefs()
Definition: sch_text.h:439
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
Definition: sch_sheet.cpp:675
void Reset()
Initializes this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:50
void OnSockRequest(wxSocketEvent &evt)
Definition: eda_dde.cpp:70
static TOOL_ACTION redo
Definition: actions.h:68
void ClearFindReplaceStatus()
SCH_SHEET & Root() const
Definition: schematic.h:102
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:118
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
see class PGM_BASE
void AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
void OnExit(wxCommandEvent &event)
SCH_SCREEN * LastScreen()
void Print(const RENDER_SETTINGS *aSettings)
Print all the items in the screen to aDC.
Definition: sch_screen.cpp:742
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
SCH_ITEM_SET & ConnectedItems(const SCH_SHEET_PATH &aPath)
Retrieves the set of items connected to this item on the given sheet.
Definition: sch_item.cpp:164
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:129
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:196
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:197
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
WX_INFOBAR * m_infoBar
wxString QuoteFullPath(wxFileName &fn, wxPathFormat format)
Quote return value of wxFileName::GetFullPath().
Definition: gestfich.cpp:378
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
#define _(s)
Definition: 3d_actions.cpp:33
EE_POINT_EDITOR.
SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
void RecomputeIntersheetRefs()
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:150
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
static TOOL_ACTION acceleratedGraphics
Definition: actions.h:168
EE_RTREE & Items()
Definition: sch_screen.h:159
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
bool SaveProject(const wxString &aFullPath=wxEmptyString)
Saves a loaded project.
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:82
Handle the component boundary box.
Definition: eda_rect.h:42
const std::string KiCadSchematicFileExtension
void ShowFindReplaceDialog(bool aReplace)
Run the Find or Find & Replace dialog.
void OnOpenPcbnew(wxCommandEvent &event)
Schematic symbol object.
Definition: sch_component.h:79
PROJECT & Prj() const
Return a reference to the project this schematic is part of.
Definition: schematic.h:85
#define IU_PER_MILS
Definition: plotter.cpp:137
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
wxString GetCurrentFileName() const override
Get the full filename + path of the currently opened file in the frame.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
These settings were stored in SCH_BASE_FRAME previously.
~SCH_EDIT_FRAME() override
wxString GetUniqueFilenameForCurrentSheet()
#define CURRENT_TOOL(action)
wxFindReplaceData * m_findReplaceData
std::map< wxString, std::set< wxString > > & GetPageRefsMap()
Definition: schematic.h:168
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
#define CHECK(x)
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:202
SCH_SHEET_PATH & GetCurrentSheet() const
static TOOL_ACTION deleteTool
Definition: actions.h:76
bool TrimWire(const wxPoint &aStart, const wxPoint &aEnd)
If any single wire passes through both points, remove the portion between the two points,...
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
Definition: id.h:87
void FocusOnItem(SCH_ITEM *aItem)
static TOOL_ACTION undo
Definition: actions.h:67
SCH_SCREEN * GetFirst()
static TOOL_ACTION drawLines
Definition: ee_actions.h:92
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
CONNECTION_SUBGRAPH * GetSubgraphForItem(SCH_ITEM *aItem)
void OnGridSettings(wxCommandEvent &event)
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:105
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:132
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:184
void InitTools()
Initializes all registered tools.
Definition for part library class.
SCH_SCREEN * RootScreen() const
Helper to retreive the screen of the root sheet.
Definition: schematic.cpp:113
bool IsContentModified() override
Get if the current schematic has been modified but not saved.
void SetModify()
Definition: base_screen.h:59
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:86
void ClearEditFlags()
Definition: eda_item.h:220
bool CheckIfOnDrawList(SCH_ITEM *st)
Definition: sch_screen.cpp:304
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition: schematic.h:132
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:206
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
int ExecuteFile(wxWindow *frame, const wxString &ExecFile, const wxString &param, wxProcess *callback)
Call the executable file ExecFile with the command line parameters param.
Definition: gestfich.cpp:165
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
std::string inputLine
problem line of input [say, from a LINE_READER].
Definition: ki_exception.h:127
void SetPageCount(int aPageCount)
Definition: base_screen.cpp:71
virtual void ShowChangedLanguage()
Redraw the menus and what not in current language.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
static TOOL_ACTION selectAll
Definition: actions.h:73
#define IS_NEW
New item, just created.
Definition: eda_item.h:106
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
void RecordERCExclusions()
Scan existing markers and record data from any that are Excluded.
static TOOL_ACTION paste
Definition: actions.h:71
#define ENABLE(x)
void AddPaths(const wxString &aPaths, int aIndex=-1)
Insert or append path(s).
bool GetShowAllPins() const override
Allow edit frame to show/hide hidden pins.
static TOOL_ACTION duplicate
Definition: actions.h:74
PRIORITY GetDriverPriority()
static TOOL_ACTION selectionTool
Definition: actions.h:156
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:522
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1513
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:161
void sendNetlistToCvpcb()
Send the kicad netlist over to CVPCB.
virtual void UpdateMsgPanel()
Redraw the message panel.
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:127
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: infobar.cpp:244
The symbol library editor main window.