Add a few more schematic properties

This commit is contained in:
Jon Evans 2023-07-01 22:23:31 -04:00
parent efac777f28
commit 632e94ef81
7 changed files with 91 additions and 15 deletions

View File

@ -1630,13 +1630,18 @@ static struct EDA_SHAPE_DESC
.Map( SHAPE_T::CIRCLE, _HKI( "Circle" ) )
.Map( SHAPE_T::POLY, _HKI( "Polygon" ) )
.Map( SHAPE_T::BEZIER, _HKI( "Bezier" ) );
ENUM_MAP<PLOT_DASH_TYPE>::Instance()
.Map( PLOT_DASH_TYPE::DEFAULT, _HKI( "Default" ) )
.Map( PLOT_DASH_TYPE::SOLID, _HKI( "Solid" ) )
.Map( PLOT_DASH_TYPE::DASH, _HKI( "Dashed" ) )
.Map( PLOT_DASH_TYPE::DOT, _HKI( "Dotted" ) )
.Map( PLOT_DASH_TYPE::DASHDOT, _HKI( "Dash-Dot" ) )
.Map( PLOT_DASH_TYPE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
auto& plotDashTypeEnum = ENUM_MAP<PLOT_DASH_TYPE>::Instance();
if( plotDashTypeEnum.Choices().GetCount() == 0 )
{
plotDashTypeEnum.Map( PLOT_DASH_TYPE::DEFAULT, _HKI( "Default" ) )
.Map( PLOT_DASH_TYPE::SOLID, _HKI( "Solid" ) )
.Map( PLOT_DASH_TYPE::DASH, _HKI( "Dashed" ) )
.Map( PLOT_DASH_TYPE::DOT, _HKI( "Dotted" ) )
.Map( PLOT_DASH_TYPE::DASHDOT, _HKI( "Dash-Dot" ) )
.Map( PLOT_DASH_TYPE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
}
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( EDA_SHAPE );

View File

@ -190,6 +190,12 @@ void SCH_BUS_ENTRY_BASE::SetPenWidth( int aWidth )
}
int SCH_BUS_ENTRY_BASE::GetPenWidth() const
{
return m_lastResolvedWidth;
}
void SCH_BUS_ENTRY_BASE::SetBusEntryColor( const COLOR4D& aColor )
{
m_stroke.SetColor( aColor );
@ -581,5 +587,32 @@ static struct SCH_BUS_ENTRY_DESC
propMgr.InheritsAfter( TYPE_HASH( SCH_BUS_ENTRY_BASE ), TYPE_HASH( SCH_ITEM ) );
propMgr.InheritsAfter( TYPE_HASH( SCH_BUS_WIRE_ENTRY ), TYPE_HASH( SCH_BUS_ENTRY_BASE ) );
propMgr.InheritsAfter( TYPE_HASH( SCH_BUS_BUS_ENTRY ), TYPE_HASH( SCH_BUS_ENTRY_BASE ) );
auto& plotDashTypeEnum = ENUM_MAP<PLOT_DASH_TYPE>::Instance();
if( plotDashTypeEnum.Choices().GetCount() == 0 )
{
plotDashTypeEnum.Map( PLOT_DASH_TYPE::DEFAULT, _HKI( "Default" ) )
.Map( PLOT_DASH_TYPE::SOLID, _HKI( "Solid" ) )
.Map( PLOT_DASH_TYPE::DASH, _HKI( "Dashed" ) )
.Map( PLOT_DASH_TYPE::DOT, _HKI( "Dotted" ) )
.Map( PLOT_DASH_TYPE::DASHDOT, _HKI( "Dash-Dot" ) )
.Map( PLOT_DASH_TYPE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
}
// TODO: Maybe SCH_BUS_ENTRY_BASE should inherit from or mix in with SCH_LINE
void ( SCH_BUS_ENTRY_BASE::*lineStyleSetter )( PLOT_DASH_TYPE ) =
&SCH_BUS_ENTRY_BASE::SetLineStyle;
propMgr.AddProperty( new PROPERTY_ENUM<SCH_BUS_ENTRY_BASE, PLOT_DASH_TYPE>(
_HKI( "Line Style" ),
lineStyleSetter, &SCH_BUS_ENTRY_BASE::GetLineStyle ) );
propMgr.AddProperty( new PROPERTY<SCH_BUS_ENTRY_BASE, int>( _HKI( "Line Width" ),
&SCH_BUS_ENTRY_BASE::SetPenWidth, &SCH_BUS_ENTRY_BASE::GetPenWidth,
PROPERTY_DISPLAY::PT_SIZE ) );
propMgr.AddProperty( new PROPERTY<SCH_BUS_ENTRY_BASE, COLOR4D>( _HKI( "Color" ),
&SCH_BUS_ENTRY_BASE::SetBusEntryColor, &SCH_BUS_ENTRY_BASE::GetBusEntryColor ) );
}
} _SCH_BUS_ENTRY_DESC;

View File

@ -71,6 +71,8 @@ public:
VECTOR2I GetSize() const { return m_size; }
void SetSize( const VECTOR2I& aSize ) { m_size = aSize; }
// Base class getter unused; necessary for property to compile
int GetPenWidth() const override;
void SetPenWidth( int aWidth );
virtual bool HasLineStroke() const override { return true; }

View File

@ -312,5 +312,9 @@ static struct SCH_JUNCTION_DESC
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( SCH_JUNCTION );
propMgr.InheritsAfter( TYPE_HASH( SCH_JUNCTION ), TYPE_HASH( SCH_ITEM ) );
propMgr.AddProperty( new PROPERTY<SCH_JUNCTION, int>( _HKI( "Diameter" ),
&SCH_JUNCTION::SetDiameter, &SCH_JUNCTION::GetDiameter,
PROPERTY_DISPLAY::PT_SIZE ) );
}
} _SCH_JUNCTION_DESC;

View File

@ -980,13 +980,17 @@ static struct SCH_LINE_DESC
{
SCH_LINE_DESC()
{
ENUM_MAP<PLOT_DASH_TYPE>::Instance()
.Map( PLOT_DASH_TYPE::DEFAULT, _HKI( "Default" ) )
.Map( PLOT_DASH_TYPE::SOLID, _HKI( "Solid" ) )
.Map( PLOT_DASH_TYPE::DASH, _HKI( "Dashed" ) )
.Map( PLOT_DASH_TYPE::DOT, _HKI( "Dotted" ) )
.Map( PLOT_DASH_TYPE::DASHDOT, _HKI( "Dash-Dot" ) )
.Map( PLOT_DASH_TYPE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
auto& plotDashTypeEnum = ENUM_MAP<PLOT_DASH_TYPE>::Instance();
if( plotDashTypeEnum.Choices().GetCount() == 0 )
{
plotDashTypeEnum.Map( PLOT_DASH_TYPE::DEFAULT, _HKI( "Default" ) )
.Map( PLOT_DASH_TYPE::SOLID, _HKI( "Solid" ) )
.Map( PLOT_DASH_TYPE::DASH, _HKI( "Dashed" ) )
.Map( PLOT_DASH_TYPE::DOT, _HKI( "Dotted" ) )
.Map( PLOT_DASH_TYPE::DASHDOT, _HKI( "Dash-Dot" ) )
.Map( PLOT_DASH_TYPE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
}
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( SCH_LINE );
@ -998,6 +1002,9 @@ static struct SCH_LINE_DESC
lineStyleSetter, &SCH_LINE::GetLineStyle ) );
propMgr.AddProperty( new PROPERTY<SCH_LINE, int>( _HKI( "Line Width" ),
&SCH_LINE::SetLineWidth, &SCH_LINE::GetLineWidth ) );
&SCH_LINE::SetLineWidth, &SCH_LINE::GetLineWidth, PROPERTY_DISPLAY::PT_SIZE ) );
propMgr.AddProperty( new PROPERTY<SCH_LINE, COLOR4D>( _HKI( "Color" ),
&SCH_LINE::SetLineColor, &SCH_LINE::GetLineColor ) );
}
} _SCH_LINE_DESC;

View File

@ -424,5 +424,14 @@ static struct SCH_PIN_DESC
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( SCH_PIN );
propMgr.InheritsAfter( TYPE_HASH( SCH_PIN ), TYPE_HASH( SCH_ITEM ) );
propMgr.AddProperty( new PROPERTY<SCH_PIN, wxString>( _HKI( "Pin Name" ),
NO_SETTER( SCH_PIN, wxString ), &SCH_PIN::GetName ) );
propMgr.AddProperty( new PROPERTY<SCH_PIN, wxString>( _HKI( "Pin Number" ),
NO_SETTER( SCH_PIN, wxString ), &SCH_PIN::GetNumber ) );
propMgr.AddProperty( new PROPERTY<SCH_PIN, int>( _HKI( "Length" ),
NO_SETTER( SCH_PIN, int ), &SCH_PIN::GetLength, PROPERTY_DISPLAY::PT_SIZE ) );
}
} _SCH_PIN_DESC;

View File

@ -366,3 +366,19 @@ void SCH_SHEET_PIN::Show( int nestLevel, std::ostream& os ) const
}
#endif
static struct SCH_SHEET_PIN_DESC
{
SCH_SHEET_PIN_DESC()
{
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( SCH_SHEET_PIN );
propMgr.AddTypeCast( new TYPE_CAST<SCH_SHEET_PIN, SCH_HIERLABEL> );
propMgr.AddTypeCast( new TYPE_CAST<SCH_SHEET_PIN, SCH_LABEL_BASE> );
propMgr.AddTypeCast( new TYPE_CAST<SCH_SHEET_PIN, SCH_TEXT> );
propMgr.AddTypeCast( new TYPE_CAST<SCH_SHEET_PIN, EDA_TEXT> );
propMgr.InheritsAfter( TYPE_HASH( SCH_SHEET_PIN ), TYPE_HASH( SCH_HIERLABEL ) );
}
} _SCH_SHEET_PIN_DESC;