KiCad PCB EDA Suite
|
Classes | |
struct | SIDE_AND_COLL |
struct | SIDE_AND_NPINS |
Public Types | |
enum | COLLISION { COLLIDE_NONE , COLLIDE_OBJECTS , COLLIDE_H_WIRES } |
typedef VECTOR2I | SIDE |
Public Member Functions | |
AUTOPLACER (SYMBOL *aSymbol, SCH_SCREEN *aScreen) | |
void | DoAutoplace (AUTOPLACE_ALGO aAlgo) |
Do the actual autoplacement. | |
Static Public Attributes | |
static const SIDE | SIDE_TOP |
static const SIDE | SIDE_BOTTOM |
static const SIDE | SIDE_LEFT |
static const SIDE | SIDE_RIGHT |
Protected Member Functions | |
VECTOR2I | computeFBoxSize (bool aDynamic) |
Compute and return the size of the fields' bounding box. | |
SIDE | getPinSide (SCH_PIN *aPin) |
Return the side that a pin is on. | |
unsigned | pinsOnSide (SIDE aSide) |
Count the number of pins on a side of the symbol. | |
void | getPossibleCollisions (std::vector< SCH_ITEM * > &aItems) |
Populate a list of all drawing items that may collide with the fields. | |
std::vector< SCH_ITEM * > | filterCollisions (const BOX2I &aRect) |
Filter a list of possible colliders to include only those that actually collide with a given rectangle. | |
std::vector< SIDE_AND_NPINS > | getPreferredSides () |
Return a list with the preferred field sides for the symbol, in decreasing order of preference. | |
std::vector< SIDE_AND_COLL > | getCollidingSides () |
Return a list of the sides where a field set would collide with another item. | |
SIDE_AND_NPINS | chooseSideFiltered (std::vector< SIDE_AND_NPINS > &aSides, const std::vector< SIDE_AND_COLL > &aCollidingSides, COLLISION aCollision, SIDE_AND_NPINS aLastSelection) |
Choose a side for the fields, filtered on only one side collision type. | |
SIDE_AND_NPINS | chooseSideForFields (bool aAvoidCollisions) |
Look where a symbol's pins are to pick a side to put the fields on. | |
void | justifyField (SCH_FIELD *aField, SIDE aFieldSide) |
Set the justification of a field based on the side it's supposed to be on, taking into account whether the field will be displayed with flipped justification due to mirroring. | |
VECTOR2I | fieldBoxPlacement (SIDE_AND_NPINS aFieldSideAndPins) |
Return the position of the field bounding box. | |
bool | fitFieldsBetweenWires (BOX2I *aBox, SIDE aSide) |
Shift a field box up or down a bit to make the fields fit between some wires. | |
int | fieldHPlacement (SCH_FIELD *aField, const BOX2I &aFieldBox) |
Place a field horizontally, taking into account the field width and justification. | |
int | fieldVPlacement (SCH_FIELD *aField, const BOX2I &aFieldBox, int *aAccumulatedPosition, bool aDynamic) |
Place a field vertically. | |
Private Attributes | |
SCH_SCREEN * | m_screen |
SYMBOL * | m_symbol |
std::vector< SCH_FIELD * > | m_fields |
std::vector< SCH_ITEM * > | m_colliders |
BOX2I | m_symbol_bbox |
VECTOR2I | m_fbox_size |
bool | m_allow_rejustify |
bool | m_align_to_grid |
bool | m_is_power_symbol |
Definition at line 83 of file autoplace_fields.cpp.
typedef VECTOR2I AUTOPLACER::SIDE |
Definition at line 86 of file autoplace_fields.cpp.
Enumerator | |
---|---|
COLLIDE_NONE | |
COLLIDE_OBJECTS | |
COLLIDE_H_WIRES |
Definition at line 88 of file autoplace_fields.cpp.
|
inline |
Definition at line 102 of file autoplace_fields.cpp.
References computeFBoxSize(), SYMBOL::GetBodyBoundingBox(), SYMBOL::GetFields(), getPossibleCollisions(), Kiface(), KIFACE_BASE::KifaceSettings(), m_align_to_grid, m_allow_rejustify, m_colliders, m_fbox_size, m_fields, m_is_power_symbol, m_symbol, and m_symbol_bbox.
|
inlineprotected |
Choose a side for the fields, filtered on only one side collision type.
Removes the sides matching the filter from the list.
Definition at line 443 of file autoplace_fields.cpp.
References collide(), AUTOPLACER::SIDE_AND_NPINS::pins, and AUTOPLACER::SIDE_AND_NPINS::side.
Referenced by chooseSideForFields().
|
inlineprotected |
Look where a symbol's pins are to pick a side to put the fields on.
aAvoidCollisions | - if true, pick last the sides where the label will collide with other items. |
Definition at line 486 of file autoplace_fields.cpp.
References chooseSideFiltered(), COLLIDE_H_WIRES, COLLIDE_OBJECTS, getCollidingSides(), getPreferredSides(), AUTOPLACER::SIDE_AND_NPINS::pins, and AUTOPLACER::SIDE_AND_NPINS::side.
Referenced by DoAutoplace().
|
inlineprotected |
Compute and return the size of the fields' bounding box.
aDynamic | - if true, use dynamic spacing |
Definition at line 194 of file autoplace_fields.cpp.
References ANGLE_HORIZONTAL, ANGLE_VERTICAL, FIELD_PADDING, BOX2< Vec >::GetHeight(), SYMBOL::GetTransform(), BOX2< Vec >::GetWidth(), m_align_to_grid, m_fields, m_symbol, EDA_IU_SCALE::MilsToIU(), round_n(), schIUScale, WIRE_V_SPACING, and TRANSFORM::y1.
Referenced by AUTOPLACER(), and fitFieldsBetweenWires().
|
inline |
Do the actual autoplacement.
aManual | - if true, use extra heuristics for smarter placement when manually called up. |
Definition at line 136 of file autoplace_fields.cpp.
References AUTOPLACE_AUTOADDED, AUTOPLACE_MANUAL, chooseSideForFields(), fieldBoxPlacement(), fieldHPlacement(), fieldVPlacement(), fitFieldsBetweenWires(), BOX2< Vec >::GetTop(), justifyField(), m_align_to_grid, m_allow_rejustify, m_fbox_size, m_fields, EDA_IU_SCALE::MilsToIU(), AUTOPLACER::SIDE_AND_NPINS::pins, round_n(), schIUScale, AUTOPLACER::SIDE_AND_NPINS::side, SIDE_BOTTOM, SIDE_RIGHT, SIDE_TOP, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by SCH_SYMBOL::AutoplaceFields().
|
inlineprotected |
Return the position of the field bounding box.
Definition at line 535 of file autoplace_fields.cpp.
References BOX2< Vec >::Centre(), BOX2< Vec >::GetHeight(), SYMBOL::GetPins(), getPinSide(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetTop(), BOX2< Vec >::GetWidth(), HPADDING, m_fbox_size, m_is_power_symbol, m_symbol, m_symbol_bbox, BOX2< Vec >::Merge(), AUTOPLACER::SIDE_AND_NPINS::pins, AUTOPLACER::SIDE_AND_NPINS::side, SIDE_BOTTOM, SIDE_LEFT, SIDE_RIGHT, SIDE_TOP, VPADDING, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by DoAutoplace(), getCollidingSides(), and getPossibleCollisions().
Place a field horizontally, taking into account the field width and justification.
aField | - the field to place. |
aFieldBox | - box in which fields will be placed |
Definition at line 643 of file autoplace_fields.cpp.
References BOX2< Vec >::Centre(), EDA_TEXT::GetHorizJustify(), BOX2< Vec >::GetLeft(), BOX2< Vec >::GetRight(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, SCH_FIELD::IsHorizJustifyFlipped(), and VECTOR2< T >::x.
Referenced by DoAutoplace().
|
inlineprotected |
Place a field vertically.
Because field vertical placements accumulate, this takes a pointer to a vertical position accumulator.
aField | - the field to place. |
aFieldBox | - box in which fields will be placed. |
aAccumulatedPosition | - pointer to a position accumulator |
aDynamic | - use dynamic spacing |
Definition at line 683 of file autoplace_fields.cpp.
References FIELD_PADDING, SCH_FIELD::GetBoundingBox(), BOX2< Vec >::GetHeight(), m_align_to_grid, EDA_IU_SCALE::MilsToIU(), round_n(), schIUScale, and WIRE_V_SPACING.
Referenced by DoAutoplace().
Filter a list of possible colliders to include only those that actually collide with a given rectangle.
Returns the new vector.
Definition at line 305 of file autoplace_fields.cpp.
References BOX2< Vec >::Intersects(), and m_colliders.
Referenced by fitFieldsBetweenWires(), and getCollidingSides().
Shift a field box up or down a bit to make the fields fit between some wires.
Returns true if a shift was made.
Definition at line 590 of file autoplace_fields.cpp.
References computeFBoxSize(), filterCollisions(), SCH_LINE::GetEndPoint(), BOX2< Vec >::GetPosition(), SCH_LINE::GetStartPoint(), m_fbox_size, round_n(), BOX2< Vec >::SetOrigin(), SIDE_BOTTOM, SIDE_TOP, WIRE_V_SPACING, and VECTOR2< T >::y.
Referenced by DoAutoplace().
|
inlineprotected |
Return a list of the sides where a field set would collide with another item.
Definition at line 396 of file autoplace_fields.cpp.
References arrayDim(), COLLIDE_H_WIRES, COLLIDE_NONE, COLLIDE_OBJECTS, fieldBoxPlacement(), filterCollisions(), SCH_LINE::GetEndPoint(), SCH_LINE::GetStartPoint(), m_fbox_size, AUTOPLACER::SIDE_AND_NPINS::pins, pinsOnSide(), AUTOPLACER::SIDE_AND_NPINS::side, SIDE_BOTTOM, SIDE_LEFT, SIDE_RIGHT, SIDE_TOP, and VECTOR2< T >::y.
Referenced by chooseSideForFields().
Return the side that a pin is on.
Definition at line 231 of file autoplace_fields.cpp.
References SYMBOL::GetTransform(), m_symbol, SCH_PIN::PinDrawOrient(), SIDE_BOTTOM, SIDE_LEFT, SIDE_RIGHT, and SIDE_TOP.
Referenced by fieldBoxPlacement(), and pinsOnSide().
|
inlineprotected |
Populate a list of all drawing items that may collide with the fields.
That is, all drawing items, including other fields, that are not the current symbol or its own fields.
Definition at line 270 of file autoplace_fields.cpp.
References fieldBoxPlacement(), SYMBOL::GetBodyAndPinsBoundingBox(), getPreferredSides(), SCH_SCREEN::Items(), m_fbox_size, m_screen, m_symbol, BOX2< Vec >::Merge(), and EE_RTREE::Overlapping().
Referenced by AUTOPLACER().
|
inlineprotected |
Return a list with the preferred field sides for the symbol, in decreasing order of preference.
Definition at line 329 of file autoplace_fields.cpp.
References arrayDim(), BOX2< Vec >::GetHeight(), SYMBOL::GetOrientation(), BOX2< Vec >::GetWidth(), m_is_power_symbol, m_symbol, m_symbol_bbox, pinsOnSide(), SIDE_BOTTOM, SIDE_LEFT, SIDE_RIGHT, SIDE_TOP, SYM_MIRROR_X, SYM_ORIENT_0, SYM_ORIENT_180, SYM_ORIENT_270, and SYM_ORIENT_90.
Referenced by chooseSideForFields(), and getPossibleCollisions().
Set the justification of a field based on the side it's supposed to be on, taking into account whether the field will be displayed with flipped justification due to mirroring.
Definition at line 522 of file autoplace_fields.cpp.
References GetFlippedAlignment(), EDA_TEXT::GetHorizJustify(), GR_TEXT_V_ALIGN_CENTER, SCH_FIELD::IsHorizJustifyFlipped(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetVertJustify(), ToHAlignment(), and VECTOR2< T >::x.
Referenced by DoAutoplace().
|
inlineprotected |
Count the number of pins on a side of the symbol.
Definition at line 250 of file autoplace_fields.cpp.
References SYMBOL::GetPins(), getPinSide(), m_is_power_symbol, and m_symbol.
Referenced by getCollidingSides(), and getPreferredSides().
|
private |
Definition at line 720 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), computeFBoxSize(), DoAutoplace(), and fieldVPlacement().
|
private |
Definition at line 719 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), and DoAutoplace().
|
private |
Definition at line 716 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), and filterCollisions().
|
private |
Definition at line 718 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), DoAutoplace(), fieldBoxPlacement(), fitFieldsBetweenWires(), getCollidingSides(), and getPossibleCollisions().
|
private |
Definition at line 715 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), computeFBoxSize(), and DoAutoplace().
|
private |
Definition at line 721 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), fieldBoxPlacement(), getPreferredSides(), and pinsOnSide().
|
private |
Definition at line 713 of file autoplace_fields.cpp.
Referenced by getPossibleCollisions().
|
private |
Definition at line 714 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), computeFBoxSize(), fieldBoxPlacement(), getPinSide(), getPossibleCollisions(), getPreferredSides(), and pinsOnSide().
|
private |
Definition at line 717 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), fieldBoxPlacement(), and getPreferredSides().
|
static |
Definition at line 87 of file autoplace_fields.cpp.
Referenced by DoAutoplace(), fieldBoxPlacement(), fitFieldsBetweenWires(), getCollidingSides(), getPinSide(), and getPreferredSides().
|
static |
Definition at line 87 of file autoplace_fields.cpp.
Referenced by fieldBoxPlacement(), getCollidingSides(), getPinSide(), and getPreferredSides().
|
static |
Definition at line 87 of file autoplace_fields.cpp.
Referenced by DoAutoplace(), fieldBoxPlacement(), getCollidingSides(), getPinSide(), and getPreferredSides().
|
static |
Definition at line 87 of file autoplace_fields.cpp.
Referenced by DoAutoplace(), fieldBoxPlacement(), fitFieldsBetweenWires(), getCollidingSides(), getPinSide(), and getPreferredSides().