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<SCH_SHEET*>( item )->GetShownName( false ); + else if( item->Type() == SCH_SYMBOL_T ) + payload = static_cast<SCH_SYMBOL*>( 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 <widgets/wx_grid.h> +#include <pcb_base_frame.h> +#include <kiface_base.h> +#include <fp_lib_table.h> +#include <footprint.h> + + +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<FOOTPRINT> 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 <dialog_footprint_associations_base.h> + +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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<wxFormBuilder_Project> + <FileVersion major="1" minor="16" /> + <object class="Project" expanded="1"> + <property name="class_decoration">; </property> + <property name="code_generation">C++</property> + <property name="disconnect_events">1</property> + <property name="disconnect_mode">source_name</property> + <property name="disconnect_php_events">0</property> + <property name="disconnect_python_events">0</property> + <property name="embedded_files_path">res</property> + <property name="encoding">UTF-8</property> + <property name="event_generation">connect</property> + <property name="file">dialog_footprint_associations_base</property> + <property name="first_id">1000</property> + <property name="help_provider">none</property> + <property name="image_path_wrapper_function_name"></property> + <property name="indent_with_spaces"></property> + <property name="internationalize">1</property> + <property name="name">DIALOG_FOOTPRINT_ASSOCIATIONS</property> + <property name="namespace"></property> + <property name="path">.</property> + <property name="precompiled_header"></property> + <property name="relative_path">1</property> + <property name="skip_lua_events">1</property> + <property name="skip_php_events">1</property> + <property name="skip_python_events">1</property> + <property name="ui_table">UI</property> + <property name="use_array_enum">0</property> + <property name="use_enum">0</property> + <property name="use_microsoft_bom">0</property> + <object class="Dialog" expanded="1"> + <property name="aui_managed">0</property> + <property name="aui_manager_style">wxAUI_MGR_DEFAULT</property> + <property name="bg"></property> + <property name="center">wxBOTH</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="enabled">1</property> + <property name="event_handler">impl_virtual</property> + <property name="extra_style"></property> + <property name="fg"></property> + <property name="font"></property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="maximum_size"></property> + <property name="minimum_size"></property> + <property name="name">DIALOG_FOOTPRINT_ASSOCIATIONS_BASE</property> + <property name="pos"></property> + <property name="size"></property> + <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property> + <property name="subclass">DIALOG_SHIM; dialog_shim.h; forward_declare</property> + <property name="title">Footprint Associations</property> + <property name="tooltip"></property> + <property name="two_step_creation">0</property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnSize">windowSize</event> + <object class="wxBoxSizer" expanded="1"> + <property name="minimum_size"></property> + <property name="name">bMainBoxSizer</property> + <property name="orient">wxVERTICAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="1"> + <property name="border">10</property> + <property name="flag">wxTOP|wxRIGHT|wxLEFT</property> + <property name="proportion">0</property> + <object class="wxStaticText" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">Library Association</property> + <property name="markup">0</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_libraryAssociationLabel</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <property name="wrap">-1</property> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxEXPAND</property> + <property name="proportion">0</property> + <object class="spacer" expanded="1"> + <property name="height">5</property> + <property name="permission">protected</property> + <property name="width">0</property> + </object> + </object> + <object class="sizeritem" expanded="0"> + <property name="border">10</property> + <property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT</property> + <property name="proportion">0</property> + <object class="wxGrid" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="autosize_cols">0</property> + <property name="autosize_rows">0</property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="cell_bg"></property> + <property name="cell_font"></property> + <property name="cell_horiz_alignment">wxALIGN_LEFT</property> + <property name="cell_text"></property> + <property name="cell_vert_alignment">wxALIGN_TOP</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="col_label_horiz_alignment">wxALIGN_CENTER</property> + <property name="col_label_size">0</property> + <property name="col_label_values"></property> + <property name="col_label_vert_alignment">wxALIGN_CENTER</property> + <property name="cols">3</property> + <property name="column_sizes">100,280,360</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="drag_col_move">0</property> + <property name="drag_col_size">1</property> + <property name="drag_grid_size">0</property> + <property name="drag_row_size">0</property> + <property name="editing">0</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="grid_line_color"></property> + <property name="grid_lines">0</property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label_bg"></property> + <property name="label_font"></property> + <property name="label_text"></property> + <property name="margin_height">0</property> + <property name="margin_width">0</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size">-1,300</property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_gridLibrary</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="row_label_horiz_alignment">wxALIGN_CENTER</property> + <property name="row_label_size">0</property> + <property name="row_label_values"></property> + <property name="row_label_vert_alignment">wxALIGN_CENTER</property> + <property name="row_sizes"></property> + <property name="rows">2</property> + <property name="show">1</property> + <property name="size"></property> + <property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style">wxVSCROLL</property> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxEXPAND</property> + <property name="proportion">1</property> + <object class="spacer" expanded="1"> + <property name="height">5</property> + <property name="permission">protected</property> + <property name="width">0</property> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">10</property> + <property name="flag">wxTOP|wxRIGHT|wxLEFT</property> + <property name="proportion">0</property> + <object class="wxStaticText" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">Schematic Association</property> + <property name="markup">0</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_symbolAssociationLabel</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <property name="wrap">-1</property> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxEXPAND</property> + <property name="proportion">0</property> + <object class="spacer" expanded="1"> + <property name="height">5</property> + <property name="permission">protected</property> + <property name="width">0</property> + </object> + </object> + <object class="sizeritem" expanded="0"> + <property name="border">10</property> + <property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property> + <property name="proportion">0</property> + <object class="wxGrid" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="autosize_cols">0</property> + <property name="autosize_rows">0</property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="cell_bg"></property> + <property name="cell_font"></property> + <property name="cell_horiz_alignment">wxALIGN_LEFT</property> + <property name="cell_text"></property> + <property name="cell_vert_alignment">wxALIGN_TOP</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="col_label_horiz_alignment">wxALIGN_CENTER</property> + <property name="col_label_size">0</property> + <property name="col_label_values"></property> + <property name="col_label_vert_alignment">wxALIGN_CENTER</property> + <property name="cols">3</property> + <property name="column_sizes">100,280,360</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="drag_col_move">0</property> + <property name="drag_col_size">1</property> + <property name="drag_grid_size">0</property> + <property name="drag_row_size">0</property> + <property name="editing">0</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="grid_line_color"></property> + <property name="grid_lines">0</property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label_bg"></property> + <property name="label_font"></property> + <property name="label_text"></property> + <property name="margin_height">0</property> + <property name="margin_width">0</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size">-1,-1</property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_gridSymbol</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="row_label_horiz_alignment">wxALIGN_CENTER</property> + <property name="row_label_size">0</property> + <property name="row_label_values"></property> + <property name="row_label_vert_alignment">wxALIGN_CENTER</property> + <property name="row_sizes"></property> + <property name="rows">1</property> + <property name="show">1</property> + <property name="size"></property> + <property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style">wxVSCROLL</property> + <event name="OnSize">drillGridSize</event> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxEXPAND</property> + <property name="proportion">0</property> + <object class="wxBoxSizer" expanded="1"> + <property name="minimum_size"></property> + <property name="name">bSizerBottom</property> + <property name="orient">wxHORIZONTAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxBOTTOM|wxLEFT|wxRIGHT|wxTOP</property> + <property name="proportion">1</property> + <object class="wxStdDialogButtonSizer" expanded="0"> + <property name="Apply">0</property> + <property name="Cancel">0</property> + <property name="ContextHelp">0</property> + <property name="Help">0</property> + <property name="No">0</property> + <property name="OK">1</property> + <property name="Save">0</property> + <property name="Yes">0</property> + <property name="minimum_size"></property> + <property name="name">m_sdbControlSizer</property> + <property name="permission">protected</property> + </object> + </object> + </object> + </object> + </object> + </object> + </object> +</wxFormBuilder_Project> 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 <wx/artprov.h> +#include <wx/xrc/xmlres.h> +#include <wx/intl.h> +class WX_GRID; + +#include "dialog_shim.h" +#include <wx/string.h> +#include <wx/stattext.h> +#include <wx/gdicmn.h> +#include <wx/font.h> +#include <wx/colour.h> +#include <wx/settings.h> +#include <wx/grid.h> +#include <wx/sizer.h> +#include <wx/button.h> +#include <wx/dialog.h> + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// 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 <dialogs/dialog_book_reporter.h> #include <dialogs/dialog_net_inspector.h> #include <dialogs/panel_setup_rules_base.h> +#include <dialogs/dialog_footprint_associations.h> #include <string_utils.h> #include <tools/board_inspection_tool.h> #include <fp_lib_table.h> @@ -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<PCB_SELECTION_TOOL>(); + + 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<FOOTPRINT*>( 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