KiCad PCB EDA Suite
Loading...
Searching...
No Matches
AUTOPLACER Class Reference

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_NPINSgetPreferredSides ()
 Return a list with the preferred field sides for the symbol, in decreasing order of preference.
 
std::vector< SIDE_AND_COLLgetCollidingSides ()
 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_SCREENm_screen
 
SYMBOLm_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
 

Detailed Description

Definition at line 83 of file autoplace_fields.cpp.

Member Typedef Documentation

◆ SIDE

Definition at line 86 of file autoplace_fields.cpp.

Member Enumeration Documentation

◆ COLLISION

Enumerator
COLLIDE_NONE 
COLLIDE_OBJECTS 
COLLIDE_H_WIRES 

Definition at line 88 of file autoplace_fields.cpp.

Constructor & Destructor Documentation

◆ AUTOPLACER()

Member Function Documentation

◆ chooseSideFiltered()

SIDE_AND_NPINS AUTOPLACER::chooseSideFiltered ( std::vector< SIDE_AND_NPINS > &  aSides,
const std::vector< SIDE_AND_COLL > &  aCollidingSides,
COLLISION  aCollision,
SIDE_AND_NPINS  aLastSelection 
)
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().

◆ chooseSideForFields()

SIDE_AND_NPINS AUTOPLACER::chooseSideForFields ( bool  aAvoidCollisions)
inlineprotected

Look where a symbol's pins are to pick a side to put the fields on.

Parameters
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().

◆ computeFBoxSize()

VECTOR2I AUTOPLACER::computeFBoxSize ( bool  aDynamic)
inlineprotected

Compute and return the size of the fields' bounding box.

Parameters
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().

◆ DoAutoplace()

◆ fieldBoxPlacement()

◆ fieldHPlacement()

int AUTOPLACER::fieldHPlacement ( SCH_FIELD aField,
const BOX2I aFieldBox 
)
inlineprotected

Place a field horizontally, taking into account the field width and justification.

Parameters
aField- the field to place.
aFieldBox- box in which fields will be placed
Returns
Correct field horizontal position

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().

◆ fieldVPlacement()

int AUTOPLACER::fieldVPlacement ( SCH_FIELD aField,
const BOX2I aFieldBox,
int *  aAccumulatedPosition,
bool  aDynamic 
)
inlineprotected

Place a field vertically.

Because field vertical placements accumulate, this takes a pointer to a vertical position accumulator.

Parameters
aField- the field to place.
aFieldBox- box in which fields will be placed.
aAccumulatedPosition- pointer to a position accumulator
aDynamic- use dynamic spacing
Returns
Correct field vertical position

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().

◆ filterCollisions()

std::vector< SCH_ITEM * > AUTOPLACER::filterCollisions ( const BOX2I aRect)
inlineprotected

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().

◆ fitFieldsBetweenWires()

bool AUTOPLACER::fitFieldsBetweenWires ( BOX2I aBox,
SIDE  aSide 
)
inlineprotected

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().

◆ getCollidingSides()

std::vector< SIDE_AND_COLL > AUTOPLACER::getCollidingSides ( )
inlineprotected

◆ getPinSide()

SIDE AUTOPLACER::getPinSide ( SCH_PIN aPin)
inlineprotected

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().

◆ getPossibleCollisions()

void AUTOPLACER::getPossibleCollisions ( std::vector< SCH_ITEM * > &  aItems)
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().

◆ getPreferredSides()

std::vector< SIDE_AND_NPINS > AUTOPLACER::getPreferredSides ( )
inlineprotected

◆ justifyField()

void AUTOPLACER::justifyField ( SCH_FIELD aField,
SIDE  aFieldSide 
)
inlineprotected

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().

◆ pinsOnSide()

unsigned AUTOPLACER::pinsOnSide ( SIDE  aSide)
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().

Member Data Documentation

◆ m_align_to_grid

bool AUTOPLACER::m_align_to_grid
private

Definition at line 720 of file autoplace_fields.cpp.

Referenced by AUTOPLACER(), computeFBoxSize(), DoAutoplace(), and fieldVPlacement().

◆ m_allow_rejustify

bool AUTOPLACER::m_allow_rejustify
private

Definition at line 719 of file autoplace_fields.cpp.

Referenced by AUTOPLACER(), and DoAutoplace().

◆ m_colliders

std::vector<SCH_ITEM*> AUTOPLACER::m_colliders
private

Definition at line 716 of file autoplace_fields.cpp.

Referenced by AUTOPLACER(), and filterCollisions().

◆ m_fbox_size

VECTOR2I AUTOPLACER::m_fbox_size
private

◆ m_fields

std::vector<SCH_FIELD*> AUTOPLACER::m_fields
private

Definition at line 715 of file autoplace_fields.cpp.

Referenced by AUTOPLACER(), computeFBoxSize(), and DoAutoplace().

◆ m_is_power_symbol

bool AUTOPLACER::m_is_power_symbol
private

Definition at line 721 of file autoplace_fields.cpp.

Referenced by AUTOPLACER(), fieldBoxPlacement(), getPreferredSides(), and pinsOnSide().

◆ m_screen

SCH_SCREEN* AUTOPLACER::m_screen
private

Definition at line 713 of file autoplace_fields.cpp.

Referenced by getPossibleCollisions().

◆ m_symbol

◆ m_symbol_bbox

BOX2I AUTOPLACER::m_symbol_bbox
private

Definition at line 717 of file autoplace_fields.cpp.

Referenced by AUTOPLACER(), fieldBoxPlacement(), and getPreferredSides().

◆ SIDE_BOTTOM

const AUTOPLACER::SIDE AUTOPLACER::SIDE_BOTTOM
static

◆ SIDE_LEFT

const AUTOPLACER::SIDE AUTOPLACER::SIDE_LEFT
static

◆ SIDE_RIGHT

const AUTOPLACER::SIDE AUTOPLACER::SIDE_RIGHT
static

◆ SIDE_TOP

const AUTOPLACER::SIDE AUTOPLACER::SIDE_TOP
static

The documentation for this class was generated from the following file: