From 1ff157184958d6cd4d8ebe0e738365722170caf2 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Wed, 11 Jan 2023 22:14:52 -0500 Subject: [PATCH] Bring back deprecated net properties to rules system --- include/properties/property.h | 11 +++++++++-- pcbnew/board_connected_item.cpp | 27 +++++++++++++++++++++++---- pcbnew/dialogs/panel_setup_rules.cpp | 6 ++++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/include/properties/property.h b/include/properties/property.h index f1e73a3442..f38b57081c 100644 --- a/include/properties/property.h +++ b/include/properties/property.h @@ -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; diff --git a/pcbnew/board_connected_item.cpp b/pcbnew/board_connected_item.cpp index 61d2676359..11865efa2f 100644 --- a/pcbnew/board_connected_item.cpp +++ b/pcbnew/board_connected_item.cpp @@ -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( _HKI( "Net" ), - &BOARD_CONNECTED_ITEM::SetNetCode, &BOARD_CONNECTED_ITEM::GetNetCode ) ); - propMgr.AddProperty( new PROPERTY( _HKI( "Net Class" ), - NO_SETTER( BOARD_CONNECTED_ITEM, wxString ), &BOARD_CONNECTED_ITEM::GetNetClassName ) ); + auto netCode = new PROPERTY_ENUM( _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( _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( _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( _HKI( "NetName" ), + NO_SETTER( BOARD_CONNECTED_ITEM, wxString ), &BOARD_CONNECTED_ITEM::GetNetname ); + oldNetName->SetIsInternal(); + propMgr.AddProperty( oldNetName ); } } _BOARD_CONNECTED_ITEM_DESC; diff --git a/pcbnew/dialogs/panel_setup_rules.cpp b/pcbnew/dialogs/panel_setup_rules.cpp index 9f5449c74f..3e5384dc27 100644 --- a/pcbnew/dialogs/panel_setup_rules.cpp +++ b/pcbnew/dialogs/panel_setup_rules.cpp @@ -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 );