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
27#include <wx/generic/textdlgg.h>
28#include <string_utils.h>
29#include <pgm_base.h>
30#include <tool/tool_manager.h>
31#include <tools/pcb_actions.h>
33#include <pcbnew_id.h>
34#include <confirm.h>
35#include <widgets/wx_infobar.h>
36#include <footprint.h>
37#include <pad.h>
38#include <pcb_group.h>
39#include <zone.h>
40#include <fp_lib_table.h>
44#include <kiway.h>
45#include <drc/drc_item.h>
46#include <project_pcb.h>
47
48#include <memory>
49
50
52 PCB_TOOL_BASE( "pcbnew.ModuleEditor" ),
53 m_frame( nullptr ),
54 m_checkerDialog( nullptr )
55{
56}
57
58
60{
61}
62
63
65{
66 m_frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
67
68 if( m_checkerDialog )
70}
71
72
74{
75 // Build a context menu for the footprint tree
76 //
77 CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
78
79 auto libSelectedCondition =
80 [ this ]( const SELECTION& aSel )
81 {
82 LIB_ID sel = m_frame->GetTreeFPID();
83 return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty();
84 };
85
86 // The libInferredCondition allows you to do things like New Symbol and Paste with a
87 // symbol selected (in other words, when we know the library context even if the library
88 // itself isn't selected.
89 auto libInferredCondition =
90 [ this ]( const SELECTION& aSel )
91 {
92 LIB_ID sel = m_frame->GetTreeFPID();
93 return !sel.GetLibNickname().empty();
94 };
95 auto pinnedLibSelectedCondition =
96 [ this ]( const SELECTION& aSel )
97 {
99 return current && current->m_Type == LIB_TREE_NODE::LIBRARY && current->m_Pinned;
100 };
101 auto unpinnedLibSelectedCondition =
102 [ this ](const SELECTION& aSel )
103 {
105 return current && current->m_Type == LIB_TREE_NODE::LIBRARY && !current->m_Pinned;
106 };
107 auto fpSelectedCondition =
108 [ this ]( const SELECTION& aSel )
109 {
110 LIB_ID sel = m_frame->GetTreeFPID();
111 return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
112 };
113
114 auto fpExportCondition =
115 [ this ]( const SELECTION& aSel )
116 {
118 return fp != nullptr;
119 };
120
121 ctxMenu.AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition );
122 ctxMenu.AddItem( ACTIONS::unpinLibrary, pinnedLibSelectedCondition );
123
124 ctxMenu.AddSeparator();
125 ctxMenu.AddItem( PCB_ACTIONS::newFootprint, libSelectedCondition );
126 ctxMenu.AddItem( PCB_ACTIONS::createFootprint, libSelectedCondition );
127
128 ctxMenu.AddSeparator();
130 ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition || fpSelectedCondition );
131 ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition || libInferredCondition );
132
133 ctxMenu.AddSeparator();
134 ctxMenu.AddItem( PCB_ACTIONS::cutFootprint, fpSelectedCondition );
135 ctxMenu.AddItem( PCB_ACTIONS::copyFootprint, fpSelectedCondition );
136 ctxMenu.AddItem( PCB_ACTIONS::pasteFootprint, libInferredCondition );
137 ctxMenu.AddItem( PCB_ACTIONS::duplicateFootprint, fpSelectedCondition );
138 ctxMenu.AddItem( PCB_ACTIONS::renameFootprint, fpSelectedCondition );
139 ctxMenu.AddItem( PCB_ACTIONS::deleteFootprint, fpSelectedCondition );
140
141 ctxMenu.AddSeparator();
142 ctxMenu.AddItem( PCB_ACTIONS::importFootprint, libInferredCondition );
143 ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpExportCondition );
144
145 // If we've got nothing else to show, at least show a hide tree option
146 ctxMenu.AddItem( PCB_ACTIONS::hideFootprintTree, !libInferredCondition );
147
148 return true;
149}
150
151
153{
154 LIB_ID selected = m_frame->GetTreeFPID();
155 wxString libraryName = selected.GetUniStringLibNickname();
156 FOOTPRINT* newFootprint = m_frame->CreateNewFootprint( wxEmptyString, libraryName, false );
157
158 if( !newFootprint )
159 return 0;
160
161 if( !m_frame->Clear_Pcb( true ) )
162 return 0;
163
165 m_frame->AddFootprintToBoard( newFootprint );
166
167 // Initialize data relative to nets and netclasses (for a new footprint the defaults are
168 // used). This is mandatory to handle and draw pads.
170 newFootprint->SetPosition( VECTOR2I( 0, 0 ) );
171 newFootprint->ClearFlags();
172
173 m_frame->Zoom_Automatique( false );
175
176 // If selected from the library tree then go ahead and save it there
177 if( !selected.GetLibNickname().empty() )
178 {
179 LIB_ID fpid = newFootprint->GetFPID();
180 fpid.SetLibNickname( selected.GetLibNickname() );
181 newFootprint->SetFPID( fpid );
182 m_frame->SaveFootprint( newFootprint );
184 }
185
187 m_frame->Update3DView( true, true );
188
189 m_frame->SyncLibraryTree( false );
190 return 0;
191}
192
193
195{
196 LIB_ID selected = m_frame->GetTreeFPID();
197
199 {
200 if( !HandleUnsavedChanges( m_frame, _( "The current footprint has been modified. "
201 "Save changes?" ),
202 [&]() -> bool
203 {
204 return m_frame->SaveFootprint( footprint() );
205 } ) )
206 {
207 return 0;
208 }
209 }
210
212 true, m_frame );
213
214 if( wizard->ShowModal( nullptr, m_frame ) )
215 {
216 // Creates the new footprint from python script wizard
217 FOOTPRINT* newFootprint = wizard->GetBuiltFootprint();
218
219 if( newFootprint ) // i.e. if create footprint command is OK
220 {
221 m_frame->Clear_Pcb( false );
222
224 // Add the new object to board
225 m_frame->AddFootprintToBoard( newFootprint );
226
227 // Initialize data relative to nets and netclasses (for a new footprint the defaults
228 // are used). This is mandatory to handle and draw pads.
230 newFootprint->SetPosition( VECTOR2I( 0, 0 ) );
231 newFootprint->ClearFlags();
232
233 m_frame->Zoom_Automatique( false );
235 m_frame->OnModify();
236
237 // If selected from the library tree then go ahead and save it there
238 if( !selected.GetLibNickname().empty() )
239 {
240 LIB_ID fpid = newFootprint->GetFPID();
241 fpid.SetLibNickname( selected.GetLibNickname() );
242 newFootprint->SetFPID( fpid );
243 m_frame->SaveFootprint( newFootprint );
245 }
246
248 canvas()->Refresh();
249 m_frame->Update3DView( true, true );
250
251 m_frame->SyncLibraryTree( false );
252 }
253 }
254
255 wizard->Destroy();
256 return 0;
257}
258
259
261{
262 if( !footprint() ) // no loaded footprint
263 return 0;
264
266 {
268 {
269 view()->Update( footprint() );
270
271 canvas()->ForceRefresh();
274 }
275 }
276
278 return 0;
279}
280
281
283{
285 {
286 // Save Library As
287 const wxString& src_libNickname = m_frame->GetTargetFPID().GetLibNickname();
288 wxString src_libFullName = PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->GetFullURI( src_libNickname );
289
290 if( m_frame->SaveLibraryAs( src_libFullName ) )
291 m_frame->SyncLibraryTree( true );
292 }
293 else if( m_frame->GetTargetFPID() == m_frame->GetLoadedFPID() )
294 {
295 // Save Footprint As
297 {
298 view()->Update( footprint() );
300
301 // Get rid of the save-will-update-board-only (or any other dismissable warning)
302 WX_INFOBAR* infobar = m_frame->GetInfoBar();
303
304 if( infobar->IsShownOnScreen() && infobar->HasCloseButton() )
305 infobar->Dismiss();
306
307 canvas()->ForceRefresh();
308 m_frame->SyncLibraryTree( true );
309 }
310 }
311 else
312 {
313 // Save Selected Footprint As
315
317 {
318 m_frame->SyncLibraryTree( true );
320 }
321 }
322
324 return 0;
325}
326
327
329{
330 getEditFrame<FOOTPRINT_EDIT_FRAME>()->RevertFootprint();
331 return 0;
332}
333
334
336{
337 LIB_ID fpID = m_frame->GetTreeFPID();
338
339 if( fpID == m_frame->GetLoadedFPID() )
340 {
341 m_copiedFootprint = std::make_unique<FOOTPRINT>( *m_frame->GetBoard()->GetFirstFootprint() );
342 m_copiedFootprint->SetParent( nullptr );
343 }
344 else
345 {
346 m_copiedFootprint.reset( m_frame->LoadFootprint( fpID ) );
347 }
348
349 if( aEvent.IsAction( &PCB_ACTIONS::cutFootprint ) )
350 DeleteFootprint( aEvent );
351
352 return 0;
353}
354
355
357{
359 {
360 wxString newLib = m_frame->GetTreeFPID().GetLibNickname();
361 wxString newName = m_copiedFootprint->GetFPID().GetLibItemName();
362
363 while( PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->FootprintExists( newLib, newName ) )
364 newName += _( "_copy" );
365
366 m_copiedFootprint->SetFPID( LIB_ID( newLib, newName ) );
368
369 m_frame->SyncLibraryTree( true );
373 }
374
375 return 0;
376}
377
378
380{
381 LIB_ID fpID = m_frame->GetTreeFPID();
383
384 if( fpID == m_frame->GetLoadedFPID() )
386 else
388
390 {
391 m_frame->SyncLibraryTree( true );
395 }
396
397 return 0;
398}
399
400
401class RENAME_DIALOG : public wxTextEntryDialog
402{
403public:
404 RENAME_DIALOG( wxWindow* aParent, const wxString& aName,
405 std::function<bool( wxString newName )> aValidator ) :
406 wxTextEntryDialog( aParent, _( "New name:" ), _( "Change Footprint Name" ), aName ),
407 m_validator( std::move( aValidator ) )
408 { }
409
410 wxString GetFPName()
411 {
412 wxString name = m_textctrl->GetValue();
413 name.Trim( true ).Trim( false );
414 return name;
415 }
416
417protected:
419 {
420 return m_validator( GetFPName() );
421 }
422
423private:
424 std::function<bool( wxString newName )> m_validator;
425};
426
427
429{
431 LIB_ID fpID = m_frame->GetTreeFPID();
432 wxString libraryName = fpID.GetLibNickname();
433 wxString oldName = fpID.GetLibItemName();
434 wxString msg;
435
436 RENAME_DIALOG dlg( m_frame, oldName,
437 [&]( wxString newName )
438 {
439 if( newName.IsEmpty() )
440 {
441 wxMessageBox( _( "Footprint must have a name." ) );
442 return false;
443 }
444
445 if( tbl->FootprintExists( libraryName, newName ) )
446 {
447 msg = wxString::Format( _( "Footprint '%s' already exists in library '%s'." ),
448 newName, libraryName );
449
450 KIDIALOG errorDlg( m_frame, msg, _( "Confirmation" ),
451 wxOK | wxCANCEL | wxICON_WARNING );
452 errorDlg.SetOKLabel( _( "Overwrite" ) );
453
454 return errorDlg.ShowModal() == wxID_OK;
455 }
456
457 return true;
458 } );
459
460 if( dlg.ShowModal() != wxID_OK )
461 return 0; // canceled by user
462
463 wxString newName = dlg.GetFPName();
464 FOOTPRINT* footprint = nullptr;
465
466 if( fpID == m_frame->GetLoadedFPID() )
467 {
469
470 if( footprint )
471 {
472 footprint->SetFPID( LIB_ID( libraryName, newName ) );
473
474 if( footprint->GetValue() == oldName )
475 footprint->SetValue( newName );
476
477 m_frame->OnModify();
479 }
480 }
481 else
482 {
484
485 if( footprint )
486 {
487 try
488 {
489 footprint->SetFPID( LIB_ID( libraryName, newName ) );
490
491 if( footprint->GetValue() == oldName )
492 footprint->SetValue( newName );
493
495
496 PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->FootprintDelete( libraryName, oldName );
497 }
498 catch( const IO_ERROR& ioe )
499 {
500 DisplayError( m_frame, ioe.What() );
501 }
502 catch( ... )
503 {
504 // Best efforts...
505 }
506 }
507 }
508
509 wxDataViewItem treeItem = m_frame->GetLibTreeAdapter()->FindItem( fpID );
510 m_frame->UpdateLibraryTree( treeItem, footprint );
511 m_frame->FocusOnLibID( LIB_ID( libraryName, newName ) );
512
513 return 0;
514}
515
516
518{
519 FOOTPRINT_EDIT_FRAME* frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
520
521 if( frame->DeleteFootprintFromLibrary( frame->GetTargetFPID(), true ) )
522 {
523 if( frame->GetTargetFPID() == frame->GetLoadedFPID() )
524 frame->Clear_Pcb( false );
525
526 frame->SyncLibraryTree( true );
527 }
528
529 return 0;
530}
531
532
534{
535 bool is_last_fp_from_brd = m_frame->IsCurrentFPFromBoard();
536
537 if( !m_frame->Clear_Pcb( true ) )
538 return -1; // this command is aborted
539
542
545
547
548 // Update the save items if needed.
549 if( is_last_fp_from_brd )
550 {
553 }
554
556 m_frame->OnModify();
557 return 0;
558}
559
560
562{
565
566 return 0;
567}
568
569
571{
573 return 0;
574}
575
576
578{
579 LIB_TREE_NODE* currentNode = m_frame->GetCurrentTreeNode();
580
581 if( currentNode && !currentNode->m_Pinned )
582 {
583 m_frame->Prj().PinLibrary( currentNode->m_LibId.GetLibNickname(), false );
584
585 currentNode->m_Pinned = true;
587 }
588
589 return 0;
590}
591
592
594{
595 LIB_TREE_NODE* currentNode = m_frame->GetCurrentTreeNode();
596
597 if( currentNode && currentNode->m_Pinned )
598 {
599 m_frame->Prj().UnpinLibrary( currentNode->m_LibId.GetLibNickname(), false );
600
601 currentNode->m_Pinned = false;
603 }
604
605 return 0;
606}
607
608
610{
612 return 0;
613}
614
615
617{
619 return 0;
620}
621
622
624{
626 return 0;
627}
628
629
631{
633 {
634 getEditFrame<FOOTPRINT_EDIT_FRAME>()->OnEditItemRequest( footprint );
636 }
637
638 return 0;
639}
640
641
643{
644 getEditFrame<FOOTPRINT_EDIT_FRAME>()->ShowPadPropertiesDialog( nullptr );
645 return 0;
646}
647
648
650{
651 FOOTPRINT_EDIT_FRAME* editFrame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
652 DIALOG_CLEANUP_GRAPHICS dlg( editFrame, true );
653
654 dlg.ShowModal();
655 return 0;
656}
657
658
660{
661 if( !m_checkerDialog )
662 {
664 m_checkerDialog->Show( true );
665 }
666 else // The dialog is just not visible (because the user has double clicked on an error item)
667 {
668 m_checkerDialog->Show( true );
669 }
670
671 return 0;
672}
673
674
676{
677 if( !m_checkerDialog )
679
680 if( !m_checkerDialog->IsShownOnScreen() )
681 m_checkerDialog->Show( true );
682
683 m_checkerDialog->SelectMarker( aMarker );
684}
685
686
688{
689 if( m_checkerDialog )
690 {
691 m_checkerDialog->Destroy();
692 m_checkerDialog = nullptr;
693 }
694}
695
696
698{
699 FOOTPRINT* footprint = board()->Footprints().front();
700 int errors = 0;
701 wxString details;
702
703 // Repair duplicate IDs and missing nets.
704 std::set<KIID> ids;
705 int duplicates = 0;
706
707 auto processItem =
708 [&]( EDA_ITEM* aItem )
709 {
710 if( ids.count( aItem->m_Uuid ) )
711 {
712 duplicates++;
713 const_cast<KIID&>( aItem->m_Uuid ) = KIID();
714 }
715
716 ids.insert( aItem->m_Uuid );
717 };
718
719 // Footprint IDs are the most important, so give them the first crack at "claiming" a
720 // particular KIID.
721
722 processItem( footprint );
723
724 // After that the principal use is for DRC marker pointers, which are most likely to pads.
725
726 for( PAD* pad : footprint->Pads() )
727 processItem( pad );
728
729 // From here out I don't think order matters much.
730
731 processItem( &footprint->Reference() );
732 processItem( &footprint->Value() );
733
734 for( BOARD_ITEM* item : footprint->GraphicalItems() )
735 processItem( item );
736
737 for( ZONE* zone : footprint->Zones() )
738 processItem( zone );
739
740 for( PCB_GROUP* group : footprint->Groups() )
741 processItem( group );
742
743 if( duplicates )
744 {
745 errors += duplicates;
746 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
747 }
748
749 /*******************************
750 * Your test here
751 */
752
753 /*******************************
754 * Inform the user
755 */
756
757 if( errors )
758 {
759 m_frame->OnModify();
760
761 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
762 DisplayInfoMessage( m_frame, msg, details );
763 }
764 else
765 {
766 DisplayInfoMessage( m_frame, _( "No footprint problems found." ) );
767 }
768
769 return 0;
770}
771
772
774{
783
788
791
794
797
806}
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:116
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:100
static TOOL_ACTION unpinLibrary
Definition: actions.h:117
static TOOL_ACTION showProperties
Definition: actions.h:177
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:790
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 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:1997
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:592
PADS & Pads()
Definition: footprint.h:188
const LIB_ID & GetFPID() const
Definition: footprint.h:230
void SetValue(const wxString &aValue)
Definition: footprint.h:583
PCB_FIELD & Reference()
Definition: footprint.h:593
GROUPS & Groups()
Definition: footprint.h:197
const wxString & GetValue() const
Definition: footprint.h:578
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:77
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 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
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:460
static TOOL_ACTION renameFootprint
Definition: pcb_actions.h:459
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:437
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:450
static TOOL_ACTION hideFootprintTree
Definition: pcb_actions.h:443
static TOOL_ACTION editFootprint
Definition: pcb_actions.h:457
static TOOL_ACTION exportFootprint
Definition: pcb_actions.h:465
static TOOL_ACTION showFootprintTree
Definition: pcb_actions.h:442
static TOOL_ACTION editTextAndGraphics
Definition: pcb_actions.h:406
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:447
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:468
static TOOL_ACTION importFootprint
Definition: pcb_actions.h:464
static TOOL_ACTION pasteFootprint
Definition: pcb_actions.h:463
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:467
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:470
static TOOL_ACTION duplicateFootprint
Definition: pcb_actions.h:458
static TOOL_ACTION cutFootprint
Definition: pcb_actions.h:461
static TOOL_ACTION repairFootprint
Definition: pcb_actions.h:539
static TOOL_ACTION copyFootprint
Definition: pcb_actions.h:462
static TOOL_ACTION cleanupGraphics
Definition: pcb_actions.h:410
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:200
void PinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
Definition: project.cpp:179
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
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.
#define _(s)
@ FRAME_FOOTPRINT_WIZARD
Definition: frame_type.h:46
STL namespace.
Class to handle a set of BOARD_ITEMs.
see class PGM_BASE
VECTOR2< double > VECTOR2D
Definition: vector2d.h:587
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588