KiCad PCB EDA Suite
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 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 
69 #define FIELD_PADDING 10 // arbitrarily chosen for aesthetics
70 #define FIELD_PADDING_ALIGNED 18 // aligns 50 mil text to a 100 mil grid
71 #define WIRE_V_SPACING 100
72 #define HPADDING 25
73 #define VPADDING 25
74 
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 
93 {
94  return static_cast<EDA_TEXT_HJUSTIFY_T>( x );
95 }
96 
97 
99 {
102  std::vector<SCH_FIELD*> m_fields;
103  std::vector<SCH_ITEM*> m_colliders;
105  wxSize m_fbox_size;
108 
109 public:
110  typedef wxPoint SIDE;
113 
115  {
117  unsigned pins;
118  };
119 
121  {
124  };
125 
126 
127  AUTOPLACER( SCH_COMPONENT* aComponent, SCH_SCREEN* aScreen )
128  :m_screen( aScreen ), m_component( aComponent )
129  {
130  m_component->GetFields( m_fields, /* aVisibleOnly */ true );
133 
135  m_fbox_size = ComputeFBoxSize( /* aDynamic */ true );
136 
138 
139  if( aScreen )
141  }
142 
143 
149  void DoAutoplace( bool aManual )
150  {
151  bool force_wire_spacing = false;
152  SIDE field_side = choose_side_for_fields( aManual );
153  wxPoint fbox_pos = field_box_placement( field_side );
154  EDA_RECT field_box( fbox_pos, m_fbox_size );
155 
156  if( aManual )
157  force_wire_spacing = fit_fields_between_wires( &field_box, field_side );
158 
159  // Move the fields
160  int last_y_coord = field_box.GetTop();
161  for( unsigned field_idx = 0; field_idx < m_fields.size(); ++field_idx )
162  {
163  SCH_FIELD* field = m_fields[field_idx];
164 
165  if( m_allow_rejustify )
166  justify_field( field, field_side );
167 
168  wxPoint pos(
169  field_horiz_placement( field, field_box ),
170  field_vert_placement( field, field_box, &last_y_coord, !force_wire_spacing ) );
171 
172  if( m_align_to_grid )
173  {
174  pos.x = round_n( pos.x, 50, field_side.x >= 0 );
175  pos.y = round_n( pos.y, 50, field_side.y == 1 );
176  }
177 
178  field->SetPosition( pos );
179  }
180  }
181 
182 
183 protected:
188  wxSize ComputeFBoxSize( bool aDynamic )
189  {
190  int max_field_width = 0;
191  int total_height = 0;
192 
193  for( SCH_FIELD* field : m_fields )
194  {
195  int field_width;
196  int field_height;
197 
198  if( m_component->GetTransform().y1 )
199  {
200  field->SetTextAngle( TEXT_ANGLE_VERT );
201  }
202  else
203  {
204  field->SetTextAngle( TEXT_ANGLE_HORIZ );
205  }
206 
207  field_width = field->GetBoundingBox().GetWidth();
208  field_height = field->GetBoundingBox().GetHeight();
209 
210  max_field_width = std::max( max_field_width, field_width );
211 
212  if( aDynamic )
213  total_height += field_height + get_field_padding();
214  else
215  total_height += WIRE_V_SPACING;
216 
217  }
218 
219  return wxSize( max_field_width, total_height );
220  }
221 
222 
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 
247  unsigned pins_on_side( SIDE aSide )
248  {
249  unsigned pin_count = 0;
250 
251  std::vector<LIB_PIN*> pins;
252  m_component->GetPins( pins );
253 
254  for( LIB_PIN* each_pin : pins )
255  {
256  if( !each_pin->IsVisible() && !m_power_symbol )
257  continue;
258  if( get_pin_side( each_pin ) == aSide )
259  ++pin_count;
260  }
261 
262  return pin_count;
263  }
264 
265 
272  void get_possible_colliders( std::vector<SCH_ITEM*>& aItems )
273  {
274  wxASSERT_MSG( m_screen, "get_possible_colliders() with null m_screen" );
275  for( SCH_ITEM* item = m_screen->GetDrawItems(); item; item = item->Next() )
276  {
277  if( SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( item ) )
278  {
279  if( comp == m_component ) 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  aItems.push_back( item );
287  }
288  }
289 
290 
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 
319  std::vector<SIDE_AND_NPINS> get_preferred_sides()
320  {
321  SIDE_AND_NPINS sides_init[] = {
326  };
327  std::vector<SIDE_AND_NPINS> sides( sides_init, sides_init + arrayDim( sides_init ) );
328 
329  int orient = m_component->GetOrientation();
330  int orient_angle = orient & 0xff; // enum is a bitmask
331  bool h_mirrored = ( ( orient & CMP_MIRROR_X )
332  && ( orient_angle == CMP_ORIENT_0 || orient_angle == CMP_ORIENT_180 ) );
333  double w = double( m_comp_bbox.GetWidth() );
334  double h = double( m_comp_bbox.GetHeight() );
335 
336  // The preferred-sides heuristics are a bit magical. These were determined mostly
337  // by trial and error.
338 
339  if( m_power_symbol )
340  {
341  // For power symbols, we generally want the label at the top first.
342  switch( orient_angle )
343  {
344  case CMP_ORIENT_0:
345  std::swap( sides[0], sides[1] );
346  std::swap( sides[1], sides[3] );
347  // TOP, BOTTOM, RIGHT, LEFT
348  break;
349  case CMP_ORIENT_90:
350  std::swap( sides[0], sides[2] );
351  std::swap( sides[1], sides[2] );
352  // LEFT, RIGHT, TOP, BOTTOM
353  break;
354  case CMP_ORIENT_180:
355  std::swap( sides[0], sides[3] );
356  // BOTTOM, TOP, LEFT, RIGHT
357  break;
358  case CMP_ORIENT_270:
359  std::swap( sides[1], sides[2] );
360  // RIGHT, LEFT, TOP, BOTTOM
361  break;
362  }
363  }
364  else
365  {
366  // If the component is horizontally mirrored, swap left and right
367  if( h_mirrored )
368  {
369  std::swap( sides[0], sides[2] );
370  }
371 
372  // If the component is very long or is a power symbol, swap H and V
373  if( w/h > 3.0 )
374  {
375  std::swap( sides[0], sides[1] );
376  std::swap( sides[1], sides[3] );
377  }
378  }
379 
380  return sides;
381  }
382 
383 
388  std::vector<SIDE_AND_COLL> get_colliding_sides()
389  {
390  SIDE sides_init[] = { SIDE_RIGHT, SIDE_TOP, SIDE_LEFT, SIDE_BOTTOM };
391  std::vector<SIDE> sides( sides_init, sides_init + arrayDim( sides_init ) );
392  std::vector<SIDE_AND_COLL> colliding;
393 
394  // Iterate over all sides and find the ones that collide
395  for( SIDE side : sides )
396  {
397  EDA_RECT box( field_box_placement( side ), m_fbox_size );
398 
399  COLLISION collision = COLLIDE_NONE;
400  for( SCH_ITEM* collider : filtered_colliders( box ) )
401  {
402  SCH_LINE* line = dynamic_cast<SCH_LINE*>( collider );
403  if( line && !side.x )
404  {
405  wxPoint start = line->GetStartPoint(), end = line->GetEndPoint();
406  if( start.y == end.y && collision != COLLIDE_OBJECTS )
407  collision = COLLIDE_H_WIRES;
408  else
409  collision = COLLIDE_OBJECTS;
410  }
411  else
412  collision = COLLIDE_OBJECTS;
413  }
414 
415  if( collision != COLLIDE_NONE )
416  colliding.push_back( { side, collision } );
417  }
418 
419  return colliding;
420  }
421 
422 
428  SIDE_AND_NPINS choose_side_filtered( std::vector<SIDE_AND_NPINS>& aSides,
429  const std::vector<SIDE_AND_COLL>& aCollidingSides, COLLISION aCollision,
430  SIDE_AND_NPINS aLastSelection)
431  {
432  SIDE_AND_NPINS sel = aLastSelection;
433 
434  std::vector<SIDE_AND_NPINS>::iterator it = aSides.begin();
435  while( it != aSides.end() )
436  {
437  bool collide = false;
438  for( SIDE_AND_COLL collision : aCollidingSides )
439  {
440  if( collision.side == it->side && collision.collision == aCollision )
441  collide = true;
442  }
443  if( !collide )
444  ++it;
445  else
446  {
447  if( it->pins <= sel.pins )
448  {
449  sel.pins = it->pins;
450  sel.side = it->side;
451  }
452  it = aSides.erase( it );
453  }
454  }
455  return sel;
456  }
457 
458 
465  SIDE choose_side_for_fields( bool aAvoidCollisions )
466  {
467  std::vector<SIDE_AND_NPINS> sides = get_preferred_sides();
468 
469  std::reverse( sides.begin(), sides.end() );
470  SIDE_AND_NPINS side = { wxPoint( 1, 0 ), UINT_MAX };
471 
472  if( aAvoidCollisions )
473  {
474  std::vector<SIDE_AND_COLL> colliding_sides = get_colliding_sides();
475  side = choose_side_filtered( sides, colliding_sides, COLLIDE_OBJECTS, side );
476  side = choose_side_filtered( sides, colliding_sides, COLLIDE_H_WIRES, side );
477  }
478 
479  for( SIDE_AND_NPINS& each_side : sides | boost::adaptors::reversed )
480  {
481  if( !each_side.pins ) return each_side.side;
482  }
483 
484  for( SIDE_AND_NPINS& each_side : sides )
485  {
486  if( each_side.pins <= side.pins )
487  {
488  side.pins = each_side.pins;
489  side.side = each_side.side;
490  }
491  }
492 
493  return side.side;
494  }
495 
496 
503  void justify_field( SCH_FIELD* aField, SIDE aFieldSide )
504  {
505  // Justification is set twice to allow IsHorizJustifyFlipped() to work correctly.
506  aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x ) );
507  aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x *
508  ( aField->IsHorizJustifyFlipped() ? -1 : 1 ) ) );
510  }
511 
512 
517  wxPoint field_box_placement( SIDE aFieldSide )
518  {
519  wxPoint fbox_center = m_comp_bbox.Centre();
520  int offs_x = ( m_comp_bbox.GetWidth() + m_fbox_size.GetWidth() ) / 2 + HPADDING;
521  int offs_y = ( m_comp_bbox.GetHeight() + m_fbox_size.GetHeight() ) / 2 + VPADDING;
522 
523  fbox_center.x += aFieldSide.x * offs_x;
524  fbox_center.y += aFieldSide.y * offs_y;
525 
526  wxPoint fbox_pos(
527  fbox_center.x - m_fbox_size.GetWidth() / 2,
528  fbox_center.y - m_fbox_size.GetHeight() / 2 );
529 
530  return fbox_pos;
531  }
532 
533 
540  {
541  if( aSide != SIDE_TOP && aSide != SIDE_BOTTOM )
542  return false;
543 
544  std::vector<SCH_ITEM*> colliders = filtered_colliders( *aBox );
545  if( colliders.empty() )
546  return false;
547 
548  // Find the offset of the wires for proper positioning
549  int offset = 0;
550 
551  for( SCH_ITEM* item : colliders )
552  {
553  SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
554  if( !line )
555  return false;
556  wxPoint start = line->GetStartPoint(), end = line->GetEndPoint();
557  if( start.y != end.y )
558  return false;
559 
560  int this_offset = (3 * WIRE_V_SPACING / 2) - ( start.y % WIRE_V_SPACING );
561  if( offset == 0 )
562  offset = this_offset;
563  else if( offset != this_offset )
564  return false;
565  }
566 
567  // At this point we are recomputing the field box size. Do not
568  // return false after this point.
569  m_fbox_size = ComputeFBoxSize( /* aDynamic */ false );
570 
571  wxPoint pos = aBox->GetPosition();
572 
573  // Remove the existing padding to get a bit more space to work with
574  if( aSide == SIDE_BOTTOM )
575  {
577  }
578  else
579  {
581  }
582 
583  pos.y = round_n( pos.y, WIRE_V_SPACING, aSide == SIDE_BOTTOM );
584 
585  aBox->SetOrigin( pos );
586  return true;
587  }
588 
589 
600  int field_horiz_placement( SCH_FIELD *aField, const EDA_RECT &aFieldBox )
601  {
602  int field_hjust;
603  int field_xcoord;
604 
605  if( aField->IsHorizJustifyFlipped() )
606  field_hjust = -aField->GetHorizJustify();
607  else
608  field_hjust = aField->GetHorizJustify();
609 
610  switch( field_hjust )
611  {
613  field_xcoord = aFieldBox.GetLeft();
614  break;
616  field_xcoord = aFieldBox.Centre().x;
617  break;
619  field_xcoord = aFieldBox.GetRight();
620  break;
621  default:
622  wxFAIL_MSG( "Unexpected value for SCH_FIELD::GetHorizJustify()" );
623  field_xcoord = aFieldBox.Centre().x; // Most are centered
624  }
625 
626  return field_xcoord;
627  }
628 
641  int field_vert_placement( SCH_FIELD *aField, const EDA_RECT &aFieldBox, int *aPosAccum,
642  bool aDynamic )
643  {
644  int field_height;
645  int padding;
646 
647  if( aDynamic )
648  {
649  field_height = aField->GetBoundingBox().GetHeight();
650 
651  padding = get_field_padding();
652  }
653  else
654  {
655  field_height = WIRE_V_SPACING / 2;
656  padding = WIRE_V_SPACING / 2;
657  }
658 
659  int placement = *aPosAccum + padding / 2 + field_height / 2;
660 
661  *aPosAccum += padding + field_height;
662 
663  return placement;
664  }
665 
671  {
672  if( m_align_to_grid )
673  return FIELD_PADDING_ALIGNED;
674  else
675  return FIELD_PADDING;
676  }
677 
678 };
679 
684 
685 
686 void SCH_COMPONENT::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
687 {
688  if( aManual )
689  wxASSERT_MSG( aScreen, "A SCH_SCREEN pointer must be given for manual autoplacement" );
690  AUTOPLACER autoplacer( this, aScreen );
691  autoplacer.DoAutoplace( aManual );
693 }
#define TEXT_ANGLE_HORIZ
void justify_field(SCH_FIELD *aField, SIDE aFieldSide)
Function justify_field Set the justification of a field based on the side it's supposed to be on,...
Class 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)
Function pins_on_side 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:63
#define VPADDING
std::vector< SIDE_AND_COLL > get_colliding_sides()
Function get_colliding_sides Return a list of the sides where a field set would collide with another ...
int GetOrientation()
Get the display symbol orientation.
wxPoint GetStartPoint() const
Definition: sch_line.h:90
#define TEXT_ANGLE_VERT
bool collide(T aObject, U aAnotherObject, int aMinDistance)
collide template method
Definition: shape_index.h:91
SCH_ITEM * Next() const
Definition: sch_item.h:153
int GetTop() const
Definition: eda_rect.h:121
int GetLeft() const
Definition: eda_rect.h:120
#define HPADDING
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
SCH_COMPONENT * m_component
int GetWidth() const
Definition: eda_rect.h:117
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)
Function choose_side_filtered Choose a side for the fields, filtered on only one side collision type.
bool IsInNetlist() const
wxPoint field_box_placement(SIDE aFieldSide)
Function field_box_placement Returns the position of the field bounding box.
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
Definition: lib_pin.h:55
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:1253
#define WIRE_V_SPACING
T round_n(const T &value, const T &n, bool aRoundUp)
Function round_n Round up/down to the nearest multiple of n.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
#define FIELD_PADDING_ALIGNED
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
int GetBottom() const
Definition: eda_rect.h:122
bool fit_fields_between_wires(EDA_RECT *aBox, SIDE aSide)
Function fit_fields_between_wires Shift a field box up or down a bit to make the fields fit between s...
int field_horiz_placement(SCH_FIELD *aField, const EDA_RECT &aFieldBox)
Function field_horiz_placement Place a field horizontally, taking into account the field width and ju...
int y1
Definition: transform.h:49
static const SIDE SIDE_LEFT
SCH_SCREEN * m_screen
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:207
const wxChar AutoplaceAlignEntry[]
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_ITEM definition.
int field_vert_placement(SCH_FIELD *aField, const EDA_RECT &aFieldBox, int *aPosAccum, bool aDynamic)
Function field_vert_placement Place a field vertically.
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:211
const wxPoint GetPosition() const
Definition: eda_rect.h:113
int GetRight() const
Definition: eda_rect.h:119
#define FIELD_PADDING
EDA_RECT m_comp_bbox
EDA_TEXT_HJUSTIFY_T TO_HJUSTIFY(int x)
Function TO_HJUSTIFY Converts an integer to a horizontal justification; neg=L zero=C pos=R.
int GetHeight() const
Definition: eda_rect.h:118
static const SIDE SIDE_RIGHT
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:107
SIDE get_pin_side(LIB_PIN *aPin)
Function get_pin_side Return the side that a pin is on.
void GetPins(std::vector< LIB_PIN * > &aPinsList)
Populate a vector with all the pins from the library object.
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Automatically orient all the fields in the component.
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_field.cpp:236
#define max(a, b)
Definition: auxiliary.h:86
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:210
static const SIDE SIDE_BOTTOM
int get_field_padding()
Function get_field_padding Return the desired padding between fields.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
static void reverse(privcurve_t *curve)
Definition: trace.cpp:1025
wxPoint Centre() const
Definition: eda_rect.h:60
bool IsHorizJustifyFlipped() const
Function IsHorizJustifyFlipped Returns whether the field will be rendered with the horizontal justifi...
Definition: sch_field.cpp:282
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
SIDE choose_side_for_fields(bool aAvoidCollisions)
Function choose_side_for_fields Look where a component's pins are to pick a side to put the fields on...
void DoAutoplace(bool aManual)
Do the actual autoplacement.
Some functions to handle hotkeys in KiCad.
static const SIDE SIDE_TOP
std::vector< SIDE_AND_NPINS > get_preferred_sides()
Function get_preferred_sides Return a list with the preferred field sides for the component,...
AUTOPLACER(SCH_COMPONENT *aComponent, SCH_SCREEN *aScreen)
AUTOPLACED m_fieldsAutoplaced
indicates status of field autoplacement
void get_possible_colliders(std::vector< SCH_ITEM * > &aItems)
Function get_possible_colliders 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:535
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
const wxChar AutoplaceJustifyEntry[]
std::vector< SCH_ITEM * > filtered_colliders(const EDA_RECT &aRect)
Function filtered_colliders Filter a list of possible colliders to include only those that actually c...
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:153
wxPoint GetEndPoint() const
Definition: sch_line.h:93