|
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. | |
| BOX2I | getDrawableArea () |
| Compute the drawable area (inside the drawing sheet border) for collision detection. | |
| 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 80 of file autoplace_fields.cpp.
| typedef VECTOR2I AUTOPLACER::SIDE |
Definition at line 83 of file autoplace_fields.cpp.
| Enumerator | |
|---|---|
| COLLIDE_NONE | |
| COLLIDE_OBJECTS | |
| COLLIDE_H_WIRES | |
Definition at line 85 of file autoplace_fields.cpp.
|
inline |
Definition at line 99 of file autoplace_fields.cpp.
References computeFBoxSize(), getPossibleCollisions(), Kiface(), KIFACE_BASE::KifaceSettings(), m_align_to_grid, m_allow_rejustify, m_colliders, m_fbox_size, m_fields, m_is_power_symbol, m_screen, 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 472 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 515 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 188 of file autoplace_fields.cpp.
References ANGLE_HORIZONTAL, FIELD_PADDING, BOX2< Vec >::GetHeight(), BOX2< Vec >::GetWidth(), m_align_to_grid, m_fields, round_n(), schIUScale, and WIRE_V_SPACING.
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 133 of file autoplace_fields.cpp.
References AUTOPLACE_MANUAL, chooseSideForFields(), fieldBoxPlacement(), fieldHPlacement(), fieldVPlacement(), fitFieldsBetweenWires(), BOX2< Vec >::GetTop(), justifyField(), m_align_to_grid, m_allow_rejustify, m_fbox_size, m_fields, 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 LIB_SYMBOL::AutoplaceFields(), and SCH_SYMBOL::AutoplaceFields().
|
inlineprotected |
Return the position of the field bounding box.
Definition at line 564 of file autoplace_fields.cpp.
References getPinSide(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetTop(), 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 672 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 712 of file autoplace_fields.cpp.
References FIELD_PADDING, SCH_FIELD::GetBoundingBox(), BOX2< Vec >::GetHeight(), m_align_to_grid, 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 301 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 619 of file autoplace_fields.cpp.
References computeFBoxSize(), end, 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 418 of file autoplace_fields.cpp.
References arrayDim(), COLLIDE_H_WIRES, COLLIDE_NONE, COLLIDE_OBJECTS, BOX2< Vec >::Contains(), end, fieldBoxPlacement(), filterCollisions(), getDrawableArea(), SCH_LINE::GetEndPoint(), BOX2< Vec >::GetHeight(), SCH_LINE::GetStartPoint(), BOX2< Vec >::GetWidth(), 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().
|
inlineprotected |
Compute the drawable area (inside the drawing sheet border) for collision detection.
Definition at line 392 of file autoplace_fields.cpp.
References DS_DATA_MODEL::GetBottomMargin(), PAGE_INFO::GetHeightIU(), DS_DATA_MODEL::GetLeftMargin(), DS_DATA_MODEL::GetRightMargin(), DS_DATA_MODEL::GetTheInstance(), DS_DATA_MODEL::GetTopMargin(), PAGE_INFO::GetWidthIU(), m_screen, schIUScale, BOX2< Vec >::SetEnd(), and BOX2< Vec >::SetOrigin().
Referenced by getCollidingSides().
Return the side that a pin is on.
Definition at line 227 of file autoplace_fields.cpp.
References m_symbol, PIN_DOWN, PIN_LEFT, PIN_RIGHT, PIN_UP, 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 266 of file autoplace_fields.cpp.
References fieldBoxPlacement(), getPreferredSides(), m_fbox_size, m_screen, m_symbol, and BOX2< Vec >::Merge().
Referenced by AUTOPLACER().
|
inlineprotected |
Return a list with the preferred field sides for the symbol, in decreasing order of preference.
Definition at line 325 of file autoplace_fields.cpp.
References arrayDim(), 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 551 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 246 of file autoplace_fields.cpp.
References getPinSide(), m_is_power_symbol, and m_symbol.
Referenced by getCollidingSides(), and getPreferredSides().
|
private |
Definition at line 749 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), computeFBoxSize(), DoAutoplace(), and fieldVPlacement().
|
private |
Definition at line 748 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), and DoAutoplace().
|
private |
Definition at line 745 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), and filterCollisions().
|
private |
Definition at line 747 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), DoAutoplace(), fieldBoxPlacement(), fitFieldsBetweenWires(), getCollidingSides(), and getPossibleCollisions().
|
private |
Definition at line 744 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), computeFBoxSize(), and DoAutoplace().
|
private |
Definition at line 750 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), fieldBoxPlacement(), getPreferredSides(), and pinsOnSide().
|
private |
Definition at line 742 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), getDrawableArea(), and getPossibleCollisions().
|
private |
Definition at line 743 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), fieldBoxPlacement(), getPinSide(), getPossibleCollisions(), getPreferredSides(), and pinsOnSide().
|
private |
Definition at line 746 of file autoplace_fields.cpp.
Referenced by AUTOPLACER(), fieldBoxPlacement(), and getPreferredSides().
|
static |
Definition at line 84 of file autoplace_fields.cpp.
Referenced by DoAutoplace(), fieldBoxPlacement(), fitFieldsBetweenWires(), getCollidingSides(), getPinSide(), and getPreferredSides().
|
static |
Definition at line 84 of file autoplace_fields.cpp.
Referenced by fieldBoxPlacement(), getCollidingSides(), getPinSide(), and getPreferredSides().
|
static |
Definition at line 84 of file autoplace_fields.cpp.
Referenced by DoAutoplace(), fieldBoxPlacement(), getCollidingSides(), getPinSide(), and getPreferredSides().
|
static |
Definition at line 84 of file autoplace_fields.cpp.
Referenced by DoAutoplace(), fieldBoxPlacement(), fitFieldsBetweenWires(), getCollidingSides(), getPinSide(), and getPreferredSides().