|
KiCad PCB EDA Suite
|
A constraint on a scalar value (counts, dimensions, etc.), supporting exact, min, and max bounds. More...
Classes | |
| struct | PARSED_SCALAR |
Public Types | |
| enum class | ROLE { COUNT , DIMENSION } |
Public Member Functions | |
| bool | Match (int aValue) const |
| Test if a value satisfies this constraint. | |
| bool | IsExact () const |
| std::optional< int > | GetMin () const |
| std::optional< int > | GetMax () const |
| std::string | Format (int aValue) const |
| Format a value for human-readable display. | |
| std::string | Describe () const |
Static Public Member Functions | |
| static SCALAR_CONSTRAINT | FromJson (const nlohmann::json &aJson, ROLE aKind) |
| Parse a scalar constraint from JSON. | |
| static SCALAR_CONSTRAINT | Exact (int aValue, ROLE aKind=ROLE::COUNT) |
Static Private Member Functions | |
| static PARSED_SCALAR | parseScalar (const nlohmann::json &aJson, ROLE aKind) |
| Parse a single bound value from JSON. | |
Private Attributes | |
| std::optional< int > | m_min |
| std::optional< int > | m_max |
| std::optional< EDA_UNITS > | m_displayUnits |
| Original units for display. | |
| ROLE | m_kind = ROLE::COUNT |
A constraint on a scalar value (counts, dimensions, etc.), supporting exact, min, and max bounds.
For ROLE::COUNT, bare integers are literal count values. For ROLE::DIMENSION, bare integers are interpreted as mm, and strings can specify units (e.g. "5 mil", "0.127 mm"). Internally, dimensions are always stored in KiCad internal units (nm).
JSON input can be:
Definition at line 80 of file board_expectations.cpp.
|
strong |
| Enumerator | |
|---|---|
| COUNT | A simple count of items (e.g. number of footprints, nets, etc.) |
| DIMENSION | A linear dimension (e.g. track width, clearance) |
Definition at line 83 of file board_expectations.cpp.
|
inline |
Definition at line 197 of file board_expectations.cpp.
|
inlinestatic |
Definition at line 149 of file board_expectations.cpp.
References COUNT, m_kind, m_max, and m_min.
Referenced by createLayerExpectation().
|
inline |
Format a value for human-readable display.
Counts are shown as plain integers. Dimensions are shown in the original units from the JSON, with the raw internal-unit value appended for debugging: e.g. "5 mil (127000 nm)"
Definition at line 184 of file board_expectations.cpp.
References COUNT, m_displayUnits, m_kind, MM, pcbIUScale, and EDA_UNIT_UTILS::UI::StringFromValue().
Referenced by CheckConstraint(), and Describe().
|
inlinestatic |
Parse a scalar constraint from JSON.
| aJson | The JSON value to parse |
| aKind | Whether to interpret bare integers as counts or mm dimensions |
Definition at line 97 of file board_expectations.cpp.
References m_displayUnits, m_kind, m_max, m_min, and parseScalar().
Referenced by createItemExprExpectation(), createLayerExpectation(), createNetClassExpectation(), and createNetExpectation().
|
inline |
Definition at line 175 of file board_expectations.cpp.
References m_max.
Referenced by CheckConstraint().
|
inline |
Definition at line 174 of file board_expectations.cpp.
References m_min.
Referenced by CheckConstraint().
|
inline |
Definition at line 172 of file board_expectations.cpp.
Referenced by CheckConstraint().
|
inline |
Test if a value satisfies this constraint.
Definition at line 161 of file board_expectations.cpp.
|
inlinestaticprivate |
Parse a single bound value from JSON.
For COUNT: must be an integer. For DIMENSION: integer (mm), float (mm), or string with units (e.g. "5 mil").
Definition at line 234 of file board_expectations.cpp.
References COUNT, DIMENSION, EDA_UNIT_UTILS::UI::DoubleValueFromString(), EDA_UNIT_UTILS::FetchUnitsFromString(), KiROUND(), MM, and pcbIUScale.
Referenced by FromJson().
|
private |
Original units for display.
Definition at line 276 of file board_expectations.cpp.
Referenced by Format(), and FromJson().
|
private |
Definition at line 277 of file board_expectations.cpp.
Referenced by Exact(), Format(), and FromJson().
|
private |
Definition at line 275 of file board_expectations.cpp.
Referenced by Describe(), Exact(), FromJson(), GetMax(), IsExact(), and Match().
|
private |
Definition at line 274 of file board_expectations.cpp.
Referenced by Describe(), Exact(), FromJson(), GetMin(), IsExact(), and Match().