41#include <wx/filename.h> 
   88    auto libSelectedCondition =
 
   98    auto libInferredCondition =
 
  105    auto fpSelectedCondition =
 
  112    auto fpExportCondition =
 
  116                return fp != 
nullptr;
 
  119    auto canOpenExternally =
 
  124                bool ret = !
m_frame->IsContentModified();
 
  132    ctxMenu.AddSeparator( 10 );
 
  134    ctxMenu.AddItem( 
ACTIONS::saveAs,                 libSelectedCondition || fpSelectedCondition, 10 );
 
  135    ctxMenu.AddItem( 
ACTIONS::revert,                 libSelectedCondition || libInferredCondition, 10 );
 
  137    ctxMenu.AddSeparator( 10 );
 
  145    ctxMenu.AddSeparator( 100 );
 
  151        ctxMenu.AddSeparator( 200 );
 
  157        ctxMenu.AddSeparator( 200 );
 
  158        ctxMenu.AddItem( 
ACTIONS::openDirectory,  canOpenExternally && ( libSelectedCondition || fpSelectedCondition ), 200 );
 
 
  173                                                            const LIB_ID& aTargetLib )
 
  193                            _( 
"The footprint could not be added to the selected library ('%s'). " 
  194                               "This library is read-only." ),
 
  205            m_frame->SaveFootprint( &aFootprint );
 
 
  216    FOOTPRINT*     newFootprint = 
m_frame->CreateNewFootprint( wxEmptyString, libraryName );
 
  221    if( !
m_frame->Clear_Pcb( 
true ) )
 
  225    m_frame->AddFootprintToBoard( newFootprint );
 
  233    m_frame->Zoom_Automatique( 
false );
 
  234    m_frame->GetScreen()->SetContentModified();
 
  239    m_frame->GetCanvas()->ForceRefresh();
 
  240    m_frame->Update3DView( 
true, 
true );
 
  242    m_frame->SyncLibraryTree( 
false );
 
 
  252    if( 
m_frame->IsContentModified() )
 
  280                m_frame->AddFootprintToBoard( newFootprint );
 
  288                m_frame->Zoom_Automatique( 
false );
 
  289                m_frame->GetScreen()->SetContentModified();
 
  296                m_frame->Update3DView( 
true, 
true );
 
  298                m_frame->SyncLibraryTree( 
false );
 
 
  333    if( 
m_frame->GetTargetFPID().GetLibItemName().empty() )
 
  336        const wxString& src_libNickname = 
m_frame->GetTargetFPID().GetLibNickname();
 
  339        if( 
m_frame->SaveLibraryAs( src_libFullName ) )
 
  340            m_frame->SyncLibraryTree( 
true );
 
  357            m_frame->SyncLibraryTree( 
true );
 
  367            m_frame->SyncLibraryTree( 
true );
 
 
  388    if( fpID == 
m_frame->GetLoadedFPID() )
 
 
  409        wxString newLib = 
m_frame->GetLibTree()->GetSelectedLibId().GetLibNickname();
 
  413            newName += 
_( 
"_copy" );
 
  418        m_frame->SyncLibraryTree( 
true );
 
 
  433    if( fpID == 
m_frame->GetLoadedFPID() )
 
  440        m_frame->SyncLibraryTree( 
true );
 
 
  461    if( !libTool->
RenameLibrary( 
_( 
"Change Footprint Name" ), oldName,
 
  462            [&]( 
const wxString& aNewName )
 
  466                if( newName.IsEmpty() )
 
  468                    wxMessageBox( 
_( 
"Footprint must have a name." ) );
 
  473                if( oldName != newName && tbl->FootprintExists( libraryName, newName ) )
 
  475                    msg = wxString::Format( 
_( 
"Footprint '%s' already exists in library '%s'." ),
 
  476                                            newName, libraryName );
 
  479                                       wxOK | wxCANCEL | wxICON_WARNING );
 
  480                    errorDlg.SetOKLabel( 
_( 
"Overwrite" ) );
 
  491    if( newName == oldName )
 
  496    if( fpID == 
m_frame->GetLoadedFPID() )
 
  539    wxDataViewItem treeItem = 
m_frame->GetLibTreeAdapter()->FindItem( fpID );
 
 
  555    if( 
frame->DeleteFootprintFromLibrary( 
frame->GetTargetFPID(), 
true ) )
 
  557        if( 
frame->GetTargetFPID() == 
frame->GetLoadedFPID() )
 
  558            frame->Clear_Pcb( 
false );
 
  560        frame->SyncLibraryTree( 
true );
 
 
  569    bool is_last_fp_from_brd = 
m_frame->IsCurrentFPFromBoard();
 
  571    if( !
m_frame->Clear_Pcb( 
true ) )
 
  577    if( 
m_frame->GetBoard()->GetFirstFootprint() )
 
  578        m_frame->GetBoard()->GetFirstFootprint()->ClearFlags();
 
  580    frame()->ClearUndoRedoList();
 
  583    if( is_last_fp_from_brd )
 
 
  598        m_frame->ExportFootprint( fp );
 
 
  613    wxString    
path = wxEmptyString;
 
  622            path = 
table->FindRow( libName, 
true )->GetFullURI( 
true );
 
  629        if( !
path.IsEmpty() )
 
  633    wxString fileExt = wxEmptyString;
 
  636    if( !libItemName.IsEmpty() )
 
  639    wxFileName fileName( 
path, libItemName, fileExt );
 
  640    wxString   explorerCommand;
 
  643        explorerCommand = cfg->m_System.file_explorer;
 
  645    if( explorerCommand.IsEmpty() )
 
  647        path = fileName.GetFullPath().BeforeLast( wxFileName::GetPathSeparator() );
 
  649        if( !
path.IsEmpty() && wxDirExists( 
path ) )
 
  655    if( !explorerCommand.EndsWith( 
"%F" ) )
 
  657        wxMessageBox( 
_( 
"Missing/malformed file explorer argument '%F' in common settings." ) );
 
  661    wxString escapedFilePath = fileName.GetFullPath();
 
  662    escapedFilePath.Replace( wxS( 
"\"" ), wxS( 
"_" ) );
 
  664    wxString fileArg = wxEmptyString;
 
  665    fileArg << 
'"' << escapedFilePath << 
'"';
 
  667    explorerCommand.Replace( wxT( 
"%F" ), fileArg );
 
  669    if( !explorerCommand.IsEmpty() )
 
  670        wxExecute( explorerCommand );
 
 
  680    if( fullEditorName.IsEmpty() )
 
  682        wxMessageBox( 
_( 
"No text editor selected in KiCad. Please choose one." ) );
 
  692    wxString    libItemName = wxEmptyString;
 
  701            libItemName = 
table->FindRow( libName, 
true )->GetFullURI( 
true );
 
  708        if( !libItemName.IsEmpty() )
 
  712    libItemName << wxFileName::GetPathSeparator();
 
  716    if( !wxFileName::FileExists( libItemName ) )
 
  719    ExecuteFile( fullEditorName, libItemName.wc_str(), 
nullptr, 
false );
 
 
  731        if( !url.has_value() )
 
  733            frame()->ShowInfoBarMsg( 
_( 
"No datasheet found in the footprint." ) );
 
  740                                   { m_frame->GetBoard(), footprint } );
 
 
  749    m_frame->LoadFootprintFromLibrary( 
m_frame->GetLibTree()->GetSelectedLibId() );
 
 
  766    if( !
m_frame->IsLibraryTreeShown() )
 
 
  775    m_frame->ToggleLayersManager();
 
 
  792        m_frame->GetCanvas()->Refresh();
 
 
  867                if( ids.count( aItem->m_Uuid ) )
 
  870                    const_cast<KIID&
>( aItem->m_Uuid ) = 
KIID();
 
  873                ids.insert( aItem->m_Uuid );
 
  898        processItem( 
group );
 
  902        errors += duplicates;
 
  903        details += wxString::Format( 
_( 
"%d duplicate IDs replaced.\n" ), duplicates );
 
  910        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 TOOL_ACTION refreshPreview
 
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
 
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
 
const FOOTPRINTS & Footprints() const
 
void SelectLeftToolbarAction(const TOOL_ACTION &aAction)
Select the given action in the left toolbar group which contains it, if any.
 
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 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()
 
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
 
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.
 
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.
 
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.
 
static TOOL_ACTION lineModeFree
Unconstrained angle mode (icon lines_any)
 
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 lineMode45
45-degree-or-orthogonal mode (icon hv45mode)
 
static TOOL_ACTION angleSnapModeChanged
Notification event when angle mode changes.
 
static TOOL_ACTION newFootprint
 
static TOOL_ACTION defaultPadProperties
 
static TOOL_ACTION importFootprint
 
static TOOL_ACTION pasteFootprint
 
static TOOL_ACTION footprintProperties
 
static TOOL_ACTION lineMode90
90-degree-only mode (icon lines90)
 
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
 
A set of BOARD_ITEMs (i.e., without duplicates).
 
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 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.
 
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
 
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, std::vector< EMBEDDED_FILES * > aFilesStack)
Open a document (file) with the suitable browser.
 
This file is part of the common library.
 
LEADER_MODE
The kind of the leader line.
 
@ DIRECT
Unconstrained point-to-point.
 
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
 
static const std::string KiCadFootprintFileExtension
 
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.
 
T * GetAppSettings(const char *aFilename)
 
VECTOR2< int32_t > VECTOR2I
 
VECTOR2< double > VECTOR2D
 
Definition of file extensions used in Kicad.