diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index 451cf3e027..35a43cbeb0 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -915,8 +915,26 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD ); payload = formatter.GetString(); - } break; + } + + case MAIL_SCH_GET_ITEM: + { + KIID uuid( payload ); + SCH_SHEET_PATH path; + + if( SCH_ITEM* item = m_schematic->GetSheets().GetItem( uuid, &path ) ) + { + if( item->Type() == SCH_SHEET_T ) + payload = static_cast( item )->GetShownName( false ); + else if( item->Type() == SCH_SYMBOL_T ) + payload = static_cast( item )->GetRef( &path, true ); + else + payload = item->GetFriendlyName(); + } + + break; + } case MAIL_ASSIGN_FOOTPRINTS: try @@ -935,8 +953,8 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL ); GetCanvas()->Refresh(); - } break; + } case MAIL_IMPORT_FILE: { @@ -960,8 +978,9 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) if( importFormat >= 0 ) importFile( path, importFormat ); - } + break; + } case MAIL_SCH_SAVE: if( SaveProject() ) diff --git a/include/mail_type.h b/include/mail_type.h index fa32ed8d07..edc3e92fd9 100644 --- a/include/mail_type.h +++ b/include/mail_type.h @@ -47,6 +47,7 @@ enum MAIL_T MAIL_SCH_UPDATE, // PCB->SCH forward update MAIL_IMPORT_FILE, // Import a different format file MAIL_SCH_GET_NETLIST, // Fetch a netlist from schematics + MAIL_SCH_GET_ITEM, // Fetch item from KIID MAIL_PCB_GET_NETLIST, // Fetch a netlist from PCB layout MAIL_PCB_UPDATE_LINKS, // Update the schematic symbol paths in the PCB's footprints MAIL_SCH_REFRESH, // Tell the schematic editor to refresh the display. diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 3bf67179f9..4c1a599c5b 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -52,6 +52,8 @@ set( PCBNEW_DIALOGS dialogs/dialog_drc_base.cpp dialogs/dialog_footprint_checker.cpp dialogs/dialog_footprint_checker_base.cpp + dialogs/dialog_footprint_associations.cpp + dialogs/dialog_footprint_associations_base.cpp dialogs/dialog_footprint_properties.cpp dialogs/dialog_footprint_properties_base.cpp dialogs/dialog_footprint_properties_fp_editor.cpp diff --git a/pcbnew/dialogs/dialog_footprint_associations.cpp b/pcbnew/dialogs/dialog_footprint_associations.cpp new file mode 100644 index 0000000000..8a6d9580b5 --- /dev/null +++ b/pcbnew/dialogs/dialog_footprint_associations.cpp @@ -0,0 +1,113 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + + +#include "dialog_footprint_associations.h" +#include +#include +#include +#include +#include + + +DIALOG_FOOTPRINT_ASSOCIATIONS::DIALOG_FOOTPRINT_ASSOCIATIONS( PCB_BASE_FRAME* aFrame, + FOOTPRINT* aFootprint ) : + DIALOG_FOOTPRINT_ASSOCIATIONS_BASE( aFrame ), + m_frame( aFrame ), + m_footprint( aFootprint ) +{ + // Remove wxgrid's selection boxes + for( wxGrid* grid : { m_gridLibrary, m_gridSymbol } ) + grid->SetCellHighlightPenWidth( 0 ); + + m_libraryAssociationLabel->SetFont( KIUI::GetStatusFont( this ) ); + m_symbolAssociationLabel->SetFont( KIUI::GetStatusFont( this ) ); + + m_gridLibrary->SetCellValue( 0, 0, _( "Library: " ) ); + m_gridLibrary->SetCellValue( 1, 0, _( "Footprint: " ) ); +} + + +bool DIALOG_FOOTPRINT_ASSOCIATIONS::TransferDataToWindow() +{ + LIB_ID fpID = m_footprint->GetFPID(); + wxString libName = fpID.GetLibNickname(); + wxString fpName = fpID.GetLibItemName(); + wxString libDesc; + wxString fpDesc; + + PROJECT* project = m_footprint->GetBoard()->GetProject(); + FP_LIB_TABLE* libTable = project->PcbFootprintLibs(); + const LIB_TABLE_ROW* libTableRow = nullptr; + + try + { + libTableRow = libTable->FindRow( libName ); + libDesc = libTableRow->GetDescr(); + } + catch( const IO_ERROR& ) + { + } + + std::shared_ptr libFootprint; + + try + { + libFootprint.reset( libTable->FootprintLoad( libName, fpName, true ) ); + fpDesc = libFootprint->GetLibDescription(); + } + catch( const IO_ERROR& ) + { + } + + m_gridLibrary->SetCellValue( 0, 1, fpID.GetLibNickname() ); + m_gridLibrary->SetCellValue( 0, 2, libDesc ); + + m_gridLibrary->SetCellValue( 1, 1, fpID.GetLibItemName() ); + m_gridLibrary->SetCellValue( 1, 2, fpDesc ); + + KIID_PATH symbolPath = m_footprint->GetPath(); + + m_gridSymbol->ClearRows(); + + for( int ii = 0; ii < (int) symbolPath.size(); ++ii ) + { + m_gridSymbol->AppendRows(); + m_gridSymbol->SetCellValue( ii, 0, ii == (int) symbolPath.size() - 1 ? _( "Symbol:" ) + : _( "Sheet: " ) ); + m_gridSymbol->SetCellValue( ii, 1, symbolPath[ii].AsString() ); + + if( !Kiface().IsSingle() && m_frame->Kiway().Player( FRAME_SCH, false ) ) + { + std::string item = symbolPath[ii].AsString().ToStdString(); + m_frame->Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_ITEM, item ); + m_gridSymbol->SetCellValue( ii, 2, item ); + } + } + + finishDialogSettings(); + + return true; +} + + diff --git a/pcbnew/dialogs/dialog_footprint_associations.h b/pcbnew/dialogs/dialog_footprint_associations.h new file mode 100644 index 0000000000..10d2e78f85 --- /dev/null +++ b/pcbnew/dialogs/dialog_footprint_associations.h @@ -0,0 +1,52 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + + +#ifndef DIALOG_FOOTPRINT_ASSOCIATIONS_H +#define DIALOG_FOOTPRINT_ASSOCIATIONS_H + + +#include + +class PCB_BASE_FRAME; +class FOOTPRINT; + + +/** + * Dialog to show footprint library and symbol links. + */ +class DIALOG_FOOTPRINT_ASSOCIATIONS : public DIALOG_FOOTPRINT_ASSOCIATIONS_BASE +{ +public: + DIALOG_FOOTPRINT_ASSOCIATIONS( PCB_BASE_FRAME* aFrame, FOOTPRINT* aFootprint ); + ~DIALOG_FOOTPRINT_ASSOCIATIONS() { } + + ///< Get data from the PCB board and print it to dialog + bool TransferDataToWindow() override; + +private: + PCB_BASE_FRAME* m_frame; + FOOTPRINT* m_footprint; +}; + +#endif // _DIALOG_FOOTPRINT_ASSOCIATIONS_H diff --git a/pcbnew/dialogs/dialog_footprint_associations_base.cpp b/pcbnew/dialogs/dialog_footprint_associations_base.cpp new file mode 100644 index 0000000000..4b3bc44ad5 --- /dev/null +++ b/pcbnew/dialogs/dialog_footprint_associations_base.cpp @@ -0,0 +1,129 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "widgets/wx_grid.h" + +#include "dialog_footprint_associations_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_FOOTPRINT_ASSOCIATIONS_BASE::DIALOG_FOOTPRINT_ASSOCIATIONS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bMainBoxSizer; + bMainBoxSizer = new wxBoxSizer( wxVERTICAL ); + + m_libraryAssociationLabel = new wxStaticText( this, wxID_ANY, _("Library Association"), wxDefaultPosition, wxDefaultSize, 0 ); + m_libraryAssociationLabel->Wrap( -1 ); + bMainBoxSizer->Add( m_libraryAssociationLabel, 0, wxTOP|wxRIGHT|wxLEFT, 10 ); + + + bMainBoxSizer->Add( 0, 5, 0, wxEXPAND, 5 ); + + m_gridLibrary = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL ); + + // Grid + m_gridLibrary->CreateGrid( 2, 3 ); + m_gridLibrary->EnableEditing( false ); + m_gridLibrary->EnableGridLines( false ); + m_gridLibrary->EnableDragGridSize( false ); + m_gridLibrary->SetMargins( 0, 0 ); + + // Columns + m_gridLibrary->SetColSize( 0, 100 ); + m_gridLibrary->SetColSize( 1, 280 ); + m_gridLibrary->SetColSize( 2, 360 ); + m_gridLibrary->EnableDragColMove( false ); + m_gridLibrary->EnableDragColSize( true ); + m_gridLibrary->SetColLabelSize( 0 ); + m_gridLibrary->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Rows + m_gridLibrary->EnableDragRowSize( false ); + m_gridLibrary->SetRowLabelSize( 0 ); + m_gridLibrary->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Label Appearance + + // Cell Defaults + m_gridLibrary->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + m_gridLibrary->SetMaxSize( wxSize( -1,300 ) ); + + bMainBoxSizer->Add( m_gridLibrary, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 10 ); + + + bMainBoxSizer->Add( 0, 5, 1, wxEXPAND, 5 ); + + m_symbolAssociationLabel = new wxStaticText( this, wxID_ANY, _("Schematic Association"), wxDefaultPosition, wxDefaultSize, 0 ); + m_symbolAssociationLabel->Wrap( -1 ); + bMainBoxSizer->Add( m_symbolAssociationLabel, 0, wxTOP|wxRIGHT|wxLEFT, 10 ); + + + bMainBoxSizer->Add( 0, 5, 0, wxEXPAND, 5 ); + + m_gridSymbol = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL ); + + // Grid + m_gridSymbol->CreateGrid( 1, 3 ); + m_gridSymbol->EnableEditing( false ); + m_gridSymbol->EnableGridLines( false ); + m_gridSymbol->EnableDragGridSize( false ); + m_gridSymbol->SetMargins( 0, 0 ); + + // Columns + m_gridSymbol->SetColSize( 0, 100 ); + m_gridSymbol->SetColSize( 1, 280 ); + m_gridSymbol->SetColSize( 2, 360 ); + m_gridSymbol->EnableDragColMove( false ); + m_gridSymbol->EnableDragColSize( true ); + m_gridSymbol->SetColLabelSize( 0 ); + m_gridSymbol->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Rows + m_gridSymbol->EnableDragRowSize( false ); + m_gridSymbol->SetRowLabelSize( 0 ); + m_gridSymbol->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Label Appearance + + // Cell Defaults + m_gridSymbol->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + bMainBoxSizer->Add( m_gridSymbol, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); + + wxBoxSizer* bSizerBottom; + bSizerBottom = new wxBoxSizer( wxHORIZONTAL ); + + m_sdbControlSizer = new wxStdDialogButtonSizer(); + m_sdbControlSizerOK = new wxButton( this, wxID_OK ); + m_sdbControlSizer->AddButton( m_sdbControlSizerOK ); + m_sdbControlSizer->Realize(); + + bSizerBottom->Add( m_sdbControlSizer, 1, wxBOTTOM|wxLEFT|wxRIGHT|wxTOP, 5 ); + + + bMainBoxSizer->Add( bSizerBottom, 0, wxEXPAND, 5 ); + + + this->SetSizer( bMainBoxSizer ); + this->Layout(); + bMainBoxSizer->Fit( this ); + + this->Centre( wxBOTH ); + + // Connect Events + this->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_FOOTPRINT_ASSOCIATIONS_BASE::windowSize ) ); + m_gridSymbol->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_FOOTPRINT_ASSOCIATIONS_BASE::drillGridSize ), NULL, this ); +} + +DIALOG_FOOTPRINT_ASSOCIATIONS_BASE::~DIALOG_FOOTPRINT_ASSOCIATIONS_BASE() +{ + // Disconnect Events + this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_FOOTPRINT_ASSOCIATIONS_BASE::windowSize ) ); + m_gridSymbol->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_FOOTPRINT_ASSOCIATIONS_BASE::drillGridSize ), NULL, this ); + +} diff --git a/pcbnew/dialogs/dialog_footprint_associations_base.fbp b/pcbnew/dialogs/dialog_footprint_associations_base.fbp new file mode 100644 index 0000000000..2cc8308f9c --- /dev/null +++ b/pcbnew/dialogs/dialog_footprint_associations_base.fbp @@ -0,0 +1,426 @@ + + + + + ; + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_footprint_associations_base + 1000 + none + + + 1 + DIALOG_FOOTPRINT_ASSOCIATIONS + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_FOOTPRINT_ASSOCIATIONS_BASE + + + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h; forward_declare + Footprint Associations + + 0 + + + + windowSize + + + bMainBoxSizer + wxVERTICAL + none + + 10 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Library Association + 0 + + 0 + + + 0 + + 1 + m_libraryAssociationLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND + 0 + + 5 + protected + 0 + + + + 10 + wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + 0 + 0 + + + + 1 + + + wxALIGN_LEFT + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTER + 0 + + wxALIGN_CENTER + 3 + 100,280,360 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + 0 + 0 + 0 + 1 + + 1 + + + 0 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + -1,300 + + 0 + + 1 + m_gridLibrary + 1 + + + protected + 1 + + Resizable + wxALIGN_CENTER + 0 + + wxALIGN_CENTER + + 2 + 1 + + WX_GRID; widgets/wx_grid.h; forward_declare + 0 + + + + wxVSCROLL + + + + 5 + wxEXPAND + 1 + + 5 + protected + 0 + + + + 10 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Schematic Association + 0 + + 0 + + + 0 + + 1 + m_symbolAssociationLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND + 0 + + 5 + protected + 0 + + + + 10 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + 0 + 0 + + + + 1 + + + wxALIGN_LEFT + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTER + 0 + + wxALIGN_CENTER + 3 + 100,280,360 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + 0 + 0 + 0 + 1 + + 1 + + + 0 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + -1,-1 + + 0 + + 1 + m_gridSymbol + 1 + + + protected + 1 + + Resizable + wxALIGN_CENTER + 0 + + wxALIGN_CENTER + + 1 + 1 + + WX_GRID; widgets/wx_grid.h; forward_declare + 0 + + + + wxVSCROLL + drillGridSize + + + + 5 + wxEXPAND + 0 + + + bSizerBottom + wxHORIZONTAL + none + + 5 + wxBOTTOM|wxLEFT|wxRIGHT|wxTOP + 1 + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbControlSizer + protected + + + + + + + + diff --git a/pcbnew/dialogs/dialog_footprint_associations_base.h b/pcbnew/dialogs/dialog_footprint_associations_base.h new file mode 100644 index 0000000000..c511d3cf1f --- /dev/null +++ b/pcbnew/dialogs/dialog_footprint_associations_base.h @@ -0,0 +1,57 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +class WX_GRID; + +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_FOOTPRINT_ASSOCIATIONS_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_FOOTPRINT_ASSOCIATIONS_BASE : public DIALOG_SHIM +{ + private: + + protected: + wxStaticText* m_libraryAssociationLabel; + WX_GRID* m_gridLibrary; + wxStaticText* m_symbolAssociationLabel; + WX_GRID* m_gridSymbol; + wxStdDialogButtonSizer* m_sdbControlSizer; + wxButton* m_sdbControlSizerOK; + + // Virtual event handlers, override them in your derived class + virtual void windowSize( wxSizeEvent& event ) { event.Skip(); } + virtual void drillGridSize( wxSizeEvent& event ) { event.Skip(); } + + + public: + + DIALOG_FOOTPRINT_ASSOCIATIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Footprint Associations"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + + ~DIALOG_FOOTPRINT_ASSOCIATIONS_BASE(); + +}; + diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index e1e53140b3..9f92d934f6 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -396,6 +396,7 @@ void PCB_EDIT_FRAME::doReCreateMenuBar() inspectMenu->AppendSeparator(); inspectMenu->Add( PCB_ACTIONS::inspectClearance ); inspectMenu->Add( PCB_ACTIONS::inspectConstraints ); + inspectMenu->Add( PCB_ACTIONS::showFootprintAssociations ); inspectMenu->Add( PCB_ACTIONS::diffFootprint ); diff --git a/pcbnew/tools/board_inspection_tool.cpp b/pcbnew/tools/board_inspection_tool.cpp index a6306121cb..8beab64032 100644 --- a/pcbnew/tools/board_inspection_tool.cpp +++ b/pcbnew/tools/board_inspection_tool.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -1410,6 +1411,30 @@ int BOARD_INSPECTION_TOOL::DiffFootprint( const TOOL_EVENT& aEvent ) } +int BOARD_INSPECTION_TOOL::ShowFootprintLinks( const TOOL_EVENT& aEvent ) +{ + wxCHECK( m_frame, 0 ); + + PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); + + wxCHECK( selTool, 0 ); + + const PCB_SELECTION& selection = selTool->GetSelection(); + + if( selection.Size() != 1 || selection.Front()->Type() != PCB_FOOTPRINT_T ) + { + m_frame->ShowInfoBarError( _( "Select a footprint for a footprint associations report." ) ); + return 0; + } + + DIALOG_FOOTPRINT_ASSOCIATIONS dlg( m_frame, static_cast( selection.Front() ) ); + + dlg.ShowModal(); + + return 0; +} + + void BOARD_INSPECTION_TOOL::DiffFootprint( FOOTPRINT* aFootprint ) { DIALOG_BOOK_REPORTER* dialog = m_frame->GetFootprintDiffDialog(); @@ -1999,6 +2024,7 @@ void BOARD_INSPECTION_TOOL::setTransitions() Go( &BOARD_INSPECTION_TOOL::InspectClearance, PCB_ACTIONS::inspectClearance.MakeEvent() ); Go( &BOARD_INSPECTION_TOOL::InspectConstraints, PCB_ACTIONS::inspectConstraints.MakeEvent() ); Go( &BOARD_INSPECTION_TOOL::DiffFootprint, PCB_ACTIONS::diffFootprint.MakeEvent() ); + Go( &BOARD_INSPECTION_TOOL::ShowFootprintLinks, PCB_ACTIONS::showFootprintAssociations.MakeEvent() ); Go( &BOARD_INSPECTION_TOOL::HighlightNet, PCB_ACTIONS::highlightNet.MakeEvent() ); Go( &BOARD_INSPECTION_TOOL::HighlightNet, PCB_ACTIONS::highlightNetSelection.MakeEvent() ); diff --git a/pcbnew/tools/board_inspection_tool.h b/pcbnew/tools/board_inspection_tool.h index c04bf4d2c7..067f3d98e8 100644 --- a/pcbnew/tools/board_inspection_tool.h +++ b/pcbnew/tools/board_inspection_tool.h @@ -89,6 +89,8 @@ public: int InspectConstraints( const TOOL_EVENT& aEvent ); + int ShowFootprintLinks( const TOOL_EVENT& aEvent ); + int DiffFootprint( const TOOL_EVENT& aEvent ); void DiffFootprint( FOOTPRINT* aFootprint ); diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index b2a5344b9d..fa4670af0f 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -1399,6 +1399,12 @@ TOOL_ACTION PCB_ACTIONS::diffFootprint( "pcbnew.InspectionTool.DiffFootprint", _( "Show differences between board footprint and its library equivalent" ), BITMAPS::library ); +TOOL_ACTION PCB_ACTIONS::showFootprintAssociations( "pcbnew.InspectionTool.ShowFootprintAssociations", + AS_GLOBAL, 0, "", + _( "Show Footprint Associations" ), + _( "Show footprint library and schematic symbol associations" ), + BITMAPS::edit_cmp_symb_links ); + //Geographic re-annotation tool TOOL_ACTION PCB_ACTIONS::boardReannotate( "pcbnew.ReannotateTool.ShowReannotateDialog", AS_GLOBAL, 0, "", diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index da8ee250eb..c31dabf24f 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -501,6 +501,7 @@ public: static TOOL_ACTION inspectClearance; static TOOL_ACTION inspectConstraints; static TOOL_ACTION diffFootprint; + static TOOL_ACTION showFootprintAssociations; // Appearance controls static TOOL_ACTION clearHighlight; // Turns off highlight and resets previous highlight