From 91ce549e63e5f022d7fae13ef25366bf218cea09 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Thu, 27 Aug 2020 00:04:53 +0200 Subject: [PATCH] PCB_EXPR_EVALUATOR: added isMicroVia() and isBlindBuriedVia() built-in methods --- pcbnew/pcb_expr_evaluator.cpp | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pcbnew/pcb_expr_evaluator.cpp b/pcbnew/pcb_expr_evaluator.cpp index ccdf646706..5a689cfe73 100644 --- a/pcbnew/pcb_expr_evaluator.cpp +++ b/pcbnew/pcb_expr_evaluator.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -210,6 +211,43 @@ static void insideArea( LIBEVAL::CONTEXT* aCtx, void* self ) } +static void isMicroVia( LIBEVAL::CONTEXT* aCtx, void* self ) +{ + PCB_EXPR_VAR_REF* vref = static_cast( self ); + BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr; + LIBEVAL::VALUE* result = aCtx->AllocValue(); + + result->Set( 0.0 ); + aCtx->Push( result ); + + auto via = dyn_cast( item ); + + if( via && via->GetViaType() == VIATYPE::MICROVIA ) + { + result->Set ( 1.0 ); + } +} + + +static void isBlindBuriedVia( LIBEVAL::CONTEXT* aCtx, void* self ) +{ + PCB_EXPR_VAR_REF* vref = static_cast( self ); + BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr; + LIBEVAL::VALUE* result = aCtx->AllocValue(); + + result->Set( 0.0 ); + aCtx->Push( result ); + + auto via = dyn_cast( item ); + + if( via && via->GetViaType() == VIATYPE::BLIND_BURIED ) + { + result->Set ( 1.0 ); + } + +} + + PCB_EXPR_BUILTIN_FUNCTIONS::PCB_EXPR_BUILTIN_FUNCTIONS() { auto registerFunc = [&]( const wxString& funcSignature, LIBEVAL::FUNC_CALL_REF funcPtr ) @@ -223,6 +261,8 @@ PCB_EXPR_BUILTIN_FUNCTIONS::PCB_EXPR_BUILTIN_FUNCTIONS() registerFunc( "isPlated()", isPlated ); registerFunc( "insideCourtyard('x')", insideCourtyard ); registerFunc( "insideArea('x')", insideArea ); + registerFunc( "isMicroVia()", isMicroVia ); + registerFunc( "isBlindBuriedVia()", isBlindBuriedVia ); }