KiCad PCB EDA Suite
Loading...
Searching...
No Matches
footprint_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) 2014-2019 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Maciej Suminski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
25
26#include <memory>
27
28#include <advanced_config.h>
29#include <string_utils.h>
30#include <pgm_base.h>
32#include <tool/tool_manager.h>
34#include <tools/pcb_actions.h>
36#include <eda_doc.h>
39#include <pcbnew_settings.h>
40#include <pcbnew_id.h>
41#include <confirm.h>
42#include <kidialog.h>
43#include <wx/debug.h>
44#include <wx/filedlg.h>
45#include <wx/filename.h>
47#include <launch_ext.h> // To default when file manager setting is empty
48#include <gestfich.h> // To open with a text editor
49#include <widgets/wx_infobar.h>
50#include <footprint.h>
51#include <pad.h>
52#include <pcb_group.h>
53#include <zone.h>
61#include <kiway.h>
62#include <pcb_plotter.h>
63#include <project_pcb.h>
64#include <view/view_controls.h>
71#include <wx/dirdlg.h>
72
73
75 PCB_TOOL_BASE( "pcbnew.ModuleEditor" ),
76 m_frame( nullptr ),
77 m_checkerDialog( nullptr )
78{
79}
80
81
89
90
92{
93 LIBRARY_EDITOR_CONTROL* libraryTreeTool = m_toolMgr->GetTool<LIBRARY_EDITOR_CONTROL>();
94
95 // Build a context menu for the footprint tree
96 //
97 CONDITIONAL_MENU& ctxMenu = m_menu->GetMenu();
98
99 auto libSelectedCondition =
100 [this]( const SELECTION& aSel )
101 {
102 LIB_ID sel = m_frame->GetLibTree()->GetSelectedLibId();
103 return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty();
104 };
105
106 // The libInferredCondition allows you to do things like New Symbol and Paste with a
107 // symbol selected (in other words, when we know the library context even if the library
108 // itself isn't selected.
109 auto libInferredCondition =
110 [this]( const SELECTION& aSel )
111 {
112 LIB_ID sel = m_frame->GetLibTree()->GetSelectedLibId();
113 return !sel.GetLibNickname().empty();
114 };
115
116 auto fpSelectedCondition =
117 [this]( const SELECTION& aSel )
118 {
119 LIB_ID sel = m_frame->GetLibTree()->GetSelectedLibId();
120 return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
121 };
122
123 auto fpExportCondition =
124 [this]( const SELECTION& aSel )
125 {
126 FOOTPRINT* fp = m_frame->GetBoard()->GetFirstFootprint();
127 return fp != nullptr;
128 };
129
130 auto canOpenExternally =
131 [this]( const SELECTION& aSel )
132 {
133 // The option is shown if the editor has no current edits,
134 // dumb/simple guard against opening a new file that does not exist on disk
135 bool ret = !m_frame->IsContentModified();
136 return ret;
137 };
138
139// clang-format off
140 ctxMenu.AddItem( PCB_ACTIONS::newFootprint, libSelectedCondition, 10 );
141 ctxMenu.AddItem( PCB_ACTIONS::createFootprint, libSelectedCondition, 10 );
142
143 ctxMenu.AddSeparator( 10 );
144 ctxMenu.AddItem( ACTIONS::save, SELECTION_CONDITIONS::ShowAlways, 10 );
145 ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition || fpSelectedCondition, 10 );
146 ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition || libInferredCondition, 10 );
147
148 ctxMenu.AddSeparator( 10 );
149 ctxMenu.AddItem( PCB_ACTIONS::cutFootprint, fpSelectedCondition, 10 );
150 ctxMenu.AddItem( PCB_ACTIONS::copyFootprint, fpSelectedCondition, 10 );
151 ctxMenu.AddItem( PCB_ACTIONS::pasteFootprint, libInferredCondition, 10 );
152 ctxMenu.AddItem( PCB_ACTIONS::duplicateFootprint, fpSelectedCondition, 10 );
153 ctxMenu.AddItem( PCB_ACTIONS::renameFootprint, fpSelectedCondition, 10 );
154 ctxMenu.AddItem( PCB_ACTIONS::deleteFootprint, fpSelectedCondition, 10 );
155 ctxMenu.AddItem( PCB_ACTIONS::footprintProperties, fpSelectedCondition, 10 );
156
157 ctxMenu.AddSeparator( 100 );
158 ctxMenu.AddItem( PCB_ACTIONS::importFootprint, libInferredCondition, 100 );
159 ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpExportCondition, 100 );
160
161 if( ADVANCED_CFG::GetCfg().m_EnableLibWithText )
162 {
163 ctxMenu.AddSeparator( 200 );
164 ctxMenu.AddItem( ACTIONS::openWithTextEditor, canOpenExternally && fpSelectedCondition, 200 );
165 }
166
167 if( ADVANCED_CFG::GetCfg().m_EnableLibDir )
168 {
169 ctxMenu.AddSeparator( 200 );
170 ctxMenu.AddItem( ACTIONS::openDirectory, canOpenExternally && ( libSelectedCondition || fpSelectedCondition ), 200 );
171 }
172
173 ctxMenu.AddSeparator( 300 );
174 ctxMenu.AddItem( PCB_ACTIONS::showLibFootprintFieldsTable, libInferredCondition, 300 );
175// clang-format on
176
177 libraryTreeTool->AddContextMenuItems( &ctxMenu );
178
179 // Ensure the left toolbar's Line modes group reflects the current setting at startup
180 if( m_toolMgr )
182
183 return true;
184}
185
186
188 const LIB_ID& aTargetLib )
189{
190 const wxString libraryName = aTargetLib.GetUniStringLibNickname();
191
192 if( aTargetLib.GetLibNickname().empty() )
193 {
194 // Do nothing - the footprint will need to be saved manually to assign
195 // to a library.
196 }
197 else
198 {
199 if( !PROJECT_PCB::FootprintLibAdapter( &m_frame->Prj() )->IsFootprintLibWritable( libraryName ) )
200 {
201 // If the library is not writeable, we'll give the user a
202 // footprint not in a library. But add a warning to let them know
203 // they didn't quite get what they wanted.
204 m_frame->ShowInfoBarWarning(
205 wxString::Format(
206 _( "The footprint could not be added to the selected library ('%s'). "
207 "This library is read-only." ),
208 libraryName ),
209 false );
210 // And the footprint will need to be saved manually
211 }
212 else
213 {
214 // Go ahead and save it to the library
215 LIB_ID fpid = aFootprint.GetFPID();
216 fpid.SetLibNickname( aTargetLib.GetLibNickname() );
217 aFootprint.SetFPID( fpid );
218
219 // Clear the modified flag only on a successful save, else the edits are silently
220 // lost (issue #23850).
221 if( m_frame->SaveFootprint( &aFootprint ) )
222 m_frame->ClearModify();
223 }
224 }
225}
226
227
229{
230 const LIB_ID selected = m_frame->GetTargetFPID();
231 const wxString libraryName = selected.GetUniStringLibNickname();
232
233 if( !m_frame->BeginNewFootprint( libraryName ) )
234 return 0;
235
236 FOOTPRINT* newFootprint = m_frame->CreateNewFootprint( wxEmptyString, libraryName );
237
238 if( !newFootprint )
239 return 0;
240
241 // Give the new footprint a resolvable identity so it opens in its own tab instead of
242 // overwriting the active one.
243 if( !libraryName.IsEmpty() )
244 {
245 newFootprint->SetFPID( LIB_ID( libraryName, newFootprint->GetFPID().GetLibItemName() ) );
246 }
247 else
248 {
249 newFootprint->SetParent( nullptr );
250 m_frame->CreateUnsavedFootprintTab();
251 }
252
254 m_frame->AddFootprintToBoard( newFootprint );
255
256 // Initialize data relative to nets and netclasses (for a new footprint the defaults are
257 // used). This is mandatory to handle and draw pads.
259 newFootprint->SetPosition( VECTOR2I( 0, 0 ) );
260 newFootprint->ClearFlags();
261
262 m_frame->Zoom_Automatique( false );
263 m_frame->GetScreen()->SetContentModified();
264 m_frame->OnModify();
265
266 tryToSaveFootprintInLibrary( *newFootprint, selected );
267
268 m_frame->UpdateView();
269 m_frame->GetCanvas()->ForceRefresh();
270 m_frame->Update3DView( true, true );
271
272 m_frame->SyncLibraryTree( false );
273 return 0;
274}
275
276
278{
279 const LIB_ID selected = m_frame->GetTargetFPID();
280
281 if( KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_FOOTPRINT_WIZARD, true, m_frame ) )
282 {
283 FOOTPRINT_WIZARD_FRAME* wizard = static_cast<FOOTPRINT_WIZARD_FRAME*>( frame );
284
285 if( wizard->ShowModal( nullptr, m_frame ) )
286 {
287 // Creates the new footprint from python script wizard
288 FOOTPRINT* newFootprint = wizard->GetBuiltFootprint();
289
290 if( newFootprint ) // i.e. if create footprint command is OK
291 {
292 if( !m_frame->BeginNewFootprint( selected.GetLibNickname() ) )
293 {
294 delete newFootprint;
295 wizard->Destroy();
296 return 0;
297 }
298
299 newFootprint->SetParent( nullptr );
300 m_frame->CreateUnsavedFootprintTab();
301
303 // Add the new object to board
304 m_frame->AddFootprintToBoard( newFootprint );
305
306 // Initialize data relative to nets and netclasses (for a new footprint the
307 // defaults are used). This is mandatory to handle and draw pads.
309 newFootprint->SetPosition( VECTOR2I( 0, 0 ) );
310 newFootprint->ClearFlags();
311
312 m_frame->Zoom_Automatique( false );
313 m_frame->GetScreen()->SetContentModified();
314 m_frame->OnModify();
315
316 tryToSaveFootprintInLibrary( *newFootprint, selected );
317
318 m_frame->UpdateView();
319 canvas()->Refresh();
320 m_frame->Update3DView( true, true );
321
322 m_frame->SyncLibraryTree( false );
323 }
324 }
325
326 wizard->Destroy();
327 }
328
329 return 0;
330}
331
332
334{
335 if( !footprint() ) // no loaded footprint
336 return 0;
337
338 const LIB_ID loadedId = m_frame->GetLoadedFPID();
339
340 // An unsaved import has no library identity for the tree selection to match, and save-as is the only
341 // way to give it one, so never let an unrelated selection swallow its save
342 if( m_frame->GetTargetFPID() == loadedId || loadedId.GetLibNickname().empty() )
343 {
344 if( m_frame->SaveFootprint( footprint() ) )
345 {
346 view()->Update( footprint() );
347
348 canvas()->ForceRefresh();
349 m_frame->ClearModify();
350 }
351 }
352
353 m_frame->RefreshLibraryTree();
354 return 0;
355}
356
357
359{
360 if( m_frame->GetTargetFPID().GetLibItemName().empty() )
361 {
363
364 // Save Library As
365 const wxString& src_libNickname = m_frame->GetTargetFPID().GetLibNickname();
366 std::optional<wxString> optUri = manager.GetFullURI( LIBRARY_TABLE_TYPE::FOOTPRINT, src_libNickname, true );
367 wxCHECK( optUri, 0 );
368
369 if( m_frame->SaveLibraryAs( *optUri ) )
370 m_frame->SyncLibraryTree( true );
371 }
372 else if( m_frame->GetTargetFPID() == m_frame->GetLoadedFPID() )
373 {
374 // Save Footprint As
375 if( footprint() && m_frame->SaveFootprintAs( footprint() ) )
376 {
377 view()->Update( footprint() );
378 m_frame->ClearModify();
379
380 // Get rid of the save-will-update-board-only (or any other dismissable warning)
381 WX_INFOBAR* infobar = m_frame->GetInfoBar();
382
383 if( infobar->IsShownOnScreen() && infobar->HasCloseButton() )
384 infobar->Dismiss();
385
386 canvas()->ForceRefresh();
387 m_frame->SyncLibraryTree( true );
388 }
389 }
390 else
391 {
392 // Save Selected Footprint As
393 FOOTPRINT* footprint = m_frame->LoadFootprint( m_frame->GetTargetFPID() );
394
395 if( footprint && m_frame->SaveFootprintAs( footprint ) )
396 {
397 m_frame->SyncLibraryTree( true );
398 m_frame->FocusOnLibID( footprint->GetFPID() );
399 }
400 }
401
402 m_frame->RefreshLibraryTree();
403 return 0;
404}
405
406
408{
409 getEditFrame<FOOTPRINT_EDIT_FRAME>()->RevertFootprint();
410 return 0;
411}
412
413
415{
416 LIB_ID fpID = m_frame->GetLibTree()->GetSelectedLibId();
417
418 if( fpID == m_frame->GetLoadedFPID() )
419 {
420 m_copiedFootprint = std::make_unique<FOOTPRINT>( *m_frame->GetBoard()->GetFirstFootprint() );
421 m_copiedFootprint->SetParent( nullptr );
422 }
423 else
424 {
425 m_copiedFootprint.reset( m_frame->LoadFootprint( fpID ) );
426 }
427
428 if( aEvent.IsAction( &PCB_ACTIONS::cutFootprint ) )
429 DeleteFootprint( aEvent );
430
431 return 0;
432}
433
434
436{
437 if( m_copiedFootprint && !m_frame->GetLibTree()->GetSelectedLibId().GetLibNickname().empty() )
438 {
439 wxString newLib = m_frame->GetLibTree()->GetSelectedLibId().GetLibNickname();
440 wxString newName = m_copiedFootprint->GetFPID().GetLibItemName();
441
442 while( PROJECT_PCB::FootprintLibAdapter( &m_frame->Prj() )->FootprintExists( newLib, newName ) )
443 newName += _( "_copy" );
444
445 m_copiedFootprint->SetFPID( LIB_ID( newLib, newName ) );
446 m_frame->SaveFootprintInLibrary( m_copiedFootprint.get(), newLib );
447
448 m_frame->SyncLibraryTree( true );
449 m_frame->LoadFootprintFromLibrary( m_copiedFootprint->GetFPID() );
450 m_frame->FocusOnLibID( m_copiedFootprint->GetFPID() );
451 m_frame->RefreshLibraryTree();
452 }
453
454 return 0;
455}
456
457
459{
460 LIB_ID fpID = m_frame->GetLibTree()->GetSelectedLibId();
462
463 if( fpID == m_frame->GetLoadedFPID() )
464 footprint = new FOOTPRINT( *m_frame->GetBoard()->GetFirstFootprint() );
465 else
466 footprint = m_frame->LoadFootprint( m_frame->GetTargetFPID() );
467
468 if( footprint && m_frame->DuplicateFootprint( footprint ) )
469 {
470 m_frame->SyncLibraryTree( true );
471 m_frame->LoadFootprintFromLibrary( footprint->GetFPID() );
472 m_frame->FocusOnLibID( footprint->GetFPID() );
473 m_frame->RefreshLibraryTree();
474 }
475
476 return 0;
477}
478
479
481{
484
485 LIB_ID fpID = m_frame->GetLibTree()->GetSelectedLibId();
486 wxString libraryName = fpID.GetLibNickname();
487 wxString oldName = fpID.GetLibItemName();
488 wxString newName;
489 wxString msg;
490
491 if( !libTool->RenameLibrary( _( "Change Footprint Name" ), oldName,
492 [&]( const wxString& aNewName )
493 {
494 newName = aNewName;
495
496 if( newName.IsEmpty() )
497 {
498 wxMessageBox( _( "Footprint must have a name." ) );
499 return false;
500 }
501
502 // If no change, accept it without prompting
503 if( oldName != newName && adapter->FootprintExists( libraryName, newName ) )
504 {
505 msg = wxString::Format( _( "Footprint '%s' already exists in library '%s'." ),
506 newName, libraryName );
507
508 KIDIALOG errorDlg( m_frame, msg, _( "Confirmation" ),
509 wxOK | wxCANCEL | wxICON_WARNING );
510 errorDlg.SetOKLabel( _( "Overwrite" ) );
511
512 return errorDlg.ShowModal() == wxID_OK;
513 }
514
515 return true;
516 } ) )
517 {
518 return 0; // canceled by user
519 }
520
521 if( newName == oldName )
522 return 0;
523
524 FOOTPRINT* footprint = nullptr;
525
526 if( fpID == m_frame->GetLoadedFPID() )
527 {
528 footprint = m_frame->GetBoard()->GetFirstFootprint();
529
530 if( footprint )
531 {
532 footprint->SetFPID( LIB_ID( libraryName, newName ) );
533
534 if( footprint->GetValue() == oldName )
535 footprint->SetValue( newName );
536
537 m_frame->OnModify();
538 m_frame->UpdateView();
539 }
540 }
541 else
542 {
543 footprint = m_frame->LoadFootprint( fpID );
544
545 if( footprint )
546 {
547 try
548 {
549 footprint->SetFPID( LIB_ID( libraryName, newName ) );
550
551 if( footprint->GetValue() == oldName )
552 footprint->SetValue( newName );
553
554 // Both names are one file on a case-insensitive filesystem.
555 adapter->DeleteFootprint( libraryName, oldName );
556
557 m_frame->SaveFootprintInLibrary( footprint, libraryName );
558 }
559 catch( const IO_ERROR& ioe )
560 {
561 DisplayErrorMessage( m_frame, _( "Error renaming footprint" ), ioe.What() );
562 }
563 catch( ... )
564 {
565 // Best efforts...
566 }
567 }
568 }
569
570 if( footprint )
571 m_frame->RenameFootprintTab( fpID, LIB_ID( libraryName, newName ) );
572
573 wxDataViewItem treeItem = m_frame->GetLibTreeAdapter()->FindItem( fpID );
574
575 if( footprint )
576 {
577 m_frame->UpdateLibraryTree( treeItem, footprint );
578 m_frame->FocusOnLibID( LIB_ID( libraryName, newName ) );
579 }
580
581 return 0;
582}
583
584
586{
588 const LIB_ID fpID = frame->GetTargetFPID();
589
590 if( frame->DeleteFootprintFromLibrary( fpID, true ) )
591 {
592 // Close only the deleted footprint's tab, leaving the others open.
593 frame->CloseFootprintTab( fpID );
594
595 frame->SyncLibraryTree( true );
596 }
597
598 return 0;
599}
600
601
603{
604 bool is_last_fp_from_brd = m_frame->IsCurrentFPFromBoard();
605
607
608 // A cancelled file dialog must leave the editor exactly as it was
609 if( !m_frame->ImportFootprint() )
610 return 0;
611
612 if( m_frame->GetBoard()->GetFirstFootprint() )
613 m_frame->GetBoard()->GetFirstFootprint()->ClearFlags();
614
615 frame()->ClearUndoRedoList();
616
617 // Update the save items if needed.
618 if( is_last_fp_from_brd )
619 {
620 m_frame->ReCreateMenuBar();
621 m_frame->ReCreateHToolbar();
622 }
623
624 m_toolMgr->RunAction( ACTIONS::zoomFitScreen );
625 m_frame->OnModify();
626 return 0;
627}
628
629
631{
632 const wxString title = _( "Export for Older KiCad Version" );
633 wxString libName = m_frame->GetTargetFPID().GetLibNickname();
634
636 std::optional<wxString> optUri = manager.GetFullURI( LIBRARY_TABLE_TYPE::FOOTPRINT, libName, true );
637
638 if( !optUri )
639 {
640 wxMessageBox( _( "Select a library first." ), title, wxOK | wxICON_ERROR, m_frame );
641 return 0;
642 }
643
644 const wxString library = *optUri;
645
646 // The export reads the files on disk, which the editor has not written yet.
647 if( m_frame->IsContentModified()
648 && wxMessageBox( _( "A library editor has unsaved changes. The export uses the last saved "
649 "library files. Continue?" ),
650 title, wxYES_NO | wxICON_WARNING, m_frame )
651 != wxYES )
652 {
653 return 0;
654 }
655
657 [&]( const DOWNGRADE_EXPORT_PASS& aPass, DOWNGRADE_EXPORT_RESULT& aResult ) -> bool
658 {
661
662 if( !aPass.m_dryRun )
663 {
664 wxFileName out( aPass.m_folder, wxEmptyString );
665 out.AppendDir( wxFileName( library ).GetFullName() );
666 job.m_outputLibraryPath = out.GetPath();
667 }
668
669 return RunDowngradeJob( m_frame->Kiway(), KIWAY::FACE_PCB, job, aPass, aResult );
670 } );
671
672 return 0;
673}
674
675
677{
678 if( FOOTPRINT* fp = m_frame->GetBoard()->GetFirstFootprint() )
679 m_frame->ExportFootprint( fp );
680
681 return 0;
682}
683
684
686{
687 FOOTPRINT* fp = m_frame->GetBoard()->GetFirstFootprint();
688
689 if( !fp )
690 {
691 wxMessageBox( _( "No footprint to export" ) );
692 return 0;
693 }
694
695 wxFileName fn( fp->GetFPID().GetLibItemName() );
696 fn.SetExt( FILEEXT::SVGFileExtension );
697
698 wxString pro_dir = wxPathOnly( m_frame->Prj().GetProjectFullName() );
699
700 wxString fullFileName = wxFileSelector( _( "SVG File Name" ), pro_dir, fn.GetFullName(), FILEEXT::SVGFileExtension,
701 FILEEXT::SVGFileWildcard(), wxFD_SAVE, m_frame );
702
703 if( !fullFileName.IsEmpty() )
704 {
705 PCB_PLOT_PARAMS plotOpts;
706 plotOpts.SetFormat( PLOT_FORMAT::SVG );
707 plotOpts.SetColorSettings( m_frame->GetColorSettings() );
708 plotOpts.SetScale( 1.0 );
709 plotOpts.SetAutoScale( false );
710
712
713 PlotFootprintToSVG( *fp, m_frame->Prj(), nullptr, plotOpts, layersToPlot, LSEQ(), fullFileName );
714 }
715
716 return 0;
717}
718
719
721{
722 wxCHECK( m_frame, 0 );
723
724 const wxString libNickname = m_frame->GetTargetFPID().GetUniStringLibNickname();
725
726 if( libNickname.IsEmpty() )
727 {
728 m_frame->ShowInfoBarError( _( "Select a library to compare against another." ) );
729 return 0;
730 }
731
733
734 wxCHECK( adapter, 0 );
735
736 std::optional<LIBRARY_TABLE_ROW*> row = adapter->GetRow( libNickname );
737
738 if( !row )
739 {
740 m_frame->ShowInfoBarError( wxString::Format( _( "Library '%s' is not in the footprint "
741 "library table." ),
742 libNickname ) );
743 return 0;
744 }
745
746 // MakeAbsolute so relative table URIs resolve from the project dir, not
747 // the process cwd.
748 wxFileName currentFn = wxFileName::DirName(
749 LIBRARY_MANAGER::GetFullURI( *row, /*aSubstituted=*/true ) );
750 currentFn.MakeAbsolute();
751 const wxString currentPath = currentFn.GetPath();
752
753 wxDirDialog dlg( m_frame, _( "Choose .pretty Folder to Compare With" ), wxEmptyString,
754 wxDD_DIR_MUST_EXIST );
755
756 if( dlg.ShowModal() != wxID_OK )
757 return 0;
758
759 wxFileName otherFn = wxFileName::DirName( dlg.GetPath() );
760 otherFn.MakeAbsolute();
761
762 if( otherFn.GetDirs().IsEmpty()
763 || !otherFn.GetDirs().Last().EndsWith( wxS( ".pretty" ) ) )
764 {
765 m_frame->ShowInfoBarError(
766 _( "Select a KiCad footprint library folder (ends with .pretty)." ) );
767 return 0;
768 }
769
770 if( otherFn.SameAs( currentFn ) )
771 {
772 m_frame->ShowInfoBarError(
773 _( "Select a different .pretty folder than the active library." ) );
774 return 0;
775 }
776
777 const wxString otherPath = otherFn.GetPath();
778
779 std::vector<std::unique_ptr<FOOTPRINT>> beforeStorage;
780 std::vector<std::unique_ptr<FOOTPRINT>> afterStorage;
783
784 auto load =
785 [&]( const wxString& aPath,
786 std::vector<std::unique_ptr<FOOTPRINT>>& aOwners,
788 {
789 try
790 {
791 auto loaded = KICAD_DIFF::FP_LIB_DIFFER::LoadLibrary( aPath );
792 aOwners = std::move( loaded.first );
793 aMap = std::move( loaded.second );
794 return true;
795 }
796 catch( const IO_ERROR& ioe )
797 {
798 m_frame->ShowInfoBarError(
799 wxString::Format( _( "Failed to load %s: %s" ), aPath, ioe.What() ) );
800 }
801 catch( const std::exception& e )
802 {
803 m_frame->ShowInfoBarError(
804 wxString::Format( _( "Failed to load %s: %s" ), aPath,
805 wxString::FromUTF8( e.what() ) ) );
806 }
807
808 return false;
809 };
810
811 if( !load( currentPath, beforeStorage, beforeMap ) )
812 return 0;
813
814 if( !load( otherPath, afterStorage, afterMap ) )
815 return 0;
816
817 KICAD_DIFF::FP_LIB_DIFFER differ( beforeMap, afterMap, otherPath );
819
821
822 DIALOG_KICAD_DIFF dlgDiff( m_frame, currentPath, otherPath, result,
825
826 dlgDiff.DrawChosenLibraryItem(
827 [&]( WIDGET_DIFF_CANVAS& aCanvas, const wxString& aName )
828 {
829 KICAD_DIFF::ShowFootprintPair( aCanvas, beforeMap, afterMap, aName );
830 } );
831
832 dlgDiff.ShowModal();
833
834 return 0;
835}
836
837
839{
840 // No check for multi selection since the context menu option must be hidden in that case
841 LIB_ID libId = m_frame->GetTargetFPID();
842
843 wxString libName = libId.GetLibNickname();
844 wxString libItemName = libId.GetLibItemName();
845 wxString path = wxEmptyString;
846
848 std::optional<wxString> optUri = manager.GetFullURI( LIBRARY_TABLE_TYPE::FOOTPRINT, libName, true );
849
850 if( !optUri )
851 return 0;
852
853 path = *optUri;
854
855 wxString fileExt = wxEmptyString;
856
857 // If selection is footprint
858 if( !libItemName.IsEmpty() )
860
861 wxFileName fileName( path, libItemName, fileExt );
862 wxString explorerCommand;
863
864 if( COMMON_SETTINGS* cfg = Pgm().GetCommonSettings() )
865 explorerCommand = cfg->m_System.file_explorer;
866
867 if( explorerCommand.IsEmpty() )
868 {
869 path = fileName.GetFullPath().BeforeLast( wxFileName::GetPathSeparator() );
870
871 if( !path.IsEmpty() && wxDirExists( path ) )
873
874 return 0;
875 }
876
877 if( !explorerCommand.EndsWith( "%F" ) )
878 {
879 wxMessageBox( _( "Missing/malformed file explorer argument '%F' in common settings." ) );
880 return 0;
881 }
882
883 wxString escapedFilePath = fileName.GetFullPath();
884 escapedFilePath.Replace( wxS( "\"" ), wxS( "_" ) );
885
886 wxString fileArg = wxEmptyString;
887 fileArg << '"' << escapedFilePath << '"';
888
889 explorerCommand.Replace( wxT( "%F" ), fileArg );
890
891 if( !explorerCommand.IsEmpty() )
892 wxExecute( explorerCommand );
893
894 return 0;
895}
896
897
899{
900 wxString fullEditorName = Pgm().GetTextEditor();
901
902 if( fullEditorName.IsEmpty() )
903 {
904 wxMessageBox( _( "No text editor selected in KiCad. Please choose one." ) );
905 return 0;
906 }
907
908 // No check for multi selection since the context menu option must be hidden in that case
909 LIB_ID libId = m_frame->GetLibTree()->GetSelectedLibId();
910
912
913 wxString libName = libId.GetLibNickname();
914 wxString libItemName = wxEmptyString;
915
916 std::optional<wxString> optUri = manager.GetFullURI( LIBRARY_TABLE_TYPE::FOOTPRINT, libName, true );
917
918 if( !optUri )
919 return 0;
920
921 libItemName = *optUri;
922 libItemName << wxFileName::GetPathSeparator();
923 libItemName << libId.GetLibItemName();
924 libItemName << '.' + FILEEXT::KiCadFootprintFileExtension;
925
926 if( !wxFileName::FileExists( libItemName ) )
927 return 0;
928
929 ExecuteFile( fullEditorName, libItemName.wc_str(), nullptr, false );
930
931 return 0;
932}
933
934
936{
937 if( FOOTPRINT* footprint = m_frame->GetBoard()->GetFirstFootprint() )
938 {
939 std::optional<wxString> url = GetFootprintDocumentationURL( *footprint );
940
941 if( !url.has_value() )
942 {
943 frame()->ShowInfoBarMsg( _( "No datasheet found in the footprint." ) );
944 }
945 else
946 {
947 // Only absolute URLs are supported
948 SEARCH_STACK* searchStack = nullptr;
949 GetAssociatedDocument( m_frame, *url, &m_frame->Prj(), searchStack,
950 { m_frame->GetBoard(), footprint } );
951 }
952 }
953 return 0;
954}
955
956
958{
959 m_frame->LoadFootprintFromLibrary( m_frame->GetLibTree()->GetSelectedLibId() );
960 return 0;
961}
962
963
965{
966 FOOTPRINT* footprint = m_frame->GetBoard()->GetFirstFootprint();
967
968 if( !footprint || !m_frame->IsCurrentFPFromBoard() )
969 {
970 wxBell();
971 return 0;
972 }
973
974 m_frame->LoadFootprintFromLibrary( footprint->GetFPID() );
975
976 if( !m_frame->IsLibraryTreeShown() )
977 m_frame->ToggleLibraryTree();
978
979 return 0;
980}
981
982
984{
985 m_frame->ToggleLayersManager();
986 return 0;
987}
988
989
991{
992 m_frame->ToggleProperties();
993 return 0;
994}
995
996
998{
999 // Check if called from tree context menu
1001 {
1002 LIB_ID treeLibId = m_frame->GetLibTree()->GetSelectedLibId();
1003
1004 // Check if a different footprint is selected in the tree
1005 if( treeLibId.IsValid()
1006 && ( !m_frame->GetBoard()->GetFirstFootprint()
1007 || m_frame->GetBoard()->GetFirstFootprint()->GetFPID() != treeLibId ) )
1008 {
1009 // Edit properties directly from library without loading to canvas
1011 return 0;
1012 }
1013 }
1014
1015 if( FOOTPRINT* footprint = m_frame->GetBoard()->GetFirstFootprint() )
1016 {
1017 getEditFrame<FOOTPRINT_EDIT_FRAME>()->OnEditItemRequest( footprint );
1018 m_frame->GetCanvas()->Refresh();
1019 }
1020
1021 return 0;
1022}
1023
1024
1026{
1027 // Load the footprint from the library (without adding it to the canvas)
1028 FOOTPRINT* libraryFootprint = m_frame->LoadFootprint( aLibId );
1029
1030 if( !libraryFootprint )
1031 return;
1032
1033 // Create a temporary board to hold the footprint (required by the dialog)
1034 std::unique_ptr<BOARD> tempBoard( new BOARD() );
1035
1036 // Set up the temp board with the current project and board settings.
1037 // Use reference-only mode to avoid modifying the project's settings.
1038 tempBoard->SetDesignSettings( m_frame->GetBoard()->GetDesignSettings() );
1039 tempBoard->SetProject( &m_frame->Prj(), true );
1040 tempBoard->SetBoardUse( BOARD_USE::FPHOLDER );
1041 tempBoard->SynchronizeProperties();
1042
1043 // Create a copy to work with and add it to the temporary board
1044 FOOTPRINT* tempFootprint = static_cast<FOOTPRINT*>( libraryFootprint->Clone() );
1045 delete libraryFootprint;
1046
1047 tempBoard->Add( tempFootprint );
1048 tempFootprint->SetParent( tempBoard.get() );
1049
1050 LIB_ID oldFPID = tempFootprint->GetFPID();
1051
1052 // Open the properties dialog
1053 DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR dialog( m_frame, tempFootprint );
1054
1055 if( dialog.ShowQuasiModal() != wxID_OK )
1056 return;
1057
1058 // Remove from temporary board before saving (to avoid double-delete)
1059 tempBoard->Remove( tempFootprint );
1060
1061 // Save the modified footprint back to the library
1063 wxString libName = aLibId.GetLibNickname();
1064
1065 try
1066 {
1067 adapter->SaveFootprint( libName, tempFootprint, true );
1068
1069 // Update the tree view
1070 wxDataViewItem treeItem = m_frame->GetLibTreeAdapter()->FindItem( oldFPID );
1071 m_frame->UpdateLibraryTree( treeItem, tempFootprint );
1072 m_frame->SyncLibraryTree( true );
1073
1074 // Clean up
1075 delete tempFootprint;
1076 }
1077 catch( const IO_ERROR& ioe )
1078 {
1079 delete tempFootprint;
1080 DisplayError( m_frame, ioe.What() );
1081 }
1082}
1083
1084
1086{
1088 DIALOG_CLEANUP_GRAPHICS dlg( editFrame, true );
1089
1090 dlg.ShowModal();
1091 return 0;
1092}
1093
1094
1096{
1097 if( !m_checkerDialog )
1098 {
1100 m_checkerDialog->Show( true );
1101 }
1102 else // The dialog is just not visible (because the user has double clicked on an error item)
1103 {
1104 m_checkerDialog->Show( true );
1105 }
1106
1107 return 0;
1108}
1109
1110
1112{
1113 const FOOTPRINT* footprint = m_frame->GetBoard()->GetFirstFootprint();
1114
1115 if( !footprint )
1116 return 0;
1117
1118 DIALOG_FOOTPRINT_USERS dlg( m_frame, m_frame->Kiway(), m_frame->GetLoadedFPID(), footprint->GetPinCount() );
1119
1120 dlg.ShowModal();
1121 return 0;
1122}
1123
1124
1126{
1127 if( !m_checkerDialog )
1129
1130 if( !m_checkerDialog->IsShownOnScreen() )
1131 m_checkerDialog->Show( true );
1132
1133 m_checkerDialog->SelectMarker( aMarker );
1134}
1135
1136
1138{
1139 if( m_checkerDialog )
1140 {
1141 m_checkerDialog->Destroy();
1142 m_checkerDialog = nullptr;
1143 }
1144}
1145
1146
1148{
1149 FOOTPRINT* footprint = board()->Footprints().front();
1150 int errors = 0;
1151 wxString details;
1152
1153 // Repair duplicate IDs and missing nets.
1154 std::set<KIID> ids;
1155 int duplicates = 0;
1156
1157 auto processItem =
1158 [&]( EDA_ITEM* aItem )
1159 {
1160 if( ids.count( aItem->m_Uuid ) )
1161 {
1162 duplicates++;
1163 if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( aItem ) )
1164 boardItem->ResetUuid();
1165 }
1166
1167 ids.insert( aItem->m_Uuid );
1168 };
1169
1170 // Footprint IDs are the most important, so give them the first crack at "claiming" a
1171 // particular KIID.
1172
1173 processItem( footprint );
1174
1175 // After that the principal use is for DRC marker pointers, which are most likely to pads.
1176
1177 for( PAD* pad : footprint->Pads() )
1178 processItem( pad );
1179
1180 // From here out I don't think order matters much.
1181
1182 processItem( &footprint->Reference() );
1183 processItem( &footprint->Value() );
1184
1185 for( BOARD_ITEM* item : footprint->GraphicalItems() )
1186 processItem( item );
1187
1188 for( ZONE* zone : footprint->Zones() )
1189 processItem( zone );
1190
1191 for( PCB_GROUP* group : footprint->Groups() )
1192 processItem( group );
1193
1194 if( duplicates )
1195 {
1196 errors += duplicates;
1197 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
1198 }
1199
1200 if( errors )
1201 {
1202 m_frame->OnModify();
1203
1204 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
1205 DisplayInfoMessage( m_frame, msg, details );
1206 }
1207 else
1208 {
1209 DisplayInfoMessage( m_frame, _( "No footprint problems found." ) );
1210 }
1211
1212 return 0;
1213}
1214
1215
1216// The appearance panel also claims Ctrl+Tab for layer-preset cycling, so it wins when focused.
1218{
1219 wxWindow* appearance = aFrame->GetAppearancePanel();
1220
1221 if( !appearance )
1222 return false;
1223
1224 for( wxWindow* focus = wxWindow::FindFocus(); focus; focus = focus->GetParent() )
1225 {
1226 if( focus == appearance )
1227 return true;
1228 }
1229
1230 return false;
1231}
1232
1233
1235{
1237 return 0;
1238
1239 m_frame->AdvanceFootprintTab( true );
1240 return 0;
1241}
1242
1243
1245{
1247 return 0;
1248
1249 m_frame->AdvanceFootprintTab( false );
1250 return 0;
1251}
1252
1253
1255{
1256 m_frame->CloseActiveFootprintTab();
1257 return 0;
1258}
1259
1260
1262{
1263 if( m_frame->GetTargetFPID().GetLibNickname().empty() )
1264 return 0;
1265
1266 if( m_frame->HasModifiedFootprintTabs() )
1267 {
1268 DisplayInfoMessage( m_frame, _( "Save or discard the changes in all modified footprint tabs before opening "
1269 "the Footprint Fields Table." ) );
1270 return 0;
1271 }
1272
1274
1275 dlg.ShowModal();
1276 return 0;
1277}
1278
1279
1281{
1282 // clang-format off
1285 PCB_ACTIONS::createFootprint.MakeEvent() );
1292
1298
1307
1311
1314
1318
1322
1326 // clang-format on
1327
1328 // Line modes for the footprint editor: explicit modes, next-mode, and toolbar sync
1334}
1335
1337{
1338 LEADER_MODE mode = aEvent.Parameter<LEADER_MODE>();
1339 GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" )->m_AngleSnapMode = mode;
1340 m_toolMgr->PostAction( ACTIONS::refreshPreview );
1342 return 0;
1343}
1344
1346{
1348
1349 if( !f )
1350 return 0;
1351
1352 LEADER_MODE mode = GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" )->m_AngleSnapMode;
1353
1354 switch( mode )
1355 {
1358 default:
1360 }
1361
1362 return 0;
1363}
@ FPHOLDER
Definition board.h:403
static TOOL_ACTION openWithTextEditor
Definition actions.h:65
static TOOL_ACTION revert
Definition actions.h:58
static TOOL_ACTION saveAs
Definition actions.h:55
static TOOL_ACTION exportForOlderVersion
Definition actions.h:60
static TOOL_ACTION openDirectory
Definition actions.h:66
static TOOL_ACTION showDatasheet
Definition actions.h:265
static TOOL_ACTION save
Definition actions.h:54
static TOOL_ACTION zoomFitScreen
Definition actions.h:139
static TOOL_ACTION showProperties
Definition actions.h:263
static TOOL_ACTION refreshPreview
Definition actions.h:156
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:99
void BuildListOfNets()
Definition board.h:1189
const FOOTPRINTS & Footprints() const
Definition board.h:465
Shows the symbols that use a footprint with some switchable match categories.
File-compare dialog (Phase 7).
void DrawChosenLibraryItem(LIBRARY_ITEM_DRAWER aDraw)
Draw only the library item named by the chosen change, since the outlines of a whole library pile up ...
int ShowModal() override
void SelectToolbarAction(const TOOL_ACTION &aAction) override
Select the given action in the toolbar group which contains it, if any.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the KIGFX::VIEW_CONTROLS instance used in the panel.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition eda_item.h:160
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
int Revert(const TOOL_EVENT &aEvent)
int ExportForOlderVersion(const TOOL_EVENT &aEvent)
int OpenWithTextEditor(const TOOL_EVENT &aEvent)
int PasteFootprint(const TOOL_EVENT &aEvent)
DIALOG_FOOTPRINT_CHECKER * m_checkerDialog
int CutCopyFootprint(const TOOL_EVENT &aEvent)
int EditFootprint(const TOOL_EVENT &aEvent)
int CloseTab(const TOOL_EVENT &aEvent)
int ToggleProperties(const TOOL_EVENT &aEvent)
int Save(const TOOL_EVENT &aEvent)
int OpenDirectory(const TOOL_EVENT &aEvent)
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
int NextTab(const TOOL_EVENT &aEvent)
int ExportFootprintAsSVG(const TOOL_EVENT &aEvent)
int ShowLibraryFieldsTable(const TOOL_EVENT &aEvent)
int NewFootprint(const TOOL_EVENT &aEvent)
int CompareLibraryWithFile(const TOOL_EVENT &aEvent)
Diff the currently-selected footprint library against another .pretty directory.
void CrossProbe(const PCB_MARKER *aMarker)
int ChangeLineMode(const TOOL_EVENT &aEvent)
int ShowFootprintUsers(const TOOL_EVENT &aEvent)
int ImportFootprint(const TOOL_EVENT &aEvent)
int CleanupGraphics(const TOOL_EVENT &aEvent)
int ShowDatasheet(const TOOL_EVENT &aEvent)
void tryToSaveFootprintInLibrary(FOOTPRINT &aFootprint, const LIB_ID &aLibId)
Try to save the footprint in the library, if it is valid and writable.
int PrevTab(const TOOL_EVENT &aEvent)
int Properties(const TOOL_EVENT &aEvent)
int ToggleLayersManager(const TOOL_EVENT &aEvent)
int RepairFootprint(const TOOL_EVENT &aEvent)
int RenameFootprint(const TOOL_EVENT &aEvent)
int DuplicateFootprint(const TOOL_EVENT &aEvent)
std::unique_ptr< FOOTPRINT > m_copiedFootprint
bool Init() override
Init() is called once upon a registration of the tool.
int CreateFootprintFromWizard(const TOOL_EVENT &aEvent)
int OnAngleSnapModeChanged(const TOOL_EVENT &aEvent)
int ExportFootprint(const TOOL_EVENT &aEvent)
int EditLibraryFootprint(const TOOL_EVENT &aEvent)
void editFootprintPropertiesFromLibrary(const LIB_ID &aLibId)
int DeleteFootprint(const TOOL_EVENT &aEvent)
int SaveAs(const TOOL_EVENT &aEvent)
void setTransitions() override
< Set up handlers for various events.
int CheckFootprint(const TOOL_EVENT &aEvent)
An interface to the global shared library manager that is schematic-specific and linked to one projec...
SAVE_T SaveFootprint(const wxString &aNickname, const FOOTPRINT *aFootprint, bool aOverwrite=true)
Write aFootprint to an existing library given by aNickname.
FOOTPRINT * GetBuiltFootprint()
Return a duplicate of the generated footprint. The caller takes ownership.
void SetPosition(const VECTOR2I &aPos) override
void SetFPID(const LIB_ID &aFPID)
Definition footprint.h:418
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
const LIB_ID & GetFPID() const
Definition footprint.h:417
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()
wxString m_outputLibraryPath
Where to write the converted copy.
wxString m_libraryPath
The .pretty footprint library to convert.
Diff two .pretty footprint library directories.
static std::pair< std::vector< std::unique_ptr< FOOTPRINT > >, FOOTPRINT_MAP > LoadLibrary(const wxString &aPrettyPath)
Load a .pretty directory into a FOOTPRINT_MAP.
DOCUMENT_DIFF Diff() override
Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with.
std::map< wxString, const FOOTPRINT * > FOOTPRINT_MAP
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
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition pcb_view.cpp:87
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
@ FACE_PCB
pcbnew DSO
Definition kiway.h:356
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< LIBRARY_TABLE_ROW * > GetRow(const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const
Like LIBRARY_MANAGER::GetRow but filtered to the LIBRARY_TABLE_TYPE of this adapter.
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
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
Definition lib_id.cpp:113
const wxString GetUniStringLibNickname() const
Definition lib_id.h:84
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
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition lseq.h:47
LSEQ SeqStackupForPlotting() const
Return the sequence that is typical for a bottom-to-top stack-up.
Definition lset.cpp:400
static const LSET & AllLayersMask()
Definition lset.cpp:637
Definition pad.h:61
static TOOL_ACTION lineModeFree
Unconstrained angle mode (icon lines_any)
static TOOL_ACTION deleteFootprint
static TOOL_ACTION renameFootprint
static TOOL_ACTION showFootprintUsers
static TOOL_ACTION showLayersManager
static TOOL_ACTION createFootprint
static TOOL_ACTION editFootprint
static TOOL_ACTION exportFootprint
static TOOL_ACTION editTextAndGraphics
static TOOL_ACTION lineMode45
45-degree-or-orthogonal mode (icon hv45mode)
static TOOL_ACTION angleSnapModeChanged
Notification event when angle mode changes.
static TOOL_ACTION newFootprint
static TOOL_ACTION prevFootprintTab
static TOOL_ACTION importFootprint
static TOOL_ACTION pasteFootprint
static TOOL_ACTION footprintProperties
static TOOL_ACTION lineMode90
90-degree-only mode (icon lines90)
static TOOL_ACTION closeFootprintTab
static TOOL_ACTION nextFootprintTab
static TOOL_ACTION showLibFootprintFieldsTable
static TOOL_ACTION checkFootprint
static TOOL_ACTION editLibFpInFpEditor
static TOOL_ACTION duplicateFootprint
static TOOL_ACTION cutFootprint
static TOOL_ACTION repairFootprint
static TOOL_ACTION exportFootprintAsSVG
static TOOL_ACTION compareFpLibraryWithFile
static TOOL_ACTION copyFootprint
static TOOL_ACTION cleanupGraphics
APPEARANCE_CONTROLS * GetAppearancePanel()
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:51
Parameters and options when plotting/printing a board.
void SetAutoScale(bool aFlag)
void SetScale(double aVal)
void SetColorSettings(COLOR_SETTINGS *aSettings)
void SetFormat(PLOT_FORMAT aFormat)
T * frame() const
KIGFX::PCB_VIEW * view() const
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
BOARD * board() const
PCB_DRAW_PANEL_GAL * canvas() const
FOOTPRINT * footprint() const
virtual const wxString & GetTextEditor(bool aCanShowFileChooser=true)
Return the path to the preferred text editor application.
Definition pgm_base.cpp:250
virtual LIBRARY_MANAGER & GetLibraryManager() const
Definition pgm_base.h:126
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
Look for files in a number of paths.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
T * getEditFrame() const
Return the application window object, casted to requested user type.
Definition tool_base.h:182
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition tool_base.cpp:40
TOOL_MANAGER * m_toolMgr
Definition tool_base.h:220
RESET_REASON
Determine the reason of reset for a tool.
Definition tool_base.h:74
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:484
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).
std::unique_ptr< TOOL_MENU > m_menu
The functions below are not yet implemented - their interface may change.
bool empty() const
Definition utf8.h:105
GAL-backed canvas for visualizing a KICAD_DIFF::DIFF_SCENE.
A modified version of the wxInfoBar class that allows us to:
Definition wx_infobar.h:77
bool HasCloseButton() const
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Handle a list of polygons defining a copper zone.
Definition zone.h:70
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition confirm.cpp:245
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.
void RunExportForOlderVersion(EDA_BASE_FRAME *aFrame, const DOWNGRADE_EXPORT_RUNNER &aRun)
bool RunDowngradeJob(KIWAY &aKiway, KIWAY::FACE_T aFace, JOB_T &aJob, const DOWNGRADE_EXPORT_PASS &aPass, DOWNGRADE_EXPORT_RESULT &aResult)
Fill in the parts of a downgrade job that every editor sets the same way, run it, and hand back its r...
#define _(s)
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, PROJECT *aProject, SEARCH_STACK *aPaths, std::vector< EMBEDDED_FILES * > aFilesStack)
Open a document (file) with the suitable browser.
Definition eda_doc.cpp:59
This file is part of the common library.
static bool appearancePanelHasFocus(FOOTPRINT_EDIT_FRAME *aFrame)
@ FRAME_FOOTPRINT_WIZARD
Definition frame_type.h:42
std::optional< wxString > GetFootprintDocumentationURL(const FOOTPRINT &aFootprint)
Get a URL to the documentation for a LIB_ID in a LIBRARY_TABLE.
LEADER_MODE
The kind of the leader line.
@ DEG45
45 Degree only
@ DIRECT
Unconstrained point-to-point.
@ DEG90
90 Degree only
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
Definition gestfich.cpp:170
static const std::string SVGFileExtension
static const std::string KiCadFootprintFileExtension
static wxString SVGFileWildcard()
bool LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
DOCUMENT_GEOMETRY ExtractFootprintGeometry(const FOOTPRINT &aFootprint, const KIGFX::COLOR4D &aColor)
Extract drawable context geometry from a single FOOTPRINT.
void ShowFootprintPair(WIDGET_DIFF_CANVAS &aCanvas, const FP_LIB_DIFFER::FOOTPRINT_MAP &aBefore, const FP_LIB_DIFFER::FOOTPRINT_MAP &aAfter, const wxString &aName)
Draw the footprint aName as it is in aBefore and aAfter.
Class to handle a set of BOARD_ITEMs.
bool PlotFootprintToSVG(const FOOTPRINT &aFootprint, PROJECT &aProject, const std::map< wxString, wxString > *aVarOverrides, PCB_PLOT_PARAMS &aPlotOpts, const LSEQ &aLayersToPlot, const LSEQ &aLayersOnAll, const wxString &aFileName, REPORTER *aReporter)
Plot a footprint to an SVG file, with the footprint origin at the SVG origin and the page/viewBox siz...
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
T * GetAppSettings(const char *aFilename)
What one pass of an export is asked to do.
bool m_dryRun
Classify only, write nothing.
wxString m_folder
Destination, empty on a dry run.
What the flow needs back from a pass.
Diff colors with defaults for light backgrounds.
Definition diff_scene.h:278
KIGFX::COLOR4D reference
Default color for source-document context geometry.
Definition diff_scene.h:292
The full set of changes between two parsed documents of one type.
std::string path
wxString result
Test unit parsing edge cases and error handling.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707
Definition of file extensions used in Kicad.