KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_constraint.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
21
22#include <algorithm>
23
24#include <base_units.h>
25#include <bitmaps.h>
26#include <eda_units.h>
27#include <geometry/eda_angle.h>
29#include <i18n_utility.h>
30#include <pcb_shape.h>
31#include <properties/property.h>
33
34#include <api/api_utils.h>
35#include <api/api_enums.h>
36#include <api/board/board_types.pb.h>
37#include <google/protobuf/any.pb.h>
38
39
41{
42 switch( aType )
43 {
44 case PCB_CONSTRAINT_TYPE::COINCIDENT: return "coincident";
45 case PCB_CONSTRAINT_TYPE::HORIZONTAL: return "horizontal";
46 case PCB_CONSTRAINT_TYPE::VERTICAL: return "vertical";
47 case PCB_CONSTRAINT_TYPE::PARALLEL: return "parallel";
48 case PCB_CONSTRAINT_TYPE::PERPENDICULAR: return "perpendicular";
49 case PCB_CONSTRAINT_TYPE::COLLINEAR: return "collinear";
50 case PCB_CONSTRAINT_TYPE::SYMMETRIC: return "symmetric";
51 case PCB_CONSTRAINT_TYPE::EQUAL_LENGTH: return "equal_length";
52 case PCB_CONSTRAINT_TYPE::EQUAL_RADIUS: return "equal_radius";
53 case PCB_CONSTRAINT_TYPE::POINT_ON_LINE: return "point_on_line";
54 case PCB_CONSTRAINT_TYPE::MIDPOINT: return "midpoint";
55 case PCB_CONSTRAINT_TYPE::FIXED_POSITION: return "fixed_position";
56 case PCB_CONSTRAINT_TYPE::FIXED_LENGTH: return "fixed_length";
57 case PCB_CONSTRAINT_TYPE::CONCENTRIC: return "concentric";
58 case PCB_CONSTRAINT_TYPE::FIXED_RADIUS: return "fixed_radius";
59 case PCB_CONSTRAINT_TYPE::ANGULAR_DIMENSION: return "angular_dimension";
60 case PCB_CONSTRAINT_TYPE::TANGENT: return "tangent";
61 case PCB_CONSTRAINT_TYPE::ARC_ANGLE: return "arc_angle";
62 case PCB_CONSTRAINT_TYPE::UNDEFINED: return "undefined";
63 }
64
65 return "undefined";
66}
67
68
70{
71 for( int i = 0; i <= static_cast<int>( PCB_CONSTRAINT_TYPE::ARC_ANGLE ); ++i )
72 {
73 PCB_CONSTRAINT_TYPE type = static_cast<PCB_CONSTRAINT_TYPE>( i );
74
75 if( aToken == ConstraintTypeToken( type ) )
76 return type;
77 }
78
80}
81
82
84{
85 switch( aType )
86 {
89 return true;
90 default:
91 return false; // the angular types are angles; everything else is valueless
92 }
93}
94
95
97{
98 switch( aAnchor )
99 {
100 case CONSTRAINT_ANCHOR::WHOLE: return "whole";
101 case CONSTRAINT_ANCHOR::START: return "start";
102 case CONSTRAINT_ANCHOR::END: return "end";
103 case CONSTRAINT_ANCHOR::MID: return "mid";
104 case CONSTRAINT_ANCHOR::CENTER: return "center";
105 case CONSTRAINT_ANCHOR::RADIUS: return "radius";
106 case CONSTRAINT_ANCHOR::VERTEX: return "vertex";
107 }
108
109 return "whole";
110}
111
112
114{
115 for( int i = 0; i <= static_cast<int>( CONSTRAINT_ANCHOR::VERTEX ); ++i )
116 {
117 CONSTRAINT_ANCHOR anchor = static_cast<CONSTRAINT_ANCHOR>( i );
118
119 if( aToken == ConstraintAnchorToken( anchor ) )
120 return anchor;
121 }
122
124}
125
126
128{
129 // Single-codepoint marks carried by both the newstroke stroke font and the OpenGL glyph atlas
130 // so every GAL backend renders them without a missing-glyph box.
131 switch( aType )
132 {
133 case PCB_CONSTRAINT_TYPE::COINCIDENT: return wxT( "●" );
134 case PCB_CONSTRAINT_TYPE::HORIZONTAL: return wxT( "↔" );
135 case PCB_CONSTRAINT_TYPE::VERTICAL: return wxT( "↕" );
136 case PCB_CONSTRAINT_TYPE::PARALLEL: return wxT( "∥" );
137 case PCB_CONSTRAINT_TYPE::PERPENDICULAR: return wxT( "⊥" );
138 case PCB_CONSTRAINT_TYPE::COLLINEAR: return wxT( "─" );
139 case PCB_CONSTRAINT_TYPE::SYMMETRIC: return wxT( "⧓" );
140 case PCB_CONSTRAINT_TYPE::EQUAL_LENGTH: return wxT( "=" );
141 case PCB_CONSTRAINT_TYPE::EQUAL_RADIUS: return wxT( "⊜" );
142 case PCB_CONSTRAINT_TYPE::POINT_ON_LINE: return wxT( "∈" );
143 case PCB_CONSTRAINT_TYPE::MIDPOINT: return wxT( "½" );
144 case PCB_CONSTRAINT_TYPE::FIXED_POSITION: return wxT( "⌖" );
145 case PCB_CONSTRAINT_TYPE::FIXED_LENGTH: return wxT( "⟷" );
146 case PCB_CONSTRAINT_TYPE::CONCENTRIC: return wxT( "◎" );
147 case PCB_CONSTRAINT_TYPE::FIXED_RADIUS: return wxT( "r" );
148 case PCB_CONSTRAINT_TYPE::ANGULAR_DIMENSION: return wxT( "∠" );
149 case PCB_CONSTRAINT_TYPE::TANGENT: return wxT( "T" );
150 case PCB_CONSTRAINT_TYPE::ARC_ANGLE: return wxT( "α" );
151 case PCB_CONSTRAINT_TYPE::UNDEFINED: return wxEmptyString;
152 }
153
154 return wxEmptyString;
155}
156
157
159{
160 switch( aType )
161 {
181 }
182
184}
185
186
188{
189 switch( aAnchor )
190 {
191 case CONSTRAINT_ANCHOR::WHOLE: return wxEmptyString;
192 case CONSTRAINT_ANCHOR::START: return _( "start" );
193 case CONSTRAINT_ANCHOR::END: return _( "end" );
194 case CONSTRAINT_ANCHOR::MID: return _( "mid" );
195 case CONSTRAINT_ANCHOR::CENTER: return _( "center" );
196 case CONSTRAINT_ANCHOR::RADIUS: return _( "radius" );
197 case CONSTRAINT_ANCHOR::VERTEX: return _( "vertex" );
198 }
199
200 return wxEmptyString;
201}
202
203
205{
206 switch( aType )
207 {
208 case PCB_CONSTRAINT_TYPE::COINCIDENT: return _( "Coincident" );
209 case PCB_CONSTRAINT_TYPE::HORIZONTAL: return _( "Horizontal" );
210 case PCB_CONSTRAINT_TYPE::VERTICAL: return _( "Vertical" );
211 case PCB_CONSTRAINT_TYPE::PARALLEL: return _( "Parallel" );
212 case PCB_CONSTRAINT_TYPE::PERPENDICULAR: return _( "Perpendicular" );
213 case PCB_CONSTRAINT_TYPE::COLLINEAR: return _( "Collinear" );
214 case PCB_CONSTRAINT_TYPE::SYMMETRIC: return _( "Symmetric" );
215 case PCB_CONSTRAINT_TYPE::EQUAL_LENGTH: return _( "Equal length" );
216 case PCB_CONSTRAINT_TYPE::EQUAL_RADIUS: return _( "Equal radius" );
217 case PCB_CONSTRAINT_TYPE::POINT_ON_LINE: return _( "Point on line" );
218 case PCB_CONSTRAINT_TYPE::MIDPOINT: return _( "Midpoint" );
219 case PCB_CONSTRAINT_TYPE::FIXED_POSITION: return _( "Fixed position" );
220 case PCB_CONSTRAINT_TYPE::FIXED_LENGTH: return _( "Fixed length" );
221 case PCB_CONSTRAINT_TYPE::CONCENTRIC: return _( "Concentric" );
222 case PCB_CONSTRAINT_TYPE::FIXED_RADIUS: return _( "Fixed radius" );
223 case PCB_CONSTRAINT_TYPE::ANGULAR_DIMENSION: return _( "Angular dimension" );
224 case PCB_CONSTRAINT_TYPE::TANGENT: return _( "Tangent" );
225 case PCB_CONSTRAINT_TYPE::ARC_ANGLE: return _( "Arc angle" );
226 case PCB_CONSTRAINT_TYPE::UNDEFINED: return _( "Undefined" );
227 }
228
229 return _( "Undefined" );
230}
231
232
237
238
241 m_type( aType ),
242 m_driving( true )
243{
244}
245
246
247void PCB_CONSTRAINT::Serialize( google::protobuf::Any& aContainer ) const
248{
249 using namespace kiapi::board::types;
250 Constraint constraint;
251
252 constraint.mutable_id()->set_value( m_Uuid.AsStdString() );
253
255 constraint.set_driving( m_driving );
256
257 if( m_value.has_value() )
258 constraint.set_value( *m_value );
259
260 for( const CONSTRAINT_MEMBER& member : m_members )
261 {
262 ConstraintMember* m = constraint.add_members();
263 m->mutable_item()->set_value( member.m_item.AsStdString() );
264 m->set_anchor( ToProtoEnum<CONSTRAINT_ANCHOR, ConstraintAnchor>( member.m_anchor ) );
265
266 // Only vertex anchors carry an index leaving it absent elsewhere keeps the negative one
267 // sentinel out of the wire format
268 if( member.m_anchor == CONSTRAINT_ANCHOR::VERTEX )
269 m->set_index( member.m_index );
270 }
271
272 kiapi::common::PackCustomProperties( constraint.mutable_custom_properties(), *this );
273 aContainer.PackFrom( constraint );
274}
275
276
277bool PCB_CONSTRAINT::Deserialize( const google::protobuf::Any& aContainer )
278{
279 using namespace kiapi::board::types;
280 Constraint constraint;
281
282 if( !aContainer.UnpackTo( &constraint ) )
283 return false;
284
285 SetUuidDirect( KIID( constraint.id().value() ) );
286
288 m_driving = constraint.driving();
289
290 if( constraint.has_value() )
291 m_value = constraint.value();
292 else
293 m_value = std::nullopt;
294
295 m_members.clear();
296
297 // Members reference items by KIID, so they need no board to resolve (resolved on use).
298 for( const auto& m : constraint.members() )
299 {
301
302 // A vertex member without an explicit index gets the negative one sentinel rather than a
303 // silent vertex zero no other anchor may carry an index at all
304 int index = anchor == CONSTRAINT_ANCHOR::VERTEX && m.has_index() ? m.index() : -1;
305
306 m_members.emplace_back( KIID( m.item().value() ), anchor, index );
307 }
308
309 kiapi::common::UnpackCustomProperties( constraint.custom_properties(), *this );
310
311 return true;
312}
313
315{
316 wxCHECK( aOther && aOther->Type() == PCB_CONSTRAINT_T, /* void */ );
317 *this = *static_cast<const PCB_CONSTRAINT*>( aOther );
318}
319
320
322{
323 // Copy constructor preserves the uuid and all members, matching PCB_GROUP.
324 return new PCB_CONSTRAINT( *this );
325}
326
327
329{
330 assert( aImage->Type() == PCB_CONSTRAINT_T );
331
332 std::swap( *this, *static_cast<PCB_CONSTRAINT*>( aImage ) );
333}
334
335
336void PCB_CONSTRAINT::RemapKIIDs( const std::map<KIID, KIID>& aIdMap )
337{
338 for( CONSTRAINT_MEMBER& member : m_members )
339 {
340 if( auto it = aIdMap.find( member.m_item ); it != aIdMap.end() )
341 member.m_item = it->second;
342 }
343}
344
345
346bool PCB_CONSTRAINT::operator==( const BOARD_ITEM& aOther ) const
347{
348 if( aOther.Type() != Type() )
349 return false;
350
351 return *this == static_cast<const PCB_CONSTRAINT&>( aOther );
352}
353
354
356{
357 // Members are positional (a symmetric constraint's axis is not interchangeable with its
358 // mirrored points), so compare them in order.
359 return m_type == aOther.m_type
360 && m_driving == aOther.m_driving
361 && m_value == aOther.m_value
362 && m_members == aOther.m_members;
363}
364
365
366double PCB_CONSTRAINT::Similarity( const BOARD_ITEM& aOther ) const
367{
368 if( aOther.Type() != Type() )
369 return 0.0;
370
371 const PCB_CONSTRAINT& other = static_cast<const PCB_CONSTRAINT&>( aOther );
372
373 if( m_type != other.m_type )
374 return 0.0;
375
376 double similarity = 0.5;
377
378 if( m_members == other.m_members )
379 similarity += 0.3;
380
381 if( m_driving == other.m_driving && m_value == other.m_value )
382 similarity += 0.2;
383
384 return similarity;
385}
386
387
389{
390 return wxString::Format( _( "Constraint: %s (%zu members)" ),
392}
393
394
395wxString ConstraintDisplayLabel( const PCB_CONSTRAINT& aConstraint, EDA_UNITS aUnits )
396{
397 wxString label = ConstraintTypeLabel( aConstraint.GetConstraintType() );
398
399 if( !aConstraint.HasValue() )
400 return label;
401
402 double value = *aConstraint.GetValue();
403 wxString text;
404
405 if( ConstraintValueIsLength( aConstraint.GetConstraintType() ) )
407 else
409
410 // Reference (non-driving) dimensions only measure, so show them parenthesized like CAD does.
411 return wxString::Format( aConstraint.IsDriving() ? wxT( "%s: %s" ) : wxT( "%s: (%s)" ), label, text );
412}
413
414
415wxString ConstraintMemberLabel( BOARD_ITEM* aItem, const CONSTRAINT_MEMBER& aMember,
416 UNITS_PROVIDER* aUnitsProvider )
417{
418 if( !aItem )
419 return _( "(missing)" );
420
421 wxString text = aItem->GetItemDescription( aUnitsProvider, false );
422 wxString anchor;
423
424 if( aMember.m_anchor == CONSTRAINT_ANCHOR::VERTEX && aMember.m_index >= 0 )
425 {
426 const PCB_SHAPE* shape = dynamic_cast<const PCB_SHAPE*>( aItem );
427
428 // Ordinals read 1 based matching the vertex editor pane grid row numbering Widened so a
429 // hostile INT_MAX index from a file cannot overflow
430 if( shape && shape->GetShape() == SHAPE_T::RECTANGLE )
431 anchor = wxString::Format( _( "corner %lld" ), static_cast<long long>( aMember.m_index ) + 1 );
432 else
433 anchor = wxString::Format( _( "vertex %lld" ), static_cast<long long>( aMember.m_index ) + 1 );
434 }
435 else
436 {
438 }
439
440 if( !anchor.IsEmpty() )
441 text += wxString::Format( wxT( " (%s)" ), anchor );
442
443 return text;
444}
445
446
448{
449 if( aA.GetConstraintType() != aB.GetConstraintType() )
450 return false;
451
452 const std::vector<CONSTRAINT_MEMBER>& a = aA.GetMembers();
453 const std::vector<CONSTRAINT_MEMBER>& b = aB.GetMembers();
454
455 if( a.empty() || a.size() != b.size() )
456 return false;
457
458 // Match members as a multiset so member order does not matter (A-B is the same as B-A).
459 // Roles survive this because a member's anchor encodes them; in SYMMETRIC and the point
460 // families the mirror/probe points carry endpoint anchors while the axis/line is WHOLE, so
461 // two constraints with the same multiset genuinely relate the same geometry the same way.
462 return std::is_permutation( a.begin(), a.end(), b.begin(), b.end() );
463}
464
465
470
471
473{
474 return std::make_shared<SHAPE_COMPOUND>();
475}
476
477
479{
481 {
486
487 // A constraint has no geometry, so hide the inherited positional/layer properties.
488 propMgr.Mask( TYPE_HASH( PCB_CONSTRAINT ), TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ) );
489 propMgr.Mask( TYPE_HASH( PCB_CONSTRAINT ), TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ) );
490 propMgr.Mask( TYPE_HASH( PCB_CONSTRAINT ), TYPE_HASH( BOARD_ITEM ), _HKI( "Layer" ) );
491 propMgr.Mask( TYPE_HASH( PCB_CONSTRAINT ), TYPE_HASH( BOARD_ITEM ), _HKI( "Locked" ) );
492
493 const wxString constraintTab = _HKI( "Constraint Properties" );
494
495 // Driving vs reference is the one freely-editable property (the "convert to reference"
496 // toggle); type and members are intrinsic and set at creation.
497 propMgr.AddProperty( new PROPERTY<PCB_CONSTRAINT, bool>( _HKI( "Driving" ),
499 constraintTab );
500 }
int index
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
Definition api_enums.cpp:55
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
BITMAPS
A list of all bitmap identifiers.
@ constraint_tangent
@ constraint_fixed_radius
@ constraint_vertical
@ constraint_arc_angle
@ constraint_parallel
@ constraint_equal_radius
@ constraint_horizontal
@ constraint_fixed_position
@ constraint_equal_length
@ constraint_symmetric
@ constraint_fixed_length
@ INVALID_BITMAP
@ constraint_collinear
@ constraint_concentric
@ constraint_angular_dimension
@ constraint_coincident
@ constraint_midpoint
@ constraint_perpendicular
@ constraint_point_on_line
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:86
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const
Return a user-visible description string of this item.
Definition eda_item.cpp:304
const KIID m_Uuid
Definition eda_item.h:597
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
SHAPE_T GetShape() const
Definition eda_shape.h:175
Definition kiid.h:46
A geometric constraint between board items (issue #2329).
void swapData(BOARD_ITEM *aImage) override
void CopyFrom(const BOARD_ITEM *aOther) override
const std::vector< CONSTRAINT_MEMBER > & GetMembers() const
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
std::optional< double > GetValue() const
PCB_CONSTRAINT(BOARD_ITEM *aParent=nullptr)
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool IsDriving() const
A driving constraint forces its value; a reference (non-driving) one only measures it.
PCB_CONSTRAINT_TYPE GetConstraintType() const
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
bool operator==(const PCB_CONSTRAINT &aOther) const
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Empty shape so any generic GetItemSet()/RunOnChildren consumer stays safe.
std::optional< double > m_value
PCB_CONSTRAINT_TYPE m_type
bool HasValue() const
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void RemapKIIDs(const std::map< KIID, KIID > &aIdMap) override
Remap KIIDs this item stores to reference other items (e.g.
void SetDriving(bool aDriving)
std::vector< CONSTRAINT_MEMBER > m_members
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
DRC_CONSTRAINT_T
Definition drc_rule.h:49
#define _(s)
@ DEGREES_T
Definition eda_angle.h:31
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:57
EDA_UNITS
Definition eda_units.h:44
Some functions to handle hotkeys in KiCad.
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:180
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ UNDEFINED_LAYER
Definition layer_ids.h:57
KICOMMON_API wxString MessageTextFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A helper to convert the double length aValue to a string in inches, millimeters, or unscaled units.
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
#define _HKI(x)
Definition page_info.cpp:40
bool ConstraintsAreDuplicate(const PCB_CONSTRAINT &aA, const PCB_CONSTRAINT &aB)
True if two constraints express the same relation, meaning the same type and the same members compare...
wxString ConstraintTypeGlyph(PCB_CONSTRAINT_TYPE aType)
Compact glyph for a constraint type (e.g. "//", "=") for on-canvas badges.
PCB_CONSTRAINT_TYPE ConstraintTypeFromToken(const wxString &aToken)
Parse a constraint-type token; returns UNDEFINED for an unknown token.
BITMAPS ConstraintTypeBitmap(PCB_CONSTRAINT_TYPE aType)
Badge icon for a constraint type; INVALID_BITMAP for UNDEFINED.
bool ConstraintValueIsLength(PCB_CONSTRAINT_TYPE aType)
True if this type's value is a length in IU (serialized in mm); false for an angle in degrees.
wxString ConstraintTypeLabel(PCB_CONSTRAINT_TYPE aType)
Human-readable name of a constraint type (e.g. "Parallel"), for menus and lists.
wxString ConstraintMemberLabel(BOARD_ITEM *aItem, const CONSTRAINT_MEMBER &aMember, UNITS_PROVIDER *aUnitsProvider)
Label for one constrained item in a list combining the item description with its anchored feature suc...
CONSTRAINT_ANCHOR ConstraintAnchorFromToken(const wxString &aToken)
Parse an anchor token; returns WHOLE for an unknown token.
const char * ConstraintTypeToken(PCB_CONSTRAINT_TYPE aType)
Stable file-format token for a constraint type (e.g. "parallel"). Used by serialization.
const char * ConstraintAnchorToken(CONSTRAINT_ANCHOR aAnchor)
Stable file-format token for a member anchor (e.g. "start").
static struct PCB_CONSTRAINT_DESC _PCB_CONSTRAINT_DESC
wxString ConstraintAnchorLabel(CONSTRAINT_ANCHOR aAnchor)
Translated name of the feature an anchor references (e.g.
wxString ConstraintDisplayLabel(const PCB_CONSTRAINT &aConstraint, EDA_UNITS aUnits)
Display label for a constraint in lists and menus.
CONSTRAINT_ANCHOR
Which feature of a referenced board item participates in a constraint.
@ VERTEX
An indexed rectangle corner or polygon outline vertex; pairs with CONSTRAINT_MEMBER::m_index.
@ MID
Midpoint of a segment or arc.
@ RADIUS
The radius (scalar feature) of an arc or circle.
@ WHOLE
The item as a whole (a segment as a line, a circle).
@ START
First endpoint of a segment or arc.
@ END
Second endpoint of a segment or arc.
@ CENTER
Center of an arc or circle.
wxString ConstraintTypeLabel(PCB_CONSTRAINT_TYPE aType)
Human-readable name of a constraint type (e.g. "Parallel"), for menus and lists.
PCB_CONSTRAINT_TYPE
The geometric relationship a PCB_CONSTRAINT enforces between its members.
@ CONCENTRIC
Two arcs/circles share a center.
@ SYMMETRIC
Two points are mirror images about an axis.
@ FIXED_POSITION
A point is locked at its current location.
@ VERTICAL
A segment (or two points) is vertical.
@ TANGENT
A line and a curve, or two curves, touch tangentially.
@ COINCIDENT
Two points are made to coincide.
@ PERPENDICULAR
Two segments are perpendicular.
@ FIXED_RADIUS
An arc/circle has a driving radius value.
@ HORIZONTAL
A segment (or two points) is horizontal.
@ EQUAL_RADIUS
Two arcs/circles have equal radius.
@ MIDPOINT
A point is the midpoint of a segment.
@ POINT_ON_LINE
A point lies on a segment's supporting line.
@ FIXED_LENGTH
A segment has a driving length value.
@ ANGULAR_DIMENSION
An angle between members (driving or reference).
@ COLLINEAR
Two segments lie on the same line.
@ ARC_ANGLE
An arc has a driving or reference swept-angle value.
@ PARALLEL
Two segments are parallel.
@ EQUAL_LENGTH
Two segments have equal length.
#define TYPE_HASH(x)
Definition property.h:74
#define REGISTER_TYPE(x)
One participant in a constraint: a referenced board item plus the feature of that item that participa...
CONSTRAINT_ANCHOR m_anchor
Which feature of that item participates.
int m_index
Vertex ordinal; only meaningful for the VERTEX anchor.
@ PCB_CONSTRAINT_T
a geometric constraint between board items
Definition typeinfo.h:237