KiCad PCB EDA Suite
CN_EDGE Class Reference

CN_EDGE represents a point-to-point connection, whether realized or unrealized (ie: tracks etc. More...

#include <connectivity_algo.h>

Public Member Functions

 CN_EDGE ()
 
 CN_EDGE (const std::shared_ptr< CN_ANCHOR > &aSource, const std::shared_ptr< CN_ANCHOR > &aTarget, unsigned aWeight=0)
 
bool operator< (CN_EDGE aOther) const
 This sort operator provides a sort-by-weight for the ratsnest operation. More...
 
std::shared_ptr< CN_ANCHORGetSourceNode () const
 
std::shared_ptr< CN_ANCHORGetTargetNode () const
 
void SetSourceNode (const std::shared_ptr< CN_ANCHOR > &aNode)
 
void SetTargetNode (const std::shared_ptr< CN_ANCHOR > &aNode)
 
void SetWeight (unsigned weight)
 
unsigned GetWeight () const
 
void SetVisible (bool aVisible)
 
bool IsVisible () const
 
const VECTOR2I GetSourcePos () const
 
const VECTOR2I GetTargetPos () const
 
const unsigned GetLength () const
 

Private Attributes

std::shared_ptr< CN_ANCHORm_source
 
std::shared_ptr< CN_ANCHORm_target
 
unsigned m_weight
 
bool m_visible
 

Detailed Description

CN_EDGE represents a point-to-point connection, whether realized or unrealized (ie: tracks etc.

or a ratsnest line).

Definition at line 63 of file connectivity_algo.h.

Constructor & Destructor Documentation

◆ CN_EDGE() [1/2]

CN_EDGE::CN_EDGE ( )
inline

Definition at line 66 of file connectivity_algo.h.

66 :
67 m_weight( 0 ),
68 m_visible( true )
69 {}
unsigned m_weight

◆ CN_EDGE() [2/2]

CN_EDGE::CN_EDGE ( const std::shared_ptr< CN_ANCHOR > &  aSource,
const std::shared_ptr< CN_ANCHOR > &  aTarget,
unsigned  aWeight = 0 
)
inline

Definition at line 71 of file connectivity_algo.h.

72 :
73 m_source( aSource ),
74 m_target( aTarget ),
75 m_weight( aWeight ),
76 m_visible( true )
77 {}
std::shared_ptr< CN_ANCHOR > m_target
std::shared_ptr< CN_ANCHOR > m_source

Member Function Documentation

◆ GetLength()

const unsigned CN_EDGE::GetLength ( ) const
inline

Definition at line 104 of file connectivity_algo.h.

105 {
106 return ( m_target->Pos() - m_source->Pos() ).EuclideanNorm();
107 }

References m_source, and m_target.

◆ GetSourceNode()

std::shared_ptr< CN_ANCHOR > CN_EDGE::GetSourceNode ( ) const
inline

◆ GetSourcePos()

const VECTOR2I CN_EDGE::GetSourcePos ( ) const
inline

Definition at line 102 of file connectivity_algo.h.

102{ return m_source->Pos(); }

References m_source.

◆ GetTargetNode()

std::shared_ptr< CN_ANCHOR > CN_EDGE::GetTargetNode ( ) const
inline

◆ GetTargetPos()

const VECTOR2I CN_EDGE::GetTargetPos ( ) const
inline

Definition at line 103 of file connectivity_algo.h.

103{ return m_target->Pos(); }

References m_target.

◆ GetWeight()

unsigned CN_EDGE::GetWeight ( ) const
inline

Definition at line 97 of file connectivity_algo.h.

97{ return m_weight; }

References m_weight.

◆ IsVisible()

bool CN_EDGE::IsVisible ( ) const
inline

Definition at line 100 of file connectivity_algo.h.

100{ return m_visible; }

References m_visible.

◆ operator<()

bool CN_EDGE::operator< ( CN_EDGE  aOther) const
inline

This sort operator provides a sort-by-weight for the ratsnest operation.

Parameters
aOtherthe other edge to compare.
Returns
true if our weight is smaller than the other weight.

Definition at line 85 of file connectivity_algo.h.

86 {
87 return m_weight < aOther.m_weight;
88 }

References m_weight.

◆ SetSourceNode()

void CN_EDGE::SetSourceNode ( const std::shared_ptr< CN_ANCHOR > &  aNode)
inline

Definition at line 93 of file connectivity_algo.h.

93{ m_source = aNode; }

References m_source.

◆ SetTargetNode()

void CN_EDGE::SetTargetNode ( const std::shared_ptr< CN_ANCHOR > &  aNode)
inline

Definition at line 94 of file connectivity_algo.h.

94{ m_target = aNode; }

References m_target.

◆ SetVisible()

void CN_EDGE::SetVisible ( bool  aVisible)
inline

Definition at line 99 of file connectivity_algo.h.

99{ m_visible = aVisible; }

References m_visible.

Referenced by BOARD::UpdateRatsnestExclusions().

◆ SetWeight()

void CN_EDGE::SetWeight ( unsigned  weight)
inline

Definition at line 96 of file connectivity_algo.h.

96{ m_weight = weight; }

References m_weight.

Member Data Documentation

◆ m_source

std::shared_ptr<CN_ANCHOR> CN_EDGE::m_source
private

Definition at line 110 of file connectivity_algo.h.

Referenced by GetLength(), GetSourceNode(), GetSourcePos(), and SetSourceNode().

◆ m_target

std::shared_ptr<CN_ANCHOR> CN_EDGE::m_target
private

Definition at line 111 of file connectivity_algo.h.

Referenced by GetLength(), GetTargetNode(), GetTargetPos(), and SetTargetNode().

◆ m_visible

bool CN_EDGE::m_visible
private

Definition at line 113 of file connectivity_algo.h.

Referenced by IsVisible(), and SetVisible().

◆ m_weight

unsigned CN_EDGE::m_weight
private

Definition at line 112 of file connectivity_algo.h.

Referenced by GetWeight(), operator<(), and SetWeight().


The documentation for this class was generated from the following file: