kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #17447
[PATCH] Add unit number into pin table.
For part with multiple subunits, the unit number is prepended to the pin
name. Common/shared pins are prefixed with "com".
---
eeschema/dialogs/dialog_lib_edit_pin_table.cpp | 45 ++++++++++++++++++++------
eeschema/dialogs/dialog_lib_edit_pin_table.h | 2 +-
eeschema/lib_pin.h | 3 ++
eeschema/libeditframe.cpp | 4 +--
4 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp
index 7421bc3..8c3f808 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp
+++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp
@@ -20,7 +20,7 @@ class DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel :
public wxDataViewModel
{
public:
- DataViewModel( LIB_PINS const& aPins );
+ DataViewModel( LIB_PART& aPart );
// wxDataViewModel
virtual unsigned int GetColumnCount() const;
@@ -54,8 +54,10 @@ public:
};
private:
+ LIB_PART& mPart;
LIB_PINS mBacking;
int mGroupingColumn;
+ int mUnitCount;
class Item;
class Group;
@@ -109,7 +111,8 @@ class DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Pin :
public Item
{
public:
- Pin( LIB_PIN* aBacking ) : mBacking( aBacking ), mGroup( 0 ) {}
+ Pin( DataViewModel& aModel,
+ LIB_PIN* aBacking ) : mModel( aModel ), mBacking( aBacking ), mGroup( 0 ) {}
virtual void GetValue( wxVariant& aValue, unsigned int aCol ) const;
@@ -120,19 +123,20 @@ public:
void SetGroup( Group* aGroup ) { mGroup = aGroup; }
private:
+ DataViewModel& mModel;
LIB_PIN* mBacking;
Group* mGroup;
};
DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( wxWindow* parent,
- LIB_PINS& pins,
+ LIB_PART& aPart,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style ) :
DIALOG_LIB_EDIT_PIN_TABLE_BASE( parent, id, title, pos, size, style ),
- mModel( new DataViewModel( pins ) )
+ mModel( new DataViewModel( aPart ) )
{
#ifdef REASSOCIATE_HACK
mModel->SetWidget( m_pins );
@@ -180,13 +184,15 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnColumnHeaderRightClicked( wxDataViewEvent& eve
}
-DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::DataViewModel( const LIB_PINS& aPins ) :
- mBacking( aPins ),
- mGroupingColumn( 1 )
+DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::DataViewModel( LIB_PART& aPart ) :
+ mPart( aPart ),
+ mGroupingColumn( 1 ),
+ mUnitCount( mPart.GetUnitCount() )
{
+ aPart.GetPins( mBacking );
/// @todo C++11
for( LIB_PINS::const_iterator i = mBacking.begin(); i != mBacking.end(); ++i )
- mPins.push_back( *i );
+ mPins.push_back( Pin( *this, *i ) );
CalculateGrouping();
}
@@ -531,8 +537,27 @@ void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Pin::GetValue( wxVariant& aValue,
break;
case ePinName:
- aValue = mBacking->GetName();
- break;
+ {
+ if( mModel.mUnitCount > 1 )
+ {
+ wxString name;
+ int unit = mBacking->GetPartNumber();
+
+ if( unit )
+ name << unit;
+ else
+ name << "com";
+
+ name << ':';
+ name << mBacking->GetName();
+ aValue = name;
+ }
+ else
+ {
+ aValue = mBacking->GetName();
+ }
+ }
+ break;
case ePinType:
aValue = mBacking->GetTypeString();
diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.h b/eeschema/dialogs/dialog_lib_edit_pin_table.h
index 87e0828..5894563 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin_table.h
+++ b/eeschema/dialogs/dialog_lib_edit_pin_table.h
@@ -7,7 +7,7 @@ class DIALOG_LIB_EDIT_PIN_TABLE :
{
public:
DIALOG_LIB_EDIT_PIN_TABLE( wxWindow* parent,
- LIB_PINS& pins,
+ LIB_PART& aPart,
wxWindowID id = wxID_ANY,
const wxString& title = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h
index 2e17264..e50b692 100644
--- a/eeschema/lib_pin.h
+++ b/eeschema/lib_pin.h
@@ -307,6 +307,9 @@ public:
*/
void SetPartNumber( int aPart );
+ /** Get the pin part number. */
+ int GetPartNumber() const { return m_Unit; }
+
/**
* Set the body style (conversion) of the pin.
*
diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp
index 0ba43bf..a65bc88 100644
--- a/eeschema/libeditframe.cpp
+++ b/eeschema/libeditframe.cpp
@@ -1345,10 +1345,8 @@ void LIB_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
void LIB_EDIT_FRAME::OnOpenPinTable( wxCommandEvent& aEvent )
{
LIB_PART* part = GetCurPart();
- LIB_PINS pins;
- part->GetPins( pins );
- DIALOG_LIB_EDIT_PIN_TABLE dlg( this, pins );
+ DIALOG_LIB_EDIT_PIN_TABLE dlg( this, *part );
if( dlg.ShowModal() == wxID_CANCEL )
return;
References