mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-11 12:40:12 +00:00
Fix use of footprint Orientation property in DRC expression parser
This commit is contained in:
parent
c92014f759
commit
3d41eca856
@ -428,6 +428,17 @@ LIBEVAL::VALUE* PCBEXPR_TYPE_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
|
||||
}
|
||||
|
||||
|
||||
LIBEVAL::VALUE* PCBORIENTATION_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
|
||||
{
|
||||
BOARD_ITEM* item = GetObject( aCtx );
|
||||
|
||||
if( !item || item->Type() != PCB_FOOTPRINT_T )
|
||||
return new LIBEVAL::VALUE();
|
||||
|
||||
return new LIBEVAL::VALUE( static_cast<FOOTPRINT*>( item )->GetOrientationDegrees() );
|
||||
}
|
||||
|
||||
|
||||
LIBEVAL::FUNC_CALL_REF PCBEXPR_UCODE::CreateFuncCall( const wxString& aName )
|
||||
{
|
||||
PCBEXPR_BUILTIN_FUNCTIONS& registry = PCBEXPR_BUILTIN_FUNCTIONS::Instance();
|
||||
@ -487,6 +498,15 @@ std::unique_ptr<LIBEVAL::VAR_REF> PCBEXPR_UCODE::CreateVarRef( const wxString& a
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
else if( aField.CmpNoCase( wxT( "Orientation" ) ) == 0 )
|
||||
{
|
||||
if( aVar == wxT( "A" ) )
|
||||
return std::make_unique<PCBORIENTATION_REF>( 0 );
|
||||
else if( aVar == wxT( "B" ) )
|
||||
return std::make_unique<PCBORIENTATION_REF>( 1 );
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if( aVar == wxT( "A" ) || aVar == wxT( "AB" ) )
|
||||
vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
|
||||
@ -530,6 +550,7 @@ std::unique_ptr<LIBEVAL::VAR_REF> PCBEXPR_UCODE::CreateVarRef( const wxString& a
|
||||
{
|
||||
vref->SetType( LIBEVAL::VT_STRING );
|
||||
}
|
||||
|
||||
else if ( prop->HasChoices() )
|
||||
{ // it's an enum, we treat it as string
|
||||
vref->SetType( LIBEVAL::VT_STRING );
|
||||
@ -569,7 +590,7 @@ BOARD* PCBEXPR_CONTEXT::GetBoard() const
|
||||
|
||||
const std::vector<wxString>& PCBEXPR_UNIT_RESOLVER::GetSupportedUnits() const
|
||||
{
|
||||
static const std::vector<wxString> pcbUnits = { wxT( "mil" ), wxT( "mm" ), wxT( "in" ) };
|
||||
static const std::vector<wxString> pcbUnits = { wxT( "mil" ), wxT( "mm" ), wxT( "in" ), wxT( "deg" ) };
|
||||
|
||||
return pcbUnits;
|
||||
}
|
||||
@ -577,7 +598,7 @@ const std::vector<wxString>& PCBEXPR_UNIT_RESOLVER::GetSupportedUnits() const
|
||||
|
||||
wxString PCBEXPR_UNIT_RESOLVER::GetSupportedUnitsMessage() const
|
||||
{
|
||||
return _( "must be mm, in, or mil" );
|
||||
return _( "must be mm, in, mil, or deg" );
|
||||
}
|
||||
|
||||
|
||||
|
@ -172,6 +172,19 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class PCBORIENTATION_REF : public PCBEXPR_VAR_REF
|
||||
{
|
||||
public:
|
||||
PCBORIENTATION_REF( int aItemIndex ) :
|
||||
PCBEXPR_VAR_REF( aItemIndex )
|
||||
{
|
||||
SetType( LIBEVAL::VT_NUMERIC );
|
||||
}
|
||||
|
||||
LIBEVAL::VALUE* GetValue( LIBEVAL::CONTEXT* aCtx ) override;
|
||||
};
|
||||
|
||||
|
||||
class PCBEXPR_BUILTIN_FUNCTIONS
|
||||
{
|
||||
public:
|
||||
|
@ -1975,7 +1975,7 @@ static struct ZONE_DESC
|
||||
groupFill )
|
||||
.SetAvailableFunc( isCopperZone );
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<ZONE, EDA_ANGLE>( _HKI( "Orientation" ),
|
||||
propMgr.AddProperty( new PROPERTY<ZONE, EDA_ANGLE>( _HKI( "Hatch Orientation" ),
|
||||
&ZONE::SetHatchOrientation, &ZONE::GetHatchOrientation,
|
||||
PROPERTY_DISPLAY::PT_DEGREE ),
|
||||
groupFill )
|
||||
|
Loading…
Reference in New Issue
Block a user