Add missing rule generation for permitted layers and allowed orientation

These constraint data classes had GetOverlayBitmap, GetFieldPositions,
and Validate overrides but were missing GetConstraintClauses and
GenerateRule, causing the overlay panels to generate empty rule text.

Port the rule generation logic from the old-style panels that were
removed in 080b4a74bf.
This commit is contained in:
Seth Hillbrand
2026-02-18 22:27:16 -08:00
parent 8da6e447cd
commit e6a7ea14da
2 changed files with 63 additions and 0 deletions
@@ -68,6 +68,50 @@ public:
};
}
std::vector<wxString> 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;
@@ -59,6 +59,25 @@ public:
};
}
std::vector<wxString> 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;