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 <bitmaps.h>
27 #include <class_library.h>
28 #include <confirm.h>
29 #include <connection_graph.h>
31 #include <eeschema_id.h>
32 #include <executable_names.h>
33 #include <gestfich.h>
34 #include <hierarch.h>
36 #include <invoke_sch_dialog.h>
37 #include <kicad_string.h>
38 #include <kiface_i.h>
39 #include <kiplatform/app.h>
40 #include <kiway.h>
41 #include <symbol_edit_frame.h>
42 #include <symbol_viewer_frame.h>
43 #include <pgm_base.h>
44 #include <profile.h>
45 #include <project.h>
46 #include <project/project_file.h>
47 #include <project/net_settings.h>
48 #include <sch_edit_frame.h>
49 #include <sch_painter.h>
50 #include <sch_sheet.h>
51 #include <sch_marker.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" ), wxDefaultPosition,
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 = _( "KiCad Schematic Editor" );
221 
222  m_findReplaceDialog = nullptr;
223 
224  // Give an icon
225  wxIcon icon;
226  wxIconBundle icon_bundle;
227 
228  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema ) );
229  icon_bundle.AddIcon( icon );
230  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
231  icon_bundle.AddIcon( icon );
232  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
233  icon_bundle.AddIcon( icon );
234 
235  SetIcons( icon_bundle );
236 
237  LoadSettings( eeconfig() );
238 
239  // Also links the schematic to the loaded project
240  CreateScreens();
241 
242  // After schematic has been linked to project, SCHEMATIC_SETTINGS works
243  m_defaults = &m_schematic->Settings();
244  LoadProjectSettings();
245 
246  setupTools();
247  setupUIConditions();
248  ReCreateMenuBar();
249  ReCreateHToolbar();
250  ReCreateVToolbar();
251  ReCreateOptToolbar();
252 
253  // Initialize common print setup dialog settings.
254  m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
255  m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
256  m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
257  m_pageSetupData.GetPrintData().SetNoCopies( 1 );
258 
259  m_auimgr.SetManagedWindow( this );
260 
261  CreateInfoBar();
262  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
263  .Top().Layer( 6 ) );
264  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
265  .Left().Layer( 3 ) );
266  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
267  .Right().Layer( 2 ) );
268  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
269  .Center() );
270  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
271  .Bottom().Layer( 6 ) );
272 
273  FinishAUIInitialization();
274 
275  resolveCanvasType();
276  SwitchCanvas( m_canvasType );
277 
278  initScreenZoom();
279 
280  // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
281  // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
282  Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
283 
284  if( GetCanvas() )
285  {
286  GetCanvas()->GetGAL()->SetAxesEnabled( false );
287 
288  if( auto p = dynamic_cast<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() ) )
289  p->SetSchematic( m_schematic );
290  }
291 
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() )
326  GetSettingsManager()->UnloadProject( &Prj(), false );
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() || !SELECTION_CONDITIONS::Idle( aSel );
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 
389 
390  mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
391  mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );
394  mgr->SetConditions( ACTIONS::doDelete, ENABLE( hasElements ) );
395  mgr->SetConditions( ACTIONS::duplicate, ENABLE( hasElements ) );
396  mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
397 
398  mgr->SetConditions( EE_ACTIONS::rotateCW, ENABLE( hasElements ) );
399  mgr->SetConditions( EE_ACTIONS::rotateCCW, ENABLE( hasElements ) );
400  mgr->SetConditions( EE_ACTIONS::mirrorH, ENABLE( hasElements ) );
401  mgr->SetConditions( EE_ACTIONS::mirrorV, ENABLE( hasElements ) );
402 
405 
406  auto showHiddenPinsCond =
407  [this] ( const SELECTION& )
408  {
409  return GetShowAllPins();
410  };
411 
412  auto forceHVCond =
413  [this] ( const SELECTION& )
414  {
415  return eeconfig()->m_Drawing.hv_lines_only;
416  };
417 
418  auto remapSymbolsCondition =
419  [&]( const SELECTION& aSel )
420  {
421  SCH_SCREENS schematic( Schematic().Root() );
422 
423  // The remapping can only be performed on legacy projects.
424  return schematic.HasNoFullyDefinedLibIds();
425  };
426 
427  auto belowRootSheetCondition =
428  [this]( const SELECTION& aSel )
429  {
430  return GetCurrentSheet().Last() != &Schematic().Root();
431  };
432 
433  mgr->SetConditions( EE_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
434  mgr->SetConditions( EE_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
435  mgr->SetConditions( EE_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
436  mgr->SetConditions( EE_ACTIONS::toggleForceHV, CHECK( forceHVCond ) );
437 
438 
439 #define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
440 
458 
459 #undef CURRENT_TOOL
460 #undef CHECK
461 #undef ENABLE
462 }
463 
464 
466 {
467  // we cannot store a pointer to an item in the display list here since
468  // that item may be deleted, such as part of a line concatenation or other.
469  // So simply always keep a copy of the object which is to be repeated.
470 
471  if( aItem )
472  {
473  delete m_item_to_repeat;
474 
475  m_item_to_repeat = (SCH_ITEM*) aItem->Clone();
476  // Clone() preserves the flags, we want 'em cleared.
478  }
479 }
480 
481 
483 {
484  return Schematic().GetSheets().GetItem( aId );
485 }
486 
487 
489 {
490  SCH_SCREEN* screen;
491  SCH_SCREENS s_list( Schematic().Root() );
492 
493  // Set the sheet count, and the sheet number (1 for root sheet)
494  int sheet_count = Schematic().Root().CountSheets();
495  int sheet_number = 1;
496  const KIID_PATH& current_sheetpath = GetCurrentSheet().Path();
497 
498  // @todo Remove all psuedo page number system is left over from prior to real page number
499  // implementation.
500  for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
501  {
502  if( sheet.Path() == current_sheetpath ) // Current sheet path found
503  break;
504 
505  sheet_number++; // Not found, increment before this current path
506  }
507 
508  for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
509  screen->SetPageCount( sheet_count );
510 
511  GetCurrentSheet().SetVirtualPageNumber( sheet_number );
512  GetScreen()->SetVirtualPageNumber( sheet_number );
513  GetScreen()->SetPageNumber( GetCurrentSheet().GetPageNumber() );
514 }
515 
516 
518 {
519  return GetCurrentSheet().LastScreen();
520 }
521 
522 
524 {
525  return *m_schematic;
526 }
527 
528 
530 {
531  wxString s = GetCurrentSheet().PathHumanReadable();
532 
533  return s;
534 }
535 
536 
538 {
539  m_schematic->Reset();
540  m_schematic->SetProject( &Prj() );
541 
543 
545 
546  SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
547  m_schematic->Root().SetScreen( rootScreen );
548  SetScreen( Schematic().RootScreen() );
549 
550  m_schematic->RootScreen()->SetFileName( wxEmptyString );
551 
552  // Don't leave root page number empty
553  SCH_SHEET_PATH rootSheetPath;
554  rootSheetPath.push_back( &m_schematic->Root() );
555  m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
556  m_schematic->Root().AddInstance( rootSheetPath.Path() );
557  m_schematic->Root().SetPageNumber( rootSheetPath, wxT( "1" ) );
558 
559  if( GetScreen() == NULL )
560  {
561  SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
562  SetScreen( screen );
563  }
564 }
565 
566 
568 {
569  return m_schematic->CurrentSheet();
570 }
571 
572 
574 {
575  if( aSheet != GetCurrentSheet() )
576  {
577  FocusOnItem( nullptr );
578 
579  Schematic().SetCurrentSheet( aSheet );
580  GetCanvas()->DisplaySheet( aSheet.LastScreen() );
581  }
582 }
583 
584 
586 {
588 
589  FocusOnItem( nullptr );
590 
591  GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
592  GetCanvas()->ForceRefresh();
593 }
594 
595 
596 bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
597 {
598  // Exit interactive editing
599  // Note this this will commit *some* pending changes. For instance, the EE_POINT_EDITOR
600  // will cancel any drag currently in progress, but commit all changes from previous drags.
601  if( m_toolManager )
603 
604  // Shutdown blocks must be determined and vetoed as early as possible
605  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
606  && Schematic().GetSheets().IsModified() )
607  {
608  return false;
609  }
610 
611  if( Kiface().IsSingle() )
612  {
613  auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
614 
615  if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
616  return false;
617 
618  auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
619 
620  if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
621  return false;
622 
623  symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
624 
625  if( symbolViewer && !symbolViewer->Close() ) // Can close modal symbol viewer?
626  return false;
627  }
628 
629  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
630 
631  if( simFrame && !simFrame->Close() ) // Can close the simulator?
632  return false;
633 
634  // We may have gotten multiple events; don't clean up twice
635  if( !Schematic().IsValid() )
636  return false;
637 
638  SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
639 
640  if( sheetlist.IsModified() )
641  {
642  wxFileName fileName = Schematic().RootScreen()->GetFileName();
643  wxString msg = _( "Save changes to \"%s\" before closing?" );
644 
645  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
646  [&]()->bool { return SaveProject(); } ) )
647  {
648  return false;
649  }
650  }
651 
652  return true;
653 }
654 
655 
657 {
658  SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
659 
660  // Shutdown all running tools
661  if( m_toolManager )
663 
665 
666  // Close the find dialog and preserve it's setting if it is displayed.
667  if( m_findReplaceDialog )
668  {
671 
672  m_findReplaceDialog->Destroy();
673  m_findReplaceDialog = nullptr;
674  }
675 
676  if( FindHierarchyNavigator() )
677  FindHierarchyNavigator()->Close( true );
678 
679  SCH_SCREENS screens( Schematic().Root() );
680  wxFileName fn;
681 
682  for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
683  {
684  fn = Prj().AbsolutePath( screen->GetFileName() );
685 
686  // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
687  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
688 
689  if( fn.FileExists() && fn.IsFileWritable() )
690  wxRemoveFile( fn.GetFullPath() );
691  }
692 
693  sheetlist.ClearModifyStatus();
694 
695  wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
696 
697  if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
698  UpdateFileHistory( fileName );
699 
700  Schematic().RootScreen()->Clear();
701 
702  // all sub sheets are deleted, only the main sheet is usable
704 
705  // Clear view before destroying schematic as repaints depend on schematic being valid
706  SetScreen( nullptr );
707 
708  Schematic().Reset();
709 
710  Destroy();
711 }
712 
713 
715 {
716  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
717  ERC_SETTINGS& ercSettings = Schematic().ErcSettings();
718 
719  ercSettings.m_ErcExclusions.clear();
720 
721  for( unsigned i = 0; i < sheetList.size(); i++ )
722  {
723  for( SCH_ITEM* item : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) )
724  {
725  SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
726 
727  if( marker->IsExcluded() )
728  ercSettings.m_ErcExclusions.insert( marker->Serialize() );
729  }
730  }
731 }
732 
733 
735 {
736  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
737 
738  for( SCH_MARKER* marker : Schematic().ResolveERCExclusions() )
739  {
740  SCH_SHEET_PATH errorPath;
741  (void) sheetList.GetItem( marker->GetRCItem()->GetMainItemID(), &errorPath );
742 
743  if( errorPath.LastScreen() )
744  errorPath.LastScreen()->Append( marker );
745  else
746  Schematic().RootScreen()->Append( marker );
747  }
748 }
749 
750 
752 {
753  // Filename is rootSheetName-sheetName-...-sheetName
754  // Note that we need to fetch the rootSheetName out of its filename, as the root SCH_SHEET's
755  // name is just a timestamp.
756 
757  wxFileName rootFn( GetCurrentSheet().at( 0 )->GetFileName() );
758  wxString filename = rootFn.GetName();
759 
760  for( unsigned i = 1; i < GetCurrentSheet().size(); i++ )
761  filename += wxT( "-" ) + GetCurrentSheet().at( i )->GetName();
762 
763  return filename;
764 }
765 
766 
768 {
769  wxASSERT( GetScreen() );
770 
771  if( !GetScreen() )
772  return;
773 
774  GetScreen()->SetModify();
775  GetScreen()->SetSave();
776 
777  if( ADVANCED_CFG::GetCfg().m_RealTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime )
779 
781  []( KIGFX::VIEW_ITEM* aItem )
782  {
783  SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
784  SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
785 
786  if( connection && connection->HasDriverChanged() )
787  {
788  connection->ClearDriverChanged();
789  return true;
790  }
791 
792  return false;
793  } );
794 
795  GetCanvas()->Refresh();
797 
798  if( !GetTitle().StartsWith( "*" ) )
799  UpdateTitle();
800 }
801 
802 
803 void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
804 {
805  if( Kiface().IsSingle() )
806  {
807  DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
808  " in stand-alone mode. In order to create/update PCBs from"
809  " schematics, launch the KiCad shell and create a project." ) );
810  return;
811  }
812 
813  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
814 
815  if( !frame )
816  {
817  wxFileName fn = Prj().GetProjectFullName();
818  fn.SetExt( PcbFileExtension );
819 
820  frame = Kiway().Player( FRAME_PCB_EDITOR, true );
821  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
822  }
823 
824  if( !frame->IsVisible() )
825  frame->Show( true );
826 
827  // On Windows, Raise() does not bring the window on screen, when iconized
828  if( frame->IsIconized() )
829  frame->Iconize( false );
830 
831  frame->Raise();
832 
833  std::string payload;
834  Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_PCB_UPDATE, payload, this );
835 }
836 
837 
839 {
840  if( m_findReplaceDialog && m_findReplaceDialog->IsVisible()
841  && !m_findReplaceData->GetFindString().IsEmpty() )
842  {
843  return m_findReplaceData;
844  }
845 
846  return nullptr;
847 }
848 
849 
851 {
852  wxWindow* navigator = wxWindow::FindWindowByName( HIERARCHY_NAVIG_DLG_WNAME );
853 
854  return static_cast< HIERARCHY_NAVIG_DLG* >( navigator );
855 }
856 
857 
859 {
860  if( aForceUpdate )
861  {
862  if( FindHierarchyNavigator() )
863  FindHierarchyNavigator()->Close();
864 
865  HIERARCHY_NAVIG_DLG* hierarchyDialog = new HIERARCHY_NAVIG_DLG( this );
866 
867  hierarchyDialog->Show( true );
868  }
869  else
870  {
871  if( FindHierarchyNavigator() )
873  }
874 }
875 
876 
878 {
879  if( m_findReplaceDialog )
880  m_findReplaceDialog->Destroy();
881 
882  m_findReplaceDialog= new DIALOG_SCH_FIND( this, m_findReplaceData, wxDefaultPosition,
883  wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
884 
887  m_findReplaceDialog->Show( true );
888 }
889 
890 
891 void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime )
892 {
893  // Prepare the infobar, since we don't know its state
896 
897  m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
898 }
899 
900 
902 {
903  m_infoBar->Dismiss();
904 }
905 
906 
908 {
911 
912  m_findReplaceDialog->Destroy();
913  m_findReplaceDialog = nullptr;
914 
916 }
917 
918 
919 void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
920 {
921  wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
922 
923  if( fn.size() )
924  OpenProjectFiles( std::vector<wxString>( 1, fn ) );
925 }
926 
927 
928 void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
929 {
931 }
932 
933 
935 {
936  wxString pro_dir = m_mruPath;
937 
938  wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
939  KiCadSchematicFileWildcard(), wxFD_SAVE );
940 
941  if( dlg.ShowModal() != wxID_CANCEL )
942  {
943  // Enforce the extension, wxFileDialog is inept.
944  wxFileName create_me = dlg.GetPath();
945  create_me.SetExt( KiCadSchematicFileExtension );
946 
947  if( create_me.FileExists() )
948  {
949  wxString msg;
950  msg.Printf( _( "Schematic file \"%s\" already exists." ), create_me.GetFullName() );
951  DisplayError( this, msg );
952  return ;
953  }
954 
955  // OpenProjectFiles() requires absolute
956  wxASSERT_MSG( create_me.IsAbsolute(), "wxFileDialog returned non-absolute path" );
957 
958  OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
959  m_mruPath = create_me.GetPath();
960  }
961 }
962 
963 
965 {
966  wxString pro_dir = m_mruPath;
967  wxString wildcards = KiCadSchematicFileWildcard();
968 
969  wildcards += "|" + LegacySchematicFileWildcard();
970 
971  wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
972  wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
973 
974  if( dlg.ShowModal() != wxID_CANCEL )
975  {
976  OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
978  }
979 }
980 
981 
982 void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
983 {
984  wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
985 
986  if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() )
987  {
988  kicad_board.SetExt( PcbFileExtension );
989  wxFileName legacy_board( kicad_board );
990  legacy_board.SetExt( LegacyPcbFileExtension );
991  wxFileName& boardfn = legacy_board;
992 
993  if( !legacy_board.FileExists() || kicad_board.FileExists() )
994  boardfn = kicad_board;
995 
996  if( Kiface().IsSingle() )
997  {
998  wxString filename = QuoteFullPath( boardfn );
999  ExecuteFile( this, PCBNEW_EXE, filename );
1000  }
1001  else
1002  {
1003  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1004 
1005  if( !frame )
1006  {
1007  frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1008  frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1009  }
1010 
1011  if( !frame->IsVisible() )
1012  frame->Show( true );
1013 
1014  // On Windows, Raise() does not bring the window on screen, when iconized
1015  if( frame->IsIconized() )
1016  frame->Iconize( false );
1017 
1018  frame->Raise();
1019  }
1020  }
1021  else
1022  {
1023  // If we are running inside a project, it should be impossible for this case to happen
1024  wxASSERT( Kiface().IsSingle() );
1025  ExecuteFile( this, PCBNEW_EXE );
1026  }
1027 }
1028 
1029 
1030 void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
1031 {
1032  wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
1033  fn.SetExt( NetlistFileExtension );
1034 
1035  if( !ReadyToNetlist( _( "Assigning footprints requires a fully annotated schematic." ) ) )
1036  return;
1037 
1038  try
1039  {
1040  KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1041 
1042  if( !player )
1043  {
1044  player = Kiway().Player( FRAME_CVPCB, true );
1045  player->Show( true );
1046  }
1047 
1049 
1050  player->Raise();
1051  }
1052  catch( const IO_ERROR& )
1053  {
1054  DisplayError( this, _( "Could not open CvPcb" ) );
1055  }
1056 }
1057 
1058 
1059 void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1060 {
1061  if( event.GetId() == wxID_EXIT )
1062  Kiway().OnKiCadExit();
1063 
1064  if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1065  Close( false );
1066 }
1067 
1068 
1070 {
1071  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1072 
1073  const wxBrush& brush =
1074  wxBrush( GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ).ToColour() );
1075  aSettings->GetPrintDC()->SetBackground( brush );
1076  aSettings->GetPrintDC()->Clear();
1077 
1078  aSettings->GetPrintDC()->SetLogicalFunction( wxCOPY );
1079  GetScreen()->Print( aSettings );
1080  PrintDrawingSheet( aSettings, GetScreen(), IU_PER_MILS, fileName );
1081 }
1082 
1083 
1085 {
1086  // In case this event happens before g_RootSheet is initialized which does happen
1087  // on mingw64 builds.
1088 
1089  if( Schematic().IsValid() )
1090  {
1091  SCH_SCREENS screenList( Schematic().Root() );
1092 
1093  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
1094  {
1095  if( screen->IsSave() )
1096  return true;
1097  }
1098  }
1099 
1100  return false;
1101 }
1102 
1103 
1104 static void inheritNetclass( const SCH_SHEET_PATH& aSheetPath, SCH_TEXT* aItem )
1105 {
1106  // Netclasses are assigned to subgraphs by association with their netname. However, when
1107  // a new label is attached to an existing subgraph (with an existing netclass association),
1108  // the association will be lost as the label will drive its name on to the graph.
1109  //
1110  // Here we find the previous driver of the subgraph and if it had a netclass we associate
1111  // the new netname with that netclass as well.
1112  //
1113  SCHEMATIC* schematic = aItem->Schematic();
1114  CONNECTION_SUBGRAPH* subgraph = schematic->ConnectionGraph()->GetSubgraphForItem( aItem );
1115 
1116  std::map<wxString, wxString>& netclassAssignments =
1118 
1119  if( subgraph )
1120  {
1121  SCH_ITEM* previousDriver = nullptr;
1123 
1124  for( SCH_ITEM* item : subgraph->m_drivers )
1125  {
1126  if( item == aItem )
1127  continue;
1128 
1130 
1131  if( p > priority )
1132  {
1133  priority = p;
1134  previousDriver = item;
1135  }
1136  }
1137 
1138  if( previousDriver )
1139  {
1140  wxString path = aSheetPath.PathHumanReadable();
1141  wxString oldDrivenName = path + subgraph->GetNameForDriver( previousDriver );
1142  wxString drivenName = path + subgraph->GetNameForDriver( aItem );
1143 
1144  if( netclassAssignments.count( oldDrivenName ) )
1145  netclassAssignments[ drivenName ] = netclassAssignments[ oldDrivenName ];
1146  }
1147  }
1148 }
1149 
1150 
1152  bool aUndoAppend )
1153 {
1154  wxCHECK_RET( aItem != NULL, wxT( "Cannot add null item to list." ) );
1155 
1156  SCH_SHEET* parentSheet = nullptr;
1157  SCH_COMPONENT* parentSymbol = nullptr;
1158  SCH_ITEM* undoItem = aItem;
1159 
1160  if( aItem->Type() == SCH_SHEET_PIN_T )
1161  {
1162  parentSheet = (SCH_SHEET*) aItem->GetParent();
1163 
1164  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
1165  wxT( "Cannot place sheet pin in invalid schematic sheet." ) );
1166 
1167  undoItem = parentSheet;
1168  }
1169 
1170  else if( aItem->Type() == SCH_FIELD_T )
1171  {
1172  parentSymbol = (SCH_COMPONENT*) aItem->GetParent();
1173 
1174  wxCHECK_RET( parentSymbol && parentSymbol->Type() == SCH_COMPONENT_T,
1175  wxT( "Cannot place field in invalid schematic symbol." ) );
1176 
1177  undoItem = parentSymbol;
1178  }
1179 
1180  if( aItem->IsNew() )
1181  {
1182  if( aItem->Type() == SCH_SHEET_PIN_T )
1183  {
1184  // Sheet pins are owned by their parent sheet.
1185  SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::CHANGED, aUndoAppend );
1186 
1187  parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
1188  }
1189  else if( aItem->Type() == SCH_FIELD_T )
1190  {
1191  // Symbol fields are also owned by their parent, but new symbol fields are
1192  // handled elsewhere.
1193  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1194  }
1195  else
1196  {
1197  if( !aScreen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
1198  AddToScreen( aItem, aScreen );
1199 
1200  SaveCopyForRepeatItem( aItem );
1201  SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::NEWITEM, aUndoAppend );
1202  }
1203 
1204  // Update connectivity info for new item
1205  if( !aItem->IsMoving() )
1206  {
1208 
1209  if( SCH_TEXT* textItem = dynamic_cast<SCH_TEXT*>( aItem ) )
1210  inheritNetclass( GetCurrentSheet(), textItem );
1211  }
1212  }
1213 
1214  aItem->ClearFlags( IS_NEW );
1215 
1216  aScreen->SetModify();
1217  UpdateItem( aItem );
1218 
1219  if( !aItem->IsMoving() && aItem->IsConnectable() )
1220  {
1221  std::vector< wxPoint > pts = aItem->GetConnectionPoints();
1222 
1223  for( auto i = pts.begin(); i != pts.end(); i++ )
1224  {
1225  for( auto j = i + 1; j != pts.end(); j++ )
1226  TrimWire( *i, *j );
1227 
1228  if( aScreen->IsJunctionNeeded( *i, true ) )
1229  AddJunction( aScreen, *i, true, false );
1230  }
1231 
1232  TestDanglingEnds();
1233 
1234  for( SCH_ITEM* item : aItem->ConnectedItems( GetCurrentSheet() ) )
1235  UpdateItem( item );
1236  }
1237 
1238  aItem->ClearEditFlags();
1239  GetCanvas()->Refresh();
1240 }
1241 
1242 
1244 {
1245  wxString title;
1246 
1247  if( GetScreen()->GetFileName().IsEmpty() )
1248  {
1249  title = _( "[no file]" ) + wxT( " \u2014 " ) + _( "Schematic Editor" );
1250  }
1251  else
1252  {
1253  wxFileName fn( Prj().AbsolutePath( GetScreen()->GetFileName() ) );
1254  bool readOnly = false;
1255  bool unsaved = false;
1256 
1257  if( fn.IsOk() && fn.FileExists() )
1258  readOnly = !fn.IsFileWritable();
1259  else
1260  unsaved = true;
1261 
1262  title.Printf( wxT( "%s%s [%s] %s%s\u2014 " ) + _( "Schematic Editor" ),
1263  IsContentModified() ? "*" : "",
1264  fn.GetName(),
1266  readOnly ? _( "[Read Only]" ) + wxS( " " ) : "",
1267  unsaved ? _( "[Unsaved]" ) + wxS( " " ) : "" );
1268  }
1269 
1270  SetTitle( title );
1271 }
1272 
1273 
1275 {
1277  GetScreen()->m_zoomInitialized = true;
1278 }
1279 
1280 
1282 {
1283  SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1284  SCH_SHEET_LIST list = Schematic().GetSheets();
1285  PROF_COUNTER timer;
1286 
1287  // Ensure schematic graph is accurate
1288  if( aCleanupFlags == LOCAL_CLEANUP )
1289  {
1291  }
1292  else if( aCleanupFlags == GLOBAL_CLEANUP )
1293  {
1294  for( const SCH_SHEET_PATH& sheet : list )
1295  SchematicCleanUp( sheet.LastScreen() );
1296  }
1297 
1298  timer.Stop();
1299  wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
1300 
1301  if( settings.m_IntersheetRefsShow )
1303 
1304  std::function<void( SCH_ITEM* )> changeHandler =
1305  [&]( SCH_ITEM* aChangedItem ) -> void
1306  {
1307  GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1308  };
1309 
1310  Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler );
1311 }
1312 
1313 
1315 {
1316  std::map<wxString, std::set<wxString>>& pageRefsMap = Schematic().GetPageRefsMap();
1317 
1318  pageRefsMap.clear();
1319 
1320  SCH_SCREENS screens( Schematic().Root() );
1321  std::vector<wxString> pageNumbers;
1322 
1323  /* Iterate over screens */
1324  for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
1325  {
1326  pageNumbers.clear();
1327 
1328  /* Find in which sheets this screen is used */
1329  for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
1330  {
1331  if( sheet.LastScreen() == screen )
1332  pageNumbers.push_back( sheet.GetPageNumber() );
1333  }
1334 
1335  for( SCH_ITEM* item : screen->Items() )
1336  {
1337  if( item->Type() == SCH_GLOBAL_LABEL_T )
1338  {
1339  SCH_GLOBALLABEL* globalLabel = static_cast<SCH_GLOBALLABEL*>( item );
1340  std::set<wxString>& pageList = pageRefsMap[ globalLabel->GetText() ];
1341 
1342  for( const wxString& pageNo : pageNumbers )
1343  pageList.insert( pageNo );
1344  }
1345  }
1346  }
1347 
1348  bool show = Schematic().Settings().m_IntersheetRefsShow;
1349 
1350  /* Refresh all global labels */
1351  for( EDA_ITEM* item : GetScreen()->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1352  {
1353  SCH_GLOBALLABEL* global = static_cast<SCH_GLOBALLABEL*>( item );
1354 
1355  global->GetIntersheetRefs()->SetVisible( show );
1356 
1357  if( show )
1358  GetCanvas()->GetView()->Update( global );
1359  }
1360 }
1361 
1362 
1364 {
1365  if( aShow )
1367 
1368  SCH_SCREENS screens( Schematic().Root() );
1369 
1370  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
1371  {
1372  for( SCH_ITEM* item : screen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1373  {
1374  SCH_GLOBALLABEL* gLabel = (SCH_GLOBALLABEL*)( item );
1375  SCH_FIELD* intersheetRef = gLabel->GetIntersheetRefs();
1376 
1377  intersheetRef->SetVisible( aShow );
1378  UpdateItem( intersheetRef, true );
1379  }
1380  }
1381 }
1382 
1383 
1384 void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1385 {
1386  SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1387  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1388 
1390 
1391  RecreateToolbars();
1392  Layout();
1393  SendSizeEvent();
1394 }
1395 
1396 
1398 {
1399  // Store the current zoom level into the current screen before calling
1400  // DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
1402  // Rebuild the sheet view (draw area and any other items):
1404 }
1405 
1406 
1408 {
1409  // call my base class
1411 
1412  // tooltips in toolbars
1413  RecreateToolbars();
1414 
1415  // status bar
1416  UpdateMsgPanel();
1417 
1418  // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
1419  // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
1420  // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
1421  // toolbar to update correctly.
1422 #if defined( __WXMSW__ )
1423  PostSizeEvent();
1424 #endif
1425 }
1426 
1427 
1429 {
1430  if( const SCH_CONNECTION* conn = GetHighlightedConnection() )
1431  {
1432  SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
1433  UnescapeString( conn->Name() ) ) );
1434  }
1435  else
1436  {
1437  SetStatusText( wxT( "" ) );
1438  }
1439 }
1440 
1441 
1443 {
1444  if( m_toolManager )
1446 
1447  SCH_BASE_FRAME::SetScreen( aScreen );
1448  GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
1449 }
1450 
1451 
1452 const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
1453 {
1454  BOX2I bBoxDoc;
1455 
1456  if( aIncludeAllVisible )
1457  {
1458  // Get the whole page size and return that
1459  int sizeX = GetScreen()->GetPageSettings().GetWidthIU();
1460  int sizeY = GetScreen()->GetPageSettings().GetHeightIU();
1461  bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
1462  }
1463  else
1464  {
1465  // Get current drawing-sheet in a form we can compare to an EDA_ITEM
1467  EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
1468 
1469  // Need an EDA_RECT so the first ".Merge" sees it's uninitialized
1470  EDA_RECT bBoxItems;
1471 
1472  // Calc the bounding box of all items on screen except the page border
1473  for( EDA_ITEM* item : GetScreen()->Items() )
1474  {
1475  if( item != dsAsItem ) // Ignore the drawing-sheet itself
1476  {
1477  if( item->Type() == SCH_COMPONENT_T )
1478  {
1479  // For symbols we need to get the bounding box without invisible text
1480  SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( item );
1481  bBoxItems.Merge( symbol->GetBoundingBox( false ) );
1482  }
1483  else
1484  bBoxItems.Merge( item->GetBoundingBox() );
1485  }
1486  bBoxDoc = bBoxItems;
1487  }
1488  }
1489  return bBoxDoc;
1490 }
1491 
1492 
1494 {
1495  // Save the current sheet, to retrieve it later
1496  SCH_SHEET_PATH oldsheetpath = GetCurrentSheet();
1497 
1498  bool modified = false;
1499 
1500  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1501 
1502  for( const SCH_SHEET_PATH& sheet : sheetList )
1503  {
1504  // We require a set here to avoid adding multiple junctions to the same spot
1505  std::set<wxPoint> junctions;
1506 
1507  SetCurrentSheet( sheet );
1509 
1510  SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
1511 
1512  for( auto aItem : screen->Items().OfType( SCH_COMPONENT_T ) )
1513  {
1514  auto cmp = static_cast<SCH_COMPONENT*>( aItem );
1515 
1516  for( const SCH_PIN* pin : cmp->GetPins( &sheet ) )
1517  {
1518  auto pos = pin->GetPosition();
1519 
1520  // Test if a _new_ junction is needed, and add it if missing
1521  if( screen->IsJunctionNeeded( pos, true ) )
1522  junctions.insert( pos );
1523  }
1524  }
1525 
1526  for( const wxPoint& pos : junctions )
1527  AddJunction( screen, pos, false, false );
1528 
1529  if( junctions.size() )
1530  modified = true;
1531  }
1532 
1533  if( modified )
1534  OnModify();
1535 
1536  // Reselect the initial sheet:
1537  SetCurrentSheet( oldsheetpath );
1539  SetScreen( GetCurrentSheet().LastScreen() );
1540 }
1541 
1542 
1544 {
1545  return Schematic().GetSheets().IsModified();
1546 }
1547 
1548 
1550 {
1551  EESCHEMA_SETTINGS* cfg = eeconfig();
1552  return cfg->m_Appearance.show_hidden_pins;
1553 }
1554 
1555 
1557 {
1558  static KIID lastBrightenedItemID( niluuid );
1559 
1560  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1562  SCH_ITEM* lastItem = sheetList.GetItem( lastBrightenedItemID, &dummy );
1563 
1564  if( lastItem && lastItem != aItem )
1565  {
1566  lastItem->ClearBrightened();
1567 
1568  UpdateItem( lastItem );
1569  lastBrightenedItemID = niluuid;
1570  }
1571 
1572  if( aItem )
1573  {
1574  aItem->SetBrightened();
1575 
1576  UpdateItem( aItem );
1577  lastBrightenedItemID = aItem->m_Uuid;
1578 
1579  FocusOnLocation( aItem->GetFocusPosition() );
1580  }
1581 }
1582 
1583 
1585 {
1586  return Schematic().GetFileName();
1587 }
1588 
1589 
1591 {
1592  return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1593 }
1594 
1595 
1596 void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
1597 {
1598  if( IsShown() )
1599  {
1600  // We only need this until the frame is done resizing and the final client size is
1601  // established.
1602  Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
1604  }
1605 
1606  // Skip() is called in the base class.
1607  EDA_DRAW_FRAME::OnSize( aEvent );
1608 }
1609 
1610 
1612 {
1613  wxString msg;
1614  bool appendToUndo = false;
1615 
1616  wxCHECK( m_toolManager, /* void */ );
1617 
1619 
1620  wxCHECK( selectionTool, /* void */ );
1621 
1622  EE_SELECTION& selection = selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
1623 
1624  if( selection.Empty() )
1625  return;
1626 
1627  SCH_SCREEN* currentScreen = GetScreen();
1628 
1629  wxCHECK( currentScreen, /* void */ );
1630 
1631  // This should work for multiple selections of the same symbol even though the editor
1632  // only works for a single symbol selection.
1633  for( EDA_ITEM* item : selection )
1634  {
1635  SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( item );
1636 
1637  wxCHECK( symbol, /* void */ );
1638 
1639  // This needs to be done before the LIB_PART is changed to prevent stale library symbols in
1640  // the schematic file.
1641  currentScreen->Remove( symbol );
1642 
1643  if( !symbol->IsNew() )
1644  {
1645  SaveCopyInUndoList( currentScreen, symbol, UNDO_REDO::CHANGED, appendToUndo );
1646  appendToUndo = true;
1647  }
1648 
1649  symbol->SetLibSymbol( aSymbol.Flatten().release() );
1650  symbol->UpdateFields( &GetCurrentSheet(),
1651  true, /* update style */
1652  true, /* update ref */
1653  true, /* update other fields */
1654  false, /* reset ref */
1655  false /* reset other fields */ );
1656 
1657  currentScreen->Append( symbol );
1658  selectionTool->SelectHighlightItem( symbol );
1659  GetCanvas()->GetView()->Update( symbol );
1660  }
1661 
1662  if( selection.IsHover() )
1664 
1665  GetCanvas()->Refresh();
1666  OnModify();
1667 }
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)
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Check if we are ready to write a netlist file for the current schematic.
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:252
bool empty() const
Definition: sch_rtree.h:163
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
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:118
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:216
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:115
Instances are attached to a symbol or sheet and provide a place for the component's value,...
Definition: sch_field.h:50
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:207
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
SCHEMATIC * m_schematic
The currently loaded schematic.
const wxString & GetFileName() const
Definition: sch_screen.h:133
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:244
SCH_SCREEN * GetNext()
void SetLibSymbol(LIB_PART *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:248
void OnKiCadExit()
Definition: kiway.cpp:599
void UpdateNetHighlightStatus()
virtual bool IsConnectable() const
Definition: sch_item.h:362
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:1425
void SetVirtualPageNumber(int aPageNumber)
Definition: base_screen.h:80
wxArrayString GetFindEntries() const
virtual std::vector< wxPoint > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:377
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)
Generate 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.
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.
Definition: schematic.h:59
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:129
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
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.).
static void add_search_paths(SEARCH_STACK *aDst, const SEARCH_STACK &aSrc, int aIndex)
bool IsModified() const
Check the entire hierarchy for any modifications.
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:87
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.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
wxString PathHumanReadable(bool aUseShortRootName=true) const
Return the sheet path in a human readable form made from the sheet 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
Handle actions specific to the schematic editor.
bool IsMoving() const
Definition: eda_item.h:170
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:127
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:85
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:473
static TOOL_ACTION placeJunction
Definition: ee_actions.h:81
virtual const wxPoint GetFocusPosition() const
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: eda_item.h:309
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:156
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:108
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:180
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:156
void ResolveERCExclusions()
Update markers to match recorded exclusions.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
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 OnAppendProject(wxCommandEvent &event)
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
NET_SETTINGS & NetSettings()
Definition: project_file.h:94
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:357
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:451
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:82
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.
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:48
Manage TOOL_ACTION objects.
virtual _ELEM * GetElem(ELEM_T aIndex)
Get and set the elements for this project.
Definition: project.cpp:247
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:289
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:81
static TOOL_ACTION mirrorH
Definition: ee_actions.h:117
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:623
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
A small class to help profiling.
Definition: profile.h:45
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:128
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:299
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:123
Class that groups generic conditions for editor states.
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
Definition: sch_sheet.cpp:1135
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:166
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:81
static TOOL_ACTION mirrorV
Definition: ee_actions.h:116
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.
Definition: project.cpp:271
static TOOL_ACTION rotateCW
Definition: ee_actions.h:114
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:199
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
bool IsNew() const
Definition: eda_item.h:169
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:182
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:259
void ClearBrightened()
Definition: eda_item.h:183
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)
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:76
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
Definition: schematic.cpp:102
wxString GetScreenDesc() const override
Return a human-readable description of the current screen.
Handle actions specific to the schematic editor.
static TOOL_ACTION drawSheet
Definition: ee_actions.h:86
Master controller class:
Definition: tool_manager.h:52
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
void SaveSymbolToSchematic(const LIB_PART &aSymbol)
Update the LIB_PART of the currently selected symbol.
Definition: kiid.h:44
static TOOL_ACTION copy
Definition: actions.h:70
void doCloseWindow() override
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:115
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:171
Item needs to be redrawn.
Definition: view_item.h:57
static TOOL_ACTION placePower
Definition: ee_actions.h:76
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:101
#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:77
size_t size() const
Forwarded method from std::vector.
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.)
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)
Find (but don't select) node under cursor.
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:88
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.
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
void initScreenZoom()
Initialize the zoom value of the current screen and mark the screen as zoom-initialized.
static TOOL_ACTION placeImage
Definition: ee_actions.h:90
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.
Definition: lib_symbol.h:93
Definition of file extensions used in Kicad.
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:165
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:65
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define PcbFileExtension
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:44
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
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:87
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:54
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:75
bool isAutoSaveRequired() const override
Return true if the schematic has been modified.
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:121
Container for ERC settings.
Definition: erc_settings.h:105
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.
Definition: project.cpp:117
HTML_MESSAGE_BOX.
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the drawing-sheet (frame and title block).
SCHEMATIC_SETTINGS * m_defaults
void SetReplaceEntries(const wxArrayString &aEntries)
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:334
wxString Serialize() const
Definition: sch_marker.cpp:66
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:74
Handle actions that are shared between different applications.
void OnUpdatePCB(wxCommandEvent &event)
COLOR_SETTINGS * GetColorSettings() const override
Returns a pointer to the active color theme settings.
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:282
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
Gather all the actions that are shared by tools.
Definition: ee_actions.h:39
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:78
Implementing SIM_PLOT_FRAME_BASE.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
static TOOL_ACTION pasteSpecial
Definition: actions.h:72
const KIID m_Uuid
Definition: eda_item.h:525
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:83
A collection of PART_LIB objects.
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
Fetch a SCH_ITEM by ID.
static wxString GetAutoSaveFilePrefix()
SCH_FIELD * GetIntersheetRefs()
Definition: sch_text.h:459
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
Definition: sch_sheet.cpp:691
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:51
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
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:92
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:714
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,...
bool m_zoomInitialized
Definition: sch_screen.h:504
SCH_ITEM_SET & ConnectedItems(const SCH_SHEET_PATH &aPath)
Retrieve 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:128
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:192
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.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
#define _(s)
Definition: 3d_actions.cpp:33
Tool that displays edit points allowing to modify items by dragging the points.
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.
EE_RTREE & Items()
Definition: sch_screen.h:103
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:80
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_symbol.h:78
#define IU_PER_MILS
Definition: plotter.cpp:137
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:124
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
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.
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false) const
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:374
~SCH_EDIT_FRAME() override
wxString GetUniqueFilenameForCurrentSheet()
#define CURRENT_TOOL(action)
wxFindReplaceData * m_findReplaceData
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:197
std::map< wxString, std::set< wxString > > & GetPageRefsMap()
Definition: schematic.h:160
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:204
void UpdateFields(const SCH_SHEET_PATH *aPath, bool aUpdateStyle, bool aUpdateRef, bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields)
Restore fields to the original library values.
Definition: sch_symbol.cpp:775
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:86
void FocusOnItem(SCH_ITEM *aItem)
static TOOL_ACTION undo
Definition: actions.h:67
SCH_SCREEN * GetFirst()
EDA_ITEM * GetItem(const KIID &aId) const override
Fetch an item by KIID.
static TOOL_ACTION drawLines
Definition: ee_actions.h:89
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
CONNECTION_SUBGRAPH * GetSubgraphForItem(SCH_ITEM *aItem)
void OnGridSettings(wxCommandEvent &event)
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
Definition: sch_view.h:98
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:134
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:131
void InitTools()
Initializes all registered tools.
Definition for part library class.
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:115
bool IsContentModified() override
Get if the current schematic has been modified but not saved.
void SetModify()
Definition: base_screen.h:59
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:119
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:84
double GetScale() const
Definition: view.h:263
void ClearEditFlags()
Definition: eda_item.h:222
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:203
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:70
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:197
static TOOL_ACTION selectAll
Definition: actions.h:73
#define IS_NEW
New item, just created.
Definition: eda_item.h:107
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:549
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:1503
bool AddInstance(const KIID_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
Definition: sch_sheet.cpp:1093
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:163
void sendNetlistToCvpcb()
Send the KiCad netlist over to CVPCB.
virtual void UpdateMsgPanel()
Redraw the message panel.
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
Definition: sch_screen.cpp:307
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: infobar.cpp:272
wxBitmap KiBitmap(BITMAPS aBitmap)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104
The symbol library editor main window.