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>
28#include <wx/generic/textdlgg.h>
29#include <string_utils.h>
30#include <pgm_base.h>
31#include <tool/tool_manager.h>
32#include <tools/pcb_actions.h>
34#include <pcbnew_id.h>
35#include <confirm.h>
36#include <kidialog.h>
37#include <gestfich.h> // To open with a text editor
38#include <widgets/wx_infobar.h>
39#include <footprint.h>
40#include <pad.h>
41#include <pcb_group.h>
42#include <zone.h>
43#include <fp_lib_table.h>
47#include <kiway.h>
48#include <drc/drc_item.h>
49#include <project_pcb.h>
50#include <view/view_controls.h>
51
52#include <memory>
53
54
56 PCB_TOOL_BASE( "pcbnew.ModuleEditor" ),
57 m_frame( nullptr ),
58 m_checkerDialog( nullptr )
59{
60}
61
62
64{
65}
66
67
69{
70 m_frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
71
72 if( m_checkerDialog )
74}
75
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 {
86 LIB_ID sel = m_frame->GetTreeFPID();
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 {
96 LIB_ID sel = m_frame->GetTreeFPID();
97 return !sel.GetLibNickname().empty();
98 };
99 auto pinnedLibSelectedCondition =
100 [ this ]( const SELECTION& aSel )
101 {
103 return current && current->m_Type == LIB_TREE_NODE::LIBRARY && current->m_Pinned;
104 };
105 auto unpinnedLibSelectedCondition =
106 [ this ](const SELECTION& aSel )
107 {
109 return current && current->m_Type == LIB_TREE_NODE::LIBRARY && !current->m_Pinned;
110 };
111 auto fpSelectedCondition =
112 [ this ]( const SELECTION& aSel )
113 {
114 LIB_ID sel = m_frame->GetTreeFPID();
115 return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
116 };
117
118 auto fpExportCondition =
119 [ this ]( const SELECTION& aSel )
120 {
122 return fp != nullptr;
123 };
124
125 auto canOpenWithTextEditor =
126 [ this ]( const SELECTION& aSel )
127 {
128 // The option is shown if the editor has no current edits,
129 // dumb/simple guard against opening a new file that does not exist on disk
130 bool ret = !m_frame->IsContentModified();
131 return ret;
132 };
133
134 ctxMenu.AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition );
135 ctxMenu.AddItem( ACTIONS::unpinLibrary, pinnedLibSelectedCondition );
136
137 ctxMenu.AddSeparator();
138 ctxMenu.AddItem( PCB_ACTIONS::newFootprint, libSelectedCondition );
139 ctxMenu.AddItem( PCB_ACTIONS::createFootprint, libSelectedCondition );
140
141 ctxMenu.AddSeparator();
143 ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition || fpSelectedCondition );
144 ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition || libInferredCondition );
145
146 ctxMenu.AddSeparator();
147 ctxMenu.AddItem( PCB_ACTIONS::cutFootprint, fpSelectedCondition );
148 ctxMenu.AddItem( PCB_ACTIONS::copyFootprint, fpSelectedCondition );
149 ctxMenu.AddItem( PCB_ACTIONS::pasteFootprint, libInferredCondition );
150 ctxMenu.AddItem( PCB_ACTIONS::duplicateFootprint, fpSelectedCondition );
151 ctxMenu.AddItem( PCB_ACTIONS::renameFootprint, fpSelectedCondition );
152 ctxMenu.AddItem( PCB_ACTIONS::deleteFootprint, fpSelectedCondition );
153
154 ctxMenu.AddSeparator();
155 ctxMenu.AddItem( PCB_ACTIONS::importFootprint, libInferredCondition );
156 ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpExportCondition );
157
158 // If we've got nothing else to show, at least show a hide tree option
159 ctxMenu.AddItem( PCB_ACTIONS::hideFootprintTree, !libInferredCondition );
160
162 {
163 ctxMenu.AddSeparator();
165 canOpenWithTextEditor && fpSelectedCondition );
166 }
167
168 return true;
169}
170
171
173{
174 LIB_ID selected = m_frame->GetTreeFPID();
175 wxString libraryName = selected.GetUniStringLibNickname();
176 FOOTPRINT* newFootprint = m_frame->CreateNewFootprint( wxEmptyString, libraryName, false );
177
178 if( !newFootprint )
179 return 0;
180
181 if( !m_frame->Clear_Pcb( true ) )
182 return 0;
183
185 m_frame->AddFootprintToBoard( newFootprint );
186
187 // Initialize data relative to nets and netclasses (for a new footprint the defaults are
188 // used). This is mandatory to handle and draw pads.
190 newFootprint->SetPosition( VECTOR2I( 0, 0 ) );
191 newFootprint->ClearFlags();
192
193 m_frame->Zoom_Automatique( false );
195
196 // If selected from the library tree then go ahead and save it there
197 if( !selected.GetLibNickname().empty() )
198 {
199 LIB_ID fpid = newFootprint->GetFPID();
200 fpid.SetLibNickname( selected.GetLibNickname() );
201 newFootprint->SetFPID( fpid );
202 m_frame->SaveFootprint( newFootprint );
204 }
205
207 m_frame->Update3DView( true, true );
208
209 m_frame->SyncLibraryTree( false );
210 return 0;
211}
212
213
215{
216 LIB_ID selected = m_frame->GetTreeFPID();
217
219 {
220 if( !HandleUnsavedChanges( m_frame, _( "The current footprint has been modified. "
221 "Save changes?" ),
222 [&]() -> bool
223 {
224 return m_frame->SaveFootprint( footprint() );
225 } ) )
226 {
227 return 0;
228 }
229 }
230
232 {
233 FOOTPRINT_WIZARD_FRAME* wizard = static_cast<FOOTPRINT_WIZARD_FRAME*>( frame );
234
235 if( wizard->ShowModal( nullptr, m_frame ) )
236 {
237 // Creates the new footprint from python script wizard
238 FOOTPRINT* newFootprint = wizard->GetBuiltFootprint();
239
240 if( newFootprint ) // i.e. if create footprint command is OK
241 {
242 m_frame->Clear_Pcb( false );
243
245 // Add the new object to board
246 m_frame->AddFootprintToBoard( newFootprint );
247
248 // Initialize data relative to nets and netclasses (for a new footprint the
249 // defaults are used). This is mandatory to handle and draw pads.
251 newFootprint->SetPosition( VECTOR2I( 0, 0 ) );
252 newFootprint->ClearFlags();
253
254 m_frame->Zoom_Automatique( false );
256 m_frame->OnModify();
257
258 // If selected from the library tree then go ahead and save it there
259 if( !selected.GetLibNickname().empty() )
260 {
261 LIB_ID fpid = newFootprint->GetFPID();
262 fpid.SetLibNickname( selected.GetLibNickname() );
263 newFootprint->SetFPID( fpid );
264 m_frame->SaveFootprint( newFootprint );
266 }
267
269 canvas()->Refresh();
270 m_frame->Update3DView( true, true );
271
272 m_frame->SyncLibraryTree( false );
273 }
274 }
275
276 wizard->Destroy();
277 }
278
279 return 0;
280}
281
282
284{
285 if( !footprint() ) // no loaded footprint
286 return 0;
287
289 {
291 {
292 view()->Update( footprint() );
293
294 canvas()->ForceRefresh();
297 }
298 }
299
301 return 0;
302}
303
304
306{
308 {
309 // Save Library As
310 const wxString& src_libNickname = m_frame->GetTargetFPID().GetLibNickname();
311 wxString src_libFullName = PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->GetFullURI( src_libNickname );
312
313 if( m_frame->SaveLibraryAs( src_libFullName ) )
314 m_frame->SyncLibraryTree( true );
315 }
316 else if( m_frame->GetTargetFPID() == m_frame->GetLoadedFPID() )
317 {
318 // Save Footprint As
320 {
321 view()->Update( footprint() );
323
324 // Get rid of the save-will-update-board-only (or any other dismissable warning)
325 WX_INFOBAR* infobar = m_frame->GetInfoBar();
326
327 if( infobar->IsShownOnScreen() && infobar->HasCloseButton() )
328 infobar->Dismiss();
329
330 canvas()->ForceRefresh();
331 m_frame->SyncLibraryTree( true );
332 }
333 }
334 else
335 {
336 // Save Selected Footprint As
338
340 {
341 m_frame->SyncLibraryTree( true );
343 }
344 }
345
347 return 0;
348}
349
350
352{
353 getEditFrame<FOOTPRINT_EDIT_FRAME>()->RevertFootprint();
354 return 0;
355}
356
357
359{
360 LIB_ID fpID = m_frame->GetTreeFPID();
361
362 if( fpID == m_frame->GetLoadedFPID() )
363 {
364 m_copiedFootprint = std::make_unique<FOOTPRINT>( *m_frame->GetBoard()->GetFirstFootprint() );
365 m_copiedFootprint->SetParent( nullptr );
366 }
367 else
368 {
369 m_copiedFootprint.reset( m_frame->LoadFootprint( fpID ) );
370 }
371
372 if( aEvent.IsAction( &PCB_ACTIONS::cutFootprint ) )
373 DeleteFootprint( aEvent );
374
375 return 0;
376}
377
378
380{
382 {
383 wxString newLib = m_frame->GetTreeFPID().GetLibNickname();
384 wxString newName = m_copiedFootprint->GetFPID().GetLibItemName();
385
386 while( PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->FootprintExists( newLib, newName ) )
387 newName += _( "_copy" );
388
389 m_copiedFootprint->SetFPID( LIB_ID( newLib, newName ) );
391
392 m_frame->SyncLibraryTree( true );
396 }
397
398 return 0;
399}
400
401
403{
404 LIB_ID fpID = m_frame->GetTreeFPID();
406
407 if( fpID == m_frame->GetLoadedFPID() )
409 else
411
413 {
414 m_frame->SyncLibraryTree( true );
418 }
419
420 return 0;
421}
422
423
424class RENAME_DIALOG : public wxTextEntryDialog
425{
426public:
427 RENAME_DIALOG( wxWindow* aParent, const wxString& aName,
428 std::function<bool( wxString newName )> aValidator ) :
429 wxTextEntryDialog( aParent, _( "New name:" ), _( "Change Footprint Name" ), aName ),
430 m_validator( std::move( aValidator ) )
431 { }
432
433 wxString GetFPName()
434 {
435 wxString name = m_textctrl->GetValue();
436 name.Trim( true ).Trim( false );
437 return name;
438 }
439
440protected:
442 {
443 return m_validator( GetFPName() );
444 }
445
446private:
447 std::function<bool( wxString newName )> m_validator;
448};
449
450
452{
454 LIB_ID fpID = m_frame->GetTreeFPID();
455 wxString libraryName = fpID.GetLibNickname();
456 wxString oldName = fpID.GetLibItemName();
457 wxString msg;
458
459 RENAME_DIALOG dlg( m_frame, oldName,
460 [&]( wxString newName )
461 {
462 if( newName.IsEmpty() )
463 {
464 wxMessageBox( _( "Footprint must have a name." ) );
465 return false;
466 }
467
468 if( tbl->FootprintExists( libraryName, newName ) )
469 {
470 msg = wxString::Format( _( "Footprint '%s' already exists in library '%s'." ),
471 newName, libraryName );
472
473 KIDIALOG errorDlg( m_frame, msg, _( "Confirmation" ),
474 wxOK | wxCANCEL | wxICON_WARNING );
475 errorDlg.SetOKLabel( _( "Overwrite" ) );
476
477 return errorDlg.ShowModal() == wxID_OK;
478 }
479
480 return true;
481 } );
482
483 if( dlg.ShowModal() != wxID_OK )
484 return 0; // canceled by user
485
486 wxString newName = dlg.GetFPName();
487 FOOTPRINT* footprint = nullptr;
488
489 if( fpID == m_frame->GetLoadedFPID() )
490 {
492
493 if( footprint )
494 {
495 footprint->SetFPID( LIB_ID( libraryName, newName ) );
496
497 if( footprint->GetValue() == oldName )
498 footprint->SetValue( newName );
499
500 m_frame->OnModify();
502 }
503 }
504 else
505 {
507
508 if( footprint )
509 {
510 try
511 {
512 footprint->SetFPID( LIB_ID( libraryName, newName ) );
513
514 if( footprint->GetValue() == oldName )
515 footprint->SetValue( newName );
516
518
519 PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->FootprintDelete( libraryName, oldName );
520 }
521 catch( const IO_ERROR& ioe )
522 {
523 DisplayError( m_frame, ioe.What() );
524 }
525 catch( ... )
526 {
527 // Best efforts...
528 }
529 }
530 }
531
532 wxDataViewItem treeItem = m_frame->GetLibTreeAdapter()->FindItem( fpID );
533 m_frame->UpdateLibraryTree( treeItem, footprint );
534 m_frame->FocusOnLibID( LIB_ID( libraryName, newName ) );
535
536 return 0;
537}
538
539
541{
542 FOOTPRINT_EDIT_FRAME* frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
543
544 if( frame->DeleteFootprintFromLibrary( frame->GetTargetFPID(), true ) )
545 {
546 if( frame->GetTargetFPID() == frame->GetLoadedFPID() )
547 frame->Clear_Pcb( false );
548
549 frame->SyncLibraryTree( true );
550 }
551
552 return 0;
553}
554
555
557{
558 bool is_last_fp_from_brd = m_frame->IsCurrentFPFromBoard();
559
560 if( !m_frame->Clear_Pcb( true ) )
561 return -1; // this command is aborted
562
565
568
570
571 // Update the save items if needed.
572 if( is_last_fp_from_brd )
573 {
576 }
577
579 m_frame->OnModify();
580 return 0;
581}
582
583
585{
588
589 return 0;
590}
591
592
594{
595 wxString fullEditorName = Pgm().GetTextEditor();
596
597 if( fullEditorName.IsEmpty() )
598 {
599 wxMessageBox( _( "No text editor selected in KiCad. Please choose one." ) );
600 return 0;
601 }
602
603 FP_LIB_TABLE* globalTable = dynamic_cast<FP_LIB_TABLE*>( &GFootprintTable );
605 LIB_ID libId = m_frame->GetTreeFPID();
606
607 const char* libName = libId.GetLibNickname().c_str();
608 wxString libItemName = wxEmptyString;
609
610 for( FP_LIB_TABLE* table : { globalTable, projectTable } )
611 {
612 if( !table )
613 break;
614
615 libItemName = table->FindRow( libName, true )->GetFullURI( true ).c_str();
616
617 libItemName = libItemName + "/" + libId.GetLibItemName() + ".kicad_mod";
618
619 }
620
621 if( !libItemName.IsEmpty() )
622 {
623 ExecuteFile( fullEditorName, libItemName.wc_str(), nullptr, false );
624 }
625
626 return 0;
627}
628
629
631{
633 return 0;
634}
635
636
638{
639 LIB_TREE_NODE* currentNode = m_frame->GetCurrentTreeNode();
640
641 if( currentNode && !currentNode->m_Pinned )
642 {
643 m_frame->Prj().PinLibrary( currentNode->m_LibId.GetLibNickname(), false );
644
645 currentNode->m_Pinned = true;
647 }
648
649 return 0;
650}
651
652
654{
655 LIB_TREE_NODE* currentNode = m_frame->GetCurrentTreeNode();
656
657 if( currentNode && currentNode->m_Pinned )
658 {
659 m_frame->Prj().UnpinLibrary( currentNode->m_LibId.GetLibNickname(), false );
660
661 currentNode->m_Pinned = false;
663 }
664
665 return 0;
666}
667
668
670{
672 return 0;
673}
674
675
677{
678 if (!m_frame->IsSearchTreeShown()) {
680 }
682 return 0;
683}
684
685
687{
689 return 0;
690}
691
692
694{
696 return 0;
697}
698
699
701{
703 {
704 getEditFrame<FOOTPRINT_EDIT_FRAME>()->OnEditItemRequest( footprint );
706 }
707
708 return 0;
709}
710
711
713{
714 getEditFrame<FOOTPRINT_EDIT_FRAME>()->ShowPadPropertiesDialog( nullptr );
715 return 0;
716}
717
718
720{
721 FOOTPRINT_EDIT_FRAME* editFrame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
722 DIALOG_CLEANUP_GRAPHICS dlg( editFrame, true );
723
724 dlg.ShowModal();
725 return 0;
726}
727
728
730{
731 if( !m_checkerDialog )
732 {
734 m_checkerDialog->Show( true );
735 }
736 else // The dialog is just not visible (because the user has double clicked on an error item)
737 {
738 m_checkerDialog->Show( true );
739 }
740
741 return 0;
742}
743
744
746{
747 if( !m_checkerDialog )
749
750 if( !m_checkerDialog->IsShownOnScreen() )
751 m_checkerDialog->Show( true );
752
753 m_checkerDialog->SelectMarker( aMarker );
754}
755
756
758{
759 if( m_checkerDialog )
760 {
761 m_checkerDialog->Destroy();
762 m_checkerDialog = nullptr;
763 }
764}
765
766
768{
769 FOOTPRINT* footprint = board()->Footprints().front();
770 int errors = 0;
771 wxString details;
772
773 // Repair duplicate IDs and missing nets.
774 std::set<KIID> ids;
775 int duplicates = 0;
776
777 auto processItem =
778 [&]( EDA_ITEM* aItem )
779 {
780 if( ids.count( aItem->m_Uuid ) )
781 {
782 duplicates++;
783 const_cast<KIID&>( aItem->m_Uuid ) = KIID();
784 }
785
786 ids.insert( aItem->m_Uuid );
787 };
788
789 // Footprint IDs are the most important, so give them the first crack at "claiming" a
790 // particular KIID.
791
792 processItem( footprint );
793
794 // After that the principal use is for DRC marker pointers, which are most likely to pads.
795
796 for( PAD* pad : footprint->Pads() )
797 processItem( pad );
798
799 // From here out I don't think order matters much.
800
801 processItem( &footprint->Reference() );
802 processItem( &footprint->Value() );
803
804 for( BOARD_ITEM* item : footprint->GraphicalItems() )
805 processItem( item );
806
807 for( ZONE* zone : footprint->Zones() )
808 processItem( zone );
809
810 for( PCB_GROUP* group : footprint->Groups() )
811 processItem( group );
812
813 if( duplicates )
814 {
815 errors += duplicates;
816 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
817 }
818
819 /*******************************
820 * Your test here
821 */
822
823 /*******************************
824 * Inform the user
825 */
826
827 if( errors )
828 {
829 m_frame->OnModify();
830
831 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
832 DisplayInfoMessage( m_frame, msg, details );
833 }
834 else
835 {
836 DisplayInfoMessage( m_frame, _( "No footprint problems found." ) );
837 }
838
839 return 0;
840}
841
842
844{
853
858
862
865
868
878}
const char * name
Definition: DXF_plotter.cpp:57
static TOOL_ACTION revert
Definition: actions.h:55
static TOOL_ACTION saveAs
Definition: actions.h:52
static TOOL_ACTION pinLibrary
Definition: actions.h:140
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:124
static TOOL_ACTION unpinLibrary
Definition: actions.h:141
static TOOL_ACTION showProperties
Definition: actions.h:201
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:77
void BuildListOfNets()
Definition: board.h:816
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:433
const FOOTPRINTS & Footprints() const
Definition: board.h:323
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
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:88
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:128
int Revert(const TOOL_EVENT &aEvent)
int OpenWithTextEditor(const TOOL_EVENT &aEvent)
int PinLibrary(const TOOL_EVENT &aEvent)
int PasteFootprint(const TOOL_EVENT &aEvent)
DIALOG_FOOTPRINT_CHECKER * m_checkerDialog
int ToggleFootprintTree(const TOOL_EVENT &aEvent)
int CutCopyFootprint(const TOOL_EVENT &aEvent)
int EditFootprint(const TOOL_EVENT &aEvent)
int ToggleProperties(const TOOL_EVENT &aEvent)
int Save(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 UnpinLibrary(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
int FootprintTreeSearch(const TOOL_EVENT &aEvent)
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)
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.
LIB_TREE_NODE * GetCurrentTreeNode() const
bool SaveFootprint(FOOTPRINT *aFootprint)
Save in an existing library a given footprint.
LIB_ID GetTreeFPID() const
Return the LIB_ID of the part or library selected in the footprint tree.
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:103
void RegenerateLibraryTree()
Filter, sort, and redisplay the library tree.
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:2315
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:234
ZONES & Zones()
Definition: footprint.h:197
PCB_FIELD & Value()
read/write accessors:
Definition: footprint.h:623
PADS & Pads()
Definition: footprint.h:191
const LIB_ID & GetFPID() const
Definition: footprint.h:233
void SetValue(const wxString &aValue)
Definition: footprint.h:614
PCB_FIELD & Reference()
Definition: footprint.h:624
GROUPS & Groups()
Definition: footprint.h:200
const wxString & GetValue() const
Definition: footprint.h:609
DRAWINGS & GraphicalItems()
Definition: footprint.h:194
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
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.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
enum TYPE m_Type
Definition: pad.h:53
static TOOL_ACTION deleteFootprint
Definition: pcb_actions.h:463
static TOOL_ACTION renameFootprint
Definition: pcb_actions.h:462
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:442
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:458
static TOOL_ACTION hideFootprintTree
Definition: pcb_actions.h:450
static TOOL_ACTION editFootprint
Definition: pcb_actions.h:460
static TOOL_ACTION exportFootprint
Definition: pcb_actions.h:468
static TOOL_ACTION showFootprintTree
Definition: pcb_actions.h:449
static TOOL_ACTION editTextAndGraphics
Definition: pcb_actions.h:412
static TOOL_ACTION footprintTreeSearch
Definition: pcb_actions.h:451
static TOOL_ACTION openWithTextEditor
Definition: pcb_actions.h:469
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:455
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:472
static TOOL_ACTION importFootprint
Definition: pcb_actions.h:467
static TOOL_ACTION pasteFootprint
Definition: pcb_actions.h:466
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:471
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:474
static TOOL_ACTION duplicateFootprint
Definition: pcb_actions.h:461
static TOOL_ACTION cutFootprint
Definition: pcb_actions.h:464
static TOOL_ACTION repairFootprint
Definition: pcb_actions.h:543
static TOOL_ACTION copyFootprint
Definition: pcb_actions.h:465
static TOOL_ACTION cleanupGraphics
Definition: pcb_actions.h:416
void ToggleProperties() override
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
FOOTPRINT * CreateNewFootprint(const wxString &aFootprintName, const wxString &aLibName, bool aQuiet)
Creates a new footprint, at position 0,0.
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:51
KIGFX::PCB_VIEW * view() const
PCB_BASE_EDIT_FRAME * frame() const
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:195
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
Definition: project_pcb.cpp:37
void UnpinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
Definition: project.cpp:192
void PinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
Definition: project.cpp:171
std::function< bool(wxString newName)> m_validator
bool TransferDataFromWindow() override
RENAME_DIALOG(wxWindow *aParent, const wxString &aName, std::function< bool(wxString newName)> aValidator)
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:217
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
const char * c_str() const
Definition: utf8.h:103
A modified version of the wxInfoBar class that allows us to:
Definition: wx_infobar.h:75
bool HasCloseButton() const
Definition: wx_infobar.cpp:325
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: wx_infobar.cpp:187
Handle a list of polygons defining a copper zone.
Definition: zone.h:72
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:161
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:213
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:121
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_EnableLibWithText
Enable option to load lib files with text editor.
This file is part of the common library.
STL namespace.
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< double > VECTOR2D
Definition: vector2d.h:601
VECTOR2< int > VECTOR2I
Definition: vector2d.h:602