From bc0d59801a135765c5291eebfb35b1c105970de5 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 9 Mar 2023 17:41:18 +0000 Subject: [PATCH] Graphical diff for schematic vs library symbols. Fixes https://gitlab.com/kicad/code/kicad/issues/13736 --- common/CMakeLists.txt | 4 +- ..._reporter.cpp => dialog_book_reporter.cpp} | 30 ++-- ...base.cpp => dialog_book_reporter_base.cpp} | 10 +- ...base.fbp => dialog_book_reporter_base.fbp} | 8 +- ...ter_base.h => dialog_book_reporter_base.h} | 8 +- common/eda_item.cpp | 6 +- eeschema/CMakeLists.txt | 1 + eeschema/dialogs/dialog_choose_symbol.cpp | 2 +- eeschema/dialogs/dialog_rescue_each.cpp | 4 +- eeschema/lib_item.cpp | 6 + eeschema/lib_item.h | 5 + eeschema/lib_shape.cpp | 10 +- eeschema/lib_symbol.cpp | 15 +- eeschema/menubar.cpp | 2 +- eeschema/sch_painter.cpp | 3 + eeschema/tools/ee_actions.cpp | 4 +- eeschema/tools/ee_actions.h | 2 +- eeschema/tools/ee_inspection_tool.cpp | 63 ++++--- eeschema/tools/ee_inspection_tool.h | 14 +- eeschema/widgets/symbol_diff_widget.cpp | 166 ++++++++++++++++++ eeschema/widgets/symbol_diff_widget.h | 60 +++++++ eeschema/widgets/symbol_preview_widget.cpp | 13 +- eeschema/widgets/symbol_preview_widget.h | 6 +- ...ints_reporter.h => dialog_book_reporter.h} | 20 ++- include/eda_item.h | 5 +- pcbnew/menubar_pcb_editor.cpp | 2 +- pcbnew/tools/board_inspection_tool.cpp | 100 +++++------ pcbnew/tools/board_inspection_tool.h | 16 +- pcbnew/tools/pcb_actions.cpp | 2 +- pcbnew/tools/pcb_actions.h | 2 +- 30 files changed, 440 insertions(+), 149 deletions(-) rename common/dialogs/{dialog_constraints_reporter.cpp => dialog_book_reporter.cpp} (69%) rename common/dialogs/{dialog_constraints_reporter_base.cpp => dialog_book_reporter_base.cpp} (70%) rename common/dialogs/{dialog_constraints_reporter_base.fbp => dialog_book_reporter_base.fbp} (96%) rename common/dialogs/{dialog_constraints_reporter_base.h => dialog_book_reporter_base.h} (72%) create mode 100644 eeschema/widgets/symbol_diff_widget.cpp create mode 100644 eeschema/widgets/symbol_diff_widget.h rename include/dialogs/{dialog_constraints_reporter.h => dialog_book_reporter.h} (73%) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 74347c2753..b8e1b99d4d 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -106,12 +106,12 @@ set( COMMON_ABOUT_DLG_SRCS set( COMMON_DLG_SRCS dialogs/dialog_assign_netclass.cpp dialogs/dialog_assign_netclass_base.cpp + dialogs/dialog_book_reporter.cpp + dialogs/dialog_book_reporter_base.cpp dialogs/dialog_color_picker.cpp dialogs/dialog_color_picker_base.cpp dialogs/dialog_configure_paths.cpp dialogs/dialog_configure_paths_base.cpp - dialogs/dialog_constraints_reporter.cpp - dialogs/dialog_constraints_reporter_base.cpp dialogs/dialog_display_html_text_base.cpp dialogs/dialog_edit_library_tables.cpp dialogs/dialog_global_lib_table_config.cpp diff --git a/common/dialogs/dialog_constraints_reporter.cpp b/common/dialogs/dialog_book_reporter.cpp similarity index 69% rename from common/dialogs/dialog_constraints_reporter.cpp rename to common/dialogs/dialog_book_reporter.cpp index dc1504fbe1..16b72695e1 100644 --- a/common/dialogs/dialog_constraints_reporter.cpp +++ b/common/dialogs/dialog_book_reporter.cpp @@ -21,38 +21,38 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include #include -DIALOG_CONSTRAINTS_REPORTER::DIALOG_CONSTRAINTS_REPORTER( KIWAY_PLAYER* aParent ) : - DIALOG_CONSTRAINTS_REPORTER_BASE( aParent ), +DIALOG_BOOK_REPORTER::DIALOG_BOOK_REPORTER( KIWAY_PLAYER* aParent ) : + DIALOG_BOOK_REPORTER_BASE( aParent ), m_frame( aParent ) { } -void DIALOG_CONSTRAINTS_REPORTER::FinishInitialization() +void DIALOG_BOOK_REPORTER::FinishInitialization() { SetupStandardButtons(); finishDialogSettings(); } -void DIALOG_CONSTRAINTS_REPORTER::DeleteAllPages() +void DIALOG_BOOK_REPORTER::DeleteAllPages() { m_notebook->DeleteAllPages(); } -void DIALOG_CONSTRAINTS_REPORTER::OnErrorLinkClicked( wxHtmlLinkEvent& event ) +void DIALOG_BOOK_REPORTER::OnErrorLinkClicked( wxHtmlLinkEvent& aEvent ) { - m_frame->ExecuteRemoteCommand( event.GetLinkInfo().GetHref().ToStdString().c_str() ); + m_frame->ExecuteRemoteCommand( aEvent.GetLinkInfo().GetHref().ToStdString().c_str() ); } -WX_HTML_REPORT_BOX* DIALOG_CONSTRAINTS_REPORTER::AddPage( const wxString& aTitle ) +WX_HTML_REPORT_BOX* DIALOG_BOOK_REPORTER::AddHTMLPage( const wxString& aTitle ) { wxPanel* panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); @@ -69,14 +69,24 @@ WX_HTML_REPORT_BOX* DIALOG_CONSTRAINTS_REPORTER::AddPage( const wxString& aTitle reporter->SetUnits( m_frame->GetUserUnits() ); reporter->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, - wxHtmlLinkEventHandler( DIALOG_CONSTRAINTS_REPORTER::OnErrorLinkClicked ), + wxHtmlLinkEventHandler( DIALOG_BOOK_REPORTER::OnErrorLinkClicked ), nullptr, this ); return reporter; } -int DIALOG_CONSTRAINTS_REPORTER::GetPageCount() const +wxPanel* DIALOG_BOOK_REPORTER::AddBlankPage( const wxString& aTitle ) +{ + wxPanel* panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, + wxTAB_TRAVERSAL ); + m_notebook->AddPage( panel, aTitle ); + + return panel; +} + + +int DIALOG_BOOK_REPORTER::GetPageCount() const { return m_notebook->GetPageCount(); } diff --git a/common/dialogs/dialog_constraints_reporter_base.cpp b/common/dialogs/dialog_book_reporter_base.cpp similarity index 70% rename from common/dialogs/dialog_constraints_reporter_base.cpp rename to common/dialogs/dialog_book_reporter_base.cpp index 201cc9c367..e3dcaa58ed 100644 --- a/common/dialogs/dialog_constraints_reporter_base.cpp +++ b/common/dialogs/dialog_book_reporter_base.cpp @@ -5,11 +5,11 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "dialog_constraints_reporter_base.h" +#include "dialog_book_reporter_base.h" /////////////////////////////////////////////////////////////////////////// -DIALOG_CONSTRAINTS_REPORTER_BASE::DIALOG_CONSTRAINTS_REPORTER_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +DIALOG_BOOK_REPORTER_BASE::DIALOG_BOOK_REPORTER_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 ); @@ -37,12 +37,12 @@ DIALOG_CONSTRAINTS_REPORTER_BASE::DIALOG_CONSTRAINTS_REPORTER_BASE( wxWindow* pa this->Centre( wxBOTH ); // Connect Events - m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONSTRAINTS_REPORTER_BASE::OnOK ), NULL, this ); + m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BOOK_REPORTER_BASE::OnOK ), NULL, this ); } -DIALOG_CONSTRAINTS_REPORTER_BASE::~DIALOG_CONSTRAINTS_REPORTER_BASE() +DIALOG_BOOK_REPORTER_BASE::~DIALOG_BOOK_REPORTER_BASE() { // Disconnect Events - m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONSTRAINTS_REPORTER_BASE::OnOK ), NULL, this ); + m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BOOK_REPORTER_BASE::OnOK ), NULL, this ); } diff --git a/common/dialogs/dialog_constraints_reporter_base.fbp b/common/dialogs/dialog_book_reporter_base.fbp similarity index 96% rename from common/dialogs/dialog_constraints_reporter_base.fbp rename to common/dialogs/dialog_book_reporter_base.fbp index bfc4821077..3ba1437cbe 100644 --- a/common/dialogs/dialog_constraints_reporter_base.fbp +++ b/common/dialogs/dialog_book_reporter_base.fbp @@ -11,13 +11,13 @@ res UTF-8 connect - dialog_constraints_reporter_base + dialog_book_reporter_base 2240 none 1 - DialogConstraintsReporterBase + DialogBookReporterBase . @@ -45,12 +45,12 @@ wxID_ANY - DIALOG_CONSTRAINTS_REPORTER_BASE + DIALOG_BOOK_REPORTER_BASE wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h; forward_declare - Constraints Resolution Report + Report 0 diff --git a/common/dialogs/dialog_constraints_reporter_base.h b/common/dialogs/dialog_book_reporter_base.h similarity index 72% rename from common/dialogs/dialog_constraints_reporter_base.h rename to common/dialogs/dialog_book_reporter_base.h index 661a1744d6..53dbd31d76 100644 --- a/common/dialogs/dialog_constraints_reporter_base.h +++ b/common/dialogs/dialog_book_reporter_base.h @@ -25,9 +25,9 @@ /////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_CONSTRAINTS_REPORTER_BASE +/// Class DIALOG_BOOK_REPORTER_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_CONSTRAINTS_REPORTER_BASE : public DIALOG_SHIM +class DIALOG_BOOK_REPORTER_BASE : public DIALOG_SHIM { private: @@ -42,9 +42,9 @@ class DIALOG_CONSTRAINTS_REPORTER_BASE : public DIALOG_SHIM public: - DIALOG_CONSTRAINTS_REPORTER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Constraints Resolution Report"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_BOOK_REPORTER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Report"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_CONSTRAINTS_REPORTER_BASE(); + ~DIALOG_BOOK_REPORTER_BASE(); }; diff --git a/common/eda_item.cpp b/common/eda_item.cpp index cf769092f9..6a44413d46 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -37,6 +37,7 @@ EDA_ITEM::EDA_ITEM( EDA_ITEM* parent, KICAD_T idType ) : m_status( 0 ), m_parent( parent ), m_forceVisible( false ), + m_forceTransparency( 0.0 ), m_flags( 0 ), m_structType( idType ) { } @@ -46,6 +47,7 @@ EDA_ITEM::EDA_ITEM( KICAD_T idType ) : m_status( 0 ), m_parent( nullptr ), m_forceVisible( false ), + m_forceTransparency( 0.0 ), m_flags( 0 ), m_structType( idType ) { } @@ -56,6 +58,7 @@ EDA_ITEM::EDA_ITEM( const EDA_ITEM& base ) : m_status( base.m_status ), m_parent( base.m_parent ), m_forceVisible( base.m_forceVisible ), + m_forceTransparency( base.m_forceTransparency ), m_flags( base.m_flags ), m_structType( base.m_structType ) { } @@ -245,7 +248,8 @@ EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem ) m_flags = aItem.m_flags; m_status = aItem.m_status; m_parent = aItem.m_parent; - m_forceVisible = aItem.m_forceVisible; + m_forceVisible = aItem.m_forceVisible; + m_forceTransparency = aItem.m_forceTransparency; return *this; } diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index b8bd90d5f8..0add71b9e8 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -159,6 +159,7 @@ set( EESCHEMA_WIDGETS widgets/hierarchy_pane.cpp widgets/pin_shape_combobox.cpp widgets/pin_type_combobox.cpp + widgets/symbol_diff_widget.cpp widgets/symbol_preview_widget.cpp widgets/symbol_tree_pane.cpp ) diff --git a/eeschema/dialogs/dialog_choose_symbol.cpp b/eeschema/dialogs/dialog_choose_symbol.cpp index 674e998a67..e0da67c29a 100644 --- a/eeschema/dialogs/dialog_choose_symbol.cpp +++ b/eeschema/dialogs/dialog_choose_symbol.cpp @@ -290,7 +290,7 @@ wxPanel* DIALOG_CHOOSE_SYMBOL::ConstructRightPanel( wxWindow* aParent ) wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL ); EDA_DRAW_PANEL_GAL::GAL_TYPE backend = m_parent->GetCanvas()->GetBackend(); - m_symbol_preview = new SYMBOL_PREVIEW_WIDGET( panel, Kiway(), backend ); + m_symbol_preview = new SYMBOL_PREVIEW_WIDGET( panel, &Kiway(), backend ); m_symbol_preview->SetLayoutDirection( wxLayout_LeftToRight ); if( m_show_footprints ) diff --git a/eeschema/dialogs/dialog_rescue_each.cpp b/eeschema/dialogs/dialog_rescue_each.cpp index 575203805d..677ee9a3f5 100644 --- a/eeschema/dialogs/dialog_rescue_each.cpp +++ b/eeschema/dialogs/dialog_rescue_each.cpp @@ -90,10 +90,10 @@ DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH( wxWindow* aParent, { wxASSERT( aCurrentSheet ); - m_previewOldWidget = new SYMBOL_PREVIEW_WIDGET( m_previewOldPanel, Kiway(), aGalBackEndType ); + m_previewOldWidget = new SYMBOL_PREVIEW_WIDGET( m_previewOldPanel, &Kiway(), aGalBackEndType ); m_SizerOldPanel->Add( m_previewOldWidget, 1, wxEXPAND | wxALL, 5 ); - m_previewNewWidget = new SYMBOL_PREVIEW_WIDGET( m_previewNewPanel, Kiway(), aGalBackEndType ); + m_previewNewWidget = new SYMBOL_PREVIEW_WIDGET( m_previewNewPanel, &Kiway(), aGalBackEndType ); m_SizerNewPanel->Add( m_previewNewWidget, 1, wxEXPAND | wxALL, 5 ); // Set the info message, customized to include the proper suffix. diff --git a/eeschema/lib_item.cpp b/eeschema/lib_item.cpp index df308d65b1..28b9965a89 100644 --- a/eeschema/lib_item.cpp +++ b/eeschema/lib_item.cpp @@ -90,6 +90,12 @@ int LIB_ITEM::compare( const LIB_ITEM& aOther, int aCompareFlags ) const } +bool LIB_ITEM::cmp_items::operator()( const LIB_ITEM* aFirst, const LIB_ITEM* aSecond ) const +{ + return aFirst->compare( *aSecond, LIB_ITEM::COMPARE_FLAGS::EQUALITY ) < 0; +} + + bool LIB_ITEM::operator==( const LIB_ITEM& aOther ) const { if( Type() != aOther.Type() ) diff --git a/eeschema/lib_item.h b/eeschema/lib_item.h index 7e56de3e06..0688c415b7 100644 --- a/eeschema/lib_item.h +++ b/eeschema/lib_item.h @@ -278,6 +278,11 @@ public: void SetPrivate( bool aPrivate ) { m_private = aPrivate; } bool IsPrivate() const { return m_private; } + struct cmp_items + { + bool operator()( const LIB_ITEM* aFirst, const LIB_ITEM* aSecond ) const; + }; + #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } #endif diff --git a/eeschema/lib_shape.cpp b/eeschema/lib_shape.cpp index 4c11d4a90e..7fe13214cb 100644 --- a/eeschema/lib_shape.cpp +++ b/eeschema/lib_shape.cpp @@ -471,24 +471,24 @@ wxString LIB_SHAPE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const switch( GetShape() ) { case SHAPE_T::ARC: - return wxString::Format( _( "Arc, radius %s" ), + return wxString::Format( _( "Arc with radius %s" ), aUnitsProvider->MessageTextFromValue( GetRadius() ) ); case SHAPE_T::CIRCLE: - return wxString::Format( _( "Circle, radius %s" ), + return wxString::Format( _( "Circle with radius %s" ), aUnitsProvider->MessageTextFromValue( GetRadius() ) ); case SHAPE_T::RECT: - return wxString::Format( _( "Rectangle, width %s height %s" ), + return wxString::Format( _( "Rectangle with width %s height %s" ), aUnitsProvider->MessageTextFromValue( std::abs( m_start.x - m_end.x ) ), aUnitsProvider->MessageTextFromValue( std::abs( m_start.y - m_end.y ) ) ); case SHAPE_T::POLY: - return wxString::Format( _( "Polyline, %d points" ), + return wxString::Format( _( "Polyline with %d points" ), int( m_poly.Outline( 0 ).GetPointCount() ) ); case SHAPE_T::BEZIER: - return wxString::Format( _( "Bezier Curve, %d points" ), + return wxString::Format( _( "Bezier Curve with %d points" ), int( m_bezierPoints.size() ) ); default: diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 1be2989ca2..1cc0776ee5 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -274,9 +274,12 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR CHECKPOINT; - std::set aShapes; - std::set aFields; - std::set aPins; + // Make sure shapes are sorted, but no need with fields and pins as we're going to + // match those up by id/name/number. + + std::set aShapes; + std::set aFields; + std::set aPins; for( auto it = m_drawings.begin(); it != m_drawings.end(); ++it ) { @@ -288,9 +291,9 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR aPins.insert( &(*it) ); } - std::set bShapes; - std::set bFields; - std::set bPins; + std::set bShapes; + std::set bFields; + std::set bPins; for( auto it = aRhs.m_drawings.begin(); it != aRhs.m_drawings.end(); ++it ) { diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index 91011de1b1..34414ffbd1 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -254,7 +254,7 @@ void SCH_EDIT_FRAME::doReCreateMenuBar() inspectMenu->Add( ACTIONS::excludeMarker ); inspectMenu->AppendSeparator(); - inspectMenu->Add( EE_ACTIONS::inspectLibraryDiff ); + inspectMenu->Add( EE_ACTIONS::diffSymbol ); #ifdef KICAD_SPICE inspectMenu->AppendSeparator(); diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 8471bd1b7e..3cf79f0b0e 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -498,6 +498,9 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM *aItem, int aLayer, bool aDr color = color.Mix( sheetColour, 0.5f ); } + if( aItem->GetForceTransparency() > 0.0 ) + color = color.WithAlpha( color.a * ( 1.0 - aItem->GetForceTransparency() ) ); + return color; } diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index 0fa1197861..c4fd1f8ae0 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -50,9 +50,9 @@ TOOL_ACTION EE_ACTIONS::checkSymbol( "eeschema.InspectionTool.checkSymbol", _( "Symbol Checker" ), _( "Show the symbol checker window" ), BITMAPS::erc ); -TOOL_ACTION EE_ACTIONS::inspectLibraryDiff( "eeschema.InspectionTool.inspectLibraryDiff", +TOOL_ACTION EE_ACTIONS::diffSymbol( "eeschema.InspectionTool.diffSymbol", AS_GLOBAL, 0, "", - _( "Check Symbol against Library..." ), + _( "Diff Symbol with Library..." ), _( "Check for differences between schematic symbol and its library equivalent" ), BITMAPS::library ); diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index 6df5c73e20..df9140151d 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -162,7 +162,7 @@ public: static TOOL_ACTION schematicSetup; static TOOL_ACTION editPageNumber; static TOOL_ACTION checkSymbol; - static TOOL_ACTION inspectLibraryDiff; + static TOOL_ACTION diffSymbol; static TOOL_ACTION rescueSymbols; static TOOL_ACTION remapSymbols; diff --git a/eeschema/tools/ee_inspection_tool.cpp b/eeschema/tools/ee_inspection_tool.cpp index 2b072ca1a3..e3cc2d2810 100644 --- a/eeschema/tools/ee_inspection_tool.cpp +++ b/eeschema/tools/ee_inspection_tool.cpp @@ -42,8 +42,9 @@ #include #include #include -#include +#include #include +#include #include // for KiROUND @@ -238,7 +239,7 @@ int EE_INSPECTION_TOOL::CheckSymbol( const TOOL_EVENT& aEvent ) } -int EE_INSPECTION_TOOL::InspectLibraryDiff( const TOOL_EVENT& aEvent ) +int EE_INSPECTION_TOOL::DiffSymbol( const TOOL_EVENT& aEvent ) { if( !m_frame->IsType( FRAME_SCH ) ) return 0; @@ -251,17 +252,17 @@ int EE_INSPECTION_TOOL::InspectLibraryDiff( const TOOL_EVENT& aEvent ) return 0; } - if( m_inspectLibraryDiffDialog == nullptr ) + if( m_diffSymbolDialog == nullptr ) { - m_inspectLibraryDiffDialog = std::make_unique( m_frame ); - m_inspectLibraryDiffDialog->SetTitle( _( "Diff Symbol with Library" ) ); + m_diffSymbolDialog = std::make_unique( m_frame ); + m_diffSymbolDialog->SetTitle( _( "Diff Symbol with Library" ) ); - m_inspectLibraryDiffDialog->Connect( wxEVT_CLOSE_WINDOW, - wxCommandEventHandler( EE_INSPECTION_TOOL::onInspectLibraryDiffDialogClosed ), - nullptr, this ); + m_diffSymbolDialog->Connect( wxEVT_CLOSE_WINDOW, + wxCommandEventHandler( EE_INSPECTION_TOOL::onDiffSymbolDialogClosed ), + nullptr, this ); } - m_inspectLibraryDiffDialog->DeleteAllPages(); + m_diffSymbolDialog->DeleteAllPages(); SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front(); wxString symbolDesc = wxString::Format( _( "Symbol %s" ), @@ -270,7 +271,7 @@ int EE_INSPECTION_TOOL::InspectLibraryDiff( const TOOL_EVENT& aEvent ) wxString libName = libId.GetLibNickname(); wxString symbolName = libId.GetLibItemName(); - WX_HTML_REPORT_BOX* r = m_inspectLibraryDiffDialog->AddPage( _( "Summary" ) ); + WX_HTML_REPORT_BOX* r = m_diffSymbolDialog->AddHTMLPage( _( "Summary" ) ); r->Report( wxS( "" ) + _( "Schematic vs library diff for:" ) + wxS( "" ) ); r->Report( wxS( "
  • " ) + EscapeHTML( symbolDesc ) + wxS( "
  • " ) @@ -323,32 +324,54 @@ int EE_INSPECTION_TOOL::InspectLibraryDiff( const TOOL_EVENT& aEvent ) field.GetName( false ) ) ); fields.back().CopyText( field ); fields.back().SetAttributes( field ); + fields.back().Offset( -symbol->GetPosition() ); } flattenedSchSymbol->SetFields( fields ); if( flattenedSchSymbol->Compare( *flattenedLibSymbol, 0, r ) == 0 ) r->Report( _( "No relevant differences detected." ) ); + + wxPanel* panel = m_diffSymbolDialog->AddBlankPage( _( "Visual" ) ); + SYMBOL_DIFF_WIDGET* diff = constructDiffPanel( panel ); + + diff->DisplayDiff( flattenedSchSymbol.release(), flattenedLibSymbol.release(), + symbol->GetUnit(), symbol->GetConvert() ); } } r->Flush(); - m_inspectLibraryDiffDialog->FinishInitialization(); - m_inspectLibraryDiffDialog->Raise(); - m_inspectLibraryDiffDialog->Show( true ); + m_diffSymbolDialog->FinishInitialization(); + m_diffSymbolDialog->Raise(); + m_diffSymbolDialog->Show( true ); return 0; } -void EE_INSPECTION_TOOL::onInspectLibraryDiffDialogClosed( wxCommandEvent& event ) +SYMBOL_DIFF_WIDGET* EE_INSPECTION_TOOL::constructDiffPanel( wxPanel* aParentPanel ) { - m_inspectLibraryDiffDialog->Disconnect( wxEVT_CLOSE_WINDOW, - wxCommandEventHandler( EE_INSPECTION_TOOL::onInspectLibraryDiffDialogClosed ), - nullptr, this ); + wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL ); - m_inspectLibraryDiffDialog->Destroy(); - m_inspectLibraryDiffDialog.release(); + EDA_DRAW_PANEL_GAL::GAL_TYPE backend = m_frame->GetCanvas()->GetBackend(); + SYMBOL_DIFF_WIDGET* diffWidget = new SYMBOL_DIFF_WIDGET( aParentPanel, backend ); + + sizer->Add( diffWidget, 1, wxEXPAND | wxALL, 5 ); + aParentPanel->SetSizer( sizer ); + aParentPanel->Layout(); + + return diffWidget; +} + + +void EE_INSPECTION_TOOL::onDiffSymbolDialogClosed( wxCommandEvent& aEvent ) +{ + m_diffSymbolDialog->Disconnect( wxEVT_CLOSE_WINDOW, + wxCommandEventHandler( EE_INSPECTION_TOOL::onDiffSymbolDialogClosed ), + nullptr, this ); + + m_diffSymbolDialog->Destroy(); + m_diffSymbolDialog.release(); } @@ -467,7 +490,7 @@ void EE_INSPECTION_TOOL::setTransitions() Go( &EE_INSPECTION_TOOL::ExcludeMarker, EE_ACTIONS::excludeMarker.MakeEvent() ); Go( &EE_INSPECTION_TOOL::CheckSymbol, EE_ACTIONS::checkSymbol.MakeEvent() ); - Go( &EE_INSPECTION_TOOL::InspectLibraryDiff, EE_ACTIONS::inspectLibraryDiff.MakeEvent() ); + Go( &EE_INSPECTION_TOOL::DiffSymbol, EE_ACTIONS::diffSymbol.MakeEvent() ); Go( &EE_INSPECTION_TOOL::RunSimulation, EE_ACTIONS::showSimulator.MakeEvent() ); Go( &EE_INSPECTION_TOOL::ShowDatasheet, EE_ACTIONS::showDatasheet.MakeEvent() ); diff --git a/eeschema/tools/ee_inspection_tool.h b/eeschema/tools/ee_inspection_tool.h index e1cbcda24b..3fd260acd4 100644 --- a/eeschema/tools/ee_inspection_tool.h +++ b/eeschema/tools/ee_inspection_tool.h @@ -26,13 +26,14 @@ #define EE_INSPECTION_TOOL_H #include -#include +#include #include class EE_SELECTION_TOOL; class SCH_BASE_FRAME; class DIALOG_ERC; +class SYMBOL_DIFF_WIDGET; class EE_INSPECTION_TOOL : public wxEvtHandler, public EE_TOOL_BASE @@ -59,7 +60,7 @@ public: int ExcludeMarker( const TOOL_EVENT& aEvent ); int CheckSymbol( const TOOL_EVENT& aEvent ); - int InspectLibraryDiff( const TOOL_EVENT& aEvent ); + int DiffSymbol( const TOOL_EVENT& aEvent ); int RunSimulation( const TOOL_EVENT& aEvent ); @@ -69,15 +70,16 @@ public: int UpdateMessagePanel( const TOOL_EVENT& aEvent ); private: - void onInspectLibraryDiffDialogClosed( wxCommandEvent& aEvent ); + SYMBOL_DIFF_WIDGET* constructDiffPanel( wxPanel* aParentPanel ); + + void onDiffSymbolDialogClosed( wxCommandEvent& aEvent ); ///< @copydoc TOOL_INTERACTIVE::setTransitions(); void setTransitions() override; private: - DIALOG_ERC* m_ercDialog; - - std::unique_ptr m_inspectLibraryDiffDialog; + DIALOG_ERC* m_ercDialog; + std::unique_ptr m_diffSymbolDialog; }; #endif /* EE_INSPECTION_TOOL_H */ diff --git a/eeschema/widgets/symbol_diff_widget.cpp b/eeschema/widgets/symbol_diff_widget.cpp new file mode 100644 index 0000000000..87182973bd --- /dev/null +++ b/eeschema/widgets/symbol_diff_widget.cpp @@ -0,0 +1,166 @@ +/* + * 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 3 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, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include + + +SYMBOL_DIFF_WIDGET::SYMBOL_DIFF_WIDGET( wxWindow* aParent, + EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) : + SYMBOL_PREVIEW_WIDGET( aParent, nullptr, aCanvasType ), + m_libraryItem( nullptr ), + m_slider( nullptr ) +{ + wxBoxSizer* bottomSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxStaticText* schLabel = new wxStaticText( this, wxID_ANY, _( "Schematic" ) ); + wxStaticText* libLabel = new wxStaticText( this, wxID_ANY, _( "Library" ) ); + m_slider = new wxSlider( this, wxID_ANY, 50, 0, 100 ); + + bottomSizer->Add( schLabel, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxALIGN_CENTRE_VERTICAL, 8 ); + bottomSizer->Add( m_slider, 1, wxLEFT | wxRIGHT | wxALIGN_BOTTOM, 30 ); + bottomSizer->Add( libLabel, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxALIGN_CENTRE_VERTICAL, 8 ); + + m_outerSizer->Add( bottomSizer, 0, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, 10 ); + + Layout(); + + m_slider->Bind( wxEVT_SCROLL_TOP, &SYMBOL_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_BOTTOM, &SYMBOL_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_LINEUP, &SYMBOL_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_LINEDOWN, &SYMBOL_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_PAGEUP, &SYMBOL_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_PAGEDOWN, &SYMBOL_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_THUMBTRACK, &SYMBOL_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_THUMBRELEASE, &SYMBOL_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_CHANGED, &SYMBOL_DIFF_WIDGET::onSlider, this ); +} + + +SYMBOL_DIFF_WIDGET::~SYMBOL_DIFF_WIDGET() +{ + delete m_libraryItem; +} + + +void SYMBOL_DIFF_WIDGET::DisplayDiff( LIB_SYMBOL* aSchSymbol, LIB_SYMBOL* aLibSymbol, int aUnit, + int aConvert ) +{ + KIGFX::VIEW* view = m_preview->GetView(); + + if( m_previewItem ) + { + view->Remove( m_previewItem ); + delete m_previewItem; + m_previewItem = nullptr; + + wxASSERT( m_libraryItem ); + + view->Remove( m_libraryItem ); + delete m_libraryItem; + m_libraryItem = nullptr; + } + + if( aSchSymbol ) + { + m_previewItem = aSchSymbol; + + // For symbols having a De Morgan body style, use the first style + auto settings = + static_cast( view->GetPainter()->GetSettings() ); + + settings->m_ShowUnit = ( m_previewItem->IsMulti() && !aUnit ) ? 1 : aUnit; + settings->m_ShowConvert = ( m_previewItem->HasConversion() && !aConvert ) ? 1 : aConvert; + + view->Add( m_previewItem ); + + // Get the symbol size, in internal units + m_itemBBox = m_previewItem->GetUnitBoundingBox( settings->m_ShowUnit, + settings->m_ShowConvert ); + + // Calculate the draw scale to fit the drawing area + fitOnDrawArea(); + + wxASSERT( aLibSymbol ); + + m_libraryItem = aLibSymbol; + view->Add( m_libraryItem ); + } + + wxScrollEvent dummy; + onSlider( dummy ); + + m_preview->Show(); + Layout(); +} + + +void SYMBOL_DIFF_WIDGET::onSlider( wxScrollEvent& aEvent ) +{ + KIGFX::VIEW* view = m_preview->GetView(); + double pct = (double) m_slider->GetValue() / 100.0; + + if( m_previewItem ) + { + double val; + + if( pct < 0.5 ) + val = 0.0; + else + val = ( pct - 0.5 ) * 2; + + m_previewItem->SetForceTransparency( val ); + view->Update( m_previewItem ); + + for( LIB_ITEM& child : m_previewItem->GetDrawItems() ) + { + child.SetForceTransparency( val ); + view->Update( &child ); + } + } + + if( m_libraryItem ) + { + double val; + + if( pct > 0.5 ) + val = 0.0; + else + val = 1.0 - ( pct * 2 ); + + m_libraryItem->SetForceTransparency( val ); + view->Update( m_libraryItem ); + + for( LIB_ITEM& child : m_libraryItem->GetDrawItems() ) + { + child.SetForceTransparency( val ); + view->Update( &child ); + } + } + + m_preview->ForceRefresh(); + + aEvent.Skip(); +} \ No newline at end of file diff --git a/eeschema/widgets/symbol_diff_widget.h b/eeschema/widgets/symbol_diff_widget.h new file mode 100644 index 0000000000..080b613cc4 --- /dev/null +++ b/eeschema/widgets/symbol_diff_widget.h @@ -0,0 +1,60 @@ +/* + * 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 3 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, see . + */ + +#ifndef SYMBOL_DIFF_WIDGET_H +#define SYMBOL_DIFF_WIDGET_H + +#include +#include +#include +#include + + +class LIB_SYMBOL; +class wxSlider; + + +class SYMBOL_DIFF_WIDGET: public SYMBOL_PREVIEW_WIDGET +{ +public: + /** + * Construct a symbol diff widget. + * + * @param aParent - parent window + * @param aCanvasType = the type of canvas (GAL_TYPE_OPENGL or GAL_TYPE_CAIRO only) + */ + SYMBOL_DIFF_WIDGET( wxWindow* aParent, EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ); + + ~SYMBOL_DIFF_WIDGET() override; + + /** + * Set the currently displayed symbol. + */ + void DisplayDiff( LIB_SYMBOL* aSchSymbol, LIB_SYMBOL* aLibSymbol, int aUnit, int aConvert ); + +private: + void onSlider( wxScrollEvent& aEvent ); + +private: + LIB_SYMBOL* m_libraryItem; + wxSlider* m_slider; +}; + + +#endif // SYMBOL_DIFF_WIDGET_H diff --git a/eeschema/widgets/symbol_preview_widget.cpp b/eeschema/widgets/symbol_preview_widget.cpp index 54a6096454..d7d2e95ac9 100644 --- a/eeschema/widgets/symbol_preview_widget.cpp +++ b/eeschema/widgets/symbol_preview_widget.cpp @@ -32,11 +32,14 @@ #include -SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway, +SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY* aKiway, EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) : - wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ), - m_kiway( aKiway ), - m_preview( nullptr ), m_status( nullptr ), m_statusSizer( nullptr ), m_previewItem( nullptr ) + wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ), + m_kiway( aKiway ), + m_preview( nullptr ), + m_status( nullptr ), + m_statusSizer( nullptr ), + m_previewItem( nullptr ) { auto common_settings = Pgm().GetCommonSettings(); auto app_settings = Pgm().GetSettingsManager().GetAppSettings(); @@ -175,7 +178,7 @@ void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit, i try { - LIB_SYMBOL* tmp = m_kiway.Prj().SchSymbolLibTable()->LoadSymbol( aSymbolID ); + LIB_SYMBOL* tmp = m_kiway->Prj().SchSymbolLibTable()->LoadSymbol( aSymbolID ); if( tmp ) symbol = tmp->Flatten(); diff --git a/eeschema/widgets/symbol_preview_widget.h b/eeschema/widgets/symbol_preview_widget.h index cf81b447df..e5c99b350d 100644 --- a/eeschema/widgets/symbol_preview_widget.h +++ b/eeschema/widgets/symbol_preview_widget.h @@ -43,7 +43,7 @@ public: * @param aKiway - an active Kiway instance * @param aCanvasType = the type of canvas (GAL_TYPE_OPENGL or GAL_TYPE_CAIRO only) */ - SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway, + SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY* aKiway, EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ); ~SYMBOL_PREVIEW_WIDGET() override; @@ -60,12 +60,12 @@ public: void DisplayPart( LIB_SYMBOL* aSymbol, int aUnit, int aConvert = 0 ); -private: +protected: void onSize( wxSizeEvent& aEvent ); void fitOnDrawArea(); // set the view scale to fit the item on screen and center - KIWAY& m_kiway; + KIWAY* m_kiway; KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions; EDA_DRAW_PANEL_GAL* m_preview; diff --git a/include/dialogs/dialog_constraints_reporter.h b/include/dialogs/dialog_book_reporter.h similarity index 73% rename from include/dialogs/dialog_constraints_reporter.h rename to include/dialogs/dialog_book_reporter.h index 2bac38a278..9d14ce095f 100644 --- a/include/dialogs/dialog_constraints_reporter.h +++ b/include/dialogs/dialog_book_reporter.h @@ -21,32 +21,34 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef DIALOG_CONSTRAINTS_REPORTER_H -#define DIALOG_CONSTRAINTS_REPORTER_H +#ifndef DIALOG_BOOK_REPORTER_H +#define DIALOG_BOOK_REPORTER_H -#include +#include class KIWAY_PLAYER; class WX_HTML_REPORT_BOX; class wxHtmlLinkEvent; -class DIALOG_CONSTRAINTS_REPORTER : public DIALOG_CONSTRAINTS_REPORTER_BASE +class DIALOG_BOOK_REPORTER : public DIALOG_BOOK_REPORTER_BASE { public: - DIALOG_CONSTRAINTS_REPORTER( KIWAY_PLAYER* aParent ); + DIALOG_BOOK_REPORTER( KIWAY_PLAYER* aParent ); void FinishInitialization(); - void OnOK( wxCommandEvent& event ) override + void OnOK( wxCommandEvent& aEvent ) override { Close(); } - void OnErrorLinkClicked( wxHtmlLinkEvent& event ); + void OnErrorLinkClicked( wxHtmlLinkEvent& aEvent ); void DeleteAllPages(); - WX_HTML_REPORT_BOX* AddPage( const wxString& pageTitle ); + WX_HTML_REPORT_BOX* AddHTMLPage( const wxString& aTitle ); + + wxPanel* AddBlankPage( const wxString& aTitle ); int GetPageCount() const; @@ -54,4 +56,4 @@ protected: KIWAY_PLAYER* m_frame; }; -#endif // DIALOG_CONSTRAINTS_REPORTER_H +#endif // DIALOG_BOOK_REPORTER_H diff --git a/include/eda_item.h b/include/eda_item.h index 10beac110d..29973ba17b 100644 --- a/include/eda_item.h +++ b/include/eda_item.h @@ -197,9 +197,11 @@ public: * setting to determine if the item is to be drawn. */ void SetForceVisible( bool aEnable ) { m_forceVisible = aEnable; } - bool IsForceVisible() const { return m_forceVisible; } + void SetForceTransparency( double aTransparency ) { m_forceTransparency = aTransparency; } + double GetForceTransparency() const { return m_forceTransparency; } + /** * Populate \a aList of #MSG_PANEL_ITEM objects with it's internal state for display * purposes. @@ -495,6 +497,7 @@ protected: EDA_ITEM_FLAGS m_status; EDA_ITEM* m_parent; ///< Linked list: Link (parent struct) bool m_forceVisible; + double m_forceTransparency; EDA_ITEM_FLAGS m_flags; private: diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 7f37bd479c..f6636c82e8 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -397,7 +397,7 @@ void PCB_EDIT_FRAME::doReCreateMenuBar() inspectMenu->AppendSeparator(); inspectMenu->Add( PCB_ACTIONS::inspectClearance ); inspectMenu->Add( PCB_ACTIONS::inspectConstraints ); - inspectMenu->Add( PCB_ACTIONS::inspectLibraryDiff ); + inspectMenu->Add( PCB_ACTIONS::diffFootprint ); //-- Tools menu ---------------------------------------------------------- diff --git a/pcbnew/tools/board_inspection_tool.cpp b/pcbnew/tools/board_inspection_tool.cpp index 466db23e19..cbc4808cd0 100644 --- a/pcbnew/tools/board_inspection_tool.cpp +++ b/pcbnew/tools/board_inspection_tool.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -244,7 +244,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR if( m_inspectClearanceDialog == nullptr ) { - m_inspectClearanceDialog = std::make_unique( m_frame ); + m_inspectClearanceDialog = std::make_unique( m_frame ); m_inspectClearanceDialog->SetTitle( _( "Violation Report" ) ); m_inspectClearanceDialog->Connect( wxEVT_CLOSE_WINDOW, @@ -271,7 +271,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR break; } - r = m_inspectClearanceDialog->AddPage( _( "Uncoupled Length" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Uncoupled Length" ) ); reportHeader( _( "Diff pair uncoupled length resolution for:" ), ac, bc, r ); if( compileError ) @@ -286,7 +286,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR } case DRCE_TEXT_HEIGHT: - r = m_inspectClearanceDialog->AddPage( _( "Text Height" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Text Height" ) ); reportHeader( _( "Text height resolution for:" ), a, r ); if( compileError ) @@ -301,7 +301,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR break; case DRCE_TEXT_THICKNESS: - r = m_inspectClearanceDialog->AddPage( _( "Text Thickness" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Text Thickness" ) ); reportHeader( _( "Text thickness resolution for:" ), a, r ); if( compileError ) @@ -316,7 +316,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR break; case DRCE_TRACK_WIDTH: - r = m_inspectClearanceDialog->AddPage( _( "Track Width" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Track Width" ) ); reportHeader( _( "Track width resolution for:" ), a, r ); if( compileError ) @@ -331,7 +331,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR break; case DRCE_CONNECTION_WIDTH: - r = m_inspectClearanceDialog->AddPage( _( "Connection Width" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Connection Width" ) ); reportHeader( _( "Connection width resolution for:" ), a, b, r ); if( compileError ) @@ -345,7 +345,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR break; case DRCE_VIA_DIAMETER: - r = m_inspectClearanceDialog->AddPage( _( "Via Diameter" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Via Diameter" ) ); reportHeader( _( "Via diameter resolution for:" ), a, r ); if( compileError ) @@ -360,7 +360,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR break; case DRCE_ANNULAR_WIDTH: - r = m_inspectClearanceDialog->AddPage( _( "Via Annulus" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Via Annulus" ) ); reportHeader( _( "Via annular width resolution for:" ), a, r ); if( compileError ) @@ -376,7 +376,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR case DRCE_DRILL_OUT_OF_RANGE: case DRCE_MICROVIA_DRILL_OUT_OF_RANGE: - r = m_inspectClearanceDialog->AddPage( _( "Hole Size" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Hole Size" ) ); reportHeader( _( "Hole diameter resolution for:" ), a, r ); if( compileError ) @@ -391,7 +391,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR break; case DRCE_HOLE_CLEARANCE: - r = m_inspectClearanceDialog->AddPage( _( "Hole Clearance" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Hole Clearance" ) ); reportHeader( _( "Hole clearance resolution for:" ), a, b, r ); if( compileError ) @@ -435,7 +435,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR break; case DRCE_DRILLED_HOLES_TOO_CLOSE: - r = m_inspectClearanceDialog->AddPage( _( "Hole to Hole" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Hole to Hole" ) ); reportHeader( _( "Hole to hole clearance resolution for:" ), a, b, r ); if( compileError ) @@ -450,7 +450,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR break; case DRCE_EDGE_CLEARANCE: - r = m_inspectClearanceDialog->AddPage( _( "Edge Clearance" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Edge Clearance" ) ); reportHeader( _( "Edge clearance resolution for:" ), a, b, r ); if( compileError ) @@ -492,7 +492,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR layer = B_Cu; } - r = m_inspectClearanceDialog->AddPage( _( "Clearance" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Clearance" ) ); reportHeader( _( "Clearance resolution for:" ), a, b, layer, r ); if( compileError ) @@ -593,7 +593,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) if( m_inspectClearanceDialog == nullptr ) { - m_inspectClearanceDialog = std::make_unique( m_frame ); + m_inspectClearanceDialog = std::make_unique( m_frame ); m_inspectClearanceDialog->SetTitle( _( "Clearance Report" ) ); m_inspectClearanceDialog->Connect( wxEVT_CLOSE_WINDOW, @@ -633,7 +633,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) else if( zone->GetLayerSet().count() > 0 ) layer = zone->GetLayerSet().Seq().front(); - r = m_inspectClearanceDialog->AddPage( _( "Zone" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Zone" ) ); reportHeader( _( "Zone connection resolution for:" ), a, b, layer, r ); constraint = drcEngine.EvalZoneConnection( pad, zone, layer, r ); @@ -756,7 +756,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) if( !copperIntersection.test( layer ) ) layer = copperIntersection.Seq().front(); - r = m_inspectClearanceDialog->AddPage( m_frame->GetBoard()->GetLayerName( layer ) ); + r = m_inspectClearanceDialog->AddHTMLPage( m_frame->GetBoard()->GetLayerName( layer ) ); reportHeader( _( "Clearance resolution for:" ), a, b, layer, r ); if( ac && bc && ac->GetNetCode() > 0 && ac->GetNetCode() == bc->GetNetCode() ) @@ -799,7 +799,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) if( DRC_ENGINE::MatchDpSuffix( refNet->GetNetname(), coupledNet, dummy ) && bc->GetNetname() == coupledNet ) { - r = m_inspectClearanceDialog->AddPage( _( "Diff Pair" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Diff Pair" ) ); reportHeader( _( "Diff pair gap resolution for:" ), ac, bc, active, r ); constraint = drcEngine.EvalRules( DIFF_PAIR_GAP_CONSTRAINT, ac, bc, active, r ); @@ -866,7 +866,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) if( ( a->IsOnLayer( layer ) && isOnCorrespondingLayer( b, layer, &warning ) ) || ( b->IsOnLayer( layer ) && isOnCorrespondingLayer( a, layer, &warning ) ) ) { - r = m_inspectClearanceDialog->AddPage( m_frame->GetBoard()->GetLayerName( layer ) ); + r = m_inspectClearanceDialog->AddHTMLPage( m_frame->GetBoard()->GetLayerName( layer ) ); reportHeader( _( "Silkscreen clearance resolution for:" ), a, b, layer, r ); constraint = drcEngine.EvalRules( SILK_CLEARANCE_CONSTRAINT, a, b, layer, r ); @@ -894,7 +894,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) if( aCourtyard && bCourtyard ) { - r = m_inspectClearanceDialog->AddPage( m_frame->GetBoard()->GetLayerName( layer ) ); + r = m_inspectClearanceDialog->AddHTMLPage( m_frame->GetBoard()->GetLayerName( layer ) ); reportHeader( _( "Courtyard clearance resolution for:" ), a, b, layer, r ); constraint = drcEngine.EvalRules( COURTYARD_CLEARANCE_CONSTRAINT, a, b, layer, r ); @@ -929,7 +929,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) { if( !pageAdded ) { - r = m_inspectClearanceDialog->AddPage( _( "Hole" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Hole" ) ); pageAdded = true; } else @@ -958,7 +958,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) { if( !pageAdded ) { - r = m_inspectClearanceDialog->AddPage( _( "Hole" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Hole" ) ); pageAdded = true; } else @@ -1006,7 +1006,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) if( layer >= 0 ) { wxString layerName = m_frame->GetBoard()->GetLayerName( edgeLayer ); - r = m_inspectClearanceDialog->AddPage( layerName + wxS( " " ) + _( "Clearance" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( layerName + wxS( " " ) + _( "Clearance" ) ); reportHeader( _( "Edge clearance resolution for:" ), a, b, layer, r ); constraint = drcEngine.EvalRules( EDGE_CLEARANCE_CONSTRAINT, a, b, layer, r ); @@ -1023,7 +1023,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) } } - r = m_inspectClearanceDialog->AddPage( _( "Physical Clearances" ) ); + r = m_inspectClearanceDialog->AddHTMLPage( _( "Physical Clearances" ) ); auto reportPhysicalClearance = [&]( PCB_LAYER_ID aLayer ) @@ -1139,7 +1139,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) if( m_inspectConstraintsDialog == nullptr ) { - m_inspectConstraintsDialog = std::make_unique( m_frame ); + m_inspectConstraintsDialog = std::make_unique( m_frame ); m_inspectConstraintsDialog->SetTitle( _( "Constraints Report" ) ); m_inspectConstraintsDialog->Connect( wxEVT_CLOSE_WINDOW, @@ -1159,7 +1159,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) if( item->Type() == PCB_TRACE_T ) { - r = m_inspectConstraintsDialog->AddPage( _( "Track Width" ) ); + r = m_inspectConstraintsDialog->AddHTMLPage( _( "Track Width" ) ); reportHeader( _( "Track width resolution for:" ), item, r ); constraint = EVAL_RULES( TRACK_WIDTH_CONSTRAINT, item, nullptr, item->GetLayer(), r ); @@ -1178,7 +1178,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) if( item->Type() == PCB_VIA_T ) { - r = m_inspectConstraintsDialog->AddPage( _( "Via Diameter" ) ); + r = m_inspectConstraintsDialog->AddHTMLPage( _( "Via Diameter" ) ); reportHeader( _( "Via diameter resolution for:" ), item, r ); // PADSTACKS TODO: once we have padstacks we'll need to run this per-layer.... @@ -1195,7 +1195,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) r->Flush(); - r = m_inspectConstraintsDialog->AddPage( _( "Via Annular Width" ) ); + r = m_inspectConstraintsDialog->AddHTMLPage( _( "Via Annular Width" ) ); reportHeader( _( "Via annular width resolution for:" ), item, r ); // PADSTACKS TODO: once we have padstacks we'll need to run this per-layer.... @@ -1216,7 +1216,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) if( ( item->Type() == PCB_PAD_T && static_cast( item )->GetDrillSize().x > 0 ) || item->Type() == PCB_VIA_T ) { - r = m_inspectConstraintsDialog->AddPage( _( "Hole Size" ) ); + r = m_inspectConstraintsDialog->AddHTMLPage( _( "Hole Size" ) ); reportHeader( _( "Hole diameter resolution for:" ), item, r ); // PADSTACKS TODO: once we have padstacks we'll need to run this per-layer.... @@ -1238,7 +1238,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) || item->Type() == PCB_TEXTBOX_T || item->Type() == PCB_FP_TEXT_T ) { - r = m_inspectConstraintsDialog->AddPage( _( "Text Size" ) ); + r = m_inspectConstraintsDialog->AddHTMLPage( _( "Text Size" ) ); reportHeader( _( "Text height resolution for:" ), item, r ); constraint = EVAL_RULES( TEXT_HEIGHT_CONSTRAINT, item, nullptr, UNDEFINED_LAYER, r ); @@ -1271,7 +1271,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) r->Flush(); } - r = m_inspectConstraintsDialog->AddPage( _( "Keepouts" ) ); + r = m_inspectConstraintsDialog->AddHTMLPage( _( "Keepouts" ) ); reportHeader( _( "Keepout resolution for:" ), item, r ); constraint = EVAL_RULES( DISALLOW_CONSTRAINT, item, nullptr, item->GetLayer(), r ); @@ -1296,7 +1296,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) r->Flush(); - r = m_inspectConstraintsDialog->AddPage( _( "Assertions" ) ); + r = m_inspectConstraintsDialog->AddHTMLPage( _( "Assertions" ) ); reportHeader( _( "Assertions for:" ), item, r ); if( compileError ) @@ -1320,7 +1320,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) } -int BOARD_INSPECTION_TOOL::InspectLibraryDiff( const TOOL_EVENT& aEvent ) +int BOARD_INSPECTION_TOOL::DiffFootprint( const TOOL_EVENT& aEvent ) { PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); const PCB_SELECTION& selection = selTool->RequestSelection( @@ -1343,17 +1343,17 @@ int BOARD_INSPECTION_TOOL::InspectLibraryDiff( const TOOL_EVENT& aEvent ) return 0; } - if( m_inspectLibraryDiffDialog == nullptr ) + if( m_diffFootprintDialog == nullptr ) { - m_inspectLibraryDiffDialog = std::make_unique( m_frame ); - m_inspectLibraryDiffDialog->SetTitle( _( "Diff Footprint with Library" ) ); + m_diffFootprintDialog = std::make_unique( m_frame ); + m_diffFootprintDialog->SetTitle( _( "Diff Footprint with Library" ) ); - m_inspectLibraryDiffDialog->Connect( wxEVT_CLOSE_WINDOW, - wxCommandEventHandler( BOARD_INSPECTION_TOOL::onInspectLibraryDiffDialogClosed ), + m_diffFootprintDialog->Connect( wxEVT_CLOSE_WINDOW, + wxCommandEventHandler( BOARD_INSPECTION_TOOL::onDiffFootprintDialogClosed ), nullptr, this ); } - m_inspectLibraryDiffDialog->DeleteAllPages(); + m_diffFootprintDialog->DeleteAllPages(); FOOTPRINT* footprint = static_cast( selection.GetItem( 0 ) ); LIB_ID fpID = footprint->GetFPID(); @@ -1361,7 +1361,7 @@ int BOARD_INSPECTION_TOOL::InspectLibraryDiff( const TOOL_EVENT& aEvent ) wxString fpName = fpID.GetLibItemName(); WX_HTML_REPORT_BOX* r = nullptr; - r = m_inspectLibraryDiffDialog->AddPage( _( "Summary" ) ); + r = m_diffFootprintDialog->AddHTMLPage( _( "Summary" ) ); r->Report( wxS( "" ) + _( "Board vs library diff for:" ) + wxS( "" ) ); r->Report( wxS( "
    • " ) + EscapeHTML( getItemDescription( footprint ) ) + wxS( "
    • " ) @@ -1421,9 +1421,9 @@ int BOARD_INSPECTION_TOOL::InspectLibraryDiff( const TOOL_EVENT& aEvent ) r->Flush(); - m_inspectLibraryDiffDialog->FinishInitialization(); - m_inspectLibraryDiffDialog->Raise(); - m_inspectLibraryDiffDialog->Show( true ); + m_diffFootprintDialog->FinishInitialization(); + m_diffFootprintDialog->Raise(); + m_diffFootprintDialog->Show( true ); return 0; } @@ -1907,14 +1907,14 @@ void BOARD_INSPECTION_TOOL::onInspectConstraintsDialogClosed( wxCommandEvent& ev } -void BOARD_INSPECTION_TOOL::onInspectLibraryDiffDialogClosed( wxCommandEvent& event ) +void BOARD_INSPECTION_TOOL::onDiffFootprintDialogClosed( wxCommandEvent& event ) { - m_inspectLibraryDiffDialog->Disconnect( wxEVT_CLOSE_WINDOW, - wxCommandEventHandler( BOARD_INSPECTION_TOOL::onInspectLibraryDiffDialogClosed ), - nullptr, this ); + m_diffFootprintDialog->Disconnect( wxEVT_CLOSE_WINDOW, + wxCommandEventHandler( BOARD_INSPECTION_TOOL::onDiffFootprintDialogClosed ), + nullptr, this ); - m_inspectLibraryDiffDialog->Destroy(); - m_inspectLibraryDiffDialog.release(); + m_diffFootprintDialog->Destroy(); + m_diffFootprintDialog.release(); } @@ -1976,7 +1976,7 @@ void BOARD_INSPECTION_TOOL::setTransitions() Go( &BOARD_INSPECTION_TOOL::ShowBoardStatistics, PCB_ACTIONS::boardStatistics.MakeEvent() ); Go( &BOARD_INSPECTION_TOOL::InspectClearance, PCB_ACTIONS::inspectClearance.MakeEvent() ); Go( &BOARD_INSPECTION_TOOL::InspectConstraints, PCB_ACTIONS::inspectConstraints.MakeEvent() ); - Go( &BOARD_INSPECTION_TOOL::InspectLibraryDiff, PCB_ACTIONS::inspectLibraryDiff.MakeEvent() ); + Go( &BOARD_INSPECTION_TOOL::DiffFootprint, PCB_ACTIONS::diffFootprint.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 c4c8d8b656..785d13c346 100644 --- a/pcbnew/tools/board_inspection_tool.h +++ b/pcbnew/tools/board_inspection_tool.h @@ -25,7 +25,7 @@ #define BOARD_INSPECTION_TOOL_H #include -#include +#include #include #include #include @@ -88,7 +88,7 @@ public: int InspectConstraints( const TOOL_EVENT& aEvent ); - int InspectLibraryDiff( const TOOL_EVENT& aEvent ); + int DiffFootprint( const TOOL_EVENT& aEvent ); /** * @return true if a net or nets to highlight have been set @@ -119,7 +119,7 @@ private: void onListNetsDialogClosed( wxCommandEvent& aEvent ); void onInspectClearanceDialogClosed( wxCommandEvent& aEvent ); void onInspectConstraintsDialogClosed( wxCommandEvent& aEvent ); - void onInspectLibraryDiffDialogClosed( wxCommandEvent& aEvent ); + void onDiffFootprintDialogClosed( wxCommandEvent& event ); DRC_ENGINE makeDRCEngine( bool* aCompileError, bool* aCourtyardError = nullptr ); @@ -139,12 +139,12 @@ private: CONNECTIVITY_DATA* m_dynamicData; // Cached connectivity data from the selection - std::unique_ptr m_listNetsDialog; - DIALOG_NET_INSPECTOR::SETTINGS m_listNetsDialogSettings; + std::unique_ptr m_listNetsDialog; + DIALOG_NET_INSPECTOR::SETTINGS m_listNetsDialogSettings; - std::unique_ptr m_inspectClearanceDialog; - std::unique_ptr m_inspectConstraintsDialog; - std::unique_ptr m_inspectLibraryDiffDialog; + std::unique_ptr m_inspectClearanceDialog; + std::unique_ptr m_inspectConstraintsDialog; + std::unique_ptr m_diffFootprintDialog; }; #endif //BOARD_INSPECTION_TOOL_H diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index a3e64c9d4d..22a6072cc1 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -1173,7 +1173,7 @@ TOOL_ACTION PCB_ACTIONS::inspectConstraints( "pcbnew.InspectionTool.InspectConst _( "Show constraints resolution for the selected object" ), BITMAPS::mw_add_gap ); -TOOL_ACTION PCB_ACTIONS::inspectLibraryDiff( "pcbnew.InspectionTool.InspectLibraryDiff", +TOOL_ACTION PCB_ACTIONS::diffFootprint( "pcbnew.InspectionTool.DiffFootprint", AS_GLOBAL, 0, "", _( "Diff Footprint with Library..." ), _( "Check for differences between board footprint and its library equivalent" ), diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 2087607434..5a3d2c00dc 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -491,7 +491,7 @@ public: static TOOL_ACTION repairFootprint; static TOOL_ACTION inspectClearance; static TOOL_ACTION inspectConstraints; - static TOOL_ACTION inspectLibraryDiff; + static TOOL_ACTION diffFootprint; // Appearance controls static TOOL_ACTION clearHighlight; // Turns off highlight and resets previous highlight