KiCad PCB EDA Suite
Loading...
Searching...
No Matches
symbol_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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
22
23#include <advanced_config.h>
25#include <confirm.h>
27#include <gestfich.h> // To open with a text editor
28#include <kidialog.h>
29#include <kiway.h>
30#include <launch_ext.h> // To default when file manager setting is empty
33#include <pgm_base.h>
34#include <sch_painter.h>
35#include <string_utils.h>
36#include <symbol_edit_frame.h>
39#include <symbol_viewer_frame.h>
43#include <tool/tool_manager.h>
44#include <tools/sch_actions.h>
46
47#include <wx/filedlg.h>
48#include <kiplatform/ui.h>
49
54#include <lib_symbol.h>
55#include <symbol_edit_frame.h>
56
57#include <map>
58
59
61{
65
67 {
68 LIBRARY_EDITOR_CONTROL* libraryTreeTool = m_toolMgr->GetTool<LIBRARY_EDITOR_CONTROL>();
69 CONDITIONAL_MENU& ctxMenu = m_menu->GetMenu();
70
71 auto libSelectedCondition =
72 [this]( const SELECTION& aSel )
73 {
75 {
76 LIB_ID sel = editFrame->GetTreeLIBID();
77 return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty();
78 }
79
80 return false;
81 };
82
83 // The libInferredCondition allows you to do things like New Symbol and Paste with a
84 // symbol selected (in other words, when we know the library context even if the library
85 // itself isn't selected.
86 auto libInferredCondition =
87 [this]( const SELECTION& aSel )
88 {
90 {
91 LIB_ID sel = editFrame->GetTreeLIBID();
92 return !sel.GetLibNickname().empty();
93 }
94
95 return false;
96 };
97
98 auto symbolSelectedCondition =
99 [this]( const SELECTION& aSel )
100 {
102 {
103 LIB_ID sel = editFrame->GetTargetLibId();
104 return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
105 }
106
107 return false;
108 };
109
110 auto derivedSymbolSelectedCondition =
111 [this]( const SELECTION& aSel )
112 {
114 {
115 LIB_ID sel = editFrame->GetTargetLibId();
116
117 if( sel.GetLibNickname().empty() || sel.GetLibItemName().empty() )
118 return false;
119
120 LIB_SYMBOL_LIBRARY_MANAGER& libMgr = editFrame->GetLibManager();
121 const LIB_SYMBOL* sym = libMgr.GetSymbol( sel.GetLibItemName(), sel.GetLibNickname() );
122
123 return sym && sym->IsDerived();
124 }
125
126 return false;
127 };
128
129 auto relatedSymbolSelectedCondition =
130 [this]( const SELECTION& aSel )
131 {
133 {
134 LIB_ID sel = editFrame->GetTargetLibId();
135
136 if( sel.GetLibNickname().empty() || sel.GetLibItemName().empty() )
137 return false;
138
139 LIB_SYMBOL_LIBRARY_MANAGER& libMgr = editFrame->GetLibManager();
140 const LIB_SYMBOL* sym = libMgr.GetSymbol( sel.GetLibItemName(), sel.GetLibNickname() );
141
142 // This runs on every menu evaluation, so ask for the answer and not the list
143 return ( sym && sym->IsDerived() )
144 || libMgr.HasDerivedSymbols( sel.GetLibItemName(), sel.GetLibNickname() );
145 }
146
147 return false;
148 };
149
150 auto multiSymbolSelectedCondition =
151 [this]( const SELECTION& aSel )
152 {
154
155 if( editFrame && editFrame->GetTreeSelectionCount() > 1 )
156 {
157 for( LIB_ID& sel : editFrame->GetSelectedLibIds() )
158 {
159 if( !sel.IsValid() )
160 return false;
161 }
162
163 return true;
164 }
165
166 return false;
167 };
168/* not used, yet
169 auto multiLibrarySelectedCondition =
170 [this]( const SELECTION& aSel )
171 {
172 SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
173
174 if( editFrame && editFrame->GetTreeSelectionCount() > 1 )
175 {
176 for( LIB_ID& sel : editFrame->GetSelectedLibIds() )
177 {
178 if( sel.IsValid() )
179 return false;
180 }
181
182 return true;
183 }
184
185 return false;
186 };
187*/
188 auto canOpenExternally =
189 [this]( const SELECTION& aSel )
190 {
191 // The option is shown if the lib has no current edits
193 {
194 LIB_SYMBOL_LIBRARY_MANAGER& libMgr = editFrame->GetLibManager();
195 wxString libName = editFrame->GetTargetLibId().GetLibNickname();
196 return !libMgr.IsLibraryModified( libName );
197 }
198
199 return false;
200 };
201
202
203// clang-format off
204 ctxMenu.AddItem( SCH_ACTIONS::newSymbol, libInferredCondition, 10 );
205 ctxMenu.AddItem( SCH_ACTIONS::deriveFromExistingSymbol, symbolSelectedCondition, 10 );
206
207 ctxMenu.AddSeparator( 10 );
208 ctxMenu.AddItem( ACTIONS::save, symbolSelectedCondition || libInferredCondition, 10 );
209 ctxMenu.AddItem( SCH_ACTIONS::saveLibraryAs, libSelectedCondition, 10 );
210 ctxMenu.AddItem( SCH_ACTIONS::saveSymbolAs, symbolSelectedCondition, 10 );
211 ctxMenu.AddItem( SCH_ACTIONS::saveSymbolCopyAs, symbolSelectedCondition, 10 );
212 ctxMenu.AddItem( ACTIONS::revert, symbolSelectedCondition || libInferredCondition, 10 );
213
214 ctxMenu.AddSeparator( 20 );
215 ctxMenu.AddItem( SCH_ACTIONS::importSymbol, libInferredCondition, 20 );
216 ctxMenu.AddItem( SCH_ACTIONS::exportSymbol, symbolSelectedCondition, 20 );
217
218 ctxMenu.AddSeparator( 100 );
219 ctxMenu.AddItem( SCH_ACTIONS::cutSymbol, symbolSelectedCondition || multiSymbolSelectedCondition, 100 );
220 ctxMenu.AddItem( SCH_ACTIONS::copySymbol, symbolSelectedCondition || multiSymbolSelectedCondition, 100 );
221 ctxMenu.AddItem( SCH_ACTIONS::pasteSymbol, libInferredCondition, 100 );
222 ctxMenu.AddItem( SCH_ACTIONS::duplicateSymbol, symbolSelectedCondition, 100 );
223 ctxMenu.AddItem( SCH_ACTIONS::deleteSymbol, symbolSelectedCondition || multiSymbolSelectedCondition, 100 );
224
225 ctxMenu.AddSeparator( 120 );
226 ctxMenu.AddItem( SCH_ACTIONS::renameSymbol, symbolSelectedCondition, 120 );
227 ctxMenu.AddItem( SCH_ACTIONS::symbolProperties, symbolSelectedCondition, 120 );
228 ctxMenu.AddItem( SCH_ACTIONS::flattenSymbol, derivedSymbolSelectedCondition, 120 );
229
230 if( ADVANCED_CFG::GetCfg().m_EnableLibWithText || ADVANCED_CFG::GetCfg().m_EnableLibDir )
231 ctxMenu.AddSeparator( 200 );
232
233 if( ADVANCED_CFG::GetCfg().m_EnableLibWithText )
234 ctxMenu.AddItem( ACTIONS::openWithTextEditor, canOpenExternally && ( symbolSelectedCondition || libSelectedCondition ), 200 );
235
236 if( ADVANCED_CFG::GetCfg().m_EnableLibDir )
237 ctxMenu.AddItem( ACTIONS::openDirectory, canOpenExternally && ( symbolSelectedCondition || libSelectedCondition ), 200 );
238
239 ctxMenu.AddSeparator( 300 );
240 ctxMenu.AddItem( SCH_ACTIONS::showLibFieldsTable, libInferredCondition, 300 );
241 ctxMenu.AddItem( SCH_ACTIONS::showRelatedLibFieldsTable, relatedSymbolSelectedCondition, 300 );
242
243 libraryTreeTool->AddContextMenuItems( &ctxMenu );
244 }
245// clang-format on
246
247 return true;
248}
249
250
252{
253 bool createNew = aEvent.IsAction( &ACTIONS::newLibrary );
254
255 if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
256 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->AddLibraryFile( createNew );
257
258 return 0;
259}
260
261
263{
264 wxString libFile = *aEvent.Parameter<wxString*>();
265
266 if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
267 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->DdAddLibrary( libFile );
268
269 return 0;
270}
271
272
274{
275 if( !m_isSymbolEditor )
276 return 0;
277
279 int unit = 0;
280 LIB_ID partId = editFrame->GetTreeLIBID( &unit );
281
282 editFrame->LoadSymbol( partId.GetLibItemName(), partId.GetLibNickname(), unit );
283 return 0;
284}
285
286
288{
290 const LIB_SYMBOL* symbol = editFrame->GetCurSymbol();
291
292 if( !symbol || !editFrame->IsSymbolFromSchematic() )
293 {
294 wxBell();
295 return 0;
296 }
297
298 const LIB_ID& libId = symbol->GetLibId();
299
300 if( editFrame->LoadSymbol( libId, editFrame->GetUnit(), editFrame->GetBodyStyle() ) )
301 {
302 if( !editFrame->IsLibraryTreeShown() )
303 editFrame->ToggleLibraryTree();
304 }
305 else
306 {
307 const wxString libName = libId.GetLibNickname();
308 const wxString symbolName = libId.GetLibItemName();
309
310 DisplayError( editFrame,
311 wxString::Format( _( "Failed to load symbol %s from "
312 "library %s." ),
313 UnescapeString( symbolName ), UnescapeString( libName ) ) );
314 }
315 return 0;
316}
317
318
320{
321 if( !m_isSymbolEditor )
322 return 0;
323
325 LIB_ID target = editFrame->GetTargetLibId();
326 const wxString& libName = target.GetLibNickname();
327 wxString msg;
328
329 if( libName.IsEmpty() )
330 {
331 msg.Printf( _( "No symbol library selected." ) );
332 m_frame->ShowInfoBarError( msg );
333 return 0;
334 }
335
336 if( !editFrame->GetLibManager().LibraryExists( libName ) )
337 {
338 msg.Printf( _( "Symbol library '%s' not found." ), libName );
339 m_frame->ShowInfoBarError( msg );
340 return 0;
341 }
342
343 if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
344 {
345 msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
346 m_frame->ShowInfoBarError( msg );
347 return 0;
348 }
349
350 if( aEvent.IsAction( &SCH_ACTIONS::newSymbol ) )
351 editFrame->CreateNewSymbol();
353 editFrame->CreateNewSymbol( target.GetLibItemName() );
354 else if( aEvent.IsAction( &SCH_ACTIONS::importSymbol ) )
355 editFrame->ImportSymbol();
356
357 return 0;
358}
359
360
362{
363 if( !m_isSymbolEditor )
364 return 0;
365
367
368 if( aEvt.IsAction( &SCH_ACTIONS::save ) )
369 editFrame->Save();
370 else if( aEvt.IsAction( &SCH_ACTIONS::saveLibraryAs ) )
371 editFrame->SaveLibraryAs();
372 else if( aEvt.IsAction( &SCH_ACTIONS::saveSymbolAs ) )
373 editFrame->SaveSymbolCopyAs( true );
374 else if( aEvt.IsAction( &SCH_ACTIONS::saveSymbolCopyAs ) )
375 editFrame->SaveSymbolCopyAs( false );
376 else if( aEvt.IsAction( &SCH_ACTIONS::saveAll ) )
377 editFrame->SaveAll();
378
379 return 0;
380}
381
382
384{
385 if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
386 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->Revert();
387
388 return 0;
389}
390
391
393{
394 if( !m_isSymbolEditor )
395 return 0;
396
399
400 LIB_ID libId = editFrame->GetTreeLIBID();
401
402 wxString libName = libId.GetLibNickname();
403 std::optional<wxString> libItemName =
404 manager.GetFullURI( LIBRARY_TABLE_TYPE::SYMBOL, libName, true );
405
406 wxCHECK( libItemName, 0 );
407
408 wxFileName fileName( *libItemName );
409
410 wxString filePath = wxEmptyString;
411 wxString explorerCommand;
412
413 if( COMMON_SETTINGS* cfg = Pgm().GetCommonSettings() )
414 explorerCommand = cfg->m_System.file_explorer;
415
416 if( explorerCommand.IsEmpty() )
417 {
418 filePath = fileName.GetFullPath().BeforeLast( wxFileName::GetPathSeparator() );
419
420 if( !filePath.IsEmpty() && wxDirExists( filePath ) )
421 LaunchExternal( filePath );
422
423 return 0;
424 }
425
426 if( !explorerCommand.EndsWith( "%F" ) )
427 {
428 wxMessageBox( _( "Missing/malformed file explorer argument '%F' in common settings." ) );
429 return 0;
430 }
431
432 filePath = fileName.GetFullPath();
433 filePath.Replace( wxS( "\"" ), wxS( "_" ) );
434
435 wxString fileArg = '"' + filePath + '"';
436
437 explorerCommand.Replace( wxT( "%F" ), fileArg );
438
439 if( !explorerCommand.IsEmpty() )
440 wxExecute( explorerCommand );
441
442 return 0;
443}
444
445
447{
448 if( !m_isSymbolEditor )
449 return 0;
450
452 wxString textEditorName = Pgm().GetTextEditor();
453
454 if( textEditorName.IsEmpty() )
455 {
456 wxMessageBox( _( "No text editor selected in KiCad. Please choose one." ) );
457 return 0;
458 }
459
461
462 LIB_ID libId = editFrame->GetTreeLIBID();
463 wxString libName = libId.GetLibNickname();
464
465 std::optional<wxString> optUri =
466 manager.GetFullURI( LIBRARY_TABLE_TYPE::SYMBOL, libName, true );
467
468 wxCHECK( optUri, 0 );
469
470 wxString tempFName = ( *optUri ).wc_str();
471
472 if( !tempFName.IsEmpty() )
473 ExecuteFile( textEditorName, tempFName, nullptr, false );
474
475 return 0;
476}
477
478
480{
481 if( !m_isSymbolEditor )
482 return 0;
483
485
487 editFrame->CopySymbolToClipboard();
488
490 {
491 bool hasWritableLibs = false;
492 wxString msg;
493
494 for( LIB_ID& sel : editFrame->GetSelectedLibIds() )
495 {
496 const wxString& libName = sel.GetLibNickname();
497
498 if( !editFrame->GetLibManager().LibraryExists( libName ) )
499 msg.Printf( _( "Symbol library '%s' not found." ), libName );
500 else if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
501 msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
502 else
503 hasWritableLibs = true;
504 }
505
506 if( !msg.IsEmpty() )
507 m_frame->ShowInfoBarError( msg );
508
509 if( !hasWritableLibs )
510 return 0;
511
512 editFrame->DeleteSymbolFromLibrary();
513 }
514
515 return 0;
516}
517
518
520{
521 if( !m_isSymbolEditor )
522 return 0;
523
525 LIB_ID sel = editFrame->GetTargetLibId();
526 // DuplicateSymbol() is called to duplicate a symbol, or to paste a previously
527 // saved symbol in clipboard
528 bool isPasteAction = aEvent.IsAction( &SCH_ACTIONS::pasteSymbol );
529 wxString msg;
530
531 if( !sel.IsValid() && !isPasteAction )
532 {
533 // When duplicating a symbol, a source symbol must exists.
534 msg.Printf( _( "No symbol selected" ) );
535 m_frame->ShowInfoBarError( msg );
536 return 0;
537 }
538
539 const wxString& libName = sel.GetLibNickname();
540
541 if( !editFrame->GetLibManager().LibraryExists( libName ) )
542 {
543 msg.Printf( _( "Symbol library '%s' not found." ), libName );
544 m_frame->ShowInfoBarError( msg );
545 return 0;
546 }
547
548 if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
549 {
550 msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
551 m_frame->ShowInfoBarError( msg );
552 return 0;
553 }
554
555 editFrame->DuplicateSymbol( isPasteAction );
556 return 0;
557}
558
559
561{
562 if( !m_isSymbolEditor )
563 return 0;
564
566 LIB_SYMBOL_LIBRARY_MANAGER& libMgr = editFrame->GetLibManager();
568
569 LIB_ID libId = editFrame->GetTreeLIBID();
570 wxString libName = libId.GetLibNickname();
571 wxString oldName = libId.GetLibItemName();
572 wxString newName;
573 wxString msg;
574
575 if( !libMgr.LibraryExists( libName ) )
576 return 0;
577
578 if( !libTool->RenameLibrary( _( "Change Symbol Name" ), oldName,
579 [&]( const wxString& aNewName )
580 {
581 newName = EscapeString( aNewName, CTX_LIBID );
582
583 if( newName.IsEmpty() )
584 {
585 wxMessageBox( _( "Symbol must have a name." ) );
586 return false;
587 }
588
589 // If no change, accept it without prompting
590 if( newName != oldName && libMgr.SymbolNameInUse( newName, libName ) )
591 {
592 msg.Printf( _( "Symbol '%s' already exists in library '%s'." ),
593 UnescapeString( newName ),
594 libName );
595
596 KIDIALOG errorDlg( m_frame, msg, _( "Confirmation" ),
597 wxOK | wxCANCEL | wxICON_WARNING );
598
599 errorDlg.SetOKLabel( _( "Overwrite" ) );
600
601 return errorDlg.ShowModal() == wxID_OK;
602 }
603
604 return true;
605 } ) )
606 {
607 return 0; // cancelled by user
608 }
609
610 if( newName == oldName )
611 return 0;
612
613 LIB_SYMBOL* libSymbol = libMgr.GetBufferedSymbol( oldName, libName );
614
615 if( !libSymbol )
616 return 0;
617
618 // Renaming the current symbol
619 const bool isCurrentSymbol = editFrame->IsCurrentSymbol( libId );
620 bool overwritingCurrentSymbol = false;
621
622 if( libMgr.SymbolExists( newName, libName ) )
623 {
624 // Overwriting the current symbol also need to update the open symbol
625 LIB_SYMBOL* const overwrittenSymbol = libMgr.GetBufferedSymbol( newName, libName );
626 overwritingCurrentSymbol = editFrame->IsCurrentSymbol( overwrittenSymbol->GetLibId() );
627 libMgr.RemoveSymbol( newName, libName );
628 }
629
630 libSymbol->SetName( newName );
631
632 if( libSymbol->GetValueField().GetText() == oldName )
633 libSymbol->GetValueField().SetText( newName );
634
635 libMgr.UpdateSymbolAfterRename( libSymbol, newName, libName );
636 libMgr.SetSymbolModified( newName, libName );
637
638 if( overwritingCurrentSymbol )
639 {
640 // We overwrite the old current symbol with the renamed one, so show
641 // the renamed one now
642 editFrame->SetCurSymbol( new LIB_SYMBOL( *libSymbol ), false );
643 }
644 else if( isCurrentSymbol && editFrame->GetCurSymbol() )
645 {
646 // Renamed the current symbol - follow it
647 libSymbol = editFrame->GetCurSymbol();
648
649 libSymbol->SetName( newName );
650
651 if( libSymbol->GetValueField().GetText() == oldName )
652 libSymbol->GetValueField().SetText( newName );
653
654 editFrame->RebuildView();
655 editFrame->OnModify();
656
657 // N.B. The view needs to be rebuilt first as the Symbol Properties change may
658 // invalidate the view pointers by rebuilting the field table
659 editFrame->UpdateMsgPanel();
660 }
661
662 editFrame->RenameSymbolTab( libId, LIB_ID( libName, newName ) );
663
664 wxDataViewItem treeItem = libMgr.GetAdapter()->FindItem( libId );
665 editFrame->UpdateLibraryTree( treeItem, libSymbol );
666 editFrame->FocusOnLibId( LIB_ID( libName, newName ) );
667 return 0;
668}
669
670
678
679
681{
682 SCH_RENDER_SETTINGS* renderSettings = m_frame->GetRenderSettings();
683 renderSettings->m_ShowPinsElectricalType = !renderSettings->m_ShowPinsElectricalType;
684
685 // Update canvas
686 m_frame->GetCanvas()->GetView()->UpdateAllItems( KIGFX::REPAINT );
687 m_frame->GetCanvas()->Refresh();
688
689 return 0;
690}
691
692
694{
695 SCH_RENDER_SETTINGS* renderSettings = m_frame->GetRenderSettings();
696 renderSettings->m_ShowPinNumbers = !renderSettings->m_ShowPinNumbers;
697
698 // Update canvas
699 m_frame->GetCanvas()->GetView()->UpdateAllItems( KIGFX::REPAINT );
700 m_frame->GetCanvas()->Refresh();
701
702 return 0;
703}
704
705
707{
708 if( !m_isSymbolEditor )
709 return 0;
710
712
713 if( SYMBOL_EDITOR_SETTINGS* cfg = editFrame->GetSettings() )
714 cfg->m_SyncPinEdit = !cfg->m_SyncPinEdit;
715
716 return 0;
717}
718
719
721{
722 if( !m_isSymbolEditor )
723 return 0;
724
725 SYMBOL_EDITOR_SETTINGS* cfg = m_frame->libeditconfig();
727
729 cfg->m_ShowHiddenPins;
730
732 m_frame->GetCanvas()->Refresh();
733 return 0;
734}
735
736
738{
739 if( !m_isSymbolEditor )
740 return 0;
741
742 SYMBOL_EDITOR_SETTINGS* cfg = m_frame->libeditconfig();
744
746
748 m_frame->GetCanvas()->Refresh();
749 return 0;
750}
751
752
754{
755 if( !m_isSymbolEditor )
756 return 0;
757
758 SYMBOL_EDITOR_SETTINGS& cfg = *m_frame->libeditconfig();
760
761 m_frame->GetRenderSettings()->m_ShowPinAltIcons = cfg.m_ShowPinAltIcons;
762
764 m_frame->GetCanvas()->Refresh();
765 return 0;
766}
767
768
770{
771 if( !m_isSymbolEditor )
772 return 0;
773
775 LIB_SYMBOL* symbol = editFrame->GetCurSymbol();
776
777 if( !symbol )
778 {
779 wxMessageBox( _( "No symbol to export" ) );
780 return 0;
781 }
782
783 wxFileName fn( symbol->GetName() );
784 fn.SetExt( "png" );
785
786 wxString projectPath = wxPathOnly( m_frame->Prj().GetProjectFullName() );
787
788 wxFileDialog dlg( editFrame, _( "Export View as PNG" ), projectPath, fn.GetFullName(),
789 FILEEXT::PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
790
792
793 if( dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty() )
794 {
795 // calling wxYield is mandatory under Linux, after closing the file selector dialog
796 // to refresh the screen before creating the PNG or JPEG image from screen
797 wxYield();
798
799 if( !editFrame->SaveCanvasImageToFile( dlg.GetPath(), BITMAP_TYPE::PNG ) )
800 {
801 wxMessageBox( wxString::Format( _( "Can't save file '%s'." ), dlg.GetPath() ) );
802 }
803 }
804
805 return 0;
806}
807
808
810{
811 if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
812 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->ExportSymbol();
813
814 return 0;
815}
816
817
819{
820 if( !m_isSymbolEditor )
821 return 0;
822
824 LIB_SYMBOL* symbol = editFrame->GetCurSymbol();
825
826 if( !symbol )
827 {
828 wxMessageBox( _( "No symbol to export" ) );
829 return 0;
830 }
831
832 wxFileName fn( symbol->GetName() );
833 fn.SetExt( FILEEXT::SVGFileExtension );
834
835 wxString pro_dir = wxPathOnly( m_frame->Prj().GetProjectFullName() );
836
837 wxString fullFileName = wxFileSelector( _( "SVG File Name" ), pro_dir, fn.GetFullName(),
839 wxFD_SAVE,
840 m_frame );
841
842 if( !fullFileName.IsEmpty() )
843 {
844 // The symbol origin is kept at the SVG origin; the page/viewBox is sized to the symbol.
845 editFrame->SVGPlotSymbol( fullFileName );
846 }
847
848 return 0;
849}
850
851
853{
854 if( !m_isSymbolEditor )
855 return 0;
856
858 LIB_SYMBOL_LIBRARY_MANAGER& libMgr = editFrame->GetLibManager();
859 LIB_ID symId = editFrame->GetTargetLibId();
860
861 if( !symId.IsValid() )
862 {
863 wxMessageBox( _( "No symbol to flatten" ) );
864 return 0;
865 }
866
867 const LIB_SYMBOL* symbol = libMgr.GetBufferedSymbol( symId.GetLibItemName(), symId.GetLibNickname() );
868 std::unique_ptr<LIB_SYMBOL> flatSymbol = symbol->Flatten();
869 wxCHECK_MSG( flatSymbol, 0, _( "Failed to flatten symbol" ) );
870
871 if( !libMgr.UpdateSymbol( flatSymbol.get(), symId.GetLibNickname() ) )
872 {
873 wxMessageBox( _( "Failed to update library with flattened symbol" ) );
874 return 0;
875 }
876
877 wxDataViewItem treeItem = libMgr.GetAdapter()->FindItem( symId );
878 editFrame->UpdateLibraryTree( treeItem, flatSymbol.get() );
879
880 return 0;
881}
882
883
885{
886 LIB_SYMBOL* libSymbol = nullptr;
887 LIB_ID libId;
888 int unit, bodyStyle;
889
890 if( m_isSymbolEditor )
891 {
893
894 libSymbol = editFrame->GetCurSymbol();
895 unit = editFrame->GetUnit();
896 bodyStyle = editFrame->GetBodyStyle();
897
898 if( libSymbol )
899 libId = libSymbol->GetLibId();
900 }
901 else
902 {
904
905 libSymbol = viewerFrame->GetSelectedSymbol();
906 unit = viewerFrame->GetUnit();
907 bodyStyle = viewerFrame->GetBodyStyle();
908
909 if( libSymbol )
910 libId = libSymbol->GetLibId();
911 }
912
913 if( libSymbol )
914 {
915 SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH, false );
916
917 if( !schframe ) // happens when the schematic editor is not active (or closed)
918 {
919 DisplayErrorMessage( m_frame, _( "No schematic currently open." ) );
920 return 0;
921 }
922
923 wxWindow* blocking_dialog = schframe->Kiway().GetBlockingDialog();
924
925 if( blocking_dialog )
926 {
927 blocking_dialog->Raise();
928 wxBell();
929 return 0;
930 }
931
932 SCH_SYMBOL* symbol = new SCH_SYMBOL( *libSymbol, libId, &schframe->GetCurrentSheet(),
933 unit, bodyStyle );
934
935 symbol->SetParent( schframe->GetScreen() );
936
937 if( schframe->eeconfig()->m_AutoplaceFields.enable )
938 {
939 // Not placed yet, so pass a nullptr screen reference
940 symbol->AutoplaceFields( nullptr, AUTOPLACE_AUTO );
941 }
942
943 schframe->Raise();
945 SCH_ACTIONS::PLACE_SYMBOL_PARAMS{ symbol, true } );
946 }
947
948 return 0;
949}
950
951
953{
954 if( !m_isSymbolEditor )
955 return 0;
956
958 const int deltaUnit = aEvent.Parameter<int>();
959
960 const int nUnits = editFrame->GetCurSymbol()->GetUnitCount();
961 const int newUnit = ( ( editFrame->GetUnit() - 1 + deltaUnit + nUnits ) % nUnits ) + 1;
962
963 editFrame->SetUnit( newUnit );
964
965 return 0;
966}
967
968
970{
971 if( SYMBOL_VIEWER_FRAME* viewerFrame = static_cast<SYMBOL_VIEWER_FRAME*>( m_toolMgr->GetToolHolder() ) )
972 viewerFrame->SelectPreviousSymbol();
973
974 return 0;
975}
976
977
979{
980 if( SYMBOL_VIEWER_FRAME* viewerFrame = static_cast<SYMBOL_VIEWER_FRAME*>( m_toolMgr->GetToolHolder() ) )
981 viewerFrame->SelectNextSymbol();
982
983 return 0;
984}
985
986
988{
990
991 SCOPE scope = SCOPE::SCOPE_LIBRARY;
992
994 scope = SCOPE::SCOPE_RELATED_SYMBOLS;
995
997
998 dlg.ShowModal();
999 return 0;
1000}
1001
1002
1003static void showTabSwitcher( SYMBOL_EDIT_FRAME* aFrame, bool aForward )
1004{
1005 EDITOR_TABS_PANEL* panel = aFrame->GetTabsPanel();
1006
1007 if( !panel || panel->Model().Entries().size() < 2 )
1008 return;
1009
1010 if( !aFrame->GetHotkeyPopup() )
1011 aFrame->CreateHotkeyPopup();
1012
1013 HOTKEY_CYCLE_POPUP* popup = aFrame->GetHotkeyPopup();
1014
1015 if( !popup )
1016 return;
1017
1018 wxArrayString labels;
1019
1020 for( const EDITOR_TABS_MODEL::ENTRY& entry : panel->Model().Entries() )
1021 labels.Add( entry.key.AfterFirst( ':' ) );
1022
1023 const int count = static_cast<int>( labels.GetCount() );
1024 const int active = panel->GetActiveTab();
1025 const int next = aForward ? ( active + 1 ) % count : ( active - 1 + count ) % count;
1026
1027 popup->Popup( _( "Switch to Tab" ), labels, next );
1028}
1029
1030
1032{
1034
1035 if( editFrame && editFrame->GetTabsPanel() )
1036 {
1037 showTabSwitcher( editFrame, true );
1038 editFrame->GetTabsPanel()->AdvanceTab( true );
1039 }
1040
1041 return 0;
1042}
1043
1044
1046{
1048
1049 if( editFrame && editFrame->GetTabsPanel() )
1050 {
1051 showTabSwitcher( editFrame, false );
1052 editFrame->GetTabsPanel()->AdvanceTab( false );
1053 }
1054
1055 return 0;
1056}
1057
1058
1060{
1062
1063 if( editFrame && editFrame->GetTabsPanel() )
1064 editFrame->GetTabsPanel()->CloseTab( editFrame->GetTabsPanel()->GetActiveTab() );
1065
1066 return 0;
1067}
1068
1069
1071{
1073
1074 wxCHECK( editFrame, 0 );
1075
1076 const wxString currentLib = editFrame->GetTreeLIBID().GetLibNickname();
1077
1078 if( currentLib.IsEmpty() )
1079 {
1080 editFrame->ShowInfoBarError( _( "Select a library to compare against a file." ) );
1081 return 0;
1082 }
1083
1084 wxFileDialog dlg( editFrame, _( "Choose Library to Compare With" ), wxEmptyString,
1085 wxEmptyString, FILEEXT::KiCadSymbolLibFileWildcard(),
1086 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1087
1088 if( dlg.ShowModal() != wxID_OK )
1089 return 0;
1090
1091 wxFileName otherFn( dlg.GetPath() );
1092 otherFn.MakeAbsolute();
1093
1094 if( !otherFn.GetExt().IsSameAs( FILEEXT::KiCadSymbolLibFileExtension, false ) )
1095 {
1096 editFrame->ShowInfoBarError(
1097 _( "Select a KiCad symbol library file (.kicad_sym)." ) );
1098 return 0;
1099 }
1100
1101 const wxString otherPath = otherFn.GetFullPath();
1102
1103 // SYM_LIB_DIFFER::Diff() consumes these borrowed pointers synchronously;
1104 // DOCUMENT_DIFF does not retain them.
1105 LIB_SYMBOL_LIBRARY_MANAGER& libMgr = editFrame->GetLibManager();
1106 wxArrayString names;
1107 libMgr.GetSymbolNames( currentLib, names );
1108
1110
1111 for( const wxString& name : names )
1112 {
1113 if( LIB_SYMBOL* sym = libMgr.GetSymbol( name, currentLib ) )
1114 beforeMap.emplace( sym->GetName(), sym );
1115 }
1116
1117 std::vector<std::unique_ptr<LIB_SYMBOL>> afterStorage;
1119
1120 try
1121 {
1122 auto loaded = KICAD_DIFF::SYM_LIB_DIFFER::LoadLibrary( otherPath );
1123 afterStorage = std::move( loaded.first );
1124 afterMap = std::move( loaded.second );
1125 }
1126 catch( const IO_ERROR& ioe )
1127 {
1128 editFrame->ShowInfoBarError( wxString::Format( _( "Failed to load %s: %s" ),
1129 otherPath, ioe.What() ) );
1130 return 0;
1131 }
1132 catch( const std::exception& e )
1133 {
1134 editFrame->ShowInfoBarError( wxString::Format( _( "Failed to load %s: %s" ),
1135 otherPath,
1136 wxString::FromUTF8( e.what() ) ) );
1137 return 0;
1138 }
1139
1140 KICAD_DIFF::SYM_LIB_DIFFER differ( beforeMap, afterMap, otherPath );
1142
1143 auto cloneHolder = std::make_shared<std::vector<std::unique_ptr<LIB_SYMBOL>>>();
1144
1145 DIALOG_KICAD_DIFF dlgDiff( editFrame, currentLib, otherPath, result );
1146
1147 std::map<KIID_PATH, const KICAD_DIFF::ITEM_CHANGE*> changesById;
1148
1149 for( const KICAD_DIFF::ITEM_CHANGE& c : result.changes )
1150 changesById[c.id] = &c;
1151
1152 dlgDiff.SetChangeSelectedHandler(
1153 [&, cloneHolder]( const KIID_PATH& aId )
1154 {
1155 WIDGET_DIFF_CANVAS* canvas = dlgDiff.DiffCanvas();
1156
1157 if( !canvas )
1158 return;
1159
1160 auto it = changesById.find( aId );
1161
1162 if( it == changesById.end() || !it->second->refdes )
1163 {
1164 KICAD_DIFF::ConfigureSymDiffCanvasContext( *canvas, nullptr, nullptr );
1165 cloneHolder->clear();
1166 return;
1167 }
1168
1169 const wxString& name = *it->second->refdes;
1170 auto beforeIt = beforeMap.find( name );
1171 auto afterIt = afterMap.find( name );
1172
1173 std::unique_ptr<LIB_SYMBOL> beforeClone =
1174 beforeIt != beforeMap.end() ? beforeIt->second->Flatten() : nullptr;
1175 std::unique_ptr<LIB_SYMBOL> afterClone =
1176 afterIt != afterMap.end() ? afterIt->second->Flatten() : nullptr;
1177
1178 KICAD_DIFF::ConfigureSymDiffCanvasContext( *canvas, beforeClone.get(), afterClone.get() );
1179
1180 cloneHolder->clear();
1181
1182 if( beforeClone )
1183 cloneHolder->push_back( std::move( beforeClone ) );
1184
1185 if( afterClone )
1186 cloneHolder->push_back( std::move( afterClone ) );
1187 } );
1188
1189 dlgDiff.ShowModal();
1190
1191 return 0;
1192}
1193
1194
1196{
1204
1206
1213
1221
1223
1227
1230
1234
1238
1243
1246
1249
1252
1255}
const char * name
static TOOL_ACTION openWithTextEditor
Definition actions.h:64
static TOOL_ACTION revert
Definition actions.h:58
static TOOL_ACTION addLibrary
Definition actions.h:52
static TOOL_ACTION openDirectory
Definition actions.h:65
static TOOL_ACTION saveAll
Definition actions.h:57
static TOOL_ACTION save
Definition actions.h:54
static TOOL_ACTION showProperties
Definition actions.h:262
static TOOL_ACTION newLibrary
Definition actions.h:51
static TOOL_ACTION ddAddLibrary
Definition actions.h:63
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
File-compare dialog (Phase 7).
int ShowModal() override
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, INFOBAR_MESSAGE_TYPE aType=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()
bool SaveCanvasImageToFile(const wxString &aFileName, BITMAP_TYPE aBitmapType)
Save the current view as an image file.
virtual void CreateHotkeyPopup()
virtual void ToggleProperties()
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
const std::vector< ENTRY > & Entries() const
The tab strip plus the single shared GAL canvas.
void AdvanceTab(bool aForward)
const EDITOR_TABS_MODEL & Model() const
AUTOPLACE_FIELDS m_AutoplaceFields
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.
virtual const wxString What() const
A composite of Problem() and Where()
Diff two .kicad_sym symbol libraries.
DOCUMENT_DIFF Diff() override
Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with.
static std::pair< std::vector< std::unique_ptr< LIB_SYMBOL > >, SYMBOL_MAP > LoadLibrary(const wxString &aPath)
Convenience: load a .kicad_sym path into a SYMBOL_MAP using SCH_IO_KICAD_SEXPR::EnumerateSymbolLib.
std::map< wxString, const LIB_SYMBOL * > SYMBOL_MAP
Library content is a map of (canonical_name -> LIB_SYMBOL*).
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition kidialog.h:38
int ShowModal() override
Definition kidialog.cpp:89
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition view.cpp:1703
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
Definition kiway.cpp:680
Module editor specific tools.
bool RenameLibrary(const wxString &aTitle, const wxString &aName, std::function< bool(const wxString &aNewName)> aValidator)
void AddContextMenuItems(CONDITIONAL_MENU *aMenu)
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false)
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
bool IsValid() const
Check if this LID_ID is valid.
Definition lib_id.h:168
const UTF8 & GetLibItemName() const
Definition lib_id.h:98
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition lib_id.h:83
Symbol library management helper that is specific to the symbol library editor frame.
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetAdapter()
Return the adapter object that provides the stored data.
Define a library symbol object.
Definition lib_symbol.h:119
const LIB_ID & GetLibId() const override
Definition lib_symbol.h:188
bool IsDerived() const
Definition lib_symbol.h:236
wxString GetName() const override
Definition lib_symbol.h:181
SCH_FIELD & GetValueField()
Return reference to the value field.
Definition lib_symbol.h:437
int GetUnitCount() const override
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
virtual void SetName(const wxString &aName)
virtual const wxString & GetTextEditor(bool aCanShowFileChooser=true)
Return the path to the preferred text editor application.
Definition pgm_base.cpp:216
virtual LIBRARY_MANAGER & GetLibraryManager() const
Definition pgm_base.h:125
static TOOL_ACTION editSymbol
static TOOL_ACTION importSymbol
static TOOL_ACTION newSymbol
static TOOL_ACTION saveLibraryAs
static TOOL_ACTION previousSymbol
static TOOL_ACTION showRelatedLibFieldsTable
static TOOL_ACTION editLibSymbolWithLibEdit
static TOOL_ACTION pasteSymbol
static TOOL_ACTION exportSymbolAsSVG
static TOOL_ACTION renameSymbol
static TOOL_ACTION duplicateSymbol
static TOOL_ACTION closeSymbolTab
static TOOL_ACTION cutSymbol
static TOOL_ACTION compareLibraryWithFile
static TOOL_ACTION saveSymbolCopyAs
static TOOL_ACTION nextUnit
static TOOL_ACTION showElectricalTypes
static TOOL_ACTION flattenSymbol
static TOOL_ACTION placeSymbol
Definition sch_actions.h:71
static TOOL_ACTION showHiddenFields
static TOOL_ACTION nextSymbol
static TOOL_ACTION prevSymbolTab
static TOOL_ACTION showHiddenPins
static TOOL_ACTION showPinNumbers
static TOOL_ACTION exportSymbolView
static TOOL_ACTION showLibFieldsTable
static TOOL_ACTION copySymbol
static TOOL_ACTION symbolProperties
static TOOL_ACTION toggleSyncedPinsMode
static TOOL_ACTION deleteSymbol
static TOOL_ACTION nextSymbolTab
static TOOL_ACTION togglePinAltIcons
static TOOL_ACTION exportSymbol
static TOOL_ACTION previousUnit
static TOOL_ACTION deriveFromExistingSymbol
static TOOL_ACTION addSymbolToSchematic
static TOOL_ACTION saveSymbolAs
SCH_RENDER_SETTINGS * GetRenderSettings()
EESCHEMA_SETTINGS * eeconfig() const
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_SHEET_PATH & GetCurrentSheet() const
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:138
void SetText(const wxString &aText) override
Schematic symbol object.
Definition sch_symbol.h:75
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
Automatically orient all the fields in the symbol.
SCH_SELECTION_TOOL * m_selectionTool
int PreviousSymbol(const TOOL_EVENT &aEvent)
int ToggleSyncedPinsMode(const TOOL_EVENT &aEvent)
int Save(const TOOL_EVENT &aEvt)
int PrevTab(const TOOL_EVENT &aEvent)
int EditSymbol(const TOOL_EVENT &aEvent)
int ExportView(const TOOL_EVENT &aEvent)
int ShowElectricalTypes(const TOOL_EVENT &aEvent)
int FlattenSymbol(const TOOL_EVENT &aEvent)
int OpenDirectory(const TOOL_EVENT &aEvent)
int RenameSymbol(const TOOL_EVENT &newName)
int DuplicateSymbol(const TOOL_EVENT &aEvent)
int ToggleHiddenPins(const TOOL_EVENT &aEvent)
int ShowLibraryTable(const TOOL_EVENT &aEvent)
int AddLibrary(const TOOL_EVENT &aEvent)
int AddSymbol(const TOOL_EVENT &aEvent)
int CloseTab(const TOOL_EVENT &aEvent)
int TogglePinAltIcons(const TOOL_EVENT &aEvent)
int ChangeUnit(const TOOL_EVENT &aEvent)
int Revert(const TOOL_EVENT &aEvent)
int ToggleHiddenFields(const TOOL_EVENT &aEvent)
int OpenWithTextEditor(const TOOL_EVENT &aEvent)
int ExportSymbol(const TOOL_EVENT &aEvent)
int NextTab(const TOOL_EVENT &aEvent)
int NextSymbol(const TOOL_EVENT &aEvent)
void setTransitions() override
< Set up handlers for various events.
int ToggleProperties(const TOOL_EVENT &aEvent)
bool Init() override
Init() is called once upon a registration of the tool.
int EditLibrarySymbol(const TOOL_EVENT &aEvent)
int CompareLibraryWithFile(const TOOL_EVENT &aEvent)
Diff the currently-open symbol library against another .kicad_sym file.
int ExportSymbolAsSVG(const TOOL_EVENT &aEvent)
int ShowPinNumbers(const TOOL_EVENT &aEvent)
int DdAddLibrary(const TOOL_EVENT &aEvent)
int AddSymbolToSchematic(const TOOL_EVENT &aEvent)
int CutCopyDelete(const TOOL_EVENT &aEvent)
The symbol library editor main window.
void SaveAll()
Save all modified symbols and libraries.
bool IsLibraryTreeShown() const override
void RenameSymbolTab(const LIB_ID &aOldId, const LIB_ID &aNewId)
Update the open tab for aOldId, if any, to the renamed symbol aNewId so its label and key track the r...
bool IsCurrentSymbol(const LIB_ID &aLibId) const
Restore the empty editor screen, without any symbol or library selected.
void SVGPlotSymbol(const wxString &aFullFileName)
Create the SVG print file for the current edited symbol.
EDITOR_TABS_PANEL * GetTabsPanel() const
The tab strip fronting the shared canvas, or nullptr before it is mounted.
LIB_ID GetTreeLIBID(int *aUnit=nullptr) const
Return the LIB_ID of the library or symbol selected in the symbol tree.
void FocusOnLibId(const LIB_ID &aLibID)
void Save()
Save the selected symbol or library.
void LoadSymbol(const wxString &aLibrary, const wxString &aSymbol, int Unit)
int GetTreeSelectionCount() const
bool IsSymbolFromSchematic() const
SYMBOL_EDITOR_SETTINGS * GetSettings() const
void DuplicateSymbol(bool aFromClipboard)
Insert a duplicate symbol.
void SetCurSymbol(LIB_SYMBOL *aSymbol, bool aUpdateZoom)
Take ownership of aSymbol and notes that it is the one currently being edited.
std::vector< LIB_ID > GetSelectedLibIds() const
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
LIB_ID GetTargetLibId() const override
Return either the symbol selected in the symbol tree (if context menu is active) or the symbol on the...
void UpdateMsgPanel() override
Redraw the message panel.
void CreateNewSymbol(const wxString &newName=wxEmptyString)
Create a new symbol in the selected library.
LIB_SYMBOL_LIBRARY_MANAGER & GetLibManager()
void SaveSymbolCopyAs(bool aOpenCopy)
Save the currently selected symbol to a new name and/or location.
void UpdateLibraryTree(const wxDataViewItem &aTreeItem, LIB_SYMBOL *aSymbol)
Update a symbol node in the library tree.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
void SaveLibraryAs()
Save the currently selected library to a new file.
void ToggleLibraryTree() override
bool IsLibraryReadOnly(const wxString &aLibrary) const
Return true if the library is stored in a read-only file.
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Return true if library exists.
LIB_SYMBOL * GetBufferedSymbol(const wxString &aSymbolName, const wxString &aLibrary)
Return the symbol copy from the buffer.
bool SymbolNameInUse(const wxString &aName, const wxString &aLibrary)
Return true if the symbol name is already in use in the specified library.
bool IsLibraryModified(const wxString &aLibrary) const
Return true if library has unsaved modifications.
LIB_SYMBOL * GetSymbol(const wxString &aSymbolName, const wxString &aLibrary) const
Return either an alias of a working LIB_SYMBOL copy, or alias of the original symbol if there is no w...
bool RemoveSymbol(const wxString &aSymbolName, const wxString &aLibrary)
Remove the symbol from the symbol buffer.
bool UpdateSymbolAfterRename(LIB_SYMBOL *aSymbol, const wxString &aOldSymbolName, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol when the name has changed.
void SetSymbolModified(const wxString &aSymbolName, const wxString &aLibrary)
void GetSymbolNames(const wxString &aLibName, wxArrayString &aSymbolNames, SYMBOL_NAME_FILTER aFilter=SYMBOL_NAME_FILTER::ALL)
bool SymbolExists(const wxString &aSymbolName, const wxString &aLibrary) const
Return true if symbol with a specific alias exists in library (either original one or buffered).
bool UpdateSymbol(LIB_SYMBOL *aSymbol, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol.
bool HasDerivedSymbols(const wxString &aSymbolName, const wxString &aLibraryName)
Check whether any symbol inherits from aSymbolName, without building the list of names.
Symbol library viewer main window.
LIB_SYMBOL * GetSelectedSymbol() const
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
SCH_BASE_FRAME * getEditFrame() const
Definition tool_base.h:182
KIGFX::VIEW * getView() const
Definition tool_base.cpp:34
Generic, UI-independent tool event.
Definition tool_event.h:167
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
T Parameter() const
Return a parameter assigned to the event.
Definition tool_event.h:469
void Go(int(SCH_BASE_FRAME::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
std::unique_ptr< TOOL_MENU > m_menu
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
bool empty() const
Definition utf8.h:105
GAL-backed canvas for visualizing a KICAD_DIFF::DIFF_SCENE.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:217
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:192
This file is part of the common library.
LIB_FIELDS_EDITOR_GRID_DATA_MODEL::SCOPE SCOPE
#define _(s)
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:31
@ FRAME_SCH
Definition frame_type.h:30
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
Definition gestfich.cpp:161
static const std::string KiCadSymbolLibFileExtension
static const std::string SVGFileExtension
static wxString PngFileWildcard()
static wxString SVGFileWildcard()
static wxString KiCadSymbolLibFileWildcard()
bool LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
void ConfigureSymDiffCanvasContext(WIDGET_DIFF_CANVAS &aCanvas, LIB_SYMBOL *aBefore, LIB_SYMBOL *aAfter)
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:54
void AllowNetworkFileSystems(wxDialog *aDialog)
Configure a file dialog to show network and virtual file systems.
Definition wxgtk/ui.cpp:521
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
CITER next(CITER it)
Definition ptree.cpp:120
@ AUTOPLACE_AUTO
Definition sch_item.h:70
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_LIBID
The full set of changes between two parsed documents of one type.
One change record on a single item.
static void showTabSwitcher(SYMBOL_EDIT_FRAME *aFrame, bool aForward)
wxString result
Test unit parsing edge cases and error handling.
Definition of file extensions used in Kicad.