KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_editor_control.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) 2019-2023 CERN
5 * Copyright (C) 1992-2024 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 <symbol_library.h>
26#include <confirm.h>
27#include <connection_graph.h>
36#include <project_rescue.h>
37#include <erc/erc.h>
38#include <invoke_sch_dialog.h>
39#include <string_utils.h>
40#include <kiway.h>
42#include <paths.h>
43#include <pgm_base.h>
46#include <project_sch.h>
47#include <sch_edit_frame.h>
49#include <sch_line.h>
50#include <sch_junction.h>
51#include <sch_bus_entry.h>
52#include <sch_shape.h>
53#include <sch_painter.h>
54#include <sch_sheet_pin.h>
55#include <sch_commit.h>
56#include <sim/simulator_frame.h>
58#include <symbol_viewer_frame.h>
59#include <tool/picker_tool.h>
60#include <tool/tool_manager.h>
61#include <tools/ee_actions.h>
62#include <tools/ee_selection.h>
66#include <eda_list_dialog.h>
67#include <view/view_controls.h>
69#include <wx_filename.h>
70#include <wx/filedlg.h>
71#include <wx/log.h>
72#include <wx/treectrl.h>
73#include <wx/msgdlg.h>
74#include "sch_edit_table_tool.h"
75
76#ifdef KICAD_IPC_API
78#endif
79
80
86static const wxChar traceSchPaste[] = wxT( "KICAD_SCH_PASTE" );
87
88
90{
92 return 0;
93}
94
95
97{
99 return 0;
100}
101
102
104{
106 return 0;
107}
108
109
111{
112 m_frame->SaveProject( true );
113 return 0;
114}
115
116
118{
119 SCH_SHEET* curr_sheet = m_frame->GetCurrentSheet().Last();
120 wxFileName curr_fn = curr_sheet->GetFileName();
121 wxFileDialog dlg( m_frame, _( "Schematic Files" ), curr_fn.GetPath(), curr_fn.GetFullName(),
123 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
124
125 if( dlg.ShowModal() == wxID_CANCEL )
126 return false;
127
128 wxString newFilename =
130
131 m_frame->saveSchematicFile( curr_sheet, newFilename );
132 return 0;
133}
134
135
137{
138 SCHEMATIC& schematic = m_frame->Schematic();
139 SCH_SHEET& root = schematic.Root();
140
141 if( m_frame->GetCurrentSheet().Last() != &root )
142 {
145
146 // Store the current zoom level into the current screen before switching
148
149 SCH_SHEET_PATH rootSheetPath;
150 rootSheetPath.push_back( &root );
151 m_frame->SetCurrentSheet( rootSheetPath );
153
154 wxSafeYield();
155 }
156
157 wxString msg;
158 msg.Printf( _( "Revert '%s' (and all sub-sheets) to last version saved?" ),
159 schematic.GetFileName() );
160
161 if( !IsOK( m_frame, msg ) )
162 return false;
163
164 SCH_SCREENS screenList( schematic.Root() );
165
166 for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
167 screen->SetContentModified( false ); // do not prompt the user for changes
168
170 m_frame->OpenProjectFiles( std::vector<wxString>( 1, schematic.GetFileName() ), KICTL_REVERT );
171
172 return 0;
173}
174
175
177{
179 return 0;
180}
181
182
184{
185 PICKED_ITEMS_LIST undoCmd;
187 ITEM_PICKER wrapper( m_frame->GetScreen(), undoItem, UNDO_REDO::PAGESETTINGS );
188
189 undoCmd.PushItem( wrapper );
190 undoCmd.SetDescription( _( "Page Settings" ) );
191 m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS, false, false );
192
196
197 if( dlg.ShowModal() == wxID_OK )
198 {
199 // Update text variables
203
204 m_frame->OnModify();
205 }
206 else
207 {
209 }
210
211 return 0;
212}
213
214
216{
217 SCH_SCREENS schematic( m_frame->Schematic().Root() );
218
219 if( schematic.HasNoFullyDefinedLibIds() )
220 RescueLegacyProject( true );
221 else
223
224 return 0;
225}
226
227
228bool SCH_EDITOR_CONTROL::RescueLegacyProject( bool aRunningOnDemand )
229{
232
233 return rescueProject( rescuer, aRunningOnDemand );
234}
235
236
238{
242
243 return rescueProject( rescuer, aRunningOnDemand );
244}
245
246
247bool SCH_EDITOR_CONTROL::rescueProject( RESCUER& aRescuer, bool aRunningOnDemand )
248{
249 if( !RESCUER::RescueProject( m_frame, aRescuer, aRunningOnDemand ) )
250 return false;
251
252 if( aRescuer.GetCandidateCount() )
253 {
254 KIWAY_PLAYER* viewer = m_frame->Kiway().Player( FRAME_SCH_VIEWER, false );
255
256 if( viewer )
257 static_cast<SYMBOL_VIEWER_FRAME*>( viewer )->ReCreateLibList();
258
259 if( aRunningOnDemand )
260 {
261 SCH_SCREENS schematic( m_frame->Schematic().Root() );
262
263 schematic.UpdateSymbolLinks();
265 }
266
268 m_frame->SyncView();
270 m_frame->OnModify();
271 }
272
273 return true;
274}
275
276
278{
279 DIALOG_SYMBOL_REMAP dlgRemap( m_frame );
280
281 dlgRemap.ShowQuasiModal();
282
283 m_frame->GetCanvas()->Refresh( true );
284
285 return 0;
286}
287
288
290{
292 return 0;
293}
294
295
297{
299
300 dlg.ShowModal();
301
302 // save project config if the prj config has changed:
303 if( dlg.PrjConfigChanged() )
304 m_frame->OnModify();
305
306 return 0;
307}
308
309
311{
312 m_frame->Close( false );
313 return 0;
314}
315
316
318{
319 doCrossProbeSchToPcb( aEvent, false );
320 return 0;
321}
322
323
325{
326 doCrossProbeSchToPcb( aEvent, true );
327 return 0;
328}
329
330
331void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce )
332{
333 // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
335 return;
336
338
339 EE_SELECTION& selection = aForce ? selTool->RequestSelection() : selTool->GetSelection();
340
341 m_frame->SendSelectItemsToPcb( selection.GetItemsSortedBySelectionOrder(), aForce );
342}
343
344
346{
347 bool savePowerSymbols = IsOK( m_frame,
348 _( "Include power symbols in schematic to the library?" ) );
349
350 bool createNew = aEvent.IsAction( &EE_ACTIONS::exportSymbolsToNewLibrary );
351
353 SCH_REFERENCE_LIST symbols;
354 sheets.GetSymbols( symbols, savePowerSymbols );
355
356 std::map<LIB_ID, LIB_SYMBOL*> libSymbols;
357 std::map<LIB_ID, std::vector<SCH_SYMBOL*>> symbolMap;
358
359 for( size_t i = 0; i < symbols.GetCount(); ++i )
360 {
361 SCH_SYMBOL* symbol = symbols[i].GetSymbol();
362 LIB_SYMBOL* libSymbol = symbol->GetLibSymbolRef().get();
363 LIB_ID id = libSymbol->GetLibId();
364
365 if( libSymbols.count( id ) )
366 {
367 wxASSERT_MSG( libSymbols[id]->Compare( *libSymbol, SCH_ITEM::COMPARE_FLAGS::ERC ) == 0,
368 "Two symbols have the same LIB_ID but are different!" );
369 }
370 else
371 {
372 libSymbols[id] = libSymbol;
373 }
374
375 symbolMap[id].emplace_back( symbol );
376 }
377
379
380 wxString targetLib;
381
382 if( createNew )
383 {
384 wxFileName fn;
386
387 if( !libTable ) // Cancelled by user
388 return 0;
389
392 ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() ),
394 {
395 return 0;
396 }
397
398 targetLib = fn.GetName();
399
400 if( libTable->HasLibrary( targetLib, false ) )
401 {
402 DisplayError( m_frame, wxString::Format( _( "Library '%s' already exists." ),
403 targetLib ) );
404 return 0;
405 }
406
407 // if the "new" library is in fact an existing library and the used asked for replacing
408 // it by the recreated lib, erase it:
409 if( fn.FileExists() )
410 wxRemoveFile( fn.GetFullPath() );
411
412 if( !mgr.CreateLibrary( fn.GetFullPath(), libTable ) )
413 {
414 DisplayError( m_frame, wxString::Format( _( "Could not add library '%s'." ),
415 targetLib ) );
416 return 0;
417 }
418 }
419 else
420 {
421 targetLib = m_frame->SelectLibraryFromList();
422 }
423
424 if( targetLib.IsEmpty() )
425 return 0;
426
427 bool map = IsOK( m_frame, _( "Update symbols in schematic to refer to new library?" ) );
428 bool append = false;
429
430 SYMBOL_LIB_TABLE_ROW* row = mgr.GetLibrary( targetLib );
431 SCH_IO_MGR::SCH_FILE_T type = SCH_IO_MGR::EnumFromStr( row->GetType() );
432 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( type ) );
433
434 wxFileName dest = row->GetFullURI( true );
435 dest.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS );
436
437 for( const std::pair<const LIB_ID, LIB_SYMBOL*>& it : libSymbols )
438 {
439 LIB_SYMBOL* origSym = it.second;
440 LIB_SYMBOL* newSym = origSym->Flatten().release();
441
442 try
443 {
444 pi->SaveSymbol( dest.GetFullPath(), newSym );
445 }
446 catch( const IO_ERROR& ioe )
447 {
448 wxString msg;
449 msg.Printf( _( "Error saving symbol %s to library '%s'." ),
450 newSym->GetName(), row->GetNickName() );
451 msg += wxS( "\n\n" ) + ioe.What();
452 wxLogWarning( msg );
453 return 0;
454 }
455
456 if( map )
457 {
458 LIB_ID id = it.first;
459 id.SetLibNickname( targetLib );
460
461 for( SCH_SYMBOL* symbol : symbolMap[it.first] )
462 {
463 m_frame->SaveCopyInUndoList( m_frame->GetScreen(), symbol, UNDO_REDO::CHANGED,
464 append, false );
465 symbol->SetLibId( id );
466 append = true;
467 }
468 }
469 }
470
471 // Save the modified symbol library table. We need to look this up by name in each table to find
472 // whether the new library is a global or project entity as the code above to choose the library
473 // returns a different type depending on whether a global or project library is chosen.
475 SYMBOL_LIB_TABLE* projectTable = nullptr;
476
477 if( !m_frame->Prj().IsNullProject() )
478 projectTable = PROJECT_SCH::SchSymbolLibTable( &m_frame->Prj() );
479
480 if( globalTable->FindRow( targetLib ) )
481 {
482 try
483 {
484 wxString globalTablePath = SYMBOL_LIB_TABLE::GetGlobalTableFileName();
485 globalTable->Save( globalTablePath );
486 }
487 catch( const IO_ERROR& ioe )
488 {
489 wxString msg;
490 msg.Printf( _( "Error saving global library table:\n\n%s" ), ioe.What() );
491 wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
492 }
493 }
494 else if( projectTable && projectTable->FindRow( targetLib ) )
495 {
496 try
497 {
498 wxString projectPath = m_frame->Prj().GetProjectPath();
499 wxFileName projectTableFn( projectPath, SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
500 projectTable->Save( projectTableFn.GetFullPath() );
501 }
502 catch( const IO_ERROR& ioe )
503 {
504 wxString msg;
505 msg.Printf( _( "Error saving project-specific library table:\n\n%s" ), ioe.What() );
506 wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
507 }
508 }
509
510 if( append )
511 {
512 std::set<SCH_SCREEN*> processedScreens;
513
514 for( SCH_SHEET_PATH& sheet : sheets )
515 {
516 SCH_SCREEN* screen = sheet.LastScreen();
517
518 if( processedScreens.find( ( screen ) ) == processedScreens.end() )
519 {
520 processedScreens.insert( screen );
521 screen->UpdateSymbolLinks();
522 }
523 }
524
525 m_frame->OnModify();
526 }
527
528 return 0;
529}
530
531
532#define HITTEST_THRESHOLD_PIXELS 5
533
535{
537 KIWAY_PLAYER* player = m_frame->Kiway().Player( FRAME_SIMULATOR, false );
538 SIMULATOR_FRAME* simFrame = static_cast<SIMULATOR_FRAME*>( player );
539
540 if( !simFrame ) // Defensive coding; shouldn't happen.
541 return 0;
542
543 if( wxWindow* blocking_win = simFrame->Kiway().GetBlockingDialog() )
544 blocking_win->Close( true );
545
546 // Deactivate other tools; particularly important if another PICKER is currently running
547 Activate();
548
549 picker->SetCursor( KICURSOR::VOLTAGE_PROBE );
550 picker->SetSnapping( false );
551
552 picker->SetClickHandler(
553 [this, simFrame]( const VECTOR2D& aPosition )
554 {
556 EDA_ITEM* item = selTool->GetNode( aPosition );
558
559 if( !item )
560 return false;
561
562 if( item->Type() == SCH_PIN_T )
563 {
564 try
565 {
566 SCH_PIN* pin = static_cast<SCH_PIN*>( item )->GetLibPin();
567 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item->GetParent() );
568
569 wxString msg;
570 WX_STRING_REPORTER reporter( &msg );
571 SIM_LIB_MGR mgr( &m_frame->Prj() );
572
573 SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol, reporter ).model;
574
575 if( reporter.HasMessage() )
576 THROW_IO_ERROR( msg );
577
578 SPICE_ITEM spiceItem;
579 spiceItem.refName = symbol->GetRef( &sheet ).ToStdString();
580 std::vector<std::string> currentNames =
581 model.SpiceGenerator().CurrentNames( spiceItem );
582
583 if( currentNames.size() == 0 )
584 {
585 return true;
586 }
587 else if( currentNames.size() == 1 )
588 {
589 simFrame->AddCurrentTrace( currentNames.at( 0 ) );
590 return true;
591 }
592
593 int modelPinIndex = model.FindModelPinIndex( pin->GetNumber().ToStdString() );
594
595 if( modelPinIndex != SIM_MODEL_PIN::NOT_CONNECTED )
596 {
597 wxString name = currentNames.at( modelPinIndex );
598 simFrame->AddCurrentTrace( name );
599 }
600 }
601 catch( const IO_ERROR& e )
602 {
604 }
605 }
606 else if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T } )
607 || item->IsType( { SCH_JUNCTION_T } ) )
608 {
609 if( SCH_CONNECTION* conn = static_cast<SCH_ITEM*>( item )->Connection() )
610 {
611 wxString spiceNet = UnescapeString( conn->Name() );
613
614 simFrame->AddVoltageTrace( wxString::Format( "V(%s)", spiceNet ) );
615 }
616 }
617
618 return true;
619 } );
620
621 picker->SetMotionHandler(
622 [this, picker]( const VECTOR2D& aPos )
623 {
624 EE_COLLECTOR collector;
625 collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
626 collector.Collect( m_frame->GetScreen(), { SCH_ITEM_LOCATE_WIRE_T,
627 SCH_PIN_T,
628 SCH_SHEET_PIN_T }, aPos );
629
631 selectionTool->GuessSelectionCandidates( collector, aPos );
632
633 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
634 SCH_LINE* wire = dynamic_cast<SCH_LINE*>( item );
635
636 const SCH_CONNECTION* conn = nullptr;
637
638 if( wire )
639 {
640 item = nullptr;
641 conn = wire->Connection();
642 }
643
644 if( item && item->Type() == SCH_PIN_T )
645 picker->SetCursor( KICURSOR::CURRENT_PROBE );
646 else
647 picker->SetCursor( KICURSOR::VOLTAGE_PROBE );
648
649 if( m_pickerItem != item )
650 {
651 if( m_pickerItem )
652 selectionTool->UnbrightenItem( m_pickerItem );
653
654 m_pickerItem = item;
655
656 if( m_pickerItem )
657 selectionTool->BrightenItem( m_pickerItem );
658 }
659
660 wxString connectionName = ( conn ) ? conn->Name() : wxString( wxS( "" ) );
661
662 if( m_frame->GetHighlightedConnection() != connectionName )
663 {
664 m_frame->SetHighlightedConnection( connectionName );
665
666 TOOL_EVENT dummyEvent;
667 UpdateNetHighlighting( dummyEvent );
668 }
669 } );
670
671 picker->SetFinalizeHandler(
672 [this]( const int& aFinalState )
673 {
674 if( m_pickerItem )
675 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
676
677 if( !m_frame->GetHighlightedConnection().IsEmpty() )
678 {
679 m_frame->SetHighlightedConnection( wxEmptyString );
680
681 TOOL_EVENT dummyEvent;
682 UpdateNetHighlighting( dummyEvent );
683 }
684
685 // Wake the selection tool after exiting to ensure the cursor gets updated
687 } );
688
690
691 return 0;
692}
693
694
696{
698
699 // Deactivate other tools; particularly important if another PICKER is currently running
700 Activate();
701
702 picker->SetCursor( KICURSOR::TUNE );
703 picker->SetSnapping( false );
704
705 picker->SetClickHandler(
706 [this]( const VECTOR2D& aPosition )
707 {
709 EDA_ITEM* item = nullptr;
710 selTool->SelectPoint( aPosition, { SCH_SYMBOL_T, SCH_FIELD_T }, &item );
711
712 if( !item )
713 return false;
714
715 if( item->Type() != SCH_SYMBOL_T )
716 {
717 item = item->GetParent();
718
719 if( item->Type() != SCH_SYMBOL_T )
720 return false;
721 }
722
723 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
724 SCH_SHEET_PATH sheetPath = symbol->Schematic()->CurrentSheet();
725 KIWAY_PLAYER* simFrame = m_frame->Kiway().Player( FRAME_SIMULATOR, false );
726
727 if( simFrame )
728 {
729 if( wxWindow* blocking_win = simFrame->Kiway().GetBlockingDialog() )
730 blocking_win->Close( true );
731
732 static_cast<SIMULATOR_FRAME*>( simFrame )->AddTuner( sheetPath, symbol );
733 }
734
735 // We do not really want to keep a symbol selected in schematic,
736 // so clear the current selection
737 selTool->ClearSelection();
738 return true;
739 } );
740
741 picker->SetMotionHandler(
742 [this]( const VECTOR2D& aPos )
743 {
744 EE_COLLECTOR collector;
745 collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
746 collector.Collect( m_frame->GetScreen(), { SCH_SYMBOL_T, SCH_FIELD_T }, aPos );
747
749 selectionTool->GuessSelectionCandidates( collector, aPos );
750
751 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
752
753 if( m_pickerItem != item )
754 {
755 if( m_pickerItem )
756 selectionTool->UnbrightenItem( m_pickerItem );
757
758 m_pickerItem = item;
759
760 if( m_pickerItem )
761 selectionTool->BrightenItem( m_pickerItem );
762 }
763 } );
764
765 picker->SetFinalizeHandler(
766 [this]( const int& aFinalState )
767 {
768 if( m_pickerItem )
769 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
770
771 // Wake the selection tool after exiting to ensure the cursor gets updated
772 // and deselect previous selection from simulator to avoid any issue
773 // ( avoid crash in some cases when the SimTune tool is deselected )
775 selectionTool->ClearSelection();
777 } );
778
780
781 return 0;
782}
783
784
785// A singleton reference for clearing the highlight
787
788
789static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
790{
791 SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetToolHolder() );
792 EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
793 SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
794 SCH_CONNECTION* conn = nullptr;
795 SCH_ITEM* item = nullptr;
796 bool retVal = true;
797
798 if( aPosition != CLEAR )
799 {
800 ERC_TESTER erc( &editFrame->Schematic() );
801
802 if( erc.TestDuplicateSheetNames( false ) > 0 )
803 {
804 wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
805 retVal = false;
806 }
807 else
808 {
809 item = static_cast<SCH_ITEM*>( selTool->GetNode( aPosition ) );
810 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
811
812 if( item )
813 {
814 if( item->IsConnectivityDirty() )
815 editFrame->RecalculateConnections( nullptr, NO_CLEANUP );
816
817 if( item->Type() == SCH_FIELD_T )
818 symbol = dynamic_cast<SCH_SYMBOL*>( item->GetParent() );
819
820 if( symbol && symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsPower() )
821 {
822 std::vector<SCH_PIN*> pins = symbol->GetPins();
823
824 if( pins.size() == 1 )
825 conn = pins[0]->Connection();
826 }
827 else
828 {
829 conn = item->Connection();
830 }
831 }
832 }
833 }
834
835 wxString connName = ( conn ) ? conn->Name() : wxString( wxS( "" ) );
836
837 if( !conn )
838 {
839 editFrame->SetStatusText( wxT( "" ) );
840 editFrame->SendCrossProbeClearHighlight();
841 editFrame->SetHighlightedConnection( wxEmptyString );
842 editorControl->SetHighlightBusMembers( false );
843 }
844 else
845 {
846 NET_NAVIGATOR_ITEM_DATA itemData( editFrame->GetCurrentSheet(), item );
847
848 if( connName != editFrame->GetHighlightedConnection() )
849 {
850 editorControl->SetHighlightBusMembers( false );
851 editFrame->SetCrossProbeConnection( conn );
852 editFrame->SetHighlightedConnection( connName, &itemData );
853 }
854 else
855 {
856 editorControl->SetHighlightBusMembers( !editorControl->GetHighlightBusMembers() );
857
858 if( item != editFrame->GetSelectedNetNavigatorItem() )
859 editFrame->SelectNetNavigatorItem( &itemData );
860 }
861 }
862
863 editFrame->UpdateNetHighlightStatus();
864
866 editorControl->UpdateNetHighlighting( dummy );
867
868 return retVal;
869}
870
871
873{
875 VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
876
877 highlightNet( m_toolMgr, cursorPos );
878
879 return 0;
880}
881
882
884{
886
887 return 0;
888}
889
890
892{
894 SCHEMATIC& schematic = m_frame->Schematic();
896
897 const SCH_CONNECTION* conn = nullptr;
898 VECTOR2D connPos;
899
900 for( EDA_ITEM* item : selectionTool->GetSelection() )
901 {
902 conn = static_cast<SCH_ITEM*>( item )->Connection();
903 connPos = item->GetPosition();
904
905 if( conn )
906 break;
907 }
908
909 if( !conn )
910 {
911 m_frame->ShowInfoBarError( _( "No net selected." ) );
912 return 0;
913 }
914
915 // Remove selection in favor of highlighting so the whole net is highlighted
916 selectionTool->ClearSelection();
917 highlightNet( m_toolMgr, connPos );
918
919 wxString netName = conn->Name();
920
921 if( conn->IsBus() )
922 {
923 wxString prefix;
924
925 if( NET_SETTINGS::ParseBusVector( netName, &prefix, nullptr ) )
926 {
927 netName = prefix + wxT( "*" );
928 }
929 else if( NET_SETTINGS::ParseBusGroup( netName, &prefix, nullptr ) )
930 {
931 netName = prefix + wxT( ".*" );
932 }
933 }
934 else if( !conn->Driver() || CONNECTION_SUBGRAPH::GetDriverPriority( conn->Driver() )
936 {
937 m_frame->ShowInfoBarError( _( "Net must be labeled to assign a netclass." ) );
939 return 0;
940 }
941
942 DIALOG_ASSIGN_NETCLASS dlg( m_frame, netName, schematic.GetNetClassAssignmentCandidates(),
943 [&]( const std::vector<wxString>& aNetNames )
944 {
945 for( SCH_ITEM* item : screen->Items() )
946 {
947 bool redraw = item->IsBrightened();
948 SCH_CONNECTION* itemConn = item->Connection();
949
950 if( itemConn && alg::contains( aNetNames, itemConn->Name() ) )
951 item->SetBrightened();
952 else
953 item->ClearBrightened();
954
955 redraw |= item->IsBrightened();
956
957 if( item->Type() == SCH_SYMBOL_T )
958 {
959 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
960
961 redraw |= symbol->HasBrightenedPins();
962
963 symbol->ClearBrightenedPins();
964
965 for( SCH_PIN* pin : symbol->GetPins() )
966 {
967 SCH_CONNECTION* pin_conn = pin->Connection();
968
969 if( pin_conn && alg::contains( aNetNames, pin_conn->Name() ) )
970 {
971 pin->SetBrightened();
972 redraw = true;
973 }
974 }
975 }
976 else if( item->Type() == SCH_SHEET_T )
977 {
978 for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
979 {
980 SCH_CONNECTION* pin_conn = pin->Connection();
981
982 redraw |= pin->IsBrightened();
983
984 if( pin_conn && alg::contains( aNetNames, pin_conn->Name() ) )
985 pin->SetBrightened();
986 else
987 pin->ClearBrightened();
988
989 redraw |= pin->IsBrightened();
990 }
991 }
992
993 if( redraw )
994 getView()->Update( item, KIGFX::VIEW_UPDATE_FLAGS::REPAINT );
995 }
996
998 } );
999
1000 if( dlg.ShowModal() )
1001 {
1002 getView()->UpdateAllItemsConditionally(
1003 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1004 {
1005 int flags = 0;
1006
1007 auto invalidateTextVars =
1008 [&flags]( EDA_TEXT* text )
1009 {
1010 if( text->HasTextVars() )
1011 {
1012 text->ClearRenderCache();
1013 text->ClearBoundingBoxCache();
1015 }
1016 };
1017
1018 // Netclass coloured items
1019 //
1020 if( dynamic_cast<SCH_LINE*>( aItem ) )
1021 flags |= KIGFX::REPAINT;
1022 else if( dynamic_cast<SCH_JUNCTION*>( aItem ) )
1023 flags |= KIGFX::REPAINT;
1024 else if( dynamic_cast<SCH_BUS_ENTRY_BASE*>( aItem ) )
1025 flags |= KIGFX::REPAINT;
1026
1027 // Items that might reference an item's netclass name
1028 //
1029 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
1030 {
1031 item->RunOnChildren(
1032 [&invalidateTextVars]( SCH_ITEM* aChild )
1033 {
1034 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
1035 invalidateTextVars( text );
1036 } );
1037
1038 if( flags & KIGFX::GEOMETRY )
1039 m_frame->GetScreen()->Update( item, false ); // Refresh RTree
1040 }
1041
1042 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1043 invalidateTextVars( text );
1044
1045 return flags;
1046 } );
1047 }
1048
1049 highlightNet( m_toolMgr, CLEAR );
1050 return 0;
1051}
1052
1053
1055{
1056 wxCHECK( m_frame, 0 );
1057
1058 const SCH_SHEET_PATH& sheetPath = m_frame->GetCurrentSheet();
1060 CONNECTION_GRAPH* connectionGraph = m_frame->Schematic().ConnectionGraph();
1061 wxString selectedName = m_frame->GetHighlightedConnection();
1062
1063 std::set<wxString> connNames;
1064 std::vector<EDA_ITEM*> itemsToRedraw;
1065
1066 wxCHECK( screen && connectionGraph, 0 );
1067
1068 if( !selectedName.IsEmpty() )
1069 {
1070 connNames.emplace( selectedName );
1071
1072 CONNECTION_SUBGRAPH* sg = connectionGraph->FindSubgraphByName( selectedName, sheetPath );
1073
1074 if( sg && m_highlightBusMembers )
1075 {
1076 for( const SCH_ITEM* item : sg->GetItems() )
1077 {
1078 wxCHECK2( item, continue );
1079
1080 if( SCH_CONNECTION* connection = item->Connection() )
1081 {
1082 for( const std::shared_ptr<SCH_CONNECTION>& member : connection->AllMembers() )
1083 {
1084 if( member )
1085 connNames.emplace( member->Name() );
1086 }
1087 }
1088 }
1089 }
1090 }
1091
1092 for( SCH_ITEM* item : screen->Items() )
1093 {
1094 wxCHECK2( item, continue );
1095
1096 if( !item->IsConnectable() )
1097 continue;
1098
1099 SCH_ITEM* redrawItem = nullptr;
1100
1101 if( item->Type() == SCH_SYMBOL_T )
1102 {
1103 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1104
1105 for( SCH_PIN* pin : symbol->GetPins() )
1106 {
1107 if( SCH_CONNECTION* pin_conn = pin->Connection() )
1108 {
1109 if( !pin->IsBrightened() && connNames.count( pin_conn->Name() ) )
1110 {
1111 pin->SetBrightened();
1112 redrawItem = symbol;
1113 }
1114 else if( pin->IsBrightened() && !connNames.count( pin_conn->Name() ) )
1115 {
1116 pin->ClearBrightened();
1117 redrawItem = symbol;
1118 }
1119 }
1120 }
1121
1122 if( symbol->IsPower() && symbol->GetPins().size() )
1123 {
1124 if( SCH_CONNECTION* pinConn = symbol->GetPins()[0]->Connection() )
1125 {
1126 std::vector<SCH_FIELD>& fields = symbol->GetFields();
1127
1128 for( int id : { REFERENCE_FIELD, VALUE_FIELD } )
1129 {
1130 if( !fields[id].IsVisible() )
1131 continue;
1132
1133 if( !fields[id].IsBrightened() && connNames.count( pinConn->Name() ) )
1134 {
1135 fields[id].SetBrightened();
1136 redrawItem = symbol;
1137 }
1138 else if( fields[id].IsBrightened() && !connNames.count( pinConn->Name() ) )
1139 {
1140 fields[id].ClearBrightened();
1141 redrawItem = symbol;
1142 }
1143 }
1144 }
1145 }
1146 }
1147 else if( item->Type() == SCH_SHEET_T )
1148 {
1149 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1150
1151 for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1152 {
1153 wxCHECK2( pin, continue );
1154
1155 if( SCH_CONNECTION* pin_conn = pin->Connection() )
1156 {
1157 if( !pin->IsBrightened() && connNames.count( pin_conn->Name() ) )
1158 {
1159 pin->SetBrightened();
1160 redrawItem = sheet;
1161 }
1162 else if( pin->IsBrightened() && !connNames.count( pin_conn->Name() ) )
1163 {
1164 pin->ClearBrightened();
1165 redrawItem = sheet;
1166 }
1167 }
1168 }
1169 }
1170 else
1171 {
1172 if( SCH_CONNECTION* itemConn = item->Connection() )
1173 {
1174 if( !item->IsBrightened() && connNames.count( itemConn->Name() ) )
1175 {
1176 item->SetBrightened();
1177 redrawItem = item;
1178 }
1179 else if( item->IsBrightened() && !connNames.count( itemConn->Name() ) )
1180 {
1181 item->ClearBrightened();
1182 redrawItem = item;
1183 }
1184 }
1185 }
1186
1187 if( redrawItem )
1188 itemsToRedraw.push_back( redrawItem );
1189 }
1190
1191 if( itemsToRedraw.size() )
1192 {
1193 // Be sure highlight change will be redrawn
1194 KIGFX::VIEW* view = getView();
1195
1196 for( EDA_ITEM* redrawItem : itemsToRedraw )
1198
1200 }
1201
1202 return 0;
1203}
1204
1205
1207{
1209
1210 // Deactivate other tools; particularly important if another PICKER is currently running
1211 Activate();
1212
1213 picker->SetCursor( KICURSOR::BULLSEYE );
1214 picker->SetSnapping( false );
1215
1216 picker->SetClickHandler(
1217 [this] ( const VECTOR2D& aPos )
1218 {
1219 return highlightNet( m_toolMgr, aPos );
1220 } );
1221
1223
1224 return 0;
1225}
1226
1227
1229{
1230 wxCHECK( m_frame, 0 );
1231
1232 if( m_frame->GetUndoCommandCount() <= 0 )
1233 return 0;
1234
1235 // Inform tools that undo command was issued
1237
1238 // Get the old list
1240
1241 wxCHECK( undo_list, 0 );
1242
1243 m_frame->PutDataInPreviousState( undo_list );
1244
1245 // Now push the old command to the RedoList
1246 undo_list->ReversePickersListOrder();
1247 m_frame->PushCommandToRedoList( undo_list );
1248
1249 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1250
1252 m_frame->OnModify();
1253
1254 return 0;
1255}
1256
1257
1259{
1260 wxCHECK( m_frame, 0 );
1261
1262 if( m_frame->GetRedoCommandCount() == 0 )
1263 return 0;
1264
1265 // Inform tools that undo command was issued
1267
1268 /* Get the old list */
1270
1271 wxCHECK( list, 0 );
1272
1273 /* Redo the command: */
1275
1276 /* Put the old list in UndoList */
1279
1280 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1281
1283 m_frame->OnModify();
1284
1285 return 0;
1286}
1287
1288
1289bool SCH_EDITOR_CONTROL::doCopy( bool aUseDuplicateClipboard )
1290{
1292 EE_SELECTION& selection = selTool->RequestSelection();
1293 SCHEMATIC& schematic = m_frame->Schematic();
1294
1295 if( selection.Empty() )
1296 return false;
1297
1298 if( aUseDuplicateClipboard )
1299 m_duplicateIsHoverSelection = selection.IsHover();
1300
1301 selection.SetScreen( m_frame->GetScreen() );
1303
1304 for( EDA_ITEM* item : selection )
1305 {
1306 if( item->Type() == SCH_SHEET_T )
1307 {
1308 SCH_SHEET* sheet = (SCH_SHEET*) item;
1309 m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
1310 }
1311 else if( item->Type() == SCH_FIELD_T && selection.IsHover() )
1312 {
1313 // Most of the time the user is trying to duplicate the parent symbol
1314 // and the field text is in it
1315 selection.Add( item->GetParent() );
1316 }
1317 else if( item->Type() == SCH_MARKER_T )
1318 {
1319 // Don't let the markers be copied
1320 selection.Remove( item );
1321 }
1322 }
1323
1324 STRING_FORMATTER formatter;
1325 SCH_IO_KICAD_SEXPR plugin;
1327
1328 plugin.Format( &selection, &selPath, schematic, &formatter, true );
1329
1330 if( selection.IsHover() )
1332
1333 if( aUseDuplicateClipboard )
1334 {
1335 m_duplicateClipboard = formatter.GetString();
1336 return true;
1337 }
1338
1339 return m_toolMgr->SaveClipboard( formatter.GetString() );
1340}
1341
1342
1343bool SCH_EDITOR_CONTROL::searchSupplementaryClipboard( const wxString& aSheetFilename,
1344 SCH_SCREEN** aScreen )
1345{
1346 if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
1347 {
1348 *aScreen = m_supplementaryClipboard[ aSheetFilename ];
1349 return true;
1350 }
1351
1352 return false;
1353}
1354
1355
1357{
1358 doCopy( true ); // Use the local clipboard
1359 Paste( aEvent );
1360
1361 return 0;
1362}
1363
1364
1366{
1367 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1368
1369 if( textEntry )
1370 {
1371 textEntry->Cut();
1372 return 0;
1373 }
1374
1375 if( doCopy() )
1377
1378 return 0;
1379}
1380
1381
1383{
1384 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1385
1386 if( textEntry )
1387 {
1388 textEntry->Copy();
1389 return 0;
1390 }
1391
1392 doCopy();
1393
1394 return 0;
1395}
1396
1397
1399 const SCH_SHEET_PATH& aPastePath,
1400 const KIID_PATH& aClipPath,
1401 bool aForceKeepAnnotations )
1402{
1403 wxCHECK( m_frame && aSymbol, /* void */ );
1404
1405 SCH_SYMBOL_INSTANCE newInstance;
1406 bool instanceFound = false;
1407 KIID_PATH pasteLookupPath = aClipPath;
1408
1409 m_pastedSymbols.insert( aSymbol );
1410
1411 for( const SCH_SYMBOL_INSTANCE& tmp : aSymbol->GetInstances() )
1412 {
1413 if( ( tmp.m_Path.empty() && aClipPath.empty() )
1414 || ( !aClipPath.empty() && tmp.m_Path.EndsWith( aClipPath ) ) )
1415 {
1416 newInstance = tmp;
1417 instanceFound = true;
1418
1419 wxLogTrace( traceSchPaste,
1420 wxS( "Pasting found symbol instance with reference %s, unit %d:"
1421 "\n\tClipboard path: %s\n\tSymbol UUID: %s." ),
1422 tmp.m_Reference, tmp.m_Unit,
1423 aClipPath.AsString(), aSymbol->m_Uuid.AsString() );
1424
1425 break;
1426 }
1427 }
1428
1429 // The pasted symbol look up paths include the symbol UUID.
1430 pasteLookupPath.push_back( aSymbol->m_Uuid );
1431
1432 if( !instanceFound )
1433 {
1434 wxLogTrace( traceSchPaste,
1435 wxS( "Clipboard symbol instance **not** found:\n\tClipboard path: %s\n\t"
1436 "Symbol UUID: %s." ),
1437 aClipPath.AsString(), aSymbol->m_Uuid.AsString() );
1438
1439 // Some legacy versions saved value fields escaped. While we still do in the symbol
1440 // editor, we don't anymore in the schematic, so be sure to unescape them.
1441 SCH_FIELD* valueField = aSymbol->GetField( VALUE_FIELD );
1442 valueField->SetText( UnescapeString( valueField->GetText() ) );
1443
1444 // Pasted from notepad or an older instance of eeschema. Use the values in the fields
1445 // instead.
1446 newInstance.m_Reference = aSymbol->GetField( REFERENCE_FIELD )->GetText();
1447 newInstance.m_Unit = aSymbol->GetUnit();
1448 }
1449
1450 newInstance.m_Path = aPastePath.Path();
1451 newInstance.m_ProjectName = m_frame->Prj().GetProjectName();
1452
1453 aSymbol->AddHierarchicalReference( newInstance );
1454
1455 if( !aForceKeepAnnotations )
1456 aSymbol->ClearAnnotation( &aPastePath, false );
1457
1458 // We might clear annotations but always leave the original unit number from the paste.
1459 aSymbol->SetUnit( newInstance.m_Unit );
1460}
1461
1462
1464 const SCH_SHEET_PATH& aPastePath,
1465 const KIID_PATH& aClipPath,
1466 bool aForceKeepAnnotations,
1467 SCH_SHEET_LIST* aPastedSheets,
1468 std::map<SCH_SHEET_PATH,
1469 SCH_REFERENCE_LIST>& aPastedSymbols )
1470{
1471 wxCHECK( aSheet && aPastedSheets, aPastePath );
1472
1473 SCH_SHEET_PATH sheetPath = aPastePath;
1474 sheetPath.push_back( aSheet );
1475
1476 aPastedSheets->push_back( sheetPath );
1477
1478 if( aSheet->GetScreen() == nullptr )
1479 return sheetPath; // We can only really set the page number but not load any items
1480
1481 for( SCH_ITEM* item : aSheet->GetScreen()->Items() )
1482 {
1483 if( item->IsConnectable() )
1484 item->SetConnectivityDirty();
1485
1486 if( item->Type() == SCH_SYMBOL_T )
1487 {
1488 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1489
1490 wxCHECK2( symbol, continue );
1491
1492 // Only do this once if the symbol is shared across multiple sheets.
1493 if( !m_pastedSymbols.count( symbol ) )
1494 {
1495 for( SCH_PIN* pin : symbol->GetPins() )
1496 {
1497 const_cast<KIID&>( pin->m_Uuid ) = KIID();
1498 pin->SetConnectivityDirty();
1499 }
1500 }
1501
1502 updatePastedSymbol( symbol, sheetPath, aClipPath, aForceKeepAnnotations );
1503 }
1504 else if( item->Type() == SCH_SHEET_T )
1505 {
1506 SCH_SHEET* subsheet = static_cast<SCH_SHEET*>( item );
1507
1508 wxCHECK2( subsheet, continue );
1509
1510 // Make sure pins get a new UUID and set the dirty connectivity flag.
1511 if( !aPastedSheets->ContainsSheet( subsheet ) )
1512 {
1513 for( SCH_SHEET_PIN* pin : subsheet->GetPins() )
1514 {
1515 const_cast<KIID&>( pin->m_Uuid ) = KIID();
1516 pin->SetConnectivityDirty();
1517 }
1518 }
1519
1520 KIID_PATH newClipPath = aClipPath;
1521 newClipPath.push_back( subsheet->m_Uuid );
1522
1523 updatePastedSheet( subsheet, sheetPath, newClipPath, aForceKeepAnnotations,
1524 aPastedSheets, aPastedSymbols );
1525 }
1526 }
1527
1528 sheetPath.GetSymbols( aPastedSymbols[aPastePath] );
1529
1530 return sheetPath;
1531}
1532
1533
1535{
1536 wxCHECK( aScreen, /* void */ );
1537
1538 for( const SCH_ITEM* item : aScreen->Items() )
1539 {
1540 if( item->Type() == SCH_SYMBOL_T )
1541 {
1542 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( item );
1543
1544 wxCHECK2( symbol, continue );
1545
1546 for( const SCH_SYMBOL_INSTANCE& symbolInstance : symbol->GetInstances() )
1547 {
1548 KIID_PATH pathWithSymbol = symbolInstance.m_Path;
1549
1550 pathWithSymbol.push_back( symbol->m_Uuid );
1551
1552 m_clipboardSymbolInstances[pathWithSymbol] = symbolInstance;
1553 }
1554 }
1555 }
1556}
1557
1558
1560{
1561 wxCHECK( m_frame, /* void */ );
1562
1563 for( SCH_SYMBOL* symbol : m_pastedSymbols )
1564 {
1565 wxCHECK2( symbol, continue );
1566
1567 std::vector<KIID_PATH> instancePathsToRemove;
1568
1569 for( const SCH_SYMBOL_INSTANCE& instance : symbol->GetInstances() )
1570 {
1571 if( ( instance.m_ProjectName != m_frame->Prj().GetProjectName() )
1572 || instance.m_Path.empty() )
1573 instancePathsToRemove.emplace_back( instance.m_Path );
1574 }
1575
1576 for( const KIID_PATH& path : instancePathsToRemove )
1577 symbol->RemoveInstance( path );
1578 }
1579}
1580
1581
1583{
1584 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1585
1586 if( textEntry )
1587 {
1588 textEntry->Paste();
1589 return 0;
1590 }
1591
1593 std::string content;
1594 VECTOR2I eventPos;
1595
1596 if( aEvent.IsAction( &ACTIONS::duplicate ) )
1597 content = m_duplicateClipboard;
1598 else
1599 content = m_toolMgr->GetClipboardUTF8();
1600
1601 if( content.empty() )
1602 return 0;
1603
1604 if( aEvent.IsAction( &ACTIONS::duplicate ) )
1605 eventPos = getViewControls()->GetCursorPosition( false );
1606
1607 STRING_LINE_READER reader( content, "Clipboard" );
1608 SCH_IO_KICAD_SEXPR plugin;
1609
1610 SCH_SHEET tempSheet;
1611 SCH_SCREEN* tempScreen = new SCH_SCREEN( &m_frame->Schematic() );
1612
1614 int annotateStartNum = m_frame->Schematic().Settings().m_AnnotateStartNum;
1615
1616 // Screen object on heap is owned by the sheet.
1617 tempSheet.SetScreen( tempScreen );
1618
1619 try
1620 {
1621 plugin.LoadContent( reader, &tempSheet );
1622 }
1623 catch( IO_ERROR& )
1624 {
1625 // If it wasn't content, then paste as text object.
1626 SCH_TEXT* text_item = new SCH_TEXT( VECTOR2I( 0, 0 ), content );
1627 tempScreen->Append( text_item );
1628 }
1629
1630 m_pastedSymbols.clear();
1632
1633 // Save pasted symbol instances in case the user chooses to keep existing symbol annotation.
1634 setPastedSymbolInstances( tempScreen );
1635
1636 tempScreen->MigrateSimModels();
1637
1638 PASTE_MODE pasteMode = annotate.automatic ? PASTE_MODE::RESPECT_OPTIONS
1639 : PASTE_MODE::REMOVE_ANNOTATIONS;
1640
1641 if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1642 {
1643 DIALOG_PASTE_SPECIAL dlg( m_frame, &pasteMode );
1644
1645 if( dlg.ShowModal() == wxID_CANCEL )
1646 return 0;
1647 }
1648
1649 bool forceKeepAnnotations = pasteMode != PASTE_MODE::REMOVE_ANNOTATIONS;
1650
1651 // SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
1652 // else. Pull them back out to start with.
1653 SCH_COMMIT commit( m_toolMgr );
1654 EDA_ITEMS loadedItems;
1655 std::vector<SCH_ITEM*> sortedLoadedItems;
1656 bool sheetsPasted = false;
1658 SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
1659 wxFileName destFn = pasteRoot.Last()->GetFileName();
1660
1661 if( destFn.IsRelative() )
1662 destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1663
1664 // List of paths in the hierarchy that refer to the destination sheet of the paste
1665 SCH_SHEET_LIST sheetPathsForScreen = hierarchy.FindAllSheetsForScreen( pasteRoot.LastScreen() );
1666 sheetPathsForScreen.SortByPageNumbers();
1667
1668 // Build a list of screens from the current design (to avoid loading sheets that already exist)
1669 std::map<wxString, SCH_SCREEN*> loadedScreens;
1670
1671 for( const SCH_SHEET_PATH& item : hierarchy )
1672 {
1673 if( item.LastScreen() )
1674 loadedScreens[item.Last()->GetFileName()] = item.LastScreen();
1675 }
1676
1677 // Build symbol list for reannotation of duplicates
1678 SCH_REFERENCE_LIST existingRefs;
1679 hierarchy.GetSymbols( existingRefs );
1680 existingRefs.SortByReferenceOnly();
1681
1682 // Build UUID map for fetching last-resolved-properties
1683 std::map<KIID, EDA_ITEM*> itemMap;
1684 hierarchy.FillItemMap( itemMap );
1685
1686 // Keep track of pasted sheets and symbols for the different paths to the hierarchy.
1687 std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> pastedSymbols;
1688 std::map<SCH_SHEET_PATH, SCH_SHEET_LIST> pastedSheets;
1689
1690 for( SCH_ITEM* item : tempScreen->Items() )
1691 {
1692 if( item->Type() == SCH_SHEET_T )
1693 sortedLoadedItems.push_back( item );
1694 else
1695 loadedItems.push_back( item );
1696 }
1697
1698 sort( sortedLoadedItems.begin(), sortedLoadedItems.end(),
1699 []( SCH_ITEM* firstItem, SCH_ITEM* secondItem )
1700 {
1701 SCH_SHEET* firstSheet = static_cast<SCH_SHEET*>( firstItem );
1702 SCH_SHEET* secondSheet = static_cast<SCH_SHEET*>( secondItem );
1703 return StrNumCmp( firstSheet->GetName(), secondSheet->GetName(), false ) < 0;
1704 });
1705
1706
1707 for( SCH_ITEM* item : sortedLoadedItems )
1708 {
1709 loadedItems.push_back( item );
1710
1711 if( item->Type() == SCH_SHEET_T )
1712 {
1713 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1714 SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1715 wxString baseName = nameField.GetText();
1716 wxFileName srcFn = sheet->GetFileName();
1717
1718 if( srcFn.IsRelative() )
1719 srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1720
1721 SCH_SHEET_LIST sheetHierarchy( sheet );
1722
1723 if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1724 {
1725 auto msg = wxString::Format( _( "The pasted sheet '%s'\n"
1726 "was dropped because the destination already has "
1727 "the sheet or one of its subsheets as a parent." ),
1728 sheet->GetFileName() );
1729 DisplayError( m_frame, msg );
1730 loadedItems.pop_back();
1731 }
1732 }
1733 }
1734
1735 // Remove the references from our temporary screen to prevent freeing on the DTOR
1736 tempScreen->Clear( false );
1737
1738 for( EDA_ITEM* item : loadedItems )
1739 {
1740 KIID_PATH clipPath( wxT( "/" ) ); // clipboard is at root
1741
1742 SCH_ITEM* schItem = static_cast<SCH_ITEM*>( item );
1743
1744 wxCHECK2( schItem, continue );
1745
1746 if( schItem->IsConnectable() )
1747 schItem->SetConnectivityDirty();
1748
1749 if( item->Type() == SCH_SYMBOL_T )
1750 {
1751 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1752
1753 // The library symbol gets set from the cached library symbols in the current
1754 // schematic not the symbol libraries. The cached library symbol may have
1755 // changed from the original library symbol which would cause the copy to
1756 // be incorrect.
1757 SCH_SCREEN* currentScreen = m_frame->GetScreen();
1758
1759 wxCHECK2( currentScreen, continue );
1760
1761 auto it = currentScreen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1762 auto end = currentScreen->GetLibSymbols().end();
1763
1764 if( it == end )
1765 {
1766 // If can't find library definition in the design, use the pasted library
1767 it = tempScreen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1768 end = tempScreen->GetLibSymbols().end();
1769 }
1770
1771 LIB_SYMBOL* libSymbol = nullptr;
1772
1773 if( it != end )
1774 {
1775 libSymbol = new LIB_SYMBOL( *it->second );
1776 symbol->SetLibSymbol( libSymbol );
1777 }
1778
1779 for( SCH_SHEET_PATH& sheetPath : sheetPathsForScreen )
1780 updatePastedSymbol( symbol, sheetPath, clipPath, forceKeepAnnotations );
1781
1782 // Assign a new KIID
1783 const_cast<KIID&>( item->m_Uuid ) = KIID();
1784
1785 // Make sure pins get a new UUID
1786 for( SCH_PIN* pin : symbol->GetPins() )
1787 {
1788 const_cast<KIID&>( pin->m_Uuid ) = KIID();
1789 pin->SetConnectivityDirty();
1790 }
1791
1792 for( SCH_SHEET_PATH& sheetPath : sheetPathsForScreen )
1793 {
1794 // Ignore symbols from a non-existant library.
1795 if( libSymbol )
1796 {
1797 SCH_REFERENCE schReference( symbol, sheetPath );
1798 schReference.SetSheetNumber( sheetPath.GetVirtualPageNumber() );
1799 pastedSymbols[sheetPath].AddItem( schReference );
1800 }
1801 }
1802 }
1803 else if( item->Type() == SCH_SHEET_T )
1804 {
1805 SCH_SHEET* sheet = (SCH_SHEET*) item;
1806 SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1807 wxString baseName = nameField.GetText();
1808 wxString candidateName = baseName;
1809 wxString number;
1810
1811 while( !baseName.IsEmpty() && wxIsdigit( baseName.Last() ) )
1812 {
1813 number = baseName.Last() + number;
1814 baseName.RemoveLast();
1815 }
1816
1817 // Update hierarchy to include any other sheets we already added, avoiding
1818 // duplicate sheet names
1820
1821 //@todo: it might be better to just iterate through the sheet names
1822 // in this screen instead of the whole hierarchy.
1823 int uniquifier = std::max( 0, wxAtoi( number ) ) + 1;
1824
1825 while( hierarchy.NameExists( candidateName ) )
1826 candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
1827
1828 nameField.SetText( candidateName );
1829
1830 wxFileName fn = sheet->GetFileName();
1831 SCH_SCREEN* existingScreen = nullptr;
1832
1833 sheet->SetParent( pasteRoot.Last() );
1834 sheet->SetScreen( nullptr );
1835
1836 if( !fn.IsAbsolute() )
1837 {
1838 wxFileName currentSheetFileName = pasteRoot.LastScreen()->GetFileName();
1839 fn.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS,
1840 currentSheetFileName.GetPath() );
1841 }
1842
1843 // Try to find the screen for the pasted sheet by several means
1844 if( !m_frame->Schematic().Root().SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ),
1845 &existingScreen ) )
1846 {
1847 if( loadedScreens.count( sheet->GetFileName() ) > 0 )
1848 existingScreen = loadedScreens.at( sheet->GetFileName() );
1849 else
1850 searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1851 }
1852
1853 if( existingScreen )
1854 {
1855 sheet->SetScreen( existingScreen );
1856 }
1857 else
1858 {
1859 if( !m_frame->LoadSheetFromFile( sheet, &pasteRoot, fn.GetFullPath() ) )
1860 m_frame->InitSheet( sheet, sheet->GetFileName() );
1861 }
1862
1863 // Save the symbol instances in case the user chooses to keep the existing
1864 // symbol annotation.
1866 sheetsPasted = true;
1867
1868 // Push it to the clipboard path while it still has its old KIID
1869 clipPath.push_back( sheet->m_Uuid );
1870
1871 // Assign a new KIID to the pasted sheet
1872 const_cast<KIID&>( sheet->m_Uuid ) = KIID();
1873
1874 // Make sure pins get a new UUID
1875 for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1876 {
1877 const_cast<KIID&>( pin->m_Uuid ) = KIID();
1878 pin->SetConnectivityDirty();
1879 }
1880
1881 // Once we have our new KIID we can update all pasted instances. This will either
1882 // reset the annotations or copy "kept" annotations from the supplementary clipboard.
1883 for( SCH_SHEET_PATH& sheetPath : sheetPathsForScreen )
1884 {
1885 SCH_SHEET_PATH subPath = updatePastedSheet( sheet, sheetPath, clipPath,
1886 ( forceKeepAnnotations && annotate.automatic ),
1887 &pastedSheets[sheetPath],
1888 pastedSymbols );
1889 }
1890 }
1891 else
1892 {
1893 SCH_ITEM* srcItem = dynamic_cast<SCH_ITEM*>( itemMap[ item->m_Uuid ] );
1894 SCH_ITEM* destItem = dynamic_cast<SCH_ITEM*>( item );
1895
1896 // Everything gets a new KIID
1897 const_cast<KIID&>( item->m_Uuid ) = KIID();
1898
1899 if( srcItem && destItem )
1900 {
1901 destItem->SetConnectivityDirty( true );
1902 destItem->SetLastResolvedState( srcItem );
1903 }
1904 }
1905
1906 // Lines need both ends selected for a move after paste so the whole line moves.
1907 if( item->Type() == SCH_LINE_T )
1908 item->SetFlags( STARTPOINT | ENDPOINT );
1909
1910 item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );
1911
1912 if( !m_frame->GetScreen()->CheckIfOnDrawList( (SCH_ITEM*) item ) ) // don't want a loop!
1913 m_frame->AddToScreen( item, m_frame->GetScreen() );
1914
1915 commit.Added( (SCH_ITEM*) item, m_frame->GetScreen() );
1916
1917 // Start out hidden so the pasted items aren't "ghosted" in their original location
1918 // before being moved to the current location.
1919 getView()->Hide( item, true );
1920 }
1921
1922 if( sheetsPasted )
1923 {
1924 // Update page numbers: Find next free numeric page number
1925 for( SCH_SHEET_PATH& sheetPath : sheetPathsForScreen )
1926 {
1927 for( SCH_SHEET_PATH& pastedSheet : pastedSheets[sheetPath] )
1928 {
1929 int page = 1;
1930 wxString pageNum = wxString::Format( "%d", page );
1931
1932 while( hierarchy.PageNumberExists( pageNum ) )
1933 pageNum = wxString::Format( "%d", ++page );
1934
1935 SCH_SHEET_INSTANCE sheetInstance;
1936
1937 sheetInstance.m_Path = pastedSheet.Path();
1938
1939 // Don't include the actual sheet in the instance path.
1940 sheetInstance.m_Path.pop_back();
1941 sheetInstance.m_PageNumber = pageNum;
1942 sheetInstance.m_ProjectName = m_frame->Prj().GetProjectName();
1943
1944 SCH_SHEET* sheet = pastedSheet.Last();
1945
1946 wxCHECK2( sheet, continue );
1947
1948 sheet->AddInstance( sheetInstance );
1949 hierarchy.push_back( pastedSheet );
1950
1951 // Remove all pasted sheet instance data that is not part of the current project.
1952 std::vector<KIID_PATH> instancesToRemove;
1953
1954 for( const SCH_SHEET_INSTANCE& instance : sheet->GetInstances() )
1955 {
1956 if( !hierarchy.HasPath( instance.m_Path ) )
1957 instancesToRemove.push_back( instance.m_Path );
1958 }
1959
1960 for( const KIID_PATH& instancePath : instancesToRemove )
1961 sheet->RemoveInstance( instancePath );
1962 }
1963 }
1964
1966
1967 // Get a version with correct sheet numbers since we've pasted sheets,
1968 // we'll need this when annotating next
1970 }
1971
1972 std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> annotatedSymbols;
1973
1974 // Update the list of symbol instances that satisfy the annotation criteria.
1975 for( const SCH_SHEET_PATH& sheetPath : sheetPathsForScreen )
1976 {
1977 for( size_t i = 0; i < pastedSymbols[sheetPath].GetCount(); i++ )
1978 {
1979 if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS
1980 || pasteMode == PASTE_MODE::RESPECT_OPTIONS
1981 || pastedSymbols[sheetPath][i].AlwaysAnnotate() )
1982 {
1983 annotatedSymbols[sheetPath].AddItem( pastedSymbols[sheetPath][i] );
1984 }
1985 }
1986
1987 for( const SCH_SHEET_PATH& pastedSheetPath : pastedSheets[sheetPath] )
1988 {
1989 for( size_t i = 0; i < pastedSymbols[pastedSheetPath].GetCount(); i++ )
1990 {
1991 if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS
1992 || pasteMode == PASTE_MODE::RESPECT_OPTIONS
1993 || pastedSymbols[pastedSheetPath][i].AlwaysAnnotate() )
1994 {
1995 annotatedSymbols[pastedSheetPath].AddItem( pastedSymbols[pastedSheetPath][i] );
1996 }
1997 }
1998 }
1999 }
2000
2001 if( !annotatedSymbols.empty() )
2002 {
2003 for( SCH_SHEET_PATH& path : sheetPathsForScreen )
2004 {
2005 annotatedSymbols[path].SortByReferenceOnly();
2006
2007 if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS )
2008 {
2009 annotatedSymbols[path].ReannotateDuplicates( existingRefs );
2010 }
2011 else
2012 {
2013 annotatedSymbols[path].ReannotateByOptions( (ANNOTATE_ORDER_T) annotate.sort_order,
2014 (ANNOTATE_ALGO_T) annotate.method,
2015 annotateStartNum, existingRefs, false,
2016 &hierarchy );
2017 }
2018
2019 annotatedSymbols[path].UpdateAnnotation();
2020
2021 // Update existing refs for next iteration
2022 for( size_t i = 0; i < annotatedSymbols[path].GetCount(); i++ )
2023 existingRefs.AddItem( annotatedSymbols[path][i] );
2024
2025 for( const SCH_SHEET_PATH& pastedSheetPath : pastedSheets[path] )
2026 {
2027 annotatedSymbols[pastedSheetPath].SortByReferenceOnly();
2028
2029 if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS )
2030 {
2031 annotatedSymbols[pastedSheetPath].ReannotateDuplicates( existingRefs );
2032 }
2033 else
2034 {
2035 annotatedSymbols[pastedSheetPath].ReannotateByOptions( (ANNOTATE_ORDER_T) annotate.sort_order,
2036 (ANNOTATE_ALGO_T) annotate.method,
2037 annotateStartNum, existingRefs,
2038 false,
2039 &hierarchy );
2040 }
2041
2042 annotatedSymbols[pastedSheetPath].UpdateAnnotation();
2043
2044 // Update existing refs for next iteration
2045 for( size_t i = 0; i < annotatedSymbols[pastedSheetPath].GetCount(); i++ )
2046 existingRefs.AddItem( annotatedSymbols[pastedSheetPath][i] );
2047 }
2048 }
2049 }
2050
2052
2053 // The copy operation creates instance paths that are not valid for the current project or
2054 // saved as part of another project. Prune them now so they do not accumulate in the saved
2055 // schematic file.
2057
2059 SCH_SCREENS allScreens( m_frame->Schematic().Root() );
2060
2061 allScreens.PruneOrphanedSymbolInstances( m_frame->Prj().GetProjectName(), sheets );
2062 allScreens.PruneOrphanedSheetInstances( m_frame->Prj().GetProjectName(), sheets );
2063
2064 // Now clear the previous selection, select the pasted items, and fire up the "move" tool.
2067
2068 EE_SELECTION& selection = selTool->GetSelection();
2069
2070 if( !selection.Empty() )
2071 {
2072 if( aEvent.IsAction( &ACTIONS::duplicate ) )
2073 {
2074 int closest_dist = INT_MAX;
2075
2076 auto processPt =
2077 [&]( const VECTOR2I& pt )
2078 {
2079 int dist = ( eventPos - pt ).EuclideanNorm();
2080
2081 if( dist < closest_dist )
2082 {
2083 selection.SetReferencePoint( pt );
2084 closest_dist = dist;
2085 }
2086 };
2087
2088 // Prefer connection points (which should remain on grid)
2089 for( EDA_ITEM* item : selection.Items() )
2090 {
2091 SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
2092 SCH_PIN* pin = dynamic_cast<SCH_PIN*>( item );
2093
2094 if( sch_item && sch_item->IsConnectable() )
2095 {
2096 for( const VECTOR2I& pt : sch_item->GetConnectionPoints() )
2097 processPt( pt );
2098 }
2099 else if( pin )
2100 {
2101 processPt( pin->GetPosition() );
2102 }
2103 }
2104
2105 // Only process other points if we didn't find any connection points
2106 if( closest_dist == INT_MAX )
2107 {
2108 for( EDA_ITEM* item : selection.Items() )
2109 {
2110 switch( item->Type() )
2111 {
2112 case SCH_LINE_T:
2113 processPt( static_cast<SCH_LINE*>( item )->GetStartPoint() );
2114 processPt( static_cast<SCH_LINE*>( item )->GetEndPoint() );
2115 break;
2116
2117 case SCH_SHAPE_T:
2118 {
2119 SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( item );
2120
2121 switch( shape->GetShape() )
2122 {
2123 case SHAPE_T::RECTANGLE:
2124 for( const VECTOR2I& pt : shape->GetRectCorners() )
2125 processPt( pt );
2126
2127 break;
2128
2129 case SHAPE_T::CIRCLE:
2130 processPt( shape->GetCenter() );
2131 break;
2132
2133 case SHAPE_T::POLY:
2134 for( int ii = 0; ii < shape->GetPolyShape().TotalVertices(); ++ii )
2135 processPt( shape->GetPolyShape().CVertex( ii ) );
2136
2137 break;
2138
2139 default:
2140 processPt( shape->GetStart() );
2141 processPt( shape->GetEnd() );
2142 break;
2143 }
2144
2145 break;
2146 }
2147
2148 default:
2149 processPt( item->GetPosition() );
2150 break;
2151 }
2152 }
2153 }
2154
2155 selection.SetIsHover( m_duplicateIsHoverSelection );
2156 }
2157 else
2158 {
2159 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetTopLeftItem() );
2160
2161 selection.SetReferencePoint( item->GetPosition() );
2162 }
2163
2165 {
2166 // Pushing the commit will update the connectivity.
2167 commit.Push( _( "Paste" ) );
2168
2169 if( sheetsPasted )
2171 // UpdateHierarchyNavigator() will call RefreshNetNavigator()
2172 else
2174 }
2175 else
2176 {
2177 commit.Revert();
2178 }
2179 }
2180
2181 return 0;
2182}
2183
2184
2186{
2188 EE_SELECTION& selection = selTool->RequestSelection( { SCH_SYMBOL_T } );
2189 SCH_SYMBOL* symbol = nullptr;
2190 SYMBOL_EDIT_FRAME* symbolEditor;
2191
2192 if( selection.GetSize() >= 1 )
2193 symbol = (SCH_SYMBOL*) selection.Front();
2194
2195 if( selection.IsHover() )
2197
2198 if( !symbol )
2199 {
2200 // Giant hack: by default we assign Edit Table to the same hotkey, so give the table
2201 // tool a chance to handle it if we can't.
2203 tableTool->EditTable( aEvent );
2204
2205 return 0;
2206 }
2207
2208 if( symbol->GetEditFlags() != 0 )
2209 return 0;
2210
2211 if( symbol->IsMissingLibSymbol() )
2212 {
2213 m_frame->ShowInfoBarError( _( "Symbols with broken library symbol links cannot "
2214 "be edited." ) );
2215 return 0;
2216 }
2217
2219 symbolEditor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
2220
2221 if( symbolEditor )
2222 {
2223 if( wxWindow* blocking_win = symbolEditor->Kiway().GetBlockingDialog() )
2224 blocking_win->Close( true );
2225
2226 if( aEvent.IsAction( &EE_ACTIONS::editWithLibEdit ) )
2227 {
2228 symbolEditor->LoadSymbolFromSchematic( symbol );
2229 }
2231 {
2232 symbolEditor->LoadSymbol( symbol->GetLibId(), symbol->GetUnit(),
2233 symbol->GetBodyStyle() );
2234
2235 if( !symbolEditor->IsLibraryTreeShown() )
2236 symbolEditor->ToggleLibraryTree();
2237 }
2238 }
2239
2240 return 0;
2241}
2242
2243
2245{
2246 wxCommandEvent dummy;
2248 return 0;
2249}
2250
2251
2253{
2254 wxCommandEvent dummy;
2256 return 0;
2257}
2258
2259
2261{
2263
2264 wxCHECK( dlg, 0 );
2265
2266 // Needed at least on Windows. Raise() is not enough
2267 dlg->Show( true );
2268
2269 // Bring it to the top if already open. Dual monitor users need this.
2270 dlg->Raise();
2271
2272 dlg->ShowEditTab();
2273
2274 return 0;
2275}
2276
2277
2279{
2282
2283 return 0;
2284}
2285
2286
2288{
2289 wxCommandEvent dummy;
2291 return 0;
2292}
2293
2294
2296{
2297 wxCommandEvent dummy;
2299 return 0;
2300}
2301
2302
2304{
2306 dlg.ShowModal();
2307 return 0;
2308}
2309
2310
2312{
2313 int result = NET_PLUGIN_CHANGE;
2314
2315 // If a plugin is removed or added, rebuild and reopen the new dialog
2316 while( result == NET_PLUGIN_CHANGE )
2317 result = InvokeDialogNetList( m_frame );
2318
2319 return 0;
2320}
2321
2322
2324{
2326
2327 wxCHECK( dlg, 0 );
2328
2329 // Needed at least on Windows. Raise() is not enough
2330 dlg->Show( true );
2331
2332 // Bring it to the top if already open. Dual monitor users need this.
2333 dlg->Raise();
2334
2335 dlg->ShowExportTab();
2336
2337 return 0;
2338}
2339
2340
2342{
2344 return 0;
2345}
2346
2347
2349{
2352 return 0;
2353}
2354
2355
2357{
2358 getEditFrame<SCH_EDIT_FRAME>()->ToggleSearch();
2359 return 0;
2360}
2361
2362
2364{
2365 getEditFrame<SCH_EDIT_FRAME>()->ToggleSchematicHierarchy();
2366 return 0;
2367}
2368
2369
2371{
2372 getEditFrame<SCH_EDIT_FRAME>()->ToggleNetNavigator();
2373 return 0;
2374}
2375
2376
2378{
2379 getEditFrame<SCH_EDIT_FRAME>()->ToggleProperties();
2380 return 0;
2381}
2382
2383
2385{
2388
2391
2392 return 0;
2393}
2394
2395
2397{
2400
2403
2404 return 0;
2405}
2406
2407
2409{
2412
2415
2416 return 0;
2417}
2418
2419
2421{
2424
2427
2428 return 0;
2429}
2430
2431
2433{
2436
2439
2440 return 0;
2441}
2442
2443
2445{
2448
2450
2451 return 0;
2452}
2453
2454
2456{
2459
2461 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
2462 {
2463 int flags = 0;
2464
2465 auto invalidateTextVars =
2466 [&flags]( EDA_TEXT* text )
2467 {
2468 if( text->HasTextVars() )
2469 {
2470 text->ClearRenderCache();
2471 text->ClearBoundingBoxCache();
2473 }
2474 };
2475
2476 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
2477 {
2478 item->RunOnChildren(
2479 [&invalidateTextVars]( SCH_ITEM* aChild )
2480 {
2481 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
2482 invalidateTextVars( text );
2483 } );
2484
2485 if( item->GetExcludedFromSim() )
2487 }
2488
2489 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
2490 invalidateTextVars( text );
2491
2492 return flags;
2493 } );
2494
2496
2497 return 0;
2498}
2499
2500
2502{
2505
2509
2510 return 0;
2511}
2512
2513
2515{
2518
2522
2523 return 0;
2524}
2525
2526
2528{
2531 return 0;
2532}
2533
2534
2536{
2538 m_frame->eeconfig()->m_Drawing.line_mode %= LINE_MODE::LINE_MODE_COUNT;
2540 return 0;
2541}
2542
2543
2545{
2548 return 0;
2549}
2550
2551
2553{
2556 return 0;
2557}
2558
2559
2561{
2562
2564 return 0;
2565}
2566
2567
2569{
2570#ifdef KICAD_IPC_API
2571 Pgm().GetPluginManager().ReloadPlugins();
2572#endif
2573 return 0;
2574}
2575
2576
2578{
2579 int errors = 0;
2580 wxString details;
2581 bool quiet = aEvent.Parameter<bool>();
2582
2583 // Repair duplicate IDs.
2584 std::map<KIID, EDA_ITEM*> ids;
2585 int duplicates = 0;
2586
2588
2589 auto processItem =
2590 [&]( EDA_ITEM* aItem )
2591 {
2592 auto it = ids.find( aItem->m_Uuid );
2593
2594 if( it != ids.end() && it->second != aItem )
2595 {
2596 duplicates++;
2597 const_cast<KIID&>( aItem->m_Uuid ) = KIID();
2598 }
2599
2600 ids[ aItem->m_Uuid ] = aItem;
2601 };
2602
2603 // Symbol IDs are the most important, so give them the first crack at "claiming" a
2604 // particular KIID.
2605
2606 for( const SCH_SHEET_PATH& sheet : sheets )
2607 {
2608 SCH_SCREEN* screen = sheet.LastScreen();
2609
2610 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
2611 {
2612 processItem( item );
2613
2614 for( SCH_PIN* pin : static_cast<SCH_SYMBOL*>( item )->GetPins( &sheet ) )
2615 processItem( pin );
2616 }
2617 }
2618
2619 for( const SCH_SHEET_PATH& sheet : sheets )
2620 {
2621 SCH_SCREEN* screen = sheet.LastScreen();
2622
2623 for( SCH_ITEM* item : screen->Items() )
2624 {
2625 processItem( item );
2626
2627 item->RunOnChildren(
2628 [&]( SCH_ITEM* aChild )
2629 {
2630 processItem( item );
2631 } );
2632 }
2633 }
2634
2635 /*******************************
2636 * Your test here
2637 */
2638
2639 /*******************************
2640 * Inform the user
2641 */
2642
2643 if( duplicates )
2644 {
2645 errors += duplicates;
2646 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
2647 }
2648
2649 if( errors )
2650 {
2651 m_frame->OnModify();
2652
2653 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
2654
2655 if( !quiet )
2656 DisplayInfoMessage( m_frame, msg, details );
2657 }
2658 else if( !quiet )
2659 {
2660 DisplayInfoMessage( m_frame, _( "No errors found." ) );
2661 }
2662
2663 return 0;
2664}
2665
2666
2668{
2669 if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
2670 return 0;
2671
2672 GRID_SETTINGS& gridSettings = m_toolMgr->GetSettings()->m_Window.grid;
2673 int currentIdx = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
2674
2675 wxArrayString gridsLabels;
2676
2677 for( const GRID& grid : gridSettings.grids )
2678 gridsLabels.Add( grid.UserUnitsMessageText( m_frame ) );
2679
2680 if( !m_frame->GetHotkeyPopup() )
2682
2684
2685 if( popup )
2686 popup->Popup( _( "Grid" ), gridsLabels, currentIdx );
2687
2688 return 0;
2689}
2690
2691
2693{
2694 Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
2695 Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
2696 Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
2703 Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
2704 Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
2705
2708
2714
2717
2723
2725
2726 Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
2727 Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
2728 Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
2729 Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
2733
2735
2752
2757
2772
2775
2777
2782}
const char * name
Definition: DXF_plotter.cpp:57
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:204
static TOOL_ACTION paste
Definition: actions.h:72
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
static TOOL_ACTION revert
Definition: actions.h:55
static TOOL_ACTION saveAs
Definition: actions.h:52
static TOOL_ACTION copy
Definition: actions.h:71
static TOOL_ACTION pluginsReload
Definition: actions.h:229
static TOOL_ACTION pickerTool
Definition: actions.h:194
static TOOL_ACTION showSymbolEditor
Definition: actions.h:201
static TOOL_ACTION pasteSpecial
Definition: actions.h:73
static TOOL_ACTION plot
Definition: actions.h:58
static TOOL_ACTION open
Definition: actions.h:50
static TOOL_ACTION pageSettings
Definition: actions.h:56
static TOOL_ACTION showSearch
Definition: actions.h:100
static TOOL_ACTION undo
Definition: actions.h:68
static TOOL_ACTION duplicate
Definition: actions.h:76
static TOOL_ACTION doDelete
Definition: actions.h:77
static TOOL_ACTION quit
Definition: actions.h:59
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION redo
Definition: actions.h:69
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:205
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION showProperties
Definition: actions.h:206
static TOOL_ACTION doNew
Definition: actions.h:47
static TOOL_ACTION cut
Definition: actions.h:70
static TOOL_ACTION refreshPreview
Definition: actions.h:139
WINDOW_SETTINGS m_Window
Definition: app_settings.h:172
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
Definition: base_screen.h:85
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81
int m_Threshold
Definition: collector.h:234
COMMIT & Added(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
Definition: commit.h:86
Calculate the connectivity of a schematic and generates netlists.
CONNECTION_SUBGRAPH * FindSubgraphByName(const wxString &aNetName, const SCH_SHEET_PATH &aPath)
Return the subgraph for a given net name on a given sheet.
A subgraph is a set of items that are electrically connected on a single sheet.
PRIORITY GetDriverPriority()
const std::set< SCH_ITEM * > & GetItems() const
Provide a read-only reference to the items in the subgraph.
void SetWksFileName(const wxString &aFilename)
bool PrjConfigChanged()
Return true if the project configuration was modified.
bool Show(bool show) override
int ShowQuasiModal()
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Add a command to undo in the undo list.
virtual int GetRedoCommandCount() const
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
Return the last command to undo and remove it from list, nothing is deleted.
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
virtual int GetUndoCommandCount() const
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Add a command to redo in the redo list.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
HOTKEY_CYCLE_POPUP * GetHotkeyPopup()
void ReleaseFile()
Release the current file marked in use.
void ScriptingConsoleEnableDisable()
Toggles the scripting console visibility.
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
virtual void CreateHotkeyPopup()
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:243
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:133
const KIID m_Uuid
Definition: eda_item.h:489
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:104
void ClearBrightened()
Definition: eda_item.h:123
void SetBrightened()
Definition: eda_item.h:120
EDA_ITEM * GetParent() const
Definition: eda_item.h:103
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:279
SHAPE_T GetShape() const
Definition: eda_shape.h:125
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:167
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:130
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1171
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:79
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:94
PANEL_ANNOTATE m_AnnotatePanel
static TOOL_ACTION importFPAssignments
Definition: ee_actions.h:176
static TOOL_ACTION repairSchematic
Definition: ee_actions.h:258
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:170
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
static TOOL_ACTION toggleAnnotateAuto
Definition: ee_actions.h:267
static TOOL_ACTION lineMode90
Definition: ee_actions.h:262
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:233
static TOOL_ACTION highlightNet
Definition: ee_actions.h:291
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:63
static TOOL_ACTION move
Definition: ee_actions.h:121
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:292
static TOOL_ACTION assignNetclass
Definition: ee_actions.h:162
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION showPythonConsole
Definition: ee_actions.h:257
static TOOL_ACTION toggleERCWarnings
Definition: ee_actions.h:238
static TOOL_ACTION simTune
Definition: ee_actions.h:280
static TOOL_ACTION toggleERCExclusions
Definition: ee_actions.h:240
static TOOL_ACTION lineModeNext
Definition: ee_actions.h:264
static TOOL_ACTION lineModeFree
Definition: ee_actions.h:261
static TOOL_ACTION editLibSymbolWithLibEdit
Definition: ee_actions.h:174
static TOOL_ACTION generateBOMLegacy
Definition: ee_actions.h:179
static TOOL_ACTION toggleERCErrors
Definition: ee_actions.h:239
static TOOL_ACTION toggleOPCurrents
Definition: ee_actions.h:243
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:294
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:293
static TOOL_ACTION exportNetlist
Definition: ee_actions.h:177
static TOOL_ACTION assignFootprints
Definition: ee_actions.h:161
static TOOL_ACTION selectOnPCB
Definition: ee_actions.h:246
static TOOL_ACTION rescueSymbols
Definition: ee_actions.h:169
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:234
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:173
static TOOL_ACTION simProbe
Definition: ee_actions.h:279
static TOOL_ACTION exportSymbolsToLibrary
Definition: ee_actions.h:182
static TOOL_ACTION drawSheetOnClipboard
Definition: ee_actions.h:253
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:153
static TOOL_ACTION showNetNavigator
Definition: ee_actions.h:295
static TOOL_ACTION annotate
Definition: ee_actions.h:152
static TOOL_ACTION toggleDirectiveLabels
Definition: ee_actions.h:237
static TOOL_ACTION showHierarchy
Definition: ee_actions.h:225
static TOOL_ACTION toggleOPVoltages
Definition: ee_actions.h:242
static TOOL_ACTION lineMode45
Definition: ee_actions.h:263
static TOOL_ACTION markSimExclusions
Definition: ee_actions.h:241
static TOOL_ACTION editSymbolLibraryLinks
Definition: ee_actions.h:154
static TOOL_ACTION saveCurrSheetCopyAs
Definition: ee_actions.h:42
static TOOL_ACTION showPcbNew
Definition: ee_actions.h:175
static TOOL_ACTION generateBOM
Definition: ee_actions.h:178
static TOOL_ACTION schematicSetup
Definition: ee_actions.h:163
static TOOL_ACTION exportSymbolsToNewLibrary
Definition: ee_actions.h:183
void Collect(SCH_SCREEN *aScreen, const std::vector< KICAD_T > &aScanTypes, const VECTOR2I &aPos, int aUnit=0, int aConvert=0)
Scan a EDA_ITEM using this class's Inspector method which does the collection.
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
void GuessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aPos)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
EE_SELECTION & RequestSelection(const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T }, bool aPromoteCellSelections=false)
Return either an existing selection (filtered), or the selection at the current cursor position if th...
EDA_ITEM * GetNode(const VECTOR2I &aPosition)
Finds a connected item at a point (usually the cursor position).
bool SelectPoint(const VECTOR2I &aWhere, const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T }, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aCheckLocked=false, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
Perform a click-type selection at a point (usually the cursor position).
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
EE_SELECTION & GetSelection()
Definition: erc.h:52
static const TOOL_EVENT ClearedEvent
Definition: actions.h:272
static const TOOL_EVENT GridChangedByKeyEvent
Definition: actions.h:290
static const TOOL_EVENT SelectedEvent
Definition: actions.h:270
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:277
static const TOOL_EVENT PointSelectedEvent
Definition: actions.h:269
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:271
Similar to EDA_VIEW_SWITCHER, this dialog is a popup that shows feedback when using a hotkey to cycle...
void Popup(const wxString &aTitle, const wxArrayString &aItems, int aSelection)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
An interface for classes handling user events controlling the view behavior such as zooming,...
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
double GetScale() const
Definition: view.h:277
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:1687
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:401
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1563
void Hide(VIEW_ITEM *aItem, bool aHide=true, bool aHideOverlay=false)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1635
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:649
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:1573
bool EndsWith(const KIID_PATH &aPath) const
Test if aPath from the last path towards the first path.
Definition: kiid.cpp:335
wxString AsString() const
Definition: kiid.cpp:356
Definition: kiid.h:49
wxString AsString() const
Definition: kiid.cpp:246
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:55
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:65
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:406
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
Definition: kiway.cpp:669
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
Definition: lib_id.cpp:99
Define a library symbol object.
Definition: lib_symbol.h:78
const LIB_ID & GetLibId() const override
Definition: lib_symbol.h:143
wxString GetName() const override
Definition: lib_symbol.h:137
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:304
const wxString & GetNickName() const
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
static void ConvertToSpiceMarkup(wxString *aNetName)
Remove formatting wrappers and replace illegal spice net name characters with underscores.
Tree view item data for the net navigator.
static bool ParseBusGroup(const wxString &aGroup, wxString *name, std::vector< wxString > *aMemberList)
Parse a bus group label into the name and a list of components.
static bool ParseBusVector(const wxString &aBus, wxString *aName, std::vector< wxString > *aMemberList)
Parse a bus vector (e.g.
static wxString GetDefaultUserSymbolsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:87
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
void SetDescription(const wxString &aDescription)
void ReversePickersListOrder()
Reverse the order of pickers stored in this list.
void SetMotionHandler(MOTION_HANDLER aHandler)
Set a handler for mouse motion.
Definition: picker_tool.h:83
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:72
void SetSnapping(bool aSnap)
Definition: picker_tool.h:65
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:63
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:103
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:135
virtual const wxString GetProjectName() const
Return the short name of the project.
Definition: project.cpp:147
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
Definition: project.cpp:153
static bool RescueProject(wxWindow *aParent, RESCUER &aRescuer, bool aRunningOnDemand)
size_t GetCandidateCount()
Return the number of rescue candidates found.
Holds all the data relating to one schematic.
Definition: schematic.h:76
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:144
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:291
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:297
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:154
SCH_SHEET_LIST BuildUnorderedSheetList() const
Definition: schematic.h:101
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition: schematic.cpp:854
SCH_SHEET & Root() const
Definition: schematic.h:113
SCH_SHEET_LIST BuildSheetListSortedByPageNumbers() const override
Definition: schematic.h:96
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SYMBOL_LIB_TABLE * SelectSymLibTable(bool aOptional=false)
Display a dialog asking the user to select a symbol library table.
wxString SelectLibraryFromList()
Display a list of loaded libraries and allows the user to select a library.
void SyncView()
Mark all items for refresh.
EESCHEMA_SETTINGS * eeconfig() const
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:38
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
Definition: sch_commit.cpp:406
virtual void Revert() override
Definition: sch_commit.cpp:484
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString Name(bool aIgnoreSheet=false) const
bool IsBus() const
SCH_ITEM * Driver() const
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Handle actions specific to the schematic editor.
int PageSetup(const TOOL_EVENT &aEvent)
bool RescueLegacyProject(bool aRunningOnDemand)
int ToggleDirectiveLabels(const TOOL_EVENT &aEvent)
int SaveAs(const TOOL_EVENT &aEvent)
int MarkSimExclusions(const TOOL_EVENT &aEvent)
int Annotate(const TOOL_EVENT &aEvent)
int ToggleAnnotateRecursive(const TOOL_EVENT &aEvent)
int ShowSchematicSetup(const TOOL_EVENT &aEvent)
int HighlightNet(const TOOL_EVENT &aEvent)
Remove any net highlighting.
int ClearHighlight(const TOOL_EVENT &aEvent)
Update net highlighting after an edit.
int EditSymbolFields(const TOOL_EVENT &aEvent)
int GenerateBOMLegacy(const TOOL_EVENT &aEvent)
int HighlightNetCursor(const TOOL_EVENT &aEvent)
int ImportFPAssignments(const TOOL_EVENT &aEvent)
int ChangeLineMode(const TOOL_EVENT &aEvent)
void doCrossProbeSchToPcb(const TOOL_EVENT &aEvent, bool aForce)
int ExportSymbolsToLibrary(const TOOL_EVENT &aEvent)
int SaveCurrSheetCopyAs(const TOOL_EVENT &aEvent)
Saves the currently-open schematic sheet to an other name.
bool rescueProject(RESCUER &aRescuer, bool aRunningOnDemand)
int CrossProbeToPcb(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
int Quit(const TOOL_EVENT &aEvent)
int RemapSymbols(const TOOL_EVENT &aEvent)
int DrawSheetOnClipboard(const TOOL_EVENT &aEvent)
SCH_SHEET_PATH updatePastedSheet(SCH_SHEET *aSheet, const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, bool aForceKeepAnnotations, SCH_SHEET_LIST *aPastedSheets, std::map< SCH_SHEET_PATH, SCH_REFERENCE_LIST > &aPastedSymbols)
int RescueSymbols(const TOOL_EVENT &aEvent)
Perform rescue operations to recover old projects from before certain changes were made.
int AssignNetclass(const TOOL_EVENT &aEvent)
std::string m_duplicateClipboard
int ExportNetlist(const TOOL_EVENT &aEvent)
int Open(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
int ToggleOPVoltages(const TOOL_EVENT &aEvent)
int Copy(const TOOL_EVENT &aEvent)
int ToggleERCWarnings(const TOOL_EVENT &aEvent)
int NextLineMode(const TOOL_EVENT &aEvent)
int Redo(const TOOL_EVENT &aEvent)
Clipboard support.
int UpdatePCB(const TOOL_EVENT &aEvent)
int UpdateFromPCB(const TOOL_EVENT &aEvent)
int ToggleAnnotateAuto(const TOOL_EVENT &aEvent)
int ToggleHiddenPins(const TOOL_EVENT &aEvent)
int Duplicate(const TOOL_EVENT &aEvent)
bool searchSupplementaryClipboard(const wxString &aSheetFilename, SCH_SCREEN **aScreen)
int GridFeedback(const TOOL_EVENT &aEvent)
int ShowSearch(const TOOL_EVENT &aEvent)
int EditWithSymbolEditor(const TOOL_EVENT &aEvent)
int SimTune(const TOOL_EVENT &aEvent)
Highlight net under the cursor.
int EditSymbolLibraryLinks(const TOOL_EVENT &aEvent)
int New(const TOOL_EVENT &aEvent)
std::map< wxString, SCH_SCREEN * > m_supplementaryClipboard
int ExplicitCrossProbeToPcb(const TOOL_EVENT &aEvent)
int ToggleOPCurrents(const TOOL_EVENT &aEvent)
int ShowPcbNew(const TOOL_EVENT &aEvent)
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Launch a tool to highlight nets.
int ToggleERCErrors(const TOOL_EVENT &aEvent)
int TogglePythonConsole(const TOOL_EVENT &aEvent)
int ShowHierarchy(const TOOL_EVENT &aEvent)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
int ShowNetNavigator(const TOOL_EVENT &aEvent)
int SimProbe(const TOOL_EVENT &aEvent)
void updatePastedSymbol(SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, bool aForceKeepAnnotations)
int ShowCvpcb(const TOOL_EVENT &aEvent)
int RepairSchematic(const TOOL_EVENT &aEvent)
std::set< SCH_SYMBOL * > m_pastedSymbols
void prunePastedSymbolInstances()
Remove all pasted symbol instances that do not belong to the current project.
int Cut(const TOOL_EVENT &aEvent)
int ToggleProperties(const TOOL_EVENT &aEvent)
std::map< KIID_PATH, SCH_SYMBOL_INSTANCE > m_clipboardSymbolInstances
int Save(const TOOL_EVENT &aEvent)
bool RescueSymbolLibTableProject(bool aRunningOnDemand)
Notifies pcbnew about the selected item.
bool doCopy(bool aUseDuplicateClipboard=false)
< copy selection to clipboard or to m_duplicateClipboard
int Undo(const TOOL_EVENT &aEvent)
int ToggleERCExclusions(const TOOL_EVENT &aEvent)
int Plot(const TOOL_EVENT &aEvent)
int Print(const TOOL_EVENT &aEvent)
int Revert(const TOOL_EVENT &aEvent)
int GenerateBOM(const TOOL_EVENT &aEvent)
int ReloadPlugins(const TOOL_EVENT &aEvent)
void setPastedSymbolInstances(const SCH_SCREEN *aScreen)
int ToggleHiddenFields(const TOOL_EVENT &aEvent)
Schematic editor (Eeschema) main window.
void ShowSchematicSetupDialog(const wxString &aInitialPage=wxEmptyString)
void RollbackSchematicFromUndo()
Perform an undo of the last edit WITHOUT logging a corresponding redo.
bool IsSyncingSelection()
bool LoadSheetFromFile(SCH_SHEET *aSheet, SCH_SHEET_PATH *aCurrentSheet, const wxString &aFileName)
Load a the KiCad schematic file aFileName into the sheet aSheet.
Definition: sheet.cpp:166
void RefreshOperatingPointDisplay()
Refresh the display of any operaintg points.
void OnOpenCvpcb(wxCommandEvent &event)
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
void SetHighlightedConnection(const wxString &aConnection, const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void InitSheet(SCH_SHEET *aSheet, const wxString &aNewFilename)
Definition: sheet.cpp:107
void UpdateHierarchyNavigator(bool aRefreshNetNavigator=true)
Update the hierarchy navigation tree and history.
void SendSelectItemsToPcb(const std::vector< EDA_ITEM * > &aItems, bool aForce)
Send items to board editor for selection.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
void SendCrossProbeClearHighlight()
Tell Pcbnew to clear the existing highlighted net, if one exists.
void HardRedraw() override
Rebuild the GAL and redraw the screen.
SCH_SHEET_PATH & GetCurrentSheet() const
const SCH_ITEM * GetSelectedNetNavigatorItem() const
SCHEMATIC & Schematic() const
bool saveSchematicFile(SCH_SHEET *aSheet, const wxString &aSavePath)
Save aSheet to a schematic file.
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:613
void RefreshNetNavigator(const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr)
void OnUpdatePCB(wxCommandEvent &event)
void OnOpenPcbnew(wxCommandEvent &event)
void OnAnnotate(wxCommandEvent &event)
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
void DisplayCurrentSheet()
Draw the current sheet on the display.
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Restore an undo or redo command to put data pointed by aList in the previous state.
const wxString & GetHighlightedConnection() const
void UpdateNetHighlightStatus()
void SelectNetNavigatorItem(const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr)
DIALOG_SYMBOL_FIELDS_TABLE * GetSymbolFieldsTableDialog()
void SetCrossProbeConnection(const SCH_CONNECTION *aConnection)
Send a connection (net or bus) to Pcbnew for highlighting.
bool SaveProject(bool aSaveAs=false)
Save the currently-open schematic (including its hierarchy) and associated project.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1205
A SCH_IO derivation for loading schematic files using the new s-expression file format.
void LoadContent(LINE_READER &aReader, SCH_SHEET *aSheet, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
void Format(SCH_SHEET *aSheet)
static SCH_FILE_T EnumFromStr(const wxString &aFileType)
Return the #SCH_FILE_T from the corresponding plugin type name: "kicad", "legacy",...
Definition: sch_io_mgr.cpp:107
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
virtual bool IsConnectable() const
Definition: sch_item.h:449
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:150
virtual void SetLastResolvedState(const SCH_ITEM *aItem)
Definition: sch_item.h:541
int GetBodyStyle() const
Definition: sch_item.h:232
int GetUnit() const
Definition: sch_item.h:229
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:512
bool IsConnectivityDirty() const
Definition: sch_item.h:510
virtual void SetUnit(int aUnit)
Definition: sch_item.h:228
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:221
virtual std::vector< VECTOR2I > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:464
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:41
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void SortByReferenceOnly()
Sort the list of references by reference.
size_t GetCount() const
void AddItem(const SCH_REFERENCE &aItem)
A helper to define a symbol's reference designator in a schematic.
void SetSheetNumber(int aSheetNumber)
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:710
SCH_SCREEN * GetNext()
void UpdateSymbolLinks(REPORTER *aReporter=nullptr)
Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in the full schematic.
SCH_SCREEN * GetFirst()
void PruneOrphanedSheetInstances(const wxString &aProjectName, const SCH_SHEET_LIST &aValidSheetPaths)
void PruneOrphanedSymbolInstances(const wxString &aProjectName, const SCH_SHEET_LIST &aValidSheetPaths)
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:152
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:277
void UpdateSymbolLinks(REPORTER *aReporter=nullptr)
Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in this schematic from the project SYMB...
Definition: sch_screen.cpp:777
const std::map< wxString, LIB_SYMBOL * > & GetLibSymbols() const
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition: sch_screen.h:480
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:634
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:108
const wxString & GetFileName() const
Definition: sch_screen.h:143
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:322
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
Definition: sch_screen.cpp:385
void MigrateSimModels()
Migrate any symbols having V6 simulation models to their V7 equivalents.
VECTOR2I GetCenter() const
Definition: sch_shape.h:73
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Fill an item cache for temporary use when many items need to be fetched.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
bool NameExists(const wxString &aSheetName) const
SCH_SHEET_LIST FindAllSheetsForScreen(const SCH_SCREEN *aScreen) const
Return a SCH_SHEET_LIST with a copy of all the SCH_SHEET_PATH using a particular screen.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
bool PageNumberExists(const wxString &aPageNumber) const
bool ContainsSheet(const SCH_SHEET *aSheet) const
bool HasPath(const KIID_PATH &aPath) const
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName)
Test every SCH_SHEET_PATH in this SCH_SHEET_LIST to verify if adding the sheets stored in aSrcSheetHi...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Adds SCH_REFERENCE object to aReferences for each symbol in the sheet.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:306
void RemoveInstance(const KIID_PATH &aInstancePath)
Definition: sch_sheet.cpp:1397
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:93
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:782
void AddInstance(const SCH_SHEET_INSTANCE &aInstance)
Definition: sch_sheet.cpp:1418
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:110
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:172
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:181
const std::vector< SCH_SHEET_INSTANCE > & GetInstances() const
Definition: sch_sheet.h:417
Schematic symbol object.
Definition: sch_symbol.h:106
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
Definition: sch_symbol.h:165
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:268
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:934
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
Definition: sch_symbol.cpp:635
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
Definition: sch_symbol.cpp:235
const LIB_ID & GetLibId() const override
Definition: sch_symbol.h:195
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:982
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:214
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:277
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
Definition: sch_symbol.cpp:735
bool IsPower() const override
void BrightenItem(EDA_ITEM *aItem)
void UnbrightenItem(EDA_ITEM *aItem)
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.cpp:180
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
The SIMULATOR_FRAME holds the main user-interface for running simulations.
void AddCurrentTrace(const wxString &aDeviceName)
Add a current trace for a given device to the current plot.
void AddVoltageTrace(const wxString &aNetName)
Add a voltage trace for a given net to the current plot.
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< SCH_PIN * > &aPins, REPORTER &aReporter)
int FindModelPinIndex(const std::string &aSymbolPinNumber)
Definition: sim_model.cpp:708
const SPICE_GENERATOR & SpiceGenerator() const
Definition: sim_model.h:435
virtual std::vector< std::string > CurrentNames(const SPICE_ITEM &aItem) const
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:433
const std::string & GetString()
Definition: richio.h:456
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:253
The symbol library editor main window.
bool IsLibraryTreeShown() const override
void LoadSymbol(const wxString &aLibrary, const wxString &aSymbol, int Unit)
void LoadSymbolFromSchematic(SCH_SYMBOL *aSymbol)
Load a symbol from the schematic to edit in place.
void ToggleLibraryTree() override
Class to handle modifications to the symbol libraries.
bool CreateLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Create an empty library and adds it to the library table.
SYMBOL_LIB_TABLE_ROW * GetLibrary(const wxString &aLibrary) const
Find a single library within the (aggregate) library table.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_IO object i...
const wxString GetType() const override
Return the type of symbol library table represented by this row.
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
static const wxString & GetSymbolLibTableFileName()
static wxString GetGlobalTableFileName()
Fetch the global symbol library table file name.
SYMBOL_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an SYMBOL_LIB_TABLE_ROW if aNickName is found in this table or in any chained fallBack table f...
Symbol library viewer main window.
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
Generic, UI-independent tool event.
Definition: tool_event.h:167
bool DisableGridSnapping() const
Definition: tool_event.h:363
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:82
T Parameter() const
Return a parameter assigned to the event.
Definition: tool_event.h:460
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
void Activate()
Run the tool.
Master controller class:
Definition: tool_manager.h:62
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
std::string GetClipboardUTF8() const
Return the information currently stored in the system clipboard.
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:402
APP_SETTINGS_BASE * GetSettings() const
Definition: tool_manager.h:400
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:235
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
bool RunSynchronousAction(const TOOL_ACTION &aAction, COMMIT *aCommit, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:197
A wrapper for reporting to a wxString object.
Definition: reporter.h:164
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.cpp:80
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
Definition: common.cpp:424
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:250
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:222
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:195
This file is part of the common library.
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
Definition: dialog_bom.cpp:111
bool InvokeDialogEditSymbolsLibId(SCH_EDIT_FRAME *aCaller)
Run a dialog to modify the LIB_ID of symbols for instance when a symbol has moved from a symbol libra...
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
#define _(s)
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:536
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_NEW
New item, just created.
#define ENDPOINT
ends. (Used to support dragging.)
#define IS_MOVING
Item being moved.
#define STARTPOINT
When a line is selected, these flags indicate which.
#define HITTEST_THRESHOLD_PIXELS
LINE_MODE
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
@ FRAME_SIMULATOR
Definition: frame_type.h:38
static const std::string KiCadSchematicFileExtension
static const std::string KiCadSymbolLibFileExtension
static wxString KiCadSymbolLibFileWildcard()
static wxString KiCadSchematicFileWildcard()
static const wxChar traceSchPaste[]
Flag to enable schematic paste debugging output.
int InvokeDialogPrintUsingPrinter(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_PRINT_USING_PRINTER and return whatever DIALOG_PRINT_USING_PRINTER::ShowModal(...
#define NET_PLUGIN_CHANGE
Create and shows DIALOG_EXPORT_NETLIST and returns whatever DIALOG_EXPORT_NETLIST::ShowModal() return...
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
Definition: io_mgr.h:33
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:39
#define KICTL_REVERT
reverting to a previously-saved (KiCad) file.
Definition: kiway_player.h:78
@ LAYER_ERC_WARN
Definition: layer_ids.h:384
@ LAYER_ERC_ERR
Definition: layer_ids.h:385
@ LAYER_OP_CURRENTS
Definition: layer_ids.h:404
@ LAYER_OP_VOLTAGES
Definition: layer_ids.h:403
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:57
@ GEOMETRY
Position or shape has changed.
Definition: view_item.h:54
#define MAX_PAGE_SIZE_EESCHEMA_MILS
Definition: page_info.h:40
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
@ LOCAL_CLEANUP
@ NO_CLEANUP
@ GLOBAL_CLEANUP
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
static VECTOR2D CLEAR
ANNOTATE_ORDER_T
Schematic annotation order options.
ANNOTATE_ALGO_T
Schematic annotation type options.
@ SHEETNAME
Definition: sch_sheet.h:45
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
std::vector< GRID > grids
Definition: grid_settings.h:66
Common grid settings, available to every frame.
Definition: grid_settings.h:34
A simple container for sheet instance information.
A simple container for schematic symbol instance information.
static constexpr auto NOT_CONNECTED
Definition: sim_model.h:73
std::string refName
GRID_SETTINGS grid
Definition: app_settings.h:81
Definition for symbol library class.
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ AS_GLOBAL
Global action (toolbar/main menu event, global shortcut)
Definition: tool_action.h:48
@ TA_UNDO_REDO_PRE
Definition: tool_event.h:105
@ TC_MESSAGE
Definition: tool_event.h:57
@ SCH_LINE_T
Definition: typeinfo.h:163
@ SCH_SYMBOL_T
Definition: typeinfo.h:172
@ SCH_FIELD_T
Definition: typeinfo.h:150
@ SCH_SHEET_T
Definition: typeinfo.h:174
@ SCH_MARKER_T
Definition: typeinfo.h:158
@ SCH_SHAPE_T
Definition: typeinfo.h:149
@ SCH_PIN_T
Definition: typeinfo.h:153
constexpr ret_type KiROUND(fp_type v, bool aQuiet=false)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:100
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:676
Definition of file extensions used in Kicad.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
Definition: wx_filename.h:39