KiCad PCB EDA Suite
backannotate.cpp File Reference
#include <backannotate.h>
#include <boost/property_tree/ptree.hpp>
#include <confirm.h>
#include <dsnlexer.h>
#include <ptree.h>
#include <reporter.h>
#include <sch_edit_frame.h>
#include <sch_sheet_path.h>
#include <sch_label.h>
#include <schematic.h>
#include <string_utils.h>
#include <kiface_base.h>
#include <wildcards_and_files_ext.h>
#include <connection_graph.h>
#include <wx/log.h>

Go to the source code of this file.

Functions

static TEXT_SPIN_STYLE orientLabel (SCH_PIN *aPin)
 
void addConnections (SCH_ITEM *aItem, const SCH_SHEET_PATH &aSheetPath, std::set< SCH_ITEM * > &connectedItems)
 

Function Documentation

◆ addConnections()

void addConnections ( SCH_ITEM aItem,
const SCH_SHEET_PATH aSheetPath,
std::set< SCH_ITEM * > &  connectedItems 
)

Definition at line 486 of file backannotate.cpp.

488{
489 if( connectedItems.insert( aItem ).second )
490 {
491 for( SCH_ITEM* connectedItem : aItem->ConnectedItems( aSheetPath ) )
492 addConnections( connectedItem, aSheetPath, connectedItems );
493 }
494}
void addConnections(SCH_ITEM *aItem, const SCH_SHEET_PATH &aSheetPath, std::set< SCH_ITEM * > &connectedItems)
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
SCH_ITEM_SET & ConnectedItems(const SCH_SHEET_PATH &aPath)
Retrieve the set of items connected to this item on the given sheet.
Definition: sch_item.cpp:187

References addConnections(), and SCH_ITEM::ConnectedItems().

Referenced by addConnections(), and BACK_ANNOTATE::processNetNameChange().

◆ orientLabel()

static TEXT_SPIN_STYLE orientLabel ( SCH_PIN aPin)
static

Definition at line 418 of file backannotate.cpp.

419{
421
422 // Initial orientation from the pin
423 switch( aPin->GetLibPin()->GetOrientation() )
424 {
425 case PIN_UP: spin = TEXT_SPIN_STYLE::BOTTOM; break;
426 case PIN_DOWN: spin = TEXT_SPIN_STYLE::UP; break;
427 case PIN_LEFT: spin = TEXT_SPIN_STYLE::RIGHT; break;
428 case PIN_RIGHT: spin = TEXT_SPIN_STYLE::LEFT; break;
429 }
430
431 // Reorient based on the actual symbol orientation now
432 struct ORIENT
433 {
434 int flag;
435 int n_rots;
436 int mirror_x;
437 int mirror_y;
438 }
439 orientations[] =
440 {
441 { SYM_ORIENT_0, 0, 0, 0 },
442 { SYM_ORIENT_90, 1, 0, 0 },
443 { SYM_ORIENT_180, 2, 0, 0 },
444 { SYM_ORIENT_270, 3, 0, 0 },
445 { SYM_MIRROR_X + SYM_ORIENT_0, 0, 1, 0 },
446 { SYM_MIRROR_X + SYM_ORIENT_90, 1, 1, 0 },
447 { SYM_MIRROR_Y, 0, 0, 1 },
448 { SYM_MIRROR_X + SYM_ORIENT_270, 3, 1, 0 },
449 { SYM_MIRROR_Y + SYM_ORIENT_0, 0, 0, 1 },
450 { SYM_MIRROR_Y + SYM_ORIENT_90, 1, 0, 1 },
451 { SYM_MIRROR_Y + SYM_ORIENT_180, 2, 0, 1 },
452 { SYM_MIRROR_Y + SYM_ORIENT_270, 3, 0, 1 }
453 };
454
455 ORIENT o = orientations[ 0 ];
456
457 SCH_SYMBOL* parentSymbol = aPin->GetParentSymbol();
458
459 if( !parentSymbol )
460 return spin;
461
462 int symbolOrientation = parentSymbol->GetOrientation();
463
464 for( auto& i : orientations )
465 {
466 if( i.flag == symbolOrientation )
467 {
468 o = i;
469 break;
470 }
471 }
472
473 for( int i = 0; i < o.n_rots; i++ )
474 spin = spin.RotateCCW();
475
476 if( o.mirror_x )
477 spin = spin.MirrorX();
478
479 if( o.mirror_y )
480 spin = spin.MirrorY();
481
482 return spin;
483}
int GetOrientation() const
Definition: lib_pin.h:74
LIB_PIN * GetLibPin() const
Definition: sch_pin.h:59
SCH_SYMBOL * GetParentSymbol() const
Definition: sch_pin.cpp:188
Schematic symbol object.
Definition: sch_symbol.h:81
int GetOrientation() const
Get the display symbol orientation.
TEXT_SPIN_STYLE MirrorY()
Mirror the label spin style across the Y axis or simply swaps left and right.
Definition: sch_text.cpp:99
TEXT_SPIN_STYLE RotateCCW()
Definition: sch_text.cpp:67
TEXT_SPIN_STYLE MirrorX()
Mirror the label spin style across the X axis or simply swaps up and bottom.
Definition: sch_text.cpp:83
@ PIN_LEFT
Definition: lib_pin.h:46
@ PIN_RIGHT
Definition: lib_pin.h:45
@ PIN_UP
Definition: lib_pin.h:47
@ PIN_DOWN
Definition: lib_pin.h:48
@ SYM_ORIENT_270
@ SYM_MIRROR_Y
@ SYM_ORIENT_180
@ SYM_MIRROR_X
@ SYM_ORIENT_90
@ SYM_ORIENT_0

References TEXT_SPIN_STYLE::BOTTOM, flag, SCH_PIN::GetLibPin(), LIB_PIN::GetOrientation(), SCH_SYMBOL::GetOrientation(), SCH_PIN::GetParentSymbol(), TEXT_SPIN_STYLE::LEFT, TEXT_SPIN_STYLE::MirrorX(), TEXT_SPIN_STYLE::MirrorY(), PIN_DOWN, PIN_LEFT, PIN_RIGHT, PIN_UP, TEXT_SPIN_STYLE::RIGHT, TEXT_SPIN_STYLE::RotateCCW(), SYM_MIRROR_X, SYM_MIRROR_Y, SYM_ORIENT_0, SYM_ORIENT_180, SYM_ORIENT_270, SYM_ORIENT_90, and TEXT_SPIN_STYLE::UP.

Referenced by BACK_ANNOTATE::processNetNameChange().