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 for( SCH_FIELD* field : m_fields )
198 {
199 if( !field->IsVisible() || !field->CanAutoplace() )
200 {
201 continue;
202 }
203
204 if( m_symbol->GetTransform().y1 )
205 field->SetTextAngle( ANGLE_VERTICAL );
206 else
207 field->SetTextAngle( ANGLE_HORIZONTAL );
208
209 BOX2I bbox = field->GetBoundingBox();
210 int field_width = bbox.GetWidth();
211 int field_height = bbox.GetHeight();
212
213 max_field_width = std::max( max_field_width, field_width );
214
215 if( !aDynamic )
216 total_height += WIRE_V_SPACING;
217 else if( m_align_to_grid )
218 total_height += round_n( field_height, schIUScale.MilsToIU( 50 ), true );
219 else
220 total_height += field_height + FIELD_PADDING;
221 }
222
223 return VECTOR2I( max_field_width, total_height );
224 }
225
230 {
231 PIN_ORIENTATION pin_orient = aPin->GetLibPin()->PinDrawOrient( m_symbol->GetTransform() );
232
233 switch( pin_orient )
234 {
235 case PIN_ORIENTATION::PIN_RIGHT: return SIDE_LEFT;
236 case PIN_ORIENTATION::PIN_LEFT: return SIDE_RIGHT;
237 case PIN_ORIENTATION::PIN_UP: return SIDE_BOTTOM;
238 case PIN_ORIENTATION::PIN_DOWN: return SIDE_TOP;
239 default:
240 wxFAIL_MSG( wxS( "Invalid pin orientation" ) );
241 return SIDE_LEFT;
242 }
243 }
244
248 unsigned pinsOnSide( SIDE aSide )
249 {
250 unsigned pin_count = 0;
251
252 for( SCH_PIN* each_pin : m_symbol->GetPins() )
253 {
254 if( !each_pin->IsVisible() && !m_is_power_symbol )
255 continue;
256
257 if( getPinSide( each_pin ) == aSide )
258 ++pin_count;
259 }
260
261 return pin_count;
262 }
263
268 void getPossibleCollisions( std::vector<SCH_ITEM*>& aItems )
269 {
270 wxCHECK_RET( m_screen, wxS( "getPossibleCollisions() with null m_screen" ) );
271
273 std::vector<SIDE_AND_NPINS> sides = getPreferredSides();
274
275 for( SIDE_AND_NPINS& side : sides )
276 {
277 BOX2I box( fieldBoxPlacement( side ), m_fbox_size );
278 box.Merge( symbolBox );
279
280 for( SCH_ITEM* item : m_screen->Items().Overlapping( box ) )
281 {
282 if( SCH_SYMBOL* candidate = dynamic_cast<SCH_SYMBOL*>( item ) )
283 {
284 if( candidate == m_symbol )
285 continue;
286
287 std::vector<SCH_FIELD*> fields;
288 candidate->GetFields( fields, /* aVisibleOnly */ true );
289
290 for( SCH_FIELD* field : fields )
291 aItems.push_back( field );
292 }
293
294 aItems.push_back( item );
295 }
296 }
297 }
298
303 std::vector<SCH_ITEM*> filterCollisions( const BOX2I& aRect )
304 {
305 std::vector<SCH_ITEM*> filtered;
306
307 for( SCH_ITEM* item : m_colliders )
308 {
309 BOX2I item_box;
310
311 if( SCH_SYMBOL* item_comp = dynamic_cast<SCH_SYMBOL*>( item ) )
312 item_box = item_comp->GetBodyAndPinsBoundingBox();
313 else
314 item_box = item->GetBoundingBox();
315
316 if( item_box.Intersects( aRect ) )
317 filtered.push_back( item );
318 }
319
320 return filtered;
321 }
322
327 std::vector<SIDE_AND_NPINS> getPreferredSides()
328 {
329 SIDE_AND_NPINS sides_init[] = {
334 };
335 std::vector<SIDE_AND_NPINS> sides( sides_init, sides_init + arrayDim( sides_init ) );
336
337 int orient = m_symbol->GetOrientation();
338 int orient_angle = orient & 0xff; // enum is a bitmask
339 bool h_mirrored = ( ( orient & SYM_MIRROR_X )
340 && ( orient_angle == SYM_ORIENT_0 || orient_angle == SYM_ORIENT_180 ) );
341 double w = double( m_symbol_bbox.GetWidth() );
342 double h = double( m_symbol_bbox.GetHeight() );
343
344 // The preferred-sides heuristics are a bit magical. These were determined mostly
345 // by trial and error.
346
348 {
349 // For power symbols, we generally want the label at the top first.
350 switch( orient_angle )
351 {
352 case SYM_ORIENT_0:
353 std::swap( sides[0], sides[1] );
354 std::swap( sides[1], sides[3] );
355 // TOP, BOTTOM, RIGHT, LEFT
356 break;
357 case SYM_ORIENT_90:
358 std::swap( sides[0], sides[2] );
359 std::swap( sides[1], sides[2] );
360 // LEFT, RIGHT, TOP, BOTTOM
361 break;
362 case SYM_ORIENT_180:
363 std::swap( sides[0], sides[3] );
364 // BOTTOM, TOP, LEFT, RIGHT
365 break;
366 case SYM_ORIENT_270:
367 std::swap( sides[1], sides[2] );
368 // RIGHT, LEFT, TOP, BOTTOM
369 break;
370 }
371 }
372 else
373 {
374 // If the symbol is horizontally mirrored, swap left and right
375 if( h_mirrored )
376 {
377 std::swap( sides[0], sides[2] );
378 }
379
380 // If the symbol is very long or is a power symbol, swap H and V
381 if( w/h > 3.0 )
382 {
383 std::swap( sides[0], sides[1] );
384 std::swap( sides[1], sides[3] );
385 }
386 }
387
388 return sides;
389 }
390
394 std::vector<SIDE_AND_COLL> getCollidingSides()
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 SIDE_AND_NPINS sideandpins;
404 sideandpins.side = side;
405 sideandpins.pins = pinsOnSide( side );
406
407 BOX2I box( fieldBoxPlacement( sideandpins ), m_fbox_size );
408
409 COLLISION collision = COLLIDE_NONE;
410
411 for( SCH_ITEM* collider : filterCollisions( box ) )
412 {
413 SCH_LINE* line = dynamic_cast<SCH_LINE*>( collider );
414
415 if( line && !side.x )
416 {
417 VECTOR2I start = line->GetStartPoint(), end = line->GetEndPoint();
418
419 if( start.y == end.y && collision != COLLIDE_OBJECTS )
420 collision = COLLIDE_H_WIRES;
421 else
422 collision = COLLIDE_OBJECTS;
423 }
424 else
425 {
426 collision = COLLIDE_OBJECTS;
427 }
428 }
429
430 if( collision != COLLIDE_NONE )
431 colliding.push_back( { side, collision } );
432 }
433
434 return colliding;
435 }
436
441 SIDE_AND_NPINS chooseSideFiltered( std::vector<SIDE_AND_NPINS>& aSides,
442 const std::vector<SIDE_AND_COLL>& aCollidingSides,
443 COLLISION aCollision,
444 SIDE_AND_NPINS aLastSelection)
445 {
446 SIDE_AND_NPINS sel = aLastSelection;
447
448 std::vector<SIDE_AND_NPINS>::iterator it = aSides.begin();
449
450 while( it != aSides.end() )
451 {
452 bool collide = false;
453
454 for( SIDE_AND_COLL collision : aCollidingSides )
455 {
456 if( collision.side == it->side && collision.collision == aCollision )
457 collide = true;
458 }
459
460 if( !collide )
461 {
462 ++it;
463 }
464 else
465 {
466 if( it->pins <= sel.pins )
467 {
468 sel.pins = it->pins;
469 sel.side = it->side;
470 }
471
472 it = aSides.erase( it );
473 }
474 }
475
476 return sel;
477 }
478
484 SIDE_AND_NPINS chooseSideForFields( bool aAvoidCollisions )
485 {
486 std::vector<SIDE_AND_NPINS> sides = getPreferredSides();
487
488 std::reverse( sides.begin(), sides.end() );
489 SIDE_AND_NPINS side = { VECTOR2I( 1, 0 ), UINT_MAX };
490
491 if( aAvoidCollisions )
492 {
493 std::vector<SIDE_AND_COLL> colliding_sides = getCollidingSides();
494 side = chooseSideFiltered( sides, colliding_sides, COLLIDE_OBJECTS, side );
495 side = chooseSideFiltered( sides, colliding_sides, COLLIDE_H_WIRES, side );
496 }
497
498 for( SIDE_AND_NPINS& each_side : sides | boost::adaptors::reversed )
499 {
500 if( !each_side.pins ) return each_side;
501 }
502
503 for( SIDE_AND_NPINS& each_side : sides )
504 {
505 if( each_side.pins <= side.pins )
506 {
507 side.pins = each_side.pins;
508 side.side = each_side.side;
509 }
510 }
511
512 return side;
513 }
514
520 void justifyField( SCH_FIELD* aField, SIDE aFieldSide )
521 {
522 // Justification is set twice to allow IsHorizJustifyFlipped() to work correctly.
523 aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x ) );
524 aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x
525 * ( aField->IsHorizJustifyFlipped() ? -1 : 1 ) ) );
527 }
528
533 {
534 VECTOR2I fbox_center = m_symbol_bbox.Centre();
535 int offs_x = ( m_symbol_bbox.GetWidth() + m_fbox_size.x ) / 2;
536 int offs_y = ( m_symbol_bbox.GetHeight() + m_fbox_size.y ) / 2;
537
538 if( aFieldSideAndPins.side.x != 0 )
539 offs_x += HPADDING;
540 else if( aFieldSideAndPins.side.y != 0 )
541 offs_y += VPADDING;
542
543 fbox_center.x += aFieldSideAndPins.side.x * offs_x;
544 fbox_center.y += aFieldSideAndPins.side.y * offs_y;
545
546 int x = fbox_center.x - ( m_fbox_size.x / 2 );
547 int y = fbox_center.y - ( m_fbox_size.y / 2 );
548
549 auto getPinsBox =
550 [&]( const VECTOR2I& aSide )
551 {
552 BOX2I pinsBox;
553
554 for( SCH_PIN* each_pin : m_symbol->GetPins() )
555 {
556 if( !each_pin->IsVisible() && !m_is_power_symbol )
557 continue;
558
559 if( getPinSide( each_pin ) == aSide )
560 pinsBox.Merge( each_pin->GetBoundingBox() );
561 }
562
563 return pinsBox;
564 };
565
566 if( aFieldSideAndPins.pins > 0 )
567 {
568 BOX2I pinsBox = getPinsBox( aFieldSideAndPins.side );
569
570 if( aFieldSideAndPins.side == SIDE_TOP || aFieldSideAndPins.side == SIDE_BOTTOM )
571 {
572 x = pinsBox.GetRight() + ( HPADDING * 2 );
573 }
574 else if( aFieldSideAndPins.side == SIDE_RIGHT || aFieldSideAndPins.side == SIDE_LEFT )
575 {
576 y = pinsBox.GetTop() - ( m_fbox_size.y + ( VPADDING * 2 ) );
577 }
578 }
579
580 return VECTOR2I( x, y );
581 }
582
587 bool fitFieldsBetweenWires( BOX2I* aBox, SIDE aSide )
588 {
589 if( aSide != SIDE_TOP && aSide != SIDE_BOTTOM )
590 return false;
591
592 std::vector<SCH_ITEM*> colliders = filterCollisions( *aBox );
593
594 if( colliders.empty() )
595 return false;
596
597 // Find the offset of the wires for proper positioning
598 int offset = 0;
599
600 for( SCH_ITEM* item : colliders )
601 {
602 SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
603
604 if( !line )
605 return false;
606
607 VECTOR2I start = line->GetStartPoint(), end = line->GetEndPoint();
608
609 if( start.y != end.y )
610 return false;
611
612 int this_offset = (3 * WIRE_V_SPACING / 2) - ( start.y % WIRE_V_SPACING );
613
614 if( offset == 0 )
615 offset = this_offset;
616 else if( offset != this_offset )
617 return false;
618 }
619
620 // At this point we are recomputing the field box size. Do not
621 // return false after this point.
622 m_fbox_size = computeFBoxSize( /* aDynamic */ false );
623
624 VECTOR2I pos = aBox->GetPosition();
625
626 pos.y = round_n( pos.y, WIRE_V_SPACING, aSide == SIDE_BOTTOM );
627
628 aBox->SetOrigin( pos );
629 return true;
630 }
631
640 int fieldHPlacement( SCH_FIELD* aField, const BOX2I& aFieldBox )
641 {
642 int field_hjust;
643 int field_xcoord;
644
645 if( aField->IsHorizJustifyFlipped() )
646 field_hjust = -aField->GetHorizJustify();
647 else
648 field_hjust = aField->GetHorizJustify();
649
650 switch( field_hjust )
651 {
653 field_xcoord = aFieldBox.GetLeft();
654 break;
656 field_xcoord = aFieldBox.Centre().x;
657 break;
659 field_xcoord = aFieldBox.GetRight();
660 break;
661 default:
662 wxFAIL_MSG( wxS( "Unexpected value for SCH_FIELD::GetHorizJustify()" ) );
663 field_xcoord = aFieldBox.Centre().x; // Most are centered
664 }
665
666 return field_xcoord;
667 }
668
680 int fieldVPlacement( SCH_FIELD* aField, const BOX2I& aFieldBox, int* aAccumulatedPosition,
681 bool aDynamic )
682 {
683 int field_height;
684 int padding;
685
686 if( !aDynamic )
687 {
688 field_height = WIRE_V_SPACING / 2;
689 padding = WIRE_V_SPACING / 2;
690 }
691 else if( m_align_to_grid )
692 {
693 field_height = aField->GetBoundingBox().GetHeight();
694 padding = round_n( field_height, schIUScale.MilsToIU( 50 ), true ) - field_height;
695 }
696 else
697 {
698 field_height = aField->GetBoundingBox().GetHeight();
699 padding = FIELD_PADDING;
700 }
701
702 int placement = *aAccumulatedPosition + padding / 2 + field_height / 2;
703
704 *aAccumulatedPosition += padding + field_height;
705
706 return placement;
707 }
708
709private:
712 std::vector<SCH_FIELD*> m_fields;
713 std::vector<SCH_ITEM*> m_colliders;
719};
720
721
726
727
728void SCH_SYMBOL::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
729{
730 if( aManual )
731 wxASSERT_MSG( aScreen, wxS( "A SCH_SCREEN pointer must be given for manual autoplacement" ) );
732
733 AUTOPLACER autoplacer( this, aScreen );
734 autoplacer.DoAutoplace( aManual );
736}
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:148
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:276
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:161
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:268
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:510
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
Definition: sch_field.cpp:552
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_field.cpp:1254
bool CanAutoplace() const
Definition: sch_field.h:198
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:165
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:561
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:109
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:314
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.
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:432
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:431
PIN_ORIENTATION
The symbol library pin object orientations.
Definition: pin_type.h:75
@ FIELDS_AUTOPLACED_AUTO
Definition: sch_item.h:61
@ FIELDS_AUTOPLACED_MANUAL
Definition: sch_item.h:62
@ SYM_ORIENT_270
Definition: sch_symbol.h:88
@ SYM_ORIENT_180
Definition: sch_symbol.h:87
@ SYM_MIRROR_X
Definition: sch_symbol.h:89
@ SYM_ORIENT_90
Definition: sch_symbol.h:86
@ SYM_ORIENT_0
Definition: sch_symbol.h:85
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