Aliases should inherit their descs, keywords, and fp filters.
Assuming they're not set locally, of course. Also updates to new class structure order. Fixes https://gitlab.com/kicad/code/kicad/issues/6051
This commit is contained in:
parent
3b35bfc0a5
commit
797a588015
|
@ -88,13 +88,13 @@ LIB_PART::LIB_PART( const wxString& aName, LIB_PART* aParent, PART_LIB* aLibrary
|
|||
m_includeInBom( true ),
|
||||
m_includeOnBoard( true )
|
||||
{
|
||||
m_dateLastEdition = 0;
|
||||
m_unitCount = 1;
|
||||
m_pinNameOffset = Mils2iu( DEFAULT_PIN_NAME_OFFSET );
|
||||
m_options = ENTRY_NORMAL;
|
||||
m_unitsLocked = false;
|
||||
m_showPinNumbers = true;
|
||||
m_showPinNames = true;
|
||||
m_lastModDate = 0;
|
||||
m_unitCount = 1;
|
||||
m_pinNameOffset = Mils2iu( DEFAULT_PIN_NAME_OFFSET );
|
||||
m_options = ENTRY_NORMAL;
|
||||
m_unitsLocked = false;
|
||||
m_showPinNumbers = true;
|
||||
m_showPinNames = true;
|
||||
|
||||
// Add the MANDATORY_FIELDS in RAM only. These are assumed to be present
|
||||
// when the field editors are invoked.
|
||||
|
@ -119,21 +119,21 @@ LIB_PART::LIB_PART( const LIB_PART& aPart, PART_LIB* aLibrary ) :
|
|||
{
|
||||
LIB_ITEM* newItem;
|
||||
|
||||
m_library = aLibrary;
|
||||
m_name = aPart.m_name;
|
||||
m_footprintFilters = wxArrayString( aPart.m_footprintFilters );
|
||||
m_unitCount = aPart.m_unitCount;
|
||||
m_unitsLocked = aPart.m_unitsLocked;
|
||||
m_pinNameOffset = aPart.m_pinNameOffset;
|
||||
m_showPinNumbers = aPart.m_showPinNumbers;
|
||||
m_includeInBom = aPart.m_includeInBom;
|
||||
m_includeOnBoard = aPart.m_includeOnBoard;
|
||||
m_showPinNames = aPart.m_showPinNames;
|
||||
m_dateLastEdition = aPart.m_dateLastEdition;
|
||||
m_options = aPart.m_options;
|
||||
m_libId = aPart.m_libId;
|
||||
m_description = aPart.m_description;
|
||||
m_keyWords = aPart.m_keyWords;
|
||||
m_library = aLibrary;
|
||||
m_name = aPart.m_name;
|
||||
m_fpFilters = wxArrayString( aPart.m_fpFilters );
|
||||
m_unitCount = aPart.m_unitCount;
|
||||
m_unitsLocked = aPart.m_unitsLocked;
|
||||
m_pinNameOffset = aPart.m_pinNameOffset;
|
||||
m_showPinNumbers = aPart.m_showPinNumbers;
|
||||
m_includeInBom = aPart.m_includeInBom;
|
||||
m_includeOnBoard = aPart.m_includeOnBoard;
|
||||
m_showPinNames = aPart.m_showPinNames;
|
||||
m_lastModDate = aPart.m_lastModDate;
|
||||
m_options = aPart.m_options;
|
||||
m_libId = aPart.m_libId;
|
||||
m_description = aPart.m_description;
|
||||
m_keyWords = aPart.m_keyWords;
|
||||
|
||||
ClearSelected();
|
||||
|
||||
|
@ -174,21 +174,21 @@ const LIB_PART& LIB_PART::operator=( const LIB_PART& aPart )
|
|||
|
||||
LIB_ITEM* newItem;
|
||||
|
||||
m_library = aPart.m_library;
|
||||
m_name = aPart.m_name;
|
||||
m_footprintFilters = wxArrayString( aPart.m_footprintFilters );
|
||||
m_unitCount = aPart.m_unitCount;
|
||||
m_unitsLocked = aPart.m_unitsLocked;
|
||||
m_pinNameOffset = aPart.m_pinNameOffset;
|
||||
m_showPinNumbers = aPart.m_showPinNumbers;
|
||||
m_showPinNames = aPart.m_showPinNames;
|
||||
m_includeInBom = aPart.m_includeInBom;
|
||||
m_includeOnBoard = aPart.m_includeOnBoard;
|
||||
m_dateLastEdition = aPart.m_dateLastEdition;
|
||||
m_options = aPart.m_options;
|
||||
m_libId = aPart.m_libId;
|
||||
m_description = aPart.m_description;
|
||||
m_keyWords = aPart.m_keyWords;
|
||||
m_library = aPart.m_library;
|
||||
m_name = aPart.m_name;
|
||||
m_fpFilters = wxArrayString( aPart.m_fpFilters );
|
||||
m_unitCount = aPart.m_unitCount;
|
||||
m_unitsLocked = aPart.m_unitsLocked;
|
||||
m_pinNameOffset = aPart.m_pinNameOffset;
|
||||
m_showPinNumbers = aPart.m_showPinNumbers;
|
||||
m_showPinNames = aPart.m_showPinNames;
|
||||
m_includeInBom = aPart.m_includeInBom;
|
||||
m_includeOnBoard = aPart.m_includeOnBoard;
|
||||
m_lastModDate = aPart.m_lastModDate;
|
||||
m_options = aPart.m_options;
|
||||
m_libId = aPart.m_libId;
|
||||
m_description = aPart.m_description;
|
||||
m_keyWords = aPart.m_keyWords;
|
||||
|
||||
m_drawings.clear();
|
||||
|
||||
|
@ -258,12 +258,12 @@ int LIB_PART::Compare( const LIB_PART& aRhs ) const
|
|||
++rhsItem;
|
||||
}
|
||||
|
||||
if( m_footprintFilters.GetCount() != aRhs.m_footprintFilters.GetCount() )
|
||||
return m_footprintFilters.GetCount() - aRhs.m_footprintFilters.GetCount();
|
||||
if( m_fpFilters.GetCount() != aRhs.m_fpFilters.GetCount() )
|
||||
return m_fpFilters.GetCount() - aRhs.m_fpFilters.GetCount();
|
||||
|
||||
for( size_t i = 0; i < m_footprintFilters.GetCount(); i++ )
|
||||
for( size_t i = 0; i < m_fpFilters.GetCount(); i++ )
|
||||
{
|
||||
retv = m_footprintFilters[i].Cmp( aRhs.m_footprintFilters[i] );
|
||||
retv = m_fpFilters[i].Cmp( aRhs.m_fpFilters[i] );
|
||||
|
||||
if( retv )
|
||||
return retv;
|
||||
|
@ -382,9 +382,9 @@ std::unique_ptr< LIB_PART > LIB_PART::Flatten() const
|
|||
}
|
||||
}
|
||||
|
||||
retv->SetKeyWords( m_keyWords );
|
||||
retv->SetDescription( m_description );
|
||||
retv->SetFootprintFilters( m_footprintFilters );
|
||||
retv->SetKeyWords( m_keyWords.IsEmpty() ? parent->GetKeyWords() : m_keyWords );
|
||||
retv->SetDescription( m_description.IsEmpty() ? parent->GetDescription() : m_description );
|
||||
retv->SetFPFilters( m_fpFilters.IsEmpty() ? parent->GetFPFilters() : m_fpFilters );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -23,10 +23,6 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file class_libentry.h
|
||||
*/
|
||||
|
||||
#ifndef CLASS_LIBENTRY_H
|
||||
#define CLASS_LIBENTRY_H
|
||||
|
||||
|
@ -96,43 +92,7 @@ struct PART_UNITS
|
|||
*/
|
||||
class LIB_PART : public EDA_ITEM, public LIB_TREE_ITEM
|
||||
{
|
||||
///< http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared
|
||||
PART_SPTR m_me;
|
||||
PART_REF m_parent; ///< Use for inherited symbols.
|
||||
|
||||
LIB_ID m_libId;
|
||||
|
||||
int m_pinNameOffset; ///< The offset in mils to draw the pin name. Set to 0
|
||||
///< to draw the pin name above the pin.
|
||||
bool m_unitsLocked; ///< True if part has multiple units and changing
|
||||
///< one unit does not automatically change another unit.
|
||||
bool m_showPinNames; ///< Determines if part pin names are visible.
|
||||
bool m_showPinNumbers; ///< Determines if part pin numbers are visible.
|
||||
bool m_includeInBom; ///< Determines if symbol should be included in
|
||||
///< schematic BOM.
|
||||
bool m_includeOnBoard; ///< Determines if symbol should be excluded from
|
||||
///< netlist when updating board.
|
||||
timestamp_t m_dateLastEdition; ///< Date of the last modification.
|
||||
LIBRENTRYOPTIONS m_options; ///< Special part features such as POWER or NORMAL.)
|
||||
int m_unitCount; ///< Number of units (parts) per package.
|
||||
LIB_ITEMS_CONTAINER m_drawings; ///< Drawing items of this part.
|
||||
wxArrayString m_footprintFilters; /**< List of suitable footprint names for the
|
||||
part (wild card names accepted). */
|
||||
PART_LIB* m_library; ///< Library the part belongs to if any.
|
||||
wxString m_name; ///< Symbol name.
|
||||
wxString m_description; ///< documentation for info
|
||||
wxString m_keyWords; ///< keyword list (used for search for parts by keyword)
|
||||
|
||||
static int m_subpartIdSeparator; ///< the separator char between
|
||||
///< the subpart id and the reference like U1A
|
||||
///< ( m_subpartIdSeparator = 0 ) or U1.A or U1-A
|
||||
static int m_subpartFirstId; ///< the ASCII char value to calculate the subpart
|
||||
///< symbol id from the part number: only 'A', 'a'
|
||||
///< or '1' can be used, other values have no sense.
|
||||
void deleteAllFields();
|
||||
|
||||
public:
|
||||
|
||||
LIB_PART( const wxString& aName, LIB_PART* aParent = nullptr, PART_LIB* aLibrary = nullptr );
|
||||
|
||||
/**
|
||||
|
@ -142,6 +102,7 @@ public:
|
|||
|
||||
virtual ~LIB_PART();
|
||||
|
||||
///< http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared
|
||||
PART_SPTR SharedPtr() { return m_me; }
|
||||
|
||||
/**
|
||||
|
@ -159,13 +120,6 @@ public:
|
|||
return dupe;
|
||||
}
|
||||
|
||||
private:
|
||||
// We create a different set parent function for this class, so we hide
|
||||
// the inherited one.
|
||||
using EDA_ITEM::SetParent;
|
||||
|
||||
public:
|
||||
|
||||
void SetParent( LIB_PART* aParent = nullptr );
|
||||
PART_REF& GetParent() { return m_parent; }
|
||||
|
||||
|
@ -182,19 +136,31 @@ public:
|
|||
|
||||
wxString GetLibNickname() const override { return GetLibraryName(); }
|
||||
|
||||
void SetDescription( const wxString& aDescription )
|
||||
void SetDescription( const wxString& aDescription ) { m_description = aDescription; }
|
||||
|
||||
wxString GetDescription() override
|
||||
{
|
||||
m_description = aDescription;
|
||||
if( m_description.IsEmpty() && IsAlias() )
|
||||
{
|
||||
if( PART_SPTR parent = m_parent.lock() )
|
||||
return parent->GetDescription();
|
||||
}
|
||||
|
||||
return m_description;
|
||||
}
|
||||
|
||||
wxString GetDescription() override { return m_description; }
|
||||
void SetKeyWords( const wxString& aKeyWords ) { m_keyWords = aKeyWords; }
|
||||
|
||||
void SetKeyWords( const wxString& aKeyWords )
|
||||
wxString GetKeyWords() const
|
||||
{
|
||||
m_keyWords = aKeyWords;
|
||||
}
|
||||
if( m_keyWords.IsEmpty() && IsAlias() )
|
||||
{
|
||||
if( PART_SPTR parent = m_parent.lock() )
|
||||
return parent->GetKeyWords();
|
||||
}
|
||||
|
||||
wxString GetKeyWords() const { return m_keyWords; }
|
||||
return m_keyWords;
|
||||
}
|
||||
|
||||
wxString GetSearchText() override;
|
||||
|
||||
|
@ -206,15 +172,22 @@ public:
|
|||
|
||||
const wxString GetLibraryName() const;
|
||||
|
||||
PART_LIB* GetLib() { return m_library; }
|
||||
PART_LIB* GetLib() { return m_library; }
|
||||
void SetLib( PART_LIB* aLibrary ) { m_library = aLibrary; }
|
||||
|
||||
timestamp_t GetDateLastEdition() const { return m_dateLastEdition; }
|
||||
timestamp_t GetLastModDate() const { return m_lastModDate; }
|
||||
|
||||
wxArrayString GetFootprints() const { return m_footprintFilters; }
|
||||
void SetFootprintFilters( const wxArrayString& aFootprintFilters )
|
||||
void SetFPFilters( const wxArrayString& aFilters ) { m_fpFilters = aFilters; }
|
||||
|
||||
wxArrayString GetFPFilters() const
|
||||
{
|
||||
m_footprintFilters = aFootprintFilters;
|
||||
if( m_fpFilters.IsEmpty() && IsAlias() )
|
||||
{
|
||||
if( PART_SPTR parent = m_parent.lock() )
|
||||
return parent->GetFPFilters();
|
||||
}
|
||||
|
||||
return m_fpFilters;
|
||||
}
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
@ -391,7 +364,6 @@ public:
|
|||
return (LIB_PIN*) GetNextDrawItem( (LIB_ITEM*) aItem, LIB_PIN_T );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a list of pin object pointers from the draw item list.
|
||||
*
|
||||
|
@ -458,6 +430,7 @@ public:
|
|||
*/
|
||||
void ClearTempFlags();
|
||||
void ClearEditFlags();
|
||||
|
||||
/**
|
||||
* Locate a draw object.
|
||||
*
|
||||
|
@ -666,6 +639,47 @@ public:
|
|||
#if defined(DEBUG)
|
||||
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
// We create a different set parent function for this class, so we hide the inherited one.
|
||||
using EDA_ITEM::SetParent;
|
||||
|
||||
void deleteAllFields();
|
||||
|
||||
private:
|
||||
PART_SPTR m_me;
|
||||
PART_REF m_parent; ///< Use for inherited symbols.
|
||||
LIB_ID m_libId;
|
||||
timestamp_t m_lastModDate;
|
||||
|
||||
int m_unitCount; ///< Number of units (parts) per package.
|
||||
bool m_unitsLocked; ///< True if part has multiple units and changing one
|
||||
///< unit does not automatically change another unit.
|
||||
|
||||
int m_pinNameOffset; ///< The offset in mils to draw the pin name. Set to
|
||||
///< 0 to draw the pin name above the pin.
|
||||
bool m_showPinNames;
|
||||
bool m_showPinNumbers;
|
||||
|
||||
bool m_includeInBom;
|
||||
bool m_includeOnBoard;
|
||||
LIBRENTRYOPTIONS m_options; ///< Special part features such as POWER or NORMAL.)
|
||||
|
||||
LIB_ITEMS_CONTAINER m_drawings;
|
||||
|
||||
PART_LIB* m_library;
|
||||
wxString m_name;
|
||||
wxString m_description;
|
||||
wxString m_keyWords; ///< Search keywords
|
||||
wxArrayString m_fpFilters; ///< List of suitable footprint names for the
|
||||
///< part (wild card names accepted).
|
||||
|
||||
static int m_subpartIdSeparator; ///< the separator char between
|
||||
///< the subpart id and the reference like U1A
|
||||
///< ( m_subpartIdSeparator = 0 ) or U1.A or U1-A
|
||||
static int m_subpartFirstId; ///< the ASCII char value to calculate the subpart
|
||||
///< symbol id from the part number: only 'A', 'a'
|
||||
///< or '1' can be used, other values have no sense.
|
||||
};
|
||||
|
||||
#endif // CLASS_LIBENTRY_H
|
||||
|
|
|
@ -474,7 +474,7 @@ void DIALOG_CHOOSE_SYMBOL::PopulateFootprintSelector( LIB_ID const& aLibId )
|
|||
symbol->GetPins( temp_pins );
|
||||
|
||||
m_fp_sel_ctrl->FilterByPinCount( temp_pins.size() );
|
||||
m_fp_sel_ctrl->FilterByFootprintFilters( symbol->GetFootprints(), true );
|
||||
m_fp_sel_ctrl->FilterByFootprintFilters( symbol->GetFPFilters(), true );
|
||||
m_fp_sel_ctrl->SetDefaultFootprint( fp_name );
|
||||
m_fp_sel_ctrl->UpdateList();
|
||||
m_fp_sel_ctrl->Enable();
|
||||
|
|
|
@ -174,7 +174,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow()
|
|||
m_PinsNameInsideButt->SetValue( m_libEntry->GetPinNameOffset() != 0 );
|
||||
m_pinNameOffset.SetValue( m_libEntry->GetPinNameOffset() );
|
||||
|
||||
wxArrayString tmp = m_libEntry->GetFootprints();
|
||||
wxArrayString tmp = m_libEntry->GetFPFilters();
|
||||
m_FootprintFilterListBox->Append( tmp );
|
||||
|
||||
// Populate the list of root parts for inherited objects.
|
||||
|
@ -376,7 +376,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow()
|
|||
m_libEntry->SetPinNameOffset( 0 ); // pin text outside the body (name is on the pin)
|
||||
}
|
||||
|
||||
m_libEntry->SetFootprintFilters( m_FootprintFilterListBox->GetStrings() );
|
||||
m_libEntry->SetFPFilters( m_FootprintFilterListBox->GetStrings());
|
||||
|
||||
m_Parent->UpdateAfterSymbolProperties( &oldName );
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName,
|
|||
|
||||
CreatePinList( comp, &sheet );
|
||||
|
||||
if( comp->GetPartRef() && comp->GetPartRef()->GetFootprints().GetCount() != 0 )
|
||||
if( comp->GetPartRef() && comp->GetPartRef()->GetFPFilters().GetCount() != 0 )
|
||||
cmpList.push_back( SCH_REFERENCE( comp, comp->GetPartRef().get(), sheet ) );
|
||||
|
||||
footprint = comp->GetFootprint( &sheet, true );
|
||||
|
|
|
@ -486,15 +486,13 @@ XNODE* NETLIST_EXPORTER_XML::makeLibParts()
|
|||
xlibpart->AddChild( node( "docs", lcomp->GetDatasheetField().GetText() ) );
|
||||
|
||||
// Write the footprint list
|
||||
if( lcomp->GetFootprints().GetCount() )
|
||||
if( lcomp->GetFPFilters().GetCount() )
|
||||
{
|
||||
XNODE* xfootprints;
|
||||
xlibpart->AddChild( xfootprints = node( "footprints" ) );
|
||||
|
||||
for( unsigned i=0; i<lcomp->GetFootprints().GetCount(); ++i )
|
||||
{
|
||||
xfootprints->AddChild( node( "fp", lcomp->GetFootprints()[i] ) );
|
||||
}
|
||||
for( unsigned i = 0; i < lcomp->GetFPFilters().GetCount(); ++i )
|
||||
xfootprints->AddChild( node( "fp", lcomp->GetFPFilters()[i] ) );
|
||||
}
|
||||
|
||||
//----- show the fields here ----------------------------------
|
||||
|
|
|
@ -813,7 +813,7 @@ void SCH_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_PART>& aSymbol )
|
|||
while( tokenizer.HasMoreTokens() )
|
||||
filters.Add( tokenizer.GetNextToken() );
|
||||
|
||||
aSymbol->SetFootprintFilters( filters );
|
||||
aSymbol->SetFPFilters( filters );
|
||||
}
|
||||
else if( name == "ki_locked" )
|
||||
{
|
||||
|
|
|
@ -1666,7 +1666,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveDcmInfoAsFields( LIB_PART* aSymbol, OUTPUTFORMA
|
|||
id += 1;
|
||||
}
|
||||
|
||||
wxArrayString fpFilters = aSymbol->GetFootprints();
|
||||
wxArrayString fpFilters = aSymbol->GetFPFilters();
|
||||
|
||||
if( !fpFilters.IsEmpty() )
|
||||
{
|
||||
|
|
|
@ -3704,7 +3704,7 @@ void SCH_LEGACY_PLUGIN_CACHE::loadFootprintFilters( std::unique_ptr<LIB_PART>& a
|
|||
{
|
||||
if( strCompare( "$ENDFPLIST", line, &line ) )
|
||||
{
|
||||
aPart->SetFootprintFilters( footprintFilters );
|
||||
aPart->SetFPFilters( footprintFilters );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3797,7 +3797,7 @@ void SCH_LEGACY_PLUGIN_CACHE::SaveSymbol( LIB_PART* aSymbol, OUTPUTFORMATTER& aF
|
|||
aSymbol->GetUnitCount(), aSymbol->UnitsLocked() ? 'L' : 'F',
|
||||
aSymbol->IsPower() ? 'P' : 'N' );
|
||||
|
||||
timestamp_t dateModified = aSymbol->GetDateLastEdition();
|
||||
timestamp_t dateModified = aSymbol->GetLastModDate();
|
||||
|
||||
if( dateModified != 0 )
|
||||
{
|
||||
|
@ -3853,7 +3853,7 @@ void SCH_LEGACY_PLUGIN_CACHE::SaveSymbol( LIB_PART* aSymbol, OUTPUTFORMATTER& aF
|
|||
aFormatter.Print( 0, "\n" );
|
||||
}
|
||||
|
||||
wxArrayString footprints = aSymbol->GetFootprints();
|
||||
wxArrayString footprints = aSymbol->GetFPFilters();
|
||||
|
||||
// Write the footprint filter list
|
||||
if( footprints.GetCount() != 0 )
|
||||
|
|
|
@ -289,17 +289,17 @@ BOOST_AUTO_TEST_CASE( Compare )
|
|||
|
||||
// Footprint filter array comparison tests.
|
||||
wxArrayString footPrintFilters;
|
||||
BOOST_CHECK( m_part_no_data.GetFootprints() == footPrintFilters );
|
||||
BOOST_CHECK( m_part_no_data.GetFPFilters() == footPrintFilters );
|
||||
footPrintFilters.Add( "b" );
|
||||
testPart.SetFootprintFilters( footPrintFilters );
|
||||
testPart.SetFPFilters( footPrintFilters );
|
||||
BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
|
||||
m_part_no_data.SetFootprintFilters( footPrintFilters );
|
||||
m_part_no_data.SetFPFilters( footPrintFilters );
|
||||
footPrintFilters.Clear();
|
||||
testPart.SetFootprintFilters( footPrintFilters );
|
||||
testPart.SetFPFilters( footPrintFilters );
|
||||
BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
|
||||
footPrintFilters.Clear();
|
||||
m_part_no_data.SetFootprintFilters( footPrintFilters );
|
||||
testPart.SetFootprintFilters( footPrintFilters );
|
||||
m_part_no_data.SetFPFilters( footPrintFilters );
|
||||
testPart.SetFPFilters( footPrintFilters );
|
||||
|
||||
// Description string tests.
|
||||
m_part_no_data.SetDescription( "b" );
|
||||
|
|
Loading…
Reference in New Issue