Graphical diff for schematic vs library symbols.

Fixes https://gitlab.com/kicad/code/kicad/issues/13736
This commit is contained in:
Jeff Young 2023-03-09 17:41:18 +00:00
parent 2d6ab62da4
commit bc0d59801a
30 changed files with 440 additions and 149 deletions

View File

@ -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

View File

@ -21,38 +21,38 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <dialogs/dialog_constraints_reporter.h>
#include <dialogs/dialog_book_reporter.h>
#include <widgets/wx_html_report_box.h>
#include <wx/wxhtml.h>
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();
}

View File

@ -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 );
}

View File

@ -11,13 +11,13 @@
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">dialog_constraints_reporter_base</property>
<property name="file">dialog_book_reporter_base</property>
<property name="first_id">2240</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">DialogConstraintsReporterBase</property>
<property name="name">DialogBookReporterBase</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
@ -45,12 +45,12 @@
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">DIALOG_CONSTRAINTS_REPORTER_BASE</property>
<property name="name">DIALOG_BOOK_REPORTER_BASE</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h; forward_declare</property>
<property name="title">Constraints Resolution Report</property>
<property name="title">Report</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>

View File

@ -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();
};

View File

@ -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;
}

View File

@ -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
)

View File

@ -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 )

View File

@ -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.

View File

@ -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() )

View File

@ -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

View File

@ -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:

View File

@ -274,9 +274,12 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
CHECKPOINT;
std::set<const LIB_ITEM*> aShapes;
std::set<const LIB_ITEM*> aFields;
std::set<const LIB_ITEM*> 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<const LIB_ITEM*, LIB_ITEM::cmp_items> aShapes;
std::set<const LIB_ITEM*> aFields;
std::set<const LIB_ITEM*> 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<const LIB_ITEM*> bShapes;
std::set<const LIB_ITEM*> bFields;
std::set<const LIB_ITEM*> bPins;
std::set<const LIB_ITEM*, LIB_ITEM::cmp_items> bShapes;
std::set<const LIB_ITEM*> bFields;
std::set<const LIB_ITEM*> bPins;
for( auto it = aRhs.m_drawings.begin(); it != aRhs.m_drawings.end(); ++it )
{

View File

@ -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();

View File

@ -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;
}

View File

@ -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 );

View File

@ -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;

View File

@ -42,8 +42,9 @@
#include <project.h>
#include <dialogs/html_message_box.h>
#include <dialogs/dialog_erc.h>
#include <dialogs/dialog_constraints_reporter.h>
#include <dialogs/dialog_book_reporter.h>
#include <widgets/wx_html_report_box.h>
#include <widgets/symbol_diff_widget.h>
#include <math/util.h> // 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<DIALOG_CONSTRAINTS_REPORTER>( m_frame );
m_inspectLibraryDiffDialog->SetTitle( _( "Diff Symbol with Library" ) );
m_diffSymbolDialog = std::make_unique<DIALOG_BOOK_REPORTER>( 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( "<h7>" ) + _( "Schematic vs library diff for:" ) + wxS( "</h7>" ) );
r->Report( wxS( "<ul><li>" ) + EscapeHTML( symbolDesc ) + wxS( "</li>" )
@ -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() );

View File

@ -26,13 +26,14 @@
#define EE_INSPECTION_TOOL_H
#include <tools/ee_tool_base.h>
#include <dialogs/dialog_constraints_reporter.h>
#include <dialogs/dialog_book_reporter.h>
#include <sch_base_frame.h>
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<SCH_BASE_FRAME>
@ -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<DIALOG_CONSTRAINTS_REPORTER> m_inspectLibraryDiffDialog;
DIALOG_ERC* m_ercDialog;
std::unique_ptr<DIALOG_BOOK_REPORTER> m_diffSymbolDialog;
};
#endif /* EE_INSPECTION_TOOL_H */

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <widgets/symbol_diff_widget.h>
#include <sch_painter.h>
#include <eeschema_settings.h>
#include <settings/settings_manager.h>
#include <sch_view.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/slider.h>
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<KIGFX::SCH_RENDER_SETTINGS*>( 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();
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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>
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

View File

@ -32,11 +32,14 @@
#include <wx/stattext.h>
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<EESCHEMA_SETTINGS>();
@ -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();

View File

@ -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;

View File

@ -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 <dialogs/dialog_constraints_reporter_base.h>
#include <dialogs/dialog_book_reporter_base.h>
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

View File

@ -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:

View File

@ -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 ----------------------------------------------------------

View File

@ -31,7 +31,7 @@
#include <connectivity/connectivity_data.h>
#include <drc/drc_engine.h>
#include <dialogs/dialog_board_statistics.h>
#include <dialogs/dialog_constraints_reporter.h>
#include <dialogs/dialog_book_reporter.h>
#include <dialogs/panel_setup_rules_base.h>
#include <string_utils.h>
#include <tools/board_inspection_tool.h>
@ -244,7 +244,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDR
if( m_inspectClearanceDialog == nullptr )
{
m_inspectClearanceDialog = std::make_unique<DIALOG_CONSTRAINTS_REPORTER>( m_frame );
m_inspectClearanceDialog = std::make_unique<DIALOG_BOOK_REPORTER>( 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<RC_ITEM>& 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<RC_ITEM>& 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<RC_ITEM>& 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<RC_ITEM>& 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<RC_ITEM>& 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<RC_ITEM>& 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<RC_ITEM>& 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<RC_ITEM>& 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<RC_ITEM>& 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<RC_ITEM>& 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<RC_ITEM>& 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<RC_ITEM>& 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<DIALOG_CONSTRAINTS_REPORTER>( m_frame );
m_inspectClearanceDialog = std::make_unique<DIALOG_BOOK_REPORTER>( 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<DIALOG_CONSTRAINTS_REPORTER>( m_frame );
m_inspectConstraintsDialog = std::make_unique<DIALOG_BOOK_REPORTER>( 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<PAD*>( 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<PCB_SELECTION_TOOL>();
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<DIALOG_CONSTRAINTS_REPORTER>( m_frame );
m_inspectLibraryDiffDialog->SetTitle( _( "Diff Footprint with Library" ) );
m_diffFootprintDialog = std::make_unique<DIALOG_BOOK_REPORTER>( 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<FOOTPRINT*>( 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( "<h7>" ) + _( "Board vs library diff for:" ) + wxS( "</h7>" ) );
r->Report( wxS( "<ul><li>" ) + EscapeHTML( getItemDescription( footprint ) ) + wxS( "</li>" )
@ -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() );

View File

@ -25,7 +25,7 @@
#define BOARD_INSPECTION_TOOL_H
#include <dialogs/dialog_net_inspector.h>
#include <dialogs/dialog_constraints_reporter.h>
#include <dialogs/dialog_book_reporter.h>
#include <drc/drc_rule.h>
#include <drc/drc_engine.h>
#include <pcb_edit_frame.h>
@ -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<DIALOG_NET_INSPECTOR> m_listNetsDialog;
DIALOG_NET_INSPECTOR::SETTINGS m_listNetsDialogSettings;
std::unique_ptr<DIALOG_NET_INSPECTOR> m_listNetsDialog;
DIALOG_NET_INSPECTOR::SETTINGS m_listNetsDialogSettings;
std::unique_ptr<DIALOG_CONSTRAINTS_REPORTER> m_inspectClearanceDialog;
std::unique_ptr<DIALOG_CONSTRAINTS_REPORTER> m_inspectConstraintsDialog;
std::unique_ptr<DIALOG_CONSTRAINTS_REPORTER> m_inspectLibraryDiffDialog;
std::unique_ptr<DIALOG_BOOK_REPORTER> m_inspectClearanceDialog;
std::unique_ptr<DIALOG_BOOK_REPORTER> m_inspectConstraintsDialog;
std::unique_ptr<DIALOG_BOOK_REPORTER> m_diffFootprintDialog;
};
#endif //BOARD_INSPECTION_TOOL_H

View File

@ -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" ),

View File

@ -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