Graphical diff for board vs library footprints.
Fixes https://gitlab.com/kicad/code/kicad/issues/13736
This commit is contained in:
parent
56b7d570f9
commit
357427d803
|
@ -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
|
||||
|
|
|
@ -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 <tomasz.wlostowski@cern.ch>
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <widgets/footprint_diff_widget.h>
|
||||
#include <pcb_painter.h>
|
||||
#include <footprint.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/slider.h>
|
||||
|
||||
|
||||
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<FOOTPRINT>& aLibFootprint )
|
||||
{
|
||||
m_boardItemCopy.reset( static_cast<FOOTPRINT*>( 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();
|
||||
}
|
|
@ -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 <pavlina.chris@gmail.com>
|
||||
*
|
||||
* 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<FOOTPRINT> aFootprintA,
|
||||
std::shared_ptr<FOOTPRINT> 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 )
|
||||
{
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
#ifndef SYMBOL_DIFF_WIDGET_H
|
||||
#define SYMBOL_DIFF_WIDGET_H
|
||||
|
||||
#include <wx/panel.h>
|
||||
#include <kiway.h>
|
||||
#include <gal/gal_display_options.h>
|
||||
#include <widgets/symbol_preview_widget.h>
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FOOTPRINT_DIFF_WIDGET_H
|
||||
#define FOOTPRINT_DIFF_WIDGET_H
|
||||
|
||||
#include <widgets/footprint_preview_widget.h>
|
||||
|
||||
|
||||
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<FOOTPRINT>& aLibFootprint );
|
||||
|
||||
private:
|
||||
void onSlider( wxScrollEvent& aEvent );
|
||||
|
||||
private:
|
||||
std::shared_ptr<FOOTPRINT> m_boardItemCopy;
|
||||
std::shared_ptr<FOOTPRINT> m_libraryItem;
|
||||
wxSlider* m_slider;
|
||||
};
|
||||
|
||||
|
||||
#endif // FOOTPRINT_DIFF_WIDGET_H
|
|
@ -29,6 +29,7 @@
|
|||
#include <gal/color4d.h>
|
||||
|
||||
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<FOOTPRINT> aFootprintA,
|
||||
std::shared_ptr<FOOTPRINT> 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<FOOTPRINT> aFootprintA,
|
||||
std::shared_ptr<FOOTPRINT> aFootprintB ) = 0;
|
||||
|
||||
/**
|
||||
* Force the redrawing of all contents.
|
||||
*/
|
||||
virtual void RefreshAll() = 0;
|
||||
|
||||
/**
|
||||
* Get the underlying wxWindow.
|
||||
*/
|
||||
|
|
|
@ -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() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 <pavlina.chris@gmail.com>
|
||||
* Copyright (C) 2016 Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
*
|
||||
|
@ -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<FOOTPRINT> 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<FOOTPRINT> 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<KIGFX::PCB_RENDER_SETTINGS*>( 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<FOOTPRINT> 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<FOOTPRINT> aFootprintA,
|
||||
std::shared_ptr<FOOTPRINT> 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<wxWindow*>( 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<KIGFX::PCB_PAINTER*>( panel->GetView()->GetPainter() );
|
||||
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
||||
settings->SetHighlight( false );
|
||||
settings->SetNetColorMode( NET_COLOR_MODE::OFF );
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
|
|
@ -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 <pavlina.chris@gmail.com>
|
||||
* Copyright (C) 2016 Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
*
|
||||
|
@ -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<FOOTPRINT> aFootprintA,
|
||||
std::shared_ptr<FOOTPRINT> 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<FOOTPRINT> aFootprint );
|
||||
|
||||
void fitToCurrentFootprint();
|
||||
|
||||
private:
|
||||
std::unique_ptr<BOARD> m_dummyBoard;
|
||||
std::unique_ptr<KIGFX::GAL_DISPLAY_OPTIONS> m_displayOptions;
|
||||
EDA_UNITS m_userUnits;
|
||||
std::shared_ptr<FOOTPRINT> m_currentFootprint;
|
||||
std::shared_ptr<FOOTPRINT> m_otherFootprint;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <pcbnew_settings.h>
|
||||
#include <widgets/appearance_controls.h>
|
||||
#include <widgets/wx_html_report_box.h>
|
||||
#include <widgets/footprint_diff_widget.h>
|
||||
#include <drc/drc_item.h>
|
||||
#include <pad.h>
|
||||
|
||||
|
@ -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<BOARD_ITEM*>();
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <tools/pcb_tool_base.h>
|
||||
|
||||
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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue