drc_proto: wip adding accessors to DRC_RULE/DRC_RULE_CONDITION
This commit is contained in:
parent
8e4a3f5e65
commit
05b88acf16
|
@ -27,13 +27,14 @@
|
||||||
#include <class_board_item.h>
|
#include <class_board_item.h>
|
||||||
|
|
||||||
#include <drc_proto/drc_rule.h>
|
#include <drc_proto/drc_rule.h>
|
||||||
|
#include <drc_proto/drc_engine.h>
|
||||||
#include <pcb_expr_evaluator.h>
|
#include <pcb_expr_evaluator.h>
|
||||||
|
|
||||||
|
|
||||||
test::DRC_RULE::DRC_RULE() :
|
test::DRC_RULE::DRC_RULE() :
|
||||||
m_Unary( false ),
|
m_Unary( false ),
|
||||||
m_Enabled( true ),
|
m_Enabled( true ),
|
||||||
m_Priority( 0 ),
|
m_priority( 0 ),
|
||||||
m_Severity( DRC_RULE_SEVERITY_T::DRC_SEVERITY_ERROR ),
|
m_Severity( DRC_RULE_SEVERITY_T::DRC_SEVERITY_ERROR ),
|
||||||
m_condition( nullptr )
|
m_condition( nullptr )
|
||||||
{
|
{
|
||||||
|
@ -50,9 +51,13 @@ void test::DRC_RULE::AddConstraint( DRC_CONSTRAINT& aConstraint )
|
||||||
m_constraints.push_back( aConstraint );
|
m_constraints.push_back( aConstraint );
|
||||||
}
|
}
|
||||||
|
|
||||||
test::DRC_RULE_CONDITION::DRC_RULE_CONDITION()
|
test::DRC_RULE_CONDITION::DRC_RULE_CONDITION( const wxString& aExpression,
|
||||||
|
const LSET aLayerCondition ) :
|
||||||
|
|
||||||
|
m_expression( aExpression ),
|
||||||
|
m_layerCondition ( aLayerCondition ),
|
||||||
|
m_ucode ( nullptr )
|
||||||
{
|
{
|
||||||
m_ucode = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,6 +96,12 @@ bool test::DRC_RULE_CONDITION::Compile( REPORTER* aReporter, int aSourceLine, in
|
||||||
PCB_EXPR_CONTEXT preflightContext( F_Cu );
|
PCB_EXPR_CONTEXT preflightContext( F_Cu );
|
||||||
|
|
||||||
bool ok = compiler.Compile( m_expression, m_ucode.get(), &preflightContext );
|
bool ok = compiler.Compile( m_expression, m_ucode.get(), &preflightContext );
|
||||||
|
|
||||||
|
if(!ok)
|
||||||
|
{
|
||||||
|
drc_dbg(1, "Error: %s", compiler.GetError().message );
|
||||||
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,8 +110,9 @@ private:
|
||||||
class DRC_CONSTRAINT
|
class DRC_CONSTRAINT
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DRC_CONSTRAINT() :
|
DRC_CONSTRAINT( DRC_CONSTRAINT_TYPE_T aType = DRC_CONSTRAINT_TYPE_T::DRC_CONSTRAINT_TYPE_UNKNOWN
|
||||||
m_Type( DRC_CONSTRAINT_TYPE_T::DRC_CONSTRAINT_TYPE_UNKNOWN ),
|
) :
|
||||||
|
m_Type( aType ),
|
||||||
m_DisallowFlags( 0 ),
|
m_DisallowFlags( 0 ),
|
||||||
m_LayerCondition( LSET::AllLayersMask() ),
|
m_LayerCondition( LSET::AllLayersMask() ),
|
||||||
m_parentRule( nullptr ) // fixme
|
m_parentRule( nullptr ) // fixme
|
||||||
|
@ -152,12 +153,15 @@ public:
|
||||||
virtual bool IsEnabled() const { return m_Enabled; }
|
virtual bool IsEnabled() const { return m_Enabled; }
|
||||||
|
|
||||||
virtual bool HasSpecificItemSet() const { return false; };
|
virtual bool HasSpecificItemSet() const { return false; };
|
||||||
virtual void FillSpecificItemSet( std::vector<BOARD_ITEM*> specificItems ) { };
|
virtual void FillSpecificItemSet( std::set<BOARD_ITEM*> specificItems ) { };
|
||||||
|
|
||||||
|
void SetPriority( int aPriority ) { m_priority = aPriority; }
|
||||||
|
int GetPriority() const { return m_priority; }
|
||||||
|
|
||||||
int GetPriority() const { return m_Priority; }
|
|
||||||
DRC_RULE_SEVERITY_T GetSeverity() const { return m_Severity; }
|
DRC_RULE_SEVERITY_T GetSeverity() const { return m_Severity; }
|
||||||
|
|
||||||
const wxString GetName() const { return m_Name; }
|
void SetName( const wxString& aName ) { m_name = aName; }
|
||||||
|
const wxString GetName() const { return m_name; }
|
||||||
|
|
||||||
std::vector<DRC_CONSTRAINT>& Constraints()
|
std::vector<DRC_CONSTRAINT>& Constraints()
|
||||||
{
|
{
|
||||||
|
@ -186,24 +190,28 @@ public:
|
||||||
m_layerCondition = aLayerCondition;
|
m_layerCondition = aLayerCondition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString m_name;
|
||||||
|
int m_priority; // 0 indicates automatic priority generation fixme: use enum
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool m_Unary;
|
bool m_Unary;
|
||||||
|
|
||||||
wxString m_Name;
|
|
||||||
LSET m_layerCondition;
|
LSET m_layerCondition;
|
||||||
DRC_RULE_CONDITION* m_condition; // fixme: consider unique_ptr
|
DRC_RULE_CONDITION* m_condition; // fixme: consider unique_ptr
|
||||||
std::vector<DRC_CONSTRAINT> m_constraints;
|
std::vector<DRC_CONSTRAINT> m_constraints;
|
||||||
|
|
||||||
DRC_RULE_SEVERITY_T m_Severity;
|
DRC_RULE_SEVERITY_T m_Severity;
|
||||||
bool m_Enabled;
|
bool m_Enabled;
|
||||||
int m_Priority; // 0 indicates automatic priority generation
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class DRC_RULE_CONDITION
|
class DRC_RULE_CONDITION
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DRC_RULE_CONDITION();
|
DRC_RULE_CONDITION( const wxString& aExpression = "",
|
||||||
|
const LSET aLayerCondition = LSET::AllLayersMask() );
|
||||||
~DRC_RULE_CONDITION();
|
~DRC_RULE_CONDITION();
|
||||||
|
|
||||||
bool EvaluateFor( const BOARD_ITEM* aItemA, const BOARD_ITEM* aItemB,
|
bool EvaluateFor( const BOARD_ITEM* aItemA, const BOARD_ITEM* aItemB,
|
||||||
|
|
|
@ -169,7 +169,7 @@ test::DRC_RULE* test::DRC_RULES_PARSER::parseDRC_RULE()
|
||||||
if( !IsSymbol( token ) )
|
if( !IsSymbol( token ) )
|
||||||
reportError( _( "Missing rule name." ) );
|
reportError( _( "Missing rule name." ) );
|
||||||
|
|
||||||
rule->m_Name = FromUTF8();
|
rule->SetName( FromUTF8() );
|
||||||
|
|
||||||
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
|
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue