24#ifndef DRC_RE_BASE_CONSTRAINT_DATA_H_
25#define DRC_RE_BASE_CONSTRAINT_DATA_H_
143 if( aRuleName.IsEmpty() )
144 return wxString( wxS(
"\"\"" ) );
146 bool needsQuoting =
false;
148 if( wxIsdigit( *aRuleName.begin() ) )
154 for( wxUniChar c : aRuleName )
156 if( !( wxIsalnum( c ) || c ==
'_' || c ==
'-' || c ==
'.' ) )
168 return wxString( wxS(
"\"" ) ) + escaped + wxS(
"\"" );
179 wxString
result( aValue );
181 if( !
result.Contains(
'.' ) )
187 if(
result.Last() ==
'.' )
195 wxString formatted = wxString::FromCDouble( aValue, aPrecision );
200 const std::vector<wxString>& aConstraintClauses )
const
205 if( !aContext.
comment.IsEmpty() )
207 wxArrayString lines = wxSplit( aContext.
comment,
'\n',
'\0' );
209 for(
const wxString& line : lines )
214 rule << wxS(
"\t# " ) << line << wxS(
"\n" );
222 if( aContext.
layerClause.StartsWith( wxS(
"(condition " ) ) )
224 wxString expr = aContext.
layerClause.AfterFirst(
'"' ).BeforeLast(
'"' );
226 if( !condExpr.IsEmpty() )
227 condExpr = expr + wxS(
" && " ) + condExpr;
233 rule << wxS(
"\t" ) << aContext.
layerClause << wxS(
"\n" );
237 for(
const wxString& clause : aConstraintClauses )
239 if( clause.IsEmpty() )
242 rule << wxS(
"\t" ) << clause << wxS(
"\n" );
245 if( !condExpr.IsEmpty() )
246 rule << wxS(
"\t(condition \"" ) <<
quoteString( condExpr ) << wxS(
"\")\n" );
BITMAPS
A list of all bitmap identifiers.
wxString GetConstraintCode() const
virtual VALIDATION_RESULT Validate() const
Validates the constraint data.
wxString m_layerSource
Original layer text: "inner", "outer", or layer name.
static wxString quoteString(const wxString &aCondition)
static wxString formatRuleName(const wxString &aRuleName)
Format a rule name for use in S-expression output while preserving the exact name the user chose.
void SetConstraintCode(const wxString &aCode)
static wxString formatDouble(double aValue, int aPrecision=6)
void SetLayers(std::vector< PCB_LAYER_ID > aLayers)
void SetGeneratedRule(const wxString &aRule)
virtual ~DRC_RE_BASE_CONSTRAINT_DATA()=default
SEVERITY GetSeverity() const
void SetLayerSource(const wxString &aSource)
virtual std::vector< wxString > GetConstraintClauses(const RULE_GENERATION_CONTEXT &aContext) const
Returns just the constraint clauses without the rule wrapper.
wxString m_constraintCode
void SetWasEdited(bool aEdited)
virtual std::vector< DRC_RE_FIELD_POSITION > GetFieldPositions() const
Returns the field positions for controls overlaid on the constraint bitmap.
wxString buildRule(const RULE_GENERATION_CONTEXT &aContext, const std::vector< wxString > &aConstraintClauses) const
wxString GetLayerSource()
static wxString trimTrailingZeros(const wxString &aValue)
DRC_RE_BASE_CONSTRAINT_DATA(int aId, int aParentId, const wxString &aRuleName)
std::vector< PCB_LAYER_ID > m_layers
wxString GetRuleCondition()
void SetSeverity(SEVERITY aSeverity)
void SetRuleCondition(const wxString &aRuleCondition)
virtual BITMAPS GetOverlayBitmap() const
Returns the bitmap to use for the overlay panel background.
void CopyFrom(const ICopyable &aSource) override
wxString m_originalRuleText
wxString GetOriginalRuleText() const
virtual wxString GenerateRule(const RULE_GENERATION_CONTEXT &aContext)
void SetOriginalRuleText(const wxString &aText)
std::vector< PCB_LAYER_ID > GetLayers()
wxString GetGeneratedRule() const
DRC_RE_BASE_CONSTRAINT_DATA()=default
Abstract interface class to enable polymorphic copying between objects.
RULE_EDITOR_DATA_BASE()=default
void CopyFrom(const ICopyable &aSource) override
Implementation of the polymorphic CopyFrom method.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
wxString conditionExpression
Result of a validation operation.
wxString result
Test unit parsing edge cases and error handling.