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

Lasting name for one handle in an EDIT_POINTS collection. More...

#include <pcb_handle_key.h>

Public Member Functions

EDIT_POINT * Resolve (EDIT_POINTS &aPoints) const
 Find this key's handle in a collection, usually after it was rebuilt.
 
const KIID & Parent () const
 
bool IsLine () const
 
int Index () const
 
bool operator== (const PCB_HANDLE_KEY &aOther) const
 
bool operator< (const PCB_HANDLE_KEY &aOther) const
 

Static Public Member Functions

static std::optional< PCB_HANDLE_KEY > Make (const EDIT_POINTS &aPoints, const EDIT_POINT *aPoint)
 Build the key for a handle in a collection.
 

Private Member Functions

 PCB_HANDLE_KEY (const KIID &aParent, bool aIsLine, int aIndex, unsigned aPointCount, unsigned aLineCount)
 

Private Attributes

KIID m_parent
 
bool m_isLine
 
int m_index
 
unsigned m_pointCount
 
unsigned m_lineCount
 

Detailed Description

Lasting name for one handle in an EDIT_POINTS collection.

Point collections are rebuilt while editing, so an EDIT_POINT pointer goes stale. A key names the handle by the parent item's KIID, whether the handle is a point or a line, and the handle's index. Two keys for the same handle are the same key, so a picked set holds each handle once.

It also stores the collection's point and line counts, which Resolve() checks. If the parent gained or lost handles the index could now name a different handle, so the key stops resolving and the caller drops it.

Definition at line 42 of file pcb_handle_key.h.

Constructor & Destructor Documentation

◆ PCB_HANDLE_KEY()

PCB_HANDLE_KEY::PCB_HANDLE_KEY ( const KIID & aParent,
bool aIsLine,
int aIndex,
unsigned aPointCount,
unsigned aLineCount )
private

Definition at line 25 of file pcb_handle_key.cpp.

References m_index, m_isLine, m_lineCount, m_parent, and m_pointCount.

Referenced by Make(), operator<(), and operator==().

Member Function Documentation

◆ Index()

int PCB_HANDLE_KEY::Index ( ) const
inline

Definition at line 65 of file pcb_handle_key.h.

References m_index.

◆ IsLine()

bool PCB_HANDLE_KEY::IsLine ( ) const
inline

Definition at line 64 of file pcb_handle_key.h.

References m_isLine.

◆ Make()

std::optional< PCB_HANDLE_KEY > PCB_HANDLE_KEY::Make ( const EDIT_POINTS & aPoints,
const EDIT_POINT * aPoint )
static

◆ operator<()

bool PCB_HANDLE_KEY::operator< ( const PCB_HANDLE_KEY & aOther) const

Definition at line 94 of file pcb_handle_key.cpp.

References m_index, m_isLine, m_parent, and PCB_HANDLE_KEY().

◆ operator==()

bool PCB_HANDLE_KEY::operator== ( const PCB_HANDLE_KEY & aOther) const

Definition at line 88 of file pcb_handle_key.cpp.

References m_index, m_isLine, m_parent, and PCB_HANDLE_KEY().

◆ Parent()

const KIID & PCB_HANDLE_KEY::Parent ( ) const
inline

Definition at line 63 of file pcb_handle_key.h.

References m_parent.

◆ Resolve()

EDIT_POINT * PCB_HANDLE_KEY::Resolve ( EDIT_POINTS & aPoints) const

Find this key's handle in a collection, usually after it was rebuilt.

Returns
the handle, or nullptr when the parent is a different item, the handle counts changed since the key was made, or the index is out of range.

Definition at line 63 of file pcb_handle_key.cpp.

References EDIT_POINTS::GetParent(), EDIT_POINTS::Line(), EDIT_POINTS::LinesSize(), m_index, m_isLine, m_lineCount, m_parent, m_pointCount, EDA_ITEM::m_Uuid, EDIT_POINTS::Point(), and EDIT_POINTS::PointsSize().

Referenced by resolveInCollections().

Member Data Documentation

◆ m_index

int PCB_HANDLE_KEY::m_index
private

Definition at line 75 of file pcb_handle_key.h.

Referenced by Index(), operator<(), operator==(), PCB_HANDLE_KEY(), and Resolve().

◆ m_isLine

bool PCB_HANDLE_KEY::m_isLine
private

Definition at line 74 of file pcb_handle_key.h.

Referenced by IsLine(), operator<(), operator==(), PCB_HANDLE_KEY(), and Resolve().

◆ m_lineCount

unsigned PCB_HANDLE_KEY::m_lineCount
private

Definition at line 77 of file pcb_handle_key.h.

Referenced by PCB_HANDLE_KEY(), and Resolve().

◆ m_parent

KIID PCB_HANDLE_KEY::m_parent
private

Definition at line 73 of file pcb_handle_key.h.

Referenced by operator<(), operator==(), Parent(), PCB_HANDLE_KEY(), and Resolve().

◆ m_pointCount

unsigned PCB_HANDLE_KEY::m_pointCount
private

Definition at line 76 of file pcb_handle_key.h.

Referenced by PCB_HANDLE_KEY(), and Resolve().


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