Bring back deprecated net properties to rules system

This commit is contained in:
Jon Evans 2023-01-11 22:14:52 -05:00
parent 05b578a9bb
commit 1ff1571849
3 changed files with 38 additions and 6 deletions

View File

@ -185,6 +185,7 @@ PROPERTY_BASE( const wxString& aName, PROPERTY_DISPLAY aDisplay = PT_DEFAULT,
m_display( aDisplay ),
m_coordType( aCoordType ),
m_isInternal( false ),
m_isDeprecated( false ),
m_availFunc( [](INSPECTABLE*)->bool { return true; } ),
m_writeableFunc( [](INSPECTABLE*)->bool { return true; } )
{
@ -274,9 +275,12 @@ PROPERTY_BASE( const wxString& aName, PROPERTY_DISPLAY aDisplay = PT_DEFAULT,
ORIGIN_TRANSFORMS::COORD_TYPES_T CoordType() const { return m_coordType; }
void SetIsInternal( bool aIsInternal ) { m_isInternal = aIsInternal; }
void SetIsInternal( bool aIsInternal = true ) { m_isInternal = aIsInternal; }
bool IsInternal() const { return m_isInternal; }
void SetIsDeprecated( bool aIsDeprecated = true ) { m_isDeprecated = aIsDeprecated; }
bool IsDeprecated() const { return m_isDeprecated; }
wxString Group() const { return m_group; }
void SetGroup( const wxString& aGroup ) { m_group = aGroup; }
@ -328,9 +332,12 @@ private:
const PROPERTY_DISPLAY m_display;
const ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType;
/// Internal properties are hidden from the GUI
/// Internal properties are hidden from the GUI but not from the rules editor autocomplete
bool m_isInternal;
/// Deprecated properties are hidden from the GUI and rules editor autocomplete
bool m_isDeprecated;
/// Optional group identifier
wxString m_group;

View File

@ -163,9 +163,28 @@ static struct BOARD_CONNECTED_ITEM_DESC
layer->SetChoices( layerEnum.Choices() );
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Layer" ), layer );
propMgr.AddProperty( new PROPERTY_ENUM<BOARD_CONNECTED_ITEM, int>( _HKI( "Net" ),
&BOARD_CONNECTED_ITEM::SetNetCode, &BOARD_CONNECTED_ITEM::GetNetCode ) );
propMgr.AddProperty( new PROPERTY<BOARD_CONNECTED_ITEM, wxString>( _HKI( "Net Class" ),
NO_SETTER( BOARD_CONNECTED_ITEM, wxString ), &BOARD_CONNECTED_ITEM::GetNetClassName ) );
auto netCode = new PROPERTY_ENUM<BOARD_CONNECTED_ITEM, int>( _HKI( "Net" ),
&BOARD_CONNECTED_ITEM::SetNetCode, &BOARD_CONNECTED_ITEM::GetNetCode );
netCode->SetIsDeprecated(); // Not really, but hide from rule editor suggestions
propMgr.AddProperty( netCode );
auto netClass = new PROPERTY<BOARD_CONNECTED_ITEM, wxString>( _HKI( "Net Class" ),
NO_SETTER( BOARD_CONNECTED_ITEM, wxString ),
&BOARD_CONNECTED_ITEM::GetNetClassName );
netClass->SetIsDeprecated(); // Not really, but hide from rule editor suggestions
propMgr.AddProperty( netClass );
// Compatibility alias for DRC engine
auto oldNetClass = new PROPERTY<BOARD_CONNECTED_ITEM, wxString>( _HKI( "NetClass" ),
NO_SETTER( BOARD_CONNECTED_ITEM, wxString ),
&BOARD_CONNECTED_ITEM::GetNetClassName );
oldNetClass->SetIsInternal();
propMgr.AddProperty( oldNetClass );
// Used only in DRC engine
auto oldNetName = new PROPERTY<BOARD_CONNECTED_ITEM, wxString>( _HKI( "NetName" ),
NO_SETTER( BOARD_CONNECTED_ITEM, wxString ), &BOARD_CONNECTED_ITEM::GetNetname );
oldNetName->SetIsInternal();
propMgr.AddProperty( oldNetName );
}
} _BOARD_CONNECTED_ITEM_DESC;

View File

@ -440,6 +440,12 @@ void PANEL_SETUP_RULES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
for( PROPERTY_BASE* prop : props )
{
// TODO: It would be nice to replace IsDeprecated with a property nickname
// system, so that two different properies don't need to be created. This is
// a bigger change than I want to make right now, though.
if( prop->IsDeprecated() )
continue;
wxString ref( prop->Name() );
ref.Replace( wxT( " " ), wxT( "_" ) );
propNames.insert( ref );