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 (C) 2019-2022 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, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <advanced_config.h>
27#include <string_utils.h>
28#include <pgm_base.h>
29#include <tool/tool_manager.h>
31#include <tools/pcb_actions.h>
32#include <eda_doc.h>
35#include <pcbnew_id.h>
36#include <confirm.h>
37#include <kidialog.h>
38#include <wx/filename.h>
40#include <launch_ext.h> // To default when file manager setting is empty
41#include <gestfich.h> // To open with a text editor
42#include <widgets/wx_infobar.h>
43#include <footprint.h>
44#include <pad.h>
45#include <pcb_group.h>
46#include <zone.h>
47#include <fp_lib_table.h>
51#include <kiway.h>
52#include <project_pcb.h>
53#include <view/view_controls.h>
54
55#include <memory>
56
58
59
61 PCB_TOOL_BASE( "pcbnew.ModuleEditor" ),
62 m_frame( nullptr ),
63 m_checkerDialog( nullptr )
64{
65}
66
67
69{
70 m_frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
71
72 if( m_checkerDialog )
74}
75
76
78{
80
81 // Build a context menu for the footprint tree
82 //
83 CONDITIONAL_MENU& ctxMenu = m_menu->GetMenu();
84
85 auto libSelectedCondition =
86 [ this ]( const SELECTION& aSel )
87 {
89 return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty();
90 };
91
92 // The libInferredCondition allows you to do things like New Symbol and Paste with a
93 // symbol selected (in other words, when we know the library context even if the library
94 // itself isn't selected.
95 auto libInferredCondition =
96 [ this ]( const SELECTION& aSel )
97 {
99 return !sel.GetLibNickname().empty();
100 };
101
102 auto fpSelectedCondition =
103 [ this ]( const SELECTION& aSel )
104 {
106 return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
107 };
108
109 auto fpExportCondition =
110 [ this ]( const SELECTION& aSel )
111 {
113 return fp != nullptr;
114 };
115
116 auto canOpenExternally =
117 [ this ]( const SELECTION& aSel )
118 {
119 // The option is shown if the editor has no current edits,
120 // dumb/simple guard against opening a new file that does not exist on disk
121 bool ret = !m_frame->IsContentModified();
122 return ret;
123 };
124
125// clang-format off
126 ctxMenu.AddItem( PCB_ACTIONS::newFootprint, libSelectedCondition, 10 );
127 ctxMenu.AddItem( PCB_ACTIONS::createFootprint, libSelectedCondition, 10 );
128
129 ctxMenu.AddSeparator( 10 );
130 ctxMenu.AddItem( ACTIONS::save, SELECTION_CONDITIONS::ShowAlways, 10 );
131 ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition || fpSelectedCondition, 10 );
132 ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition || libInferredCondition, 10 );
133
134 ctxMenu.AddSeparator( 10 );
135 ctxMenu.AddItem( PCB_ACTIONS::cutFootprint, fpSelectedCondition, 10 );
136 ctxMenu.AddItem( PCB_ACTIONS::copyFootprint, fpSelectedCondition, 10 );
137 ctxMenu.AddItem( PCB_ACTIONS::pasteFootprint, libInferredCondition, 10 );
138 ctxMenu.AddItem( PCB_ACTIONS::duplicateFootprint, fpSelectedCondition, 10 );
139 ctxMenu.AddItem( PCB_ACTIONS::renameFootprint, fpSelectedCondition, 10 );
140 ctxMenu.AddItem( PCB_ACTIONS::deleteFootprint, fpSelectedCondition, 10 );
141
142 ctxMenu.AddSeparator( 100 );
143 ctxMenu.AddItem( PCB_ACTIONS::importFootprint, libInferredCondition, 100 );
144 ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpExportCondition, 100 );
145
147 {
148 ctxMenu.AddSeparator( 200 );
149 ctxMenu.AddItem( ACTIONS::openWithTextEditor, canOpenExternally && fpSelectedCondition, 200 );
150 }
151
153 {
154 ctxMenu.AddSeparator( 200 );
155 ctxMenu.AddItem( ACTIONS::openDirectory, canOpenExternally && ( libSelectedCondition || fpSelectedCondition ), 200 );
156 }
157// clang-format on
158
159 libraryTreeTool->AddContextMenuItems( &ctxMenu );
160
161 return true;
162}
163
164
166 const LIB_ID& aTargetLib )
167{
168 const wxString libraryName = aTargetLib.GetUniStringLibNickname();
169
170 if( aTargetLib.GetLibNickname().empty() )
171 {
172 // Do nothing - the footprint will need to be saved manually to assign
173 // to a library.
174 }
175 else
176 {
178
179 if( !libTable.IsFootprintLibWritable( libraryName ) )
180 {
181 // If the library is not writeable, we'll give the user a
182 // footprint not in a library. But add a warning to let them know
183 // they didn't quite get what they wanted.
185 wxString::Format(
186 _( "The footprint could not be added to the selected library ('%s'). "
187 "This library is read-only." ),
188 libraryName ),
189 false );
190 // And the footprint will need to be saved manually
191 }
192 else
193 {
194 // Go ahead and save it to the library
195 LIB_ID fpid = aFootprint.GetFPID();
196 fpid.SetLibNickname( aTargetLib.GetLibNickname() );
197 aFootprint.SetFPID( fpid );
198 m_frame->SaveFootprint( &aFootprint );
200 }
201 }
202}
203
204
206{
207 const LIB_ID selected = m_frame->GetTargetFPID();
208 const wxString libraryName = selected.GetUniStringLibNickname();
209 FOOTPRINT* newFootprint = m_frame->CreateNewFootprint( wxEmptyString, libraryName );
210
211 if( !newFootprint )
212 return 0;
213
214 if( !m_frame->Clear_Pcb( true ) )
215 return 0;
216
218 m_frame->AddFootprintToBoard( newFootprint );
219
220 // Initialize data relative to nets and netclasses (for a new footprint the defaults are
221 // used). This is mandatory to handle and draw pads.
223 newFootprint->SetPosition( VECTOR2I( 0, 0 ) );
224 newFootprint->ClearFlags();
225
226 m_frame->Zoom_Automatique( false );
228
229 tryToSaveFootprintInLibrary( *newFootprint, selected );
230
232 m_frame->Update3DView( true, true );
233
234 m_frame->SyncLibraryTree( false );
235 return 0;
236}
237
238
240{
241 LIB_ID selected = m_frame->GetLibTree()->GetSelectedLibId();
242 wxString libraryName = selected.GetUniStringLibNickname();
243
245 {
246 if( !HandleUnsavedChanges( m_frame, _( "The current footprint has been modified. "
247 "Save changes?" ),
248 [&]() -> bool
249 {
250 return m_frame->SaveFootprint( footprint() );
251 } ) )
252 {
253 return 0;
254 }
255 }
256
258 {
259 FOOTPRINT_WIZARD_FRAME* wizard = static_cast<FOOTPRINT_WIZARD_FRAME*>( frame );
260
261 if( wizard->ShowModal( nullptr, m_frame ) )
262 {
263 // Creates the new footprint from python script wizard
264 FOOTPRINT* newFootprint = wizard->GetBuiltFootprint();
265
266 if( newFootprint ) // i.e. if create footprint command is OK
267 {
268 m_frame->Clear_Pcb( false );
269
271 // Add the new object to board
272 m_frame->AddFootprintToBoard( newFootprint );
273
274 // Initialize data relative to nets and netclasses (for a new footprint the
275 // defaults are used). This is mandatory to handle and draw pads.
277 newFootprint->SetPosition( VECTOR2I( 0, 0 ) );
278 newFootprint->ClearFlags();
279
280 m_frame->Zoom_Automatique( false );
282 m_frame->OnModify();
283
284 tryToSaveFootprintInLibrary( *newFootprint, selected );
285
287 canvas()->Refresh();
288 m_frame->Update3DView( true, true );
289
290 m_frame->SyncLibraryTree( false );
291 }
292 }
293
294 wizard->Destroy();
295 }
296
297 return 0;
298}
299
300
302{
303 if( !footprint() ) // no loaded footprint
304 return 0;
305
307 {
309 {
310 view()->Update( footprint() );
311
312 canvas()->ForceRefresh();
315 }
316 }
317
319 return 0;
320}
321
322
324{
326 {
327 // Save Library As
328 const wxString& src_libNickname = m_frame->GetTargetFPID().GetLibNickname();
329 wxString src_libFullName = PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->GetFullURI( src_libNickname );
330
331 if( m_frame->SaveLibraryAs( src_libFullName ) )
332 m_frame->SyncLibraryTree( true );
333 }
334 else if( m_frame->GetTargetFPID() == m_frame->GetLoadedFPID() )
335 {
336 // Save Footprint As
338 {
339 view()->Update( footprint() );
341
342 // Get rid of the save-will-update-board-only (or any other dismissable warning)
343 WX_INFOBAR* infobar = m_frame->GetInfoBar();
344
345 if( infobar->IsShownOnScreen() && infobar->HasCloseButton() )
346 infobar->Dismiss();
347
348 canvas()->ForceRefresh();
349 m_frame->SyncLibraryTree( true );
350 }
351 }
352 else
353 {
354 // Save Selected Footprint As
356
358 {
359 m_frame->SyncLibraryTree( true );
361 }
362 }
363
365 return 0;
366}
367
368
370{
371 getEditFrame<FOOTPRINT_EDIT_FRAME>()->RevertFootprint();
372 return 0;
373}
374
375
377{
379
380 if( fpID == m_frame->GetLoadedFPID() )
381 {
382 m_copiedFootprint = std::make_unique<FOOTPRINT>( *m_frame->GetBoard()->GetFirstFootprint() );
383 m_copiedFootprint->SetParent( nullptr );
384 }
385 else
386 {
387 m_copiedFootprint.reset( m_frame->LoadFootprint( fpID ) );
388 }
389
390 if( aEvent.IsAction( &PCB_ACTIONS::cutFootprint ) )
391 DeleteFootprint( aEvent );
392
393 return 0;
394}
395
396
398{
400 {
401 wxString newLib = m_frame->GetLibTree()->GetSelectedLibId().GetLibNickname();
402 wxString newName = m_copiedFootprint->GetFPID().GetLibItemName();
403
404 while( PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->FootprintExists( newLib, newName ) )
405 newName += _( "_copy" );
406
407 m_copiedFootprint->SetFPID( LIB_ID( newLib, newName ) );
409
410 m_frame->SyncLibraryTree( true );
414 }
415
416 return 0;
417}
418
419
421{
424
425 if( fpID == m_frame->GetLoadedFPID() )
427 else
429
431 {
432 m_frame->SyncLibraryTree( true );
436 }
437
438 return 0;
439}
440
441
443{
446
448 wxString libraryName = fpID.GetLibNickname();
449 wxString oldName = fpID.GetLibItemName();
450 wxString newName;
451 wxString msg;
452
453 if( !libTool->RenameLibrary( _( "Change Footprint Name" ), oldName,
454 [&]( const wxString& aNewName )
455 {
456 newName = aNewName;
457
458 if( newName.IsEmpty() )
459 {
460 wxMessageBox( _( "Footprint must have a name." ) );
461 return false;
462 }
463
464 if( tbl->FootprintExists( libraryName, newName ) )
465 {
466 msg = wxString::Format( _( "Footprint '%s' already exists in library '%s'." ),
467 newName, libraryName );
468
469 KIDIALOG errorDlg( m_frame, msg, _( "Confirmation" ),
470 wxOK | wxCANCEL | wxICON_WARNING );
471 errorDlg.SetOKLabel( _( "Overwrite" ) );
472
473 return errorDlg.ShowModal() == wxID_OK;
474 }
475
476 return true;
477 } ) )
478 {
479 return 0; // cancelled by user
480 }
481
482 FOOTPRINT* footprint = nullptr;
483
484 if( fpID == m_frame->GetLoadedFPID() )
485 {
487
488 if( footprint )
489 {
490 footprint->SetFPID( LIB_ID( libraryName, newName ) );
491
492 if( footprint->GetValue() == oldName )
493 footprint->SetValue( newName );
494
495 m_frame->OnModify();
497 }
498 }
499 else
500 {
502
503 if( footprint )
504 {
505 try
506 {
507 footprint->SetFPID( LIB_ID( libraryName, newName ) );
508
509 if( footprint->GetValue() == oldName )
510 footprint->SetValue( newName );
511
513
514 PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->FootprintDelete( libraryName, oldName );
515 }
516 catch( const IO_ERROR& ioe )
517 {
518 DisplayErrorMessage( m_frame, _( "Error renaming footprint" ), ioe.What() );
519 }
520 catch( ... )
521 {
522 // Best efforts...
523 }
524 }
525 }
526
527 wxDataViewItem treeItem = m_frame->GetLibTreeAdapter()->FindItem( fpID );
528 m_frame->UpdateLibraryTree( treeItem, footprint );
529 m_frame->FocusOnLibID( LIB_ID( libraryName, newName ) );
530
531 return 0;
532}
533
534
536{
537 FOOTPRINT_EDIT_FRAME* frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
538
539 if( frame->DeleteFootprintFromLibrary( frame->GetTargetFPID(), true ) )
540 {
541 if( frame->GetTargetFPID() == frame->GetLoadedFPID() )
542 frame->Clear_Pcb( false );
543
544 frame->SyncLibraryTree( true );
545 }
546
547 return 0;
548}
549
550
552{
553 bool is_last_fp_from_brd = m_frame->IsCurrentFPFromBoard();
554
555 if( !m_frame->Clear_Pcb( true ) )
556 return -1; // this command is aborted
557
560
563
564 frame()->ClearUndoRedoList();
565
566 // Update the save items if needed.
567 if( is_last_fp_from_brd )
568 {
571 }
572
574 m_frame->OnModify();
575 return 0;
576}
577
578
580{
583
584 return 0;
585}
586
587
589{
590 // No check for multi selection since the context menu option must be hidden in that case
591 FP_LIB_TABLE* globalTable = dynamic_cast<FP_LIB_TABLE*>( &GFootprintTable );
593 LIB_ID libId = m_frame->GetTargetFPID();
594
595 wxString libName = libId.GetLibNickname();
596 wxString libItemName = libId.GetLibItemName();
597 wxString path = wxEmptyString;
598
599 for( FP_LIB_TABLE* table : { globalTable, projectTable } )
600 {
601 if( !table )
602 break;
603
604 try
605 {
606 path = table->FindRow( libName, true )->GetFullURI( true );
607 }
608 catch( IO_ERROR& )
609 {
610 // Do nothing: libName can be not found in globalTable if libName is in projectTable
611 }
612
613 if( !path.IsEmpty() )
614 break;
615 }
616
617 wxString fileExt = wxEmptyString;
618
619 // If selection is footprint
620 if( !libItemName.IsEmpty() )
622
623 wxFileName fileName( path, libItemName, fileExt );
624
626
627 wxString explCommand = cfg->m_System.file_explorer;
628
629 if( explCommand.IsEmpty() )
630 {
631 path = fileName.GetFullPath().BeforeLast( wxFileName::GetPathSeparator() );
632
633 if( !path.IsEmpty() && wxDirExists( path ) )
635 return 0;
636 }
637
638 if( !explCommand.EndsWith( "%F" ) )
639 {
640 wxMessageBox( _( "Missing/malformed file explorer argument '%F' in common settings." ) );
641 return 0;
642 }
643
644 wxString escapedFilePath = fileName.GetFullPath();
645 escapedFilePath.Replace( wxS( "\"" ), wxS( "_" ) );
646
647 wxString fileArg = wxEmptyString;
648 fileArg << '"' << escapedFilePath << '"';
649
650 explCommand.Replace( wxT( "%F" ), fileArg );
651
652 if( !explCommand.IsEmpty() )
653 wxExecute( explCommand );
654
655 return 0;
656}
657
658
660{
661 wxString fullEditorName = Pgm().GetTextEditor();
662
663 if( fullEditorName.IsEmpty() )
664 {
665 wxMessageBox( _( "No text editor selected in KiCad. Please choose one." ) );
666 return 0;
667 }
668
669 // No check for multi selection since the context menu option must be hidden in that case
670 FP_LIB_TABLE* globalTable = dynamic_cast<FP_LIB_TABLE*>( &GFootprintTable );
673
674 wxString libName = libId.GetLibNickname();
675 wxString libItemName = wxEmptyString;
676
677 for( FP_LIB_TABLE* table : { globalTable, projectTable } )
678 {
679 if( !table )
680 break;
681
682 try
683 {
684 libItemName = table->FindRow( libName, true )->GetFullURI( true );
685 }
686 catch( IO_ERROR& )
687 {
688 // Do nothing: libName can be not found in globalTable if libName is in projectTable
689 }
690
691 if( !libItemName.IsEmpty() )
692 break;
693 }
694
695 libItemName << wxFileName::GetPathSeparator();
696 libItemName << libId.GetLibItemName();
697 libItemName << '.' + FILEEXT::KiCadFootprintFileExtension;
698
699 if( !wxFileName::FileExists( libItemName ) )
700 return 0;
701
702 ExecuteFile( fullEditorName, libItemName.wc_str(), nullptr, false );
703
704 return 0;
705}
706
707
709{
711 {
712 std::optional<wxString> url = GetFootprintDocumentationURL( *footprint );
713
714 if( !url.has_value() )
715 {
716 frame()->ShowInfoBarMsg( _( "No datasheet found in the footprint." ) );
717 }
718 else
719 {
720 // Only absolute URLs are supported
721 SEARCH_STACK* searchStack = nullptr;
722 GetAssociatedDocument( m_frame, *url, &m_frame->Prj(), searchStack, footprint );
723 }
724 }
725 return 0;
726}
727
728
730{
732 return 0;
733}
734
735
737{
739
741 {
742 wxBell();
743 return 0;
744 }
745
747
750
751 return 0;
752}
753
754
756{
758 return 0;
759}
760
761
763{
765 return 0;
766}
767
768
770{
772 {
773 getEditFrame<FOOTPRINT_EDIT_FRAME>()->OnEditItemRequest( footprint );
775 }
776
777 return 0;
778}
779
780
782{
783 getEditFrame<FOOTPRINT_EDIT_FRAME>()->ShowPadPropertiesDialog( nullptr );
784 return 0;
785}
786
787
789{
790 FOOTPRINT_EDIT_FRAME* editFrame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
791 DIALOG_CLEANUP_GRAPHICS dlg( editFrame, true );
792
793 dlg.ShowModal();
794 return 0;
795}
796
797
799{
800 if( !m_checkerDialog )
801 {
803 m_checkerDialog->Show( true );
804 }
805 else // The dialog is just not visible (because the user has double clicked on an error item)
806 {
807 m_checkerDialog->Show( true );
808 }
809
810 return 0;
811}
812
813
815{
816 if( !m_checkerDialog )
818
819 if( !m_checkerDialog->IsShownOnScreen() )
820 m_checkerDialog->Show( true );
821
822 m_checkerDialog->SelectMarker( aMarker );
823}
824
825
827{
828 if( m_checkerDialog )
829 {
830 m_checkerDialog->Destroy();
831 m_checkerDialog = nullptr;
832 }
833}
834
835
837{
838 FOOTPRINT* footprint = board()->Footprints().front();
839 int errors = 0;
840 wxString details;
841
842 // Repair duplicate IDs and missing nets.
843 std::set<KIID> ids;
844 int duplicates = 0;
845
846 auto processItem =
847 [&]( EDA_ITEM* aItem )
848 {
849 if( ids.count( aItem->m_Uuid ) )
850 {
851 duplicates++;
852 const_cast<KIID&>( aItem->m_Uuid ) = KIID();
853 }
854
855 ids.insert( aItem->m_Uuid );
856 };
857
858 // Footprint IDs are the most important, so give them the first crack at "claiming" a
859 // particular KIID.
860
861 processItem( footprint );
862
863 // After that the principal use is for DRC marker pointers, which are most likely to pads.
864
865 for( PAD* pad : footprint->Pads() )
866 processItem( pad );
867
868 // From here out I don't think order matters much.
869
870 processItem( &footprint->Reference() );
871 processItem( &footprint->Value() );
872
873 for( BOARD_ITEM* item : footprint->GraphicalItems() )
874 processItem( item );
875
876 for( ZONE* zone : footprint->Zones() )
877 processItem( zone );
878
879 for( PCB_GROUP* group : footprint->Groups() )
880 processItem( group );
881
882 if( duplicates )
883 {
884 errors += duplicates;
885 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
886 }
887
888 if( errors )
889 {
890 m_frame->OnModify();
891
892 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
893 DisplayInfoMessage( m_frame, msg, details );
894 }
895 else
896 {
897 DisplayInfoMessage( m_frame, _( "No footprint problems found." ) );
898 }
899
900 return 0;
901}
902
903
905{
906 // clang-format off
915
921
924
928
931
934
939 // clang-format on
940}
static TOOL_ACTION openWithTextEditor
Definition: actions.h:61
static TOOL_ACTION revert
Definition: actions.h:55
static TOOL_ACTION saveAs
Definition: actions.h:52
static TOOL_ACTION openDirectory
Definition: actions.h:62
static TOOL_ACTION showDatasheet
Definition: actions.h:217
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:134
static TOOL_ACTION showProperties
Definition: actions.h:216
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
void BuildListOfNets()
Definition: board.h:834
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:448
const FOOTPRINTS & Footprints() const
Definition: board.h:331
void SelectMarker(const PCB_MARKER *aMarker)
bool Show(bool show) override
int ShowModal() override
void ShowInfoBarWarning(const wxString &aWarningMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and a warning icon on the left ...
void ReCreateMenuBar()
Recreates the menu bar.
WX_INFOBAR * GetInfoBar()
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #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:89
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:129
int Revert(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 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 CreateFootprint(const TOOL_EVENT &aEvent)
FOOTPRINT_EDIT_FRAME * m_frame
int NewFootprint(const TOOL_EVENT &aEvent)
int DefaultPadProperties(const TOOL_EVENT &aEvent)
Edit the properties used for new pad creation.
void CrossProbe(const PCB_MARKER *aMarker)
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 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 ExportFootprint(const TOOL_EVENT &aEvent)
int EditLibraryFootprint(const TOOL_EVENT &aEvent)
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)
void UpdateLibraryTree(const wxDataViewItem &treeItem, FOOTPRINT *aFootprint)
Update a single node in the library tree.
void SyncLibraryTree(bool aProgress)
Synchronize the footprint library tree to the current state of the footprint library table.
bool SaveFootprintInLibrary(FOOTPRINT *aFootprint, const wxString &aLibraryName)
bool SaveLibraryAs(const wxString &aLibraryPath)
Save a library to a new name and/or library type.
bool SaveFootprintAs(FOOTPRINT *aFootprint)
bool DuplicateFootprint(FOOTPRINT *aFootprint)
void ToggleLibraryTree() override
LIB_TREE * GetLibTree() const override
void ExportFootprint(FOOTPRINT *aFootprint)
Create a file containing only one footprint.
LIB_ID GetTargetFPID() const
Return the LIB_ID of the part selected in the footprint tree, or the loaded part if there is no selec...
LIB_ID GetLoadedFPID() const
Return the LIB_ID of the part being edited.
bool SaveFootprint(FOOTPRINT *aFootprint)
Save in an existing library a given footprint.
void LoadFootprintFromLibrary(LIB_ID aFPID)
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetLibTreeAdapter()
Return the adapter object that provides the stored data.
FOOTPRINT * ImportFootprint(const wxString &aName=wxT(""))
Read a file containing only one footprint.
void ReCreateHToolbar() override
Create the main horizontal toolbar for the footprint editor.
bool IsContentModified() const override
Get if any footprints or libraries have been modified but not saved.
bool IsLibraryTreeShown() const override
bool Clear_Pcb(bool doAskAboutUnsavedChanges)
Delete all and reinitialize the current board.
Definition: initpcb.cpp:105
void AddFootprintToBoard(FOOTPRINT *aFootprint) override
Override from PCB_BASE_EDIT_FRAME which adds a footprint to the editor's dummy board,...
void OnModify() override
Must be called after a footprint change in order to set the "modify" flag of the current screen and p...
void FocusOnLibID(const LIB_ID &aLibID)
void RefreshLibraryTree()
Redisplay the library tree.
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:2388
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:249
ZONES & Zones()
Definition: footprint.h:212
PCB_FIELD & Value()
read/write accessors:
Definition: footprint.h:658
std::deque< PAD * > & Pads()
Definition: footprint.h:206
const LIB_ID & GetFPID() const
Definition: footprint.h:248
void SetValue(const wxString &aValue)
Definition: footprint.h:649
PCB_FIELD & Reference()
Definition: footprint.h:659
GROUPS & Groups()
Definition: footprint.h:215
const wxString & GetValue() const
Definition: footprint.h:644
DRAWINGS & GraphicalItems()
Definition: footprint.h:209
void FootprintDelete(const wxString &aNickname, const wxString &aFootprintName)
Delete the aFootprintName from the library given by aNickname.
bool FootprintExists(const wxString &aNickname, const wxString &aFootprintName)
Indicates whether or not the given footprint already exists in the given library.
bool IsFootprintLibWritable(const wxString &aNickname)
Return true if the library given by aNickname is writable.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
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:91
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
Definition: kiid.h:49
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:55
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:65
virtual 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.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:406
Module editor specific tools.
bool RenameLibrary(const wxString &aTitle, const wxString &aName, std::function< bool(const wxString &aNewName)> aValidator)
void AddContextMenuItems(CONDITIONAL_MENU *aMenu)
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
Definition: lib_id.cpp:99
const wxString GetUniStringLibNickname() const
Definition: lib_id.h:88
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
wxString GetFullURI(const wxString &aLibNickname, bool aExpandEnvVars=true) const
Return the full URI of the library mapped to aLibNickname.
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit,...
Definition: lib_tree.cpp:301
Definition: pad.h:54
static TOOL_ACTION deleteFootprint
Definition: pcb_actions.h:471
static TOOL_ACTION renameFootprint
Definition: pcb_actions.h:470
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:454
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:466
static TOOL_ACTION editFootprint
Definition: pcb_actions.h:468
static TOOL_ACTION exportFootprint
Definition: pcb_actions.h:476
static TOOL_ACTION editTextAndGraphics
Definition: pcb_actions.h:423
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:463
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:479
static TOOL_ACTION importFootprint
Definition: pcb_actions.h:475
static TOOL_ACTION pasteFootprint
Definition: pcb_actions.h:474
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:478
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:481
static TOOL_ACTION editLibFpInFpEditor
Definition: pcb_actions.h:452
static TOOL_ACTION duplicateFootprint
Definition: pcb_actions.h:469
static TOOL_ACTION cutFootprint
Definition: pcb_actions.h:472
static TOOL_ACTION repairFootprint
Definition: pcb_actions.h:550
static TOOL_ACTION copyFootprint
Definition: pcb_actions.h:473
static TOOL_ACTION cleanupGraphics
Definition: pcb_actions.h:427
void ToggleProperties() override
FOOTPRINT * CreateNewFootprint(wxString aFootprintName, const wxString &aLibName)
Creates a new footprint, at position 0,0.
FOOTPRINT * LoadFootprint(const LIB_ID &aFootprintId)
Attempt to load aFootprintId from the footprint library table.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
BOARD * GetBoard() const
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:52
T * frame() const
KIGFX::PCB_VIEW * view() const
BOARD * board() const
PCB_DRAW_PANEL_GAL * canvas() const
FOOTPRINT * footprint() const
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:679
virtual const wxString & GetTextEditor(bool aCanShowFileChooser=true)
Return the path to the preferred text editor application.
Definition: pgm_base.cpp:196
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
Definition: project_pcb.cpp:37
Look for files in a number of paths.
Definition: search_stack.h:43
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
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.
Definition: tool_event.cpp:82
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 RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
bool empty() const
Definition: utf8.h:104
A modified version of the wxInfoBar class that allows us to:
Definition: wx_infobar.h:76
bool HasCloseButton() const
Definition: wx_infobar.cpp:328
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: wx_infobar.cpp:190
Handle a list of polygons defining a copper zone.
Definition: zone.h:73
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:222
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:130
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:195
This file is part of the common library.
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: cvpcb.cpp:150
#define _(s)
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, PROJECT *aProject, SEARCH_STACK *aPaths, EMBEDDED_FILES *aFiles)
Open a document (file) with the suitable browser.
Definition: eda_doc.cpp:62
This file is part of the common library.
@ FRAME_FOOTPRINT_WIZARD
Definition: frame_type.h:46
std::optional< wxString > GetFootprintDocumentationURL(const FOOTPRINT &aFootprint)
Get a URL to the documentation for a LIB_ID in a FP_LIB_TABLE.
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
Definition: gestfich.cpp:143
bool m_EnableLibDir
Enable option to open lib file directory.
bool m_EnableLibWithText
Enable option to load lib files with text editor.
static const std::string KiCadFootprintFileExtension
This file is part of the common library.
bool LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
Definition: launch_ext.cpp:25
Class to handle a set of BOARD_ITEMs.
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691
VECTOR2< double > VECTOR2D
Definition: vector2d.h:690
Definition of file extensions used in Kicad.