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 <lib_edit_frame.h>
41 #include <lib_view_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_iref.h>
49 #include <sch_painter.h>
50 #include <sch_view.h>
51 #include <sch_sheet.h>
52 #include <schematic.h>
54 #include <advanced_config.h>
55 #include <sim/sim_plot_frame.h>
56 #include <tool/action_manager.h>
57 #include <tool/action_toolbar.h>
58 #include <tool/common_control.h>
59 #include <tool/common_tools.h>
60 #include <tool/editor_conditions.h>
61 #include <tool/picker_tool.h>
62 #include <tool/selection.h>
63 #include <tool/tool_dispatcher.h>
64 #include <tool/tool_manager.h>
65 #include <tool/zoom_tool.h>
66 #include <tools/ee_actions.h>
68 #include <tools/ee_point_editor.h>
71 #include <tools/sch_edit_tool.h>
74 #include <tools/sch_move_tool.h>
76 #include <view/view_controls.h>
77 #include <widgets/infobar.h>
79 #include <wx/cmdline.h>
82 
83 // non-member so it can be moved easily, and kept REALLY private.
84 // Do NOT Clear() in here.
85 static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
86 {
87  for( unsigned i=0; i<aSrc.GetCount(); ++i )
88  aDst->AddPaths( aSrc[i], aIndex );
89 }
90 
91 
92 //-----<SCH "data on demand" functions>-------------------------------------------
93 
94 SEARCH_STACK* PROJECT::SchSearchS()
95 {
97 
98  wxASSERT( !ss || dynamic_cast<SEARCH_STACK*>( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
99 
100  if( !ss )
101  {
102  ss = new SEARCH_STACK();
103 
104  // Make PROJECT the new SEARCH_STACK owner.
106 
107  // to the empty SEARCH_STACK for SchSearchS(), add project dir as first
108  ss->AddPaths( m_project_name.GetPath() );
109 
110  // next add the paths found in *.pro, variable "LibDir"
111  wxString libDir;
112 
113  try
114  {
115  PART_LIBS::LibNamesAndPaths( this, false, &libDir );
116  }
117  catch( const IO_ERROR& )
118  {
119  }
120 
121  if( !!libDir )
122  {
123  wxArrayString paths;
124 
125  SEARCH_STACK::Split( &paths, libDir );
126 
127  for( unsigned i =0; i<paths.GetCount(); ++i )
128  {
129  wxString path = AbsolutePath( paths[i] );
130 
131  ss->AddPaths( path ); // at the end
132  }
133  }
134 
135  // append all paths from aSList
136  add_search_paths( ss, Kiface().KifaceSearch(), -1 );
137  }
138 
139  return ss;
140 }
141 
142 
143 PART_LIBS* PROJECT::SchLibs()
144 {
146 
147  wxASSERT( !libs || libs->Type() == PART_LIBS_T );
148 
149  if( !libs )
150  {
151  libs = new PART_LIBS();
152 
153  // Make PROJECT the new PART_LIBS owner.
155 
156  try
157  {
158  libs->LoadAllLibraries( this );
159  }
160  catch( const PARSE_ERROR& pe )
161  {
162  wxString lib_list = UTF8( pe.inputLine );
163  wxWindow* parent = Pgm().App().GetTopWindow();
164 
165  // parent of this dialog cannot be NULL since that breaks the Kiway() chain.
166  HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
167 
168  dlg.MessageSet( _( "The following libraries were not found:" ) );
169 
170  dlg.ListSet( lib_list );
171 
172  dlg.Layout();
173 
174  dlg.ShowModal();
175  }
176  catch( const IO_ERROR& ioe )
177  {
178  wxWindow* parent = Pgm().App().GetTopWindow();
179 
180  DisplayError( parent, ioe.What() );
181  }
182  }
183 
184  return libs;
185 }
186 
187 //-----</SCH "data on demand" functions>------------------------------------------
188 
189 
190 BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
193 
194  EVT_SIZE( SCH_EDIT_FRAME::OnSize )
195 
198 
201 
202  EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
203  EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
204 
206 END_EVENT_TABLE()
207 
208 
209 SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
210  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ),
211  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ),
212  m_highlightedConn( nullptr ),
213  m_item_to_repeat( nullptr )
214 {
215  m_maximizeByDefault = true;
216  m_schematic = new SCHEMATIC( nullptr );
217 
218  m_showBorderAndTitleBlock = true; // true to show sheet references
219  m_hasAutoSave = true;
220  m_AboutTitle = "Eeschema";
221 
222  m_findReplaceDialog = nullptr;
223 
224  // Give an icon
225  wxIcon icon;
226  icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
227  SetIcon( icon );
228 
229  LoadSettings( eeconfig() );
230 
231  // Also links the schematic to the loaded project
232  CreateScreens();
233 
234  // After schematic has been linked to project, SCHEMATIC_SETTINGS works
235  m_defaults = &m_schematic->Settings();
236  LoadProjectSettings();
237 
238  setupTools();
239  setupUIConditions();
240  ReCreateMenuBar();
241  ReCreateHToolbar();
242  ReCreateVToolbar();
243  ReCreateOptToolbar();
244 
245  // Create the infobar
246  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
247 
248  // Initialize common print setup dialog settings.
249  m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
250  m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
251  m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
252  m_pageSetupData.GetPrintData().SetNoCopies( 1 );
253 
254  m_auimgr.SetManagedWindow( this );
255 
256  m_auimgr.AddPane( m_mainToolBar,
257  EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
258  m_auimgr.AddPane( m_optionsToolBar,
259  EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
260  m_auimgr.AddPane( m_drawToolBar,
261  EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(2) );
262  m_auimgr.AddPane( m_infoBar,
263  EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
264  m_auimgr.AddPane( GetCanvas(),
265  EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
266  m_auimgr.AddPane( m_messagePanel,
267  EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
268 
269  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
270  // hidding it.
271  m_auimgr.Update();
272 
273  // We don't want the infobar displayed right away
274  m_auimgr.GetPane( "InfoBar" ).Hide();
275  m_auimgr.Update();
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 )
312 
313  delete m_item_to_repeat; // we own the cloned object, see this->SaveCopyForRepeatItem()
314 
315  SetScreen( NULL );
316 
317  delete m_schematic;
318 
319  // Close the project if we are standalone, so it gets cleaned up properly
320  if( Kiface().IsSingle() )
322 }
323 
324 
326 {
327  // Create the manager and dispatcher & route draw panel events to the dispatcher
329  m_toolManager->SetEnvironment( &Schematic(), GetCanvas()->GetView(),
330  GetCanvas()->GetViewControls(), config(), this );
331  m_actions = new EE_ACTIONS();
333 
334  // Register tools
349 
350  // Run the selection tool, it is supposed to be always active
352 
354 }
355 
356 
358 {
360 
362  EDITOR_CONDITIONS cond( this );
363 
364  wxASSERT( mgr );
365 
366  auto hasElements =
367  [ this ] ( const SELECTION& aSel )
368  {
369  return !GetScreen()->Items().empty();
370  };
371 
372 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
373 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
374 
376  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
377  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
378 
386 
393  mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
394 
397 
398  auto showHiddenPinsCond =
399  [this] ( const SELECTION& )
400  {
401  return GetShowAllPins();
402  };
403 
404  auto forceHVCond =
405  [this] ( const SELECTION& )
406  {
407  return eeconfig()->m_Drawing.hv_lines_only;
408  };
409 
410  auto remapSymbolsCondition =
411  [&]( const SELECTION& aSel )
412  {
413  SCH_SCREENS schematic( Schematic().Root() );
414 
415  // The remapping can only be performed on legacy projects.
416  return schematic.HasNoFullyDefinedLibIds();
417  };
418 
419  auto belowRootSheetCondition =
420  [this]( const SELECTION& aSel )
421  {
422  return GetCurrentSheet().Last() != &Schematic().Root();
423  };
424 
425  mgr->SetConditions( EE_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
426  mgr->SetConditions( EE_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
427  mgr->SetConditions( EE_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
428  mgr->SetConditions( EE_ACTIONS::toggleForceHV, CHECK( forceHVCond ) );
429 
430 
431 #define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
432 
450 
451 #undef CURRENT_TOOL
452 #undef CHECK
453 #undef ENABLE
454 }
455 
456 
458 {
459  // we cannot store a pointer to an item in the display list here since
460  // that item may be deleted, such as part of a line concatenation or other.
461  // So simply always keep a copy of the object which is to be repeated.
462 
463  if( aItem )
464  {
465  delete m_item_to_repeat;
466 
467  m_item_to_repeat = (SCH_ITEM*) aItem->Clone();
468  // Clone() preserves the flags, we want 'em cleared.
470  }
471 }
472 
473 
475 {
476  return Schematic().GetSheets().GetItem( aId );
477 }
478 
479 
481 {
482  SCH_SCREEN* screen;
483  SCH_SCREENS s_list( Schematic().Root() );
484 
485  // Set the sheet count, and the sheet number (1 for root sheet)
486  int sheet_count = Schematic().Root().CountSheets();
487  int sheet_number = 1;
488  const KIID_PATH& current_sheetpath = GetCurrentSheet().Path();
489 
490  // @todo Remove all psuedo page number system is left over from prior to real page number
491  // implementation.
492  for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
493  {
494  if( sheet.Path() == current_sheetpath ) // Current sheet path found
495  break;
496 
497  sheet_number++; // Not found, increment before this current path
498  }
499 
500  for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
501  screen->SetPageCount( sheet_count );
502 
503  GetCurrentSheet().SetVirtualPageNumber( sheet_number );
504  GetScreen()->SetVirtualPageNumber( sheet_number );
505  GetScreen()->SetPageNumber( GetCurrentSheet().GetPageNumber() );
506 }
507 
508 
510 {
511  return GetCurrentSheet().LastScreen();
512 }
513 
514 
516 {
517  return *m_schematic;
518 }
519 
520 
522 {
523  wxString s = GetCurrentSheet().PathHumanReadable();
524 
525  return s;
526 }
527 
528 
530 {
531  m_schematic->Reset();
532  m_schematic->SetProject( &Prj() );
533 
535 
537 
538  SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
539  m_schematic->Root().SetScreen( rootScreen );
540  SetScreen( Schematic().RootScreen() );
541 
542  m_schematic->RootScreen()->SetFileName( wxEmptyString );
543 
544  if( GetScreen() == NULL )
545  {
546  SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
547  SetScreen( screen );
548  }
549 }
550 
551 
553 {
554  return m_schematic->CurrentSheet();
555 }
556 
557 
559 {
560  if( aSheet != GetCurrentSheet() )
561  {
562  FocusOnItem( nullptr );
563 
564  Schematic().SetCurrentSheet( aSheet );
565  GetCanvas()->DisplaySheet( aSheet.LastScreen() );
566  }
567 }
568 
569 
571 {
573 
574  FocusOnItem( nullptr );
575 
576  GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
577  GetCanvas()->ForceRefresh();
578 }
579 
580 
581 bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
582 {
583  // Shutdown blocks must be determined and vetoed as early as possible
584  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
585  && Schematic().GetSheets().IsModified() )
586  {
587  return false;
588  }
589 
590  if( Kiface().IsSingle() )
591  {
592  LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
593  if( libeditFrame && !libeditFrame->Close() ) // Can close component editor?
594  return false;
595 
596  LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
597  if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer?
598  return false;
599 
600  viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
601 
602  if( viewlibFrame && !viewlibFrame->Close() ) // Can close modal component viewer?
603  return false;
604  }
605 
606  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
607 
608  if( simFrame && !simFrame->Close() ) // Can close the simulator?
609  return false;
610 
611  // We may have gotten multiple events; don't clean up twice
612  if( !Schematic().IsValid() )
613  return false;
614 
615  SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
616 
617  if( sheetlist.IsModified() )
618  {
619  wxFileName fileName = Schematic().RootScreen()->GetFileName();
620  wxString msg = _( "Save changes to \"%s\" before closing?" );
621 
622  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
623  [&]()->bool { return SaveProject(); } ) )
624  {
625  return false;
626  }
627  }
628 
629  return true;
630 }
631 
632 
634 {
635  SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
636 
637  // Shutdown all running tools ( and commit any pending change )
638  if( m_toolManager )
640 
641  // Close the find dialog and preserve it's setting if it is displayed.
642  if( m_findReplaceDialog )
643  {
646 
647  m_findReplaceDialog->Destroy();
648  m_findReplaceDialog = nullptr;
649  }
650 
651  if( FindHierarchyNavigator() )
652  FindHierarchyNavigator()->Close( true );
653 
654  SCH_SCREENS screens( Schematic().Root() );
655  wxFileName fn;
656 
657  for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
658  {
659  fn = Prj().AbsolutePath( screen->GetFileName() );
660 
661  // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
662  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
663 
664  if( fn.FileExists() && fn.IsFileWritable() )
665  wxRemoveFile( fn.GetFullPath() );
666  }
667 
668  sheetlist.ClearModifyStatus();
669 
670  wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
671 
672  if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
673  UpdateFileHistory( fileName );
674 
675  Schematic().RootScreen()->Clear();
676 
677  // all sub sheets are deleted, only the main sheet is usable
679 
680  // Clear view before destroying schematic as repaints depend on schematic being valid
681  SetScreen( nullptr );
682 
684  Schematic().Reset();
685 
686  Destroy();
687 }
688 
689 
691 {
692  // Filename is rootSheetName-sheetName-...-sheetName
693  // Note that we need to fetch the rootSheetName out of its filename, as the root SCH_SHEET's
694  // name is just a timestamp.
695 
696  wxFileName rootFn( GetCurrentSheet().at( 0 )->GetFileName() );
697  wxString filename = rootFn.GetName();
698 
699  for( unsigned i = 1; i < GetCurrentSheet().size(); i++ )
700  filename += wxT( "-" ) + GetCurrentSheet().at( i )->GetName();
701 
702  return filename;
703 }
704 
705 
707 {
708  wxASSERT( GetScreen() );
709 
710  if( !GetScreen() )
711  return;
712 
713  GetScreen()->SetModify();
714  GetScreen()->SetSave();
715 
716  if( ADVANCED_CFG::GetCfg().m_realTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime )
718 
720  []( KIGFX::VIEW_ITEM* aItem )
721  {
722  SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
723  SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
724 
725  if( connection && connection->HasDriverChanged() )
726  {
727  connection->ClearDriverChanged();
728  return true;
729  }
730 
731  return false;
732  } );
733 
734  GetCanvas()->Refresh();
735 }
736 
737 
738 void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
739 {
740  if( Kiface().IsSingle() )
741  {
742  DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
743  " in stand-alone mode. In order to create/update PCBs from"
744  " schematics, launch the Kicad shell and create a project." ) );
745  return;
746  }
747 
748  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
749 
750  if( !frame )
751  {
752  wxFileName fn = Prj().GetProjectFullName();
753  fn.SetExt( PcbFileExtension );
754 
755  frame = Kiway().Player( FRAME_PCB_EDITOR, true );
756  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
757  }
758 
759  if( !frame->IsVisible() )
760  frame->Show( true );
761 
762  // On Windows, Raise() does not bring the window on screen, when iconized
763  if( frame->IsIconized() )
764  frame->Iconize( false );
765 
766  frame->Raise();
767 
768  std::string payload;
769  Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_PCB_UPDATE, payload, this );
770 }
771 
772 
774 {
775  if( m_findReplaceDialog && m_findReplaceDialog->IsVisible()
776  && !m_findReplaceData->GetFindString().IsEmpty() )
777  {
778  return m_findReplaceData;
779  }
780 
781  return nullptr;
782 }
783 
784 
786 {
787  wxWindow* navigator = wxWindow::FindWindowByName( HIERARCHY_NAVIG_DLG_WNAME );
788 
789  return static_cast< HIERARCHY_NAVIG_DLG* >( navigator );
790 }
791 
792 
794 {
795  if( aForceUpdate )
796  {
797  if( FindHierarchyNavigator() )
798  FindHierarchyNavigator()->Close();
799 
800  HIERARCHY_NAVIG_DLG* hierarchyDialog = new HIERARCHY_NAVIG_DLG( this );
801 
802  hierarchyDialog->Show( true );
803  }
804  else
805  {
806  if( FindHierarchyNavigator() )
808  }
809 }
810 
811 
813 {
814  if( m_findReplaceDialog )
815  m_findReplaceDialog->Destroy();
816 
817  m_findReplaceDialog= new DIALOG_SCH_FIND( this, m_findReplaceData, wxDefaultPosition,
818  wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
819 
822  m_findReplaceDialog->Show( true );
823 }
824 
825 
826 void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime )
827 {
828  // Prepare the infobar, since we don't know its state
831 
832  m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
833 }
834 
835 
837 {
838  m_infoBar->Dismiss();
839 }
840 
841 
843 {
846 
847  m_findReplaceDialog->Destroy();
848  m_findReplaceDialog = nullptr;
849 
851 }
852 
853 
854 void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
855 {
856  wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
857 
858  if( fn.size() )
859  OpenProjectFiles( std::vector<wxString>( 1, fn ) );
860 }
861 
862 
863 void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
864 {
866 }
867 
868 
870 {
871  wxString pro_dir = m_mruPath;
872 
873  wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
874  KiCadSchematicFileWildcard(), wxFD_SAVE );
875 
876  if( dlg.ShowModal() != wxID_CANCEL )
877  {
878  // Enforce the extension, wxFileDialog is inept.
879  wxFileName create_me = dlg.GetPath();
880  create_me.SetExt( KiCadSchematicFileExtension );
881 
882  if( create_me.FileExists() )
883  {
884  wxString msg;
885  msg.Printf( _( "Schematic file \"%s\" already exists." ), create_me.GetFullName() );
886  DisplayError( this, msg );
887  return ;
888  }
889 
890  // OpenProjectFiles() requires absolute
891  wxASSERT_MSG( create_me.IsAbsolute(), "wxFileDialog returned non-absolute path" );
892 
893  OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
894  m_mruPath = create_me.GetPath();
895  }
896 }
897 
898 
900 {
901  wxString pro_dir = m_mruPath;
902  wxString wildcards = KiCadSchematicFileWildcard();
903 
904  wildcards += "|" + LegacySchematicFileWildcard();
905 
906  wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
907  wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
908 
909  if( dlg.ShowModal() != wxID_CANCEL )
910  {
911  OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
913  }
914 }
915 
916 
917 void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
918 {
919  wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
920 
921  if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() )
922  {
923  kicad_board.SetExt( PcbFileExtension );
924  wxFileName legacy_board( kicad_board );
925  legacy_board.SetExt( LegacyPcbFileExtension );
926  wxFileName& boardfn = legacy_board;
927 
928  if( !legacy_board.FileExists() || kicad_board.FileExists() )
929  boardfn = kicad_board;
930 
931  if( Kiface().IsSingle() )
932  {
933  wxString filename = QuoteFullPath( boardfn );
934  ExecuteFile( this, PCBNEW_EXE, filename );
935  }
936  else
937  {
938  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
939 
940  if( !frame )
941  {
942  frame = Kiway().Player( FRAME_PCB_EDITOR, true );
943  frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
944  }
945 
946  if( !frame->IsVisible() )
947  frame->Show( true );
948 
949  // On Windows, Raise() does not bring the window on screen, when iconized
950  if( frame->IsIconized() )
951  frame->Iconize( false );
952 
953  frame->Raise();
954  }
955  }
956  else
957  {
958  // If we are running inside a project, it should be impossible for this case to happen
959  wxASSERT( Kiface().IsSingle() );
960  ExecuteFile( this, PCBNEW_EXE );
961  }
962 }
963 
964 
965 void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
966 {
967  wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
968  fn.SetExt( NetlistFileExtension );
969 
970  if( !ReadyToNetlist() )
971  return;
972 
973  try
974  {
975  KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
976 
977  if( !player )
978  {
979  player = Kiway().Player( FRAME_CVPCB, true );
980  player->Show( true );
981  }
982 
984 
985  player->Raise();
986  }
987  catch( const IO_ERROR& )
988  {
989  DisplayError( this, _( "Could not open CvPcb" ) );
990  }
991 }
992 
993 
994 void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
995 {
996  if( event.GetId() == wxID_EXIT )
997  Kiway().OnKiCadExit();
998 
999  if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1000  Close( false );
1001 }
1002 
1003 
1005 {
1006  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1007 
1008  aSettings->GetPrintDC()->SetLogicalFunction( wxCOPY );
1009  GetScreen()->Print( aSettings );
1010  PrintWorkSheet( aSettings, GetScreen(), IU_PER_MILS, fileName );
1011 }
1012 
1013 
1015 {
1016  // In case this event happens before g_RootSheet is initialized which does happen
1017  // on mingw64 builds.
1018 
1019  if( Schematic().IsValid() )
1020  {
1021  SCH_SCREENS screenList( Schematic().Root() );
1022 
1023  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
1024  {
1025  if( screen->IsSave() )
1026  return true;
1027  }
1028  }
1029 
1030  return false;
1031 }
1032 
1033 
1034 static void inheritNetclass( const SCH_SHEET_PATH& aSheetPath, SCH_TEXT* aItem )
1035 {
1036  // Netclasses are assigned to subgraphs by association with their netname. However, when
1037  // a new label is attached to an existing subgraph (with an existing netclass association),
1038  // the association will be lost as the label will drive its name on to the graph.
1039  //
1040  // Here we find the previous driver of the subgraph and if it had a netclass we associate
1041  // the new netname with that netclass as well.
1042  //
1043  SCHEMATIC* schematic = aItem->Schematic();
1044  CONNECTION_SUBGRAPH* subgraph = schematic->ConnectionGraph()->GetSubgraphForItem( aItem );
1045 
1046  std::map<wxString, wxString>& netclassAssignments =
1048 
1049  if( subgraph )
1050  {
1051  SCH_ITEM* previousDriver = nullptr;
1053 
1054  for( SCH_ITEM* item : subgraph->m_drivers )
1055  {
1056  if( item == aItem )
1057  continue;
1058 
1060 
1061  if( p > priority )
1062  {
1063  priority = p;
1064  previousDriver = item;
1065  }
1066  }
1067 
1068  if( previousDriver )
1069  {
1070  wxString path = aSheetPath.PathHumanReadable();
1071  wxString oldDrivenName = path + subgraph->GetNameForDriver( previousDriver );
1072  wxString drivenName = path + subgraph->GetNameForDriver( aItem );
1073 
1074  if( netclassAssignments.count( oldDrivenName ) )
1075  netclassAssignments[ drivenName ] = netclassAssignments[ oldDrivenName ];
1076  }
1077  }
1078 }
1079 
1080 
1082  bool aUndoAppend )
1083 {
1084  wxCHECK_RET( aItem != NULL, wxT( "Cannot add null item to list." ) );
1085 
1086  SCH_SHEET* parentSheet = nullptr;
1087  SCH_COMPONENT* parentComponent = nullptr;
1088  SCH_ITEM* undoItem = aItem;
1089 
1090  if( aItem->Type() == SCH_SHEET_PIN_T )
1091  {
1092  parentSheet = (SCH_SHEET*) aItem->GetParent();
1093 
1094  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
1095  wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
1096 
1097  undoItem = parentSheet;
1098  }
1099 
1100  else if( aItem->Type() == SCH_FIELD_T )
1101  {
1102  parentComponent = (SCH_COMPONENT*) aItem->GetParent();
1103 
1104  wxCHECK_RET( parentComponent && parentComponent->Type() == SCH_COMPONENT_T,
1105  wxT( "Cannot place field in invalid schematic component object." ) );
1106 
1107  undoItem = parentComponent;
1108  }
1109 
1110  if( aItem->IsNew() )
1111  {
1112  if( aItem->Type() == SCH_SHEET_PIN_T )
1113  {
1114  // Sheet pins are owned by their parent sheet.
1115  SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::CHANGED, aUndoAppend );
1116 
1117  parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
1118  }
1119  else if( aItem->Type() == SCH_FIELD_T )
1120  {
1121  // Component fields are also owned by their parent, but new component fields
1122  // are handled elsewhere.
1123  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1124  }
1125  else
1126  {
1127  if( !aScreen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
1128  AddToScreen( aItem, aScreen );
1129 
1130  SaveCopyForRepeatItem( aItem );
1131  SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::NEWITEM, aUndoAppend );
1132  }
1133 
1134  // Update connectivity info for new item
1135  if( !aItem->IsMoving() )
1136  {
1138 
1139  if( SCH_TEXT* textItem = dynamic_cast<SCH_TEXT*>( aItem ) )
1140  inheritNetclass( GetCurrentSheet(), textItem );
1141  }
1142  }
1143 
1144  aItem->ClearFlags( IS_NEW );
1145 
1146  aScreen->SetModify();
1147  UpdateItem( aItem );
1148 
1149  if( !aItem->IsMoving() && aItem->IsConnectable() )
1150  {
1151  std::vector< wxPoint > pts = aItem->GetConnectionPoints();
1152 
1153  for( auto i = pts.begin(); i != pts.end(); i++ )
1154  {
1155  for( auto j = i + 1; j != pts.end(); j++ )
1156  TrimWire( *i, *j );
1157 
1158  if( aScreen->IsJunctionNeeded( *i, true ) )
1159  AddJunction( aScreen, *i, true, false );
1160  }
1161 
1162  TestDanglingEnds();
1163 
1164  for( SCH_ITEM* item : aItem->ConnectedItems( GetCurrentSheet() ) )
1165  UpdateItem( item );
1166  }
1167 
1168  aItem->ClearEditFlags();
1169  GetCanvas()->Refresh();
1170 }
1171 
1172 
1174 {
1175  wxString title;
1176  wxString nofile = _( "[no file]" ) + wxS(" ");
1177  wxString app = _( "Eeschema" );
1178 
1179  if( GetScreen()->GetFileName().IsEmpty() )
1180  {
1181  title = nofile + wxT( "\u2014 " ) + app;
1182  }
1183  else
1184  {
1185  wxFileName fn( Prj().AbsolutePath( GetScreen()->GetFileName() ) );
1186  wxString append;
1187 
1188  if( fn.FileExists() )
1189  {
1190  if( !fn.IsFileWritable() )
1191  append = _( "[Read Only]" ) + wxS( " " );
1192  }
1193  else
1194  append = nofile;
1195 
1196  title.Printf( wxT( "%s [%s] %s\u2014 " ) + app,
1197  fn.GetName(),
1199  append );
1200  }
1201 
1202  SetTitle( title );
1203 }
1204 
1205 
1207 {
1208  SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1209  SCH_SHEET_LIST list = Schematic().GetSheets();
1210  PROF_COUNTER timer;
1211 
1212  // Ensure schematic graph is accurate
1213  if( aCleanupFlags == LOCAL_CLEANUP )
1214  {
1216  }
1217  else if( aCleanupFlags == GLOBAL_CLEANUP )
1218  {
1219  for( const auto& sheet : list )
1220  SchematicCleanUp( sheet.LastScreen() );
1221  }
1222 
1223  timer.Stop();
1224  wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
1225 
1226  if( settings.m_IntersheetsRefShow == true )
1228 
1229  Schematic().ConnectionGraph()->Recalculate( list, true );
1230 }
1231 
1233 {
1234  SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1235  std::vector<wxString> pagesNumbers;
1236  SCH_GLOBALLABEL* gLabel;
1237  SCH_IREF* iref;
1238 
1239  m_labelTable.clear();
1240 
1241  SCH_SCREENS screens( Schematic().Root() );
1242 
1243  /* Iterate over screens */
1244  for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
1245  {
1246  pagesNumbers.clear();
1247 
1248  /* Find in which sheets this screen is used */
1249  for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
1250  {
1251  if( sheet.LastScreen() == screen )
1252  pagesNumbers.push_back( sheet.GetPageNumber() );
1253  }
1254 
1255  for( SCH_ITEM* item : screen->Items() )
1256  {
1257  if( item->Type() == SCH_GLOBAL_LABEL_T )
1258  {
1259  gLabel = static_cast<SCH_GLOBALLABEL*>( item );
1260  m_labelTable.push_back( gLabel );
1261 
1262  if( gLabel->GetIref() == nullptr )
1263  {
1264  iref = new SCH_IREF();
1265  gLabel->SetIref( iref );
1266 
1267  iref->SetParentLabel( gLabel );
1268  iref->SetFlags( IS_NEW );
1269  iref->SetScreen( screen );
1270 
1271  if( gLabel->GetIrefSavedPosition() != wxDefaultPosition )
1272  iref->SetPosition( gLabel->GetIrefSavedPosition() );
1273  else
1274  iref->PlaceAtDefaultPosition();
1275 
1276  iref->CopyParentStyle();
1277  }
1278  else
1279  {
1280  iref = gLabel->GetIref();
1281  }
1282 
1283  iref->GetRefTable().clear();
1284  iref->GetRefTable().insert( iref->GetRefTable().end(),
1285  pagesNumbers.begin(),
1286  pagesNumbers.end() );
1287  }
1288  }
1289  }
1290 
1291  /* Fill intersheets references for each global label */
1292  for( SCH_GLOBALLABEL* item : m_labelTable )
1293  {
1294  for( SCH_GLOBALLABEL* iter : m_labelTable )
1295  {
1296  if( iter->GetText().IsSameAs( item->GetText() ) && ( iter != item ) )
1297  {
1298  iter->GetIref()->GetRefTable().insert( iter->GetIref()->GetRefTable().end(),
1299  item->GetIref()->GetRefTable().begin(),
1300  item->GetIref()->GetRefTable().end() );
1301  }
1302  }
1303  }
1304 
1305  /* Refresh all global labels */
1306  for( SCH_GLOBALLABEL* item : m_labelTable )
1307  {
1308  wxString text, tmp;
1309 
1310  iref = item->GetIref();
1311 
1312  std::sort( iref->GetRefTable().begin(), iref->GetRefTable().end() );
1313  iref->GetRefTable().erase( std::unique( iref->GetRefTable().begin(),
1314  iref->GetRefTable().end() ),
1315  iref->GetRefTable().end() );
1316 
1317  text.Printf( "%s", settings.m_IntersheetsRefPrefix );
1318 
1319  if( ( settings.m_IntersheetsRefFormatShort ) && ( iref->GetRefTable().size() > 2 ) )
1320  {
1321  tmp.Printf( "%s..%s", iref->GetRefTable().front(), iref->GetRefTable().back() );
1322  text.Append( tmp );
1323  }
1324  else
1325  {
1326  for( wxString ref : iref->GetRefTable() )
1327  {
1328  tmp.Printf( "%s,", ref );
1329  text.Append( tmp );
1330  }
1331 
1332  if( text.Last() == ',' )
1333  text.RemoveLast();
1334  }
1335 
1336  text.Append( settings.m_IntersheetsRefSuffix );
1337 
1338  iref->SetText( text );
1339 
1340  SCH_SCREEN* screen = iref->GetScreen();
1341 
1342  if( !screen->CheckIfOnDrawList( iref ) )
1343  AddToScreen( iref, screen );
1344 
1345  iref->ClearFlags( IS_NEW );
1346 
1347  screen->SetModify();
1348  Refresh( iref );
1349 
1350  iref->ClearEditFlags();
1351  GetCanvas()->Refresh();
1352  }
1353 
1354  return 0;
1355 }
1356 
1358 {
1359  SCH_SHEET_LIST sheets = Schematic().GetSheets();
1360  std::vector<SCH_IREF*> irefList;
1361  SCH_GLOBALLABEL* gLabel;
1362 
1363  SCH_SCREENS screens( Schematic().Root() );
1364 
1365  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
1366  {
1367 
1368  for( SCH_ITEM* item : screen->Items() )
1369  {
1370  if( item->Type() == SCH_GLOBAL_LABEL_T )
1371  {
1372  gLabel = (SCH_GLOBALLABEL*)( item );
1373  SCH_IREF* iref = gLabel->GetIref();
1374 
1375  if( iref )
1376  {
1377  gLabel->SetIref( nullptr );
1378  gLabel->SetIrefSavedPosition( wxDefaultPosition );
1379  irefList.push_back( iref );
1380  }
1381  }
1382  }
1383  }
1384 
1385  for( SCH_IREF* iref : irefList )
1386  RemoveFromScreen( iref, iref->GetScreen() );
1387 }
1388 
1389 void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1390 {
1391  SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1392  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1393 
1394  if( settings.m_IntersheetsRefShow == false )
1396  else
1398 
1400  GetCanvas()->Refresh();
1401 
1402  RecreateToolbars();
1403  Layout();
1404  SendSizeEvent();
1405 }
1406 
1407 
1409 {
1410  // Rebuild the sheet view (draw area and any other items):
1412 }
1413 
1414 
1416 {
1417  // call my base class
1419 
1420  // tooltips in toolbars
1421  RecreateToolbars();
1422 
1423  // status bar
1424  UpdateMsgPanel();
1425 
1426  // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
1427  // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
1428  // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
1429  // toolbar to update correctly.
1430 #if defined( __WXMSW__ )
1431  PostSizeEvent();
1432 #endif
1433 }
1434 
1435 
1437 {
1438  if( const SCH_CONNECTION* conn = GetHighlightedConnection() )
1439  {
1440  SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
1441  UnescapeString( conn->Name() ) ) );
1442  }
1443  else
1444  {
1445  SetStatusText( wxT( "" ) );
1446  }
1447 }
1448 
1449 
1451 {
1452  if( m_toolManager )
1454 
1455  SCH_BASE_FRAME::SetScreen( aScreen );
1456  GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
1457 }
1458 
1459 
1460 const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
1461 {
1462  BOX2I bBoxDoc;
1463 
1464  if( aIncludeAllVisible )
1465  {
1466  // Get the whole page size and return that
1467  int sizeX = GetScreen()->GetPageSettings().GetWidthIU();
1468  int sizeY = GetScreen()->GetPageSettings().GetHeightIU();
1469  bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
1470  }
1471  else
1472  {
1473  // Get current worksheet in a form we can compare to an EDA_ITEM
1475  EDA_ITEM* currWsAsItem = static_cast<EDA_ITEM*>( currWs );
1476 
1477  // Need an EDA_RECT so the first ".Merge" sees it's uninitialized
1478  EDA_RECT bBoxItems;
1479 
1480  // Calc the bounding box of all items on screen except the page border
1481  for( EDA_ITEM* item : GetScreen()->Items() )
1482  {
1483  if( item != currWsAsItem ) // Ignore the worksheet itself
1484  {
1485  if( item->Type() == SCH_COMPONENT_T )
1486  {
1487  // For components we need to get the bounding box without invisible text
1488  SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
1489  bBoxItems.Merge( comp->GetBoundingBox( false ) );
1490  }
1491  else
1492  bBoxItems.Merge( item->GetBoundingBox() );
1493  }
1494  bBoxDoc = bBoxItems;
1495  }
1496  }
1497  return bBoxDoc;
1498 }
1499 
1500 
1502 {
1503  // Save the current sheet, to retrieve it later
1504  SCH_SHEET_PATH oldsheetpath = GetCurrentSheet();
1505 
1506  bool modified = false;
1507 
1508  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1509 
1510  for( const SCH_SHEET_PATH& sheet : sheetList )
1511  {
1512  // We require a set here to avoid adding multiple junctions to the same spot
1513  std::set<wxPoint> junctions;
1514 
1515  SetCurrentSheet( sheet );
1517 
1518  SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
1519 
1520  for( auto aItem : screen->Items().OfType( SCH_COMPONENT_T ) )
1521  {
1522  auto cmp = static_cast<SCH_COMPONENT*>( aItem );
1523 
1524  for( const SCH_PIN* pin : cmp->GetPins( &sheet ) )
1525  {
1526  auto pos = pin->GetPosition();
1527 
1528  // Test if a _new_ junction is needed, and add it if missing
1529  if( screen->IsJunctionNeeded( pos, true ) )
1530  junctions.insert( pos );
1531  }
1532  }
1533 
1534  for( const wxPoint& pos : junctions )
1535  AddJunction( screen, pos, false, false );
1536 
1537  if( junctions.size() )
1538  modified = true;
1539  }
1540 
1541  if( modified )
1542  OnModify();
1543 
1544  // Reselect the initial sheet:
1545  SetCurrentSheet( oldsheetpath );
1547  SetScreen( GetCurrentSheet().LastScreen() );
1548 }
1549 
1550 
1552 {
1553  return Schematic().GetSheets().IsModified();
1554 }
1555 
1556 
1558 {
1559  EESCHEMA_SETTINGS* cfg = eeconfig();
1560  return cfg->m_Appearance.show_hidden_pins;
1561 }
1562 
1563 
1565 {
1566  static KIID lastBrightenedItemID( niluuid );
1567 
1568  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1570  SCH_ITEM* lastItem = sheetList.GetItem( lastBrightenedItemID, &dummy );
1571 
1572  if( lastItem && lastItem != aItem )
1573  {
1574  lastItem->ClearBrightened();
1575 
1576  UpdateItem( lastItem );
1577  lastBrightenedItemID = niluuid;
1578  }
1579 
1580  if( aItem )
1581  {
1582  aItem->SetBrightened();
1583 
1584  UpdateItem( aItem );
1585  lastBrightenedItemID = aItem->m_Uuid;
1586 
1587  FocusOnLocation( aItem->GetFocusPosition() );
1588  }
1589 }
1590 
1591 
1593 {
1594  return Schematic().GetFileName();
1595 }
1596 
1597 
1599 {
1600  return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1601 }
1602 
1603 
1604 void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
1605 {
1606  if( IsShown() )
1607  {
1608  // We only need this until the frame is done resizing and the final client size is
1609  // established.
1610  Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
1612  }
1613 
1614  // Skip() is called in the base class.
1615  EDA_DRAW_FRAME::OnSize( aEvent );
1616 }
1617 
1618 
1620 {
1621  wxString msg;
1622  bool appendToUndo = false;
1623 
1624  wxCHECK( m_toolManager, /* void */ );
1625 
1627 
1628  wxCHECK( selectionTool, /* void */ );
1629 
1630  EE_SELECTION& selection = selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
1631 
1632  if( selection.Empty() )
1633  return;
1634 
1635  SCH_SCREEN* currentScreen = GetScreen();
1636 
1637  wxCHECK( currentScreen, /* void */ );
1638 
1639  // This should work for multiple selections of the same symbol even though the editor
1640  // only works for a single symbol selection.
1641  for( auto item : selection )
1642  {
1643  SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( item );
1644 
1645  wxCHECK( symbol, /* void */ );
1646 
1647  // This needs to be done before the LIB_PART is changed to prevent stale library symbols in
1648  // the schematic file.
1649  currentScreen->Remove( symbol );
1650 
1651  if( !symbol->IsNew() )
1652  {
1653  SaveCopyInUndoList( currentScreen, symbol, UNDO_REDO::CHANGED, appendToUndo );
1654  appendToUndo = true;
1655  }
1656 
1657  symbol->SetLibSymbol( aSymbol.Flatten().release() );
1658  currentScreen->Append( symbol );
1659  selectionTool->SelectHighlightItem( symbol );
1660  GetCanvas()->GetView()->Update( symbol );
1661  }
1662 
1663  if( selection.IsHover() )
1665 
1666  GetCanvas()->Refresh();
1667  OnModify();
1668 }
void DisplaySheet(const SCH_SCREEN *aScreen)
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 Stop()
save the time when this function was called, and set the counter stane to stop
Definition: profile.h:82
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:240
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:109
UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to...
Definition: utf8.h:73
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns 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)
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
Definition: kiway_player.h:120
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:202
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
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.
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
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:585
void UpdateNetHighlightStatus()
virtual bool IsConnectable() const
Definition: sch_item.h:377
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
HIERARCHY_NAVIG_DLG * FindHierarchyNavigator()
KIWAY & Kiway() const
Function Kiway returns 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
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
void ForceRefresh()
Function ForceRefresh() Forces 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)
Function Merge modifies 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:147
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Updates items in the view according to the given flags and condition.
Definition: view.cpp:1431
void SetVirtualPageNumber(int aPageNumber)
Definition: base_screen.h:144
wxArrayString GetFindEntries() const
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:91
virtual std::vector< wxPoint > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:391
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.
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.
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
void SetSave()
Definition: base_screen.h:125
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:131
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
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()
Creates a functor testing if the cursor is full screen in a frame.
double msecs(bool aSinceLast=false)
Definition: profile.h:143
const wxString PCBNEW_EXE
Definition: id.h:88
SCH_SCREEN * GetScreen()
Definition: sch_iref.h:70
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)
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false)
Updates the connection graph for the given list of sheets.
VIEW_CONTROLS class definition.
static TOOL_ACTION zoomTool
Definition: actions.h:97
static bool Idle(const SELECTION &aSelection)
Tests 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.
#define KICTL_CREATE
caller thinks requested project files may not exist
Definition: kiway_player.h:81
SCH_NAVIGATE_TOOL.
bool IsMoving() const
Definition: eda_item.h:189
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
void CopyParentStyle()
Definition: sch_iref.cpp:117
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:124
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:87
static TOOL_ACTION placeJunction
Definition: ee_actions.h:83
virtual const wxPoint GetFocusPosition() const
Function GetFocusPosition similar to GetPosition, but allows items to return their visual center rath...
Definition: eda_item.h:334
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:150
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
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:110
void UpdateAllItems(int aUpdateFlags)
Updates all items in the view according to the given flags.
Definition: view.cpp:1417
wxString KiCadSchematicFileWildcard()
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Creates 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:113
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
void SetBrightened()
Definition: eda_item.h:198
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:158
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
static TOOL_ACTION millimetersUnits
Definition: actions.h:144
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.
void PrintWorkSheet(RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, double aScale, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the page layout with the frame and the basic inscriptions.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs 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:164
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:98
SELECTION_CONDITION CanvasType(EDA_DRAW_PANEL_GAL::GAL_TYPE aType)
Creates a functor testing if the specified canvas is active in the frame.
SCH_CLEANUP_FLAGS
Schematic editor (Eeschema) main window.
SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
static TOOL_ACTION placeBusWireEntry
Definition: ee_actions.h:84
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
SELECTION_CONDITION RedoAvailable()
Creates a functor that tests if there are any items in the redo queue.
void SetScreen(SCH_SCREEN *screen)
Definition: sch_iref.h:72
void OnPageSettingsChange() override
Called when modifying the page settings.
std::vector< SCH_GLOBALLABEL * > m_labelTable
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
ACTION_MANAGER.
VTBL_ENTRY _ELEM * GetElem(ELEM_T aIndex)
Typically wrapped somewhere else in a more meaningful function wrapper.
Definition: project.cpp:245
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:234
VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:85
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:118
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
Item needs to be redrawn.
Definition: view_item.h:63
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:594
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
The class PROF_COUNTER is a small class to help profiling.
Definition: profile.h:44
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:279
static bool NotEmpty(const SELECTION &aSelection)
Tests if there are any items selected.
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:121
Class that groups generic conditions for editor states.
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
Symbol library viewer main window.
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:97
VTBL_ENTRY const wxString AbsolutePath(const wxString &aFileName) const
Function AbsolutePath fixes up aFileName if it is relative to the project's directory to be an absolu...
Definition: project.cpp:269
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
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
bool IsNew() const
Definition: eda_item.h:188
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:184
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:257
void ClearBrightened()
Definition: eda_item.h:201
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:147
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:99
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
TOOL_MANAGER.
Definition: tool_manager.h:51
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:217
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:140
std::vector< wxString > & GetRefTable()
Definition: sch_iref.h:57
void SetParentLabel(SCH_GLOBALLABEL *parent)
Definition: sch_iref.h:68
Item is being added to the view.
Definition: view_item.h:62
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 SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:221
const wxString & GetNameForDriver(SCH_ITEM *aItem)
Returns the candidate net name for a driver.
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:120
SELECTION_CONDITION GridVisible()
Creates a functor testing if the grid is visible in a frame.
#define SCH_EDIT_FRAME_NAME
wxString GetName() const
Definition: sch_sheet.h:282
#define NULL
bool IsSingle() const
Function IsSingle is this KIFACE_I running under single_top?
Definition: kiface_i.h:117
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:343
wxArrayString m_replaceStringHistoryList
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Creates a functor that tests if the frame has the specified units.
void UpdateHierarchyTree()
Update the hierarchical tree of the schematic.
Definition: hierarch.cpp:196
static TOOL_ACTION drawWire
Definition: ee_actions.h:79
size_t size() const
Forwarded method from std::vector.
SCH_LINE_DRAWING_TOOL.
int RecomputeIntersheetsRefs()
wxFileName m_project_name
<fullpath>/<basename>.pro
Definition: project.h:338
void HardRedraw() override
Rebuild the GAL and redraw the screen.
static TOOL_ACTION toggleGrid
Definition: actions.h:138
void RemoveAllIntersheetsRefs()
void SetVirtualPageNumber(int aPageNumber)
Set the sheet instance virtual page number.
KICAD_T Type() override
VTBL_ENTRY PROJECT_FILE & GetProjectFile() const
Definition: project.h:143
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
static int Split(wxArrayString *aResult, const wxString &aPathString)
Function Split separates aPathString into individual paths.
static void inheritNetclass(const SCH_SHEET_PATH &aSheetPath, SCH_TEXT *aItem)
static TOOL_ACTION inchesUnits
Definition: actions.h:142
Subclass of DIALOG_SCH_FIND_BASE, which is generated by wxFormBuilder.
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
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
ACTIONS * m_actions
Definition: tools_holder.h:49
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.
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
EDA_ITEM * GetParent() const
Definition: eda_item.h:184
void SetIref(SCH_IREF *iref)
Definition: sch_text.h:423
void Print(RENDER_SETTINGS *aSettings)
Print all the items in the screen to aDC.
Definition: sch_screen.cpp:738
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:35
std::vector< SCH_ITEM * > m_drivers
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
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.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:115
virtual void PrintPage(RENDER_SETTINGS *aSettings) override
Plot or print the current sheet to the clipboard.
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.
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:72
COMMON_CONTROL.
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 PlaceAtDefaultPosition()
Definition: sch_iref.cpp:42
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:226
static TOOL_ACTION milsUnits
Definition: actions.h:143
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:50
EESCHEMA_ACTIONS.
Definition: ee_actions.h:41
COMMON_TOOLS.
Definition: common_tools.h:38
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
static TOOL_ACTION drawBus
Definition: ee_actions.h:80
Implementing SIM_PLOT_FRAME_BASE.
SELECTION_CONDITION ContentModified()
Creates 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:151
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Removes all files from the file history.
static bool m_allowRealTime
static TOOL_ACTION placeLabel
Definition: ee_actions.h:85
A collection of PART_LIB objects.
static wxString GetAutoSaveFilePrefix()
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
Definition: sch_sheet.cpp:692
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:437
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:70
void Reset()
Initializes this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:49
void OnSockRequest(wxSocketEvent &evt)
Definition: eda_dde.cpp:70
static TOOL_ACTION redo
Definition: actions.h:68
void ClearFindReplaceStatus()
void SetIrefSavedPosition(wxPoint pos)
Definition: sch_text.h:426
SCH_SHEET & Root() const
Definition: schematic.h:96
Struct PARSE_ERROR contains a filename or source description, a problem input line,...
Definition: ki_exception.h:123
The symbol library editor main window.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
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 AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
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:201
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:180
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:193
SCH_IREF * GetIref()
Definition: sch_text.h:422
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:200
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Sets 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:367
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
#define _(s)
Definition: 3d_actions.cpp:33
EE_POINT_EDITOR.
SELECTION_CONDITION UndoAvailable()
Creates a functor that tests if there are any items in the undo queue.
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:152
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
static TOOL_ACTION acceleratedGraphics
Definition: actions.h:163
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
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
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:79
#define IU_PER_MILS
Definition: plotter.cpp:137
EDA_ITEM is 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
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:222
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 of advanced config.
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:76
CONNECTION_SUBGRAPH * GetSubgraphForItem(SCH_ITEM *aItem)
void OnGridSettings(wxCommandEvent &event)
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:100
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
Definitions of the SCH_IREF class and derivatives for Eeschema.
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:184
void InitTools()
Function 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:112
bool IsContentModified() override
Get if the current schematic has been modified but not saved.
void SetModify()
Definition: base_screen.h:123
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:86
void ClearEditFlags()
Definition: eda_item.h:240
bool CheckIfOnDrawList(SCH_ITEM *st)
Definition: sch_screen.cpp:304
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition: schematic.h:126
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:203
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions Move the graphic cursor (crosshair cursor...
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
void SetPosition(const wxPoint &aPosition) override
Definition: sch_text.h:313
wxPoint GetIrefSavedPosition()
Definition: sch_text.h:425
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:163
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME,...
std::string inputLine
problem line of input [say, from a LINE_READER].
Definition: ki_exception.h:132
void SetPageCount(int aPageCount)
Definition: base_screen.cpp:71
virtual void ShowChangedLanguage()
Redraw 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
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
static TOOL_ACTION paste
Definition: actions.h:71
#define ENABLE(x)
void AddPaths(const wxString &aPaths, int aIndex=-1)
Function AddPaths 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:151
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:521
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1513
void RegisterTool(TOOL_BASE *aTool)
Function RegisterTool() Adds a tool to the manager set and sets it up.
KICAD_T Type() const
Function Type()
Definition: eda_item.h:182
void sendNetlistToCvpcb()
Send the kicad netlist over to CVPCB.
virtual void UpdateMsgPanel()
Redraw the message panel.
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:121
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: infobar.cpp:216