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
26
27#include <clipboard.h>
28#include <confirm.h>
29#include <connection_graph.h>
39#include <project_rescue.h>
40#include <erc/erc.h>
41#include <invoke_sch_dialog.h>
42#include <string_utils.h>
43#include <kiway.h>
45#include <paths.h>
46#include <pgm_base.h>
49#include <project_sch.h>
50#include <sch_edit_frame.h>
52#include <sch_bitmap.h>
53#include <sch_line.h>
54#include <sch_junction.h>
55#include <sch_bus_entry.h>
56#include <sch_shape.h>
57#include <sch_painter.h>
58#include <sch_sheet_pin.h>
59#include <sch_commit.h>
60#include <sim/simulator_frame.h>
61#include <symbol_lib_table.h>
62#include <symbol_library.h>
64#include <symbol_viewer_frame.h>
65#include <tool/picker_tool.h>
66#include <tool/tool_manager.h>
67#include <tools/ee_actions.h>
68#include <tools/ee_selection.h>
70#include <tools/ee_tool_utils.h>
72#include <eda_list_dialog.h>
73#include <view/view_controls.h>
75#include <wx_filename.h>
76#include <wx/filedlg.h>
77#include <wx/log.h>
78#include <wx/treectrl.h>
79#include <wx/msgdlg.h>
80#include "sch_edit_table_tool.h"
81
82#ifdef KICAD_IPC_API
84#endif
85
86
92static const wxChar traceSchPaste[] = wxT( "KICAD_SCH_PASTE" );
93
94
96{
98 return 0;
99}
100
101
103{
105 return 0;
106}
107
108
110{
112 return 0;
113}
114
115
117{
118 m_frame->SaveProject( true );
119 return 0;
120}
121
122
124{
125 SCH_SHEET* curr_sheet = m_frame->GetCurrentSheet().Last();
126 wxFileName curr_fn = curr_sheet->GetFileName();
127 wxFileDialog dlg( m_frame, _( "Schematic Files" ), curr_fn.GetPath(), curr_fn.GetFullName(),
129 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
130
131 if( dlg.ShowModal() == wxID_CANCEL )
132 return false;
133
134 wxString newFilename =
136
137 m_frame->saveSchematicFile( curr_sheet, newFilename );
138 return 0;
139}
140
141
143{
144 SCHEMATIC& schematic = m_frame->Schematic();
145 SCH_SHEET& root = schematic.Root();
146
147 if( m_frame->GetCurrentSheet().Last() != &root )
148 {
151
152 // Store the current zoom level into the current screen before switching
154
155 SCH_SHEET_PATH rootSheetPath;
156 rootSheetPath.push_back( &root );
157 m_frame->SetCurrentSheet( rootSheetPath );
159
160 wxSafeYield();
161 }
162
163 wxString msg;
164 msg.Printf( _( "Revert '%s' (and all sub-sheets) to last version saved?" ),
165 schematic.GetFileName() );
166
167 if( !IsOK( m_frame, msg ) )
168 return false;
169
170 SCH_SCREENS screenList( schematic.Root() );
171
172 for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
173 screen->SetContentModified( false ); // do not prompt the user for changes
174
176 m_frame->OpenProjectFiles( std::vector<wxString>( 1, schematic.GetFileName() ), KICTL_REVERT );
177
178 return 0;
179}
180
181
183{
185 return 0;
186}
187
188
190{
191 PICKED_ITEMS_LIST undoCmd;
193 ITEM_PICKER wrapper( m_frame->GetScreen(), undoItem, UNDO_REDO::PAGESETTINGS );
194
195 undoCmd.PushItem( wrapper );
196 undoCmd.SetDescription( _( "Page Settings" ) );
197 m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS, false, false );
198
202
203 if( dlg.ShowModal() == wxID_OK )
204 {
205 // Update text variables
209
210 m_frame->OnModify();
211 }
212 else
213 {
215 }
216
217 return 0;
218}
219
220
222{
223 SCH_SCREENS schematic( m_frame->Schematic().Root() );
224
225 if( schematic.HasNoFullyDefinedLibIds() )
226 RescueLegacyProject( true );
227 else
229
230 return 0;
231}
232
233
234bool SCH_EDITOR_CONTROL::RescueLegacyProject( bool aRunningOnDemand )
235{
238
239 return rescueProject( rescuer, aRunningOnDemand );
240}
241
242
244{
248
249 return rescueProject( rescuer, aRunningOnDemand );
250}
251
252
253bool SCH_EDITOR_CONTROL::rescueProject( RESCUER& aRescuer, bool aRunningOnDemand )
254{
255 if( !RESCUER::RescueProject( m_frame, aRescuer, aRunningOnDemand ) )
256 return false;
257
258 if( aRescuer.GetCandidateCount() )
259 {
260 KIWAY_PLAYER* viewer = m_frame->Kiway().Player( FRAME_SCH_VIEWER, false );
261
262 if( viewer )
263 static_cast<SYMBOL_VIEWER_FRAME*>( viewer )->ReCreateLibList();
264
265 if( aRunningOnDemand )
266 {
267 SCH_SCREENS schematic( m_frame->Schematic().Root() );
268
269 schematic.UpdateSymbolLinks();
271 }
272
274 m_frame->SyncView();
276 m_frame->OnModify();
277 }
278
279 return true;
280}
281
282
284{
285 DIALOG_SYMBOL_REMAP dlgRemap( m_frame );
286
287 dlgRemap.ShowQuasiModal();
288
289 m_frame->GetCanvas()->Refresh( true );
290
291 return 0;
292}
293
294
296{
298 return 0;
299}
300
301
303{
305
306 dlg.ShowModal();
307
308 // save project config if the prj config has changed:
309 if( dlg.PrjConfigChanged() )
310 m_frame->OnModify();
311
312 return 0;
313}
314
315
317{
318 m_frame->Close( false );
319 return 0;
320}
321
322
324{
325 doCrossProbeSchToPcb( aEvent, false );
326 return 0;
327}
328
329
331{
332 doCrossProbeSchToPcb( aEvent, true );
333 return 0;
334}
335
336
337void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce )
338{
339 // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
341 return;
342
344
345 EE_SELECTION& selection = aForce ? selTool->RequestSelection() : selTool->GetSelection();
346
347 m_frame->SendSelectItemsToPcb( selection.GetItemsSortedBySelectionOrder(), aForce );
348}
349
350
352{
353 bool savePowerSymbols = IsOK( m_frame,
354 _( "Include power symbols in schematic to the library?" ) );
355
356 bool createNew = aEvent.IsAction( &EE_ACTIONS::exportSymbolsToNewLibrary );
357
359 SCH_REFERENCE_LIST symbols;
360 sheets.GetSymbols( symbols, savePowerSymbols );
361
362 std::map<LIB_ID, LIB_SYMBOL*> libSymbols;
363 std::map<LIB_ID, std::vector<SCH_SYMBOL*>> symbolMap;
364
365 for( size_t i = 0; i < symbols.GetCount(); ++i )
366 {
367 SCH_SYMBOL* symbol = symbols[i].GetSymbol();
368 LIB_SYMBOL* libSymbol = symbol->GetLibSymbolRef().get();
369 LIB_ID id = libSymbol->GetLibId();
370
371 if( libSymbols.count( id ) )
372 {
373 wxASSERT_MSG( libSymbols[id]->Compare( *libSymbol, SCH_ITEM::COMPARE_FLAGS::ERC ) == 0,
374 "Two symbols have the same LIB_ID but are different!" );
375 }
376 else
377 {
378 libSymbols[id] = libSymbol;
379 }
380
381 symbolMap[id].emplace_back( symbol );
382 }
383
385
386 wxString targetLib;
387
388 if( createNew )
389 {
390 wxFileName fn;
392
393 if( !libTable ) // Cancelled by user
394 return 0;
395
398 ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() ),
400 {
401 return 0;
402 }
403
404 targetLib = fn.GetName();
405
406 if( libTable->HasLibrary( targetLib, false ) )
407 {
408 DisplayError( m_frame, wxString::Format( _( "Library '%s' already exists." ),
409 targetLib ) );
410 return 0;
411 }
412
413 // if the "new" library is in fact an existing library and the used asked for replacing
414 // it by the recreated lib, erase it:
415 if( fn.FileExists() )
416 wxRemoveFile( fn.GetFullPath() );
417
418 if( !mgr.CreateLibrary( fn.GetFullPath(), *libTable ) )
419 {
420 DisplayError( m_frame, wxString::Format( _( "Could not add library '%s'." ),
421 targetLib ) );
422 return 0;
423 }
424 }
425 else
426 {
427 targetLib = m_frame->SelectLibraryFromList();
428 }
429
430 if( targetLib.IsEmpty() )
431 return 0;
432
433 bool map = IsOK( m_frame, _( "Update symbols in schematic to refer to new library?" ) );
434 bool append = false;
435
436 SYMBOL_LIB_TABLE_ROW* row = mgr.GetLibrary( targetLib );
437 SCH_IO_MGR::SCH_FILE_T type = SCH_IO_MGR::EnumFromStr( row->GetType() );
438 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( type ) );
439
440 wxFileName dest = row->GetFullURI( true );
441 dest.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS );
442
443 for( const std::pair<const LIB_ID, LIB_SYMBOL*>& it : libSymbols )
444 {
445 LIB_SYMBOL* origSym = it.second;
446 LIB_SYMBOL* newSym = origSym->Flatten().release();
447
448 try
449 {
450 pi->SaveSymbol( dest.GetFullPath(), newSym );
451 }
452 catch( const IO_ERROR& ioe )
453 {
454 wxString msg;
455 msg.Printf( _( "Error saving symbol %s to library '%s'." ),
456 newSym->GetName(), row->GetNickName() );
457 msg += wxS( "\n\n" ) + ioe.What();
458 wxLogWarning( msg );
459 return 0;
460 }
461
462 if( map )
463 {
464 LIB_ID id = it.first;
465 id.SetLibNickname( targetLib );
466
467 for( SCH_SYMBOL* symbol : symbolMap[it.first] )
468 {
469 m_frame->SaveCopyInUndoList( m_frame->GetScreen(), symbol, UNDO_REDO::CHANGED,
470 append, false );
471 symbol->SetLibId( id );
472 append = true;
473 }
474 }
475 }
476
477 // Save the modified symbol library table. We need to look this up by name in each table to find
478 // whether the new library is a global or project entity as the code above to choose the library
479 // returns a different type depending on whether a global or project library is chosen.
481 SYMBOL_LIB_TABLE* projectTable = nullptr;
482
483 if( !m_frame->Prj().IsNullProject() )
484 projectTable = PROJECT_SCH::SchSymbolLibTable( &m_frame->Prj() );
485
486 if( globalTable->FindRow( targetLib ) )
487 {
488 try
489 {
490 wxString globalTablePath = SYMBOL_LIB_TABLE::GetGlobalTableFileName();
491 globalTable->Save( globalTablePath );
492 }
493 catch( const IO_ERROR& ioe )
494 {
495 wxString msg;
496 msg.Printf( _( "Error saving global library table:\n\n%s" ), ioe.What() );
497 wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
498 }
499 }
500 else if( projectTable && projectTable->FindRow( targetLib ) )
501 {
502 try
503 {
504 wxString projectPath = m_frame->Prj().GetProjectPath();
505 wxFileName projectTableFn( projectPath, SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
506 projectTable->Save( projectTableFn.GetFullPath() );
507 }
508 catch( const IO_ERROR& ioe )
509 {
510 wxString msg;
511 msg.Printf( _( "Error saving project-specific library table:\n\n%s" ), ioe.What() );
512 wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
513 }
514 }
515
516 if( append )
517 {
518 std::set<SCH_SCREEN*> processedScreens;
519
520 for( SCH_SHEET_PATH& sheet : sheets )
521 {
522 SCH_SCREEN* screen = sheet.LastScreen();
523
524 if( processedScreens.find( ( screen ) ) == processedScreens.end() )
525 {
526 processedScreens.insert( screen );
527 screen->UpdateSymbolLinks();
528 }
529 }
530
531 m_frame->OnModify();
532 }
533
534 return 0;
535}
536
537
538#define HITTEST_THRESHOLD_PIXELS 5
539
541{
543 KIWAY_PLAYER* player = m_frame->Kiway().Player( FRAME_SIMULATOR, false );
544 SIMULATOR_FRAME* simFrame = static_cast<SIMULATOR_FRAME*>( player );
545
546 if( !simFrame ) // Defensive coding; shouldn't happen.
547 return 0;
548
549 if( wxWindow* blocking_win = simFrame->Kiway().GetBlockingDialog() )
550 blocking_win->Close( true );
551
552 // Deactivate other tools; particularly important if another PICKER is currently running
553 Activate();
554
555 picker->SetCursor( KICURSOR::VOLTAGE_PROBE );
556 picker->SetSnapping( false );
557
558 picker->SetClickHandler(
559 [this, simFrame]( const VECTOR2D& aPosition )
560 {
562 EDA_ITEM* item = selTool->GetNode( aPosition );
564
565 if( !item )
566 return false;
567
568 if( item->Type() == SCH_PIN_T )
569 {
570 try
571 {
572 SCH_PIN* pin = static_cast<SCH_PIN*>( item )->GetLibPin();
573 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item->GetParent() );
574
575 WX_STRING_REPORTER reporter;
576 SIM_LIB_MGR mgr( &m_frame->Prj() );
577
578 SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol, reporter ).model;
579
580 if( reporter.HasMessage() )
581 THROW_IO_ERROR( reporter.GetMessages() );
582
583 SPICE_ITEM spiceItem;
584 spiceItem.refName = symbol->GetRef( &sheet ).ToStdString();
585 std::vector<std::string> currentNames =
586 model.SpiceGenerator().CurrentNames( spiceItem );
587
588 if( currentNames.size() == 0 )
589 {
590 return true;
591 }
592 else if( currentNames.size() == 1 )
593 {
594 simFrame->AddCurrentTrace( currentNames.at( 0 ) );
595 return true;
596 }
597
598 int modelPinIndex = model.FindModelPinIndex( pin->GetNumber().ToStdString() );
599
600 if( modelPinIndex != SIM_MODEL_PIN::NOT_CONNECTED )
601 {
602 wxString name = currentNames.at( modelPinIndex );
603 simFrame->AddCurrentTrace( name );
604 }
605 }
606 catch( const IO_ERROR& e )
607 {
609 }
610 }
611 else if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T } )
612 || item->IsType( { SCH_JUNCTION_T } ) )
613 {
614 if( SCH_CONNECTION* conn = static_cast<SCH_ITEM*>( item )->Connection() )
615 {
616 wxString spiceNet = UnescapeString( conn->Name() );
618
619 simFrame->AddVoltageTrace( wxString::Format( "V(%s)", spiceNet ) );
620 }
621 }
622
623 return true;
624 } );
625
626 picker->SetMotionHandler(
627 [this, picker]( const VECTOR2D& aPos )
628 {
629 EE_COLLECTOR collector;
630 collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
631 collector.Collect( m_frame->GetScreen(), { SCH_ITEM_LOCATE_WIRE_T,
632 SCH_PIN_T,
633 SCH_SHEET_PIN_T }, aPos );
634
636 selectionTool->GuessSelectionCandidates( collector, aPos );
637
638 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
639 SCH_LINE* wire = dynamic_cast<SCH_LINE*>( item );
640
641 const SCH_CONNECTION* conn = nullptr;
642
643 if( wire )
644 {
645 item = nullptr;
646 conn = wire->Connection();
647 }
648
649 if( item && item->Type() == SCH_PIN_T )
650 picker->SetCursor( KICURSOR::CURRENT_PROBE );
651 else
652 picker->SetCursor( KICURSOR::VOLTAGE_PROBE );
653
654 if( m_pickerItem != item )
655 {
656 if( m_pickerItem )
657 selectionTool->UnbrightenItem( m_pickerItem );
658
659 m_pickerItem = item;
660
661 if( m_pickerItem )
662 selectionTool->BrightenItem( m_pickerItem );
663 }
664
665 wxString connectionName = ( conn ) ? conn->Name() : wxString( wxS( "" ) );
666
667 if( m_frame->GetHighlightedConnection() != connectionName )
668 {
669 m_frame->SetHighlightedConnection( connectionName );
670
671 TOOL_EVENT dummyEvent;
672 UpdateNetHighlighting( dummyEvent );
673 }
674 } );
675
676 picker->SetFinalizeHandler(
677 [this]( const int& aFinalState )
678 {
679 if( m_pickerItem )
680 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
681
682 if( !m_frame->GetHighlightedConnection().IsEmpty() )
683 {
684 m_frame->SetHighlightedConnection( wxEmptyString );
685
686 TOOL_EVENT dummyEvent;
687 UpdateNetHighlighting( dummyEvent );
688 }
689
690 // Wake the selection tool after exiting to ensure the cursor gets updated
692 } );
693
695
696 return 0;
697}
698
699
701{
703
704 // Deactivate other tools; particularly important if another PICKER is currently running
705 Activate();
706
707 picker->SetCursor( KICURSOR::TUNE );
708 picker->SetSnapping( false );
709
710 picker->SetClickHandler(
711 [this]( const VECTOR2D& aPosition )
712 {
714 EDA_ITEM* item = nullptr;
715 selTool->SelectPoint( aPosition, { SCH_SYMBOL_T, SCH_FIELD_T }, &item );
716
717 if( !item )
718 return false;
719
720 if( item->Type() != SCH_SYMBOL_T )
721 {
722 item = item->GetParent();
723
724 if( item->Type() != SCH_SYMBOL_T )
725 return false;
726 }
727
728 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
729 SCH_SHEET_PATH sheetPath = symbol->Schematic()->CurrentSheet();
730 KIWAY_PLAYER* simFrame = m_frame->Kiway().Player( FRAME_SIMULATOR, false );
731
732 if( simFrame )
733 {
734 if( wxWindow* blocking_win = simFrame->Kiway().GetBlockingDialog() )
735 blocking_win->Close( true );
736
737 static_cast<SIMULATOR_FRAME*>( simFrame )->AddTuner( sheetPath, symbol );
738 }
739
740 // We do not really want to keep a symbol selected in schematic,
741 // so clear the current selection
742 selTool->ClearSelection();
743 return true;
744 } );
745
746 picker->SetMotionHandler(
747 [this]( const VECTOR2D& aPos )
748 {
749 EE_COLLECTOR collector;
750 collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
751 collector.Collect( m_frame->GetScreen(), { SCH_SYMBOL_T, SCH_FIELD_T }, aPos );
752
754 selectionTool->GuessSelectionCandidates( collector, aPos );
755
756 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
757
758 if( m_pickerItem != item )
759 {
760 if( m_pickerItem )
761 selectionTool->UnbrightenItem( m_pickerItem );
762
763 m_pickerItem = item;
764
765 if( m_pickerItem )
766 selectionTool->BrightenItem( m_pickerItem );
767 }
768 } );
769
770 picker->SetFinalizeHandler(
771 [this]( const int& aFinalState )
772 {
773 if( m_pickerItem )
774 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
775
776 // Wake the selection tool after exiting to ensure the cursor gets updated
777 // and deselect previous selection from simulator to avoid any issue
778 // ( avoid crash in some cases when the SimTune tool is deselected )
780 selectionTool->ClearSelection();
782 } );
783
785
786 return 0;
787}
788
789
790// A singleton reference for clearing the highlight
792
793
794static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
795{
796 SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetToolHolder() );
797 EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
798 SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
799 SCH_CONNECTION* conn = nullptr;
800 SCH_ITEM* item = nullptr;
801 bool retVal = true;
802
803 if( aPosition != CLEAR )
804 {
805 ERC_TESTER erc( &editFrame->Schematic() );
806
807 if( erc.TestDuplicateSheetNames( false ) > 0 )
808 {
809 wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
810 retVal = false;
811 }
812 else
813 {
814 item = static_cast<SCH_ITEM*>( selTool->GetNode( aPosition ) );
815 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
816
817 if( item )
818 {
819 if( item->IsConnectivityDirty() )
820 editFrame->RecalculateConnections( nullptr, NO_CLEANUP );
821
822 if( item->Type() == SCH_FIELD_T )
823 symbol = dynamic_cast<SCH_SYMBOL*>( item->GetParent() );
824
825 if( symbol && symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsPower() )
826 {
827 std::vector<SCH_PIN*> pins = symbol->GetPins();
828
829 if( pins.size() == 1 )
830 conn = pins[0]->Connection();
831 }
832 else
833 {
834 conn = item->Connection();
835 }
836 }
837 }
838 }
839
840 wxString connName = ( conn ) ? conn->Name() : wxString( wxS( "" ) );
841
842 if( !conn )
843 {
844 editFrame->SetStatusText( wxT( "" ) );
845 editFrame->SendCrossProbeClearHighlight();
846 editFrame->SetHighlightedConnection( wxEmptyString );
847 editorControl->SetHighlightBusMembers( false );
848 }
849 else
850 {
851 NET_NAVIGATOR_ITEM_DATA itemData( editFrame->GetCurrentSheet(), item );
852
853 if( connName != editFrame->GetHighlightedConnection() )
854 {
855 editorControl->SetHighlightBusMembers( false );
856 editFrame->SetCrossProbeConnection( conn );
857 editFrame->SetHighlightedConnection( connName, &itemData );
858 }
859 else
860 {
861 editorControl->SetHighlightBusMembers( !editorControl->GetHighlightBusMembers() );
862
863 if( item != editFrame->GetSelectedNetNavigatorItem() )
864 editFrame->SelectNetNavigatorItem( &itemData );
865 }
866 }
867
868 editFrame->UpdateNetHighlightStatus();
869
871 editorControl->UpdateNetHighlighting( dummy );
872
873 return retVal;
874}
875
876
878{
880 VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
881
882 highlightNet( m_toolMgr, cursorPos );
883
884 return 0;
885}
886
887
889{
891
892 return 0;
893}
894
895
897{
899 SCHEMATIC& schematic = m_frame->Schematic();
901
902 const SCH_CONNECTION* conn = nullptr;
903 VECTOR2D connPos;
904
905 for( EDA_ITEM* item : selectionTool->GetSelection() )
906 {
907 conn = static_cast<SCH_ITEM*>( item )->Connection();
908 connPos = item->GetPosition();
909
910 if( conn )
911 break;
912 }
913
914 if( !conn )
915 {
916 m_frame->ShowInfoBarError( _( "No net selected." ) );
917 return 0;
918 }
919
920 // Remove selection in favor of highlighting so the whole net is highlighted
921 selectionTool->ClearSelection();
922 highlightNet( m_toolMgr, connPos );
923
924 wxString netName = conn->Name();
925
926 if( conn->IsBus() )
927 {
928 wxString prefix;
929
930 if( NET_SETTINGS::ParseBusVector( netName, &prefix, nullptr ) )
931 {
932 netName = prefix + wxT( "*" );
933 }
934 else if( NET_SETTINGS::ParseBusGroup( netName, &prefix, nullptr ) )
935 {
936 netName = prefix + wxT( ".*" );
937 }
938 }
939 else if( !conn->Driver() || CONNECTION_SUBGRAPH::GetDriverPriority( conn->Driver() )
941 {
942 m_frame->ShowInfoBarError( _( "Net must be labeled to assign a netclass." ) );
944 return 0;
945 }
946
947 DIALOG_ASSIGN_NETCLASS dlg( m_frame, netName, schematic.GetNetClassAssignmentCandidates(),
948 [&]( const std::vector<wxString>& aNetNames )
949 {
950 for( SCH_ITEM* item : screen->Items() )
951 {
952 bool redraw = item->IsBrightened();
953 SCH_CONNECTION* itemConn = item->Connection();
954
955 if( itemConn && alg::contains( aNetNames, itemConn->Name() ) )
956 item->SetBrightened();
957 else
958 item->ClearBrightened();
959
960 redraw |= item->IsBrightened();
961
962 if( item->Type() == SCH_SYMBOL_T )
963 {
964 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
965
966 redraw |= symbol->HasBrightenedPins();
967
968 symbol->ClearBrightenedPins();
969
970 for( SCH_PIN* pin : symbol->GetPins() )
971 {
972 SCH_CONNECTION* pin_conn = pin->Connection();
973
974 if( pin_conn && alg::contains( aNetNames, pin_conn->Name() ) )
975 {
976 pin->SetBrightened();
977 redraw = true;
978 }
979 }
980 }
981 else if( item->Type() == SCH_SHEET_T )
982 {
983 for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
984 {
985 SCH_CONNECTION* pin_conn = pin->Connection();
986
987 redraw |= pin->IsBrightened();
988
989 if( pin_conn && alg::contains( aNetNames, pin_conn->Name() ) )
990 pin->SetBrightened();
991 else
992 pin->ClearBrightened();
993
994 redraw |= pin->IsBrightened();
995 }
996 }
997
998 if( redraw )
999 getView()->Update( item, KIGFX::VIEW_UPDATE_FLAGS::REPAINT );
1000 }
1001
1003 } );
1004
1005 if( dlg.ShowModal() )
1006 {
1007 getView()->UpdateAllItemsConditionally(
1008 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1009 {
1010 int flags = 0;
1011
1012 auto invalidateTextVars =
1013 [&flags]( EDA_TEXT* text )
1014 {
1015 if( text->HasTextVars() )
1016 {
1017 text->ClearRenderCache();
1018 text->ClearBoundingBoxCache();
1020 }
1021 };
1022
1023 // Netclass coloured items
1024 //
1025 if( dynamic_cast<SCH_LINE*>( aItem ) )
1026 flags |= KIGFX::REPAINT;
1027 else if( dynamic_cast<SCH_JUNCTION*>( aItem ) )
1028 flags |= KIGFX::REPAINT;
1029 else if( dynamic_cast<SCH_BUS_ENTRY_BASE*>( aItem ) )
1030 flags |= KIGFX::REPAINT;
1031
1032 // Items that might reference an item's netclass name
1033 //
1034 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
1035 {
1036 item->RunOnChildren(
1037 [&invalidateTextVars]( SCH_ITEM* aChild )
1038 {
1039 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
1040 invalidateTextVars( text );
1041 } );
1042
1043 if( flags & KIGFX::GEOMETRY )
1044 m_frame->GetScreen()->Update( item, false ); // Refresh RTree
1045 }
1046
1047 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1048 invalidateTextVars( text );
1049
1050 return flags;
1051 } );
1052 }
1053
1054 highlightNet( m_toolMgr, CLEAR );
1055 return 0;
1056}
1057
1058
1060{
1061 wxCHECK( m_frame, 0 );
1062
1063 const SCH_SHEET_PATH& sheetPath = m_frame->GetCurrentSheet();
1065 CONNECTION_GRAPH* connectionGraph = m_frame->Schematic().ConnectionGraph();
1066 wxString selectedName = m_frame->GetHighlightedConnection();
1067
1068 std::set<wxString> connNames;
1069 std::vector<EDA_ITEM*> itemsToRedraw;
1070
1071 wxCHECK( screen && connectionGraph, 0 );
1072
1073 if( !selectedName.IsEmpty() )
1074 {
1075 connNames.emplace( selectedName );
1076
1077 CONNECTION_SUBGRAPH* sg = connectionGraph->FindSubgraphByName( selectedName, sheetPath );
1078
1079 if( sg && m_highlightBusMembers )
1080 {
1081 for( const SCH_ITEM* item : sg->GetItems() )
1082 {
1083 wxCHECK2( item, continue );
1084
1085 if( SCH_CONNECTION* connection = item->Connection() )
1086 {
1087 for( const std::shared_ptr<SCH_CONNECTION>& member : connection->AllMembers() )
1088 {
1089 if( member )
1090 connNames.emplace( member->Name() );
1091 }
1092 }
1093 }
1094 }
1095 }
1096
1097 for( SCH_ITEM* item : screen->Items() )
1098 {
1099 wxCHECK2( item, continue );
1100
1101 if( !item->IsConnectable() )
1102 continue;
1103
1104 SCH_ITEM* redrawItem = nullptr;
1105
1106 if( item->Type() == SCH_SYMBOL_T )
1107 {
1108 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1109
1110 for( SCH_PIN* pin : symbol->GetPins() )
1111 {
1112 if( SCH_CONNECTION* pin_conn = pin->Connection() )
1113 {
1114 if( !pin->IsBrightened() && connNames.count( pin_conn->Name() ) )
1115 {
1116 pin->SetBrightened();
1117 redrawItem = symbol;
1118 }
1119 else if( pin->IsBrightened() && !connNames.count( pin_conn->Name() ) )
1120 {
1121 pin->ClearBrightened();
1122 redrawItem = symbol;
1123 }
1124 }
1125 }
1126
1127 if( symbol->IsPower() && symbol->GetPins().size() )
1128 {
1129 if( SCH_CONNECTION* pinConn = symbol->GetPins()[0]->Connection() )
1130 {
1131 std::vector<SCH_FIELD>& fields = symbol->GetFields();
1132
1133 for( int id : { REFERENCE_FIELD, VALUE_FIELD } )
1134 {
1135 if( !fields[id].IsVisible() )
1136 continue;
1137
1138 if( !fields[id].IsBrightened() && connNames.count( pinConn->Name() ) )
1139 {
1140 fields[id].SetBrightened();
1141 redrawItem = symbol;
1142 }
1143 else if( fields[id].IsBrightened() && !connNames.count( pinConn->Name() ) )
1144 {
1145 fields[id].ClearBrightened();
1146 redrawItem = symbol;
1147 }
1148 }
1149 }
1150 }
1151 }
1152 else if( item->Type() == SCH_SHEET_T )
1153 {
1154 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1155
1156 for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1157 {
1158 wxCHECK2( pin, continue );
1159
1160 if( SCH_CONNECTION* pin_conn = pin->Connection() )
1161 {
1162 if( !pin->IsBrightened() && connNames.count( pin_conn->Name() ) )
1163 {
1164 pin->SetBrightened();
1165 redrawItem = sheet;
1166 }
1167 else if( pin->IsBrightened() && !connNames.count( pin_conn->Name() ) )
1168 {
1169 pin->ClearBrightened();
1170 redrawItem = sheet;
1171 }
1172 }
1173 }
1174 }
1175 else
1176 {
1177 if( SCH_CONNECTION* itemConn = item->Connection() )
1178 {
1179 if( !item->IsBrightened() && connNames.count( itemConn->Name() ) )
1180 {
1181 item->SetBrightened();
1182 redrawItem = item;
1183 }
1184 else if( item->IsBrightened() && !connNames.count( itemConn->Name() ) )
1185 {
1186 item->ClearBrightened();
1187 redrawItem = item;
1188 }
1189 }
1190 }
1191
1192 if( redrawItem )
1193 itemsToRedraw.push_back( redrawItem );
1194 }
1195
1196 if( itemsToRedraw.size() )
1197 {
1198 // Be sure highlight change will be redrawn
1199 KIGFX::VIEW* view = getView();
1200
1201 for( EDA_ITEM* redrawItem : itemsToRedraw )
1203
1205 }
1206
1207 return 0;
1208}
1209
1210
1212{
1214
1215 // Deactivate other tools; particularly important if another PICKER is currently running
1216 Activate();
1217
1218 picker->SetCursor( KICURSOR::BULLSEYE );
1219 picker->SetSnapping( false );
1220
1221 picker->SetClickHandler(
1222 [this] ( const VECTOR2D& aPos )
1223 {
1224 return highlightNet( m_toolMgr, aPos );
1225 } );
1226
1228
1229 return 0;
1230}
1231
1232
1234{
1235 wxCHECK( m_frame, 0 );
1236
1237 if( m_frame->GetUndoCommandCount() <= 0 )
1238 return 0;
1239
1240 // Inform tools that undo command was issued
1242
1243 // Get the old list
1245
1246 wxCHECK( undo_list, 0 );
1247
1248 m_frame->PutDataInPreviousState( undo_list );
1249
1250 // Now push the old command to the RedoList
1251 undo_list->ReversePickersListOrder();
1252 m_frame->PushCommandToRedoList( undo_list );
1253
1254 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1255
1257 m_frame->OnModify();
1258
1259 return 0;
1260}
1261
1262
1264{
1265 wxCHECK( m_frame, 0 );
1266
1267 if( m_frame->GetRedoCommandCount() == 0 )
1268 return 0;
1269
1270 // Inform tools that undo command was issued
1272
1273 /* Get the old list */
1275
1276 wxCHECK( list, 0 );
1277
1278 /* Redo the command: */
1280
1281 /* Put the old list in UndoList */
1284
1285 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1286
1288 m_frame->OnModify();
1289
1290 return 0;
1291}
1292
1293
1294bool SCH_EDITOR_CONTROL::doCopy( bool aUseDuplicateClipboard )
1295{
1297 EE_SELECTION& selection = selTool->RequestSelection();
1298 SCHEMATIC& schematic = m_frame->Schematic();
1299
1300 if( selection.Empty() )
1301 return false;
1302
1303 if( aUseDuplicateClipboard )
1304 m_duplicateIsHoverSelection = selection.IsHover();
1305
1306 selection.SetScreen( m_frame->GetScreen() );
1308
1309 for( EDA_ITEM* item : selection )
1310 {
1311 if( item->Type() == SCH_SHEET_T )
1312 {
1313 SCH_SHEET* sheet = (SCH_SHEET*) item;
1314 m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
1315 }
1316 else if( item->Type() == SCH_FIELD_T && selection.IsHover() )
1317 {
1318 // Most of the time the user is trying to duplicate the parent symbol
1319 // and the field text is in it
1320 selection.Add( item->GetParent() );
1321 }
1322 else if( item->Type() == SCH_MARKER_T )
1323 {
1324 // Don't let the markers be copied
1325 selection.Remove( item );
1326 }
1327 }
1328
1329 STRING_FORMATTER formatter;
1330 SCH_IO_KICAD_SEXPR plugin;
1332
1333 plugin.Format( &selection, &selPath, schematic, &formatter, true );
1334
1335 if( selection.IsHover() )
1337
1338 if( aUseDuplicateClipboard )
1339 {
1340 m_duplicateClipboard = formatter.GetString();
1341 return true;
1342 }
1343
1344 return SaveClipboard( formatter.GetString() );
1345}
1346
1347
1348bool SCH_EDITOR_CONTROL::searchSupplementaryClipboard( const wxString& aSheetFilename,
1349 SCH_SCREEN** aScreen )
1350{
1351 if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
1352 {
1353 *aScreen = m_supplementaryClipboard[ aSheetFilename ];
1354 return true;
1355 }
1356
1357 return false;
1358}
1359
1360
1362{
1363 doCopy( true ); // Use the local clipboard
1364 Paste( aEvent );
1365
1366 return 0;
1367}
1368
1369
1371{
1372 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1373
1374 if( textEntry )
1375 {
1376 textEntry->Cut();
1377 return 0;
1378 }
1379
1380 if( doCopy() )
1382
1383 return 0;
1384}
1385
1386
1388{
1389 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1390
1391 if( textEntry )
1392 {
1393 textEntry->Copy();
1394 return 0;
1395 }
1396
1397 doCopy();
1398
1399 return 0;
1400}
1401
1402
1404{
1406 EE_SELECTION& selection = selTool->RequestSelection();
1407
1408 if( selection.Empty() )
1409 return false;
1410
1411 wxString itemsAsText = GetSelectedItemsAsText( selection );
1412
1413 if( selection.IsHover() )
1415
1416 return SaveClipboard( itemsAsText.ToStdString() );
1417}
1418
1419
1421 const SCH_SHEET_PATH& aPastePath,
1422 const KIID_PATH& aClipPath,
1423 bool aForceKeepAnnotations )
1424{
1425 wxCHECK( m_frame && aSymbol, /* void */ );
1426
1427 SCH_SYMBOL_INSTANCE newInstance;
1428 bool instanceFound = false;
1429 KIID_PATH pasteLookupPath = aClipPath;
1430
1431 m_pastedSymbols.insert( aSymbol );
1432
1433 for( const SCH_SYMBOL_INSTANCE& tmp : aSymbol->GetInstances() )
1434 {
1435 if( ( tmp.m_Path.empty() && aClipPath.empty() )
1436 || ( !aClipPath.empty() && tmp.m_Path.EndsWith( aClipPath ) ) )
1437 {
1438 newInstance = tmp;
1439 instanceFound = true;
1440
1441 wxLogTrace( traceSchPaste,
1442 wxS( "Pasting found symbol instance with reference %s, unit %d:"
1443 "\n\tClipboard path: %s\n\tSymbol UUID: %s." ),
1444 tmp.m_Reference, tmp.m_Unit,
1445 aClipPath.AsString(), aSymbol->m_Uuid.AsString() );
1446
1447 break;
1448 }
1449 }
1450
1451 // The pasted symbol look up paths include the symbol UUID.
1452 pasteLookupPath.push_back( aSymbol->m_Uuid );
1453
1454 if( !instanceFound )
1455 {
1456 wxLogTrace( traceSchPaste,
1457 wxS( "Clipboard symbol instance **not** found:\n\tClipboard path: %s\n\t"
1458 "Symbol UUID: %s." ),
1459 aClipPath.AsString(), aSymbol->m_Uuid.AsString() );
1460
1461 // Some legacy versions saved value fields escaped. While we still do in the symbol
1462 // editor, we don't anymore in the schematic, so be sure to unescape them.
1463 SCH_FIELD* valueField = aSymbol->GetField( VALUE_FIELD );
1464 valueField->SetText( UnescapeString( valueField->GetText() ) );
1465
1466 // Pasted from notepad or an older instance of eeschema. Use the values in the fields
1467 // instead.
1468 newInstance.m_Reference = aSymbol->GetField( REFERENCE_FIELD )->GetText();
1469 newInstance.m_Unit = aSymbol->GetUnit();
1470 }
1471
1472 newInstance.m_Path = aPastePath.Path();
1473 newInstance.m_ProjectName = m_frame->Prj().GetProjectName();
1474
1475 aSymbol->AddHierarchicalReference( newInstance );
1476
1477 if( !aForceKeepAnnotations )
1478 aSymbol->ClearAnnotation( &aPastePath, false );
1479
1480 // We might clear annotations but always leave the original unit number from the paste.
1481 aSymbol->SetUnit( newInstance.m_Unit );
1482}
1483
1484
1486 const SCH_SHEET_PATH& aPastePath,
1487 const KIID_PATH& aClipPath,
1488 bool aForceKeepAnnotations,
1489 SCH_SHEET_LIST* aPastedSheets,
1490 std::map<SCH_SHEET_PATH,
1491 SCH_REFERENCE_LIST>& aPastedSymbols )
1492{
1493 wxCHECK( aSheet && aPastedSheets, aPastePath );
1494
1495 SCH_SHEET_PATH sheetPath = aPastePath;
1496 sheetPath.push_back( aSheet );
1497
1498 aPastedSheets->push_back( sheetPath );
1499
1500 if( aSheet->GetScreen() == nullptr )
1501 return sheetPath; // We can only really set the page number but not load any items
1502
1503 for( SCH_ITEM* item : aSheet->GetScreen()->Items() )
1504 {
1505 if( item->IsConnectable() )
1506 item->SetConnectivityDirty();
1507
1508 if( item->Type() == SCH_SYMBOL_T )
1509 {
1510 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1511
1512 wxCHECK2( symbol, continue );
1513
1514 // Only do this once if the symbol is shared across multiple sheets.
1515 if( !m_pastedSymbols.count( symbol ) )
1516 {
1517 for( SCH_PIN* pin : symbol->GetPins() )
1518 {
1519 const_cast<KIID&>( pin->m_Uuid ) = KIID();
1520 pin->SetConnectivityDirty();
1521 }
1522 }
1523
1524 updatePastedSymbol( symbol, sheetPath, aClipPath, aForceKeepAnnotations );
1525 }
1526 else if( item->Type() == SCH_SHEET_T )
1527 {
1528 SCH_SHEET* subsheet = static_cast<SCH_SHEET*>( item );
1529
1530 wxCHECK2( subsheet, continue );
1531
1532 // Make sure pins get a new UUID and set the dirty connectivity flag.
1533 if( !aPastedSheets->ContainsSheet( subsheet ) )
1534 {
1535 for( SCH_SHEET_PIN* pin : subsheet->GetPins() )
1536 {
1537 const_cast<KIID&>( pin->m_Uuid ) = KIID();
1538 pin->SetConnectivityDirty();
1539 }
1540 }
1541
1542 KIID_PATH newClipPath = aClipPath;
1543 newClipPath.push_back( subsheet->m_Uuid );
1544
1545 updatePastedSheet( subsheet, sheetPath, newClipPath, aForceKeepAnnotations,
1546 aPastedSheets, aPastedSymbols );
1547 }
1548 }
1549
1550 sheetPath.GetSymbols( aPastedSymbols[aPastePath] );
1551
1552 return sheetPath;
1553}
1554
1555
1557{
1558 wxCHECK( aScreen, /* void */ );
1559
1560 for( const SCH_ITEM* item : aScreen->Items() )
1561 {
1562 if( item->Type() == SCH_SYMBOL_T )
1563 {
1564 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( item );
1565
1566 wxCHECK2( symbol, continue );
1567
1568 for( const SCH_SYMBOL_INSTANCE& symbolInstance : symbol->GetInstances() )
1569 {
1570 KIID_PATH pathWithSymbol = symbolInstance.m_Path;
1571
1572 pathWithSymbol.push_back( symbol->m_Uuid );
1573
1574 m_clipboardSymbolInstances[pathWithSymbol] = symbolInstance;
1575 }
1576 }
1577 }
1578}
1579
1580
1582{
1583 wxCHECK( m_frame, /* void */ );
1584
1585 for( SCH_SYMBOL* symbol : m_pastedSymbols )
1586 {
1587 wxCHECK2( symbol, continue );
1588
1589 std::vector<KIID_PATH> instancePathsToRemove;
1590
1591 for( const SCH_SYMBOL_INSTANCE& instance : symbol->GetInstances() )
1592 {
1593 if( ( instance.m_ProjectName != m_frame->Prj().GetProjectName() )
1594 || instance.m_Path.empty() )
1595 instancePathsToRemove.emplace_back( instance.m_Path );
1596 }
1597
1598 for( const KIID_PATH& path : instancePathsToRemove )
1599 symbol->RemoveInstance( path );
1600 }
1601}
1602
1603
1605{
1606 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1607
1608 if( textEntry )
1609 {
1610 textEntry->Paste();
1611 return 0;
1612 }
1613
1615 std::string content;
1616 VECTOR2I eventPos;
1617
1618 SCH_SHEET tempSheet;
1619 SCH_SCREEN* tempScreen = new SCH_SCREEN( &m_frame->Schematic() );
1620
1621 if( std::unique_ptr<wxImage> clipImg = GetImageFromClipboard() )
1622 {
1623 // Just image data
1624 auto bitmap = std::make_unique<SCH_BITMAP>();
1625 bitmap->GetReferenceImage().SetImage( *clipImg );
1626
1627 tempScreen->Append( bitmap.release() );
1628 }
1629 else
1630 {
1631 if( aEvent.IsAction( &ACTIONS::duplicate ) )
1632 content = m_duplicateClipboard;
1633 else
1634 content = GetClipboardUTF8();
1635
1636 if( content.empty() )
1637 {
1638 delete tempScreen;
1639 return 0;
1640 }
1641
1642 if( aEvent.IsAction( &ACTIONS::duplicate ) )
1643 eventPos = getViewControls()->GetCursorPosition( false );
1644
1645 STRING_LINE_READER reader( content, "Clipboard" );
1646 SCH_IO_KICAD_SEXPR plugin;
1647
1648 // Screen object on heap is owned by the sheet.
1649 tempSheet.SetScreen( tempScreen );
1650
1651 try
1652 {
1653 plugin.LoadContent( reader, &tempSheet );
1654 }
1655 catch( IO_ERROR& )
1656 {
1657 // If it wasn't content, then paste as a text object.
1658 SCH_TEXT* text_item = new SCH_TEXT( VECTOR2I( 0, 0 ), content );
1659 tempScreen->Append( text_item );
1660 }
1661 }
1662
1663 m_pastedSymbols.clear();
1665
1666 // Save pasted symbol instances in case the user chooses to keep existing symbol annotation.
1667 setPastedSymbolInstances( tempScreen );
1668
1669 tempScreen->MigrateSimModels();
1670
1672 int annotateStartNum = m_frame->Schematic().Settings().m_AnnotateStartNum;
1673
1674 PASTE_MODE pasteMode = annotate.automatic ? PASTE_MODE::RESPECT_OPTIONS
1675 : PASTE_MODE::REMOVE_ANNOTATIONS;
1676
1677 if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1678 {
1679 DIALOG_PASTE_SPECIAL dlg( m_frame, &pasteMode );
1680
1681 if( dlg.ShowModal() == wxID_CANCEL )
1682 return 0;
1683 }
1684
1685 bool forceKeepAnnotations = pasteMode != PASTE_MODE::REMOVE_ANNOTATIONS;
1686
1687 // SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
1688 // else. Pull them back out to start with.
1689 SCH_COMMIT commit( m_toolMgr );
1690 EDA_ITEMS loadedItems;
1691 std::vector<SCH_ITEM*> sortedLoadedItems;
1692 bool sheetsPasted = false;
1693 SCH_SHEET_LIST hierarchy = m_frame->Schematic().Hierarchy();
1694 SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
1695 wxFileName destFn = pasteRoot.Last()->GetFileName();
1696
1697 if( destFn.IsRelative() )
1698 destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1699
1700 // List of paths in the hierarchy that refer to the destination sheet of the paste
1701 SCH_SHEET_LIST sheetPathsForScreen = hierarchy.FindAllSheetsForScreen( pasteRoot.LastScreen() );
1702 sheetPathsForScreen.SortByPageNumbers();
1703
1704 // Build a list of screens from the current design (to avoid loading sheets that already exist)
1705 std::map<wxString, SCH_SCREEN*> loadedScreens;
1706
1707 for( const SCH_SHEET_PATH& item : hierarchy )
1708 {
1709 if( item.LastScreen() )
1710 loadedScreens[item.Last()->GetFileName()] = item.LastScreen();
1711 }
1712
1713 // Build symbol list for reannotation of duplicates
1714 SCH_REFERENCE_LIST existingRefs;
1715 hierarchy.GetSymbols( existingRefs );
1716 existingRefs.SortByReferenceOnly();
1717
1718 // Build UUID map for fetching last-resolved-properties
1719 std::map<KIID, EDA_ITEM*> itemMap;
1720 hierarchy.FillItemMap( itemMap );
1721
1722 // Keep track of pasted sheets and symbols for the different paths to the hierarchy.
1723 std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> pastedSymbols;
1724 std::map<SCH_SHEET_PATH, SCH_SHEET_LIST> pastedSheets;
1725
1726 for( SCH_ITEM* item : tempScreen->Items() )
1727 {
1728 if( item->Type() == SCH_SHEET_T )
1729 sortedLoadedItems.push_back( item );
1730 else
1731 loadedItems.push_back( item );
1732 }
1733
1734 sort( sortedLoadedItems.begin(), sortedLoadedItems.end(),
1735 []( SCH_ITEM* firstItem, SCH_ITEM* secondItem )
1736 {
1737 SCH_SHEET* firstSheet = static_cast<SCH_SHEET*>( firstItem );
1738 SCH_SHEET* secondSheet = static_cast<SCH_SHEET*>( secondItem );
1739 return StrNumCmp( firstSheet->GetName(), secondSheet->GetName(), false ) < 0;
1740 });
1741
1742
1743 for( SCH_ITEM* item : sortedLoadedItems )
1744 {
1745 loadedItems.push_back( item );
1746
1747 if( item->Type() == SCH_SHEET_T )
1748 {
1749 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1750 SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1751 wxString baseName = nameField.GetText();
1752 wxFileName srcFn = sheet->GetFileName();
1753
1754 if( srcFn.IsRelative() )
1755 srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1756
1757 SCH_SHEET_LIST sheetHierarchy( sheet );
1758
1759 if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1760 {
1761 auto msg = wxString::Format( _( "The pasted sheet '%s'\n"
1762 "was dropped because the destination already has "
1763 "the sheet or one of its subsheets as a parent." ),
1764 sheet->GetFileName() );
1765 DisplayError( m_frame, msg );
1766 loadedItems.pop_back();
1767 }
1768 }
1769 }
1770
1771 // Remove the references from our temporary screen to prevent freeing on the DTOR
1772 tempScreen->Clear( false );
1773
1774 for( EDA_ITEM* item : loadedItems )
1775 {
1776 KIID_PATH clipPath( wxT( "/" ) ); // clipboard is at root
1777
1778 SCH_ITEM* schItem = static_cast<SCH_ITEM*>( item );
1779
1780 wxCHECK2( schItem, continue );
1781
1782 if( schItem->IsConnectable() )
1783 schItem->SetConnectivityDirty();
1784
1785 if( item->Type() == SCH_SYMBOL_T )
1786 {
1787 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1788
1789 // The library symbol gets set from the cached library symbols in the current
1790 // schematic not the symbol libraries. The cached library symbol may have
1791 // changed from the original library symbol which would cause the copy to
1792 // be incorrect.
1793 SCH_SCREEN* currentScreen = m_frame->GetScreen();
1794
1795 wxCHECK2( currentScreen, continue );
1796
1797 auto it = currentScreen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1798 auto end = currentScreen->GetLibSymbols().end();
1799
1800 if( it == end )
1801 {
1802 // If can't find library definition in the design, use the pasted library
1803 it = tempScreen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1804 end = tempScreen->GetLibSymbols().end();
1805 }
1806
1807 LIB_SYMBOL* libSymbol = nullptr;
1808
1809 if( it != end )
1810 {
1811 libSymbol = new LIB_SYMBOL( *it->second );
1812 symbol->SetLibSymbol( libSymbol );
1813 }
1814
1815 for( SCH_SHEET_PATH& sheetPath : sheetPathsForScreen )
1816 updatePastedSymbol( symbol, sheetPath, clipPath, forceKeepAnnotations );
1817
1818 // Assign a new KIID
1819 const_cast<KIID&>( item->m_Uuid ) = KIID();
1820
1821 // Make sure pins get a new UUID
1822 for( SCH_PIN* pin : symbol->GetPins() )
1823 {
1824 const_cast<KIID&>( pin->m_Uuid ) = KIID();
1825 pin->SetConnectivityDirty();
1826 }
1827
1828 for( SCH_SHEET_PATH& sheetPath : sheetPathsForScreen )
1829 {
1830 // Ignore symbols from a non-existant library.
1831 if( libSymbol )
1832 {
1833 SCH_REFERENCE schReference( symbol, sheetPath );
1834 schReference.SetSheetNumber( sheetPath.GetVirtualPageNumber() );
1835 pastedSymbols[sheetPath].AddItem( schReference );
1836 }
1837 }
1838 }
1839 else if( item->Type() == SCH_SHEET_T )
1840 {
1841 SCH_SHEET* sheet = (SCH_SHEET*) item;
1842 SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1843 wxString baseName = nameField.GetText();
1844 wxString candidateName = baseName;
1845 wxString number;
1846
1847 while( !baseName.IsEmpty() && wxIsdigit( baseName.Last() ) )
1848 {
1849 number = baseName.Last() + number;
1850 baseName.RemoveLast();
1851 }
1852
1853 // Update hierarchy to include any other sheets we already added, avoiding
1854 // duplicate sheet names
1855 hierarchy = m_frame->Schematic().Hierarchy();
1856
1857 //@todo: it might be better to just iterate through the sheet names
1858 // in this screen instead of the whole hierarchy.
1859 int uniquifier = std::max( 0, wxAtoi( number ) ) + 1;
1860
1861 while( hierarchy.NameExists( candidateName ) )
1862 candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
1863
1864 nameField.SetText( candidateName );
1865
1866 wxFileName fn = sheet->GetFileName();
1867 SCH_SCREEN* existingScreen = nullptr;
1868
1869 sheet->SetParent( pasteRoot.Last() );
1870 sheet->SetScreen( nullptr );
1871
1872 if( !fn.IsAbsolute() )
1873 {
1874 wxFileName currentSheetFileName = pasteRoot.LastScreen()->GetFileName();
1875 fn.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS,
1876 currentSheetFileName.GetPath() );
1877 }
1878
1879 // Try to find the screen for the pasted sheet by several means
1880 if( !m_frame->Schematic().Root().SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ),
1881 &existingScreen ) )
1882 {
1883 if( loadedScreens.count( sheet->GetFileName() ) > 0 )
1884 existingScreen = loadedScreens.at( sheet->GetFileName() );
1885 else
1886 searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1887 }
1888
1889 if( existingScreen )
1890 {
1891 sheet->SetScreen( existingScreen );
1892 }
1893 else
1894 {
1895 if( !m_frame->LoadSheetFromFile( sheet, &pasteRoot, fn.GetFullPath() ) )
1896 m_frame->InitSheet( sheet, sheet->GetFileName() );
1897 }
1898
1899 // Save the symbol instances in case the user chooses to keep the existing
1900 // symbol annotation.
1902 sheetsPasted = true;
1903
1904 // Push it to the clipboard path while it still has its old KIID
1905 clipPath.push_back( sheet->m_Uuid );
1906
1907 // Assign a new KIID to the pasted sheet
1908 const_cast<KIID&>( sheet->m_Uuid ) = KIID();
1909
1910 // Make sure pins get a new UUID
1911 for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1912 {
1913 const_cast<KIID&>( pin->m_Uuid ) = KIID();
1914 pin->SetConnectivityDirty();
1915 }
1916
1917 // Once we have our new KIID we can update all pasted instances. This will either
1918 // reset the annotations or copy "kept" annotations from the supplementary clipboard.
1919 for( SCH_SHEET_PATH& sheetPath : sheetPathsForScreen )
1920 {
1921 SCH_SHEET_PATH subPath = updatePastedSheet( sheet, sheetPath, clipPath,
1922 ( forceKeepAnnotations && annotate.automatic ),
1923 &pastedSheets[sheetPath],
1924 pastedSymbols );
1925 }
1926 }
1927 else
1928 {
1929 SCH_ITEM* srcItem = dynamic_cast<SCH_ITEM*>( itemMap[ item->m_Uuid ] );
1930 SCH_ITEM* destItem = dynamic_cast<SCH_ITEM*>( item );
1931
1932 // Everything gets a new KIID
1933 const_cast<KIID&>( item->m_Uuid ) = KIID();
1934
1935 if( srcItem && destItem )
1936 {
1937 destItem->SetConnectivityDirty( true );
1938 destItem->SetLastResolvedState( srcItem );
1939 }
1940 }
1941
1942 // Lines need both ends selected for a move after paste so the whole line moves.
1943 if( item->Type() == SCH_LINE_T )
1944 item->SetFlags( STARTPOINT | ENDPOINT );
1945
1946 item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );
1947
1948 if( !m_frame->GetScreen()->CheckIfOnDrawList( (SCH_ITEM*) item ) ) // don't want a loop!
1949 m_frame->AddToScreen( item, m_frame->GetScreen() );
1950
1951 commit.Added( (SCH_ITEM*) item, m_frame->GetScreen() );
1952
1953 // Start out hidden so the pasted items aren't "ghosted" in their original location
1954 // before being moved to the current location.
1955 getView()->Hide( item, true );
1956 }
1957
1958 if( sheetsPasted )
1959 {
1960 // The full schematic hierarchy need to be update before assigning new annotation and
1961 // page numbers.
1963
1964 // Update page numbers: Find next free numeric page number
1965 for( SCH_SHEET_PATH& sheetPath : sheetPathsForScreen )
1966 {
1967 for( SCH_SHEET_PATH& pastedSheet : pastedSheets[sheetPath] )
1968 {
1969 int page = 1;
1970 wxString pageNum = wxString::Format( "%d", page );
1971
1972 while( hierarchy.PageNumberExists( pageNum ) )
1973 pageNum = wxString::Format( "%d", ++page );
1974
1975 SCH_SHEET_INSTANCE sheetInstance;
1976
1977 sheetInstance.m_Path = pastedSheet.Path();
1978
1979 // Don't include the actual sheet in the instance path.
1980 sheetInstance.m_Path.pop_back();
1981 sheetInstance.m_PageNumber = pageNum;
1982 sheetInstance.m_ProjectName = m_frame->Prj().GetProjectName();
1983
1984 SCH_SHEET* sheet = pastedSheet.Last();
1985
1986 wxCHECK2( sheet, continue );
1987
1988 sheet->AddInstance( sheetInstance );
1989 hierarchy.push_back( pastedSheet );
1990
1991 // Remove all pasted sheet instance data that is not part of the current project.
1992 std::vector<KIID_PATH> instancesToRemove;
1993
1994 for( const SCH_SHEET_INSTANCE& instance : sheet->GetInstances() )
1995 {
1996 if( !hierarchy.HasPath( instance.m_Path ) )
1997 instancesToRemove.push_back( instance.m_Path );
1998 }
1999
2000 for( const KIID_PATH& instancePath : instancesToRemove )
2001 sheet->RemoveInstance( instancePath );
2002 }
2003 }
2004
2006
2007 // Get a version with correct sheet numbers since we've pasted sheets,
2008 // we'll need this when annotating next
2009 hierarchy = m_frame->Schematic().Hierarchy();
2010 }
2011
2012 std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> annotatedSymbols;
2013
2014 // Update the list of symbol instances that satisfy the annotation criteria.
2015 for( const SCH_SHEET_PATH& sheetPath : sheetPathsForScreen )
2016 {
2017 for( size_t i = 0; i < pastedSymbols[sheetPath].GetCount(); i++ )
2018 {
2019 if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS
2020 || pasteMode == PASTE_MODE::RESPECT_OPTIONS
2021 || pastedSymbols[sheetPath][i].AlwaysAnnotate() )
2022 {
2023 annotatedSymbols[sheetPath].AddItem( pastedSymbols[sheetPath][i] );
2024 }
2025 }
2026
2027 for( const SCH_SHEET_PATH& pastedSheetPath : pastedSheets[sheetPath] )
2028 {
2029 for( size_t i = 0; i < pastedSymbols[pastedSheetPath].GetCount(); i++ )
2030 {
2031 if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS
2032 || pasteMode == PASTE_MODE::RESPECT_OPTIONS
2033 || pastedSymbols[pastedSheetPath][i].AlwaysAnnotate() )
2034 {
2035 annotatedSymbols[pastedSheetPath].AddItem( pastedSymbols[pastedSheetPath][i] );
2036 }
2037 }
2038 }
2039 }
2040
2041 if( !annotatedSymbols.empty() )
2042 {
2043 for( SCH_SHEET_PATH& path : sheetPathsForScreen )
2044 {
2045 annotatedSymbols[path].SortByReferenceOnly();
2046
2047 if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS )
2048 {
2049 annotatedSymbols[path].ReannotateDuplicates( existingRefs );
2050 }
2051 else
2052 {
2053 annotatedSymbols[path].ReannotateByOptions( (ANNOTATE_ORDER_T) annotate.sort_order,
2054 (ANNOTATE_ALGO_T) annotate.method,
2055 annotateStartNum, existingRefs, false,
2056 &hierarchy );
2057 }
2058
2059 annotatedSymbols[path].UpdateAnnotation();
2060
2061 // Update existing refs for next iteration
2062 for( size_t i = 0; i < annotatedSymbols[path].GetCount(); i++ )
2063 existingRefs.AddItem( annotatedSymbols[path][i] );
2064
2065 for( const SCH_SHEET_PATH& pastedSheetPath : pastedSheets[path] )
2066 {
2067 annotatedSymbols[pastedSheetPath].SortByReferenceOnly();
2068
2069 if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS )
2070 {
2071 annotatedSymbols[pastedSheetPath].ReannotateDuplicates( existingRefs );
2072 }
2073 else
2074 {
2075 annotatedSymbols[pastedSheetPath].ReannotateByOptions( (ANNOTATE_ORDER_T) annotate.sort_order,
2076 (ANNOTATE_ALGO_T) annotate.method,
2077 annotateStartNum, existingRefs,
2078 false,
2079 &hierarchy );
2080 }
2081
2082 annotatedSymbols[pastedSheetPath].UpdateAnnotation();
2083
2084 // Update existing refs for next iteration
2085 for( size_t i = 0; i < annotatedSymbols[pastedSheetPath].GetCount(); i++ )
2086 existingRefs.AddItem( annotatedSymbols[pastedSheetPath][i] );
2087 }
2088 }
2089 }
2090
2092
2093 // The copy operation creates instance paths that are not valid for the current project or
2094 // saved as part of another project. Prune them now so they do not accumulate in the saved
2095 // schematic file.
2097
2099 SCH_SCREENS allScreens( m_frame->Schematic().Root() );
2100
2101 allScreens.PruneOrphanedSymbolInstances( m_frame->Prj().GetProjectName(), sheets );
2102 allScreens.PruneOrphanedSheetInstances( m_frame->Prj().GetProjectName(), sheets );
2103
2104 // Now clear the previous selection, select the pasted items, and fire up the "move" tool.
2107
2108 EE_SELECTION& selection = selTool->GetSelection();
2109
2110 if( !selection.Empty() )
2111 {
2112 if( aEvent.IsAction( &ACTIONS::duplicate ) )
2113 {
2114 int closest_dist = INT_MAX;
2115
2116 auto processPt =
2117 [&]( const VECTOR2I& pt )
2118 {
2119 int dist = ( eventPos - pt ).EuclideanNorm();
2120
2121 if( dist < closest_dist )
2122 {
2123 selection.SetReferencePoint( pt );
2124 closest_dist = dist;
2125 }
2126 };
2127
2128 // Prefer connection points (which should remain on grid)
2129 for( EDA_ITEM* item : selection.Items() )
2130 {
2131 SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
2132 SCH_PIN* pin = dynamic_cast<SCH_PIN*>( item );
2133
2134 if( sch_item && sch_item->IsConnectable() )
2135 {
2136 for( const VECTOR2I& pt : sch_item->GetConnectionPoints() )
2137 processPt( pt );
2138 }
2139 else if( pin )
2140 {
2141 processPt( pin->GetPosition() );
2142 }
2143
2144 // Symbols need to have their center point added since often users are trying to
2145 // move parts from their center.
2146 if( dynamic_cast<SCH_SYMBOL*>( item ) )
2147 processPt( item->GetPosition() );
2148 }
2149
2150 // Only process other points if we didn't find any connection points
2151 if( closest_dist == INT_MAX )
2152 {
2153 for( EDA_ITEM* item : selection.Items() )
2154 {
2155 switch( item->Type() )
2156 {
2157 case SCH_LINE_T:
2158 processPt( static_cast<SCH_LINE*>( item )->GetStartPoint() );
2159 processPt( static_cast<SCH_LINE*>( item )->GetEndPoint() );
2160 break;
2161
2162 case SCH_SHAPE_T:
2163 {
2164 SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( item );
2165
2166 switch( shape->GetShape() )
2167 {
2168 case SHAPE_T::RECTANGLE:
2169 for( const VECTOR2I& pt : shape->GetRectCorners() )
2170 processPt( pt );
2171
2172 break;
2173
2174 case SHAPE_T::CIRCLE:
2175 processPt( shape->GetCenter() );
2176 break;
2177
2178 case SHAPE_T::POLY:
2179 for( int ii = 0; ii < shape->GetPolyShape().TotalVertices(); ++ii )
2180 processPt( shape->GetPolyShape().CVertex( ii ) );
2181
2182 break;
2183
2184 default:
2185 processPt( shape->GetStart() );
2186 processPt( shape->GetEnd() );
2187 break;
2188 }
2189
2190 break;
2191 }
2192
2193 default:
2194 processPt( item->GetPosition() );
2195 break;
2196 }
2197 }
2198 }
2199
2200 selection.SetIsHover( m_duplicateIsHoverSelection );
2201 }
2202 else
2203 {
2204 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetTopLeftItem() );
2205
2206 selection.SetReferencePoint( item->GetPosition() );
2207 }
2208
2210 {
2211 // Pushing the commit will update the connectivity.
2212 commit.Push( _( "Paste" ) );
2213
2214 if( sheetsPasted )
2216 // UpdateHierarchyNavigator() will call RefreshNetNavigator()
2217 else
2219 }
2220 else
2221 {
2222 commit.Revert();
2223 }
2224 }
2225
2226 return 0;
2227}
2228
2229
2231{
2233 EE_SELECTION& selection = selTool->RequestSelection( { SCH_SYMBOL_T } );
2234 SCH_SYMBOL* symbol = nullptr;
2235 SYMBOL_EDIT_FRAME* symbolEditor;
2236
2237 if( selection.GetSize() >= 1 )
2238 symbol = (SCH_SYMBOL*) selection.Front();
2239
2240 if( selection.IsHover() )
2242
2243 if( !symbol )
2244 {
2245 // Giant hack: by default we assign Edit Table to the same hotkey, so give the table
2246 // tool a chance to handle it if we can't.
2248 tableTool->EditTable( aEvent );
2249
2250 return 0;
2251 }
2252
2253 if( symbol->GetEditFlags() != 0 )
2254 return 0;
2255
2256 if( symbol->IsMissingLibSymbol() )
2257 {
2258 m_frame->ShowInfoBarError( _( "Symbols with broken library symbol links cannot "
2259 "be edited." ) );
2260 return 0;
2261 }
2262
2264 symbolEditor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
2265
2266 if( symbolEditor )
2267 {
2268 if( wxWindow* blocking_win = symbolEditor->Kiway().GetBlockingDialog() )
2269 blocking_win->Close( true );
2270
2271 if( aEvent.IsAction( &EE_ACTIONS::editWithLibEdit ) )
2272 {
2273 symbolEditor->LoadSymbolFromSchematic( symbol );
2274 }
2276 {
2277 symbolEditor->LoadSymbol( symbol->GetLibId(), symbol->GetUnit(),
2278 symbol->GetBodyStyle() );
2279
2280 if( !symbolEditor->IsLibraryTreeShown() )
2281 symbolEditor->ToggleLibraryTree();
2282 }
2283 }
2284
2285 return 0;
2286}
2287
2288
2290{
2292 return 0;
2293}
2294
2295
2297{
2299
2300 dlg.SetInitialFocus( dlg.m_FirstRefDes );
2301
2302 if( dlg.ShowModal() == wxID_OK )
2303 {
2304 SCH_REFERENCE startRef;
2305 startRef.SetRef( dlg.m_FirstRefDes->GetValue() );
2306
2307 if( startRef.IsSplitNeeded() )
2308 startRef.Split();
2309 else
2310 return 0;
2311
2312 int startNum = atoi( startRef.GetRefNumber().utf8_string().c_str() );
2313
2314 SCH_COMMIT commit( m_frame );
2315 SCHEMATIC* schematic = m_frame->m_schematic;
2316 SCH_REFERENCE_LIST references;
2317
2318 if( dlg.m_AllSheets->GetValue() )
2319 schematic->Hierarchy().GetSymbols( references );
2320 else
2321 schematic->CurrentSheet().GetSymbols( references );
2322
2323 references.SplitReferences();
2324
2325 for( SCH_REFERENCE& ref : references )
2326 {
2327 if( ref.GetRef() == startRef.GetRef() )
2328 {
2329 int num = atoi( ref.GetRefNumber().utf8_string().c_str() );
2330
2331 if( num >= startNum )
2332 {
2333 const SCH_SHEET_PATH& sheet = ref.GetSheetPath();
2334 wxString fullRef = ref.GetRef();
2335
2336 num += dlg.m_Increment->GetValue();
2337 fullRef << num;
2338
2339 commit.Modify( ref.GetSymbol(), sheet.LastScreen() );
2340 ref.GetSymbol()->SetRef( &sheet, From_UTF8( fullRef.c_str() ) );
2341 }
2342 }
2343 }
2344
2345 if( !commit.Empty() )
2346 commit.Push( _( "Increment Annotations" ) );
2347 }
2348
2349 return 0;
2350}
2351
2352
2354{
2356 return 0;
2357}
2358
2359
2361{
2363
2364 wxCHECK( dlg, 0 );
2365
2366 // Needed at least on Windows. Raise() is not enough
2367 dlg->Show( true );
2368
2369 // Bring it to the top if already open. Dual monitor users need this.
2370 dlg->Raise();
2371
2372 dlg->ShowEditTab();
2373
2374 return 0;
2375}
2376
2377
2379{
2382
2383 return 0;
2384}
2385
2386
2388{
2390 return 0;
2391}
2392
2393
2395{
2397 return 0;
2398}
2399
2400
2402{
2404 dlg.ShowModal();
2405 return 0;
2406}
2407
2408
2410{
2411 int result = NET_PLUGIN_CHANGE;
2412
2413 // If a plugin is removed or added, rebuild and reopen the new dialog
2414 while( result == NET_PLUGIN_CHANGE )
2415 result = InvokeDialogNetList( m_frame );
2416
2417 return 0;
2418}
2419
2420
2422{
2424
2425 wxCHECK( dlg, 0 );
2426
2427 // Needed at least on Windows. Raise() is not enough
2428 dlg->Show( true );
2429
2430 // Bring it to the top if already open. Dual monitor users need this.
2431 dlg->Raise();
2432
2433 dlg->ShowExportTab();
2434
2435 return 0;
2436}
2437
2438
2440{
2442 return 0;
2443}
2444
2445
2447{
2450 return 0;
2451}
2452
2453
2455{
2456 getEditFrame<SCH_EDIT_FRAME>()->ToggleSearch();
2457 return 0;
2458}
2459
2460
2462{
2463 getEditFrame<SCH_EDIT_FRAME>()->ToggleSchematicHierarchy();
2464 return 0;
2465}
2466
2467
2469{
2470 getEditFrame<SCH_EDIT_FRAME>()->ToggleNetNavigator();
2471 return 0;
2472}
2473
2474
2476{
2477 getEditFrame<SCH_EDIT_FRAME>()->ToggleProperties();
2478 return 0;
2479}
2480
2481
2483{
2484 getEditFrame<SCH_EDIT_FRAME>()->ToggleLibraryTree();
2485 return 0;
2486}
2487
2488
2490{
2493
2496
2497 return 0;
2498}
2499
2500
2502{
2505
2508
2509 return 0;
2510}
2511
2512
2514{
2517
2520
2521 return 0;
2522}
2523
2524
2526{
2529
2532
2533 return 0;
2534}
2535
2536
2538{
2541
2544
2545 return 0;
2546}
2547
2548
2550{
2553
2555
2556 return 0;
2557}
2558
2559
2561{
2564
2566 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
2567 {
2568 int flags = 0;
2569
2570 auto invalidateTextVars =
2571 [&flags]( EDA_TEXT* text )
2572 {
2573 if( text->HasTextVars() )
2574 {
2575 text->ClearRenderCache();
2576 text->ClearBoundingBoxCache();
2578 }
2579 };
2580
2581 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
2582 {
2583 item->RunOnChildren(
2584 [&invalidateTextVars]( SCH_ITEM* aChild )
2585 {
2586 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
2587 invalidateTextVars( text );
2588 } );
2589
2590 if( item->GetExcludedFromSim() )
2592 }
2593
2594 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
2595 invalidateTextVars( text );
2596
2597 return flags;
2598 } );
2599
2601
2602 return 0;
2603}
2604
2605
2607{
2610
2614
2615 return 0;
2616}
2617
2618
2620{
2623
2627
2628 return 0;
2629}
2630
2631
2633{
2636
2638
2641
2642 return 0;
2643}
2644
2645
2647{
2650 return 0;
2651}
2652
2653
2655{
2657 m_frame->eeconfig()->m_Drawing.line_mode %= LINE_MODE::LINE_MODE_COUNT;
2659 return 0;
2660}
2661
2662
2664{
2667 return 0;
2668}
2669
2670
2672{
2675 return 0;
2676}
2677
2678
2680{
2681
2683 return 0;
2684}
2685
2686
2688{
2689#ifdef KICAD_IPC_API
2690 Pgm().GetPluginManager().ReloadPlugins();
2691#endif
2692 return 0;
2693}
2694
2695
2697{
2698 int errors = 0;
2699 wxString details;
2700 bool quiet = aEvent.Parameter<bool>();
2701
2702 // Repair duplicate IDs.
2703 std::map<KIID, EDA_ITEM*> ids;
2704 int duplicates = 0;
2705
2707
2708 auto processItem =
2709 [&]( EDA_ITEM* aItem )
2710 {
2711 auto it = ids.find( aItem->m_Uuid );
2712
2713 if( it != ids.end() && it->second != aItem )
2714 {
2715 duplicates++;
2716 const_cast<KIID&>( aItem->m_Uuid ) = KIID();
2717 }
2718
2719 ids[ aItem->m_Uuid ] = aItem;
2720 };
2721
2722 // Symbol IDs are the most important, so give them the first crack at "claiming" a
2723 // particular KIID.
2724
2725 for( const SCH_SHEET_PATH& sheet : sheets )
2726 {
2727 SCH_SCREEN* screen = sheet.LastScreen();
2728
2729 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
2730 {
2731 processItem( item );
2732
2733 for( SCH_PIN* pin : static_cast<SCH_SYMBOL*>( item )->GetPins( &sheet ) )
2734 processItem( pin );
2735 }
2736 }
2737
2738 for( const SCH_SHEET_PATH& sheet : sheets )
2739 {
2740 SCH_SCREEN* screen = sheet.LastScreen();
2741
2742 for( SCH_ITEM* item : screen->Items() )
2743 {
2744 processItem( item );
2745
2746 item->RunOnChildren(
2747 [&]( SCH_ITEM* aChild )
2748 {
2749 processItem( item );
2750 } );
2751 }
2752 }
2753
2754 /*******************************
2755 * Your test here
2756 */
2757
2758 /*******************************
2759 * Inform the user
2760 */
2761
2762 if( duplicates )
2763 {
2764 errors += duplicates;
2765 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
2766 }
2767
2768 if( errors )
2769 {
2770 m_frame->OnModify();
2771
2772 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
2773
2774 if( !quiet )
2775 DisplayInfoMessage( m_frame, msg, details );
2776 }
2777 else if( !quiet )
2778 {
2779 DisplayInfoMessage( m_frame, _( "No errors found." ) );
2780 }
2781
2782 return 0;
2783}
2784
2785
2787{
2788 if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
2789 return 0;
2790
2791 GRID_SETTINGS& gridSettings = m_toolMgr->GetSettings()->m_Window.grid;
2792 int currentIdx = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
2793
2794 wxArrayString gridsLabels;
2795
2796 for( const GRID& grid : gridSettings.grids )
2797 gridsLabels.Add( grid.UserUnitsMessageText( m_frame ) );
2798
2799 if( !m_frame->GetHotkeyPopup() )
2801
2803
2804 if( popup )
2805 popup->Popup( _( "Grid" ), gridsLabels, currentIdx );
2806
2807 return 0;
2808}
2809
2810
2812{
2813 Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
2814 Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
2815 Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
2822 Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
2823 Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
2824
2827
2833
2836
2842
2844
2845 Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
2846 Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
2847 Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
2848 Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
2853
2855
2873
2880
2896
2899
2901
2906}
const char * name
Definition: DXF_plotter.cpp:57
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:212
static TOOL_ACTION paste
Definition: actions.h:73
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:239
static TOOL_ACTION pickerTool
Definition: actions.h:202
static TOOL_ACTION showSymbolEditor
Definition: actions.h:209
static TOOL_ACTION pasteSpecial
Definition: actions.h:74
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:108
static TOOL_ACTION undo
Definition: actions.h:68
static TOOL_ACTION duplicate
Definition: actions.h:77
static TOOL_ACTION doDelete
Definition: actions.h:78
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:213
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION showProperties
Definition: actions.h:214
static TOOL_ACTION doNew
Definition: actions.h:47
static TOOL_ACTION cut
Definition: actions.h:70
static TOOL_ACTION copyAsText
Definition: actions.h:72
static TOOL_ACTION refreshPreview
Definition: actions.h:147
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 & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:105
COMMIT & Added(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
Definition: commit.h:86
bool Empty() const
Returns status of an item.
Definition: commit.h:144
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.
Class DIALOG_INCREMENT_ANNOTATIONS_BASE.
void SetWksFileName(const wxString &aFilename)
bool PrjConfigChanged()
Return true if the project configuration was modified.
bool Show(bool show) override
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:102
int ShowQuasiModal()
int ShowModal() override
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:1134
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:182
static TOOL_ACTION repairSchematic
Definition: ee_actions.h:273
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:176
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
static TOOL_ACTION toggleAnnotateAuto
Definition: ee_actions.h:284
static TOOL_ACTION lineMode90
Definition: ee_actions.h:279
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:247
static TOOL_ACTION highlightNet
Definition: ee_actions.h:308
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:127
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:309
static TOOL_ACTION assignNetclass
Definition: ee_actions.h:168
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION showPythonConsole
Definition: ee_actions.h:272
static TOOL_ACTION toggleERCWarnings
Definition: ee_actions.h:252
static TOOL_ACTION simTune
Definition: ee_actions.h:297
static TOOL_ACTION toggleERCExclusions
Definition: ee_actions.h:254
static TOOL_ACTION lineModeNext
Definition: ee_actions.h:281
static TOOL_ACTION lineModeFree
Definition: ee_actions.h:278
static TOOL_ACTION editLibSymbolWithLibEdit
Definition: ee_actions.h:180
static TOOL_ACTION incrementAnnotations
Definition: ee_actions.h:158
static TOOL_ACTION generateBOMLegacy
Definition: ee_actions.h:185
static TOOL_ACTION toggleERCErrors
Definition: ee_actions.h:253
static TOOL_ACTION toggleOPCurrents
Definition: ee_actions.h:257
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:311
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:310
static TOOL_ACTION exportNetlist
Definition: ee_actions.h:183
static TOOL_ACTION assignFootprints
Definition: ee_actions.h:167
static TOOL_ACTION selectOnPCB
Definition: ee_actions.h:261
static TOOL_ACTION togglePinAltIcons
Definition: ee_actions.h:258
static TOOL_ACTION rescueSymbols
Definition: ee_actions.h:175
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:248
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:179
static TOOL_ACTION simProbe
Definition: ee_actions.h:296
static TOOL_ACTION exportSymbolsToLibrary
Definition: ee_actions.h:188
static TOOL_ACTION drawSheetOnClipboard
Definition: ee_actions.h:268
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:159
static TOOL_ACTION showNetNavigator
Definition: ee_actions.h:312
static TOOL_ACTION annotate
Definition: ee_actions.h:157
static TOOL_ACTION toggleDirectiveLabels
Definition: ee_actions.h:251
static TOOL_ACTION showHierarchy
Definition: ee_actions.h:239
static TOOL_ACTION toggleOPVoltages
Definition: ee_actions.h:256
static TOOL_ACTION showDesignBlockPanel
Definition: ee_actions.h:206
static TOOL_ACTION lineMode45
Definition: ee_actions.h:280
static TOOL_ACTION markSimExclusions
Definition: ee_actions.h:255
static TOOL_ACTION editSymbolLibraryLinks
Definition: ee_actions.h:160
static TOOL_ACTION saveCurrSheetCopyAs
Definition: ee_actions.h:42
static TOOL_ACTION showPcbNew
Definition: ee_actions.h:181
static TOOL_ACTION generateBOM
Definition: ee_actions.h:184
static TOOL_ACTION schematicSetup
Definition: ee_actions.h:169
static TOOL_ACTION exportSymbolsToNewLibrary
Definition: ee_actions.h:189
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:292
static const TOOL_EVENT GridChangedByKeyEvent
Definition: actions.h:310
static const TOOL_EVENT SelectedEvent
Definition: actions.h:290
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:297
static const TOOL_EVENT PointSelectedEvent
Definition: actions.h:289
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:291
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:327
wxString AsString() const
Definition: kiid.cpp:348
Definition: kiid.h:49
wxString AsString() const
Definition: kiid.cpp:238
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:84
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:73
void SetSnapping(bool aSnap)
Definition: picker_tool.h:66
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:64
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:104
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:77
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:152
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:308
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:314
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:162
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
Definition: schematic.cpp:214
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition: schematic.cpp:860
SCH_SHEET & Root() const
Definition: schematic.h:121
SCH_SHEET_LIST BuildSheetListSortedByPageNumbers() const override
Definition: schematic.h:97
void RefreshHierarchy()
Definition: schematic.cpp:222
SCH_RENDER_SETTINGS * GetRenderSettings()
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:432
virtual void Revert() override
Definition: sch_commit.cpp:510
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 CopyAsText(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 TogglePinAltIcons(const TOOL_EVENT &aEvent)
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)
int IncrementAnnotations(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 ToggleLibraryTree(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()
void RefreshOperatingPointDisplay()
Refresh the display of any operaintg points.
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.
bool LoadSheetFromFile(SCH_SHEET *aSheet, SCH_SHEET_PATH *aCurrentSheet, const wxString &aFileName, bool aSkipRecursionCheck=false, bool aSkipLibCheck=false)
Load a the KiCad schematic file aFileName into the sheet aSheet.
Definition: sheet.cpp:166
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.
SCHEMATIC * m_schematic
The currently loaded schematic.
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:619
void RefreshNetNavigator(const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr)
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:1212
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 SplitReferences()
Attempt to split all reference designators into a name (U) and number (1).
void AddItem(const SCH_REFERENCE &aItem)
A helper to define a symbol's reference designator in a schematic.
void SetRef(const wxString &aReference)
void Split()
Attempt to split the reference designator into a name (U) and number (1).
bool IsSplitNeeded()
Determine if this reference needs to be split or if it likely already has been.
wxString GetRef() const
void SetSheetNumber(int aSheetNumber)
wxString GetRefNumber() const
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:712
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:153
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:278
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:666
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:636
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:323
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
Definition: sch_screen.cpp:386
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:1405
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:783
void AddInstance(const SCH_SHEET_INSTANCE &aInstance)
Definition: sch_sheet.cpp:1426
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:173
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:104
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
Definition: sch_symbol.h:163
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:270
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:939
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:637
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
Definition: sch_symbol.cpp:237
const LIB_ID & GetLibId() const override
Definition: sch_symbol.h:193
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:987
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:212
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:279
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
Definition: sch_symbol.cpp:737
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:717
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:436
const std::string & GetString()
Definition: richio.h:459
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
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 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:171
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.cpp:97
const wxString & GetMessages() const
Definition: reporter.cpp:84
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
Definition: clipboard.cpp:31
std::string GetClipboardUTF8()
Return the information currently stored in the system clipboard.
Definition: clipboard.cpp:51
std::unique_ptr< wxImage > GetImageFromClipboard()
Get image data from the clipboard, if there is any.
Definition: clipboard.cpp:77
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:422
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:60
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
wxString GetSelectedItemsAsText(const SELECTION &aSel)
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:405
@ LAYER_OP_VOLTAGES
Definition: layer_ids.h:404
@ 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:1060
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)
wxString From_UTF8(const char *cstring)
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
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691
Definition of file extensions used in Kicad.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
Definition: wx_filename.h:39