From 220ef6fb44bffaf1970a50a74e8e30563b9605fe Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Fri, 25 Nov 2022 11:49:21 -0500 Subject: [PATCH] Properties: Add some missing footprint properties; cleanup Add concept of "internal" properties that will be accessible from Python/DRC but not shown in the Properties Manager --- common/eda_item.cpp | 15 +++++++++--- common/properties/pg_properties.cpp | 1 + common/widgets/properties_panel.cpp | 6 ++++- include/eda_item.h | 4 +++- include/properties/property.h | 7 ++++++ pcbnew/footprint.cpp | 23 +++++++++++++----- pcbnew/footprint.h | 36 +++++++++++++++++++++++++++++ pcbnew/zone.cpp | 24 +++++++++++-------- pcbnew/zone.h | 1 + 9 files changed, 96 insertions(+), 21 deletions(-) diff --git a/common/eda_item.cpp b/common/eda_item.cpp index 3f03af84f1..11c35b1a76 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -298,7 +298,7 @@ std::ostream& EDA_ITEM::NestedSpace( int nestLevel, std::ostream& os ) #endif -wxString EDA_ITEM::GetTypeDesc() +wxString EDA_ITEM::GetTypeDesc() const { //@see EDA_ITEM_DESC for definition of ENUM_MAP wxString typeDescr = ENUM_MAP::Instance().ToString( Type() ); @@ -307,6 +307,12 @@ wxString EDA_ITEM::GetTypeDesc() } +wxString EDA_ITEM::GetFriendlyName() const +{ + return GetTypeDesc(); +} + + static struct EDA_ITEM_DESC { EDA_ITEM_DESC() @@ -385,8 +391,11 @@ static struct EDA_ITEM_DESC PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); REGISTER_TYPE( EDA_ITEM ); - propMgr.AddProperty( new PROPERTY_ENUM( "Type", - NO_SETTER( EDA_ITEM, KICAD_T ), &EDA_ITEM::Type ) ); + + auto typeProp = new PROPERTY_ENUM( "Type", + NO_SETTER( EDA_ITEM, KICAD_T ), &EDA_ITEM::Type ); + typeProp->SetIsInternal( true ); + propMgr.AddProperty( typeProp ); } } _EDA_ITEM_DESC; diff --git a/common/properties/pg_properties.cpp b/common/properties/pg_properties.cpp index 92e6196b3f..1c2f223beb 100644 --- a/common/properties/pg_properties.cpp +++ b/common/properties/pg_properties.cpp @@ -159,6 +159,7 @@ wxPGProperty* PGPropertyFactory( const PROPERTY_BASE* aProperty ) ret->SetLabel( aProperty->Name() ); ret->SetName( aProperty->Name() ); ret->Enable( !aProperty->IsReadOnly() ); + ret->SetHelpString( aProperty->Name() ); ret->SetClientData( const_cast( aProperty ) ); } diff --git a/common/widgets/properties_panel.cpp b/common/widgets/properties_panel.cpp index 6411415b1c..9670a8ba7f 100644 --- a/common/widgets/properties_panel.cpp +++ b/common/widgets/properties_panel.cpp @@ -52,6 +52,7 @@ PROPERTIES_PANEL::PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame ) m_grid = new wxPropertyGrid( this, wxID_ANY, wxDefaultPosition, wxSize( 300, 400 ), wxPG_AUTO_SORT | wxPG_DEFAULT_STYLE ); m_grid->SetUnspecifiedValueAppearance( wxPGCell( wxT( "<...>" ) ) ); + m_grid->SetExtraStyle( wxPG_EX_HELP_AS_TOOLTIPS ); mainSizer->Add( m_grid, 1, wxALL | wxEXPAND, 5 ); m_grid->SetCellDisabledTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) ); @@ -106,7 +107,7 @@ void PROPERTIES_PANEL::update( const SELECTION& aSelection ) } else { - m_caption->SetLabel( aSelection.Front()->GetTypeDesc() ); + m_caption->SetLabel( aSelection.Front()->GetFriendlyName() ); } PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); @@ -134,6 +135,9 @@ void PROPERTIES_PANEL::update( const SELECTION& aSelection ) // Find a set of properties that is common to all selected items for( const auto& property : commonProps ) { + if( property->IsInternal() ) + continue; + if( !property->Available( aSelection.Front() ) ) continue; diff --git a/include/eda_item.h b/include/eda_item.h index 871fe8ce75..1c895230da 100644 --- a/include/eda_item.h +++ b/include/eda_item.h @@ -212,6 +212,8 @@ public: { } + virtual wxString GetFriendlyName() const; + /** * Test if \a aPosition is inside or on the boundary of this item. * @@ -344,7 +346,7 @@ public: * Return a translated description of the type for this EDA_ITEM for display in user facing * messages. */ - wxString GetTypeDesc(); + wxString GetTypeDesc() const; /** * Return the text to display to be used in the selection clarification context menu diff --git a/include/properties/property.h b/include/properties/property.h index c8c7e908e5..43bfe5a315 100644 --- a/include/properties/property.h +++ b/include/properties/property.h @@ -183,6 +183,7 @@ PROPERTY_BASE( const wxString& aName, PROPERTY_DISPLAY aDisplay = PT_DEFAULT, m_name( aName ), m_display( aDisplay ), m_coordType( aCoordType ), + m_isInternal( false ), m_availFunc( [](INSPECTABLE*)->bool { return true; } ) { } @@ -263,6 +264,9 @@ 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; } + bool IsInternal() const { return m_isInternal; } + protected: template void set( void* aObject, T aValue ) @@ -291,6 +295,9 @@ private: const PROPERTY_DISPLAY m_display; const ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType; + /// Internal properties are hidden from the GUI + bool m_isInternal; + std::function m_availFunc; ///< Eval to determine if prop is available friend class INSPECTABLE; diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 70c149c6f7..774481b338 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -2858,15 +2858,26 @@ static struct FOOTPRINT_DESC propMgr.AddProperty( new PROPERTY( _HKI( "Solderpaste Margin Override" ), &FOOTPRINT::SetLocalSolderPasteMargin, &FOOTPRINT::GetLocalSolderPasteMargin, PROPERTY_DISPLAY::PT_SIZE ) ); - propMgr.AddProperty( new PROPERTY( _HKI( "Solderpaste Margin Ratio Override" ), + propMgr.AddProperty( new PROPERTY( + _HKI( "Solderpaste Margin Ratio Override" ), &FOOTPRINT::SetLocalSolderPasteMarginRatio, - &FOOTPRINT::GetLocalSolderPasteMarginRatio ) ); - propMgr.AddProperty( new PROPERTY( _HKI( "Library ID" ), - &FOOTPRINT::SetFPIDAsString, &FOOTPRINT::GetFPIDAsString ) ); + &FOOTPRINT::GetLocalSolderPasteMarginRatio ) ); + propMgr.AddProperty( new PROPERTY( _HKI( "Library link" ), + NO_SETTER( FOOTPRINT, wxString ), &FOOTPRINT::GetFPIDAsString ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Description" ), - &FOOTPRINT::SetDescription, &FOOTPRINT::GetDescription ) ); + NO_SETTER( FOOTPRINT, wxString ), &FOOTPRINT::GetDescription ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Keywords" ), - &FOOTPRINT::SetKeywords, &FOOTPRINT::GetKeywords ) ); + NO_SETTER( FOOTPRINT, wxString ), &FOOTPRINT::GetKeywords ) ); + + propMgr.AddProperty( new PROPERTY( _HKI( "Not in schematic" ), + &FOOTPRINT::SetBoardOnly, &FOOTPRINT::IsBoardOnly ) ); + propMgr.AddProperty( new PROPERTY( _HKI( "Exclude from position files" ), + &FOOTPRINT::SetExcludedFromPosFiles, &FOOTPRINT::IsExcludedFromPosFiles ) ); + propMgr.AddProperty( new PROPERTY( _HKI( "Exclude from BOM" ), + &FOOTPRINT::SetExcludedFromBOM, &FOOTPRINT::IsExcludedFromBOM ) ); + propMgr.AddProperty( new PROPERTY( + _HKI( "Exempt from courtyard requirement" ), + &FOOTPRINT::SetAllowMissingCourtyard, &FOOTPRINT::AllowMissingCourtyard ) ); // TODO zone connection } } _FOOTPRINT_DESC; diff --git a/pcbnew/footprint.h b/pcbnew/footprint.h index 392ea4173e..d43fcd1474 100644 --- a/pcbnew/footprint.h +++ b/pcbnew/footprint.h @@ -580,6 +580,42 @@ public: } void SetProperty( const wxString& aKey, const wxString& aVal ) { m_properties[ aKey ] = aVal; } + bool IsBoardOnly() const { return m_attributes & FP_BOARD_ONLY; } + void SetBoardOnly( bool aIsBoardOnly = true ) + { + if( aIsBoardOnly ) + m_attributes |= FP_BOARD_ONLY; + else + m_attributes &= ~FP_BOARD_ONLY; + } + + bool IsExcludedFromPosFiles() const { return m_attributes & FP_EXCLUDE_FROM_POS_FILES; } + void SetExcludedFromPosFiles( bool aExclude = true ) + { + if( aExclude ) + m_attributes |= FP_EXCLUDE_FROM_POS_FILES; + else + m_attributes &= ~FP_EXCLUDE_FROM_POS_FILES; + } + + bool IsExcludedFromBOM() const { return m_attributes & FP_EXCLUDE_FROM_BOM; } + void SetExcludedFromBOM( bool aExclude = true ) + { + if( aExclude ) + m_attributes |= FP_EXCLUDE_FROM_BOM; + else + m_attributes &= ~FP_EXCLUDE_FROM_BOM; + } + + bool AllowMissingCourtyard() const { return m_attributes & FP_ALLOW_MISSING_COURTYARD; } + void SetAllowMissingCourtyard( bool aAllow = true ) + { + if( aAllow ) + m_attributes |= FP_ALLOW_MISSING_COURTYARD; + else + m_attributes &= ~FP_ALLOW_MISSING_COURTYARD; + } + /** * Return a #PAD with a matching number. * diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 4af23107f1..fe4485ad4f 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -517,16 +517,7 @@ bool ZONE::HitTestCutout( const VECTOR2I& aRefPos, int* aOutlineIdx, int* aHoleI void ZONE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { - wxString msg; - - if( GetIsRuleArea() ) - msg = _( "Rule Area" ); - else if( IsTeardropArea() ) - msg = _( "Teardrop Area" ); - else if( IsOnCopperLayer() ) - msg = _( "Copper Zone" ); - else - msg = _( "Non-copper Zone" ); + wxString msg = GetFriendlyName(); // Display Cutout instead of Outline for holes inside a zone (i.e. when num contour !=0). // Check whether the selected corner is in a hole; i.e., in any contour but the first one. @@ -659,6 +650,19 @@ void ZONE::Move( const VECTOR2I& offset ) } +wxString ZONE::GetFriendlyName() const +{ + if( GetIsRuleArea() ) + return _( "Rule Area" ); + else if( IsTeardropArea() ) + return _( "Teardrop Area" ); + else if( IsOnCopperLayer() ) + return _( "Copper Zone" ); + else + return _( "Non-copper Zone" ); +} + + void ZONE::MoveEdge( const VECTOR2I& offset, int aEdge ) { int next_corner; diff --git a/pcbnew/zone.h b/pcbnew/zone.h index 9b95c0e96b..c4966761dd 100644 --- a/pcbnew/zone.h +++ b/pcbnew/zone.h @@ -116,6 +116,7 @@ public: bool SameNet( const ZONE* aOther ) const; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; + wxString GetFriendlyName() const override; void SetLayerSet( LSET aLayerSet ) override; virtual LSET GetLayerSet() const override { return m_layerSet; }