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
This commit is contained in:
Jon Evans 2022-11-25 11:49:21 -05:00
parent 4aff5c7618
commit 220ef6fb44
9 changed files with 96 additions and 21 deletions

View File

@ -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<KICAD_T>
wxString typeDescr = ENUM_MAP<KICAD_T>::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<EDA_ITEM, KICAD_T>( "Type",
NO_SETTER( EDA_ITEM, KICAD_T ), &EDA_ITEM::Type ) );
auto typeProp = new PROPERTY_ENUM<EDA_ITEM, KICAD_T>( "Type",
NO_SETTER( EDA_ITEM, KICAD_T ), &EDA_ITEM::Type );
typeProp->SetIsInternal( true );
propMgr.AddProperty( typeProp );
}
} _EDA_ITEM_DESC;

View File

@ -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<PROPERTY_BASE*>( aProperty ) );
}

View File

@ -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;

View File

@ -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

View File

@ -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<typename T>
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<bool(INSPECTABLE*)> m_availFunc; ///< Eval to determine if prop is available
friend class INSPECTABLE;

View File

@ -2858,15 +2858,26 @@ static struct FOOTPRINT_DESC
propMgr.AddProperty( new PROPERTY<FOOTPRINT, int>( _HKI( "Solderpaste Margin Override" ),
&FOOTPRINT::SetLocalSolderPasteMargin, &FOOTPRINT::GetLocalSolderPasteMargin,
PROPERTY_DISPLAY::PT_SIZE ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, double>( _HKI( "Solderpaste Margin Ratio Override" ),
propMgr.AddProperty( new PROPERTY<FOOTPRINT, double>(
_HKI( "Solderpaste Margin Ratio Override" ),
&FOOTPRINT::SetLocalSolderPasteMarginRatio,
&FOOTPRINT::GetLocalSolderPasteMarginRatio ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Library ID" ),
&FOOTPRINT::SetFPIDAsString, &FOOTPRINT::GetFPIDAsString ) );
&FOOTPRINT::GetLocalSolderPasteMarginRatio ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Library link" ),
NO_SETTER( FOOTPRINT, wxString ), &FOOTPRINT::GetFPIDAsString ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Description" ),
&FOOTPRINT::SetDescription, &FOOTPRINT::GetDescription ) );
NO_SETTER( FOOTPRINT, wxString ), &FOOTPRINT::GetDescription ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Keywords" ),
&FOOTPRINT::SetKeywords, &FOOTPRINT::GetKeywords ) );
NO_SETTER( FOOTPRINT, wxString ), &FOOTPRINT::GetKeywords ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, bool>( _HKI( "Not in schematic" ),
&FOOTPRINT::SetBoardOnly, &FOOTPRINT::IsBoardOnly ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, bool>( _HKI( "Exclude from position files" ),
&FOOTPRINT::SetExcludedFromPosFiles, &FOOTPRINT::IsExcludedFromPosFiles ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, bool>( _HKI( "Exclude from BOM" ),
&FOOTPRINT::SetExcludedFromBOM, &FOOTPRINT::IsExcludedFromBOM ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, bool>(
_HKI( "Exempt from courtyard requirement" ),
&FOOTPRINT::SetAllowMissingCourtyard, &FOOTPRINT::AllowMissingCourtyard ) );
// TODO zone connection
}
} _FOOTPRINT_DESC;

View File

@ -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.
*

View File

@ -517,16 +517,7 @@ bool ZONE::HitTestCutout( const VECTOR2I& aRefPos, int* aOutlineIdx, int* aHoleI
void ZONE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& 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;

View File

@ -116,6 +116,7 @@ public:
bool SameNet( const ZONE* aOther ) const;
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
wxString GetFriendlyName() const override;
void SetLayerSet( LSET aLayerSet ) override;
virtual LSET GetLayerSet() const override { return m_layerSet; }