Make pin name/number visibility architecture more clear.

This commit is contained in:
Jeff Young 2024-04-28 12:51:02 +01:00
parent 6fdeca7c56
commit 1db8b322da
4 changed files with 34 additions and 23 deletions

View File

@ -749,32 +749,25 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow()
case 2: m_symbol->SetOrientation( SYM_MIRROR_Y ); break;
}
if( m_part )
{
m_part->SetShowPinNames( m_ShowPinNameButt->GetValue() );
m_part->SetShowPinNumbers( m_ShowPinNumButt->GetValue() );
}
m_symbol->SetShowPinNames( m_ShowPinNameButt->GetValue() );
m_symbol->SetShowPinNumbers( m_ShowPinNumButt->GetValue() );
// Restore m_Flag modified by SetUnit() and other change settings from the dialog
m_symbol->ClearFlags();
m_symbol->SetFlags( flags );
// change all field positions from relative to absolute
for( unsigned i = 0; i < m_fields->size(); ++i )
for( SCH_FIELD& field : *m_fields )
{
SCH_FIELD& field = m_fields->at( i );
field.Offset( m_symbol->GetPosition() );
field.SetText( m_symbol->Schematic()->ConvertRefsToKIIDs( field.GetText() ) );
}
SCH_FIELDS& fields = m_symbol->GetFields();
fields.clear();
for( size_t ii = 0; ii < m_fields->size(); ++ii )
for( SCH_FIELD& field : *m_fields )
{
SCH_FIELD& field = m_fields->at( ii );
const wxString& fieldName = field.GetCanonicalName();
if( fieldName.IsEmpty() && field.GetText().IsEmpty() )

View File

@ -2598,15 +2598,33 @@ void SCH_SYMBOL::ClearBrightenedPins()
}
bool SCH_SYMBOL::SCH_SYMBOL::GetShowPinNumbers() const
{
return m_part && m_part->GetShowPinNumbers();
}
/*
* When modified at the schematic level, we still store the values of these flags in the
* associated m_part. If m_part now diverges from other usages, a new derived LIB_SYMBOL
* will be created and stored locally in the schematic.
*/
bool SCH_SYMBOL::GetShowPinNames() const
{
return m_part && m_part->GetShowPinNames();
wxCHECK( m_part, false );
return m_part->GetShowPinNames();
}
void SCH_SYMBOL::SetShowPinNames( bool aShow )
{
wxCHECK( m_part, /* void */ );
m_part->SetShowPinNames( aShow );
}
bool SCH_SYMBOL::GetShowPinNumbers() const
{
wxCHECK( m_part, false );
return m_part->GetShowPinNumbers();
}
void SCH_SYMBOL::SetShowPinNumbers( bool aShow )
{
wxCHECK( m_part, /* void */ );
m_part->SetShowPinNumbers( aShow );
}

View File

@ -850,11 +850,11 @@ public:
bool IsPower() const override;
bool IsNormal() const override;
/*
* We don't currently support changing these at the schematic level.
*/
bool GetShowPinNames() const override;
void SetShowPinNames( bool aShow ) override;
bool GetShowPinNumbers() const override;
void SetShowPinNumbers( bool aShow ) override;
double Similarity( const SCH_ITEM& aOther ) const override;

View File

@ -120,13 +120,13 @@ public:
/**
* Set or clear the pin name visibility flag.
*/
void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; }
virtual void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; }
virtual bool GetShowPinNames() const { return m_showPinNames; }
/**
* Set or clear the pin number visibility flag.
*/
void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; }
virtual void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; }
virtual bool GetShowPinNumbers() const { return m_showPinNumbers; }
/**