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