Power Symbols: make value editable, use as netname
QA: update tests for editable power symbol values
This commit is contained in:
parent
ca5004b1d2
commit
5995e0e516
|
@ -996,7 +996,13 @@ void CONNECTION_GRAPH::generateGlobalPowerPinSubGraphs()
|
|||
if( !connection || connection->SubgraphCode() > 0 )
|
||||
continue;
|
||||
|
||||
connection->SetName( pin->GetShownName() );
|
||||
// Proper modern power symbols get their net name from the value field
|
||||
// in the symbol, but we support legacy non-power symbols with global
|
||||
// power connections based on invisible, power-in, pin's names.
|
||||
if( pin->GetLibPin()->GetParent()->IsPower() )
|
||||
connection->SetName( pin->GetParentSymbol()->GetValueFieldText( true ) );
|
||||
else
|
||||
connection->SetName( pin->GetShownName() );
|
||||
|
||||
int code = assignNewNetCode( *connection );
|
||||
|
||||
|
|
|
@ -184,19 +184,7 @@ void DIALOG_FIELD_PROPERTIES::init()
|
|||
m_TextValueSelectButton->SetBitmap( KiBitmap( BITMAPS::small_library ) );
|
||||
m_TextValueSelectButton->Show( m_fieldId == FOOTPRINT_FIELD );
|
||||
|
||||
// Value fields of power symbols cannot be modified. This will grey out
|
||||
// the text box and display an explanation.
|
||||
if( m_fieldId == VALUE_FIELD && m_isPower )
|
||||
{
|
||||
m_note->SetLabel( wxString::Format( m_note->GetLabel(), _( "Power symbol value field text "
|
||||
"cannot be changed." ) ) );
|
||||
m_note->Show( true );
|
||||
m_TextCtrl->Enable( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TextCtrl->Enable( true );
|
||||
}
|
||||
m_TextCtrl->Enable( true );
|
||||
|
||||
GetSizer()->SetSizeHints( this );
|
||||
|
||||
|
|
|
@ -422,20 +422,8 @@ wxGridCellAttr* FIELDS_GRID_TABLE<T>::GetAttr( int aRow, int aCol, wxGridCellAtt
|
|||
}
|
||||
else if( m_parentType == SCH_SYMBOL_T && aRow == VALUE_FIELD )
|
||||
{
|
||||
// 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_SYMBOL_EDITOR ) ) )
|
||||
{
|
||||
tmp = m_readOnlyAttr->Clone();
|
||||
tmp->SetReadOnly( true );
|
||||
tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
|
||||
return tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_valueAttr->IncRef();
|
||||
return m_valueAttr;
|
||||
}
|
||||
m_valueAttr->IncRef();
|
||||
return m_valueAttr;
|
||||
}
|
||||
else if( m_parentType == SCH_SYMBOL_T && aRow == FOOTPRINT_FIELD )
|
||||
{
|
||||
|
|
|
@ -438,9 +438,6 @@ void LIB_SYMBOL::SetName( const wxString& aName )
|
|||
{
|
||||
m_name = aName;
|
||||
m_libId.SetLibItemName( aName );
|
||||
|
||||
if( IsPower() )
|
||||
GetValueField().SetText( aName );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -611,17 +611,7 @@ bool SCH_FIELD::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) co
|
|||
|
||||
bool SCH_FIELD::IsReplaceable() const
|
||||
{
|
||||
if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
|
||||
{
|
||||
SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
|
||||
|
||||
if( m_id == VALUE_FIELD )
|
||||
{
|
||||
if( parentSymbol->GetLibSymbolRef() && parentSymbol->GetLibSymbolRef()->IsPower() )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
{
|
||||
// See comments in SCH_FIELD::Replace(), below.
|
||||
if( m_id == SHEETFILENAME )
|
||||
|
|
|
@ -269,8 +269,15 @@ void SCH_PIN::ClearDefaultNetName( const SCH_SHEET_PATH* aPath )
|
|||
|
||||
wxString SCH_PIN::GetDefaultNetName( const SCH_SHEET_PATH& aPath, bool aForceNoConnect )
|
||||
{
|
||||
if( m_libPin->IsGlobalPower() )
|
||||
return EscapeString( m_libPin->GetName(), CTX_NETNAME );
|
||||
// Need to check for parent as power symbol to make sure we aren't dealing
|
||||
// with legacy global power pins on non-power symbols
|
||||
if( IsGlobalPower() )
|
||||
{
|
||||
if( GetLibPin()->GetParent()->IsPower() )
|
||||
return EscapeString( GetParentSymbol()->GetValueFieldText( true ), CTX_NETNAME );
|
||||
else
|
||||
return EscapeString( m_libPin->GetName(), CTX_NETNAME );
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock( m_netmap_mutex );
|
||||
|
||||
|
|
|
@ -1421,6 +1421,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef
|
|||
{
|
||||
pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
|
||||
pin->SetName( aSymbol->GetName() );
|
||||
aSymbol->GetValueField().SetText( aSymbol->GetName() );
|
||||
}
|
||||
|
||||
aSymbol->AddDrawItem( pin );
|
||||
|
|
|
@ -156,6 +156,7 @@ BOOST_AUTO_TEST_CASE( PinNumberingPower )
|
|||
// but if we set isPower...
|
||||
m_lib_pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
|
||||
m_parent_part->SetPower();
|
||||
BOOST_CHECK_EQUAL( m_lib_pin->IsGlobalPower(), true );
|
||||
|
||||
// and update symbol from library...
|
||||
SCH_SHEET_PATH path;
|
||||
|
@ -163,13 +164,14 @@ BOOST_AUTO_TEST_CASE( PinNumberingPower )
|
|||
m_parent_symbol = new SCH_SYMBOL( *m_parent_part, m_parent_part->GetLibId(), &path, 0, 0,
|
||||
VECTOR2I( 1, 2 ) );
|
||||
m_parent_symbol->SetRef( &path, "U2" );
|
||||
m_parent_symbol->SetValueFieldText( "voltage_value" );
|
||||
m_parent_symbol->UpdatePins();
|
||||
|
||||
m_sch_pin = m_parent_symbol->GetPins( &path )[0];
|
||||
|
||||
// ... then the name is just the pin name
|
||||
const wxString pwr_name = m_sch_pin->GetDefaultNetName( path );
|
||||
BOOST_CHECK_EQUAL( pwr_name, "pinname" );
|
||||
BOOST_CHECK_EQUAL( pwr_name, "voltage_value" );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
Loading…
Reference in New Issue