KiCad PCB EDA Suite
Loading...
Searching...
No Matches
LIB_TREE_NODE_UNIT Class Reference

Node type: unit of component. More...

#include <lib_tree_model.h>

Inheritance diagram for LIB_TREE_NODE_UNIT:
LIB_TREE_NODE

Public Types

enum class  TYPE {
  ROOT , LIBRARY , ITEM , UNIT ,
  INVALID
}
 
typedef std::vector< std::unique_ptr< LIB_TREE_NODE > > PTR_VECTOR
 

Public Member Functions

 LIB_TREE_NODE_UNIT (LIB_TREE_NODE_UNIT const &_)=delete
 The addresses of CMP_TREE_NODEs are used as unique IDs for the wxDataViewModel, so don't let them be copied around.
 
void operator= (LIB_TREE_NODE_UNIT const &_)=delete
 
 LIB_TREE_NODE_UNIT (LIB_TREE_NODE *aParent, LIB_TREE_ITEM *aItem, int aUnit)
 Construct a unit node.
 
void UpdateScore (EDA_COMBINED_MATCHER *aMatcher, const wxString &aLib, std::function< bool(LIB_TREE_NODE &aNode)> *aFilter) override
 Update the score for this part.
 
virtual void ResetScore ()
 Initialize scores recursively.
 
virtual void ForceScore (int aScore)
 
void AssignIntrinsicRanks (bool presorted=false)
 Store intrinsic ranks on all children of this node.
 
void SortNodes (bool aUseScores)
 Sort child nodes quickly and recursively (IntrinsicRanks must have been set).
 

Static Public Member Functions

static bool Compare (LIB_TREE_NODE const &aNode1, LIB_TREE_NODE const &aNode2, bool aUseScores)
 Compare two nodes.
 

Public Attributes

LIB_TREE_NODEm_Parent
 
PTR_VECTOR m_Children
 
enum TYPE m_Type
 
int m_IntrinsicRank
 The rank of the item before any search terms are applied.
 
int m_Score
 
bool m_Pinned
 
wxString m_Name
 
wxString m_Desc
 
wxString m_Footprint
 
int m_PinCount
 
std::vector< SEARCH_TERMm_SearchTerms
 
std::map< wxString, wxString > m_Fields
 List of weighted search terms.
 
LIB_ID m_LibId
 
int m_Unit
 
bool m_IsRoot
 

Detailed Description

Node type: unit of component.

Definition at line 156 of file lib_tree_model.h.

Member Typedef Documentation

◆ PTR_VECTOR

typedef std::vector<std::unique_ptr<LIB_TREE_NODE> > LIB_TREE_NODE::PTR_VECTOR
inherited

Definition at line 123 of file lib_tree_model.h.

Member Enumeration Documentation

◆ TYPE

enum class LIB_TREE_NODE::TYPE
stronginherited
Enumerator
ROOT 
LIBRARY 
ITEM 
UNIT 
INVALID 

Definition at line 114 of file lib_tree_model.h.

Constructor & Destructor Documentation

◆ LIB_TREE_NODE_UNIT() [1/2]

LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT ( LIB_TREE_NODE_UNIT const &  _)
delete

The addresses of CMP_TREE_NODEs are used as unique IDs for the wxDataViewModel, so don't let them be copied around.

◆ LIB_TREE_NODE_UNIT() [2/2]

LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT ( LIB_TREE_NODE aParent,
LIB_TREE_ITEM aItem,
int  aUnit 
)

Construct a unit node.

The name of the unit will be "Unit %s", where s is aUnit formatted by LIB_PART::SubReference.

Parameters
aParentparent node, should be a CMP_TREE_NODE_ALIAS
aItemparent item
aUnitunit number

Definition at line 143 of file lib_tree_model.cpp.

References _, PGM_BASE::GetLocale(), LIB_TREE_ITEM::GetUnitDisplayName(), LIB_TREE_ITEM::GetUnitReference(), LIB_TREE_ITEM::HasUnitDisplayName(), LIB_TREE_NODE::m_Desc, LIB_TREE_NODE::m_IntrinsicRank, LIB_TREE_NODE::m_LibId, LIB_TREE_NODE::m_Name, LIB_TREE_NODE::m_Parent, LIB_TREE_NODE::m_Type, LIB_TREE_NODE::m_Unit, and Pgm().

Member Function Documentation

◆ AssignIntrinsicRanks()

◆ Compare()

bool LIB_TREE_NODE::Compare ( LIB_TREE_NODE const &  aNode1,
LIB_TREE_NODE const &  aNode2,
bool  aUseScores 
)
staticinherited

Compare two nodes.

Returns true if aNode1 < aNode2.

Definition at line 83 of file lib_tree_model.cpp.

References LIB_TREE_NODE::m_IntrinsicRank, LIB_TREE_NODE::m_Name, LIB_TREE_NODE::m_Pinned, LIB_TREE_NODE::m_Score, and LIB_TREE_NODE::m_Type.

◆ ForceScore()

virtual void LIB_TREE_NODE::ForceScore ( int  aScore)
inlinevirtualinherited

Definition at line 92 of file lib_tree_model.h.

References LIB_TREE_NODE::m_Score.

◆ operator=()

void LIB_TREE_NODE_UNIT::operator= ( LIB_TREE_NODE_UNIT const &  _)
delete

◆ ResetScore()

void LIB_TREE_NODE::ResetScore ( )
virtualinherited

Initialize scores recursively.

Definition at line 33 of file lib_tree_model.cpp.

References LIB_TREE_NODE::m_Children, and LIB_TREE_NODE::m_Score.

Referenced by LIB_TREE_MODEL_ADAPTER::UpdateSearchString().

◆ SortNodes()

void LIB_TREE_NODE::SortNodes ( bool  aUseScores)
inherited

Sort child nodes quickly and recursively (IntrinsicRanks must have been set).

Definition at line 70 of file lib_tree_model.cpp.

References LIB_TREE_NODE::m_Children.

Referenced by LIB_TREE_MODEL_ADAPTER::resortTree(), and LIB_TREE_MODEL_ADAPTER::UpdateSearchString().

◆ UpdateScore()

void LIB_TREE_NODE_UNIT::UpdateScore ( EDA_COMBINED_MATCHER aMatcher,
const wxString &  aLib,
std::function< bool(LIB_TREE_NODE &aNode)> *  aFilter 
)
overridevirtual

Update the score for this part.

This is accumulative - it will be called once per search term.

Parameters
aMatcheran EDA_COMBINED_MATCHER initialized with the search term

Implements LIB_TREE_NODE.

Definition at line 173 of file lib_tree_model.cpp.

References LIB_TREE_NODE::m_Parent, and LIB_TREE_NODE::m_Score.

Member Data Documentation

◆ m_Children

◆ m_Desc

◆ m_Fields

std::map<wxString, wxString> LIB_TREE_NODE::m_Fields
inherited

◆ m_Footprint

wxString LIB_TREE_NODE::m_Footprint
inherited

◆ m_IntrinsicRank

int LIB_TREE_NODE::m_IntrinsicRank
inherited

The rank of the item before any search terms are applied.

This is a fairly expensive sort (involving string compares) so it helps to store the result of that sort.

Definition at line 134 of file lib_tree_model.h.

Referenced by LIB_TREE_NODE::AssignIntrinsicRanks(), LIB_TREE_NODE::Compare(), and LIB_TREE_NODE_UNIT().

◆ m_IsRoot

◆ m_LibId

◆ m_Name

◆ m_Parent

◆ m_PinCount

int LIB_TREE_NODE::m_PinCount
inherited

◆ m_Pinned

◆ m_Score

◆ m_SearchTerms

◆ m_Type

◆ m_Unit


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