27 using namespace std::placeholders;
81 bool is_last_fp_from_brd = IsCurrentFPFromBoard();
89 if( aFootprint ==
NULL )
94 aFootprint = SelectFootprintFromBoard( frame->
GetBoard() );
97 if( aFootprint ==
NULL )
106 if( !Clear_Pcb(
true ) )
109 m_boardFootprintUuids.clear();
111 auto recordAndUpdateUuid =
115 m_boardFootprintUuids[ newId ] = aItem->m_Uuid;
116 const_cast<KIID&>( aItem->m_Uuid ) = newId;
124 recordAndUpdateUuid( newFootprint );
132 recordAndUpdateUuid( aItem );
135 AddFootprintToBoard( newFootprint );
143 GetCanvas()->GetViewControls()->SetCrossHairCursorPosition(
VECTOR2D( 0, 0 ),
false );
144 PlaceFootprint( newFootprint );
156 Zoom_Automatique(
false );
158 m_adapter->SetPreselectNode( newFootprint->
GetFPID(), 0 );
161 GetScreen()->ClrModify();
164 if( !is_last_fp_from_brd )
169 if( IsSearchTreeShown() )
173 Update3DView(
true );
175 GetCanvas()->Refresh();
176 m_treePane->GetLibTree()->RefreshLibTree();
205 int ret = viewer->
ShowModal( &fpid,
this );
217 wxString footprintName;
221 static wxString lastComponentName;
225 _(
"Loading Footprint Libraries" ), 3 );
227 bool cancel = progressReporter->WasCancelled();
234 delete progressReporter;
245 std::vector<LIB_TREE_ITEM*> historyInfos;
252 if( fp_info !=
nullptr )
253 historyInfos.push_back( fp_info );
256 adapter->
DoAddLibrary(
"-- " +
_(
"Recently Used" ) +
" --", wxEmptyString, historyInfos,
true );
260 else if( historyInfos.size() )
266 title.Printf(
_(
"Choose Footprint (%d items loaded)" ), adapter->
GetItemCount() );
277 footprintName = SelectFootprintFromLibBrowser();
279 if( footprintName.IsEmpty() )
282 fpid.
Parse( footprintName );
291 footprintName = fpid.
Format();
296 footprint = loadFootprint( fpid );
304 lastComponentName = footprintName;
318 footprint = loadFootprint( aFootprintId );
332 wxCHECK_MSG( fptbl,
NULL, wxT(
"Cannot look up LIB_ID in NULL FP_LIB_TABLE." ) );
355 static wxString oldName;
359 wxArrayString listnames;
362 listnames.
Add( footprint->GetReference() );
364 msg.Printf(
_(
"Footprints [%u items]" ), (
unsigned) listnames.GetCount() );
366 wxArrayString headers;
368 headers.Add(
_(
"Footprint" ) );
370 std::vector<wxArrayString> itemsToDisplay;
373 for(
unsigned i = 0; i < listnames.GetCount(); i++ )
377 item.Add( listnames[i] );
378 itemsToDisplay.push_back( item );
381 EDA_LIST_DIALOG dlg(
this, msg, headers, itemsToDisplay, wxEmptyString );
383 if( dlg.ShowModal() == wxID_OK )
392 if( fpname == mod->GetReference() )
402 const wxString& curLibPath = aLibraryPath;
403 wxString dstLibPath = CreateNewLibrary( wxEmptyString, aLibraryPath );
419 wxArrayString footprints;
421 cur->FootprintEnumerate( footprints, curLibPath,
false );
423 for(
unsigned i = 0; i < footprints.size(); ++i )
425 const FOOTPRINT* footprint = cur->GetEnumeratedFootprint( curLibPath, footprints[i] );
426 dst->FootprintSave( dstLibPath, footprint );
429 SetStatusText( msg );
444 SetStatusText( wxEmptyString );
457 wxString footprintName;
458 wxArrayString fplist;
461 for(
auto fp :
GetBoard()->Footprints() )
462 fplist.
Add( fp->GetReference() + wxT(
" ( ") + fp->GetValue() + wxT(
" )") );
468 if( dlg.ShowModal() != wxID_OK )
472 footprintName.Trim(
true );
473 footprintName.Trim(
false );
475 if( !footprintName.IsEmpty() )
479 if( mod->GetReference().CmpNoCase( footprintName ) == 0 )
490 if( aFootprint == 0 )
495 if( aFootprint->
IsNew() )
516 aFootprint->
SetPosition((wxPoint) GetCanvas()->GetViewControls()->GetCursorPosition() );
522 if( aRecreateRatsnest )
523 m_pcb->GetConnectivity()->Update( aFootprint );
525 if( aRecreateRatsnest )
526 Compile_Ratsnest(
true );
528 SetMsgPanel( aFootprint );
void DoAddLibrary(wxString const &aNodeName, wxString const &aDesc, std::vector< LIB_TREE_ITEM * > const &aItemList, bool presorted)
Add the given list of components by alias.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
wxString SelectFootprintFromLibBrowser()
Launch the footprint viewer to select the name of a footprint to load.
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
FOOTPRINT * SelectFootprintFromLibTree(LIB_ID aPreselect=LIB_ID())
Open a dialog to select a footprint.
This file is part of the common library.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
A mix-in to provide polymorphism between items stored in libraries (symbols, aliases and footprints).
void SetPreselectNode(LIB_ID const &aLibId, int aUnit)
Set the component name to be selected if there are no search results.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
class PAD, a pad in a footprint
virtual void SetLocked(bool aLocked)
Modify the 'lock' status for of the item.
FOOTPRINT * FootprintLoadWithOptionalNickname(const LIB_ID &aFootprintId)
Load a footprint having aFootprintId with possibly an empty nickname.
A logical library item identifier and consists of various portions much like a URI.
bool IsValid() const
Check if this LID_ID is valid.
void SetLink(EDA_ITEM *aItem)
unsigned GetCount() const
static PCB_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath)
Return a plugin type given a footprint library's libPath.
virtual void SetParent(EDA_ITEM *aParent)
void PlaceFootprint(FOOTPRINT *aFootprint, bool aRecreateRatsnest=true)
Places aFootprint at the current cursor position and updates footprint coordinates with the new posit...
This file contains miscellaneous commonly used macros and functions.
Releases a PLUGIN in the context of a potential thrown exception through its destructor.
int GetItemCount() const
Return the number of components loaded in the tree.
#define PAD_PROPERTIES_DLG_NAME
DIALOG_PAD_PROPERTIES, derived from DIALOG_PAD_PROPERTIES_BASE, created by wxFormBuilder.
Multi-thread safe progress reporter dialog, intended for use of tasks that paralleize reporting back ...
FOOTPRINT * loadFootprint(const LIB_ID &aFootprintId)
Attempts to load aFootprintId from the footprint library table.
FOOTPRINT * GetFirstFootprint() const
Gets the first footprint on the board or nullptr.
VECTOR2< double > VECTOR2D
virtual const wxString What() const
A composite of Problem() and Where()
FOOTPRINTS & Footprints()
Helper dialog and control classes.
FOOTPRINT * LoadFootprint(const LIB_ID &aFootprintId)
Attempt to load aFootprintId from the footprint library table.
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(EDA_BASE_FRAME *aParent, LIB_TABLE *aLibs)
Factory function: create a model adapter in a reference-counting container.
A holder to handle information on schematic or board items.
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Information pertinent to a Pcbnew printed circuit board.
static PLUGIN * PluginFind(PCB_FILE_T aFileType)
Return a PLUGIN which the caller can use to import, export, save, or load design documents.
The main frame for Pcbnew.
PCBNEW_SETTINGS & Settings()
void ClearItemsList()
Delete only the list of pickers NOT the picked data itself.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
PCB_FILE_T
The set of file types that the IO_MGR knows about, and for which there has been a plugin written.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
FOOTPRINT * GetFootprintFromBoardByReference()
KICAD_T Type() const
Returns the type of object.