20#ifndef DRC_RE_VIA_STYLE_CONSTRAINT_DATA_H_
21#define DRC_RE_VIA_STYLE_CONSTRAINT_DATA_H_
47 double aMaxViaDiameter,
double aMinViaHoleSize,
double aMaxViaHoleSize,
69 _(
"Smallest allowed via diameter" ) },
73 _(
"Smallest allowed via hole diameter" ) },
77 _(
"Restrict this rule to a single via type" ) },
91 result.AddError(
_(
"Minimum Via Diameter cannot be negative" ) );
94 result.AddError(
_(
"Maximum Via Diameter cannot be negative" ) );
97 result.AddError(
_(
"Minimum Via Diameter cannot be greater than Maximum Via Diameter" ) );
103 result.AddError(
_(
"Minimum Via Hole Size cannot be negative" ) );
106 result.AddError(
_(
"Maximum Via Hole Size cannot be negative" ) );
109 result.AddError(
_(
"Minimum Via Hole Size cannot be greater than Maximum Via Hole Size" ) );
112 if( !hasDiameter && !hasHoleSize )
113 result.AddError(
_(
"At least one constraint must be specified" ) );
120 auto formatDimension = [](
double aValue )
125 auto formatRange = [&](
const wxString& aCode,
double aMin,
double aOpt,
double aMax )
127 wxString clause = wxS(
"(constraint " ) + aCode;
130 clause << wxS(
" (min " ) << formatDimension( aMin ) << wxS(
")" );
132 if( aOpt > 0 && aOpt >= aMin && ( aMax <= 0 || aOpt <= aMax ) )
133 clause << wxS(
" (opt " ) << formatDimension( aOpt ) << wxS(
")" );
136 clause << wxS(
" (max " ) << formatDimension( aMax ) << wxS(
")" );
138 return clause + wxS(
")" );
141 std::vector<wxString> clauses;
162 if( !viaTypeCondition.IsEmpty() )
212 default:
return wxEmptyString;
BITMAPS
A list of all bitmap identifiers.
static wxString formatDouble(double aValue, int aPrecision=6)
wxString buildRule(const RULE_GENERATION_CONTEXT &aContext, const std::vector< wxString > &aConstraintClauses) const
void CopyFrom(const ICopyable &aSource) override
DRC_RE_BASE_CONSTRAINT_DATA()=default
double GetOptViaHoleSize() const
double GetMaxViaDiameter()
wxString GetConditionPredicate() const override
Returns a predicate this panel holds in its own fields rather than in the rule condition,...
void SetMinViaDiameter(double aMinViaDiameter)
double GetOptViaDiameter() const
wxString GetViaTypeCondition() const
BITMAPS GetOverlayBitmap() const override
Returns the bitmap to use for the overlay panel background.
DRC_RE_VIA_STYLE_CONSTRAINT_DATA()=default
double GetMinViaHoleSize()
DRC_RE_VIA_STYLE_CONSTRAINT_DATA(int aId, const wxString &aRuleName, double aMinViaDiameter, double aMaxViaDiameter, double aMinViaHoleSize, double aMaxViaHoleSize, VIA_STYLE_TYPE aViaType=VIA_STYLE_TYPE::ANY)
double GetMinViaDiameter()
void SetMinViaHoleSize(double aMinViaHoleSize)
double GetMaxViaHoleSize()
void SetOptViaDiameter(double aOptViaDiameter)
void SetOptViaHoleSize(double aOptViaHoleSize)
void CopyFrom(const ICopyable &aSource) override
std::vector< wxString > GetConstraintClauses(const RULE_GENERATION_CONTEXT &aContext) const override
Returns just the constraint clauses without the rule wrapper.
VIA_STYLE_TYPE GetViaType() const
void SetMaxViaDiameter(double aMaxViaDiameter)
virtual ~DRC_RE_VIA_STYLE_CONSTRAINT_DATA()=default
DRC_RE_VIA_STYLE_CONSTRAINT_DATA(const DRC_RE_BASE_CONSTRAINT_DATA &aBaseData)
void SetMaxViaHoleSize(double aMaxViaHoleSize)
std::vector< DRC_RE_FIELD_POSITION > GetFieldPositions() const override
Returns the field positions for controls overlaid on the constraint bitmap.
void SetViaType(VIA_STYLE_TYPE aType)
VALIDATION_RESULT Validate() const override
Validates the constraint data.
wxString GenerateRule(const RULE_GENERATION_CONTEXT &aContext) override
Abstract interface class to enable polymorphic copying between objects.
@ RIGHT
Label to the right of the field.
@ LEFT
Label to the left of the field.
wxString conditionExpression
Result of a validation operation.
wxString result
Test unit parsing edge cases and error handling.