Implement simple inheritance for library symbols.

This change completely removes the LIB_ALIAS design pattern an replaces
it by allowing LIB_PART objects to inherit from other LIB_PART objects.
The initial implementation only allows for single inheritance and only
supports the mandatory fields in the derived part because that is all
that the current symbol library file format will support.  Once the new
file format is implemented and saving to the old file format is deprecated,
more complex inheritance will be added.  The LIB_ALIAS information saved
in the document files was move into the LIB_PART object.  This change
impacts virtually every part of the schematic and symbol library editor
code so this commit message is woefully incomplete.

REMOVE: Removed the symbol aliases concept from the schematic and symbol
editors and the symbol viewer.

NEW: Replace the symbol alias concept with simple inheritance that allows
a library symbol to be derived from another library symbol.
This commit is contained in:
Wayne Stambaugh
2019-12-06 11:33:52 -05:00
parent 9f896312ee
commit 54f066fed7
80 changed files with 2697 additions and 4449 deletions
+123 -23
View File
@@ -199,13 +199,20 @@ bool FIELDS_GRID_TABLE<T>::CanSetValueAs( int aRow, int aCol, const wxString& aT
template <class T>
wxGridCellAttr* FIELDS_GRID_TABLE<T>::GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind )
{
wxGridCellAttr* tmp;
// Only the VALUE and DATASHEET fields can be edited for inherited symbols.
bool rowIsReadOnly = m_part && m_part->IsAlias() && ( aRow == REFERENCE || aRow == FOOTPRINT );
switch( aCol )
{
case FDC_NAME:
if( aRow < MANDATORY_FIELDS )
if( aRow < MANDATORY_FIELDS || rowIsReadOnly )
{
m_readOnlyAttr->IncRef();
return m_readOnlyAttr;
tmp = m_fieldNameAttr->Clone();
tmp->SetReadOnly( true );
tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
return tmp;
}
else
{
@@ -216,17 +223,30 @@ wxGridCellAttr* FIELDS_GRID_TABLE<T>::GetAttr( int aRow, int aCol, wxGridCellAtt
case FDC_VALUE:
if( aRow == REFERENCE )
{
m_referenceAttr->IncRef();
return m_referenceAttr;
if( rowIsReadOnly )
{
tmp = m_referenceAttr->Clone();
tmp->SetReadOnly( true );
tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
return tmp;
}
else
{
m_referenceAttr->IncRef();
return m_referenceAttr;
}
}
else if( aRow == VALUE )
{
// For power symbols, the value is not editable, because value and pin name must
// be the same and can be edited only in library editor.
if( m_part && m_part->IsPower() && ! m_frame->IsType( FRAME_SCH_LIB_EDITOR ) )
if( ( m_part && m_part->IsPower() && !m_frame->IsType( FRAME_SCH_LIB_EDITOR ) )
|| rowIsReadOnly )
{
m_readOnlyAttr->IncRef();
return m_readOnlyAttr;
tmp = m_readOnlyAttr->Clone();
tmp->SetReadOnly( true );
tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
return tmp;
}
else
{
@@ -236,8 +256,18 @@ wxGridCellAttr* FIELDS_GRID_TABLE<T>::GetAttr( int aRow, int aCol, wxGridCellAtt
}
else if( aRow == FOOTPRINT )
{
m_footprintAttr->IncRef();
return m_footprintAttr;
if( rowIsReadOnly )
{
tmp = m_footprintAttr->Clone();
tmp->SetReadOnly( true );
tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
return tmp;
}
else
{
m_footprintAttr->IncRef();
return m_footprintAttr;
}
}
else if( aRow == DATASHEET )
{
@@ -251,39 +281,109 @@ wxGridCellAttr* FIELDS_GRID_TABLE<T>::GetAttr( int aRow, int aCol, wxGridCellAtt
if( templateFn && templateFn->m_URL )
{
m_urlAttr->IncRef();
return m_urlAttr;
if( rowIsReadOnly )
{
tmp = m_urlAttr->Clone();
tmp->SetReadOnly( true );
tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
return tmp;
}
else
{
m_urlAttr->IncRef();
return m_urlAttr;
}
}
else
{
m_nonUrlAttr->IncRef();
return m_nonUrlAttr;
if( rowIsReadOnly )
{
tmp = m_nonUrlAttr->Clone();
tmp->SetReadOnly( true );
tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
return tmp;
}
else
{
m_nonUrlAttr->IncRef();
return m_nonUrlAttr;
}
}
}
return nullptr;
case FDC_TEXT_SIZE:
case FDC_POSX:
case FDC_POSY:
return nullptr;
if( rowIsReadOnly )
{
tmp = m_readOnlyAttr->Clone();
tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
return tmp;
}
else
{
return nullptr;
}
case FDC_H_ALIGN:
m_hAlignAttr->IncRef();
return m_hAlignAttr;
if( rowIsReadOnly )
{
tmp = m_hAlignAttr->Clone();
tmp->SetReadOnly( true );
tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
return tmp;
}
else
{
m_hAlignAttr->IncRef();
return m_hAlignAttr;
}
case FDC_V_ALIGN:
m_vAlignAttr->IncRef();
return m_vAlignAttr;
if( rowIsReadOnly )
{
tmp = m_vAlignAttr->Clone();
tmp->SetReadOnly( true );
tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
return tmp;
}
else
{
m_vAlignAttr->IncRef();
return m_vAlignAttr;
}
case FDC_ORIENTATION:
m_orientationAttr->IncRef();
return m_orientationAttr;
if( rowIsReadOnly )
{
tmp = m_orientationAttr->Clone();
tmp->SetReadOnly( true );
tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
return tmp;
}
else
{
m_orientationAttr->IncRef();
return m_orientationAttr;
}
case FDC_SHOWN:
case FDC_ITALIC:
case FDC_BOLD:
m_boolAttr->IncRef();
return m_boolAttr;
if( rowIsReadOnly )
{
tmp = m_boolAttr->Clone();
tmp->SetReadOnly( true );
tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
return tmp;
}
else
{
m_boolAttr->IncRef();
return m_boolAttr;
}
default:
wxFAIL;