Updated classes meta-data to take advantage of property replacement

This commit is contained in:
Maciej Suminski 2020-02-05 16:04:12 +01:00 committed by Tomasz Wlostowski
parent f084a86601
commit 04728278c0
5 changed files with 46 additions and 72 deletions

View File

@ -208,7 +208,11 @@ static struct BOARD_CONNECTED_ITEM_DESC
REGISTER_TYPE( BOARD_CONNECTED_ITEM );
propMgr.InheritsAfter( TYPE_HASH( BOARD_CONNECTED_ITEM ), TYPE_HASH( BOARD_ITEM ) );
propMgr.AddProperty( new PROPERTY<BOARD_CONNECTED_ITEM, int>( _( "Net" ),
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _( "Layer" ),
new PROPERTY_ENUM<BOARD_CONNECTED_ITEM, PCB_LAYER_ID, BOARD_ITEM>( _( "Layer" ),
&BOARD_CONNECTED_ITEM::SetLayer, &BOARD_CONNECTED_ITEM::GetLayer ) );
propMgr.AddProperty( new PROPERTY_ENUM<BOARD_CONNECTED_ITEM, int>( _( "Net" ),
&BOARD_CONNECTED_ITEM::SetNetCode, &BOARD_CONNECTED_ITEM::GetNetCode ) );
propMgr.AddProperty( new PROPERTY<BOARD_CONNECTED_ITEM, wxString>( _( "Net class" ),
NO_SETTER( BOARD_CONNECTED_ITEM, wxString ), &BOARD_CONNECTED_ITEM::GetNetClassName ) );

View File

@ -148,57 +148,12 @@ static struct BOARD_ITEM_DESC
{
BOARD_ITEM_DESC()
{
ENUM_MAP<PCB_LAYER_ID>::Instance()
.Map( F_Cu, LSET::Name( F_Cu ) )
.Map( In1_Cu, LSET::Name( In1_Cu ) )
.Map( In2_Cu, LSET::Name( In2_Cu ) )
.Map( In3_Cu, LSET::Name( In3_Cu ) )
.Map( In4_Cu, LSET::Name( In4_Cu ) )
.Map( In5_Cu, LSET::Name( In5_Cu ) )
.Map( In6_Cu, LSET::Name( In6_Cu ) )
.Map( In7_Cu, LSET::Name( In7_Cu ) )
.Map( In8_Cu, LSET::Name( In8_Cu ) )
.Map( In9_Cu, LSET::Name( In9_Cu ) )
.Map( In10_Cu, LSET::Name( In10_Cu ) )
.Map( In11_Cu, LSET::Name( In11_Cu ) )
.Map( In12_Cu, LSET::Name( In12_Cu ) )
.Map( In13_Cu, LSET::Name( In13_Cu ) )
.Map( In14_Cu, LSET::Name( In14_Cu ) )
.Map( In15_Cu, LSET::Name( In15_Cu ) )
.Map( In16_Cu, LSET::Name( In16_Cu ) )
.Map( In17_Cu, LSET::Name( In17_Cu ) )
.Map( In18_Cu, LSET::Name( In18_Cu ) )
.Map( In19_Cu, LSET::Name( In19_Cu ) )
.Map( In20_Cu, LSET::Name( In20_Cu ) )
.Map( In21_Cu, LSET::Name( In21_Cu ) )
.Map( In22_Cu, LSET::Name( In22_Cu ) )
.Map( In23_Cu, LSET::Name( In23_Cu ) )
.Map( In24_Cu, LSET::Name( In24_Cu ) )
.Map( In25_Cu, LSET::Name( In25_Cu ) )
.Map( In26_Cu, LSET::Name( In26_Cu ) )
.Map( In27_Cu, LSET::Name( In27_Cu ) )
.Map( In28_Cu, LSET::Name( In28_Cu ) )
.Map( In29_Cu, LSET::Name( In29_Cu ) )
.Map( In30_Cu, LSET::Name( In30_Cu ) )
.Map( B_Cu, LSET::Name( B_Cu ) )
.Map( B_Adhes, LSET::Name( B_Adhes ) )
.Map( F_Adhes, LSET::Name( F_Adhes ) )
.Map( B_Paste, LSET::Name( B_Paste ) )
.Map( F_Paste, LSET::Name( F_Paste ) )
.Map( B_SilkS, LSET::Name( B_SilkS ) )
.Map( F_SilkS, LSET::Name( F_SilkS ) )
.Map( B_Mask, LSET::Name( B_Mask ) )
.Map( F_Mask, LSET::Name( F_Mask ) )
.Map( Dwgs_User, LSET::Name( Dwgs_User ) )
.Map( Cmts_User, LSET::Name( Cmts_User ) )
.Map( Eco1_User, LSET::Name( Eco1_User ) )
.Map( Eco2_User, LSET::Name( Eco2_User ) )
.Map( Edge_Cuts, LSET::Name( Edge_Cuts ) )
.Map( Margin, LSET::Name( Margin ) )
.Map( B_CrtYd, LSET::Name( B_CrtYd ) )
.Map( F_CrtYd, LSET::Name( F_CrtYd ) )
.Map( B_Fab, LSET::Name( B_Fab ) )
.Map( F_Fab, LSET::Name( F_Fab ) );
auto& layerEnum = ENUM_MAP<PCB_LAYER_ID>::Instance();
for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
{
layerEnum.Map( *seq, LSET::Name( *seq ) );
}
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( BOARD_ITEM );

View File

@ -1520,6 +1520,10 @@ static struct MODULE_DESC
{
MODULE_DESC()
{
wxPGChoices fpLayers; // footprints might be placed only on F.Cu & B.Cu
fpLayers.Add( LSET::Name( F_Cu ), F_Cu );
fpLayers.Add( LSET::Name( B_Cu ), B_Cu );
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( MODULE );
propMgr.AddTypeCast( new TYPE_CAST<MODULE, BOARD_ITEM> );
@ -1527,6 +1531,11 @@ static struct MODULE_DESC
propMgr.InheritsAfter( TYPE_HASH( MODULE ), TYPE_HASH( BOARD_ITEM ) );
propMgr.InheritsAfter( TYPE_HASH( MODULE ), TYPE_HASH( BOARD_ITEM_CONTAINER ) );
auto layer = new PROPERTY_ENUM<MODULE, PCB_LAYER_ID, BOARD_ITEM>( _( "Layer" ),
&MODULE::SetLayer, &MODULE::GetLayer );
layer->SetChoices( fpLayers );
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _( "Layer" ), layer );
propMgr.AddProperty( new PROPERTY<MODULE, wxString>( _( "Reference" ),
&MODULE::SetReference, &MODULE::GetReference ) );
propMgr.AddProperty( new PROPERTY<MODULE, wxString>( _( "Value" ),

View File

@ -1194,10 +1194,13 @@ static struct PAD_DESC
PAD_DESC()
{
ENUM_MAP<PAD_SHAPE_T>::Instance()
.Map( PAD_SHAPE_CIRCLE, _( "Circle" ) )
.Map( PAD_SHAPE_RECT, _( "Rectangle" ) )
.Map( PAD_SHAPE_OVAL, _( "Oval" ) )
.Map( PAD_SHAPE_TRAPEZOID, _( "Trapezoid" ) )
.Map( PAD_SHAPE_ROUNDRECT, _( "Rounded Rectangular" ) );
.Map( PAD_SHAPE_ROUNDRECT, _( "Rounded Rectangle" ) )
.Map( PAD_SHAPE_CHAMFERED_RECT, _( "Chamfered Rectangle" ) )
.Map( PAD_SHAPE_CUSTOM, _( "Chamfered Rectangle" ) );
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( D_PAD );

View File

@ -983,9 +983,9 @@ static struct TRACK_VIA_DESC
TRACK_VIA_DESC()
{
ENUM_MAP<VIATYPE>::Instance()
.Map( VIATYPE::THROUGH, _( "Through" ) )
.Map( VIATYPE::BLIND_BURIED, _( "Blind/Buried" ) )
.Map( VIATYPE::MICROVIA, _( "Microvia" ) );
.Map( VIATYPE::THROUGH, _( "Through" ) )
.Map( VIATYPE::BLIND_BURIED, _( "Blind/Buried" ) )
.Map( VIATYPE::MICROVIA, _( "Microvia" ) );
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
@ -994,33 +994,36 @@ static struct TRACK_VIA_DESC
propMgr.InheritsAfter( TYPE_HASH( TRACK ), TYPE_HASH( BOARD_CONNECTED_ITEM ) );
propMgr.AddProperty( new PROPERTY<TRACK, int>( _( "Width" ),
&TRACK::SetWidth, &TRACK::GetWidth, PROPERTY_DISPLAY::DISTANCE ) );
//propMgr.AddProperty( new PROPERTY<TRACK, int>( _( "Origin X" ),
//&TRACK::SetX, &TRACK::GetX, PROPERTY_DISPLAY::DISTANCE ) );
//propMgr.AddProperty( new PROPERTY<TRACK, int>( _( "Origin Y" ),
//&TRACK::SetY, &TRACK::GetY, PROPERTY_DISPLAY::DISTANCE ) );
&TRACK::SetWidth, &TRACK::GetWidth, PROPERTY_DISPLAY::DISTANCE ) );
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _( "Position X" ),
new PROPERTY<TRACK, int, BOARD_ITEM>( _( "Origin X" ),
&TRACK::SetX, &TRACK::GetX, PROPERTY_DISPLAY::DISTANCE ) );
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _( "Position Y" ),
new PROPERTY<TRACK, int, BOARD_ITEM>( _( "Origin Y" ),
&TRACK::SetY, &TRACK::GetY, PROPERTY_DISPLAY::DISTANCE ) );
propMgr.AddProperty( new PROPERTY<TRACK, int>( _( "End X" ),
&TRACK::SetEndX, &TRACK::GetEndX, PROPERTY_DISPLAY::DISTANCE ) );
&TRACK::SetEndX, &TRACK::GetEndX, PROPERTY_DISPLAY::DISTANCE ) );
propMgr.AddProperty( new PROPERTY<TRACK, int>( _( "End Y" ),
&TRACK::SetEndY, &TRACK::GetEndY, PROPERTY_DISPLAY::DISTANCE ) );
&TRACK::SetEndY, &TRACK::GetEndY, PROPERTY_DISPLAY::DISTANCE ) );
// Via
REGISTER_TYPE( VIA );
propMgr.InheritsAfter( TYPE_HASH( VIA ), TYPE_HASH( BOARD_CONNECTED_ITEM ) );
// TODO layerset for vias?
// TODO rename width to radius
// TODO test drill, use getdrillvalue?
//propMgr.AddProperty( new PROPERTY<VIA, int>( _( "Radius" ),
//&VIA::SetWidth, &VIA::GetWidth, PROPERTY_DISPLAY::DISTANCE ) );
propMgr.AddProperty( new PROPERTY<VIA, int>( "Drill",
&VIA::SetDrill, &VIA::GetDrillValue, PROPERTY_DISPLAY::DISTANCE ) );
//propMgr.AddProperty( new PROPERTY_ENUM<VIA, PCB_LAYER_ID>( _( "Layer Top" ),
//&VIA::SetLayer, &VIA::GetLayer ) );
propMgr.ReplaceProperty( TYPE_HASH( TRACK ), _( "Width" ),
new PROPERTY<VIA, int, TRACK>( _( "Diameter" ), &VIA::SetWidth, &VIA::GetWidth,
PROPERTY_DISPLAY::DISTANCE ) );
propMgr.AddProperty( new PROPERTY<VIA, int>( _( "Drill" ),
&VIA::SetDrill, &VIA::GetDrillValue, PROPERTY_DISPLAY::DISTANCE ) );
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _( "Layer" ),
new PROPERTY_ENUM<VIA, PCB_LAYER_ID, BOARD_ITEM>( _( "Layer Top" ),
&VIA::SetLayer, &VIA::GetLayer ) );
propMgr.AddProperty( new PROPERTY_ENUM<VIA, PCB_LAYER_ID>( _( "Layer Bottom" ),
&VIA::SetBottomLayer, &VIA::BottomLayer ) );
&VIA::SetBottomLayer, &VIA::BottomLayer ) );
propMgr.AddProperty( new PROPERTY_ENUM<VIA, VIATYPE>( _( "Via Type" ),
&VIA::SetViaType, &VIA::GetViaType ) );
&VIA::SetViaType, &VIA::GetViaType ) );
}
} _TRACK_VIA_DESC;