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, 2020 KiCad Developers, see AUTHORS.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  wxASSERT( cfg );
133 
134  m_allow_rejustify = false;
135  m_align_to_grid = true;
136 
137  if( cfg )
138  {
139  m_allow_rejustify = cfg->m_AutoplaceFields.allow_rejustify;
140  m_align_to_grid = cfg->m_AutoplaceFields.align_to_grid;
141  }
142 
144  m_fbox_size = ComputeFBoxSize( /* aDynamic */ true );
145 
147 
148  if( aScreen )
150  }
151 
152 
158  void DoAutoplace( bool aManual )
159  {
160  bool force_wire_spacing = false;
161  SIDE field_side = choose_side_for_fields( aManual );
162  wxPoint fbox_pos = field_box_placement( field_side );
163  EDA_RECT field_box( fbox_pos, m_fbox_size );
164 
165  if( aManual )
166  force_wire_spacing = fit_fields_between_wires( &field_box, field_side );
167 
168  // Move the fields
169  int last_y_coord = field_box.GetTop();
170  for( unsigned field_idx = 0; field_idx < m_fields.size(); ++field_idx )
171  {
172  SCH_FIELD* field = m_fields[field_idx];
173 
174  if( m_allow_rejustify )
175  justify_field( field, field_side );
176 
177  wxPoint pos(
178  field_horiz_placement( field, field_box ),
179  field_vert_placement( field, field_box, &last_y_coord, !force_wire_spacing ) );
180 
181  if( m_align_to_grid )
182  {
183  pos.x = round_n( pos.x, Mils2iu( 50 ), field_side.x >= 0 );
184  pos.y = round_n( pos.y, Mils2iu( 50 ), field_side.y == 1 );
185  }
186 
187  field->SetPosition( pos );
188  }
189  }
190 
191 
192 protected:
197  wxSize ComputeFBoxSize( bool aDynamic )
198  {
199  int max_field_width = 0;
200  int total_height = 0;
201 
202  for( SCH_FIELD* field : m_fields )
203  {
204  int field_width;
205  int field_height;
206 
207  if( m_component->GetTransform().y1 )
208  {
209  field->SetTextAngle( TEXT_ANGLE_VERT );
210  }
211  else
212  {
213  field->SetTextAngle( TEXT_ANGLE_HORIZ );
214  }
215 
216  field_width = field->GetBoundingBox().GetWidth();
217  field_height = field->GetBoundingBox().GetHeight();
218 
219  max_field_width = std::max( max_field_width, field_width );
220 
221  if( aDynamic )
222  total_height += field_height + get_field_padding();
223  else
224  total_height += WIRE_V_SPACING;
225 
226  }
227 
228  return wxSize( max_field_width, total_height );
229  }
230 
231 
236  {
237  int pin_orient = aPin->PinDrawOrient( m_component->GetTransform() );
238  switch( pin_orient )
239  {
240  case PIN_RIGHT: return SIDE_LEFT;
241  case PIN_LEFT: return SIDE_RIGHT;
242  case PIN_UP: return SIDE_BOTTOM;
243  case PIN_DOWN: return SIDE_TOP;
244  default:
245  wxFAIL_MSG( "Invalid pin orientation" );
246  return SIDE_LEFT;
247  }
248  }
249 
250 
254  unsigned pins_on_side( SIDE aSide )
255  {
256  unsigned pin_count = 0;
257 
258  std::vector<LIB_PIN*> pins;
259  m_component->GetPins( pins );
260 
261  for( LIB_PIN* each_pin : pins )
262  {
263  if( !each_pin->IsVisible() && !m_power_symbol )
264  continue;
265  if( get_pin_side( each_pin ) == aSide )
266  ++pin_count;
267  }
268 
269  return pin_count;
270  }
271 
272 
278  void get_possible_colliders( std::vector<SCH_ITEM*>& aItems )
279  {
280  wxCHECK_RET( m_screen, "get_possible_colliders() with null m_screen" );
281 
282  for( auto item : m_screen->Items().Overlapping( m_component->GetBoundingBox() ) )
283  {
284  if( SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( item ) )
285  {
286  if( comp == m_component )
287  continue;
288 
289  std::vector<SCH_FIELD*> fields;
290  comp->GetFields( fields, /* aVisibleOnly */ true );
291  for( SCH_FIELD* field : fields )
292  aItems.push_back( field );
293  }
294 
295  aItems.push_back( item );
296  }
297  }
298 
299 
304  std::vector<SCH_ITEM*> filtered_colliders( const EDA_RECT& aRect )
305  {
306  std::vector<SCH_ITEM*> filtered;
307  for( SCH_ITEM* item : m_colliders )
308  {
309  EDA_RECT item_box;
310  if( SCH_COMPONENT* item_comp = dynamic_cast<SCH_COMPONENT*>( item ) )
311  item_box = item_comp->GetBodyBoundingBox();
312  else
313  item_box = item->GetBoundingBox();
314 
315  if( item_box.Intersects( aRect ) )
316  filtered.push_back( item );
317  }
318  return filtered;
319  }
320 
321 
326  std::vector<SIDE_AND_NPINS> get_preferred_sides()
327  {
328  SIDE_AND_NPINS sides_init[] = {
333  };
334  std::vector<SIDE_AND_NPINS> sides( sides_init, sides_init + arrayDim( sides_init ) );
335 
336  int orient = m_component->GetOrientation();
337  int orient_angle = orient & 0xff; // enum is a bitmask
338  bool h_mirrored = ( ( orient & CMP_MIRROR_X )
339  && ( orient_angle == CMP_ORIENT_0 || orient_angle == CMP_ORIENT_180 ) );
340  double w = double( m_comp_bbox.GetWidth() );
341  double h = double( m_comp_bbox.GetHeight() );
342 
343  // The preferred-sides heuristics are a bit magical. These were determined mostly
344  // by trial and error.
345 
346  if( m_power_symbol )
347  {
348  // For power symbols, we generally want the label at the top first.
349  switch( orient_angle )
350  {
351  case CMP_ORIENT_0:
352  std::swap( sides[0], sides[1] );
353  std::swap( sides[1], sides[3] );
354  // TOP, BOTTOM, RIGHT, LEFT
355  break;
356  case CMP_ORIENT_90:
357  std::swap( sides[0], sides[2] );
358  std::swap( sides[1], sides[2] );
359  // LEFT, RIGHT, TOP, BOTTOM
360  break;
361  case CMP_ORIENT_180:
362  std::swap( sides[0], sides[3] );
363  // BOTTOM, TOP, LEFT, RIGHT
364  break;
365  case CMP_ORIENT_270:
366  std::swap( sides[1], sides[2] );
367  // RIGHT, LEFT, TOP, BOTTOM
368  break;
369  }
370  }
371  else
372  {
373  // If the component is horizontally mirrored, swap left and right
374  if( h_mirrored )
375  {
376  std::swap( sides[0], sides[2] );
377  }
378 
379  // If the component is very long or is a power symbol, swap H and V
380  if( w/h > 3.0 )
381  {
382  std::swap( sides[0], sides[1] );
383  std::swap( sides[1], sides[3] );
384  }
385  }
386 
387  return sides;
388  }
389 
390 
394  std::vector<SIDE_AND_COLL> get_colliding_sides()
395  {
396  SIDE sides_init[] = { SIDE_RIGHT, SIDE_TOP, SIDE_LEFT, SIDE_BOTTOM };
397  std::vector<SIDE> sides( sides_init, sides_init + arrayDim( sides_init ) );
398  std::vector<SIDE_AND_COLL> colliding;
399 
400  // Iterate over all sides and find the ones that collide
401  for( SIDE side : sides )
402  {
403  EDA_RECT box( field_box_placement( side ), m_fbox_size );
404 
405  COLLISION collision = COLLIDE_NONE;
406  for( SCH_ITEM* collider : filtered_colliders( box ) )
407  {
408  SCH_LINE* line = dynamic_cast<SCH_LINE*>( collider );
409  if( line && !side.x )
410  {
411  wxPoint start = line->GetStartPoint(), end = line->GetEndPoint();
412  if( start.y == end.y && collision != COLLIDE_OBJECTS )
413  collision = COLLIDE_H_WIRES;
414  else
415  collision = COLLIDE_OBJECTS;
416  }
417  else
418  collision = COLLIDE_OBJECTS;
419  }
420 
421  if( collision != COLLIDE_NONE )
422  colliding.push_back( { side, collision } );
423  }
424 
425  return colliding;
426  }
427 
428 
433  SIDE_AND_NPINS choose_side_filtered( std::vector<SIDE_AND_NPINS>& aSides,
434  const std::vector<SIDE_AND_COLL>& aCollidingSides, COLLISION aCollision,
435  SIDE_AND_NPINS aLastSelection)
436  {
437  SIDE_AND_NPINS sel = aLastSelection;
438 
439  std::vector<SIDE_AND_NPINS>::iterator it = aSides.begin();
440  while( it != aSides.end() )
441  {
442  bool collide = false;
443  for( SIDE_AND_COLL collision : aCollidingSides )
444  {
445  if( collision.side == it->side && collision.collision == aCollision )
446  collide = true;
447  }
448  if( !collide )
449  ++it;
450  else
451  {
452  if( it->pins <= sel.pins )
453  {
454  sel.pins = it->pins;
455  sel.side = it->side;
456  }
457  it = aSides.erase( it );
458  }
459  }
460  return sel;
461  }
462 
463 
469  SIDE choose_side_for_fields( bool aAvoidCollisions )
470  {
471  std::vector<SIDE_AND_NPINS> sides = get_preferred_sides();
472 
473  std::reverse( sides.begin(), sides.end() );
474  SIDE_AND_NPINS side = { wxPoint( 1, 0 ), UINT_MAX };
475 
476  if( aAvoidCollisions )
477  {
478  std::vector<SIDE_AND_COLL> colliding_sides = get_colliding_sides();
479  side = choose_side_filtered( sides, colliding_sides, COLLIDE_OBJECTS, side );
480  side = choose_side_filtered( sides, colliding_sides, COLLIDE_H_WIRES, side );
481  }
482 
483  for( SIDE_AND_NPINS& each_side : sides | boost::adaptors::reversed )
484  {
485  if( !each_side.pins ) return each_side.side;
486  }
487 
488  for( SIDE_AND_NPINS& each_side : sides )
489  {
490  if( each_side.pins <= side.pins )
491  {
492  side.pins = each_side.pins;
493  side.side = each_side.side;
494  }
495  }
496 
497  return side.side;
498  }
499 
500 
506  void justify_field( SCH_FIELD* aField, SIDE aFieldSide )
507  {
508  // Justification is set twice to allow IsHorizJustifyFlipped() to work correctly.
509  aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x ) );
510  aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x *
511  ( aField->IsHorizJustifyFlipped() ? -1 : 1 ) ) );
513  }
514 
515 
520  {
521  wxPoint fbox_center = m_comp_bbox.Centre();
522  int offs_x = ( m_comp_bbox.GetWidth() + m_fbox_size.GetWidth() ) / 2 + HPADDING;
523  int offs_y = ( m_comp_bbox.GetHeight() + m_fbox_size.GetHeight() ) / 2 + VPADDING;
524 
525  fbox_center.x += aFieldSide.x * offs_x;
526  fbox_center.y += aFieldSide.y * offs_y;
527 
528  wxPoint fbox_pos(
529  fbox_center.x - m_fbox_size.GetWidth() / 2,
530  fbox_center.y - m_fbox_size.GetHeight() / 2 );
531 
532  return fbox_pos;
533  }
534 
535 
541  {
542  if( aSide != SIDE_TOP && aSide != SIDE_BOTTOM )
543  return false;
544 
545  std::vector<SCH_ITEM*> colliders = filtered_colliders( *aBox );
546  if( colliders.empty() )
547  return false;
548 
549  // Find the offset of the wires for proper positioning
550  int offset = 0;
551 
552  for( SCH_ITEM* item : colliders )
553  {
554  SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
555  if( !line )
556  return false;
557  wxPoint start = line->GetStartPoint(), end = line->GetEndPoint();
558  if( start.y != end.y )
559  return false;
560 
561  int this_offset = (3 * WIRE_V_SPACING / 2) - ( start.y % WIRE_V_SPACING );
562  if( offset == 0 )
563  offset = this_offset;
564  else if( offset != this_offset )
565  return false;
566  }
567 
568  // At this point we are recomputing the field box size. Do not
569  // return false after this point.
570  m_fbox_size = ComputeFBoxSize( /* aDynamic */ false );
571 
572  wxPoint pos = aBox->GetPosition();
573 
574  // Remove the existing padding to get a bit more space to work with
575  if( aSide == SIDE_BOTTOM )
576  {
578  }
579  else
580  {
582  }
583 
584  pos.y = round_n( pos.y, WIRE_V_SPACING, aSide == SIDE_BOTTOM );
585 
586  aBox->SetOrigin( pos );
587  return true;
588  }
589 
590 
599  int field_horiz_placement( SCH_FIELD *aField, const EDA_RECT &aFieldBox )
600  {
601  int field_hjust;
602  int field_xcoord;
603 
604  if( aField->IsHorizJustifyFlipped() )
605  field_hjust = -aField->GetHorizJustify();
606  else
607  field_hjust = aField->GetHorizJustify();
608 
609  switch( field_hjust )
610  {
612  field_xcoord = aFieldBox.GetLeft();
613  break;
615  field_xcoord = aFieldBox.Centre().x;
616  break;
618  field_xcoord = aFieldBox.GetRight();
619  break;
620  default:
621  wxFAIL_MSG( "Unexpected value for SCH_FIELD::GetHorizJustify()" );
622  field_xcoord = aFieldBox.Centre().x; // Most are centered
623  }
624 
625  return field_xcoord;
626  }
627 
639  int field_vert_placement( SCH_FIELD *aField, const EDA_RECT &aFieldBox, int *aPosAccum,
640  bool aDynamic )
641  {
642  int field_height;
643  int padding;
644 
645  if( aDynamic )
646  {
647  field_height = aField->GetBoundingBox().GetHeight();
648 
649  padding = get_field_padding();
650  }
651  else
652  {
653  field_height = WIRE_V_SPACING / 2;
654  padding = WIRE_V_SPACING / 2;
655  }
656 
657  int placement = *aPosAccum + padding / 2 + field_height / 2;
658 
659  *aPosAccum += padding + field_height;
660 
661  return placement;
662  }
663 
668  {
669  if( m_align_to_grid )
670  return FIELD_PADDING_ALIGNED;
671  else
672  return FIELD_PADDING;
673  }
674 
675 };
676 
681 
682 
683 void SCH_COMPONENT::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
684 {
685  if( aManual )
686  wxASSERT_MSG( aScreen, "A SCH_SCREEN pointer must be given for manual autoplacement" );
687 
688  AUTOPLACER autoplacer( this, aScreen );
689  autoplacer.DoAutoplace( aManual );
691 }
#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:47
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:94
#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:1232
#define HPADDING
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:193
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:198
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:202
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:160
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:37
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_field.cpp:234
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:201
static const SIDE SIDE_BOTTOM
int get_field_padding()
Return the desired padding between fields.
EE_RTREE & Items()
Definition: sch_screen.h:162
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.
Schematic symbol object.
Definition: sch_component.h:88
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:276
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
Set the schematic item position to aPosition.
Definition: sch_field.cpp:558
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:186
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:97