KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <[email protected]>
5 * Copyright (C) 2015, 2020-2023 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 symbol fields, and places them there.
27 * There are two modes: "auto"-autoplace, and "manual" autoplace.
28 * Auto mode is for when the process is run automatically, like when rotating parts, and it
29 * avoids doing things that would be helpful for the final positioning but annoying if they
30 * 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 symbol'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 <kiface_base.h>
61#include <algorithm>
62#include <tool/tool_manager.h>
64#include <eeschema_settings.h>
65#include <core/arraydim.h>
66
67#define FIELD_PADDING schIUScale.MilsToIU( 15 ) // arbitrarily chosen for aesthetics
68#define WIRE_V_SPACING schIUScale.MilsToIU( 100 )
69#define HPADDING schIUScale.MilsToIU( 25 ) // arbitrarily chosen for aesthetics
70#define VPADDING schIUScale.MilsToIU( 15 ) // arbitrarily chosen for aesthetics
71
75template<typename T> T round_n( const T& value, const T& n, bool aRoundUp )
76{
77 if( value % n )
78 return n * (value / n + (aRoundUp ? 1 : 0));
79 else
80 return value;
81}
82
83
85{
86public:
87 typedef VECTOR2I SIDE;
90
92 {
94 unsigned pins;
95 };
96
98 {
101 };
102
103 AUTOPLACER( SCH_SYMBOL* aSymbol, SCH_SCREEN* aScreen ) :
104 m_screen( aScreen ),
105 m_symbol( aSymbol )
106 {
107 m_symbol->GetFields( m_fields, /* aVisibleOnly */ true );
108
109 auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
110 wxASSERT( cfg );
111
112 m_allow_rejustify = false;
113 m_align_to_grid = true;
114
115 if( cfg )
116 {
117 m_allow_rejustify = cfg->m_AutoplaceFields.allow_rejustify;
118 m_align_to_grid = cfg->m_AutoplaceFields.align_to_grid;
119 }
120
122 m_fbox_size = computeFBoxSize( /* aDynamic */ true );
123
125
126 if( aScreen )
128 }
129
135 void DoAutoplace( bool aManual )
136 {
137 bool forceWireSpacing = false;
138 SIDE_AND_NPINS sideandpins = chooseSideForFields( aManual );
139 SIDE field_side = sideandpins.side;
140 VECTOR2I fbox_pos = fieldBoxPlacement( sideandpins );
141 BOX2I field_box( fbox_pos, m_fbox_size );
142
143 if( aManual )
144 forceWireSpacing = fitFieldsBetweenWires( &field_box, field_side );
145
146 // Move the fields
147 int last_y_coord = field_box.GetTop();
148
149 for( unsigned field_idx = 0; field_idx < m_fields.size(); ++field_idx )
150 {
151 SCH_FIELD* field = m_fields[field_idx];
152
153 if( !field->IsVisible() || !field->CanAutoplace() )
154 continue;
155
157 {
158 if( sideandpins.pins > 0 )
159 {
160 if( field_side == SIDE_TOP || field_side == SIDE_BOTTOM )
161 justifyField( field, SIDE_RIGHT );
162 else
163 justifyField( field, SIDE_TOP );
164 }
165 else
166 {
167 justifyField( field, field_side );
168 }
169 }
170
171 VECTOR2I pos( fieldHPlacement( field, field_box ),
172 fieldVPlacement( field, field_box, &last_y_coord, !forceWireSpacing ) );
173
174 if( m_align_to_grid )
175 {
176 if( abs( field_side.x ) > 0 )
177 pos.x = round_n( pos.x, schIUScale.MilsToIU( 50 ), field_side.x >= 0 );
178
179 if( abs( field_side.y ) > 0 )
180 pos.y = round_n( pos.y, schIUScale.MilsToIU( 50 ), field_side.y >= 0 );
181 }
182
183 field->SetPosition( pos );
184 }
185 }
186
187protected:
192 VECTOR2I computeFBoxSize( bool aDynamic )
193 {
194 int max_field_width = 0;
195 int total_height = 0;
196
197 std::vector<SCH_FIELD*> visibleFields;
198
199 for( SCH_FIELD* field : m_fields )
200 {
201 if( field->IsVisible() )
202 visibleFields.push_back( field );
203 }
204
205 for( SCH_FIELD* field : visibleFields )
206 {
207 if( field->CanAutoplace() )
208 {
209 if( m_symbol->GetTransform().y1 )
210 field->SetTextAngle( ANGLE_VERTICAL );
211 else
212 field->SetTextAngle( ANGLE_HORIZONTAL );
213 }
214
215 BOX2I bbox = field->GetBoundingBox();
216 int field_width = bbox.GetWidth();
217 int field_height = bbox.GetHeight();
218
219 max_field_width = std::max( max_field_width, field_width );
220
221 if( !aDynamic )
222 total_height += WIRE_V_SPACING;
223 else if( m_align_to_grid )
224 total_height += round_n( field_height, schIUScale.MilsToIU( 50 ), true );
225 else
226 total_height += field_height + FIELD_PADDING;
227 }
228
229 return VECTOR2I( max_field_width, total_height );
230 }
231
236 {
237 PIN_ORIENTATION pin_orient = aPin->GetLibPin()->PinDrawOrient( m_symbol->GetTransform() );
238
239 switch( pin_orient )
240 {
241 case PIN_ORIENTATION::PIN_RIGHT: return SIDE_LEFT;
242 case PIN_ORIENTATION::PIN_LEFT: return SIDE_RIGHT;
243 case PIN_ORIENTATION::PIN_UP: return SIDE_BOTTOM;
244 case PIN_ORIENTATION::PIN_DOWN: return SIDE_TOP;
245 default:
246 wxFAIL_MSG( wxS( "Invalid pin orientation" ) );
247 return SIDE_LEFT;
248 }
249 }
250
254 unsigned pinsOnSide( SIDE aSide )
255 {
256 unsigned pin_count = 0;
257
258 for( SCH_PIN* each_pin : m_symbol->GetPins() )
259 {
260 if( !each_pin->IsVisible() && !m_is_power_symbol )
261 continue;
262
263 if( getPinSide( each_pin ) == aSide )
264 ++pin_count;
265 }
266
267 return pin_count;
268 }
269
274 void getPossibleCollisions( std::vector<SCH_ITEM*>& aItems )
275 {
276 wxCHECK_RET( m_screen, wxS( "getPossibleCollisions() with null m_screen" ) );
277
279 std::vector<SIDE_AND_NPINS> sides = getPreferredSides();
280
281 for( SIDE_AND_NPINS& side : sides )
282 {
283 BOX2I box( fieldBoxPlacement( side ), m_fbox_size );
284 box.Merge( symbolBox );
285
286 for( SCH_ITEM* item : m_screen->Items().Overlapping( box ) )
287 {
288 if( SCH_SYMBOL* candidate = dynamic_cast<SCH_SYMBOL*>( item ) )
289 {
290 if( candidate == m_symbol )
291 continue;
292
293 std::vector<SCH_FIELD*> fields;
294 candidate->GetFields( fields, /* aVisibleOnly */ true );
295
296 for( SCH_FIELD* field : fields )
297 aItems.push_back( field );
298 }
299
300 aItems.push_back( item );
301 }
302 }
303 }
304
309 std::vector<SCH_ITEM*> filterCollisions( const BOX2I& aRect )
310 {
311 std::vector<SCH_ITEM*> filtered;
312
313 for( SCH_ITEM* item : m_colliders )
314 {
315 BOX2I item_box;
316
317 if( SCH_SYMBOL* item_comp = dynamic_cast<SCH_SYMBOL*>( item ) )
318 item_box = item_comp->GetBodyAndPinsBoundingBox();
319 else
320 item_box = item->GetBoundingBox();
321
322 if( item_box.Intersects( aRect ) )
323 filtered.push_back( item );
324 }
325
326 return filtered;
327 }
328
333 std::vector<SIDE_AND_NPINS> getPreferredSides()
334 {
335 SIDE_AND_NPINS sides_init[] = {
340 };
341 std::vector<SIDE_AND_NPINS> sides( sides_init, sides_init + arrayDim( sides_init ) );
342
343 int orient = m_symbol->GetOrientation();
344 int orient_angle = orient & 0xff; // enum is a bitmask
345 bool h_mirrored = ( ( orient & SYM_MIRROR_X )
346 && ( orient_angle == SYM_ORIENT_0 || orient_angle == SYM_ORIENT_180 ) );
347 double w = double( m_symbol_bbox.GetWidth() );
348 double h = double( m_symbol_bbox.GetHeight() );
349
350 // The preferred-sides heuristics are a bit magical. These were determined mostly
351 // by trial and error.
352
354 {
355 // For power symbols, we generally want the label at the top first.
356 switch( orient_angle )
357 {
358 case SYM_ORIENT_0:
359 std::swap( sides[0], sides[1] );
360 std::swap( sides[1], sides[3] );
361 // TOP, BOTTOM, RIGHT, LEFT
362 break;
363 case SYM_ORIENT_90:
364 std::swap( sides[0], sides[2] );
365 std::swap( sides[1], sides[2] );
366 // LEFT, RIGHT, TOP, BOTTOM
367 break;
368 case SYM_ORIENT_180:
369 std::swap( sides[0], sides[3] );
370 // BOTTOM, TOP, LEFT, RIGHT
371 break;
372 case SYM_ORIENT_270:
373 std::swap( sides[1], sides[2] );
374 // RIGHT, LEFT, TOP, BOTTOM
375 break;
376 }
377 }
378 else
379 {
380 // If the symbol is horizontally mirrored, swap left and right
381 if( h_mirrored )
382 {
383 std::swap( sides[0], sides[2] );
384 }
385
386 // If the symbol is very long or is a power symbol, swap H and V
387 if( w/h > 3.0 )
388 {
389 std::swap( sides[0], sides[1] );
390 std::swap( sides[1], sides[3] );
391 }
392 }
393
394 return sides;
395 }
396
400 std::vector<SIDE_AND_COLL> getCollidingSides()
401 {
402 SIDE sides_init[] = { SIDE_RIGHT, SIDE_TOP, SIDE_LEFT, SIDE_BOTTOM };
403 std::vector<SIDE> sides( sides_init, sides_init + arrayDim( sides_init ) );
404 std::vector<SIDE_AND_COLL> colliding;
405
406 // Iterate over all sides and find the ones that collide
407 for( SIDE side : sides )
408 {
409 SIDE_AND_NPINS sideandpins;
410 sideandpins.side = side;
411 sideandpins.pins = pinsOnSide( side );
412
413 BOX2I box( fieldBoxPlacement( sideandpins ), m_fbox_size );
414
415 COLLISION collision = COLLIDE_NONE;
416
417 for( SCH_ITEM* collider : filterCollisions( box ) )
418 {
419 SCH_LINE* line = dynamic_cast<SCH_LINE*>( collider );
420
421 if( line && !side.x )
422 {
423 VECTOR2I start = line->GetStartPoint(), end = line->GetEndPoint();
424
425 if( start.y == end.y && collision != COLLIDE_OBJECTS )
426 collision = COLLIDE_H_WIRES;
427 else
428 collision = COLLIDE_OBJECTS;
429 }
430 else
431 {
432 collision = COLLIDE_OBJECTS;
433 }
434 }
435
436 if( collision != COLLIDE_NONE )
437 colliding.push_back( { side, collision } );
438 }
439
440 return colliding;
441 }
442
447 SIDE_AND_NPINS chooseSideFiltered( std::vector<SIDE_AND_NPINS>& aSides,
448 const std::vector<SIDE_AND_COLL>& aCollidingSides,
449 COLLISION aCollision,
450 SIDE_AND_NPINS aLastSelection)
451 {
452 SIDE_AND_NPINS sel = aLastSelection;
453
454 std::vector<SIDE_AND_NPINS>::iterator it = aSides.begin();
455
456 while( it != aSides.end() )
457 {
458 bool collide = false;
459
460 for( SIDE_AND_COLL collision : aCollidingSides )
461 {
462 if( collision.side == it->side && collision.collision == aCollision )
463 collide = true;
464 }
465
466 if( !collide )
467 {
468 ++it;
469 }
470 else
471 {
472 if( it->pins <= sel.pins )
473 {
474 sel.pins = it->pins;
475 sel.side = it->side;
476 }
477
478 it = aSides.erase( it );
479 }
480 }
481
482 return sel;
483 }
484
490 SIDE_AND_NPINS chooseSideForFields( bool aAvoidCollisions )
491 {
492 std::vector<SIDE_AND_NPINS> sides = getPreferredSides();
493
494 std::reverse( sides.begin(), sides.end() );
495 SIDE_AND_NPINS side = { VECTOR2I( 1, 0 ), UINT_MAX };
496
497 if( aAvoidCollisions )
498 {
499 std::vector<SIDE_AND_COLL> colliding_sides = getCollidingSides();
500 side = chooseSideFiltered( sides, colliding_sides, COLLIDE_OBJECTS, side );
501 side = chooseSideFiltered( sides, colliding_sides, COLLIDE_H_WIRES, side );
502 }
503
504 for( SIDE_AND_NPINS& each_side : sides | boost::adaptors::reversed )
505 {
506 if( !each_side.pins ) return each_side;
507 }
508
509 for( SIDE_AND_NPINS& each_side : sides )
510 {
511 if( each_side.pins <= side.pins )
512 {
513 side.pins = each_side.pins;
514 side.side = each_side.side;
515 }
516 }
517
518 return side;
519 }
520
526 void justifyField( SCH_FIELD* aField, SIDE aFieldSide )
527 {
528 // Justification is set twice to allow IsHorizJustifyFlipped() to work correctly.
529 aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x ) );
530 aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x
531 * ( aField->IsHorizJustifyFlipped() ? -1 : 1 ) ) );
533 }
534
539 {
540 VECTOR2I fbox_center = m_symbol_bbox.Centre();
541 int offs_x = ( m_symbol_bbox.GetWidth() + m_fbox_size.x ) / 2;
542 int offs_y = ( m_symbol_bbox.GetHeight() + m_fbox_size.y ) / 2;
543
544 if( aFieldSideAndPins.side.x != 0 )
545 offs_x += HPADDING;
546 else if( aFieldSideAndPins.side.y != 0 )
547 offs_y += VPADDING;
548
549 fbox_center.x += aFieldSideAndPins.side.x * offs_x;
550 fbox_center.y += aFieldSideAndPins.side.y * offs_y;
551
552 int x = fbox_center.x - ( m_fbox_size.x / 2 );
553 int y = fbox_center.y - ( m_fbox_size.y / 2 );
554
555 auto getPinsBox =
556 [&]( const VECTOR2I& aSide )
557 {
558 BOX2I pinsBox;
559
560 for( SCH_PIN* each_pin : m_symbol->GetPins() )
561 {
562 if( !each_pin->IsVisible() && !m_is_power_symbol )
563 continue;
564
565 if( getPinSide( each_pin ) == aSide )
566 pinsBox.Merge( each_pin->GetBoundingBox() );
567 }
568
569 return pinsBox;
570 };
571
572 if( aFieldSideAndPins.pins > 0 )
573 {
574 BOX2I pinsBox = getPinsBox( aFieldSideAndPins.side );
575
576 if( aFieldSideAndPins.side == SIDE_TOP || aFieldSideAndPins.side == SIDE_BOTTOM )
577 {
578 x = pinsBox.GetRight() + ( HPADDING * 2 );
579 }
580 else if( aFieldSideAndPins.side == SIDE_RIGHT || aFieldSideAndPins.side == SIDE_LEFT )
581 {
582 y = pinsBox.GetTop() - ( m_fbox_size.y + ( VPADDING * 2 ) );
583 }
584 }
585
586 return VECTOR2I( x, y );
587 }
588
593 bool fitFieldsBetweenWires( BOX2I* aBox, SIDE aSide )
594 {
595 if( aSide != SIDE_TOP && aSide != SIDE_BOTTOM )
596 return false;
597
598 std::vector<SCH_ITEM*> colliders = filterCollisions( *aBox );
599
600 if( colliders.empty() )
601 return false;
602
603 // Find the offset of the wires for proper positioning
604 int offset = 0;
605
606 for( SCH_ITEM* item : colliders )
607 {
608 SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
609
610 if( !line )
611 return false;
612
613 VECTOR2I start = line->GetStartPoint(), end = line->GetEndPoint();
614
615 if( start.y != end.y )
616 return false;
617
618 int this_offset = (3 * WIRE_V_SPACING / 2) - ( start.y % WIRE_V_SPACING );
619
620 if( offset == 0 )
621 offset = this_offset;
622 else if( offset != this_offset )
623 return false;
624 }
625
626 // At this point we are recomputing the field box size. Do not
627 // return false after this point.
628 m_fbox_size = computeFBoxSize( /* aDynamic */ false );
629
630 VECTOR2I pos = aBox->GetPosition();
631
632 pos.y = round_n( pos.y, WIRE_V_SPACING, aSide == SIDE_BOTTOM );
633
634 aBox->SetOrigin( pos );
635 return true;
636 }
637
646 int fieldHPlacement( SCH_FIELD* aField, const BOX2I& aFieldBox )
647 {
648 int field_hjust;
649 int field_xcoord;
650
651 if( aField->IsHorizJustifyFlipped() )
652 field_hjust = -aField->GetHorizJustify();
653 else
654 field_hjust = aField->GetHorizJustify();
655
656 switch( field_hjust )
657 {
659 field_xcoord = aFieldBox.GetLeft();
660 break;
662 field_xcoord = aFieldBox.Centre().x;
663 break;
665 field_xcoord = aFieldBox.GetRight();
666 break;
667 default:
668 wxFAIL_MSG( wxS( "Unexpected value for SCH_FIELD::GetHorizJustify()" ) );
669 field_xcoord = aFieldBox.Centre().x; // Most are centered
670 }
671
672 return field_xcoord;
673 }
674
686 int fieldVPlacement( SCH_FIELD* aField, const BOX2I& aFieldBox, int* aAccumulatedPosition,
687 bool aDynamic )
688 {
689 int field_height;
690 int padding;
691
692 if( !aDynamic )
693 {
694 field_height = WIRE_V_SPACING / 2;
695 padding = WIRE_V_SPACING / 2;
696 }
697 else if( m_align_to_grid )
698 {
699 field_height = aField->GetBoundingBox().GetHeight();
700 padding = round_n( field_height, schIUScale.MilsToIU( 50 ), true ) - field_height;
701 }
702 else
703 {
704 field_height = aField->GetBoundingBox().GetHeight();
705 padding = FIELD_PADDING;
706 }
707
708 int placement = *aAccumulatedPosition + padding / 2 + field_height / 2;
709
710 *aAccumulatedPosition += padding + field_height;
711
712 return placement;
713 }
714
715private:
718 std::vector<SCH_FIELD*> m_fields;
719 std::vector<SCH_ITEM*> m_colliders;
725};
726
727
732
733
734void SCH_SYMBOL::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
735{
736 if( aManual )
737 wxASSERT_MSG( aScreen, wxS( "A SCH_SCREEN pointer must be given for manual autoplacement" ) );
738
739 AUTOPLACER autoplacer( this, aScreen );
740 autoplacer.DoAutoplace( aManual );
742}
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
#define HPADDING
#define FIELD_PADDING
#define VPADDING
#define WIRE_V_SPACING
T round_n(const T &value, const T &n, bool aRoundUp)
Round up/down to the nearest multiple of n.
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
VECTOR2I computeFBoxSize(bool aDynamic)
Compute and return the size of the fields' bounding box.
VECTOR2I fieldBoxPlacement(SIDE_AND_NPINS aFieldSideAndPins)
Return the position of the field bounding box.
SIDE getPinSide(SCH_PIN *aPin)
Return the side that a pin is on.
int fieldVPlacement(SCH_FIELD *aField, const BOX2I &aFieldBox, int *aAccumulatedPosition, bool aDynamic)
Place a field vertically.
void getPossibleCollisions(std::vector< SCH_ITEM * > &aItems)
Populate a list of all drawing items that may collide with the fields.
void DoAutoplace(bool aManual)
Do the actual autoplacement.
static const SIDE SIDE_TOP
static const SIDE SIDE_BOTTOM
unsigned pinsOnSide(SIDE aSide)
Count the number of pins on a side of the symbol.
std::vector< SCH_FIELD * > m_fields
VECTOR2I m_fbox_size
SIDE_AND_NPINS chooseSideForFields(bool aAvoidCollisions)
Look where a symbol's pins are to pick a side to put the fields on.
AUTOPLACER(SCH_SYMBOL *aSymbol, SCH_SCREEN *aScreen)
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.
SCH_SCREEN * m_screen
std::vector< SCH_ITEM * > m_colliders
static const SIDE SIDE_RIGHT
std::vector< SCH_ITEM * > filterCollisions(const BOX2I &aRect)
Filter a list of possible colliders to include only those that actually collide with a given rectangl...
SCH_SYMBOL * m_symbol
std::vector< SIDE_AND_NPINS > getPreferredSides()
Return a list with the preferred field sides for the symbol, in decreasing order of preference.
std::vector< SIDE_AND_COLL > getCollidingSides()
Return a list of the sides where a field set would collide with another item.
static const SIDE SIDE_LEFT
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 SetOrigin(const Vec &pos)
Definition: box2.h:203
const Vec & GetPosition() const
Definition: box2.h:185
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:270
coord_type GetTop() const
Definition: box2.h:195
coord_type GetHeight() const
Definition: box2.h:189
coord_type GetWidth() const
Definition: box2.h:188
Vec Centre() const
Definition: box2.h:71
coord_type GetRight() const
Definition: box2.h:190
coord_type GetLeft() const
Definition: box2.h:194
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:589
virtual bool IsVisible() const
Definition: eda_text.h:147
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:257
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:160
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:249
EE_TYPE Overlapping(const BOX2I &aRect) const
Definition: sch_rtree.h:243
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:95
PIN_ORIENTATION 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:959
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:52
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:499
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
Definition: sch_field.cpp:541
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_field.cpp:1236
bool CanAutoplace() const
Definition: sch_field.h:195
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:150
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:512
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
VECTOR2I GetEndPoint() const
Definition: sch_line.h:145
VECTOR2I GetStartPoint() const
Definition: sch_line.h:140
LIB_PIN * GetLibPin() const
Definition: sch_pin.h:59
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
Schematic symbol object.
Definition: sch_symbol.h:81
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the symbol.
bool IsInNetlist() const
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
TRANSFORM & GetTransform()
Definition: sch_symbol.h:281
int GetOrientation() const
Get the display symbol orientation.
BOX2I GetBodyAndPinsBoundingBox() const
Return a bounding box for the symbol body and pins but not the fields.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:973
BOX2I GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the pins or fields.
int y1
Definition: transform.h:49
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:433
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:434
PIN_ORIENTATION
The symbol library pin object orientations.
Definition: pin_type.h:75
@ SYM_ORIENT_270
@ SYM_ORIENT_180
@ SYM_MIRROR_X
@ SYM_ORIENT_90
@ SYM_ORIENT_0
@ FIELDS_AUTOPLACED_AUTO
Definition: sch_item.h:60
@ FIELDS_AUTOPLACED_MANUAL
Definition: sch_item.h:61
bool collide(T aObject, U aAnotherObject, int aMinDistance)
Used by SHAPE_INDEX to implement Query().
Definition: shape_index.h:96
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_CENTER
#define TO_HJUSTIFY(x)
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588