20#ifndef PCB_CONSTRAINT_H_
21#define PCB_CONSTRAINT_H_
133enum class BITMAPS :
unsigned int;
162 wxString
GetClass()
const override {
return wxT(
"PCB_CONSTRAINT" ); }
173 m_members.emplace_back( aItem, aAnchor, aIndex );
184 void Serialize( google::protobuf::Any& aContainer )
const override;
185 bool Deserialize(
const google::protobuf::Any& aContainer )
override;
199 bool HitTest(
const VECTOR2I& aPosition,
int aAccuracy = 0 )
const override {
return false; }
200 bool HitTest(
const BOX2I& aRect,
bool aContained,
int aAccuracy = 0 )
const override
221 void RemapKIIDs(
const std::map<KIID, KIID>& aIdMap )
override;
224 void Show(
int nestLevel, std::ostream& os )
const override { ShowDummy( os ); }
BITMAPS
A list of all bitmap identifiers.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
A geometric constraint between board items (issue #2329).
void swapData(BOARD_ITEM *aImage) override
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
const std::vector< CONSTRAINT_MEMBER > & GetMembers() const
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
bool HitTest(const BOX2I &aRect, bool aContained, int aAccuracy=0) const override
Test if aRect intersects this item.
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
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
void AddMember(const KIID &aItem, CONSTRAINT_ANCHOR aAnchor=CONSTRAINT_ANCHOR::WHOLE, int aIndex=-1)
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
wxString GetClass() const override
Return the class name.
std::optional< double > m_value
PCB_CONSTRAINT_TYPE m_type
void SetValue(std::optional< double > aValue)
VECTOR2I GetPosition() const override
void SetConstraintType(PCB_CONSTRAINT_TYPE aType)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
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
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
std::vector< CONSTRAINT_MEMBER > & Members()
static bool ClassOf(const EDA_ITEM *aItem)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void SetPosition(const VECTOR2I &) override
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Empty shape so any generic GetItemSet()/RunOnChildren consumer stays safe.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
@ FIXED_LENGTH
Dragged line maintains its length, adjacent lines adjust angles.
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
@ DEFAULT
Flashing follows connectivity.
PCB_LAYER_ID
A quick note on layer IDs:
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.
CONSTRAINT_ANCHOR
Which feature of a referenced board item participates in a constraint.
@ 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.
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").
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.
@ 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.
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.
One participant in a constraint: a referenced board item plus the feature of that item that participa...
KIID m_item
Referenced board item, usually a PCB_SHAPE.
CONSTRAINT_MEMBER(const KIID &aItem, CONSTRAINT_ANCHOR aAnchor, int aIndex=-1)
CONSTRAINT_ANCHOR m_anchor
Which feature of that item participates.
bool operator==(const CONSTRAINT_MEMBER &aOther) const =default
int m_index
Vertex ordinal; only meaningful for the VERTEX anchor.
@ PCB_CONSTRAINT_T
class PCB_CONSTRAINT, a geometric constraint between board items
VECTOR2< int32_t > VECTOR2I