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 489 of file backannotate.cpp.

491{
492 if( connectedItems.insert( aItem ).second )
493 {
494 for( SCH_ITEM* connectedItem : aItem->ConnectedItems( aSheetPath ) )
495 addConnections( connectedItem, aSheetPath, connectedItems );
496 }
497}
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:145
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:185

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 421 of file backannotate.cpp.

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