From ed42f95794c7520de0e04aac4b189e545448f4c8 Mon Sep 17 00:00:00 2001 From: Scott Hanson <9652406-scooter.seh@users.noreply.gitlab.com> Date: Thu, 29 Sep 2022 19:27:08 +0000 Subject: [PATCH] CVPCB: Add warning if footprint is missing --- cvpcb/cvpcb_mainframe.cpp | 20 ++++++++++++++++++++ cvpcb/listboxes.h | 8 ++++++++ cvpcb/readwrite_dlgs.cpp | 8 ++++++++ cvpcb/symbols_listbox.cpp | 33 ++++++++++++++++++++++++++++++++- 4 files changed, 68 insertions(+), 1 deletion(-) diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index 6e3184f02a..0c6a29567b 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -655,6 +655,18 @@ void CVPCB_MAINFRAME::AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation, candidate->GetValue(), candidate->GetFPID().Format().wx_str() ); m_symbolsListBox->SetString( idx, description ); + + FOOTPRINT_INFO* fp = + m_FootprintsList->GetFootprintInfo( symbol->GetFPID().Format().wx_str() ); + + if( !fp ) + { + m_symbolsListBox->AppendWarning( idx ); + } + else + { + m_symbolsListBox->RemoveWarning( idx ); + } } } @@ -1021,6 +1033,14 @@ void CVPCB_MAINFRAME::BuildSymbolsListBox() symbol->GetValue(), symbol->GetFPID().Format().wx_str() ); m_symbolsListBox->m_SymbolList.Add( msg ); + + FOOTPRINT_INFO* fp = + m_FootprintsList->GetFootprintInfo( symbol->GetFPID().Format().wx_str() ); + + if( !fp ) + { + m_symbolsListBox->AppendWarning( i ); + } } if( m_symbolsListBox->m_SymbolList.Count() ) diff --git a/cvpcb/listboxes.h b/cvpcb/listboxes.h index a89bfe2162..8e7799a46e 100644 --- a/cvpcb/listboxes.h +++ b/cvpcb/listboxes.h @@ -26,6 +26,7 @@ #include #include +#include /* Forward declarations of all top-level window classes. */ class CVPCB_MAINFRAME; @@ -192,6 +193,7 @@ public: * because real data is not handled by #ITEMS_LISTBOX_BASE. */ wxString OnGetItemText( long item, long column ) const override; + wxListItemAttr* OnGetItemAttr( long item) const override; /* * Enable or disable an item @@ -199,6 +201,8 @@ public: void SetSelection( int index, bool State = true ); void SetString( unsigned linecount, const wxString& text ); void AppendLine( const wxString& text ); + void AppendWarning( int index ); + void RemoveWarning( int index ); // Events functions: @@ -221,6 +225,10 @@ public: public: wxArrayString m_SymbolList; + +private: + std::vector m_symbolWarning; + std::unique_ptr m_warningAttr; }; diff --git a/cvpcb/readwrite_dlgs.cpp b/cvpcb/readwrite_dlgs.cpp index 6ee285c7ae..bca2849b5b 100644 --- a/cvpcb/readwrite_dlgs.cpp +++ b/cvpcb/readwrite_dlgs.cpp @@ -269,6 +269,14 @@ bool CVPCB_MAINFRAME::readNetListAndFpFiles( const std::string& aNetlist ) FROM_UTF8( component->GetFPID().Format().c_str() ) ); m_symbolsListBox->AppendLine( msg ); + + FOOTPRINT_INFO* fp = + m_FootprintsList->GetFootprintInfo( component->GetFPID().Format().wx_str() ); + + if( !fp ) + { + m_symbolsListBox->AppendWarning( i ); + } } if( !m_netlist.IsEmpty() ) diff --git a/cvpcb/symbols_listbox.cpp b/cvpcb/symbols_listbox.cpp index 509f6394ae..4bd8f101ae 100644 --- a/cvpcb/symbols_listbox.cpp +++ b/cvpcb/symbols_listbox.cpp @@ -34,8 +34,10 @@ SYMBOLS_LISTBOX::SYMBOLS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id ) : - ITEMS_LISTBOX_BASE( parent, id ) + ITEMS_LISTBOX_BASE( parent, id ), + m_warningAttr( std::make_unique() ) { + m_warningAttr->SetBackgroundColour( *wxYELLOW ); } @@ -85,12 +87,41 @@ void SYMBOLS_LISTBOX::AppendLine( const wxString& text ) } +void SYMBOLS_LISTBOX::AppendWarning( int index ) +{ + if( !std::count( m_symbolWarning.begin(), m_symbolWarning.end(), index ) ) + { + m_symbolWarning.emplace_back( index ); + } +} + + +void SYMBOLS_LISTBOX::RemoveWarning( int index ) +{ + if( auto const found{ std::find( m_symbolWarning.begin(), m_symbolWarning.end(), index ) }; + found != m_symbolWarning.end() ) + { + m_symbolWarning.erase( found ); + } +} + + wxString SYMBOLS_LISTBOX::OnGetItemText( long item, long column ) const { return m_SymbolList.Item( item ); } +wxListItemAttr* SYMBOLS_LISTBOX::OnGetItemAttr( long item ) const +{ + if( std::count( m_symbolWarning.begin(), m_symbolWarning.end(), item ) ) + { + return m_warningAttr.get(); + } + return nullptr; +} + + void SYMBOLS_LISTBOX::SetSelection( int index, bool State ) { if( index >= GetCount() )