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 <gestfich.h> // To open with a text editor
37#include <widgets/wx_infobar.h>
38#include <footprint.h>
39#include <pad.h>
40#include <pcb_group.h>
41#include <zone.h>
42#include <fp_lib_table.h>
46#include <kiway.h>
47#include <drc/drc_item.h>
48#include <project_pcb.h>
49
50#include <memory>
51
52
54 PCB_TOOL_BASE( "pcbnew.ModuleEditor" ),
55 m_frame( nullptr ),
56 m_checkerDialog( nullptr )
57{
58}
59
60
62{
63}
64
65
67{
68 m_frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
69
70 if( m_checkerDialog )
72}
73
74
76{
77 // Build a context menu for the footprint tree
78 //
79 CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
80
81 auto libSelectedCondition =
82 [ this ]( const SELECTION& aSel )
83 {
84 LIB_ID sel = m_frame->GetTreeFPID();
85 return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty();
86 };
87
88 // The libInferredCondition allows you to do things like New Symbol and Paste with a
89 // symbol selected (in other words, when we know the library context even if the library
90 // itself isn't selected.
91 auto libInferredCondition =
92 [ this ]( const SELECTION& aSel )
93 {
94 LIB_ID sel = m_frame->GetTreeFPID();
95 return !sel.GetLibNickname().empty();
96 };
97 auto pinnedLibSelectedCondition =
98 [ this ]( const SELECTION& aSel )
99 {
101 return current && current->m_Type == LIB_TREE_NODE::LIBRARY && current->m_Pinned;
102 };
103 auto unpinnedLibSelectedCondition =
104 [ this ](const SELECTION& aSel )
105 {
107 return current && current->m_Type == LIB_TREE_NODE::LIBRARY && !current->m_Pinned;
108 };
109 auto fpSelectedCondition =
110 [ this ]( const SELECTION& aSel )
111 {
112 LIB_ID sel = m_frame->GetTreeFPID();
113 return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
114 };
115
116 auto fpExportCondition =
117 [ this ]( const SELECTION& aSel )
118 {
120 return fp != nullptr;
121 };
122
123 auto canOpenWithTextEditor =
124 [ this ]( const SELECTION& aSel )
125 {
126 // The option is shown if the editor has no current edits,
127 // dumb/simple guard against opening a new file that does not exist on disk
128 bool ret = !m_frame->IsContentModified();
129 return ret;
130 };
131
132 ctxMenu.AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition );
133 ctxMenu.AddItem( ACTIONS::unpinLibrary, pinnedLibSelectedCondition );
134
135 ctxMenu.AddSeparator();
136 ctxMenu.AddItem( PCB_ACTIONS::newFootprint, libSelectedCondition );
137 ctxMenu.AddItem( PCB_ACTIONS::createFootprint, libSelectedCondition );
138
139 ctxMenu.AddSeparator();
141 ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition || fpSelectedCondition );
142 ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition || libInferredCondition );
143
144 ctxMenu.AddSeparator();
145 ctxMenu.AddItem( PCB_ACTIONS::cutFootprint, fpSelectedCondition );
146 ctxMenu.AddItem( PCB_ACTIONS::copyFootprint, fpSelectedCondition );
147 ctxMenu.AddItem( PCB_ACTIONS::pasteFootprint, libInferredCondition );
148 ctxMenu.AddItem( PCB_ACTIONS::duplicateFootprint, fpSelectedCondition );
149 ctxMenu.AddItem( PCB_ACTIONS::renameFootprint, fpSelectedCondition );
150 ctxMenu.AddItem( PCB_ACTIONS::deleteFootprint, fpSelectedCondition );
151
152 ctxMenu.AddSeparator();
153 ctxMenu.AddItem( PCB_ACTIONS::importFootprint, libInferredCondition );
154 ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpExportCondition );
155
156 // If we've got nothing else to show, at least show a hide tree option
157 ctxMenu.AddItem( PCB_ACTIONS::hideFootprintTree, !libInferredCondition );
158
160 {
161 ctxMenu.AddSeparator();
163 canOpenWithTextEditor && fpSelectedCondition );
164 }
165
166 return true;
167}
168
169
171{
172 LIB_ID selected = m_frame->GetTreeFPID();
173 wxString libraryName = selected.GetUniStringLibNickname();
174 FOOTPRINT* newFootprint = m_frame->CreateNewFootprint( wxEmptyString, libraryName, false );
175
176 if( !newFootprint )
177 return 0;
178
179 if( !m_frame->Clear_Pcb( true ) )
180 return 0;
181
183 m_frame->AddFootprintToBoard( newFootprint );
184
185 // Initialize data relative to nets and netclasses (for a new footprint the defaults are
186 // used). This is mandatory to handle and draw pads.
188 newFootprint->SetPosition( VECTOR2I( 0, 0 ) );
189 newFootprint->ClearFlags();
190
191 m_frame->Zoom_Automatique( false );
193
194 // If selected from the library tree then go ahead and save it there
195 if( !selected.GetLibNickname().empty() )
196 {
197 LIB_ID fpid = newFootprint->GetFPID();
198 fpid.SetLibNickname( selected.GetLibNickname() );
199 newFootprint->SetFPID( fpid );
200 m_frame->SaveFootprint( newFootprint );
202 }
203
205 m_frame->Update3DView( true, true );
206
207 m_frame->SyncLibraryTree( false );
208 return 0;
209}
210
211
213{
214 LIB_ID selected = m_frame->GetTreeFPID();
215
217 {
218 if( !HandleUnsavedChanges( m_frame, _( "The current footprint has been modified. "
219 "Save changes?" ),
220 [&]() -> bool
221 {
222 return m_frame->SaveFootprint( footprint() );
223 } ) )
224 {
225 return 0;
226 }
227 }
228
230 true, m_frame );
231
232 if( wizard->ShowModal( nullptr, m_frame ) )
233 {
234 // Creates the new footprint from python script wizard
235 FOOTPRINT* newFootprint = wizard->GetBuiltFootprint();
236
237 if( newFootprint ) // i.e. if create footprint command is OK
238 {
239 m_frame->Clear_Pcb( false );
240
242 // Add the new object to board
243 m_frame->AddFootprintToBoard( newFootprint );
244
245 // Initialize data relative to nets and netclasses (for a new footprint the defaults
246 // are used). This is mandatory to handle and draw pads.
248 newFootprint->SetPosition( VECTOR2I( 0, 0 ) );
249 newFootprint->ClearFlags();
250
251 m_frame->Zoom_Automatique( false );
253 m_frame->OnModify();
254
255 // If selected from the library tree then go ahead and save it there
256 if( !selected.GetLibNickname().empty() )
257 {
258 LIB_ID fpid = newFootprint->GetFPID();
259 fpid.SetLibNickname( selected.GetLibNickname() );
260 newFootprint->SetFPID( fpid );
261 m_frame->SaveFootprint( newFootprint );
263 }
264
266 canvas()->Refresh();
267 m_frame->Update3DView( true, true );
268
269 m_frame->SyncLibraryTree( false );
270 }
271 }
272
273 wizard->Destroy();
274 return 0;
275}
276
277
279{
280 if( !footprint() ) // no loaded footprint
281 return 0;
282
284 {
286 {
287 view()->Update( footprint() );
288
289 canvas()->ForceRefresh();
292 }
293 }
294
296 return 0;
297}
298
299
301{
303 {
304 // Save Library As
305 const wxString& src_libNickname = m_frame->GetTargetFPID().GetLibNickname();
306 wxString src_libFullName = PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->GetFullURI( src_libNickname );
307
308 if( m_frame->SaveLibraryAs( src_libFullName ) )
309 m_frame->SyncLibraryTree( true );
310 }
311 else if( m_frame->GetTargetFPID() == m_frame->GetLoadedFPID() )
312 {
313 // Save Footprint As
315 {
316 view()->Update( footprint() );
318
319 // Get rid of the save-will-update-board-only (or any other dismissable warning)
320 WX_INFOBAR* infobar = m_frame->GetInfoBar();
321
322 if( infobar->IsShownOnScreen() && infobar->HasCloseButton() )
323 infobar->Dismiss();
324
325 canvas()->ForceRefresh();
326 m_frame->SyncLibraryTree( true );
327 }
328 }
329 else
330 {
331 // Save Selected Footprint As
333
335 {
336 m_frame->SyncLibraryTree( true );
338 }
339 }
340
342 return 0;
343}
344
345
347{
348 getEditFrame<FOOTPRINT_EDIT_FRAME>()->RevertFootprint();
349 return 0;
350}
351
352
354{
355 LIB_ID fpID = m_frame->GetTreeFPID();
356
357 if( fpID == m_frame->GetLoadedFPID() )
358 {
359 m_copiedFootprint = std::make_unique<FOOTPRINT>( *m_frame->GetBoard()->GetFirstFootprint() );
360 m_copiedFootprint->SetParent( nullptr );
361 }
362 else
363 {
364 m_copiedFootprint.reset( m_frame->LoadFootprint( fpID ) );
365 }
366
367 if( aEvent.IsAction( &PCB_ACTIONS::cutFootprint ) )
368 DeleteFootprint( aEvent );
369
370 return 0;
371}
372
373
375{
377 {
378 wxString newLib = m_frame->GetTreeFPID().GetLibNickname();
379 wxString newName = m_copiedFootprint->GetFPID().GetLibItemName();
380
381 while( PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->FootprintExists( newLib, newName ) )
382 newName += _( "_copy" );
383
384 m_copiedFootprint->SetFPID( LIB_ID( newLib, newName ) );
386
387 m_frame->SyncLibraryTree( true );
391 }
392
393 return 0;
394}
395
396
398{
399 LIB_ID fpID = m_frame->GetTreeFPID();
401
402 if( fpID == m_frame->GetLoadedFPID() )
404 else
406
408 {
409 m_frame->SyncLibraryTree( true );
413 }
414
415 return 0;
416}
417
418
419class RENAME_DIALOG : public wxTextEntryDialog
420{
421public:
422 RENAME_DIALOG( wxWindow* aParent, const wxString& aName,
423 std::function<bool( wxString newName )> aValidator ) :
424 wxTextEntryDialog( aParent, _( "New name:" ), _( "Change Footprint Name" ), aName ),
425 m_validator( std::move( aValidator ) )
426 { }
427
428 wxString GetFPName()
429 {
430 wxString name = m_textctrl->GetValue();
431 name.Trim( true ).Trim( false );
432 return name;
433 }
434
435protected:
437 {
438 return m_validator( GetFPName() );
439 }
440
441private:
442 std::function<bool( wxString newName )> m_validator;
443};
444
445
447{
449 LIB_ID fpID = m_frame->GetTreeFPID();
450 wxString libraryName = fpID.GetLibNickname();
451 wxString oldName = fpID.GetLibItemName();
452 wxString msg;
453
454 RENAME_DIALOG dlg( m_frame, oldName,
455 [&]( wxString newName )
456 {
457 if( newName.IsEmpty() )
458 {
459 wxMessageBox( _( "Footprint must have a name." ) );
460 return false;
461 }
462
463 if( tbl->FootprintExists( libraryName, newName ) )
464 {
465 msg = wxString::Format( _( "Footprint '%s' already exists in library '%s'." ),
466 newName, libraryName );
467
468 KIDIALOG errorDlg( m_frame, msg, _( "Confirmation" ),
469 wxOK | wxCANCEL | wxICON_WARNING );
470 errorDlg.SetOKLabel( _( "Overwrite" ) );
471
472 return errorDlg.ShowModal() == wxID_OK;
473 }
474
475 return true;
476 } );
477
478 if( dlg.ShowModal() != wxID_OK )
479 return 0; // canceled by user
480
481 wxString newName = dlg.GetFPName();
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 DisplayError( m_frame, 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
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 wxString fullEditorName = Pgm().GetTextEditor();
591
592 if( fullEditorName.IsEmpty() )
593 {
594 wxMessageBox( _( "No text editor selected in KiCad. Please choose one." ) );
595 return 0;
596 }
597
598 FP_LIB_TABLE* globalTable = dynamic_cast<FP_LIB_TABLE*>( &GFootprintTable );
600 LIB_ID libId = m_frame->GetTreeFPID();
601
602 const char* libName = libId.GetLibNickname().c_str();
603 wxString libItemName = wxEmptyString;
604
605 for( FP_LIB_TABLE* table : { globalTable, projectTable } )
606 {
607 if( !table )
608 break;
609
610 libItemName = table->FindRow( libName, true )->GetFullURI( true ).c_str();
611
612 libItemName = libItemName + "/" + libId.GetLibItemName() + ".kicad_mod";
613
614 }
615
616 if( !libItemName.IsEmpty() )
617 {
618 ExecuteFile( fullEditorName, libItemName.wc_str(), nullptr, false );
619 }
620
621 return 0;
622}
623
624
626{
628 return 0;
629}
630
631
633{
634 LIB_TREE_NODE* currentNode = m_frame->GetCurrentTreeNode();
635
636 if( currentNode && !currentNode->m_Pinned )
637 {
638 m_frame->Prj().PinLibrary( currentNode->m_LibId.GetLibNickname(), false );
639
640 currentNode->m_Pinned = true;
642 }
643
644 return 0;
645}
646
647
649{
650 LIB_TREE_NODE* currentNode = m_frame->GetCurrentTreeNode();
651
652 if( currentNode && currentNode->m_Pinned )
653 {
654 m_frame->Prj().UnpinLibrary( currentNode->m_LibId.GetLibNickname(), false );
655
656 currentNode->m_Pinned = false;
658 }
659
660 return 0;
661}
662
663
665{
667 return 0;
668}
669
670
672{
674 return 0;
675}
676
677
679{
681 return 0;
682}
683
684
686{
688 {
689 getEditFrame<FOOTPRINT_EDIT_FRAME>()->OnEditItemRequest( footprint );
691 }
692
693 return 0;
694}
695
696
698{
699 getEditFrame<FOOTPRINT_EDIT_FRAME>()->ShowPadPropertiesDialog( nullptr );
700 return 0;
701}
702
703
705{
706 FOOTPRINT_EDIT_FRAME* editFrame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
707 DIALOG_CLEANUP_GRAPHICS dlg( editFrame, true );
708
709 dlg.ShowModal();
710 return 0;
711}
712
713
715{
716 if( !m_checkerDialog )
717 {
719 m_checkerDialog->Show( true );
720 }
721 else // The dialog is just not visible (because the user has double clicked on an error item)
722 {
723 m_checkerDialog->Show( true );
724 }
725
726 return 0;
727}
728
729
731{
732 if( !m_checkerDialog )
734
735 if( !m_checkerDialog->IsShownOnScreen() )
736 m_checkerDialog->Show( true );
737
738 m_checkerDialog->SelectMarker( aMarker );
739}
740
741
743{
744 if( m_checkerDialog )
745 {
746 m_checkerDialog->Destroy();
747 m_checkerDialog = nullptr;
748 }
749}
750
751
753{
754 FOOTPRINT* footprint = board()->Footprints().front();
755 int errors = 0;
756 wxString details;
757
758 // Repair duplicate IDs and missing nets.
759 std::set<KIID> ids;
760 int duplicates = 0;
761
762 auto processItem =
763 [&]( EDA_ITEM* aItem )
764 {
765 if( ids.count( aItem->m_Uuid ) )
766 {
767 duplicates++;
768 const_cast<KIID&>( aItem->m_Uuid ) = KIID();
769 }
770
771 ids.insert( aItem->m_Uuid );
772 };
773
774 // Footprint IDs are the most important, so give them the first crack at "claiming" a
775 // particular KIID.
776
777 processItem( footprint );
778
779 // After that the principal use is for DRC marker pointers, which are most likely to pads.
780
781 for( PAD* pad : footprint->Pads() )
782 processItem( pad );
783
784 // From here out I don't think order matters much.
785
786 processItem( &footprint->Reference() );
787 processItem( &footprint->Value() );
788
789 for( BOARD_ITEM* item : footprint->GraphicalItems() )
790 processItem( item );
791
792 for( ZONE* zone : footprint->Zones() )
793 processItem( zone );
794
795 for( PCB_GROUP* group : footprint->Groups() )
796 processItem( group );
797
798 if( duplicates )
799 {
800 errors += duplicates;
801 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
802 }
803
804 /*******************************
805 * Your test here
806 */
807
808 /*******************************
809 * Inform the user
810 */
811
812 if( errors )
813 {
814 m_frame->OnModify();
815
816 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
817 DisplayInfoMessage( m_frame, msg, details );
818 }
819 else
820 {
821 DisplayInfoMessage( m_frame, _( "No footprint problems found." ) );
822 }
823
824 return 0;
825}
826
827
829{
838
843
847
850
853
862}
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:795
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:414
FOOTPRINTS & Footprints()
Definition: board.h:318
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:85
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:125
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
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:2056
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:231
ZONES & Zones()
Definition: footprint.h:194
PCB_FIELD & Value()
read/write accessors:
Definition: footprint.h:617
PADS & Pads()
Definition: footprint.h:188
const LIB_ID & GetFPID() const
Definition: footprint.h:230
void SetValue(const wxString &aValue)
Definition: footprint.h:608
PCB_FIELD & Reference()
Definition: footprint.h:618
GROUPS & Groups()
Definition: footprint.h:197
const wxString & GetValue() const
Definition: footprint.h:603
DRAWINGS & GraphicalItems()
Definition: footprint.h:191
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:53
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:432
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:59
static TOOL_ACTION deleteFootprint
Definition: pcb_actions.h:458
static TOOL_ACTION renameFootprint
Definition: pcb_actions.h:457
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:439
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:453
static TOOL_ACTION hideFootprintTree
Definition: pcb_actions.h:446
static TOOL_ACTION editFootprint
Definition: pcb_actions.h:455
static TOOL_ACTION exportFootprint
Definition: pcb_actions.h:463
static TOOL_ACTION showFootprintTree
Definition: pcb_actions.h:445
static TOOL_ACTION editTextAndGraphics
Definition: pcb_actions.h:408
static TOOL_ACTION openWithTextEditor
Definition: pcb_actions.h:464
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:450
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:467
static TOOL_ACTION importFootprint
Definition: pcb_actions.h:462
static TOOL_ACTION pasteFootprint
Definition: pcb_actions.h:461
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:456
static TOOL_ACTION cutFootprint
Definition: pcb_actions.h:459
static TOOL_ACTION repairFootprint
Definition: pcb_actions.h:538
static TOOL_ACTION copyFootprint
Definition: pcb_actions.h:460
static TOOL_ACTION cleanupGraphics
Definition: pcb_actions.h:412
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
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:216
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:145
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
bool empty() const
Definition: utf8.h:103
const char * c_str() const
Definition: utf8.h:102
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:280
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:332
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:240
This file is part of the common library.
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: cvpcb.cpp:169
#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.
STL namespace.
Class to handle a set of BOARD_ITEMs.
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:119
VECTOR2< double > VECTOR2D
Definition: vector2d.h:587
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588