KiCad PCB EDA Suite
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 CERN
5 * Copyright (C) 1992-2023 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>
34#include <project_rescue.h>
35#include <erc.h>
36#include <fmt.h>
37#include <invoke_sch_dialog.h>
38#include <string_utils.h>
39#include <kiway.h>
40#include <kiway_player.h>
42#include <paths.h>
45#include <sch_edit_frame.h>
47#include <sch_line.h>
48#include <sch_junction.h>
49#include <sch_bus_entry.h>
50#include <sch_shape.h>
51#include <sch_painter.h>
52#include <sch_sheet.h>
53#include <sch_sheet_pin.h>
54#include <sch_view.h>
55#include <schematic.h>
56#include <advanced_config.h>
57#include <sim/sim_plot_frame.h>
58#include <sim/spice_generator.h>
59#include <sim/sim_lib_mgr.h>
61#include <symbol_viewer_frame.h>
62#include <status_popup.h>
63#include <tool/picker_tool.h>
64#include <tool/tool_manager.h>
65#include <tools/ee_actions.h>
66#include <tools/ee_selection.h>
71#include <eda_list_dialog.h>
73#include <wx_filename.h>
74#include <sch_sheet_path.h>
75#include <wx/filedlg.h>
76
77
79{
81 return 0;
82}
83
84
86{
88 return 0;
89}
90
91
93{
95 return 0;
96}
97
98
100{
101 m_frame->SaveProject( true );
102 return 0;
103}
104
105
107{
108 SCH_SHEET* curr_sheet = m_frame->GetCurrentSheet().Last();
109 wxFileName curr_fn = curr_sheet->GetFileName();
110 wxFileDialog dlg( m_frame, _( "Schematic Files" ), curr_fn.GetPath(),
111 curr_fn.GetFullName(), KiCadSchematicFileWildcard(),
112 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
113
114 if( dlg.ShowModal() == wxID_CANCEL )
115 return false;
116
117 wxFileName newFileName = dlg.GetPath();
118 newFileName.SetExt( KiCadSchematicFileExtension );
119
120 m_frame->saveSchematicFile( curr_sheet, newFileName.GetFullPath() );
121 return 0;
122}
123
124
126{
127 SCHEMATIC& schematic = m_frame->Schematic();
128 SCH_SHEET& root = schematic.Root();
129
130 if( m_frame->GetCurrentSheet().Last() != &root )
131 {
134
135 // Store the current zoom level into the current screen before switching
137
138 SCH_SHEET_PATH rootSheetPath;
139 rootSheetPath.push_back( &root );
140 m_frame->SetCurrentSheet( rootSheetPath );
142
143 wxSafeYield();
144 }
145
146 wxString msg;
147 msg.Printf( _( "Revert '%s' (and all sub-sheets) to last version saved?" ),
148 schematic.GetFileName() );
149
150 if( !IsOK( m_frame, msg ) )
151 return false;
152
153 SCH_SCREENS screenList( schematic.Root() );
154
155 for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
156 screen->SetContentModified( false ); // do not prompt the user for changes
157
159 m_frame->OpenProjectFiles( std::vector<wxString>( 1, schematic.GetFileName() ) );
160
161 return 0;
162}
163
164
166{
168 return 0;
169}
170
171
173{
174 PICKED_ITEMS_LIST undoCmd;
176 ITEM_PICKER wrapper( m_frame->GetScreen(), undoItem, UNDO_REDO::PAGESETTINGS );
177
178 undoCmd.PushItem( wrapper );
179 m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS, false, false );
180
184
185 if( dlg.ShowModal() == wxID_OK )
186 {
187 // Update text variables
191
192 m_frame->OnModify();
193 }
194 else
195 {
197 }
198
199 return 0;
200}
201
202
204{
205 SCH_SCREENS schematic( m_frame->Schematic().Root() );
206
207 if( schematic.HasNoFullyDefinedLibIds() )
208 RescueLegacyProject( true );
209 else
211
212 return 0;
213}
214
215
216bool SCH_EDITOR_CONTROL::RescueLegacyProject( bool aRunningOnDemand )
217{
220
221 return rescueProject( rescuer, aRunningOnDemand );
222}
223
224
226{
230
231 return rescueProject( rescuer, aRunningOnDemand );
232}
233
234
235bool SCH_EDITOR_CONTROL::rescueProject( RESCUER& aRescuer, bool aRunningOnDemand )
236{
237 if( !RESCUER::RescueProject( m_frame, aRescuer, aRunningOnDemand ) )
238 return false;
239
240 if( aRescuer.GetCandidateCount() )
241 {
242 KIWAY_PLAYER* viewer = m_frame->Kiway().Player( FRAME_SCH_VIEWER, false );
243
244 if( viewer )
245 static_cast<SYMBOL_VIEWER_FRAME*>( viewer )->ReCreateLibList();
246
247 if( aRunningOnDemand )
248 {
249 SCH_SCREENS schematic( m_frame->Schematic().Root() );
250
251 schematic.UpdateSymbolLinks();
253 }
254
256 m_frame->SyncView();
258 m_frame->OnModify();
259 }
260
261 return true;
262}
263
264
266{
267 DIALOG_SYMBOL_REMAP dlgRemap( m_frame );
268
269 dlgRemap.ShowQuasiModal();
270
271 m_frame->GetCanvas()->Refresh( true );
272
273 return 0;
274}
275
276
278{
280
281 wxFileName fn = m_frame->Prj().AbsolutePath( m_frame->Schematic().RootScreen()->GetFileName() );
282
283 if( fn.GetName() != NAMELESS_PROJECT )
285
286 return 0;
287}
288
289
291{
293
294 dlg.ShowModal();
295
296 // save project config if the prj config has changed:
297 if( dlg.PrjConfigChanged() )
299
300 return 0;
301}
302
303
305{
306 m_frame->Close( false );
307 return 0;
308}
309
310
312{
313 doCrossProbeSchToPcb( aEvent, false );
314 return 0;
315}
316
317
319{
320 doCrossProbeSchToPcb( aEvent, true );
321 return 0;
322}
323
324
325void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce )
326{
327 // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
329 return;
330
332
333 EE_SELECTION& selection = aForce ? selTool->RequestSelection() : selTool->GetSelection();
334
335 m_frame->SendSelectItemsToPcb( selection.GetItemsSortedBySelectionOrder(), aForce );
336}
337
338
340{
341 bool createNew = aEvent.IsAction( &EE_ACTIONS::exportSymbolsToNewLibrary );
342
343 SCH_REFERENCE_LIST symbols;
344 m_frame->Schematic().GetSheets().GetSymbols( symbols, false );
345
346 std::map<LIB_ID, LIB_SYMBOL*> libSymbols;
347 std::map<LIB_ID, std::vector<SCH_SYMBOL*>> symbolMap;
348
349 for( size_t i = 0; i < symbols.GetCount(); ++i )
350 {
351 SCH_SYMBOL* symbol = symbols[i].GetSymbol();
352 LIB_SYMBOL* libSymbol = symbol->GetLibSymbolRef().get();
353 LIB_ID id = libSymbol->GetLibId();
354
355 if( libSymbols.count( id ) )
356 {
357 wxASSERT_MSG( libSymbols[id]->Compare( *libSymbol, LIB_ITEM::COMPARE_FLAGS::ERC ) == 0,
358 "Two symbols have the same LIB_ID but are different!" );
359 }
360 else
361 {
362 libSymbols[id] = libSymbol;
363 }
364
365 symbolMap[id].emplace_back( symbol );
366 }
367
369
370 wxString targetLib;
371
372 if( createNew )
373 {
374 wxFileName fn;
376
379 ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() ),
381 {
382 return 0;
383 }
384
385 targetLib = fn.GetName();
386
387 if( libTable->HasLibrary( targetLib, false ) )
388 {
389 DisplayError( m_frame, wxString::Format( _( "Library '%s' already exists." ),
390 targetLib ) );
391 return 0;
392 }
393
394 if( !mgr.CreateLibrary( fn.GetFullPath(), libTable ) )
395 {
396 DisplayError( m_frame, wxString::Format( _( "Could not add library '%s'." ),
397 targetLib ) );
398 return 0;
399 }
400 }
401 else
402 {
403 targetLib = m_frame->SelectLibraryFromList();
404 }
405
406 if( targetLib.IsEmpty() )
407 return 0;
408
409 bool map = IsOK( m_frame, _( "Update symbols in schematic to refer to new library?" ) );
410 bool append = false;
411
412 SYMBOL_LIB_TABLE_ROW* row = mgr.GetLibrary( targetLib );
413 SCH_IO_MGR::SCH_FILE_T type = SCH_IO_MGR::EnumFromStr( row->GetType() );
414 SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( type ) );
415
416 wxFileName dest = row->GetFullURI( true );
417 dest.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS );
418
419 for( const std::pair<const LIB_ID, LIB_SYMBOL*>& it : libSymbols )
420 {
421 LIB_SYMBOL* origSym = it.second;
422 LIB_SYMBOL* newSym = origSym->Flatten().release();
423
424 pi->SaveSymbol( dest.GetFullPath(), newSym );
425
426 if( map )
427 {
428 LIB_ID id = it.first;
429 id.SetLibNickname( targetLib );
430
431
432 for( SCH_SYMBOL* symbol : symbolMap[it.first] )
433 {
434 m_frame->SaveCopyInUndoList( m_frame->GetScreen(), symbol, UNDO_REDO::CHANGED, append, false);
435 symbol->SetLibId( id );
436 append = true;
437 }
438 }
439 }
440
441 if( append )
442 m_frame->OnModify();
443
444 return 0;
445}
446
447
448#ifdef KICAD_SPICE
449
450#define HITTEST_THRESHOLD_PIXELS 5
451
452int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
453{
456
457 if( !simFrame ) // Defensive coding; shouldn't happen.
458 return 0;
459
460 if( wxWindow* blocking_win = simFrame->Kiway().GetBlockingDialog() )
461 blocking_win->Close( true );
462
463 // Deactivate other tools; particularly important if another PICKER is currently running
464 Activate();
465
467 picker->SetSnapping( false );
468
469 picker->SetClickHandler(
470 [this, simFrame]( const VECTOR2D& aPosition )
471 {
473 EDA_ITEM* item = selTool->GetNode( aPosition );
475
476 if( !item )
477 return false;
478
479 if( item->Type() == SCH_PIN_T )
480 {
481 try
482 {
483 LIB_PIN* pin = static_cast<SCH_PIN*>( item )->GetLibPin();
484 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item->GetParent() );
485
486 wxString msg;
487 WX_STRING_REPORTER reporter( &msg );
488 SIM_LIB_MGR mgr( &m_frame->Prj(), &reporter );
489
490 SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol ).model;
491
492 if( reporter.HasMessage() )
493 THROW_IO_ERROR( msg );
494
495 SPICE_ITEM spiceItem;
496 spiceItem.refName = std::string( symbol->GetRef( &sheet ).ToUTF8() );
497 std::vector<std::string> currentNames =
498 model.SpiceGenerator().CurrentNames( spiceItem );
499
500 if( currentNames.size() == 0 )
501 return true;
502 else if( currentNames.size() == 1 )
503 {
504 simFrame->AddCurrentPlot( currentNames.at( 0 ) );
505 return true;
506 }
507
508 int modelPinIndex =
509 model.FindModelPinIndex( std::string( pin->GetNumber().ToUTF8() ) );
510
511 if( modelPinIndex != SIM_MODEL::PIN::NOT_CONNECTED )
512 {
513 wxString name = currentNames.at( modelPinIndex );
514 simFrame->AddCurrentPlot( name );
515 }
516 }
517 catch( const IO_ERROR& e )
518 {
520 }
521 }
522 else if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T } ) )
523 {
524 if( SCH_CONNECTION* conn = static_cast<SCH_ITEM*>( item )->Connection() )
525 {
526 std::string spiceNet = std::string( UnescapeString( conn->Name() ).ToUTF8() );
528
529 simFrame->AddVoltagePlot( wxString::Format( "V(%s)", spiceNet ) );
530 }
531 }
532
533 return true;
534 } );
535
536 picker->SetMotionHandler(
537 [this, picker]( const VECTOR2D& aPos )
538 {
539 EE_COLLECTOR collector;
540 collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
541 collector.Collect( m_frame->GetScreen(), { SCH_ITEM_LOCATE_WIRE_T,
542 SCH_PIN_T,
543 SCH_SHEET_PIN_T }, aPos );
544
546 selectionTool->GuessSelectionCandidates( collector, aPos );
547
548 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
549 SCH_LINE* wire = dynamic_cast<SCH_LINE*>( item );
550
551 const SCH_CONNECTION* conn = nullptr;
552
553 if( wire )
554 {
555 item = nullptr;
556 conn = wire->Connection();
557 }
558
559 if( item && item->Type() == SCH_PIN_T )
561 else
563
564 if( m_pickerItem != item )
565 {
566 if( m_pickerItem )
567 selectionTool->UnbrightenItem( m_pickerItem );
568
569 m_pickerItem = item;
570
571 if( m_pickerItem )
572 selectionTool->BrightenItem( m_pickerItem );
573 }
574
575 if( m_frame->GetHighlightedConnection() != conn )
576 {
578
579 TOOL_EVENT dummyEvent;
580 UpdateNetHighlighting( dummyEvent );
581 }
582 } );
583
584 picker->SetFinalizeHandler(
585 [this]( const int& aFinalState )
586 {
587 if( m_pickerItem )
588 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
589
591 {
593
594 TOOL_EVENT dummyEvent;
595 UpdateNetHighlighting( dummyEvent );
596 }
597
598 // Wake the selection tool after exiting to ensure the cursor gets updated
600 } );
601
603
604 return 0;
605}
606
607
608int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
609{
611
612 // Deactivate other tools; particularly important if another PICKER is currently running
613 Activate();
614
615 picker->SetCursor( KICURSOR::TUNE );
616 picker->SetSnapping( false );
617
618 picker->SetClickHandler(
619 [this]( const VECTOR2D& aPosition )
620 {
622 EDA_ITEM* item = nullptr;
623 selTool->SelectPoint( aPosition, { SCH_SYMBOL_T, SCH_FIELD_T }, &item );
624
625 if( !item )
626 return false;
627
628 if( item->Type() != SCH_SYMBOL_T )
629 {
630 item = item->GetParent();
631
632 if( item->Type() != SCH_SYMBOL_T )
633 return false;
634 }
635
636 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
637 SCH_SHEET_PATH sheetPath = symbol->Schematic()->CurrentSheet();
638 KIWAY_PLAYER* simFrame = m_frame->Kiway().Player( FRAME_SIMULATOR, false );
639
640 if( simFrame )
641 {
642 if( wxWindow* blocking_win = simFrame->Kiway().GetBlockingDialog() )
643 blocking_win->Close( true );
644
645 static_cast<SIM_PLOT_FRAME*>( simFrame )->AddTuner( sheetPath, symbol );
646 }
647
648 // We do not really want to keep a symbol selected in schematic,
649 // so clear the current selection
650 selTool->ClearSelection();
651 return true;
652 } );
653
654 picker->SetMotionHandler(
655 [this]( const VECTOR2D& aPos )
656 {
657 EE_COLLECTOR collector;
658 collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
659 collector.Collect( m_frame->GetScreen(), { SCH_SYMBOL_T, SCH_FIELD_T }, aPos );
660
662 selectionTool->GuessSelectionCandidates( collector, aPos );
663
664 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
665
666 if( m_pickerItem != item )
667 {
668 if( m_pickerItem )
669 selectionTool->UnbrightenItem( m_pickerItem );
670
671 m_pickerItem = item;
672
673 if( m_pickerItem )
674 selectionTool->BrightenItem( m_pickerItem );
675 }
676 } );
677
678 picker->SetFinalizeHandler(
679 [this]( const int& aFinalState )
680 {
681 if( m_pickerItem )
682 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
683
684 // Wake the selection tool after exiting to ensure the cursor gets updated
685 // and deselect previous selection from simulator to avoid any issue
686 // ( avoid crash in some cases when the SimTune tool is deselected )
688 selectionTool->ClearSelection();
690 } );
691
693
694 return 0;
695}
696#endif /* KICAD_SPICE */
697
698
699// A singleton reference for clearing the highlight
701
702
703static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
704{
705 SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetToolHolder() );
706 EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
707 SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
708 SCH_CONNECTION* conn = nullptr;
709 bool retVal = true;
710
711 if( aPosition != CLEAR )
712 {
713 ERC_TESTER erc( &editFrame->Schematic() );
714
715 if( erc.TestDuplicateSheetNames( false ) > 0 )
716 {
717 wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
718 retVal = false;
719 }
720 else
721 {
722 SCH_ITEM* item = static_cast<SCH_ITEM*>( selTool->GetNode( aPosition ) );
723 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
724
725 if( item )
726 {
727 if( item->IsConnectivityDirty() )
728 {
730 }
731
732 if( item->Type() == SCH_FIELD_T )
733 symbol = dynamic_cast<SCH_SYMBOL*>( item->GetParent() );
734
735 if( symbol && symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsPower() )
736 {
737 std::vector<SCH_PIN*> pins = symbol->GetPins();
738
739 if( pins.size() == 1 )
740 conn = pins[0]->Connection();
741 }
742 else
743 {
744 conn = item->Connection();
745 }
746 }
747 }
748 }
749
750 if( !conn || conn == editFrame->GetHighlightedConnection() )
751 {
752 editFrame->SetStatusText( wxT( "" ) );
753 editFrame->SendCrossProbeClearHighlight();
754 editFrame->SetHighlightedConnection( nullptr );
755 }
756 else
757 {
758 editFrame->SetCrossProbeConnection( conn );
759 editFrame->SetHighlightedConnection( conn );
760 }
761
762 editFrame->UpdateNetHighlightStatus();
763
765 editorControl->UpdateNetHighlighting( dummy );
766
767 return retVal;
768}
769
770
772{
774 VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
775
776 highlightNet( m_toolMgr, cursorPos );
777
778 return 0;
779}
780
781
783{
785
786 return 0;
787}
788
789
791{
793 SCHEMATIC& schematic = m_frame->Schematic();
795
796 const SCH_CONNECTION* conn = nullptr;
797 VECTOR2D connPos;
798
799 for( EDA_ITEM* item : selectionTool->GetSelection() )
800 {
801 conn = static_cast<SCH_ITEM*>( item )->Connection();
802 connPos = item->GetPosition();
803
804 if( conn )
805 break;
806 }
807
808 if( !conn )
809 {
810 m_frame->ShowInfoBarError( _( "No net selected." ) );
811 return 0;
812 }
813
814 // Remove selection in favor of highlighting so the whole net is highlighted
815 selectionTool->ClearSelection();
816 highlightNet( m_toolMgr, connPos );
817
818 wxString netName = conn->Name();
819
820 if( conn->IsBus() )
821 {
822 wxString prefix;
823
824 if( NET_SETTINGS::ParseBusVector( netName, &prefix, nullptr ) )
825 {
826 netName = prefix + wxT( "*" );
827 }
828 else if( NET_SETTINGS::ParseBusGroup( netName, &prefix, nullptr ) )
829 {
830 netName = prefix + wxT( ".*" );
831 }
832 }
833 else if( !conn->Driver() || CONNECTION_SUBGRAPH::GetDriverPriority( conn->Driver() )
835 {
836 m_frame->ShowInfoBarError( _( "Net must be labeled to assign a netclass." ) );
838 return 0;
839 }
840
841 DIALOG_ASSIGN_NETCLASS dlg( m_frame, netName, schematic.GetNetClassAssignmentCandidates(),
842 [&]( const std::vector<wxString>& aNetNames )
843 {
844 for( SCH_ITEM* item : screen->Items() )
845 {
846 bool redraw = item->IsBrightened();
847 SCH_CONNECTION* itemConn = item->Connection();
848
849 if( itemConn && alg::contains( aNetNames, itemConn->Name() ) )
850 item->SetBrightened();
851 else
852 item->ClearBrightened();
853
854 redraw |= item->IsBrightened();
855
856 if( item->Type() == SCH_SYMBOL_T )
857 {
858 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
859
860 redraw |= symbol->HasBrightenedPins();
861
862 symbol->ClearBrightenedPins();
863
864 for( SCH_PIN* pin : symbol->GetPins() )
865 {
866 SCH_CONNECTION* pin_conn = pin->Connection();
867
868 if( pin_conn && alg::contains( aNetNames, pin_conn->Name() ) )
869 {
870 pin->SetBrightened();
871 redraw = true;
872 }
873 }
874 }
875 else if( item->Type() == SCH_SHEET_T )
876 {
877 for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
878 {
879 SCH_CONNECTION* pin_conn = pin->Connection();
880
881 redraw |= pin->IsBrightened();
882
883 if( pin_conn && alg::contains( aNetNames, pin_conn->Name() ) )
884 pin->SetBrightened();
885 else
886 pin->ClearBrightened();
887
888 redraw |= pin->IsBrightened();
889 }
890 }
891
892 if( redraw )
893 getView()->Update( item, KIGFX::VIEW_UPDATE_FLAGS::REPAINT );
894 }
895
897 } );
898
899 if( dlg.ShowModal() )
900 {
901 getView()->UpdateAllItemsConditionally(
902 []( KIGFX::VIEW_ITEM* aItem ) -> int
903 {
904 // Netclass coloured items
905 //
906 if( dynamic_cast<SCH_LINE*>( aItem ) )
907 return KIGFX::REPAINT;
908 else if( dynamic_cast<SCH_JUNCTION*>( aItem ) )
909 return KIGFX::REPAINT;
910 else if( dynamic_cast<SCH_BUS_ENTRY_BASE*>( aItem ) )
911 return KIGFX::REPAINT;
912
913 // Items that might reference an item's netclass name
914 //
915 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
916
917 if( text && text->HasTextVars() )
918 {
919 text->ClearRenderCache();
920 text->ClearBoundingBoxCache();
922 }
923
924 return 0;
925 } );
926 }
927
928 highlightNet( m_toolMgr, CLEAR );
929 return 0;
930}
931
932
934{
936 CONNECTION_GRAPH* connectionGraph = m_frame->Schematic().ConnectionGraph();
937 std::vector<EDA_ITEM*> itemsToRedraw;
938 const SCH_CONNECTION* selectedConn = m_frame->GetHighlightedConnection();
939
940 if( !screen )
941 return 0;
942
943 bool selectedIsBus = selectedConn ? selectedConn->IsBus() : false;
944 wxString selectedName = selectedConn ? selectedConn->Name() : wxString( wxS( "" ) );
945
946 bool selectedIsNoNet = false;
947 CONNECTION_SUBGRAPH* selectedSubgraph = nullptr;
948
949 if( selectedConn && selectedConn->Driver() == nullptr )
950 {
951 selectedIsNoNet = true;
952 selectedSubgraph = connectionGraph->GetSubgraphForItem( selectedConn->Parent() );
953 }
954
955 for( SCH_ITEM* item : screen->Items() )
956 {
957 bool redraw = item->IsBrightened();
958 bool highlight = false;
959
960 if( selectedConn )
961 {
962 SCH_CONNECTION* itemConn = nullptr;
963 SCH_SYMBOL* symbol = nullptr;
964
965 if( item->Type() == SCH_SYMBOL_T )
966 symbol = static_cast<SCH_SYMBOL*>( item );
967
968 if( symbol && symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsPower() )
969 itemConn = symbol->Connection();
970 else
971 itemConn = item->Connection();
972
973 if( selectedIsNoNet && selectedSubgraph )
974 {
975 for( SCH_ITEM* subgraphItem : selectedSubgraph->m_items )
976 {
977 if( item == subgraphItem )
978 {
979 highlight = true;
980 break;
981 }
982 }
983 }
984 else if( selectedIsBus && itemConn && itemConn->IsNet() )
985 {
986 for( const std::shared_ptr<SCH_CONNECTION>& member : selectedConn->Members() )
987 {
988 if( member->Name() == itemConn->Name() )
989 {
990 highlight = true;
991 break;
992 }
993 else if( member->IsBus() )
994 {
995 for( const std::shared_ptr<SCH_CONNECTION>& bus_member : member->Members() )
996 {
997 if( bus_member->Name() == itemConn->Name() )
998 {
999 highlight = true;
1000 break;
1001 }
1002 }
1003 }
1004 }
1005 }
1006 else if( selectedConn && itemConn && selectedName == itemConn->Name() )
1007 {
1008 highlight = true;
1009 }
1010 }
1011
1012 if( highlight )
1013 item->SetBrightened();
1014 else
1015 item->ClearBrightened();
1016
1017 redraw |= item->IsBrightened();
1018
1019 if( item->Type() == SCH_SYMBOL_T )
1020 {
1021 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1022
1023 redraw |= symbol->HasBrightenedPins();
1024
1025 symbol->ClearBrightenedPins();
1026
1027 for( SCH_PIN* pin : symbol->GetPins() )
1028 {
1029 SCH_CONNECTION* pin_conn = pin->Connection();
1030
1031 if( pin_conn && pin_conn->Name() == selectedName )
1032 {
1033 pin->SetBrightened();
1034 redraw = true;
1035 }
1036 }
1037
1038 if( symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsPower() )
1039 {
1040 std::vector<SCH_FIELD>& fields = symbol->GetFields();
1041
1042 for( int id : { REFERENCE_FIELD, VALUE_FIELD } )
1043 {
1044 if( item->IsBrightened() && fields[id].IsVisible() )
1045 fields[id].SetBrightened();
1046 else
1047 fields[id].ClearBrightened();
1048 }
1049 }
1050 }
1051 else if( item->Type() == SCH_SHEET_T )
1052 {
1053 for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
1054 {
1055 SCH_CONNECTION* pin_conn = pin->Connection();
1056 bool redrawPin = pin->IsBrightened();
1057
1058 if( pin_conn && pin_conn->Name() == selectedName )
1059 pin->SetBrightened();
1060 else
1061 pin->ClearBrightened();
1062
1063 redrawPin ^= pin->IsBrightened();
1064 redraw |= redrawPin;
1065 }
1066 }
1067
1068 if( redraw )
1069 itemsToRedraw.push_back( item );
1070 }
1071
1072 // Be sure highlight change will be redrawn
1073 KIGFX::VIEW* view = getView();
1074
1075 for( EDA_ITEM* redrawItem : itemsToRedraw )
1077
1079
1080 return 0;
1081}
1082
1083
1085{
1087
1088 // Deactivate other tools; particularly important if another PICKER is currently running
1089 Activate();
1090
1091 picker->SetCursor( KICURSOR::BULLSEYE );
1092 picker->SetSnapping( false );
1093
1094 picker->SetClickHandler(
1095 [this] ( const VECTOR2D& aPos )
1096 {
1097 return highlightNet( m_toolMgr, aPos );
1098 } );
1099
1101
1102 return 0;
1103}
1104
1105
1107{
1108 if( m_frame->GetUndoCommandCount() <= 0 )
1109 return 0;
1110
1111 // Inform tools that undo command was issued
1113
1114 // Get the old list
1116 size_t num_undos = m_frame->m_undoList.m_CommandsList.size();
1117
1118 // The cleanup routines normally run after an operation and so attempt to append their
1119 // undo items onto the operation's list. However, in this case that's going be the list
1120 // under us, which we don't want, so we push a dummy list onto the stack.
1123
1125
1129
1130 // The cleanup routines *should* have appended to our dummy list, but just to be doubly
1131 // sure pop any other new lists off the stack as well
1132 while( m_frame->m_undoList.m_CommandsList.size() > num_undos )
1134
1135 // Now push the old command to the RedoList
1138
1139 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1140
1141 m_frame->SyncView();
1143 m_frame->OnModify();
1144
1145 return 0;
1146}
1147
1148
1150{
1151 if( m_frame->GetRedoCommandCount() == 0 )
1152 return 0;
1153
1154 // Inform tools that undo command was issued
1156
1157 /* Get the old list */
1159
1160 /* Redo the command: */
1162
1163 /* Put the old list in UndoList */
1166
1170
1171 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1172
1173 m_frame->SyncView();
1175 m_frame->OnModify();
1176
1177 return 0;
1178}
1179
1180
1181bool SCH_EDITOR_CONTROL::doCopy( bool aUseDuplicateClipboard )
1182{
1184 EE_SELECTION& selection = selTool->RequestSelection();
1185 SCHEMATIC& schematic = m_frame->Schematic();
1186
1187 if( selection.Empty() )
1188 return false;
1189
1190 if( aUseDuplicateClipboard )
1191 m_duplicateIsHoverSelection = selection.IsHover();
1192
1193 selection.SetScreen( m_frame->GetScreen() );
1195
1196 for( EDA_ITEM* item : selection )
1197 {
1198 if( item->Type() == SCH_SHEET_T )
1199 {
1200 SCH_SHEET* sheet = (SCH_SHEET*) item;
1201 m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
1202 }
1203 else if( item->Type() == SCH_FIELD_T && selection.IsHover() )
1204 {
1205 // Most of the time the user is trying to duplicate the parent symbol
1206 // and the field text is in it
1207 selection.Add( item->GetParent() );
1208 }
1209 }
1210
1211 STRING_FORMATTER formatter;
1212 SCH_SEXPR_PLUGIN plugin;
1213 SCH_SHEET_LIST hierarchy = schematic.GetSheets();
1215
1216 plugin.Format( &selection, &selPath, schematic, &formatter, true );
1217
1218 if( selection.IsHover() )
1220
1221 if( aUseDuplicateClipboard )
1222 {
1223 m_duplicateClipboard = formatter.GetString();
1224 return true;
1225 }
1226
1227 return m_toolMgr->SaveClipboard( formatter.GetString() );
1228}
1229
1230
1231bool SCH_EDITOR_CONTROL::searchSupplementaryClipboard( const wxString& aSheetFilename,
1232 SCH_SCREEN** aScreen )
1233{
1234 if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
1235 {
1236 *aScreen = m_supplementaryClipboard[ aSheetFilename ];
1237 return true;
1238 }
1239
1240 return false;
1241}
1242
1243
1245{
1246 doCopy( true ); // Use the local clipboard
1247 Paste( aEvent );
1248
1249 return 0;
1250}
1251
1252
1254{
1255 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1256
1257 if( textEntry )
1258 {
1259 textEntry->Cut();
1260 return 0;
1261 }
1262
1263 if( doCopy() )
1265
1266 return 0;
1267}
1268
1269
1271{
1272 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1273
1274 if( textEntry )
1275 {
1276 textEntry->Copy();
1277 return 0;
1278 }
1279
1280 doCopy();
1281
1282 return 0;
1283}
1284
1285
1287 const SCH_SHEET_PATH& aPastePath,
1288 const KIID_PATH& aClipPath,
1289 bool aForceKeepAnnotations )
1290{
1291 wxCHECK( aSymbol && aPasteScreen, /* void */ );
1292
1293 KIID_PATH clipItemPath = aClipPath;
1294
1295 wxString reference, value, footprint;
1296 int unit;
1297
1298 if( m_clipboardSymbolInstances.count( clipItemPath ) > 0 )
1299 {
1300 SCH_SYMBOL_INSTANCE instance = m_clipboardSymbolInstances.at( clipItemPath );
1301
1302 unit = instance.m_Unit;
1303 reference = instance.m_Reference;
1304 }
1305 else
1306 {
1307 // Some legacy versions saved value fields escaped. While we still do in the symbol
1308 // editor, we don't anymore in the schematic, so be sure to unescape them.
1309 SCH_FIELD* valueField = aSymbol->GetField( VALUE_FIELD );
1310 valueField->SetText( UnescapeString( valueField->GetText() ) );
1311
1312 // Pasted from notepad or an older instance of eeschema. Use the values in the fields
1313 // instead.
1314 reference = aSymbol->GetField( REFERENCE_FIELD )->GetText();
1315 value = aSymbol->GetField( VALUE_FIELD )->GetText();
1316 footprint = aSymbol->GetField( FOOTPRINT_FIELD )->GetText();
1317 unit = aSymbol->GetUnit();
1318 }
1319
1320 if( aForceKeepAnnotations && !reference.IsEmpty() )
1321 aSymbol->SetRef( &aPastePath, reference );
1322 else
1323 aSymbol->ClearAnnotation( &aPastePath, false );
1324
1325 // We might clear annotations but always leave the original unit number from the paste.
1326 aSymbol->SetUnitSelection( &aPastePath, unit );
1327 aSymbol->SetUnit( unit );
1328}
1329
1330
1332 const KIID_PATH& aClipPath, SCH_SHEET* aSheet,
1333 bool aForceKeepAnnotations,
1334 SCH_SHEET_LIST* aPastedSheetsSoFar,
1335 SCH_REFERENCE_LIST* aPastedSymbolsSoFar )
1336{
1337 wxCHECK( aSheet && aPastedSheetsSoFar && aPastedSymbolsSoFar, aPastePath );
1338
1339 SCH_SHEET_PATH sheetPath = aPastePath;
1340 sheetPath.push_back( aSheet );
1341
1342 aPastedSheetsSoFar->push_back( sheetPath );
1343
1344 if( aSheet->GetScreen() == nullptr )
1345 return sheetPath; // We can only really set the page number but not load any items
1346
1347 for( SCH_ITEM* item : aSheet->GetScreen()->Items() )
1348 {
1349 if( item->Type() == SCH_SYMBOL_T )
1350 {
1351 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1352
1353 updatePastedSymbol( symbol, aSheet->GetScreen(), sheetPath, aClipPath,
1354 aForceKeepAnnotations );
1355 }
1356 else if( item->Type() == SCH_SHEET_T )
1357 {
1358 SCH_SHEET* subsheet = static_cast<SCH_SHEET*>( item );
1359
1360 KIID_PATH newClipPath = aClipPath;
1361 newClipPath.push_back( subsheet->m_Uuid );
1362
1363 updatePastedSheet( sheetPath, newClipPath, subsheet, aForceKeepAnnotations,
1364 aPastedSheetsSoFar, aPastedSymbolsSoFar );
1365
1366 SCH_SHEET_PATH subSheetPath = sheetPath;
1367
1368 subSheetPath.push_back( subsheet );
1369 subSheetPath.GetSymbols( *aPastedSymbolsSoFar );
1370 }
1371 }
1372
1373 return sheetPath;
1374}
1375
1376
1378{
1380
1381 for( const SCH_SHEET_INSTANCE& sheet : aPastedScreen->GetSheetInstances() )
1382 m_clipboardSheetInstances[sheet.m_Path] = sheet;
1383
1385
1386 for( const SCH_SYMBOL_INSTANCE& symbol : aPastedScreen->GetSymbolInstances() )
1387 m_clipboardSymbolInstances[symbol.m_Path] = symbol;
1388}
1389
1390
1392{
1393 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1394
1395 if( textEntry )
1396 {
1397 textEntry->Paste();
1398 return 0;
1399 }
1400
1402 std::string content;
1403 VECTOR2I eventPos;
1404
1405 if( aEvent.IsAction( &ACTIONS::duplicate ) )
1406 content = m_duplicateClipboard;
1407 else
1408 content = m_toolMgr->GetClipboardUTF8();
1409
1410 if( content.empty() )
1411 return 0;
1412
1413 if( aEvent.IsAction( &ACTIONS::duplicate ) )
1414 eventPos = getViewControls()->GetCursorPosition( false );
1415
1416 STRING_LINE_READER reader( content, "Clipboard" );
1417 SCH_SEXPR_PLUGIN plugin;
1418
1419 SCH_SHEET tempSheet;
1420 SCH_SCREEN* tempScreen = new SCH_SCREEN( &m_frame->Schematic() );
1421
1423 int annotateStartNum = m_frame->Schematic().Settings().m_AnnotateStartNum;
1424
1425 // Screen object on heap is owned by the sheet.
1426 tempSheet.SetScreen( tempScreen );
1427
1428 try
1429 {
1430 plugin.LoadContent( reader, &tempSheet );
1431 }
1432 catch( IO_ERROR& )
1433 {
1434 // If it wasn't content, then paste as text object.
1435 SCH_TEXT* text_item = new SCH_TEXT( wxPoint( 0, 0 ), content );
1436 text_item->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT ); // Left alignment
1437 tempScreen->Append( text_item );
1438 }
1439
1440 // Save loaded screen instances to m_clipboardSheetInstances
1441 setClipboardInstances( tempScreen );
1442
1443 tempScreen->MigrateSimModels();
1444
1445 PASTE_MODE pasteMode = annotate.automatic ? PASTE_MODE::RESPECT_OPTIONS
1447
1448 if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1449 {
1450 DIALOG_PASTE_SPECIAL dlg( m_frame, &pasteMode );
1451
1452 if( dlg.ShowModal() == wxID_CANCEL )
1453 return 0;
1454 }
1455
1456 bool forceKeepAnnotations = pasteMode != PASTE_MODE::REMOVE_ANNOTATIONS;
1457
1458 // SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
1459 // else. Pull them back out to start with.
1460 EDA_ITEMS loadedItems;
1461 bool sheetsPasted = false;
1462 SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
1463 SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
1464 wxFileName destFn = pasteRoot.Last()->GetFileName();
1465
1466 if( destFn.IsRelative() )
1467 destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1468
1469 // List of paths in the hierarchy that refer to the destination sheet of the paste
1470 SCH_SHEET_LIST pasteInstances = hierarchy.FindAllSheetsForScreen( pasteRoot.LastScreen() );
1471 pasteInstances.SortByPageNumbers();
1472
1473 // Build a list of screens from the current design (to avoid loading sheets that already exist)
1474 std::map<wxString, SCH_SCREEN*> loadedScreens;
1475
1476 for( const SCH_SHEET_PATH& item : hierarchy )
1477 {
1478 if( item.LastScreen() )
1479 loadedScreens[item.Last()->GetFileName()] = item.LastScreen();
1480 }
1481
1482 // Build symbol list for reannotation of duplicates
1483 SCH_REFERENCE_LIST existingRefs;
1484 hierarchy.GetSymbols( existingRefs );
1485 existingRefs.SortByReferenceOnly();
1486
1487 // Build UUID map for fetching last-resolved-properties
1488 std::map<KIID, EDA_ITEM*> itemMap;
1489 hierarchy.FillItemMap( itemMap );
1490
1491 // Keep track of pasted sheets and symbols for the different paths to the hierarchy.
1492 std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> pastedSymbols;
1493 std::map<SCH_SHEET_PATH, SCH_SHEET_LIST> pastedSheets;
1494
1495 for( SCH_ITEM* item : tempScreen->Items() )
1496 {
1497 loadedItems.push_back( item );
1498
1499 //@todo: we might want to sort the sheets by page number before adding to loadedItems
1500 if( item->Type() == SCH_SHEET_T )
1501 {
1502 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1503 wxFileName srcFn = sheet->GetFileName();
1504
1505 if( srcFn.IsRelative() )
1506 srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1507
1508 SCH_SHEET_LIST sheetHierarchy( sheet );
1509
1510 if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1511 {
1512 auto msg = wxString::Format( _( "The pasted sheet '%s'\n"
1513 "was dropped because the destination already has "
1514 "the sheet or one of its subsheets as a parent." ),
1515 sheet->GetFileName() );
1516 DisplayError( m_frame, msg );
1517 loadedItems.pop_back();
1518 }
1519 }
1520 }
1521
1522 // Remove the references from our temporary screen to prevent freeing on the DTOR
1523 tempScreen->Clear( false );
1524
1525 for( unsigned i = 0; i < loadedItems.size(); ++i )
1526 {
1527 EDA_ITEM* item = loadedItems[i];
1528 KIID_PATH clipPath( wxT( "/" ) ); // clipboard is at root
1529
1530 if( item->Type() == SCH_SYMBOL_T )
1531 {
1532 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1533
1534 // The library symbol gets set from the cached library symbols in the current
1535 // schematic not the symbol libraries. The cached library symbol may have
1536 // changed from the original library symbol which would cause the copy to
1537 // be incorrect.
1538 SCH_SCREEN* currentScreen = m_frame->GetScreen();
1539
1540 wxCHECK2( currentScreen, continue );
1541
1542 auto it = currentScreen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1543 auto end = currentScreen->GetLibSymbols().end();
1544
1545 if( it == end )
1546 {
1547 // If can't find library definition in the design, use the pasted library
1548 it = tempScreen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1549 end = tempScreen->GetLibSymbols().end();
1550 }
1551
1552 LIB_SYMBOL* libSymbol = nullptr;
1553
1554 if( it != end )
1555 {
1556 libSymbol = new LIB_SYMBOL( *it->second );
1557 symbol->SetLibSymbol( libSymbol );
1558 }
1559
1560 for( SCH_SHEET_PATH& instance : pasteInstances )
1561 updatePastedSymbol( symbol, tempScreen, instance, clipPath, forceKeepAnnotations );
1562
1563 // Assign a new KIID
1564 const_cast<KIID&>( item->m_Uuid ) = KIID();
1565
1566 // Make sure pins get a new UUID
1567 for( SCH_PIN* pin : symbol->GetPins() )
1568 const_cast<KIID&>( pin->m_Uuid ) = KIID();
1569
1570 for( SCH_SHEET_PATH& instance : pasteInstances )
1571 {
1572 // Ignore symbols from a non-existant library.
1573 if( libSymbol )
1574 {
1575 SCH_REFERENCE schReference( symbol, libSymbol, instance );
1576 schReference.SetSheetNumber( instance.GetVirtualPageNumber() );
1577 pastedSymbols[instance].AddItem( schReference );
1578 }
1579 }
1580 }
1581 else if( item->Type() == SCH_SHEET_T )
1582 {
1583 SCH_SHEET* sheet = (SCH_SHEET*) item;
1584 SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1585 wxString baseName = nameField.GetText();
1586 wxString candidateName = baseName;
1587 wxString number;
1588
1589 while( !baseName.IsEmpty() && wxIsdigit( baseName.Last() ) )
1590 {
1591 number = baseName.Last() + number;
1592 baseName.RemoveLast();
1593 }
1594
1595 // Update hierarchy to include any other sheets we already added, avoiding
1596 // duplicate sheet names
1597 hierarchy = m_frame->Schematic().GetSheets();
1598
1599 //@todo: it might be better to just iterate through the sheet names
1600 // in this screen instead of the whole hierarchy.
1601 int uniquifier = std::max( 0, wxAtoi( number ) ) + 1;
1602
1603 while( hierarchy.NameExists( candidateName ) )
1604 candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
1605
1606 nameField.SetText( candidateName );
1607
1608 wxFileName fn = sheet->GetFileName();
1609 SCH_SCREEN* existingScreen = nullptr;
1610
1611 sheet->SetParent( pasteRoot.Last() );
1612 sheet->SetScreen( nullptr );
1613
1614 if( !fn.IsAbsolute() )
1615 {
1616 wxFileName currentSheetFileName = pasteRoot.LastScreen()->GetFileName();
1617 fn.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS,
1618 currentSheetFileName.GetPath() );
1619 }
1620
1621 // Try to find the screen for the pasted sheet by several means
1622 if( !m_frame->Schematic().Root().SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ),
1623 &existingScreen ) )
1624 {
1625 if( loadedScreens.count( sheet->GetFileName() ) > 0 )
1626 existingScreen = loadedScreens.at( sheet->GetFileName() );
1627 else
1628 searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1629 }
1630
1631 if( existingScreen )
1632 {
1633 sheet->SetScreen( existingScreen );
1634 }
1635 else
1636 {
1637 if( !m_frame->LoadSheetFromFile( sheet, &pasteRoot, fn.GetFullPath() ) )
1638 m_frame->InitSheet( sheet, sheet->GetFileName() );
1639 }
1640
1641 sheetsPasted = true;
1642
1643 // Push it to the clipboard path while it still has its old KIID
1644 clipPath.push_back( sheet->m_Uuid );
1645
1646 // Assign a new KIID to the pasted sheet
1647 const_cast<KIID&>( sheet->m_Uuid ) = KIID();
1648
1649 // Make sure pins get a new UUID
1650 for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1651 const_cast<KIID&>( pin->m_Uuid ) = KIID();
1652
1653 // Once we have our new KIID we can update all pasted instances. This will either
1654 // reset the annotations or copy "kept" annotations from the supplementary clipboard.
1655 for( SCH_SHEET_PATH& instance : pasteInstances )
1656 {
1657 SCH_SHEET_PATH sheetPath = updatePastedSheet( instance, clipPath, sheet,
1658 ( forceKeepAnnotations && annotate.automatic ),
1659 &pastedSheets[instance],
1660 &pastedSymbols[instance] );
1661
1662 sheetPath.GetSymbols( pastedSymbols[instance] );
1663 }
1664 }
1665 else
1666 {
1667 SCH_ITEM* srcItem = dynamic_cast<SCH_ITEM*>( itemMap[ item->m_Uuid ] );
1668 SCH_ITEM* destItem = dynamic_cast<SCH_ITEM*>( item );
1669
1670 // Everything gets a new KIID
1671 const_cast<KIID&>( item->m_Uuid ) = KIID();
1672
1673 if( srcItem && destItem )
1674 {
1675 destItem->SetConnectivityDirty( true );
1676 destItem->SetLastResolvedState( srcItem );
1677 }
1678 }
1679
1680 // Lines need both ends selected for a move after paste so the whole line moves.
1681 if( item->Type() == SCH_LINE_T )
1682 item->SetFlags( STARTPOINT | ENDPOINT );
1683
1684 item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );
1686
1687 // Reset flags for subsequent move operation
1688 item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );
1689
1690 // Start out hidden so the pasted items aren't "ghosted" in their original location
1691 // before being moved to the current location.
1692 getView()->Hide( item, true );
1693 }
1694
1695 pasteInstances.SortByPageNumbers();
1696
1697 if( sheetsPasted )
1698 {
1699 // Update page numbers: Find next free numeric page number
1700 for( SCH_SHEET_PATH& instance : pasteInstances )
1701 {
1702 pastedSheets[instance].SortByPageNumbers();
1703
1704 for( SCH_SHEET_PATH& pastedSheet : pastedSheets[instance] )
1705 {
1706 int page = 1;
1707 wxString pageNum = wxString::Format( "%d", page );
1708
1709 while( hierarchy.PageNumberExists( pageNum ) )
1710 pageNum = wxString::Format( "%d", ++page );
1711
1712 pastedSheet.SetPageNumber( pageNum );
1713 hierarchy.push_back( pastedSheet );
1714 }
1715 }
1716
1719
1720 // Get a version with correct sheet numbers since we've pasted sheets,
1721 // we'll need this when annotating next
1722 hierarchy = m_frame->Schematic().GetSheets();
1723 }
1724
1725 std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> annotatedSymbols;
1726
1727 // Update the list of symbol instances that satisfy the annotation criteria.
1728 for( const SCH_SHEET_PATH& sheetPath : pasteInstances )
1729 {
1730 for( size_t i = 0; i < pastedSymbols[sheetPath].GetCount(); i++ )
1731 {
1732 if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS
1733 || pasteMode == PASTE_MODE::RESPECT_OPTIONS
1734 || pastedSymbols[sheetPath][i].AlwaysAnnotate() )
1735 {
1736 annotatedSymbols[sheetPath].AddItem( pastedSymbols[sheetPath][i] );
1737 }
1738 }
1739 }
1740
1741 if( !annotatedSymbols.empty() )
1742 {
1743 for( SCH_SHEET_PATH& instance : pasteInstances )
1744 {
1745 annotatedSymbols[instance].SortByReferenceOnly();
1746
1747 if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS )
1748 annotatedSymbols[instance].ReannotateDuplicates( existingRefs );
1749 else
1750 annotatedSymbols[instance].ReannotateByOptions( (ANNOTATE_ORDER_T) annotate.sort_order,
1751 (ANNOTATE_ALGO_T) annotate.method,
1752 annotateStartNum, existingRefs,
1753 true,
1754 &hierarchy );
1755
1756 annotatedSymbols[instance].UpdateAnnotation();
1757
1758 // Update existing refs for next iteration
1759 for( size_t i = 0; i < annotatedSymbols[instance].GetCount(); i++ )
1760 existingRefs.AddItem( annotatedSymbols[instance][i] );
1761 }
1762 }
1763
1765
1766 // Now clear the previous selection, select the pasted items, and fire up the "move" tool.
1768 m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
1769
1770 EE_SELECTION& selection = selTool->GetSelection();
1771
1772 if( !selection.Empty() )
1773 {
1774 if( aEvent.IsAction( &ACTIONS::duplicate ) )
1775 {
1776 int closest_dist = INT_MAX;
1777
1778 auto processPt =
1779 [&]( const VECTOR2I& pt )
1780 {
1781 int dist = ( eventPos - pt ).EuclideanNorm();
1782
1783 if( dist < closest_dist )
1784 {
1785 selection.SetReferencePoint( pt );
1786 closest_dist = dist;
1787 }
1788 };
1789
1790 // Prefer connection points (which should remain on grid)
1791 for( EDA_ITEM* item : selection.Items() )
1792 {
1793 SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
1794 LIB_PIN* lib_pin = dynamic_cast<LIB_PIN*>( item );
1795
1796 if( sch_item && sch_item->IsConnectable() )
1797 {
1798 for( const VECTOR2I& pt : sch_item->GetConnectionPoints() )
1799 processPt( pt );
1800 }
1801 else if( lib_pin )
1802 {
1803 processPt( lib_pin->GetPosition() );
1804 }
1805 }
1806
1807 // Only process other points if we didn't find any connection points
1808 if( closest_dist == INT_MAX )
1809 {
1810 for( EDA_ITEM* item : selection.Items() )
1811 {
1812 switch( item->Type() )
1813 {
1814 case SCH_LINE_T:
1815 processPt( static_cast<SCH_LINE*>( item )->GetStartPoint() );
1816 processPt( static_cast<SCH_LINE*>( item )->GetEndPoint() );
1817 break;
1818
1819 case SCH_SHAPE_T:
1820 {
1821 SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( item );
1822
1823 switch( shape->GetShape() )
1824 {
1825 case SHAPE_T::RECT:
1826 for( const VECTOR2I& pt : shape->GetRectCorners() )
1827 processPt( pt );
1828
1829 break;
1830
1831 case SHAPE_T::CIRCLE:
1832 processPt( shape->GetCenter() );
1833 break;
1834
1835 case SHAPE_T::POLY:
1836 for( int ii = 0; ii < shape->GetPolyShape().TotalVertices(); ++ii )
1837 processPt( shape->GetPolyShape().CVertex( ii ) );
1838
1839 break;
1840
1841 default:
1842 processPt( shape->GetStart() );
1843 processPt( shape->GetEnd() );
1844 break;
1845 }
1846
1847 break;
1848 }
1849
1850 default:
1851 processPt( item->GetPosition() );
1852 break;
1853 }
1854 }
1855 }
1856
1858 }
1859 else
1860 {
1861 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetTopLeftItem() );
1862
1863 selection.SetReferencePoint( item->GetPosition() );
1864 }
1865
1867 }
1868
1869 return 0;
1870}
1871
1872
1874{
1876 EE_SELECTION& selection = selTool->RequestSelection( { SCH_SYMBOL_T } );
1877 SCH_SYMBOL* symbol = nullptr;
1878 SYMBOL_EDIT_FRAME* symbolEditor;
1879
1880 if( selection.GetSize() >= 1 )
1881 symbol = (SCH_SYMBOL*) selection.Front();
1882
1883 if( selection.IsHover() )
1885
1886 if( !symbol || symbol->GetEditFlags() != 0 )
1887 return 0;
1888
1889 if( symbol->IsMissingLibSymbol() )
1890 {
1891 m_frame->ShowInfoBarError( _( "Symbols with broken library symbol links cannot "
1892 "be edited." ) );
1893 return 0;
1894 }
1895
1897 symbolEditor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1898
1899 if( symbolEditor )
1900 {
1901 if( wxWindow* blocking_win = symbolEditor->Kiway().GetBlockingDialog() )
1902 blocking_win->Close( true );
1903
1904 if( aEvent.IsAction( &EE_ACTIONS::editWithLibEdit ) )
1905 {
1906 symbolEditor->LoadSymbolFromSchematic( symbol );
1907 }
1909 {
1910 symbolEditor->LoadSymbol( symbol->GetLibId(), symbol->GetUnit(), symbol->GetConvert() );
1911
1912 if( !symbolEditor->IsSymbolTreeShown() )
1913 {
1914 wxCommandEvent evt;
1915 symbolEditor->OnToggleSymbolTree( evt );
1916 }
1917 }
1918 }
1919
1920 return 0;
1921}
1922
1923
1925{
1926 wxCommandEvent dummy;
1928 return 0;
1929}
1930
1931
1933{
1934 wxCommandEvent dummy;
1936 return 0;
1937}
1938
1939
1941{
1943 dlg.ShowQuasiModal();
1944 return 0;
1945}
1946
1947
1949{
1952
1953 return 0;
1954}
1955
1956
1958{
1959 wxCommandEvent dummy;
1961 return 0;
1962}
1963
1964
1966{
1967 wxCommandEvent dummy;
1969 return 0;
1970}
1971
1972
1974{
1976 dlg.ShowModal();
1977 return 0;
1978}
1979
1980
1982{
1983 int result = NET_PLUGIN_CHANGE;
1984
1985 // If a plugin is removed or added, rebuild and reopen the new dialog
1986 while( result == NET_PLUGIN_CHANGE )
1987 result = InvokeDialogNetList( m_frame );
1988
1989 return 0;
1990}
1991
1992
1994{
1996 return 0;
1997}
1998
1999
2001{
2004 return 0;
2005}
2006
2007
2009{
2010 getEditFrame<SCH_EDIT_FRAME>()->ToggleSchematicHierarchy();
2011 return 0;
2012}
2013
2014
2016{
2019
2022
2023 return 0;
2024}
2025
2026
2028{
2031
2034
2035 return 0;
2036}
2037
2038
2040{
2043
2046
2047 return 0;
2048}
2049
2050
2052{
2055
2058
2059 return 0;
2060}
2061
2062
2064{
2067
2070
2071 return 0;
2072}
2073
2074
2076{
2077 m_frame->eeconfig()->m_Drawing.line_mode = aEvent.Parameter<int>();
2079 return 0;
2080}
2081
2082
2084{
2088 return 0;
2089}
2090
2091
2093{
2096 return 0;
2097}
2098
2099
2101{
2104 return 0;
2105}
2106
2107
2109{
2110
2112 return 0;
2113}
2114
2115
2117{
2118 int errors = 0;
2119 wxString details;
2120 bool quiet = aEvent.Parameter<bool>();
2121
2122 // Repair duplicate IDs.
2123 std::map<KIID, EDA_ITEM*> ids;
2124 int duplicates = 0;
2125
2126 auto processItem =
2127 [&]( EDA_ITEM* aItem )
2128 {
2129 auto it = ids.find( aItem->m_Uuid );
2130
2131 if( it != ids.end() && it->second != aItem )
2132 {
2133 duplicates++;
2134 const_cast<KIID&>( aItem->m_Uuid ) = KIID();
2135 }
2136
2137 ids[ aItem->m_Uuid ] = aItem;
2138 };
2139
2140 // Symbol IDs are the most important, so give them the first crack at "claiming" a
2141 // particular KIID.
2142
2143 for( const SCH_SHEET_PATH& sheet : m_frame->Schematic().GetSheets() )
2144 {
2145 SCH_SCREEN* screen = sheet.LastScreen();
2146
2147 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
2148 {
2149 processItem( item );
2150
2151 for( SCH_PIN* pin : static_cast<SCH_SYMBOL*>( item )->GetPins( &sheet ) )
2152 processItem( pin );
2153 }
2154 }
2155
2156 for( const SCH_SHEET_PATH& sheet : m_frame->Schematic().GetSheets() )
2157 {
2158 SCH_SCREEN* screen = sheet.LastScreen();
2159
2160 for( SCH_ITEM* item : screen->Items() )
2161 {
2162 processItem( item );
2163
2164 item->RunOnChildren(
2165 [&]( SCH_ITEM* aChild )
2166 {
2167 processItem( item );
2168 } );
2169 }
2170 }
2171
2172 /*******************************
2173 * Your test here
2174 */
2175
2176 /*******************************
2177 * Inform the user
2178 */
2179
2180 if( duplicates )
2181 {
2182 errors += duplicates;
2183 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
2184 }
2185
2186 if( errors )
2187 {
2188 m_frame->OnModify();
2189
2190 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
2191
2192 if( !quiet )
2193 DisplayInfoMessage( m_frame, msg, details );
2194 }
2195 else if( !quiet )
2196 {
2197 DisplayInfoMessage( m_frame, _( "No errors found." ) );
2198 }
2199
2200 return 0;
2201}
2202
2203
2205{
2206 Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
2207 Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
2208 Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
2215 Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
2216 Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
2217
2220
2226
2227#ifdef KICAD_SPICE
2228 Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
2229 Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
2230#endif /* KICAD_SPICE */
2231
2237
2239
2240 Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
2241 Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
2242 Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
2243 Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
2247
2261
2263
2274
2276
2278
2281}
const char * name
Definition: DXF_plotter.cpp:56
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:167
static TOOL_ACTION paste
Definition: actions.h:69
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:68
static TOOL_ACTION pickerTool
Definition: actions.h:158
static TOOL_ACTION showSymbolEditor
Definition: actions.h:164
static TOOL_ACTION pasteSpecial
Definition: actions.h:70
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 undo
Definition: actions.h:65
static TOOL_ACTION duplicate
Definition: actions.h:72
static TOOL_ACTION doDelete
Definition: actions.h:73
static TOOL_ACTION quit
Definition: actions.h:59
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:168
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION doNew
Definition: actions.h:47
static TOOL_ACTION cut
Definition: actions.h:67
static TOOL_ACTION refreshPreview
Definition: actions.h:109
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
Calculates the connectivity of a schematic and generates netlists.
CONNECTION_SUBGRAPH * GetSubgraphForItem(SCH_ITEM *aItem)
A subgraph is a set of items that are electrically connected on a single sheet.
PRIORITY GetDriverPriority()
std::vector< SCH_ITEM * > m_items
void SetWksFileName(const wxString &aFilename)
bool PrjConfigChanged()
Return true if the project configuration was modified.
int ShowQuasiModal()
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Add a command to undo in the undo list.
virtual int GetRedoCommandCount() const
UNDO_REDO_CONTAINER m_undoList
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...
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)
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
Update the board display after modifying it by a python script (note: it is automatically called by a...
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:249
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:145
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:139
const KIID m_Uuid
Definition: eda_item.h:492
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
void ClearBrightened()
Definition: eda_item.h:119
void SetBrightened()
Definition: eda_item.h:116
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
bool IsBrightened() const
Definition: eda_item.h:108
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:247
SHAPE_T GetShape() const
Definition: eda_shape.h:113
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:145
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:120
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1035
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
PANEL_ANNOTATE m_AnnotatePanel
static TOOL_ACTION importFPAssignments
Definition: ee_actions.h:173
static TOOL_ACTION repairSchematic
Definition: ee_actions.h:232
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:167
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
static TOOL_ACTION toggleAnnotateAuto
Definition: ee_actions.h:241
static TOOL_ACTION lineMode90
Definition: ee_actions.h:236
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:213
static TOOL_ACTION highlightNet
Definition: ee_actions.h:249
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:120
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:250
static TOOL_ACTION assignNetclass
Definition: ee_actions.h:161
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION showPythonConsole
Definition: ee_actions.h:231
static TOOL_ACTION toggleERCWarnings
Definition: ee_actions.h:215
static TOOL_ACTION simTune
Definition: ee_actions.h:246
static TOOL_ACTION toggleERCExclusions
Definition: ee_actions.h:217
static TOOL_ACTION lineModeNext
Definition: ee_actions.h:238
static TOOL_ACTION lineModeFree
Definition: ee_actions.h:235
static TOOL_ACTION editLibSymbolWithLibEdit
Definition: ee_actions.h:171
static TOOL_ACTION toggleERCErrors
Definition: ee_actions.h:216
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:252
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:251
static TOOL_ACTION exportNetlist
Definition: ee_actions.h:174
static TOOL_ACTION assignFootprints
Definition: ee_actions.h:160
static TOOL_ACTION selectOnPCB
Definition: ee_actions.h:220
static TOOL_ACTION rescueSymbols
Definition: ee_actions.h:166
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:214
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:170
static TOOL_ACTION simProbe
Definition: ee_actions.h:245
static TOOL_ACTION exportSymbolsToLibrary
Definition: ee_actions.h:177
static TOOL_ACTION drawSheetOnClipboard
Definition: ee_actions.h:228
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:152
static TOOL_ACTION annotate
Definition: ee_actions.h:151
static TOOL_ACTION showHierarchy
Definition: ee_actions.h:205
static TOOL_ACTION lineMode45
Definition: ee_actions.h:237
static TOOL_ACTION editSymbolLibraryLinks
Definition: ee_actions.h:153
static TOOL_ACTION saveCurrSheetCopyAs
Definition: ee_actions.h:42
static TOOL_ACTION showPcbNew
Definition: ee_actions.h:172
static TOOL_ACTION generateBOM
Definition: ee_actions.h:175
static TOOL_ACTION schematicSetup
Definition: ee_actions.h:162
static TOOL_ACTION exportSymbolsToNewLibrary
Definition: ee_actions.h:178
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 })
Return either an existing selection (filtered), or the selection at the current cursor position if th...
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.
EDA_ITEM * GetNode(VECTOR2I aPosition)
Finds a connected item at a point (usually the cursor position).
EE_SELECTION & GetSelection()
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
Definition: erc.h:48
static const TOOL_EVENT ClearedEvent
Definition: actions.h:208
static const TOOL_EVENT SelectedEvent
Definition: actions.h:206
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:213
static const TOOL_EVENT PointSelectedEvent
Definition: actions.h:205
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:207
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
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:77
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
double GetScale() const
Definition: view.h:269
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:1591
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:393
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1550
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1484
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:641
Definition: kiid.h:48
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:53
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:66
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:394
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
Definition: kiway.cpp:620
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:98
VECTOR2I GetPosition() const override
Definition: lib_pin.h:222
Define a library symbol object.
Definition: lib_symbol.h:99
LIB_ID GetLibId() const override
Definition: lib_symbol.h:141
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:456
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.
static void ConvertToSpiceMarkup(std::string &aNetName)
Remove formatting wrappers and replace illegal spice net name characters with underscores.
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:97
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 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:82
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:71
void SetSnapping(bool aSnap)
Definition: picker_tool.h:64
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:62
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:102
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:126
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
Definition: project.cpp:305
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:61
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:120
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:172
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:178
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:130
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:86
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:119
SCH_SHEET & Root() const
Definition: schematic.h:91
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
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
bool IsNet() const
SCH_ITEM * Parent() const
wxString Name(bool aIgnoreSheet=false) const
bool IsBus() const
SCH_ITEM * Driver() const
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
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 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)
< Highlight net under the cursor.
int ClearHighlight(const TOOL_EVENT &aEvent)
Update net highlighting after an edit.
int EditSymbolFields(const TOOL_EVENT &aEvent)
int HighlightNetCursor(const TOOL_EVENT &aEvent)
int ImportFPAssignments(const TOOL_EVENT &aEvent)
int ChangeLineMode(const TOOL_EVENT &aEvent)
void setClipboardInstances(const SCH_SCREEN *aPastedScreen)
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)
int RescueSymbols(const TOOL_EVENT &aEvent)
Perform rescue operations to recover old projects from before certain changes were made.
std::map< KIID_PATH, SCH_SHEET_INSTANCE > m_clipboardSheetInstances
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 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 EditWithSymbolEditor(const TOOL_EVENT &aEvent)
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 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.
void updatePastedSymbol(SCH_SYMBOL *aSymbol, SCH_SCREEN *aPasteScreen, const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, bool aForceKeepAnnotations)
int ShowCvpcb(const TOOL_EVENT &aEvent)
SCH_SHEET_PATH updatePastedSheet(const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, SCH_SHEET *aSheet, bool aForceKeepAnnotations, SCH_SHEET_LIST *aPastedSheetsSoFar, SCH_REFERENCE_LIST *aPastedSymbolsSoFar)
int RepairSchematic(const TOOL_EVENT &aEvent)
int Cut(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 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 *aHierarchy, const wxString &aFileName)
Load a the KiCad schematic file aFileName into the sheet aSheet.
Definition: sheet.cpp:105
const SCH_CONNECTION * GetHighlightedConnection() const
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
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 AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
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:97
void SendSelectItemsToPcb(const std::vector< EDA_ITEM * > &aItems, bool aForce)
Sends items to Pcbnew 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
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:543
void OnUpdatePCB(wxCommandEvent &event)
void OnOpenPcbnew(wxCommandEvent &event)
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
void OnAnnotate(wxCommandEvent &event)
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void OnPageSettingsChange() override
Called when modifying the page settings.
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
void SetHighlightedConnection(const SCH_CONNECTION *aConnection)
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.
void UpdateNetHighlightStatus()
void UpdateHierarchyNavigator()
Update the hierarchy navigation tree and history.
void SetCrossProbeConnection(const SCH_CONNECTION *aConnection)
Send a connection (net or bus) to Pcbnew for highlighting.
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
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
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:101
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
virtual bool IsConnectable() const
Definition: sch_item.h:349
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:112
virtual void SetLastResolvedState(const SCH_ITEM *aItem)
Definition: sch_item.h:417
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:415
bool IsConnectivityDirty() const
Definition: sch_item.h:413
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:146
virtual std::vector< VECTOR2I > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:364
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:535
virtual void SaveSymbol(const wxString &aLibraryPath, const LIB_SYMBOL *aSymbol, const STRING_UTF8_MAP *aProperties=nullptr)
Write aSymbol to an existing library located at aLibraryPath.
Definition: sch_plugin.cpp:94
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:638
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()
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
std::map< wxString, LIB_SYMBOL * > & GetLibSymbols()
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition: sch_screen.h:478
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:227
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:562
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
const wxString & GetFileName() const
Definition: sch_screen.h:144
const std::vector< SCH_SYMBOL_INSTANCE > & GetSymbolInstances() const
Definition: sch_screen.h:513
const std::vector< SCH_SHEET_INSTANCE > & GetSheetInstances() const
Definition: sch_screen.h:518
void MigrateSimModels()
Migrate any symbols having V6 simulation models to their V7 equivalents.
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:145
A SCH_PLUGIN derivation for loading schematic files using the new s-expression file format.
void Format(SCH_SHEET *aSheet)
void LoadContent(LINE_READER &aReader, SCH_SHEET *aSheet, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
VECTOR2I GetCenter() const
Definition: sch_shape.h:80
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 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.
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:302
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:719
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:106
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:175
Schematic symbol object.
Definition: sch_symbol.h:81
bool HasBrightenedPins()
int GetUnit() const
Definition: sch_symbol.h:228
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:290
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:652
void ClearBrightenedPins()
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:843
int GetConvert() const
Definition: sch_symbol.h:270
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:694
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.
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
Definition: sch_symbol.cpp:236
void SetUnit(int aUnit)
Change the unit number to aUnit.
Definition: sch_symbol.cpp:384
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:175
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:879
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:787
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:192
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:299
virtual void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:188
void BrightenItem(EDA_ITEM *aItem)
void UnbrightenItem(EDA_ITEM *aItem)
void SetIsHover(bool aIsHover)
Definition: selection.h:78
std::deque< EDA_ITEM * > & Items()
Definition: selection.h:213
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:260
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the aGlobalIndex-th vertex in the poly set.
int FindModelPinIndex(const std::string &aSymbolPinNumber)
Definition: sim_model.cpp:702
const SPICE_GENERATOR & SpiceGenerator() const
Definition: sim_model.h:430
Implementing SIM_PLOT_FRAME_BASE.
virtual std::vector< std::string > CurrentNames(const SPICE_ITEM &aItem) const
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:415
const std::string & GetString()
Definition: richio.h:438
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:241
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_PLUGIN obje...
const wxString GetType() const override
Return the type of symbol library table represented by this row.
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
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:215
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:156
bool DisableGridSnapping() const
Definition: tool_event.h:344
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:442
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:88
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:55
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
std::string GetClipboardUTF8() const
Return the information currently stored in the system clipboard.
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:296
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
A wrapper for reporting to a wxString object.
Definition: reporter.h:164
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:380
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:300
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:352
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:325
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:110
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)
@ REMOVE_ANNOTATIONS
@ UNIQUE_ANNOTATIONS
int InvokeDialogPrintUsingPrinter(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_PRINT_USING_PRINTER and return whatever DIALOG_PRINT_USING_PRINTER::ShowModal(...
#define _(s)
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:524
#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_COUNT
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
@ FRAME_SIMULATOR
Definition: frame_type.h:38
const std::string KiCadSymbolLibFileExtension
const std::string KiCadSchematicFileExtension
wxString KiCadSchematicFileWildcard()
wxString KiCadSymbolLibFileWildcard()
#define NET_PLUGIN_CHANGE
Create and shows DIALOG_EXPORT_NETLIST and returns whatever DIALOG_EXPORT_NETLIST::ShowModal() return...
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
@ LAYER_ERC_WARN
Definition: layer_ids.h:369
@ LAYER_ERC_EXCLUSION
Definition: layer_ids.h:371
@ LAYER_ERC_ERR
Definition: layer_ids.h:370
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:52
@ GEOMETRY
Position or shape has changed.
Definition: view_item.h:49
#define MAX_PAGE_SIZE_EESCHEMA_MILS
Definition: page_info.h:41
#define NAMELESS_PROJECT
default name for nameless projects
Definition: project.h:42
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
@ 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)
A simple container for sheet instance information.
A simple container for schematic symbol instance information.
static constexpr auto NOT_CONNECTED
Definition: sim_model.h:293
std::string refName
Definition for symbol library class.
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ 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:45
@ TA_UNDO_REDO_PRE
Definition: tool_event.h:101
@ TC_MESSAGE
Definition: tool_event.h:53
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129
@ SCH_LINE_T
Definition: typeinfo.h:146
@ SCH_SYMBOL_T
Definition: typeinfo.h:156
@ SCH_FIELD_T
Definition: typeinfo.h:155
@ SCH_SHEET_T
Definition: typeinfo.h:158
@ SCH_SHAPE_T
Definition: typeinfo.h:147
@ SCH_PIN_T
Definition: typeinfo.h:159
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:85
Definition of file extensions used in Kicad.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
Definition: wx_filename.h:38