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