From 3c5a4a35056f68cd98daf8655d613345fe978f47 Mon Sep 17 00:00:00 2001 From: Simon Richter Date: Wed, 13 Jan 2016 14:17:54 -0500 Subject: [PATCH] Add pin number summary Below the pin table, display which pins are currently defined, in order to find gaps. --- .../dialogs/dialog_lib_edit_pin_table.cpp | 27 ++++++ eeschema/dialogs/dialog_lib_edit_pin_table.h | 2 + .../dialog_lib_edit_pin_table_base.cpp | 3 + .../dialog_lib_edit_pin_table_base.fbp | 91 +++++++++++++++++++ .../dialogs/dialog_lib_edit_pin_table_base.h | 2 + eeschema/pin_number.cpp | 21 +++++ eeschema/pin_number.h | 2 + 7 files changed, 148 insertions(+) diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index 68a66cad8b..4d8d676499 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -43,6 +43,8 @@ public: void CalculateGrouping(); void Refresh(); + PinNumbers GetAllPinNumbers(); + #ifdef REASSOCIATE_HACK void SetWidget( wxDataViewCtrl* aWidget ) { m_Widget = aWidget; } #endif @@ -176,6 +178,8 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( wxWindow* parent, m_Pins->AppendColumn( col2 ); m_Pins->AppendColumn( col3 ); + UpdateSummary(); + GetSizer()->SetSizeHints(this); Centre(); } @@ -186,6 +190,14 @@ DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE() } +void DIALOG_LIB_EDIT_PIN_TABLE::UpdateSummary() +{ + PinNumbers pins = m_Model->GetAllPinNumbers(); + + m_Summary->SetValue( pins.GetSummary() ); +} + + void DIALOG_LIB_EDIT_PIN_TABLE::OnColumnHeaderRightClicked( wxDataViewEvent& event ) { m_Model->SetGroupingColumn( event.GetDataViewColumn()->GetModelColumn() ); @@ -377,6 +389,21 @@ void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Refresh() } +PinNumbers DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::GetAllPinNumbers() +{ + PinNumbers ret; + + for( std::list::const_iterator i = m_Pins.begin(); i != m_Pins.end(); ++i ) + { + wxVariant var; + i->GetValue( var, PIN_NUMBER ); + ret.insert( var.GetString() ); + } + + return ret; +} + + void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Group::GetValue( wxVariant& aValue, unsigned int aCol ) const { diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.h b/eeschema/dialogs/dialog_lib_edit_pin_table.h index 345a77c3fa..868c4531b3 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.h +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.h @@ -9,6 +9,8 @@ public: DIALOG_LIB_EDIT_PIN_TABLE( wxWindow* parent, LIB_PART& aPart ); ~DIALOG_LIB_EDIT_PIN_TABLE(); + void UpdateSummary(); + virtual void OnColumnHeaderRightClicked( wxDataViewEvent& aEvent ); private: diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp index 3e82df548a..d617af6af8 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp @@ -21,6 +21,9 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent top_sizer->Add( m_Pins, 1, wxALL|wxEXPAND, 5 ); + m_Summary = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxNO_BORDER ); + top_sizer->Add( m_Summary, 0, wxALL|wxEXPAND, 5 ); + m_Buttons = new wxStdDialogButtonSizer(); m_ButtonsOK = new wxButton( this, wxID_OK ); m_Buttons->AddButton( m_ButtonsOK ); diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp b/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp index b618c106d7..b41061947c 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp @@ -161,6 +161,97 @@ + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_Summary + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_READONLY + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + wxNO_BORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxEXPAND|wxALL diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table_base.h b/eeschema/dialogs/dialog_lib_edit_pin_table_base.h index 5763e40368..1b229a593e 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.h +++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.h @@ -20,6 +20,7 @@ class DIALOG_SHIM; #include #include #include +#include #include #include #include @@ -36,6 +37,7 @@ class DIALOG_LIB_EDIT_PIN_TABLE_BASE : public DIALOG_SHIM protected: wxDataViewCtrl* m_Pins; + wxTextCtrl* m_Summary; wxStdDialogButtonSizer* m_Buttons; wxButton* m_ButtonsOK; diff --git a/eeschema/pin_number.cpp b/eeschema/pin_number.cpp index 9f5f9eace8..dd98f92ec9 100644 --- a/eeschema/pin_number.cpp +++ b/eeschema/pin_number.cpp @@ -67,6 +67,27 @@ wxString GetNextComponent( const wxString& str, wxString::size_type& cursor ) } +wxString PinNumbers::GetSummary() const +{ + wxString ret; + + const_iterator i = begin(); + if( i == end() ) + return ret; + + ret = *i; + ++i; + + for( ; i != end(); ++i ) + { + ret += ','; + ret += *i; + } + + return ret; +} + + int PinNumbers::Compare( const PinNumber& lhs, const PinNumber& rhs ) { wxString::size_type cursor1 = 0; diff --git a/eeschema/pin_number.h b/eeschema/pin_number.h index d1e9c6f06e..0db3d6f345 100644 --- a/eeschema/pin_number.h +++ b/eeschema/pin_number.h @@ -34,6 +34,8 @@ typedef wxString PinNumber; class PinNumbers { public: + wxString GetSummary() const; + static int Compare( PinNumber const &lhs, PinNumber const &rhs ); private: