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-2021 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. ::chooseSideForFields
35  * 1. Sort the four sides in preference order,
36  * depending on the component's shape and
37  * orientation ::getPreferredSides
38  * 2. If in manual mode, sift out the sides that would
39  * cause fields to overlap other items ::getCollidingSides
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 ::fieldBoxPlacement
46  * 4. In manual mode, shift the box vertically if possible
47  * to fit fields between adjacent wires ::fitFieldsBetweenWires
48  * 5. Move all fields to their final positions
49  * 1. Re-justify fields if options allow that ::justifyField
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_symbol.h>
58 #include <sch_line.h>
59 #include <lib_pin.h>
60 #include <sch_draw_panel.h>
61 #include <kiface_i.h>
62 #include <vector>
63 #include <algorithm>
64 #include <tool/tool_manager.h>
66 #include <eeschema_settings.h>
67 #include <core/arraydim.h>
68 
69 #define FIELD_PADDING Mils2iu( 10 ) // arbitrarily chosen for aesthetics
70 #define WIRE_V_SPACING Mils2iu( 100 )
71 #define HPADDING Mils2iu( 25 )
72 #define VPADDING Mils2iu( 25 )
73 
77 template<typename T> T round_n( const T& value, const T& n, bool aRoundUp )
78 {
79  if( value % n )
80  return n * (value / n + (aRoundUp ? 1 : 0));
81  else
82  return value;
83 }
84 
85 
90 {
91  return static_cast<EDA_TEXT_HJUSTIFY_T>( x );
92 }
93 
94 
96 {
97 public:
98  typedef wxPoint SIDE;
101 
103  {
105  unsigned pins;
106  };
107 
109  {
112  };
113 
114  AUTOPLACER( SCH_COMPONENT* aSymbol, SCH_SCREEN* aScreen ) :
115  m_screen( aScreen ),
116  m_symbol( aSymbol )
117  {
118  m_symbol->GetFields( m_fields, /* aVisibleOnly */ true );
119 
120  auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
121  wxASSERT( cfg );
122 
123  m_allow_rejustify = false;
124  m_align_to_grid = true;
125 
126  if( cfg )
127  {
128  m_allow_rejustify = cfg->m_AutoplaceFields.allow_rejustify;
129  m_align_to_grid = cfg->m_AutoplaceFields.align_to_grid;
130  }
131 
133  m_fbox_size = computeFBoxSize( /* aDynamic */ true );
134 
136 
137  if( aScreen )
139  }
140 
146  void DoAutoplace( bool aManual )
147  {
148  bool force_wire_spacing = false;
149  SIDE field_side = chooseSideForFields( aManual );
150  wxPoint fbox_pos = fieldBoxPlacement( field_side );
151  EDA_RECT field_box( fbox_pos, m_fbox_size );
152 
153  if( aManual )
154  force_wire_spacing = fitFieldsBetweenWires( &field_box, field_side );
155 
156  // Move the fields
157  int last_y_coord = field_box.GetTop();
158 
159  for( unsigned field_idx = 0; field_idx < m_fields.size(); ++field_idx )
160  {
161  SCH_FIELD* field = m_fields[field_idx];
162 
163  if( m_allow_rejustify )
164  justifyField( field, field_side );
165 
166  wxPoint pos( fieldHorizPlacement( field, field_box ),
167  fieldVertPlacement( field, field_box, &last_y_coord, !force_wire_spacing ) );
168 
169  if( m_align_to_grid )
170  {
171  pos.x = round_n( pos.x, Mils2iu( 50 ), field_side.x >= 0 );
172  pos.y = round_n( pos.y, Mils2iu( 50 ), field_side.y >= 0 );
173  }
174 
175  field->SetPosition( pos );
176  }
177  }
178 
179 protected:
184  wxSize computeFBoxSize( bool aDynamic )
185  {
186  int max_field_width = 0;
187  int total_height = 0;
188 
189  for( SCH_FIELD* field : m_fields )
190  {
191  int field_width;
192  int field_height;
193 
194  if( m_symbol->GetTransform().y1 )
195  field->SetTextAngle( TEXT_ANGLE_VERT );
196  else
197  field->SetTextAngle( TEXT_ANGLE_HORIZ );
198 
199  field_width = field->GetBoundingBox().GetWidth();
200  field_height = field->GetBoundingBox().GetHeight();
201 
202  max_field_width = std::max( max_field_width, field_width );
203 
204  if( !aDynamic )
205  total_height += WIRE_V_SPACING;
206  else if( m_align_to_grid )
207  total_height += round_n( field_height, Mils2iu( 50 ), true );
208  else
209  total_height += field_height + FIELD_PADDING;
210  }
211 
212  return wxSize( max_field_width, total_height );
213  }
214 
219  {
220  int pin_orient = aPin->GetLibPin()->PinDrawOrient( m_symbol->GetTransform() );
221 
222  switch( pin_orient )
223  {
224  case PIN_RIGHT: return SIDE_LEFT;
225  case PIN_LEFT: return SIDE_RIGHT;
226  case PIN_UP: return SIDE_BOTTOM;
227  case PIN_DOWN: return SIDE_TOP;
228  default:
229  wxFAIL_MSG( "Invalid pin orientation" );
230  return SIDE_LEFT;
231  }
232  }
233 
237  unsigned pinsOnSide( SIDE aSide )
238  {
239  unsigned pin_count = 0;
240 
241  for( SCH_PIN* each_pin : m_symbol->GetPins() )
242  {
243  if( !each_pin->IsVisible() && !m_is_power_symbol )
244  continue;
245 
246  if( getPinSide( each_pin ) == aSide )
247  ++pin_count;
248  }
249 
250  return pin_count;
251  }
252 
258  void getPossibleCollisions( std::vector<SCH_ITEM*>& aItems )
259  {
260  wxCHECK_RET( m_screen, "getPossibleCollisions() with null m_screen" );
261 
262  for( SCH_ITEM* item : m_screen->Items().Overlapping( m_symbol->GetBoundingBox() ) )
263  {
264  if( SCH_COMPONENT* candidate = dynamic_cast<SCH_COMPONENT*>( item ) )
265  {
266  if( candidate == m_symbol )
267  continue;
268 
269  std::vector<SCH_FIELD*> fields;
270  candidate->GetFields( fields, /* aVisibleOnly */ true );
271 
272  for( SCH_FIELD* field : fields )
273  aItems.push_back( field );
274  }
275 
276  aItems.push_back( item );
277  }
278  }
279 
284  std::vector<SCH_ITEM*> filterCollisions( const EDA_RECT& aRect )
285  {
286  std::vector<SCH_ITEM*> filtered;
287 
288  for( SCH_ITEM* item : m_colliders )
289  {
290  EDA_RECT item_box;
291 
292  if( SCH_COMPONENT* item_comp = dynamic_cast<SCH_COMPONENT*>( item ) )
293  item_box = item_comp->GetBodyBoundingBox();
294  else
295  item_box = item->GetBoundingBox();
296 
297  if( item_box.Intersects( aRect ) )
298  filtered.push_back( item );
299  }
300  return filtered;
301  }
302 
307  std::vector<SIDE_AND_NPINS> getPreferredSides()
308  {
309  SIDE_AND_NPINS sides_init[] = {
311  { SIDE_TOP, pinsOnSide( SIDE_TOP ) },
314  };
315  std::vector<SIDE_AND_NPINS> sides( sides_init, sides_init + arrayDim( sides_init ) );
316 
317  int orient = m_symbol->GetOrientation();
318  int orient_angle = orient & 0xff; // enum is a bitmask
319  bool h_mirrored = ( ( orient & CMP_MIRROR_X )
320  && ( orient_angle == CMP_ORIENT_0 || orient_angle == CMP_ORIENT_180 ) );
321  double w = double( m_symbol_bbox.GetWidth() );
322  double h = double( m_symbol_bbox.GetHeight() );
323 
324  // The preferred-sides heuristics are a bit magical. These were determined mostly
325  // by trial and error.
326 
327  if( m_is_power_symbol )
328  {
329  // For power symbols, we generally want the label at the top first.
330  switch( orient_angle )
331  {
332  case CMP_ORIENT_0:
333  std::swap( sides[0], sides[1] );
334  std::swap( sides[1], sides[3] );
335  // TOP, BOTTOM, RIGHT, LEFT
336  break;
337  case CMP_ORIENT_90:
338  std::swap( sides[0], sides[2] );
339  std::swap( sides[1], sides[2] );
340  // LEFT, RIGHT, TOP, BOTTOM
341  break;
342  case CMP_ORIENT_180:
343  std::swap( sides[0], sides[3] );
344  // BOTTOM, TOP, LEFT, RIGHT
345  break;
346  case CMP_ORIENT_270:
347  std::swap( sides[1], sides[2] );
348  // RIGHT, LEFT, TOP, BOTTOM
349  break;
350  }
351  }
352  else
353  {
354  // If the component is horizontally mirrored, swap left and right
355  if( h_mirrored )
356  {
357  std::swap( sides[0], sides[2] );
358  }
359 
360  // If the component is very long or is a power symbol, swap H and V
361  if( w/h > 3.0 )
362  {
363  std::swap( sides[0], sides[1] );
364  std::swap( sides[1], sides[3] );
365  }
366  }
367 
368  return sides;
369  }
370 
374  std::vector<SIDE_AND_COLL> getCollidingSides()
375  {
376  SIDE sides_init[] = { SIDE_RIGHT, SIDE_TOP, SIDE_LEFT, SIDE_BOTTOM };
377  std::vector<SIDE> sides( sides_init, sides_init + arrayDim( sides_init ) );
378  std::vector<SIDE_AND_COLL> colliding;
379 
380  // Iterate over all sides and find the ones that collide
381  for( SIDE side : sides )
382  {
383  EDA_RECT box( fieldBoxPlacement( side ), m_fbox_size );
384 
385  COLLISION collision = COLLIDE_NONE;
386 
387  for( SCH_ITEM* collider : filterCollisions( box ) )
388  {
389  SCH_LINE* line = dynamic_cast<SCH_LINE*>( collider );
390 
391  if( line && !side.x )
392  {
393  wxPoint start = line->GetStartPoint(), end = line->GetEndPoint();
394 
395  if( start.y == end.y && collision != COLLIDE_OBJECTS )
396  collision = COLLIDE_H_WIRES;
397  else
398  collision = COLLIDE_OBJECTS;
399  }
400  else
401  {
402  collision = COLLIDE_OBJECTS;
403  }
404  }
405 
406  if( collision != COLLIDE_NONE )
407  colliding.push_back( { side, collision } );
408  }
409 
410  return colliding;
411  }
412 
417  SIDE_AND_NPINS chooseSideFiltered( std::vector<SIDE_AND_NPINS>& aSides,
418  const std::vector<SIDE_AND_COLL>& aCollidingSides,
419  COLLISION aCollision,
420  SIDE_AND_NPINS aLastSelection)
421  {
422  SIDE_AND_NPINS sel = aLastSelection;
423 
424  std::vector<SIDE_AND_NPINS>::iterator it = aSides.begin();
425 
426  while( it != aSides.end() )
427  {
428  bool collide = false;
429 
430  for( SIDE_AND_COLL collision : aCollidingSides )
431  {
432  if( collision.side == it->side && collision.collision == aCollision )
433  collide = true;
434  }
435 
436  if( !collide )
437  {
438  ++it;
439  }
440  else
441  {
442  if( it->pins <= sel.pins )
443  {
444  sel.pins = it->pins;
445  sel.side = it->side;
446  }
447 
448  it = aSides.erase( it );
449  }
450  }
451 
452  return sel;
453  }
454 
460  SIDE chooseSideForFields( bool aAvoidCollisions )
461  {
462  std::vector<SIDE_AND_NPINS> sides = getPreferredSides();
463 
464  std::reverse( sides.begin(), sides.end() );
465  SIDE_AND_NPINS side = { wxPoint( 1, 0 ), UINT_MAX };
466 
467  if( aAvoidCollisions )
468  {
469  std::vector<SIDE_AND_COLL> colliding_sides = getCollidingSides();
470  side = chooseSideFiltered( sides, colliding_sides, COLLIDE_OBJECTS, side );
471  side = chooseSideFiltered( sides, colliding_sides, COLLIDE_H_WIRES, side );
472  }
473 
474  for( SIDE_AND_NPINS& each_side : sides | boost::adaptors::reversed )
475  {
476  if( !each_side.pins ) return each_side.side;
477  }
478 
479  for( SIDE_AND_NPINS& each_side : sides )
480  {
481  if( each_side.pins <= side.pins )
482  {
483  side.pins = each_side.pins;
484  side.side = each_side.side;
485  }
486  }
487 
488  return side.side;
489  }
490 
496  void justifyField( SCH_FIELD* aField, SIDE aFieldSide )
497  {
498  // Justification is set twice to allow IsHorizJustifyFlipped() to work correctly.
499  aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x ) );
500  aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x
501  * ( aField->IsHorizJustifyFlipped() ? -1 : 1 ) ) );
503  }
504 
508  wxPoint fieldBoxPlacement( SIDE aFieldSide )
509  {
510  wxPoint fbox_center = m_symbol_bbox.Centre();
511  int offs_x = ( m_symbol_bbox.GetWidth() + m_fbox_size.GetWidth() ) / 2;
512  int offs_y = ( m_symbol_bbox.GetHeight() + m_fbox_size.GetHeight() ) / 2;
513 
514  if( aFieldSide.x != 0 )
515  offs_x += HPADDING;
516  else if( aFieldSide.y != 0 )
517  offs_y += VPADDING;
518 
519  fbox_center.x += aFieldSide.x * offs_x;
520  fbox_center.y += aFieldSide.y * offs_y;
521 
522  wxPoint fbox_pos( fbox_center.x - m_fbox_size.GetWidth() / 2,
523  fbox_center.y - m_fbox_size.GetHeight() / 2 );
524 
525  return fbox_pos;
526  }
527 
532  bool fitFieldsBetweenWires( EDA_RECT* aBox, SIDE aSide )
533  {
534  if( aSide != SIDE_TOP && aSide != SIDE_BOTTOM )
535  return false;
536 
537  std::vector<SCH_ITEM*> colliders = filterCollisions( *aBox );
538 
539  if( colliders.empty() )
540  return false;
541 
542  // Find the offset of the wires for proper positioning
543  int offset = 0;
544 
545  for( SCH_ITEM* item : colliders )
546  {
547  SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
548 
549  if( !line )
550  return false;
551 
552  wxPoint start = line->GetStartPoint(), end = line->GetEndPoint();
553 
554  if( start.y != end.y )
555  return false;
556 
557  int this_offset = (3 * WIRE_V_SPACING / 2) - ( start.y % WIRE_V_SPACING );
558 
559  if( offset == 0 )
560  offset = this_offset;
561  else if( offset != this_offset )
562  return false;
563  }
564 
565  // At this point we are recomputing the field box size. Do not
566  // return false after this point.
567  m_fbox_size = computeFBoxSize( /* aDynamic */ false );
568 
569  wxPoint pos = aBox->GetPosition();
570 
571  pos.y = round_n( pos.y, WIRE_V_SPACING, aSide == SIDE_BOTTOM );
572 
573  aBox->SetOrigin( pos );
574  return true;
575  }
576 
585  int fieldHorizPlacement( SCH_FIELD *aField, const EDA_RECT &aFieldBox )
586  {
587  int field_hjust;
588  int field_xcoord;
589 
590  if( aField->IsHorizJustifyFlipped() )
591  field_hjust = -aField->GetHorizJustify();
592  else
593  field_hjust = aField->GetHorizJustify();
594 
595  switch( field_hjust )
596  {
598  field_xcoord = aFieldBox.GetLeft();
599  break;
601  field_xcoord = aFieldBox.Centre().x;
602  break;
604  field_xcoord = aFieldBox.GetRight();
605  break;
606  default:
607  wxFAIL_MSG( "Unexpected value for SCH_FIELD::GetHorizJustify()" );
608  field_xcoord = aFieldBox.Centre().x; // Most are centered
609  }
610 
611  return field_xcoord;
612  }
613 
625  int fieldVertPlacement( SCH_FIELD *aField, const EDA_RECT &aFieldBox, int *aPosAccum,
626  bool aDynamic )
627  {
628  int field_height;
629  int padding;
630 
631  if( !aDynamic )
632  {
633  field_height = WIRE_V_SPACING / 2;
634  padding = WIRE_V_SPACING / 2;
635  }
636  else if( m_align_to_grid )
637  {
638  field_height = aField->GetBoundingBox().GetHeight();
639  padding = round_n( field_height, Mils2iu( 50 ), true ) - field_height;
640  }
641  else
642  {
643  field_height = aField->GetBoundingBox().GetHeight();
644  padding = FIELD_PADDING;
645  }
646 
647  int placement = *aPosAccum + padding / 2 + field_height / 2;
648 
649  *aPosAccum += padding + field_height;
650 
651  return placement;
652  }
653 
654 private:
657  std::vector<SCH_FIELD*> m_fields;
658  std::vector<SCH_ITEM*> m_colliders;
660  wxSize m_fbox_size;
664 };
665 
666 
671 
672 
673 void SCH_COMPONENT::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
674 {
675  if( aManual )
676  wxASSERT_MSG( aScreen, "A SCH_SCREEN pointer must be given for manual autoplacement" );
677 
678  AUTOPLACER autoplacer( this, aScreen );
679  autoplacer.DoAutoplace( aManual );
681 }
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: eda_text.h:50
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
LIB_PIN * GetLibPin() const
Definition: sch_pin.h:69
std::vector< SCH_FIELD * > m_fields
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:61
std::vector< SIDE_AND_NPINS > getPreferredSides()
Return a list with the preferred field sides for the component, in decreasing order of preference.
int GetOrientation()
Get the display symbol orientation.
wxPoint GetStartPoint() const
Definition: sch_line.h:94
bool collide(T aObject, U aAnotherObject, int aMinDistance)
collide template method
Definition: shape_index.h:92
int GetTop() const
Definition: eda_rect.h:118
bool fitFieldsBetweenWires(EDA_RECT *aBox, SIDE aSide)
Shift a field box up or down a bit to make the fields fit between some wires.
int GetLeft() const
Definition: eda_rect.h:117
#define WIRE_V_SPACING
EE_TYPE Overlapping(const EDA_RECT &aRect)
Definition: sch_rtree.h:224
#define VPADDING
int GetWidth() const
Definition: eda_rect.h:114
bool IsInNetlist() const
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:126
Definition: lib_pin.h:50
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:791
wxPoint fieldBoxPlacement(SIDE aFieldSide)
Return the position of the field bounding box.
SIDE getPinSide(SCH_PIN *aPin)
Return the side that a pin is on.
#define HPADDING
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:203
int fieldHorizPlacement(SCH_FIELD *aField, const EDA_RECT &aFieldBox)
Place a field horizontally, taking into account the field width and justification.
std::vector< SCH_ITEM * > filterCollisions(const EDA_RECT &aRect)
Filter a list of possible colliders to include only those that actually collide with a given rectangl...
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:724
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
int y1
Definition: transform.h:49
static const SIDE SIDE_LEFT
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:205
std::vector< SCH_ITEM * > m_colliders
EDA_RECT GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the fields.
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:209
const wxPoint GetPosition() const
Definition: eda_rect.h:107
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
wxSize computeFBoxSize(bool aDynamic)
Compute and return the size of the fields' bounding box.
AUTOPLACER(SCH_COMPONENT *aSymbol, SCH_SCREEN *aScreen)
int GetRight() const
Definition: eda_rect.h:116
int fieldVertPlacement(SCH_FIELD *aField, const EDA_RECT &aFieldBox, int *aPosAccum, bool aDynamic)
Place a field vertically.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
unsigned pinsOnSide(SIDE aSide)
Count the number of pins on a side of the component.
TRANSFORM & GetTransform()
Definition: sch_symbol.h:273
int GetHeight() const
Definition: eda_rect.h:115
SCH_COMPONENT * m_symbol
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieves a list of the SCH_PINs for the given sheet path.
Definition: sch_symbol.cpp:863
static const SIDE SIDE_RIGHT
T round_n(const T &value, const T &n, bool aRoundUp)
Round up/down to the nearest multiple of n.
SIDE chooseSideForFields(bool aAvoidCollisions)
Look where a component's pins are to pick a side to put the fields on.
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
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:262
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:208
static const SIDE SIDE_BOTTOM
EE_RTREE & Items()
Definition: sch_screen.h:162
Handle the component boundary box.
Definition: eda_rect.h:42
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the component.
Schematic symbol object.
Definition: sch_symbol.h:79
std::vector< SIDE_AND_COLL > getCollidingSides()
Return a list of the sides where a field set would collide with another item.
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:304
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Definition: eda_rect.cpp:150
#define FIELD_PADDING
void DoAutoplace(bool aManual)
Do the actual autoplacement.
#define TEXT_ANGLE_VERT
Definition: eda_text.h:51
static const SIDE SIDE_TOP
void SetPosition(const wxPoint &aPosition) override
Definition: sch_field.cpp:650
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:196
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.
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 whethe...
void getPossibleCollisions(std::vector< SCH_ITEM * > &aItems)
Populate a list of all drawing items that may collide with the fields.
wxPoint GetEndPoint() const
Definition: sch_line.h:97