From 357427d803d78cac1a554c178f036252ef77e5d7 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 10 Mar 2023 17:15:40 +0000 Subject: [PATCH] Graphical diff for board vs library footprints. Fixes https://gitlab.com/kicad/code/kicad/issues/13736 --- common/CMakeLists.txt | 3 +- common/draw_panel_gal.cpp | 5 +- common/widgets/footprint_diff_widget.cpp | 127 ++++++++++++++++++ common/widgets/footprint_preview_widget.cpp | 16 ++- eeschema/widgets/symbol_diff_widget.cpp | 4 +- eeschema/widgets/symbol_diff_widget.h | 6 +- include/widgets/footprint_diff_widget.h | 57 ++++++++ include/widgets/footprint_preview_widget.h | 25 +++- .../drc/drc_test_provider_library_parity.cpp | 6 +- pcbnew/footprint_preview_panel.cpp | 101 +++++++++++--- pcbnew/footprint_preview_panel.h | 9 +- pcbnew/pcb_painter.cpp | 3 + pcbnew/tools/board_inspection_tool.cpp | 25 +++- pcbnew/tools/board_inspection_tool.h | 3 + 14 files changed, 351 insertions(+), 39 deletions(-) create mode 100644 common/widgets/footprint_diff_widget.cpp create mode 100644 include/widgets/footprint_diff_widget.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 687e9a5e2a..7c648a88c5 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -169,10 +169,10 @@ set( COMMON_WIDGET_SRCS widgets/bitmap_button.cpp widgets/bitmap_toggle.cpp widgets/button_row_panel.cpp - widgets/wx_collapsible_pane.cpp widgets/color_swatch.cpp widgets/font_choice.cpp widgets/footprint_choice.cpp + widgets/footprint_diff_widget.cpp widgets/footprint_preview_widget.cpp widgets/footprint_select_widget.cpp widgets/gal_options_panel.cpp @@ -206,6 +206,7 @@ set( COMMON_WIDGET_SRCS widgets/wx_aui_art_providers.cpp widgets/wx_aui_utils.cpp widgets/wx_busy_indicator.cpp + widgets/wx_collapsible_pane.cpp widgets/wx_combobox.cpp widgets/wx_ellipsized_static_text.cpp widgets/wx_grid.cpp diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index 74681723e7..99e07a43a9 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2017 CERN - * Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2013-2023 KiCad Developers, see AUTHORS.txt for contributors. * * @author Tomasz Wlostowski * @author Maciej Suminski @@ -361,7 +361,8 @@ void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent ) if( m_view ) bottom = m_view->ToWorld( m_gal->GetScreenPixelSize(), true ); - m_gal->ResizeScreen( clientSize.GetX(), clientSize.GetY() ); + // Note: ( +1, +1 ) prevents an ugly black line on right and bottom (at least on Mac) + m_gal->ResizeScreen( clientSize.GetX() + 1, clientSize.GetY() + 1 ); if( m_view ) { diff --git a/common/widgets/footprint_diff_widget.cpp b/common/widgets/footprint_diff_widget.cpp new file mode 100644 index 0000000000..a44cdf2e01 --- /dev/null +++ b/common/widgets/footprint_diff_widget.cpp @@ -0,0 +1,127 @@ +/* + * 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 + + +FOOTPRINT_DIFF_WIDGET::FOOTPRINT_DIFF_WIDGET( wxWindow* aParent, KIWAY& aKiway ) : + FOOTPRINT_PREVIEW_WIDGET( aParent, aKiway ), + m_libraryItem( nullptr ), + m_slider( nullptr ) +{ + wxBoxSizer* bottomSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxStaticText* schLabel = new wxStaticText( this, wxID_ANY, _( "Board" ) ); + 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, 6 ); + bottomSizer->Add( m_slider, 1, wxLEFT | wxRIGHT | wxALIGN_BOTTOM, 30 ); + bottomSizer->Add( libLabel, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxALIGN_CENTRE_VERTICAL, 6 ); + + m_outerSizer->Add( bottomSizer, 0, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, 10 ); + + Layout(); + + m_slider->Bind( wxEVT_SCROLL_TOP, &FOOTPRINT_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_BOTTOM, &FOOTPRINT_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_LINEUP, &FOOTPRINT_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_LINEDOWN, &FOOTPRINT_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_PAGEUP, &FOOTPRINT_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_PAGEDOWN, &FOOTPRINT_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_THUMBTRACK, &FOOTPRINT_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_THUMBRELEASE, &FOOTPRINT_DIFF_WIDGET::onSlider, this ); + m_slider->Bind( wxEVT_SCROLL_CHANGED, &FOOTPRINT_DIFF_WIDGET::onSlider, this ); +} + + +void FOOTPRINT_DIFF_WIDGET::DisplayDiff( FOOTPRINT* aBoardFootprint, + std::shared_ptr& aLibFootprint ) +{ + m_boardItemCopy.reset( static_cast( aBoardFootprint->Clone() ) ); + m_boardItemCopy->ClearSelected(); + m_boardItemCopy->ClearBrightened(); + + m_boardItemCopy->RunOnChildren( + [&]( BOARD_ITEM* child ) + { + child->ClearSelected(); + child->ClearBrightened(); + } ); + + m_boardItemCopy->Move( -m_boardItemCopy->GetPosition() ); + + m_libraryItem = aLibFootprint; + + DisplayFootprints( m_boardItemCopy, m_libraryItem ); + + wxScrollEvent dummy; + onSlider( dummy ); +} + + +void FOOTPRINT_DIFF_WIDGET::onSlider( wxScrollEvent& aEvent ) +{ + double pct = (double) m_slider->GetValue() / 100.0; + + if( m_boardItemCopy ) + { + double val; + + if( pct < 0.5 ) + val = 0.0; + else + val = ( pct - 0.5 ) * 2; + + m_boardItemCopy->SetForceTransparency( val ); + + m_boardItemCopy->RunOnChildren( + [&]( BOARD_ITEM* child ) + { + child->SetForceTransparency( val ); + } ); + } + + if( m_libraryItem ) + { + double val; + + if( pct > 0.5 ) + val = 0.0; + else + val = 1.0 - ( pct * 2 ); + + m_libraryItem->SetForceTransparency( val ); + + m_libraryItem->RunOnChildren( + [&]( BOARD_ITEM* child ) + { + child->SetForceTransparency( val ); + } ); + } + + RefreshAll(); + aEvent.Skip(); +} \ No newline at end of file diff --git a/common/widgets/footprint_preview_widget.cpp b/common/widgets/footprint_preview_widget.cpp index 8544df81c5..342c0a3b0f 100644 --- a/common/widgets/footprint_preview_widget.cpp +++ b/common/widgets/footprint_preview_widget.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2017 Chris Pavlina * * This program is free software: you can redistribute it and/or modify it @@ -112,6 +112,20 @@ void FOOTPRINT_PREVIEW_WIDGET::DisplayFootprint( const LIB_ID& aFPID ) } +void FOOTPRINT_PREVIEW_WIDGET::DisplayFootprints( std::shared_ptr aFootprintA, + std::shared_ptr aFootprintB ) +{ + ClearStatus(); + m_prev_panel->DisplayFootprints( aFootprintA, aFootprintB ); +} + + +void FOOTPRINT_PREVIEW_WIDGET::RefreshAll() +{ + m_prev_panel->RefreshAll(); +} + + FOOTPRINT_PREVIEW_PANEL_BASE* FOOTPRINT_PREVIEW_PANEL_BASE::Create( wxWindow* aParent, KIWAY& aKiway ) { diff --git a/eeschema/widgets/symbol_diff_widget.cpp b/eeschema/widgets/symbol_diff_widget.cpp index 87182973bd..c26f176652 100644 --- a/eeschema/widgets/symbol_diff_widget.cpp +++ b/eeschema/widgets/symbol_diff_widget.cpp @@ -39,9 +39,9 @@ SYMBOL_DIFF_WIDGET::SYMBOL_DIFF_WIDGET( wxWindow* aParent, 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( schLabel, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxALIGN_CENTRE_VERTICAL, 6 ); bottomSizer->Add( m_slider, 1, wxLEFT | wxRIGHT | wxALIGN_BOTTOM, 30 ); - bottomSizer->Add( libLabel, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxALIGN_CENTRE_VERTICAL, 8 ); + bottomSizer->Add( libLabel, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxALIGN_CENTRE_VERTICAL, 6 ); m_outerSizer->Add( bottomSizer, 0, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, 10 ); diff --git a/eeschema/widgets/symbol_diff_widget.h b/eeschema/widgets/symbol_diff_widget.h index 080b613cc4..7aa82d37ae 100644 --- a/eeschema/widgets/symbol_diff_widget.h +++ b/eeschema/widgets/symbol_diff_widget.h @@ -20,9 +20,6 @@ #ifndef SYMBOL_DIFF_WIDGET_H #define SYMBOL_DIFF_WIDGET_H -#include -#include -#include #include @@ -34,7 +31,8 @@ class SYMBOL_DIFF_WIDGET: public SYMBOL_PREVIEW_WIDGET { public: /** - * Construct a symbol diff widget. + * Construct a symbol diff widget, consisting on a canvas for displaying a schematic and + * a library symbol, and a slider for fading between the two. * * @param aParent - parent window * @param aCanvasType = the type of canvas (GAL_TYPE_OPENGL or GAL_TYPE_CAIRO only) diff --git a/include/widgets/footprint_diff_widget.h b/include/widgets/footprint_diff_widget.h new file mode 100644 index 0000000000..f69f7de5e5 --- /dev/null +++ b/include/widgets/footprint_diff_widget.h @@ -0,0 +1,57 @@ +/* + * 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 FOOTPRINT_DIFF_WIDGET_H +#define FOOTPRINT_DIFF_WIDGET_H + +#include + + +class FOOTPRINT; +class wxSlider; + + +class FOOTPRINT_DIFF_WIDGET: public FOOTPRINT_PREVIEW_WIDGET +{ +public: + /** + * Construct a footprint diff widget, consisting on a canvas for displaying a board and + * a library footprint, and a slider for fading between the two. + * + * @param aParent - parent window + * @param aKiway - an active Kiway instance + */ + FOOTPRINT_DIFF_WIDGET( wxWindow* aParent, KIWAY& aKiway ); + + /** + * Set the currently displayed symbol. + */ + void DisplayDiff( FOOTPRINT* aBoardFootprint, std::shared_ptr& aLibFootprint ); + +private: + void onSlider( wxScrollEvent& aEvent ); + +private: + std::shared_ptr m_boardItemCopy; + std::shared_ptr m_libraryItem; + wxSlider* m_slider; +}; + + +#endif // FOOTPRINT_DIFF_WIDGET_H diff --git a/include/widgets/footprint_preview_widget.h b/include/widgets/footprint_preview_widget.h index e5525373c3..49ec5edc96 100644 --- a/include/widgets/footprint_preview_widget.h +++ b/include/widgets/footprint_preview_widget.h @@ -29,6 +29,7 @@ #include class FOOTPRINT_PREVIEW_PANEL_BASE; +class FOOTPRINT; class KIWAY; class wxStaticText; class wxSizer; @@ -74,7 +75,18 @@ public: */ void DisplayFootprint( const LIB_ID& aFPID ); -private: + /** + * Display a pair of footprints. (Normally used for diff'ing.) + */ + void DisplayFootprints( std::shared_ptr aFootprintA, + std::shared_ptr aFootprintB ); + + /** + * Force the redrawing of all contents. + */ + void RefreshAll(); + +protected: FOOTPRINT_PREVIEW_PANEL_BASE* m_prev_panel; wxStaticText* m_status; @@ -102,6 +114,17 @@ public: */ virtual bool DisplayFootprint( LIB_ID const& aFPID ) = 0; + /** + * Display a pair of footprints. (Normally used for diff'ing.) + */ + virtual void DisplayFootprints( std::shared_ptr aFootprintA, + std::shared_ptr aFootprintB ) = 0; + + /** + * Force the redrawing of all contents. + */ + virtual void RefreshAll() = 0; + /** * Get the underlying wxWindow. */ diff --git a/pcbnew/drc/drc_test_provider_library_parity.cpp b/pcbnew/drc/drc_test_provider_library_parity.cpp index 46b56a8c18..5e14e13d4c 100644 --- a/pcbnew/drc/drc_test_provider_library_parity.cpp +++ b/pcbnew/drc/drc_test_provider_library_parity.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2021-2022 KiCad Developers. + * Copyright (C) 2021-2023 KiCad Developers. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -556,12 +556,12 @@ bool FOOTPRINT::FootprintNeedsUpdate( const FOOTPRINT* aLibFootprint, REPORTER* if( padNeedsUpdate( *aIt, *bIt ) ) { diff = true; - REPORT( wxString::Format( _( "%s differs." ), ITEM_DESC( *aIt ) ) ); + REPORT( wxString::Format( _( "Pad %s differs." ), (*aIt)->GetNumber() ) ); } else if( aReporter && padHasOverrides( *aIt, *bIt ) ) { diff = true; - REPORT( wxString::Format( _( "%s has overrides." ), ITEM_DESC( *aIt ) ) ); + REPORT( wxString::Format( _( "Pad %s has overrides." ), (*aIt)->GetNumber() ) ); } } } diff --git a/pcbnew/footprint_preview_panel.cpp b/pcbnew/footprint_preview_panel.cpp index 8d6033c89b..337195581e 100644 --- a/pcbnew/footprint_preview_panel.cpp +++ b/pcbnew/footprint_preview_panel.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2017 Chris Pavlina * Copyright (C) 2016 Tomasz Wlostowski * @@ -72,6 +72,13 @@ FOOTPRINT_PREVIEW_PANEL::~FOOTPRINT_PREVIEW_PANEL( ) GetView()->Clear(); m_currentFootprint->SetParent( nullptr ); } + + if( m_otherFootprint ) + { + GetView()->Remove( m_otherFootprint.get() ); + GetView()->Clear(); + m_otherFootprint->SetParent( nullptr ); + } } @@ -95,19 +102,7 @@ const COLOR4D& FOOTPRINT_PREVIEW_PANEL::GetForegroundColor() const void FOOTPRINT_PREVIEW_PANEL::renderFootprint( std::shared_ptr aFootprint ) { - if( m_currentFootprint ) - { - GetView()->Remove( m_currentFootprint.get() ); - GetView()->Clear(); - m_currentFootprint->SetParent( nullptr ); - } - - m_currentFootprint = aFootprint; - - if( !m_currentFootprint ) - return; - - m_currentFootprint->SetParent( m_dummyBoard.get() ); + aFootprint->SetParent( m_dummyBoard.get() ); INSPECTOR_FUNC inspector = [&]( EDA_ITEM* descendant, void* aTestData ) @@ -116,20 +111,24 @@ void FOOTPRINT_PREVIEW_PANEL::renderFootprint( std::shared_ptr aFootp return INSPECT_RESULT::CONTINUE; }; - m_currentFootprint->Visit( inspector, nullptr, { PCB_FP_DIM_LEADER_T, - PCB_FP_DIM_ORTHOGONAL_T, - PCB_FP_DIM_CENTER_T, - PCB_FP_DIM_RADIAL_T } ); + aFootprint->Visit( inspector, nullptr, { PCB_FP_DIM_LEADER_T, + PCB_FP_DIM_ORTHOGONAL_T, + PCB_FP_DIM_CENTER_T, + PCB_FP_DIM_RADIAL_T } ); // Ensure we are not using the high contrast mode to display the selected footprint KIGFX::PAINTER* painter = GetView()->GetPainter(); auto settings = static_cast( painter->GetSettings() ); settings->m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL; - GetView()->Add( m_currentFootprint.get() ); - GetView()->SetVisible( m_currentFootprint.get(), true ); - GetView()->Update( m_currentFootprint.get(), KIGFX::ALL ); + GetView()->Add( aFootprint.get() ); + GetView()->SetVisible( aFootprint.get(), true ); + GetView()->Update( aFootprint.get(), KIGFX::ALL ); +} + +void FOOTPRINT_PREVIEW_PANEL::fitToCurrentFootprint() +{ BOX2I bbox = m_currentFootprint->ViewBBox(); bbox.Merge( m_currentFootprint->Value().ViewBBox() ); bbox.Merge( m_currentFootprint->Reference().ViewBBox() ); @@ -149,6 +148,13 @@ void FOOTPRINT_PREVIEW_PANEL::renderFootprint( std::shared_ptr aFootp bool FOOTPRINT_PREVIEW_PANEL::DisplayFootprint( const LIB_ID& aFPID ) { + if( m_currentFootprint ) + { + GetView()->Remove( m_currentFootprint.get() ); + GetView()->Clear(); + m_currentFootprint->SetParent( nullptr ); + } + FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs(); try @@ -166,13 +172,59 @@ bool FOOTPRINT_PREVIEW_PANEL::DisplayFootprint( const LIB_ID& aFPID ) m_currentFootprint.reset(); } - renderFootprint( m_currentFootprint ); + if( m_currentFootprint ) + { + renderFootprint( m_currentFootprint ); + fitToCurrentFootprint(); + } + Refresh(); return m_currentFootprint != nullptr; } +void FOOTPRINT_PREVIEW_PANEL::DisplayFootprints( std::shared_ptr aFootprintA, + std::shared_ptr aFootprintB ) +{ + if( m_currentFootprint ) + { + GetView()->Remove( m_currentFootprint.get() ); + m_currentFootprint->SetParent( nullptr ); + + wxASSERT( m_otherFootprint ); + + GetView()->Remove( m_otherFootprint.get() ); + m_otherFootprint->SetParent( nullptr ); + + GetView()->Clear(); + } + + m_currentFootprint = aFootprintA; + m_otherFootprint = aFootprintB; + + if( m_currentFootprint ) + { + wxASSERT( m_otherFootprint ); + + renderFootprint( m_currentFootprint ); + renderFootprint( m_otherFootprint ); + fitToCurrentFootprint(); + } + + Show(); + Layout(); + RefreshAll(); +} + + +void FOOTPRINT_PREVIEW_PANEL::RefreshAll() +{ + GetView()->UpdateAllItems( KIGFX::REPAINT ); + ForceRefresh(); +} + + wxWindow* FOOTPRINT_PREVIEW_PANEL::GetWindow() { return static_cast( this ); @@ -213,5 +265,10 @@ FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow* gridCfg.sizes[ gridIdx ] ); panel->GetGAL()->SetGridSize( VECTOR2D( gridSize, gridSize ) ); + auto painter = static_cast( panel->GetView()->GetPainter() ); + auto settings = static_cast( painter->GetSettings() ); + settings->SetHighlight( false ); + settings->SetNetColorMode( NET_COLOR_MODE::OFF ); + return panel; } diff --git a/pcbnew/footprint_preview_panel.h b/pcbnew/footprint_preview_panel.h index b1e8aa7fdb..b654b985a1 100644 --- a/pcbnew/footprint_preview_panel.h +++ b/pcbnew/footprint_preview_panel.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2017 Chris Pavlina * Copyright (C) 2016 Tomasz Wlostowski * @@ -55,6 +55,8 @@ public: virtual void SetUserUnits( EDA_UNITS aUnits ) override { m_userUnits = aUnits; } virtual bool DisplayFootprint( const LIB_ID& aFPID ) override; + virtual void DisplayFootprints( std::shared_ptr aFootprintA, + std::shared_ptr aFootprintB ) override; virtual const KIGFX::COLOR4D& GetBackgroundColor() const override; virtual const KIGFX::COLOR4D& GetForegroundColor() const override; @@ -62,6 +64,8 @@ public: virtual wxWindow* GetWindow() override; BOARD* GetBoard() { return m_dummyBoard.get(); } + virtual void RefreshAll() override; + static FOOTPRINT_PREVIEW_PANEL* New( KIWAY* aKiway, wxWindow* aParent ); private: @@ -79,11 +83,14 @@ private: void renderFootprint( std::shared_ptr aFootprint ); + void fitToCurrentFootprint(); + private: std::unique_ptr m_dummyBoard; std::unique_ptr m_displayOptions; EDA_UNITS m_userUnits; std::shared_ptr m_currentFootprint; + std::shared_ptr m_otherFootprint; }; #endif diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 96ff62a6af..ed237d24f8 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -434,6 +434,9 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons else if( item->Type() == PCB_BITMAP_T ) color.a *= m_imageOpacity; + if( item->GetForceTransparency() > 0.0 ) + color = color.WithAlpha( color.a * ( 1.0 - item->GetForceTransparency() ) ); + // No special modifiers enabled return color; } diff --git a/pcbnew/tools/board_inspection_tool.cpp b/pcbnew/tools/board_inspection_tool.cpp index cbc4808cd0..ed0b7087ac 100644 --- a/pcbnew/tools/board_inspection_tool.cpp +++ b/pcbnew/tools/board_inspection_tool.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -1413,9 +1414,15 @@ int BOARD_INSPECTION_TOOL::DiffFootprint( const TOOL_EVENT& aEvent ) r->Report( wxString::Format( _( "The library no longer contains the item %s." ), fpName) ); } - else if( !footprint->FootprintNeedsUpdate( libFootprint.get(), r ) ) + else { - r->Report( _( "No relevant differences detected." ) ); + if( !footprint->FootprintNeedsUpdate( libFootprint.get(), r ) ) + r->Report( _( "No relevant differences detected." ) ); + + wxPanel* panel = m_diffFootprintDialog->AddBlankPage( _( "Visual" ) ); + FOOTPRINT_DIFF_WIDGET* diff = constructDiffPanel( panel ); + + diff->DisplayDiff( footprint, libFootprint ); } } @@ -1428,6 +1435,20 @@ int BOARD_INSPECTION_TOOL::DiffFootprint( const TOOL_EVENT& aEvent ) } +FOOTPRINT_DIFF_WIDGET* BOARD_INSPECTION_TOOL::constructDiffPanel( wxPanel* aParentPanel ) +{ + wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL ); + + FOOTPRINT_DIFF_WIDGET* diffWidget = new FOOTPRINT_DIFF_WIDGET( aParentPanel, m_frame->Kiway() ); + + sizer->Add( diffWidget, 1, wxEXPAND | wxALL, 5 ); + aParentPanel->SetSizer( sizer ); + aParentPanel->Layout(); + + return diffWidget; +} + + int BOARD_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent ) { BOARD_ITEM* item = aEvent.Parameter(); diff --git a/pcbnew/tools/board_inspection_tool.h b/pcbnew/tools/board_inspection_tool.h index 785d13c346..53c7a0182a 100644 --- a/pcbnew/tools/board_inspection_tool.h +++ b/pcbnew/tools/board_inspection_tool.h @@ -34,6 +34,7 @@ #include class CONNECTIVITY_DATA; +class FOOTPRINT_DIFF_WIDGET; /** @@ -131,6 +132,8 @@ private: void reportHeader( const wxString& aTitle, BOARD_ITEM* a, BOARD_ITEM* b, PCB_LAYER_ID aLayer, REPORTER* r ); + FOOTPRINT_DIFF_WIDGET* constructDiffPanel( wxPanel* aParentPanel ); + private: PCB_EDIT_FRAME* m_frame; // Pointer to the currently used edit frame.