KiCad PCB EDA Suite
eeschema/autoplace_fields.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 (C) 2015 Chris Pavlina <pavlina.chris@gmail.com>
5  * Copyright (C) 2015, 2019 KiCad Developers, see change_log.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 /******************************************************************************
26  * Field autoplacer: Tries to find an optimal place for component fields, and
27  * places them there. There are two modes: "auto"-autoplace, and "manual" autoplace.
28  * Auto mode is for when the process is run automatically, like when rotating parts,
29  * and it avoids doing things that would be helpful for the final positioning but
30  * annoying if they happened without permission.
31  * Short description of the process:
32  *
33  * 1. Compute the dimensions of the fields' bounding box ::ComputeFBoxSize
34  * 2. Determine which side the fields will go on. ::choose_side_for_fields
35  * 1. Sort the four sides in preference order,
36  * depending on the component's shape and
37  * orientation ::get_preferred_sides
38  * 2. If in manual mode, sift out the sides that would
39  * cause fields to overlap other items ::get_colliding_sides
40  * 3. If any remaining sides have zero pins there,
41  * choose the highest zero-pin side according to
42  * preference order.
43  * 4. If all sides have pins, choose the side with the
44  * fewest pins.
45  * 3. Compute the position of the fields' bounding box ::field_box_placement
46  * 4. In manual mode, shift the box vertically if possible
47  * to fit fields between adjacent wires ::fit_fields_between_wires
48  * 5. Move all fields to their final positions
49  * 1. Re-justify fields if options allow that ::justify_field
50  * 2. Round to a 50-mil grid coordinate if desired
51  */
52 
53 #include <boost/range/adaptor/reversed.hpp>
54 
55 #include <sch_edit_frame.h>
56 #include <hotkeys_basic.h>
57 #include <sch_component.h>
58 #include <sch_line.h>
59 #include <lib_pin.h>
60 #include <sch_draw_panel.h>
61 #include <class_libentry.h>
62 #include <eeschema_config.h>
63 #include <kiface_i.h>
64 #include <vector>
65 #include <algorithm>
66 #include <tool/tool_manager.h>
68 #include <eeschema_settings.h>
69 
70 #define FIELD_PADDING Mils2iu( 10 ) // arbitrarily chosen for aesthetics
71 #define FIELD_PADDING_ALIGNED Mils2iu( 18 ) // aligns 50 mil text to a 100 mil grid
72 #define WIRE_V_SPACING Mils2iu( 100 )
73 #define HPADDING Mils2iu( 25 )
74 #define VPADDING Mils2iu( 25 )
75 
79 template<typename T> T round_n( const T& value, const T& n, bool aRoundUp )
80 {
81  if( value % n )
82  return n * (value / n + (aRoundUp ? 1 : 0));
83  else
84  return value;
85 }
86 
87 
92 {
93  return static_cast<EDA_TEXT_HJUSTIFY_T>( x );
94 }
95 
96 
98 {
101  std::vector<SCH_FIELD*> m_fields;
102  std::vector<SCH_ITEM*> m_colliders;
104  wxSize m_fbox_size;
107 
108 public:
109  typedef wxPoint SIDE;
112 
114  {
116  unsigned pins;
117  };
118 
120  {
123  };
124 
125 
126  AUTOPLACER( SCH_COMPONENT* aComponent, SCH_SCREEN* aScreen )
127  :m_screen( aScreen ), m_component( aComponent )
128  {
129  m_component->GetFields( m_fields, /* aVisibleOnly */ true );
130 
131  auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
132  m_allow_rejustify = cfg->m_AutoplaceFields.allow_rejustify;
133  m_align_to_grid = cfg->m_AutoplaceFields.align_to_grid;
134 
136  m_fbox_size = ComputeFBoxSize( /* aDynamic */ true );
137 
139 
140  if( aScreen )
142  }
143 
144 
150  void DoAutoplace( bool aManual )
151  {
152  bool force_wire_spacing = false;
153  SIDE field_side = choose_side_for_fields( aManual );
154  wxPoint fbox_pos = field_box_placement( field_side );
155  EDA_RECT field_box( fbox_pos, m_fbox_size );
156 
157  if( aManual )
158  force_wire_spacing = fit_fields_between_wires( &field_box, field_side );
159 
160  // Move the fields
161  int last_y_coord = field_box.GetTop();
162  for( unsigned field_idx = 0; field_idx < m_fields.size(); ++field_idx )
163  {
164  SCH_FIELD* field = m_fields[field_idx];
165 
166  if( m_allow_rejustify )
167  justify_field( field, field_side );
168 
169  wxPoint pos(
170  field_horiz_placement( field, field_box ),
171  field_vert_placement( field, field_box, &last_y_coord, !force_wire_spacing ) );
172 
173  if( m_align_to_grid )
174  {
175  pos.x = round_n( pos.x, Mils2iu( 50 ), field_side.x >= 0 );
176  pos.y = round_n( pos.y, Mils2iu( 50 ), field_side.y == 1 );
177  }
178 
179  field->SetPosition( pos );
180  }
181  }
182 
183 
184 protected:
189  wxSize ComputeFBoxSize( bool aDynamic )
190  {
191  int max_field_width = 0;
192  int total_height = 0;
193 
194  for( SCH_FIELD* field : m_fields )
195  {
196  int field_width;
197  int field_height;
198 
199  if( m_component->GetTransform().y1 )
200  {
201  field->SetTextAngle( TEXT_ANGLE_VERT );
202  }
203  else
204  {
205  field->SetTextAngle( TEXT_ANGLE_HORIZ );
206  }
207 
208  field_width = field->GetBoundingBox().GetWidth();
209  field_height = field->GetBoundingBox().GetHeight();
210 
211  max_field_width = std::max( max_field_width, field_width );
212 
213  if( aDynamic )
214  total_height += field_height + get_field_padding();
215  else
216  total_height += WIRE_V_SPACING;
217 
218  }
219 
220  return wxSize( max_field_width, total_height );
221  }
222 
223 
228  {
229  int pin_orient = aPin->PinDrawOrient( m_component->GetTransform() );
230  switch( pin_orient )
231  {
232  case PIN_RIGHT: return SIDE_LEFT;
233  case PIN_LEFT: return SIDE_RIGHT;
234  case PIN_UP: return SIDE_BOTTOM;
235  case PIN_DOWN: return SIDE_TOP;
236  default:
237  wxFAIL_MSG( "Invalid pin orientation" );
238  return SIDE_LEFT;
239  }
240  }
241 
242 
246  unsigned pins_on_side( SIDE aSide )
247  {
248  unsigned pin_count = 0;
249 
250  std::vector<LIB_PIN*> pins;
251  m_component->GetPins( pins );
252 
253  for( LIB_PIN* each_pin : pins )
254  {
255  if( !each_pin->IsVisible() && !m_power_symbol )
256  continue;
257  if( get_pin_side( each_pin ) == aSide )
258  ++pin_count;
259  }
260 
261  return pin_count;
262  }
263 
264 
270  void get_possible_colliders( std::vector<SCH_ITEM*>& aItems )
271  {
272  wxCHECK_RET( m_screen, "get_possible_colliders() with null m_screen" );
273 
274  for( auto item : m_screen->Items().Overlapping( m_component->GetBoundingBox() ) )
275  {
276  if( SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( item ) )
277  {
278  if( comp == m_component )
279  continue;
280 
281  std::vector<SCH_FIELD*> fields;
282  comp->GetFields( fields, /* aVisibleOnly */ true );
283  for( SCH_FIELD* field : fields )
284  aItems.push_back( field );
285  }
286 
287  aItems.push_back( item );
288  }
289  }
290 
291 
296  std::vector<SCH_ITEM*> filtered_colliders( const EDA_RECT& aRect )
297  {
298  std::vector<SCH_ITEM*> filtered;
299  for( SCH_ITEM* item : m_colliders )
300  {
301  EDA_RECT item_box;
302  if( SCH_COMPONENT* item_comp = dynamic_cast<SCH_COMPONENT*>( item ) )
303  item_box = item_comp->GetBodyBoundingBox();
304  else
305  item_box = item->GetBoundingBox();
306 
307  if( item_box.Intersects( aRect ) )
308  filtered.push_back( item );
309  }
310  return filtered;
311  }
312 
313 
318  std::vector<SIDE_AND_NPINS> get_preferred_sides()
319  {
320  SIDE_AND_NPINS sides_init[] = {
325  };
326  std::vector<SIDE_AND_NPINS> sides( sides_init, sides_init + arrayDim( sides_init ) );
327 
328  int orient = m_component->GetOrientation();
329  int orient_angle = orient & 0xff; // enum is a bitmask
330  bool h_mirrored = ( ( orient & CMP_MIRROR_X )
331  && ( orient_angle == CMP_ORIENT_0 || orient_angle == CMP_ORIENT_180 ) );
332  double w = double( m_comp_bbox.GetWidth() );
333  double h = double( m_comp_bbox.GetHeight() );
334 
335  // The preferred-sides heuristics are a bit magical. These were determined mostly
336  // by trial and error.
337 
338  if( m_power_symbol )
339  {
340  // For power symbols, we generally want the label at the top first.
341  switch( orient_angle )
342  {
343  case CMP_ORIENT_0:
344  std::swap( sides[0], sides[1] );
345  std::swap( sides[1], sides[3] );
346  // TOP, BOTTOM, RIGHT, LEFT
347  break;
348  case CMP_ORIENT_90:
349  std::swap( sides[0], sides[2] );
350  std::swap( sides[1], sides[2] );
351  // LEFT, RIGHT, TOP, BOTTOM
352  break;
353  case CMP_ORIENT_180:
354  std::swap( sides[0], sides[3] );
355  // BOTTOM, TOP, LEFT, RIGHT
356  break;
357  case CMP_ORIENT_270:
358  std::swap( sides[1], sides[2] );
359  // RIGHT, LEFT, TOP, BOTTOM
360  break;
361  }
362  }
363  else
364  {
365  // If the component is horizontally mirrored, swap left and right
366  if( h_mirrored )
367  {
368  std::swap( sides[0], sides[2] );
369  }
370 
371  // If the component is very long or is a power symbol, swap H and V
372  if( w/h > 3.0 )
373  {
374  std::swap( sides[0], sides[1] );
375  std::swap( sides[1], sides[3] );
376  }
377  }
378 
379  return sides;
380  }
381 
382 
386  std::vector<SIDE_AND_COLL> get_colliding_sides()
387  {
388  SIDE sides_init[] = { SIDE_RIGHT, SIDE_TOP, SIDE_LEFT, SIDE_BOTTOM };
389  std::vector<SIDE> sides( sides_init, sides_init + arrayDim( sides_init ) );
390  std::vector<SIDE_AND_COLL> colliding;
391 
392  // Iterate over all sides and find the ones that collide
393  for( SIDE side : sides )
394  {
395  EDA_RECT box( field_box_placement( side ), m_fbox_size );
396 
397  COLLISION collision = COLLIDE_NONE;
398  for( SCH_ITEM* collider : filtered_colliders( box ) )
399  {
400  SCH_LINE* line = dynamic_cast<SCH_LINE*>( collider );
401  if( line && !side.x )
402  {
403  wxPoint start = line->GetStartPoint(), end = line->GetEndPoint();
404  if( start.y == end.y && collision != COLLIDE_OBJECTS )
405  collision = COLLIDE_H_WIRES;
406  else
407  collision = COLLIDE_OBJECTS;
408  }
409  else
410  collision = COLLIDE_OBJECTS;
411  }
412 
413  if( collision != COLLIDE_NONE )
414  colliding.push_back( { side, collision } );
415  }
416 
417  return colliding;
418  }
419 
420 
425  SIDE_AND_NPINS choose_side_filtered( std::vector<SIDE_AND_NPINS>& aSides,
426  const std::vector<SIDE_AND_COLL>& aCollidingSides, COLLISION aCollision,
427  SIDE_AND_NPINS aLastSelection)
428  {
429  SIDE_AND_NPINS sel = aLastSelection;
430 
431  std::vector<SIDE_AND_NPINS>::iterator it = aSides.begin();
432  while( it != aSides.end() )
433  {
434  bool collide = false;
435  for( SIDE_AND_COLL collision : aCollidingSides )
436  {
437  if( collision.side == it->side && collision.collision == aCollision )
438  collide = true;
439  }
440  if( !collide )
441  ++it;
442  else
443  {
444  if( it->pins <= sel.pins )
445  {
446  sel.pins = it->pins;
447  sel.side = it->side;
448  }
449  it = aSides.erase( it );
450  }
451  }
452  return sel;
453  }
454 
455 
461  SIDE choose_side_for_fields( bool aAvoidCollisions )
462  {
463  std::vector<SIDE_AND_NPINS> sides = get_preferred_sides();
464 
465  std::reverse( sides.begin(), sides.end() );
466  SIDE_AND_NPINS side = { wxPoint( 1, 0 ), UINT_MAX };
467 
468  if( aAvoidCollisions )
469  {
470  std::vector<SIDE_AND_COLL> colliding_sides = get_colliding_sides();
471  side = choose_side_filtered( sides, colliding_sides, COLLIDE_OBJECTS, side );
472  side = choose_side_filtered( sides, colliding_sides, COLLIDE_H_WIRES, side );
473  }
474 
475  for( SIDE_AND_NPINS& each_side : sides | boost::adaptors::reversed )
476  {
477  if( !each_side.pins ) return each_side.side;
478  }
479 
480  for( SIDE_AND_NPINS& each_side : sides )
481  {
482  if( each_side.pins <= side.pins )
483  {
484  side.pins = each_side.pins;
485  side.side = each_side.side;
486  }
487  }
488 
489  return side.side;
490  }
491 
492 
498  void justify_field( SCH_FIELD* aField, SIDE aFieldSide )
499  {
500  // Justification is set twice to allow IsHorizJustifyFlipped() to work correctly.
501  aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x ) );
502  aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x *
503  ( aField->IsHorizJustifyFlipped() ? -1 : 1 ) ) );
505  }
506 
507 
512  {
513  wxPoint fbox_center = m_comp_bbox.Centre();
514  int offs_x = ( m_comp_bbox.GetWidth() + m_fbox_size.GetWidth() ) / 2 + HPADDING;
515  int offs_y = ( m_comp_bbox.GetHeight() + m_fbox_size.GetHeight() ) / 2 + VPADDING;
516 
517  fbox_center.x += aFieldSide.x * offs_x;
518  fbox_center.y += aFieldSide.y * offs_y;
519 
520  wxPoint fbox_pos(
521  fbox_center.x - m_fbox_size.GetWidth() / 2,
522  fbox_center.y - m_fbox_size.GetHeight() / 2 );
523 
524  return fbox_pos;
525  }
526 
527 
533  {
534  if( aSide != SIDE_TOP && aSide != SIDE_BOTTOM )
535  return false;
536 
537  std::vector<SCH_ITEM*> colliders = filtered_colliders( *aBox );
538  if( colliders.empty() )
539  return false;
540 
541  // Find the offset of the wires for proper positioning
542  int offset = 0;
543 
544  for( SCH_ITEM* item : colliders )
545  {
546  SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
547  if( !line )
548  return false;
549  wxPoint start = line->GetStartPoint(), end = line->GetEndPoint();
550  if( start.y != end.y )
551  return false;
552 
553  int this_offset = (3 * WIRE_V_SPACING / 2) - ( start.y % WIRE_V_SPACING );
554  if( offset == 0 )
555  offset = this_offset;
556  else if( offset != this_offset )
557  return false;
558  }
559 
560  // At this point we are recomputing the field box size. Do not
561  // return false after this point.
562  m_fbox_size = ComputeFBoxSize( /* aDynamic */ false );
563 
564  wxPoint pos = aBox->GetPosition();
565 
566  // Remove the existing padding to get a bit more space to work with
567  if( aSide == SIDE_BOTTOM )
568  {
570  }
571  else
572  {
574  }
575 
576  pos.y = round_n( pos.y, WIRE_V_SPACING, aSide == SIDE_BOTTOM );
577 
578  aBox->SetOrigin( pos );
579  return true;
580  }
581 
582 
591  int field_horiz_placement( SCH_FIELD *aField, const EDA_RECT &aFieldBox )
592  {
593  int field_hjust;
594  int field_xcoord;
595 
596  if( aField->IsHorizJustifyFlipped() )
597  field_hjust = -aField->GetHorizJustify();
598  else
599  field_hjust = aField->GetHorizJustify();
600 
601  switch( field_hjust )
602  {
604  field_xcoord = aFieldBox.GetLeft();
605  break;
607  field_xcoord = aFieldBox.Centre().x;
608  break;
610  field_xcoord = aFieldBox.GetRight();
611  break;
612  default:
613  wxFAIL_MSG( "Unexpected value for SCH_FIELD::GetHorizJustify()" );
614  field_xcoord = aFieldBox.Centre().x; // Most are centered
615  }
616 
617  return field_xcoord;
618  }
619 
631  int field_vert_placement( SCH_FIELD *aField, const EDA_RECT &aFieldBox, int *aPosAccum,
632  bool aDynamic )
633  {
634  int field_height;
635  int padding;
636 
637  if( aDynamic )
638  {
639  field_height = aField->GetBoundingBox().GetHeight();
640 
641  padding = get_field_padding();
642  }
643  else
644  {
645  field_height = WIRE_V_SPACING / 2;
646  padding = WIRE_V_SPACING / 2;
647  }
648 
649  int placement = *aPosAccum + padding / 2 + field_height / 2;
650 
651  *aPosAccum += padding + field_height;
652 
653  return placement;
654  }
655 
660  {
661  if( m_align_to_grid )
662  return FIELD_PADDING_ALIGNED;
663  else
664  return FIELD_PADDING;
665  }
666 
667 };
668 
673 
674 
675 void SCH_COMPONENT::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
676 {
677  if( aManual )
678  wxASSERT_MSG( aScreen, "A SCH_SCREEN pointer must be given for manual autoplacement" );
679 
680  AUTOPLACER autoplacer( this, aScreen );
681  autoplacer.DoAutoplace( aManual );
683 }
#define TEXT_ANGLE_HORIZ
void justify_field(SCH_FIELD *aField, SIDE aFieldSide)
Set the justification of a field based on the side it's supposed to be on, taking into account whethe...
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
wxSize ComputeFBoxSize(bool aDynamic)
Compute and return the size of the fields' bounding box.
unsigned pins_on_side(SIDE aSide)
Count the number of pins on a side of the component.
std::vector< SCH_FIELD * > m_fields
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:44
std::vector< SIDE_AND_COLL > get_colliding_sides()
Return a list of the sides where a field set would collide with another item.
int GetOrientation()
Get the display symbol orientation.
wxPoint GetStartPoint() const
Definition: sch_line.h:97
#define TEXT_ANGLE_VERT
bool collide(T aObject, U aAnotherObject, int aMinDistance)
collide template method
Definition: shape_index.h:92
int GetTop() const
Definition: eda_rect.h:123
int GetLeft() const
Definition: eda_rect.h:122
#define WIRE_V_SPACING
EE_TYPE Overlapping(const EDA_RECT &aRect)
Definition: sch_rtree.h:224
SCH_COMPONENT * m_component
#define VPADDING
int GetWidth() const
Definition: eda_rect.h:119
SIDE_AND_NPINS choose_side_filtered(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.
bool IsInNetlist() const
wxPoint field_box_placement(SIDE aFieldSide)
Return the position of the field bounding box.
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
Definition: lib_pin.h:58
int PinDrawOrient(const TRANSFORM &aTransform) const
Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT), according to its orientation...
Definition: lib_pin.cpp:1201
#define HPADDING
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:154
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
int GetBottom() const
Definition: eda_rect.h:124
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
bool fit_fields_between_wires(EDA_RECT *aBox, SIDE aSide)
Shift a field box up or down a bit to make the fields fit between some wires.
int field_horiz_placement(SCH_FIELD *aField, const EDA_RECT &aFieldBox)
Place a field horizontally, taking into account the field width and justification.
int y1
Definition: transform.h:49
static const SIDE SIDE_LEFT
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:183
std::vector< SCH_ITEM * > m_colliders
TRANSFORM & GetTransform() const
EDA_RECT GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the fields.
Class LIB_PIN definition.
int field_vert_placement(SCH_FIELD *aField, const EDA_RECT &aFieldBox, int *aPosAccum, bool aDynamic)
Place a field vertically.
EDA_TEXT_HJUSTIFY_T TO_HJUSTIFY(int x)
Convert an integer to a horizontal justification; neg=L zero=C pos=R.
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:187
const wxPoint GetPosition() const
Definition: eda_rect.h:115
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
int GetRight() const
Definition: eda_rect.h:121
int GetHeight() const
Definition: eda_rect.h:120
static const SIDE SIDE_RIGHT
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108
SIDE get_pin_side(LIB_PIN *aPin)
Return the side that a pin is on.
T round_n(const T &value, const T &n, bool aRoundUp)
Round up/down to the nearest multiple of n.
void GetPins(std::vector< LIB_PIN * > &aPinsList)
Populate a vector with all the pins from the library object.
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:38
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_field.cpp:204
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:186
static const SIDE SIDE_BOTTOM
int get_field_padding()
Return the desired padding between fields.
EE_RTREE & Items()
Definition: sch_screen.h:127
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the component.
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
wxPoint Centre() const
Definition: eda_rect.h:62
bool IsHorizJustifyFlipped() const
Function IsHorizJustifyFlipped Returns whether the field will be rendered with the horizontal justifi...
Definition: sch_field.cpp:256
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
#define FIELD_PADDING
SIDE choose_side_for_fields(bool aAvoidCollisions)
Look where a component's pins are to pick a side to put the fields on.
void DoAutoplace(bool aManual)
Do the actual autoplacement.
#define FIELD_PADDING_ALIGNED
static const SIDE SIDE_TOP
std::vector< SIDE_AND_NPINS > get_preferred_sides()
Return a list with the preferred field sides for the component, in decreasing order of preference.
AUTOPLACER(SCH_COMPONENT *aComponent, SCH_SCREEN *aScreen)
void get_possible_colliders(std::vector< SCH_ITEM * > &aItems)
Populate a list of all drawing items that may collide with the fields.
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_field.cpp:518
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
std::vector< SCH_ITEM * > filtered_colliders(const EDA_RECT &aRect)
Filter a list of possible colliders to include only those that actually collide with a given rectangl...
wxPoint GetEndPoint() const
Definition: sch_line.h:100