← Back to team overview

kicad-developers team mailing list archive

[PATCH 4/5] Add pin number summary

 

Below the pin table, display which pins are currently defined, in order to
find gaps.
---
 eeschema/dialogs/dialog_lib_edit_pin_table.cpp     | 27 +++++++
 eeschema/dialogs/dialog_lib_edit_pin_table.h       |  2 +
 .../dialogs/dialog_lib_edit_pin_table_base.cpp     |  3 +
 .../dialogs/dialog_lib_edit_pin_table_base.fbp     | 91 ++++++++++++++++++++++
 eeschema/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 68a66ca..4d8d676 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<Pin>::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 345a77c..868c453 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 3e82df5..d617af6 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 b618c10..b410619 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp
+++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp
@@ -163,6 +163,97 @@
                 </object>
                 <object class="sizeritem" expanded="1">
                     <property name="border">5</property>
+                    <property name="flag">wxALL|wxEXPAND</property>
+                    <property name="proportion">0</property>
+                    <object class="wxTextCtrl" expanded="1">
+                        <property name="BottomDockable">1</property>
+                        <property name="LeftDockable">1</property>
+                        <property name="RightDockable">1</property>
+                        <property name="TopDockable">1</property>
+                        <property name="aui_layer"></property>
+                        <property name="aui_name"></property>
+                        <property name="aui_position"></property>
+                        <property name="aui_row"></property>
+                        <property name="best_size"></property>
+                        <property name="bg"></property>
+                        <property name="caption"></property>
+                        <property name="caption_visible">1</property>
+                        <property name="center_pane">0</property>
+                        <property name="close_button">1</property>
+                        <property name="context_help"></property>
+                        <property name="context_menu">1</property>
+                        <property name="default_pane">0</property>
+                        <property name="dock">Dock</property>
+                        <property name="dock_fixed">0</property>
+                        <property name="docking">Left</property>
+                        <property name="enabled">1</property>
+                        <property name="fg"></property>
+                        <property name="floatable">1</property>
+                        <property name="font"></property>
+                        <property name="gripper">0</property>
+                        <property name="hidden">0</property>
+                        <property name="id">wxID_ANY</property>
+                        <property name="max_size"></property>
+                        <property name="maximize_button">0</property>
+                        <property name="maximum_size"></property>
+                        <property name="maxlength"></property>
+                        <property name="min_size"></property>
+                        <property name="minimize_button">0</property>
+                        <property name="minimum_size"></property>
+                        <property name="moveable">1</property>
+                        <property name="name">m_Summary</property>
+                        <property name="pane_border">1</property>
+                        <property name="pane_position"></property>
+                        <property name="pane_size"></property>
+                        <property name="permission">protected</property>
+                        <property name="pin_button">1</property>
+                        <property name="pos"></property>
+                        <property name="resize">Resizable</property>
+                        <property name="show">1</property>
+                        <property name="size"></property>
+                        <property name="style">wxTE_READONLY</property>
+                        <property name="subclass"></property>
+                        <property name="toolbar_pane">0</property>
+                        <property name="tooltip"></property>
+                        <property name="validator_data_type"></property>
+                        <property name="validator_style">wxFILTER_NONE</property>
+                        <property name="validator_type">wxDefaultValidator</property>
+                        <property name="validator_variable"></property>
+                        <property name="value"></property>
+                        <property name="window_extra_style"></property>
+                        <property name="window_name"></property>
+                        <property name="window_style">wxNO_BORDER</property>
+                        <event name="OnChar"></event>
+                        <event name="OnEnterWindow"></event>
+                        <event name="OnEraseBackground"></event>
+                        <event name="OnKeyDown"></event>
+                        <event name="OnKeyUp"></event>
+                        <event name="OnKillFocus"></event>
+                        <event name="OnLeaveWindow"></event>
+                        <event name="OnLeftDClick"></event>
+                        <event name="OnLeftDown"></event>
+                        <event name="OnLeftUp"></event>
+                        <event name="OnMiddleDClick"></event>
+                        <event name="OnMiddleDown"></event>
+                        <event name="OnMiddleUp"></event>
+                        <event name="OnMotion"></event>
+                        <event name="OnMouseEvents"></event>
+                        <event name="OnMouseWheel"></event>
+                        <event name="OnPaint"></event>
+                        <event name="OnRightDClick"></event>
+                        <event name="OnRightDown"></event>
+                        <event name="OnRightUp"></event>
+                        <event name="OnSetFocus"></event>
+                        <event name="OnSize"></event>
+                        <event name="OnText"></event>
+                        <event name="OnTextEnter"></event>
+                        <event name="OnTextMaxLen"></event>
+                        <event name="OnTextURL"></event>
+                        <event name="OnUpdateUI"></event>
+                    </object>
+                </object>
+                <object class="sizeritem" expanded="1">
+                    <property name="border">5</property>
                     <property name="flag">wxEXPAND|wxALL</property>
                     <property name="proportion">0</property>
                     <object class="wxStdDialogButtonSizer" expanded="1">
diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table_base.h b/eeschema/dialogs/dialog_lib_edit_pin_table_base.h
index 5763e40..1b229a5 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 <wx/colour.h>
 #include <wx/settings.h>
 #include <wx/string.h>
+#include <wx/textctrl.h>
 #include <wx/sizer.h>
 #include <wx/button.h>
 #include <wx/dialog.h>
@@ -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 9f5f9ea..dd98f92 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 d1e9c6f..0db3d6f 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:

Follow ups

References