diff --git a/pcbnew/drc/rule_editor/drc_re_allowed_orientation_constraint_data.h b/pcbnew/drc/rule_editor/drc_re_allowed_orientation_constraint_data.h index f308c908f3..69962b241a 100644 --- a/pcbnew/drc/rule_editor/drc_re_allowed_orientation_constraint_data.h +++ b/pcbnew/drc/rule_editor/drc_re_allowed_orientation_constraint_data.h @@ -68,6 +68,50 @@ public: }; } + std::vector GetConstraintClauses( const RULE_GENERATION_CONTEXT& aContext ) const override + { + wxString code = GetConstraintCode(); + + if( code.IsEmpty() ) + code = wxS( "allowed_orientation" ); + + wxString clause; + + if( m_allowAllDegrees ) + { + clause = wxString::Format( wxS( "(constraint %s (any true))" ), code ); + } + else + { + wxArrayString angles; + + if( m_allowZeroDegreess ) + angles.Add( wxS( "0" ) ); + + if( m_allowNinetyDegrees ) + angles.Add( wxS( "90" ) ); + + if( m_allowOneEightyDegrees ) + angles.Add( wxS( "180" ) ); + + if( m_allowTwoSeventyDegrees ) + angles.Add( wxS( "270" ) ); + + if( angles.IsEmpty() ) + clause = wxString::Format( wxS( "(constraint %s (angles none))" ), code ); + else + clause = wxString::Format( wxS( "(constraint %s (angles %s))" ), code, + wxJoin( angles, ' ' ) ); + } + + return { clause }; + } + + wxString GenerateRule( const RULE_GENERATION_CONTEXT& aContext ) override + { + return buildRule( aContext, GetConstraintClauses( aContext ) ); + } + VALIDATION_RESULT Validate() const override { VALIDATION_RESULT result; diff --git a/pcbnew/drc/rule_editor/drc_re_permitted_layers_constraint_data.h b/pcbnew/drc/rule_editor/drc_re_permitted_layers_constraint_data.h index ccce65a528..7c98b6a918 100644 --- a/pcbnew/drc/rule_editor/drc_re_permitted_layers_constraint_data.h +++ b/pcbnew/drc/rule_editor/drc_re_permitted_layers_constraint_data.h @@ -59,6 +59,25 @@ public: }; } + std::vector GetConstraintClauses( const RULE_GENERATION_CONTEXT& aContext ) const override + { + wxString code = GetConstraintCode(); + + if( code.IsEmpty() ) + code = wxS( "permitted_layers" ); + + wxString topState = m_topLayer ? wxS( "true" ) : wxS( "false" ); + wxString bottomState = m_bottomLayer ? wxS( "true" ) : wxS( "false" ); + + return { wxString::Format( wxS( "(constraint %s (top %s) (bottom %s))" ), + code, topState, bottomState ) }; + } + + wxString GenerateRule( const RULE_GENERATION_CONTEXT& aContext ) override + { + return buildRule( aContext, GetConstraintClauses( aContext ) ); + } + VALIDATION_RESULT Validate() const override { VALIDATION_RESULT result;