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 <sch_symbol.h>
57#include <sch_line.h>
58#include <sch_pin.h>
59#include <kiface_base.h>
60#include <algorithm>
61#include <tool/tool_manager.h>
63#include <eeschema_settings.h>
64#include <core/arraydim.h>
65
66#define FIELD_PADDING schIUScale.MilsToIU( 15 ) // arbitrarily chosen for aesthetics
67#define WIRE_V_SPACING schIUScale.MilsToIU( 100 )
68#define HPADDING schIUScale.MilsToIU( 25 ) // arbitrarily chosen for aesthetics
69#define VPADDING schIUScale.MilsToIU( 15 ) // arbitrarily chosen for aesthetics
70
74template<typename T> T round_n( const T& value, const T& n, bool aRoundUp )
75{
76 if( value % n )
77 return n * (value / n + (aRoundUp ? 1 : 0));
78 else
79 return value;
80}
81
82
84{
85public:
86 typedef VECTOR2I SIDE;
89
91 {
93 unsigned pins;
94 };
95
97 {
100 };
101
102 AUTOPLACER( SCH_SYMBOL* aSymbol, SCH_SCREEN* aScreen ) :
103 m_screen( aScreen ),
104 m_symbol( aSymbol )
105 {
106 m_symbol->GetFields( m_fields, /* aVisibleOnly */ true );
107
108 auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
109 wxASSERT( cfg );
110
111 m_allow_rejustify = false;
112 m_align_to_grid = true;
113
114 if( cfg )
115 {
116 m_allow_rejustify = cfg->m_AutoplaceFields.allow_rejustify;
117 m_align_to_grid = cfg->m_AutoplaceFields.align_to_grid;
118 }
119
121 m_fbox_size = computeFBoxSize( /* aDynamic */ true );
122
124
125 if( aScreen )
127 }
128
134 void DoAutoplace( bool aManual )
135 {
136 bool forceWireSpacing = false;
137 SIDE_AND_NPINS sideandpins = chooseSideForFields( aManual );
138 SIDE field_side = sideandpins.side;
139 VECTOR2I fbox_pos = fieldBoxPlacement( sideandpins );
140 BOX2I field_box( fbox_pos, m_fbox_size );
141
142 if( aManual )
143 forceWireSpacing = fitFieldsBetweenWires( &field_box, field_side );
144
145 // Move the fields
146 int last_y_coord = field_box.GetTop();
147
148 for( unsigned field_idx = 0; field_idx < m_fields.size(); ++field_idx )
149 {
150 SCH_FIELD* field = m_fields[field_idx];
151
152 if( !field->IsVisible() || !field->CanAutoplace() )
153 continue;
154
156 {
157 if( sideandpins.pins > 0 )
158 {
159 if( field_side == SIDE_TOP || field_side == SIDE_BOTTOM )
160 justifyField( field, SIDE_RIGHT );
161 else
162 justifyField( field, SIDE_TOP );
163 }
164 else
165 {
166 justifyField( field, field_side );
167 }
168 }
169
170 VECTOR2I pos( fieldHPlacement( field, field_box ),
171 fieldVPlacement( field, field_box, &last_y_coord, !forceWireSpacing ) );
172
173 if( m_align_to_grid )
174 {
175 if( abs( field_side.x ) > 0 )
176 pos.x = round_n( pos.x, schIUScale.MilsToIU( 50 ), field_side.x >= 0 );
177
178 if( abs( field_side.y ) > 0 )
179 pos.y = round_n( pos.y, schIUScale.MilsToIU( 50 ), field_side.y >= 0 );
180 }
181
182 field->SetPosition( pos );
183 }
184 }
185
186protected:
191 VECTOR2I computeFBoxSize( bool aDynamic )
192 {
193 int max_field_width = 0;
194 int total_height = 0;
195
196 for( SCH_FIELD* field : m_fields )
197 {
198 if( !field->IsVisible() || !field->CanAutoplace() )
199 {
200 continue;
201 }
202
203 if( m_symbol->GetTransform().y1 )
204 field->SetTextAngle( ANGLE_VERTICAL );
205 else
206 field->SetTextAngle( ANGLE_HORIZONTAL );
207
208 BOX2I bbox = field->GetBoundingBox();
209 int field_width = bbox.GetWidth();
210 int field_height = bbox.GetHeight();
211
212 max_field_width = std::max( max_field_width, field_width );
213
214 if( !aDynamic )
215 total_height += WIRE_V_SPACING;
216 else if( m_align_to_grid )
217 total_height += round_n( field_height, schIUScale.MilsToIU( 50 ), true );
218 else
219 total_height += field_height + FIELD_PADDING;
220 }
221
222 return VECTOR2I( max_field_width, total_height );
223 }
224
229 {
230 PIN_ORIENTATION pin_orient = aPin->PinDrawOrient( m_symbol->GetTransform() );
231
232 switch( pin_orient )
233 {
234 case PIN_ORIENTATION::PIN_RIGHT: return SIDE_LEFT;
235 case PIN_ORIENTATION::PIN_LEFT: return SIDE_RIGHT;
236 case PIN_ORIENTATION::PIN_UP: return SIDE_BOTTOM;
237 case PIN_ORIENTATION::PIN_DOWN: return SIDE_TOP;
238 default:
239 wxFAIL_MSG( wxS( "Invalid pin orientation" ) );
240 return SIDE_LEFT;
241 }
242 }
243
247 unsigned pinsOnSide( SIDE aSide )
248 {
249 unsigned pin_count = 0;
250
251 for( SCH_PIN* each_pin : m_symbol->GetPins() )
252 {
253 if( !each_pin->IsVisible() && !m_is_power_symbol )
254 continue;
255
256 if( getPinSide( each_pin ) == aSide )
257 ++pin_count;
258 }
259
260 return pin_count;
261 }
262
267 void getPossibleCollisions( std::vector<SCH_ITEM*>& aItems )
268 {
269 wxCHECK_RET( m_screen, wxS( "getPossibleCollisions() with null m_screen" ) );
270
272 std::vector<SIDE_AND_NPINS> sides = getPreferredSides();
273
274 for( SIDE_AND_NPINS& side : sides )
275 {
276 BOX2I box( fieldBoxPlacement( side ), m_fbox_size );
277 box.Merge( symbolBox );
278
279 for( SCH_ITEM* item : m_screen->Items().Overlapping( box ) )
280 {
281 if( SCH_SYMBOL* candidate = dynamic_cast<SCH_SYMBOL*>( item ) )
282 {
283 if( candidate == m_symbol )
284 continue;
285
286 std::vector<SCH_FIELD*> fields;
287 candidate->GetFields( fields, /* aVisibleOnly */ true );
288
289 for( SCH_FIELD* field : fields )
290 aItems.push_back( field );
291 }
292
293 aItems.push_back( item );
294 }
295 }
296 }
297
302 std::vector<SCH_ITEM*> filterCollisions( const BOX2I& aRect )
303 {
304 std::vector<SCH_ITEM*> filtered;
305
306 for( SCH_ITEM* item : m_colliders )
307 {
308 BOX2I item_box;
309
310 if( SCH_SYMBOL* item_comp = dynamic_cast<SCH_SYMBOL*>( item ) )
311 item_box = item_comp->GetBodyAndPinsBoundingBox();
312 else
313 item_box = item->GetBoundingBox();
314
315 if( item_box.Intersects( aRect ) )
316 filtered.push_back( item );
317 }
318
319 return filtered;
320 }
321
326 std::vector<SIDE_AND_NPINS> getPreferredSides()
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_symbol->GetOrientation();
337 int orient_angle = orient & 0xff; // enum is a bitmask
338 bool h_mirrored = ( ( orient & SYM_MIRROR_X )
339 && ( orient_angle == SYM_ORIENT_0 || orient_angle == SYM_ORIENT_180 ) );
340 double w = double( m_symbol_bbox.GetWidth() );
341 double h = double( m_symbol_bbox.GetHeight() );
342
343 // The preferred-sides heuristics are a bit magical. These were determined mostly
344 // by trial and error.
345
347 {
348 // For power symbols, we generally want the label at the top first.
349 switch( orient_angle )
350 {
351 case SYM_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 SYM_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 SYM_ORIENT_180:
362 std::swap( sides[0], sides[3] );
363 // BOTTOM, TOP, LEFT, RIGHT
364 break;
365 case SYM_ORIENT_270:
366 std::swap( sides[1], sides[2] );
367 // RIGHT, LEFT, TOP, BOTTOM
368 break;
369 }
370 }
371 else
372 {
373 // If the symbol is horizontally mirrored, swap left and right
374 if( h_mirrored )
375 {
376 std::swap( sides[0], sides[2] );
377 }
378
379 // If the symbol 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
393 std::vector<SIDE_AND_COLL> getCollidingSides()
394 {
395 SIDE sides_init[] = { SIDE_RIGHT, SIDE_TOP, SIDE_LEFT, SIDE_BOTTOM };
396 std::vector<SIDE> sides( sides_init, sides_init + arrayDim( sides_init ) );
397 std::vector<SIDE_AND_COLL> colliding;
398
399 // Iterate over all sides and find the ones that collide
400 for( SIDE side : sides )
401 {
402 SIDE_AND_NPINS sideandpins;
403 sideandpins.side = side;
404 sideandpins.pins = pinsOnSide( side );
405
406 BOX2I box( fieldBoxPlacement( sideandpins ), m_fbox_size );
407
408 COLLISION collision = COLLIDE_NONE;
409
410 for( SCH_ITEM* collider : filterCollisions( box ) )
411 {
412 SCH_LINE* line = dynamic_cast<SCH_LINE*>( collider );
413
414 if( line && !side.x )
415 {
416 VECTOR2I start = line->GetStartPoint(), end = line->GetEndPoint();
417
418 if( start.y == end.y && collision != COLLIDE_OBJECTS )
419 collision = COLLIDE_H_WIRES;
420 else
421 collision = COLLIDE_OBJECTS;
422 }
423 else
424 {
425 collision = COLLIDE_OBJECTS;
426 }
427 }
428
429 if( collision != COLLIDE_NONE )
430 colliding.push_back( { side, collision } );
431 }
432
433 return colliding;
434 }
435
440 SIDE_AND_NPINS chooseSideFiltered( std::vector<SIDE_AND_NPINS>& aSides,
441 const std::vector<SIDE_AND_COLL>& aCollidingSides,
442 COLLISION aCollision,
443 SIDE_AND_NPINS aLastSelection)
444 {
445 SIDE_AND_NPINS sel = aLastSelection;
446
447 std::vector<SIDE_AND_NPINS>::iterator it = aSides.begin();
448
449 while( it != aSides.end() )
450 {
451 bool collide = false;
452
453 for( SIDE_AND_COLL collision : aCollidingSides )
454 {
455 if( collision.side == it->side && collision.collision == aCollision )
456 collide = true;
457 }
458
459 if( !collide )
460 {
461 ++it;
462 }
463 else
464 {
465 if( it->pins <= sel.pins )
466 {
467 sel.pins = it->pins;
468 sel.side = it->side;
469 }
470
471 it = aSides.erase( it );
472 }
473 }
474
475 return sel;
476 }
477
483 SIDE_AND_NPINS chooseSideForFields( bool aAvoidCollisions )
484 {
485 std::vector<SIDE_AND_NPINS> sides = getPreferredSides();
486
487 std::reverse( sides.begin(), sides.end() );
488 SIDE_AND_NPINS side = { VECTOR2I( 1, 0 ), UINT_MAX };
489
490 if( aAvoidCollisions )
491 {
492 std::vector<SIDE_AND_COLL> colliding_sides = getCollidingSides();
493 side = chooseSideFiltered( sides, colliding_sides, COLLIDE_OBJECTS, side );
494 side = chooseSideFiltered( sides, colliding_sides, COLLIDE_H_WIRES, side );
495 }
496
497 for( SIDE_AND_NPINS& each_side : sides | boost::adaptors::reversed )
498 {
499 if( !each_side.pins ) return each_side;
500 }
501
502 for( SIDE_AND_NPINS& each_side : sides )
503 {
504 if( each_side.pins <= side.pins )
505 {
506 side.pins = each_side.pins;
507 side.side = each_side.side;
508 }
509 }
510
511 return side;
512 }
513
519 void justifyField( SCH_FIELD* aField, SIDE aFieldSide )
520 {
521 // Justification is set twice to allow IsHorizJustifyFlipped() to work correctly.
522 aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x ) );
523 aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x
524 * ( aField->IsHorizJustifyFlipped() ? -1 : 1 ) ) );
526 }
527
532 {
533 VECTOR2I fbox_center = m_symbol_bbox.Centre();
534 int offs_x = ( m_symbol_bbox.GetWidth() + m_fbox_size.x ) / 2;
535 int offs_y = ( m_symbol_bbox.GetHeight() + m_fbox_size.y ) / 2;
536
537 if( aFieldSideAndPins.side.x != 0 )
538 offs_x += HPADDING;
539 else if( aFieldSideAndPins.side.y != 0 )
540 offs_y += VPADDING;
541
542 fbox_center.x += aFieldSideAndPins.side.x * offs_x;
543 fbox_center.y += aFieldSideAndPins.side.y * offs_y;
544
545 int x = fbox_center.x - ( m_fbox_size.x / 2 );
546 int y = fbox_center.y - ( m_fbox_size.y / 2 );
547
548 auto getPinsBox =
549 [&]( const VECTOR2I& aSide )
550 {
551 BOX2I pinsBox;
552
553 for( SCH_PIN* each_pin : m_symbol->GetPins() )
554 {
555 if( !each_pin->IsVisible() && !m_is_power_symbol )
556 continue;
557
558 if( getPinSide( each_pin ) == aSide )
559 pinsBox.Merge( each_pin->GetBoundingBox() );
560 }
561
562 return pinsBox;
563 };
564
565 if( aFieldSideAndPins.pins > 0 )
566 {
567 BOX2I pinsBox = getPinsBox( aFieldSideAndPins.side );
568
569 if( aFieldSideAndPins.side == SIDE_TOP || aFieldSideAndPins.side == SIDE_BOTTOM )
570 {
571 x = pinsBox.GetRight() + ( HPADDING * 2 );
572 }
573 else if( aFieldSideAndPins.side == SIDE_RIGHT || aFieldSideAndPins.side == SIDE_LEFT )
574 {
575 y = pinsBox.GetTop() - ( m_fbox_size.y + ( VPADDING * 2 ) );
576 }
577 }
578
579 return VECTOR2I( x, y );
580 }
581
586 bool fitFieldsBetweenWires( BOX2I* aBox, SIDE aSide )
587 {
588 if( aSide != SIDE_TOP && aSide != SIDE_BOTTOM )
589 return false;
590
591 std::vector<SCH_ITEM*> colliders = filterCollisions( *aBox );
592
593 if( colliders.empty() )
594 return false;
595
596 // Find the offset of the wires for proper positioning
597 int offset = 0;
598
599 for( SCH_ITEM* item : colliders )
600 {
601 SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
602
603 if( !line )
604 return false;
605
606 VECTOR2I start = line->GetStartPoint(), end = line->GetEndPoint();
607
608 if( start.y != end.y )
609 return false;
610
611 int this_offset = (3 * WIRE_V_SPACING / 2) - ( start.y % WIRE_V_SPACING );
612
613 if( offset == 0 )
614 offset = this_offset;
615 else if( offset != this_offset )
616 return false;
617 }
618
619 // At this point we are recomputing the field box size. Do not
620 // return false after this point.
621 m_fbox_size = computeFBoxSize( /* aDynamic */ false );
622
623 VECTOR2I pos = aBox->GetPosition();
624
625 pos.y = round_n( pos.y, WIRE_V_SPACING, aSide == SIDE_BOTTOM );
626
627 aBox->SetOrigin( pos );
628 return true;
629 }
630
639 int fieldHPlacement( SCH_FIELD* aField, const BOX2I& aFieldBox )
640 {
641 int field_hjust;
642 int field_xcoord;
643
644 if( aField->IsHorizJustifyFlipped() )
645 field_hjust = -aField->GetHorizJustify();
646 else
647 field_hjust = aField->GetHorizJustify();
648
649 switch( field_hjust )
650 {
652 field_xcoord = aFieldBox.GetLeft();
653 break;
655 field_xcoord = aFieldBox.Centre().x;
656 break;
658 field_xcoord = aFieldBox.GetRight();
659 break;
660 default:
661 wxFAIL_MSG( wxS( "Unexpected value for SCH_FIELD::GetHorizJustify()" ) );
662 field_xcoord = aFieldBox.Centre().x; // Most are centered
663 }
664
665 return field_xcoord;
666 }
667
679 int fieldVPlacement( SCH_FIELD* aField, const BOX2I& aFieldBox, int* aAccumulatedPosition,
680 bool aDynamic )
681 {
682 int field_height;
683 int padding;
684
685 if( !aDynamic )
686 {
687 field_height = WIRE_V_SPACING / 2;
688 padding = WIRE_V_SPACING / 2;
689 }
690 else if( m_align_to_grid )
691 {
692 field_height = aField->GetBoundingBox().GetHeight();
693 padding = round_n( field_height, schIUScale.MilsToIU( 50 ), true ) - field_height;
694 }
695 else
696 {
697 field_height = aField->GetBoundingBox().GetHeight();
698 padding = FIELD_PADDING;
699 }
700
701 int placement = *aAccumulatedPosition + padding / 2 + field_height / 2;
702
703 *aAccumulatedPosition += padding + field_height;
704
705 return placement;
706 }
707
708private:
711 std::vector<SCH_FIELD*> m_fields;
712 std::vector<SCH_ITEM*> m_colliders;
718};
719
720
725
726
727void SCH_SYMBOL::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
728{
729 if( aManual )
730 wxASSERT_MSG( aScreen, wxS( "A SCH_SCREEN pointer must be given for manual autoplacement" ) );
731
732 AUTOPLACER autoplacer( this, aScreen );
733 autoplacer.DoAutoplace( aManual );
735}
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:110
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:227
const Vec & GetPosition() const
Definition: box2.h:201
size_type GetHeight() const
Definition: box2.h:205
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:294
coord_type GetTop() const
Definition: box2.h:219
size_type GetWidth() const
Definition: box2.h:204
Vec Centre() const
Definition: box2.h:87
coord_type GetRight() const
Definition: box2.h:207
coord_type GetLeft() const
Definition: box2.h:218
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:623
virtual bool IsVisible() const
Definition: eda_text.h:147
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:275
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:160
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:267
EE_TYPE Overlapping(const BOX2I &aRect) const
Definition: sch_rtree.h:243
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:95
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:609
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
Definition: sch_field.cpp:637
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_field.cpp:1458
bool CanAutoplace() const
Definition: sch_field.h:219
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:727
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:41
VECTOR2I GetEndPoint() const
Definition: sch_line.h:141
VECTOR2I GetStartPoint() const
Definition: sch_line.h:136
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: sch_pin.cpp:1304
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:108
Schematic symbol object.
Definition: sch_symbol.h:106
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:290
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:982
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_VERTICAL
Definition: eda_angle.h:398
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:397
PIN_ORIENTATION
The symbol library pin object orientations.
Definition: pin_type.h:77
@ FIELDS_AUTOPLACED_AUTO
Definition: sch_item.h:70
@ FIELDS_AUTOPLACED_MANUAL
Definition: sch_item.h:71
@ SYM_ORIENT_270
Definition: sch_symbol.h:85
@ SYM_ORIENT_180
Definition: sch_symbol.h:84
@ SYM_MIRROR_X
Definition: sch_symbol.h:86
@ SYM_ORIENT_90
Definition: sch_symbol.h:83
@ SYM_ORIENT_0
Definition: sch_symbol.h:82
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:93
@ 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< int32_t > VECTOR2I
Definition: vector2d.h:673