38#include <wx/filename.h>
63 m_checkerDialog( nullptr )
70 m_frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
85 auto libSelectedCondition =
95 auto libInferredCondition =
102 auto fpSelectedCondition =
109 auto fpExportCondition =
113 return fp !=
nullptr;
116 auto canOpenExternally =
129 ctxMenu.AddSeparator( 10 );
131 ctxMenu.AddItem(
ACTIONS::saveAs, libSelectedCondition || fpSelectedCondition, 10 );
132 ctxMenu.AddItem(
ACTIONS::revert, libSelectedCondition || libInferredCondition, 10 );
134 ctxMenu.AddSeparator( 10 );
142 ctxMenu.AddSeparator( 100 );
148 ctxMenu.AddSeparator( 200 );
154 ctxMenu.AddSeparator( 200 );
155 ctxMenu.AddItem(
ACTIONS::openDirectory, canOpenExternally && ( libSelectedCondition || fpSelectedCondition ), 200 );
166 const LIB_ID& aTargetLib )
186 _(
"The footprint could not be added to the selected library ('%s'). "
187 "This library is read-only." ),
371 getEditFrame<FOOTPRINT_EDIT_FRAME>()->RevertFootprint();
405 newName +=
_(
"_copy" );
453 if( !libTool->
RenameLibrary(
_(
"Change Footprint Name" ), oldName,
454 [&](
const wxString& aNewName )
458 if( newName.IsEmpty() )
460 wxMessageBox( _(
"Footprint must have a name." ) );
464 if( tbl->FootprintExists( libraryName, newName ) )
466 msg = wxString::Format( _(
"Footprint '%s' already exists in library '%s'." ),
467 newName, libraryName );
469 KIDIALOG errorDlg( m_frame, msg, _(
"Confirmation" ),
470 wxOK | wxCANCEL | wxICON_WARNING );
471 errorDlg.SetOKLabel( _(
"Overwrite" ) );
473 return errorDlg.ShowModal() == wxID_OK;
539 if(
frame->DeleteFootprintFromLibrary(
frame->GetTargetFPID(),
true ) )
541 if(
frame->GetTargetFPID() ==
frame->GetLoadedFPID() )
542 frame->Clear_Pcb(
false );
544 frame->SyncLibraryTree(
true );
564 frame()->ClearUndoRedoList();
567 if( is_last_fp_from_brd )
597 wxString
path = wxEmptyString;
599 for(
FP_LIB_TABLE* table : { globalTable, projectTable } )
606 path = table->FindRow( libName,
true )->GetFullURI(
true );
613 if( !
path.IsEmpty() )
617 wxString fileExt = wxEmptyString;
620 if( !libItemName.IsEmpty() )
623 wxFileName fileName(
path, libItemName, fileExt );
629 if( explCommand.IsEmpty() )
631 path = fileName.GetFullPath().BeforeLast( wxFileName::GetPathSeparator() );
633 if( !
path.IsEmpty() && wxDirExists(
path ) )
638 if( !explCommand.EndsWith(
"%F" ) )
640 wxMessageBox(
_(
"Missing/malformed file explorer argument '%F' in common settings." ) );
644 wxString escapedFilePath = fileName.GetFullPath();
645 escapedFilePath.Replace( wxS(
"\"" ), wxS(
"_" ) );
647 wxString fileArg = wxEmptyString;
648 fileArg <<
'"' << escapedFilePath <<
'"';
650 explCommand.Replace( wxT(
"%F" ), fileArg );
652 if( !explCommand.IsEmpty() )
653 wxExecute( explCommand );
663 if( fullEditorName.IsEmpty() )
665 wxMessageBox(
_(
"No text editor selected in KiCad. Please choose one." ) );
675 wxString libItemName = wxEmptyString;
677 for(
FP_LIB_TABLE* table : { globalTable, projectTable } )
684 libItemName = table->FindRow( libName,
true )->GetFullURI(
true );
691 if( !libItemName.IsEmpty() )
695 libItemName << wxFileName::GetPathSeparator();
699 if( !wxFileName::FileExists( libItemName ) )
702 ExecuteFile( fullEditorName, libItemName.wc_str(),
nullptr,
false );
714 if( !url.has_value() )
716 frame()->ShowInfoBarMsg(
_(
"No datasheet found in the footprint." ) );
773 getEditFrame<FOOTPRINT_EDIT_FRAME>()->OnEditItemRequest(
footprint );
783 getEditFrame<FOOTPRINT_EDIT_FRAME>()->ShowPadPropertiesDialog(
nullptr );
849 if( ids.count( aItem->m_Uuid ) )
852 const_cast<KIID&
>( aItem->m_Uuid ) =
KIID();
855 ids.insert( aItem->m_Uuid );
880 processItem(
group );
884 errors += duplicates;
885 details += wxString::Format(
_(
"%d duplicate IDs replaced.\n" ), duplicates );
892 wxString msg = wxString::Format(
_(
"%d potential problems repaired." ), errors );
static TOOL_ACTION openWithTextEditor
static TOOL_ACTION revert
static TOOL_ACTION saveAs
static TOOL_ACTION openDirectory
static TOOL_ACTION showDatasheet
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION showProperties
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void SetContentModified(bool aModified=true)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
const FOOTPRINTS & Footprints() const
bool Show(bool show) 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()
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.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
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.
virtual const wxString What() const
A composite of Problem() and Where()
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...
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
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.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
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.
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.
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
const wxString GetUniStringLibNickname() const
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
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,...
static TOOL_ACTION deleteFootprint
static TOOL_ACTION renameFootprint
static TOOL_ACTION showLayersManager
static TOOL_ACTION createFootprint
static TOOL_ACTION editFootprint
static TOOL_ACTION exportFootprint
static TOOL_ACTION editTextAndGraphics
static TOOL_ACTION newFootprint
static TOOL_ACTION defaultPadProperties
static TOOL_ACTION importFootprint
static TOOL_ACTION pasteFootprint
static TOOL_ACTION footprintProperties
static TOOL_ACTION checkFootprint
static TOOL_ACTION editLibFpInFpEditor
static TOOL_ACTION duplicateFootprint
static TOOL_ACTION cutFootprint
static TOOL_ACTION repairFootprint
static TOOL_ACTION copyFootprint
static TOOL_ACTION cleanupGraphics
void ToggleProperties() override
FOOTPRINT * CreateNewFootprint(wxString aFootprintName, const wxString &aLibName)
Creates 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.
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).
virtual COMMON_SETTINGS * GetCommonSettings() const
virtual const wxString & GetTextEditor(bool aCanShowFileChooser=true)
Return the path to the preferred text editor application.
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
Look for files in a number of paths.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
A modified version of the wxInfoBar class that allows us to:
bool HasCloseButton() const
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Handle a list of polygons defining a copper zone.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
This file is part of the common library.
FP_LIB_TABLE GFootprintTable
The global footprint library table.
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, PROJECT *aProject, SEARCH_STACK *aPaths, EMBEDDED_FILES *aFiles)
Open a document (file) with the suitable browser.
This file is part of the common library.
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
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.
Class to handle a set of BOARD_ITEMs.
PGM_BASE & Pgm()
The global Program "get" accessor.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
Definition of file extensions used in Kicad.