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>
33#include <pcbnew_id.h>
34#include <confirm.h>
35#include <kidialog.h>
36#include <wx/filename.h>
38#include <launch_ext.h> // To default when file manager setting is empty
39#include <gestfich.h> // To open with a text editor
40#include <widgets/wx_infobar.h>
41#include <footprint.h>
42#include <pad.h>
43#include <pcb_group.h>
44#include <zone.h>
45#include <fp_lib_table.h>
49#include <kiway.h>
50#include <project_pcb.h>
51#include <view/view_controls.h>
52
53#include <memory>
54
56
57
59 PCB_TOOL_BASE( "pcbnew.ModuleEditor" ),
60 m_frame( nullptr ),
61 m_checkerDialog( nullptr )
62{
63}
64
65
67{
68 m_frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
69
70 if( m_checkerDialog )
72}
73
74
76{
78
79 // Build a context menu for the footprint tree
80 //
81 CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
82
83 auto libSelectedCondition =
84 [ this ]( const SELECTION& aSel )
85 {
87 return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty();
88 };
89
90 // The libInferredCondition allows you to do things like New Symbol and Paste with a
91 // symbol selected (in other words, when we know the library context even if the library
92 // itself isn't selected.
93 auto libInferredCondition =
94 [ this ]( const SELECTION& aSel )
95 {
97 return !sel.GetLibNickname().empty();
98 };
99
100 auto fpSelectedCondition =
101 [ this ]( const SELECTION& aSel )
102 {
104 return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
105 };
106
107 auto fpExportCondition =
108 [ this ]( const SELECTION& aSel )
109 {
111 return fp != nullptr;
112 };
113
114 auto canOpenExternally =
115 [ this ]( const SELECTION& aSel )
116 {
117 // The option is shown if the editor has no current edits,
118 // dumb/simple guard against opening a new file that does not exist on disk
119 bool ret = !m_frame->IsContentModified();
120 return ret;
121 };
122
123// clang-format off
124 ctxMenu.AddItem( PCB_ACTIONS::newFootprint, libSelectedCondition, 10 );
125 ctxMenu.AddItem( PCB_ACTIONS::createFootprint, libSelectedCondition, 10 );
126
127 ctxMenu.AddSeparator( 10 );
128 ctxMenu.AddItem( ACTIONS::save, SELECTION_CONDITIONS::ShowAlways, 10 );
129 ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition || fpSelectedCondition, 10 );
130 ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition || libInferredCondition, 10 );
131
132 ctxMenu.AddSeparator( 10 );
133 ctxMenu.AddItem( PCB_ACTIONS::cutFootprint, fpSelectedCondition, 10 );
134 ctxMenu.AddItem( PCB_ACTIONS::copyFootprint, fpSelectedCondition, 10 );
135 ctxMenu.AddItem( PCB_ACTIONS::pasteFootprint, libInferredCondition, 10 );
136 ctxMenu.AddItem( PCB_ACTIONS::duplicateFootprint, fpSelectedCondition, 10 );
137 ctxMenu.AddItem( PCB_ACTIONS::renameFootprint, fpSelectedCondition, 10 );
138 ctxMenu.AddItem( PCB_ACTIONS::deleteFootprint, fpSelectedCondition, 10 );
139
140 ctxMenu.AddSeparator( 100 );
141 ctxMenu.AddItem( PCB_ACTIONS::importFootprint, libInferredCondition, 100 );
142 ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpExportCondition, 100 );
143
145 {
146 ctxMenu.AddSeparator( 200 );
147 ctxMenu.AddItem( ACTIONS::openWithTextEditor, canOpenExternally && fpSelectedCondition, 200 );
148 }
149
151 {
152 ctxMenu.AddSeparator( 200 );
153 ctxMenu.AddItem( ACTIONS::openDirectory, canOpenExternally && ( libSelectedCondition || fpSelectedCondition ), 200 );
154 }
155// clang-format on
156
157 libraryTreeTool->AddContextMenuItems( &ctxMenu );
158
159 return true;
160}
161
162
164{
165 LIB_ID selected = m_frame->GetTargetFPID();
166 wxString libraryName = selected.GetUniStringLibNickname();
167 FOOTPRINT* newFootprint = m_frame->CreateNewFootprint( wxEmptyString, libraryName );
168
169 if( !newFootprint )
170 return 0;
171
172 if( !m_frame->Clear_Pcb( true ) )
173 return 0;
174
176 m_frame->AddFootprintToBoard( newFootprint );
177
178 // Initialize data relative to nets and netclasses (for a new footprint the defaults are
179 // used). This is mandatory to handle and draw pads.
181 newFootprint->SetPosition( VECTOR2I( 0, 0 ) );
182 newFootprint->ClearFlags();
183
184 m_frame->Zoom_Automatique( false );
186
187 // If selected from the library tree then go ahead and save it there
188 if( !selected.GetLibNickname().empty() )
189 {
190 LIB_ID fpid = newFootprint->GetFPID();
191 fpid.SetLibNickname( selected.GetLibNickname() );
192 newFootprint->SetFPID( fpid );
193 m_frame->SaveFootprint( newFootprint );
195 }
196
198 m_frame->Update3DView( true, true );
199
200 m_frame->SyncLibraryTree( false );
201 return 0;
202}
203
204
206{
207 LIB_ID selected = m_frame->GetLibTree()->GetSelectedLibId();
208
210 {
211 if( !HandleUnsavedChanges( m_frame, _( "The current footprint has been modified. "
212 "Save changes?" ),
213 [&]() -> bool
214 {
215 return m_frame->SaveFootprint( footprint() );
216 } ) )
217 {
218 return 0;
219 }
220 }
221
223 {
224 FOOTPRINT_WIZARD_FRAME* wizard = static_cast<FOOTPRINT_WIZARD_FRAME*>( frame );
225
226 if( wizard->ShowModal( nullptr, m_frame ) )
227 {
228 // Creates the new footprint from python script wizard
229 FOOTPRINT* newFootprint = wizard->GetBuiltFootprint();
230
231 if( newFootprint ) // i.e. if create footprint command is OK
232 {
233 m_frame->Clear_Pcb( false );
234
236 // Add the new object to board
237 m_frame->AddFootprintToBoard( newFootprint );
238
239 // Initialize data relative to nets and netclasses (for a new footprint the
240 // defaults are used). This is mandatory to handle and draw pads.
242 newFootprint->SetPosition( VECTOR2I( 0, 0 ) );
243 newFootprint->ClearFlags();
244
245 m_frame->Zoom_Automatique( false );
247 m_frame->OnModify();
248
249 // If selected from the library tree then go ahead and save it there
250 if( !selected.GetLibNickname().empty() )
251 {
252 LIB_ID fpid = newFootprint->GetFPID();
253 fpid.SetLibNickname( selected.GetLibNickname() );
254 newFootprint->SetFPID( fpid );
255 m_frame->SaveFootprint( newFootprint );
257 }
258
260 canvas()->Refresh();
261 m_frame->Update3DView( true, true );
262
263 m_frame->SyncLibraryTree( false );
264 }
265 }
266
267 wizard->Destroy();
268 }
269
270 return 0;
271}
272
273
275{
276 if( !footprint() ) // no loaded footprint
277 return 0;
278
280 {
282 {
283 view()->Update( footprint() );
284
285 canvas()->ForceRefresh();
288 }
289 }
290
292 return 0;
293}
294
295
297{
299 {
300 // Save Library As
301 const wxString& src_libNickname = m_frame->GetTargetFPID().GetLibNickname();
302 wxString src_libFullName = PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->GetFullURI( src_libNickname );
303
304 if( m_frame->SaveLibraryAs( src_libFullName ) )
305 m_frame->SyncLibraryTree( true );
306 }
307 else if( m_frame->GetTargetFPID() == m_frame->GetLoadedFPID() )
308 {
309 // Save Footprint As
311 {
312 view()->Update( footprint() );
314
315 // Get rid of the save-will-update-board-only (or any other dismissable warning)
316 WX_INFOBAR* infobar = m_frame->GetInfoBar();
317
318 if( infobar->IsShownOnScreen() && infobar->HasCloseButton() )
319 infobar->Dismiss();
320
321 canvas()->ForceRefresh();
322 m_frame->SyncLibraryTree( true );
323 }
324 }
325 else
326 {
327 // Save Selected Footprint As
329
331 {
332 m_frame->SyncLibraryTree( true );
334 }
335 }
336
338 return 0;
339}
340
341
343{
344 getEditFrame<FOOTPRINT_EDIT_FRAME>()->RevertFootprint();
345 return 0;
346}
347
348
350{
352
353 if( fpID == m_frame->GetLoadedFPID() )
354 {
355 m_copiedFootprint = std::make_unique<FOOTPRINT>( *m_frame->GetBoard()->GetFirstFootprint() );
356 m_copiedFootprint->SetParent( nullptr );
357 }
358 else
359 {
360 m_copiedFootprint.reset( m_frame->LoadFootprint( fpID ) );
361 }
362
363 if( aEvent.IsAction( &PCB_ACTIONS::cutFootprint ) )
364 DeleteFootprint( aEvent );
365
366 return 0;
367}
368
369
371{
373 {
374 wxString newLib = m_frame->GetLibTree()->GetSelectedLibId().GetLibNickname();
375 wxString newName = m_copiedFootprint->GetFPID().GetLibItemName();
376
377 while( PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->FootprintExists( newLib, newName ) )
378 newName += _( "_copy" );
379
380 m_copiedFootprint->SetFPID( LIB_ID( newLib, newName ) );
382
383 m_frame->SyncLibraryTree( true );
387 }
388
389 return 0;
390}
391
392
394{
397
398 if( fpID == m_frame->GetLoadedFPID() )
400 else
402
404 {
405 m_frame->SyncLibraryTree( true );
409 }
410
411 return 0;
412}
413
414
416{
419
421 wxString libraryName = fpID.GetLibNickname();
422 wxString oldName = fpID.GetLibItemName();
423 wxString newName;
424 wxString msg;
425
426 if( !libTool->RenameLibrary( _( "Change Footprint Name" ), oldName,
427 [&]( const wxString& aNewName )
428 {
429 newName = aNewName;
430
431 if( newName.IsEmpty() )
432 {
433 wxMessageBox( _( "Footprint must have a name." ) );
434 return false;
435 }
436
437 if( tbl->FootprintExists( libraryName, newName ) )
438 {
439 msg = wxString::Format( _( "Footprint '%s' already exists in library '%s'." ),
440 newName, libraryName );
441
442 KIDIALOG errorDlg( m_frame, msg, _( "Confirmation" ),
443 wxOK | wxCANCEL | wxICON_WARNING );
444 errorDlg.SetOKLabel( _( "Overwrite" ) );
445
446 return errorDlg.ShowModal() == wxID_OK;
447 }
448
449 return true;
450 } ) )
451 {
452 return 0; // cancelled by user
453 }
454
455 FOOTPRINT* footprint = nullptr;
456
457 if( fpID == m_frame->GetLoadedFPID() )
458 {
460
461 if( footprint )
462 {
463 footprint->SetFPID( LIB_ID( libraryName, newName ) );
464
465 if( footprint->GetValue() == oldName )
466 footprint->SetValue( newName );
467
468 m_frame->OnModify();
470 }
471 }
472 else
473 {
475
476 if( footprint )
477 {
478 try
479 {
480 footprint->SetFPID( LIB_ID( libraryName, newName ) );
481
482 if( footprint->GetValue() == oldName )
483 footprint->SetValue( newName );
484
486
487 PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->FootprintDelete( libraryName, oldName );
488 }
489 catch( const IO_ERROR& ioe )
490 {
491 DisplayError( m_frame, ioe.What() );
492 }
493 catch( ... )
494 {
495 // Best efforts...
496 }
497 }
498 }
499
500 wxDataViewItem treeItem = m_frame->GetLibTreeAdapter()->FindItem( fpID );
501 m_frame->UpdateLibraryTree( treeItem, footprint );
502 m_frame->FocusOnLibID( LIB_ID( libraryName, newName ) );
503
504 return 0;
505}
506
507
509{
510 FOOTPRINT_EDIT_FRAME* frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
511
512 if( frame->DeleteFootprintFromLibrary( frame->GetTargetFPID(), true ) )
513 {
514 if( frame->GetTargetFPID() == frame->GetLoadedFPID() )
515 frame->Clear_Pcb( false );
516
517 frame->SyncLibraryTree( true );
518 }
519
520 return 0;
521}
522
523
525{
526 bool is_last_fp_from_brd = m_frame->IsCurrentFPFromBoard();
527
528 if( !m_frame->Clear_Pcb( true ) )
529 return -1; // this command is aborted
530
533
536
538
539 // Update the save items if needed.
540 if( is_last_fp_from_brd )
541 {
544 }
545
547 m_frame->OnModify();
548 return 0;
549}
550
551
553{
556
557 return 0;
558}
559
560
562{
563 // No check for multi selection since the context menu option must be hidden in that case
564 FP_LIB_TABLE* globalTable = dynamic_cast<FP_LIB_TABLE*>( &GFootprintTable );
566 LIB_ID libId = m_frame->GetTargetFPID();
567
568 wxString libName = libId.GetLibNickname();
569 wxString libItemName = libId.GetLibItemName();
570 wxString path = wxEmptyString;
571
572 for( FP_LIB_TABLE* table : { globalTable, projectTable } )
573 {
574 if( !table )
575 break;
576
577 try
578 {
579 path = table->FindRow( libName, true )->GetFullURI( true );
580 }
581 catch( IO_ERROR& )
582 {
583 // Do nothing: libName can be not found in globalTable if libName is in projectTable
584 }
585
586 if( !path.IsEmpty() )
587 break;
588 }
589
590 wxString fileExt = wxEmptyString;
591
592 // If selection is footprint
593 if( !libItemName.IsEmpty() )
595
596 wxFileName fileName( path, libItemName, fileExt );
597
599
600 wxString explCommand = cfg->m_System.file_explorer;
601
602 if( explCommand.IsEmpty() )
603 {
604 path = fileName.GetFullPath().BeforeLast( wxFileName::GetPathSeparator() );
605
606 if( !path.IsEmpty() && wxDirExists( path ) )
608 return 0;
609 }
610
611 if( !explCommand.EndsWith( "%F" ) )
612 {
613 wxMessageBox( _( "Missing/malformed file explorer argument '%F' in common settings." ) );
614 return 0;
615 }
616
617 wxString escapedFilePath = fileName.GetFullPath();
618 escapedFilePath.Replace( wxS( "\"" ), wxS( "_" ) );
619
620 wxString fileArg = wxEmptyString;
621 fileArg << '"' << escapedFilePath << '"';
622
623 explCommand.Replace( wxT( "%F" ), fileArg );
624
625 if( !explCommand.IsEmpty() )
626 wxExecute( explCommand );
627
628 return 0;
629}
630
631
633{
634 wxString fullEditorName = Pgm().GetTextEditor();
635
636 if( fullEditorName.IsEmpty() )
637 {
638 wxMessageBox( _( "No text editor selected in KiCad. Please choose one." ) );
639 return 0;
640 }
641
642 // No check for multi selection since the context menu option must be hidden in that case
643 FP_LIB_TABLE* globalTable = dynamic_cast<FP_LIB_TABLE*>( &GFootprintTable );
646
647 wxString libName = libId.GetLibNickname();
648 wxString libItemName = wxEmptyString;
649
650 for( FP_LIB_TABLE* table : { globalTable, projectTable } )
651 {
652 if( !table )
653 break;
654
655 try
656 {
657 libItemName = table->FindRow( libName, true )->GetFullURI( true );
658 }
659 catch( IO_ERROR& )
660 {
661 // Do nothing: libName can be not found in globalTable if libName is in projectTable
662 }
663
664 if( !libItemName.IsEmpty() )
665 break;
666 }
667
668 libItemName << wxFileName::GetPathSeparator();
669 libItemName << libId.GetLibItemName();
670 libItemName << '.' + FILEEXT::KiCadFootprintFileExtension;
671
672 if( !wxFileName::FileExists( libItemName ) )
673 return 0;
674
675 ExecuteFile( fullEditorName, libItemName.wc_str(), nullptr, false );
676
677 return 0;
678}
679
680
682{
684 return 0;
685}
686
687
689{
691 return 0;
692}
693
694
696{
698 return 0;
699}
700
701
703{
705 {
706 getEditFrame<FOOTPRINT_EDIT_FRAME>()->OnEditItemRequest( footprint );
708 }
709
710 return 0;
711}
712
713
715{
716 getEditFrame<FOOTPRINT_EDIT_FRAME>()->ShowPadPropertiesDialog( nullptr );
717 return 0;
718}
719
720
722{
723 FOOTPRINT_EDIT_FRAME* editFrame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
724 DIALOG_CLEANUP_GRAPHICS dlg( editFrame, true );
725
726 dlg.ShowModal();
727 return 0;
728}
729
730
732{
733 if( !m_checkerDialog )
734 {
736 m_checkerDialog->Show( true );
737 }
738 else // The dialog is just not visible (because the user has double clicked on an error item)
739 {
740 m_checkerDialog->Show( true );
741 }
742
743 return 0;
744}
745
746
748{
749 if( !m_checkerDialog )
751
752 if( !m_checkerDialog->IsShownOnScreen() )
753 m_checkerDialog->Show( true );
754
755 m_checkerDialog->SelectMarker( aMarker );
756}
757
758
760{
761 if( m_checkerDialog )
762 {
763 m_checkerDialog->Destroy();
764 m_checkerDialog = nullptr;
765 }
766}
767
768
770{
771 FOOTPRINT* footprint = board()->Footprints().front();
772 int errors = 0;
773 wxString details;
774
775 // Repair duplicate IDs and missing nets.
776 std::set<KIID> ids;
777 int duplicates = 0;
778
779 auto processItem =
780 [&]( EDA_ITEM* aItem )
781 {
782 if( ids.count( aItem->m_Uuid ) )
783 {
784 duplicates++;
785 const_cast<KIID&>( aItem->m_Uuid ) = KIID();
786 }
787
788 ids.insert( aItem->m_Uuid );
789 };
790
791 // Footprint IDs are the most important, so give them the first crack at "claiming" a
792 // particular KIID.
793
794 processItem( footprint );
795
796 // After that the principal use is for DRC marker pointers, which are most likely to pads.
797
798 for( PAD* pad : footprint->Pads() )
799 processItem( pad );
800
801 // From here out I don't think order matters much.
802
803 processItem( &footprint->Reference() );
804 processItem( &footprint->Value() );
805
806 for( BOARD_ITEM* item : footprint->GraphicalItems() )
807 processItem( item );
808
809 for( ZONE* zone : footprint->Zones() )
810 processItem( zone );
811
812 for( PCB_GROUP* group : footprint->Groups() )
813 processItem( group );
814
815 if( duplicates )
816 {
817 errors += duplicates;
818 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
819 }
820
821 if( errors )
822 {
823 m_frame->OnModify();
824
825 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
826 DisplayInfoMessage( m_frame, msg, details );
827 }
828 else
829 {
830 DisplayInfoMessage( m_frame, _( "No footprint problems found." ) );
831 }
832
833 return 0;
834}
835
836
838{
847
852
855
858
861
864
869}
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 save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:126
static TOOL_ACTION showProperties
Definition: actions.h:206
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:827
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:447
const FOOTPRINTS & Footprints() const
Definition: board.h:330
void SelectMarker(const PCB_MARKER *aMarker)
bool Show(bool show) override
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
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 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 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)
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 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:2343
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:238
ZONES & Zones()
Definition: footprint.h:201
PCB_FIELD & Value()
read/write accessors:
Definition: footprint.h:627
PADS & Pads()
Definition: footprint.h:195
const LIB_ID & GetFPID() const
Definition: footprint.h:237
void SetValue(const wxString &aValue)
Definition: footprint.h:618
PCB_FIELD & Reference()
Definition: footprint.h:628
GROUPS & Groups()
Definition: footprint.h:204
const wxString & GetValue() const
Definition: footprint.h:613
DRAWINGS & GraphicalItems()
Definition: footprint.h:198
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.
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:75
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:459
static TOOL_ACTION renameFootprint
Definition: pcb_actions.h:458
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:442
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:454
static TOOL_ACTION editFootprint
Definition: pcb_actions.h:456
static TOOL_ACTION exportFootprint
Definition: pcb_actions.h:464
static TOOL_ACTION editTextAndGraphics
Definition: pcb_actions.h:412
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:451
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:467
static TOOL_ACTION importFootprint
Definition: pcb_actions.h:463
static TOOL_ACTION pasteFootprint
Definition: pcb_actions.h:462
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:466
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:469
static TOOL_ACTION duplicateFootprint
Definition: pcb_actions.h:457
static TOOL_ACTION cutFootprint
Definition: pcb_actions.h:460
static TOOL_ACTION repairFootprint
Definition: pcb_actions.h:538
static TOOL_ACTION copyFootprint
Definition: pcb_actions.h:461
static TOOL_ACTION cleanupGraphics
Definition: pcb_actions.h:416
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
KIGFX::PCB_VIEW * view() const
PCB_BASE_EDIT_FRAME * frame() const
BOARD * board() const
PCB_DRAW_PANEL_GAL * canvas() const
FOOTPRINT * footprint() const
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:678
virtual const wxString & GetTextEditor(bool aCanShowFileChooser=true)
Return the path to the preferred text editor application.
Definition: pgm_base.cpp:195
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
Definition: project_pcb.cpp:37
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).
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
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
bool empty() const
Definition: utf8.h:104
A modified version of the wxInfoBar class that allows us to:
Definition: wx_infobar.h:75
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 DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
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
This file is part of the common library.
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: cvpcb.cpp:150
#define _(s)
@ FRAME_FOOTPRINT_WIZARD
Definition: frame_type.h:46
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
Definition: gestfich.cpp:139
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:1059
see class PGM_BASE
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:673
VECTOR2< double > VECTOR2D
Definition: vector2d.h:672
Definition of file extensions used in Kicad.