20#ifndef PCB_NET_INSPECTOR_PANEL_DATA_MODEL 
   21#define PCB_NET_INSPECTOR_PANEL_DATA_MODEL 
  259        auto& [
_, length] = *it;
 
  263            m_parent->SetLayerWireLength( 
m_parent->GetBoardWireLength() - length + aValue,
 
 
  280                m_parent->SubLayerWireLength( oldLength, oldLayer );
 
  282            for( 
auto& [newLayer, newLength] : aValue )
 
  283                m_parent->AddLayerWireLength( newLength, newLayer );
 
 
  292            m_parent->AddLayerWireLength( aValue, aLayer );
 
 
  301            m_parent->SubLayerWireLength( aValue, aLayer );
 
 
  312                m_parent->SubLayerWireDelay( oldLength, oldLayer );
 
  314            for( 
auto& [newLayer, newLength] : aValue )
 
  315                m_parent->AddLayerWireDelay( newLength, newLayer );
 
 
  324            m_parent->AddLayerWireDelay( aValue, aLayer );
 
 
  333            m_parent->SubLayerWireDelay( aValue, aLayer );
 
 
  355            m_parent->AddPadDieLength( aValue );
 
 
  364            m_parent->SubPadDieLength( aValue );
 
 
  427                m_parent->SubLayerWireLength( length, layer );
 
  430                m_parent->SubLayerWireDelay( delay, layer );
 
  436                                                   m_parent->m_children.end(), 
this ) );
 
  449                m_parent->AddLayerWireLength( length, layer );
 
  452                m_parent->AddLayerWireDelay( delay, layer );
 
  457            m_parent->m_children.push_back( 
this );
 
 
 
  493    template <
typename T>
 
  496        return a->GetNetCode() < b->GetNetCode();
 
 
  499    template <
typename T>
 
  502        return a->GetNetCode() < b;
 
 
  505    template <
typename T>
 
  508        return a < b->GetNetCode();
 
 
 
  515    template <
typename T>
 
  518        return a->GetGroupNumber() < b->GetGroupNumber();
 
 
  521    template <
typename T>
 
  524        return a->GetGroupNumber() < b;
 
 
  527    template <
typename T>
 
  530        return a < b->GetGroupNumber();
 
 
 
  549    wxVariant 
valueAt( 
unsigned int aCol, 
unsigned int aRow )
 const 
 
  560        std::vector<std::pair<wxString, wxDataViewItem>> ret;
 
  562        for( std::unique_ptr<LIST_ITEM>& item : 
m_items )
 
  564            if( item->GetIsGroup() )
 
  565                ret.push_back( std::make_pair( item->GetGroupName(), wxDataViewItem( item.get() ) ) );
 
 
  571    std::optional<LIST_ITEM_ITER> 
findItem( 
int aNetCode )
 
  573        auto i = std::lower_bound( 
m_items.begin(), 
m_items.end(), aNetCode,
 
  576        if( i == 
m_items.end() || ( *i )->GetNetCode() != aNetCode )
 
 
  584        if( aNet != 
nullptr )
 
 
  592        auto i = std::lower_bound( 
m_items.begin(), 
m_items.end(), aGroupNumber,
 
  595        if( i == 
m_items.end() || ( *i )->GetGroupNumber() != aGroupNumber )
 
 
  605                                             [&]( 
const std::unique_ptr<LIST_ITEM>& x )
 
  607                                                 return x->GetGroupName() == groupName
 
  608                                                        && x->GetGroupType() == groupType;
 
  611        if( 
group == groupsEnd )
 
  613            int                        dist = std::distance( groupsBegin, groupsEnd );
 
  614            std::unique_ptr<LIST_ITEM> groupItem = std::make_unique<LIST_ITEM>( dist, groupName, groupType );
 
  616            group = 
m_items.insert( groupsEnd, std::move( groupItem ) );
 
  617            ItemAdded( wxDataViewItem( ( *group )->Parent() ), wxDataViewItem( ( *group ).get() ) );
 
  620        return ( *group ).get();
 
 
  623    std::optional<LIST_ITEM_ITER> 
addItem( std::unique_ptr<LIST_ITEM> aItem )
 
  625        if( aItem == 
nullptr )
 
  628        bool groupMatched = 
false;
 
  631        if( 
m_parent.m_custom_group_rules.size() > 0 )
 
  633            wxString searchName = aItem->GetNetName();
 
  635            for( 
const std::unique_ptr<EDA_COMBINED_MATCHER>& rule : 
m_parent.m_custom_group_rules )
 
  637                if( rule->Find( searchName ) )
 
  647        if( 
m_parent.m_groupByNetclass && !groupMatched )
 
  651                                                          []( 
const std::unique_ptr<LIST_ITEM>& x )
 
  653                                                              return x->GetIsGroup();
 
  656            wxString match_str = aItem->GetNetclassName();
 
  658            aItem->SetParent( 
group );
 
  665        auto new_iter = std::lower_bound( 
m_items.begin(), 
m_items.end(), aItem->GetNetCode(),
 
  668        new_iter = 
m_items.insert( new_iter, std::move( aItem ) );
 
  669        const std::unique_ptr<LIST_ITEM>& new_item = *new_iter;
 
  671        ItemAdded( wxDataViewItem( new_item->Parent() ), wxDataViewItem( new_item.get() ) );
 
 
  676    void addItems( std::vector<std::unique_ptr<LIST_ITEM>>& aItems )
 
  680        for( std::unique_ptr<LIST_ITEM>& i : aItems )
 
 
  684    std::unique_ptr<LIST_ITEM> 
deleteItem( 
const std::optional<LIST_ITEM_ITER>& aRow )
 
  689        std::unique_ptr<LIST_ITEM> i = std::move( **aRow );
 
  692        i->SetParent( 
nullptr );
 
  695        ItemDeleted( wxDataViewItem( parent ), wxDataViewItem( &*i ) );
 
  699            ItemChanged( wxDataViewItem( parent ) );
 
  704                                       [&]( std::unique_ptr<LIST_ITEM>& x )
 
  706                                           return x.get() == parent;
 
  709                wxASSERT( p != 
m_items.end() );
 
  712                ItemDeleted( wxDataViewItem( parent->
Parent() ), wxDataViewItem( parent ) );
 
 
  730        for( 
const std::unique_ptr<EDA_COMBINED_MATCHER>& rule : 
m_parent.m_custom_group_rules )
 
  732            std::unique_ptr<LIST_ITEM>& 
group = 
m_items.emplace_back( std::make_unique<LIST_ITEM>(
 
  735            group->SetLayerCount( 
m_parent.m_board->GetCopperLayerCount() );
 
  736            ItemAdded( wxDataViewItem( 
group->Parent() ), wxDataViewItem( 
group.get() ) );
 
 
  752            const std::unique_ptr<LIST_ITEM>& listItem = *aRow.value();
 
  754            if( listItem->Parent() )
 
  755                ItemChanged( wxDataViewItem( listItem->Parent() ) );
 
  757            ItemChanged( wxDataViewItem( listItem.get() ) );
 
 
  764        for( std::unique_ptr<LIST_ITEM>& i : 
m_items )
 
  765            ItemChanged( wxDataViewItem( i.get() ) );
 
 
  770        if( wxDataViewColumn* column = 
m_parent.m_netsList->GetSortingColumn() )
 
  772            bool changed = 
false;
 
  778                i->ResetColumnChangedBits();
 
 
  787        if( aItem == 
nullptr || aCol >= 
m_parent.m_columns.size() )
 
 
  825    void GetValue( wxVariant& aOutValue, 
const wxDataViewItem& aItem,
 
  826                   unsigned int aCol )
 const override 
  832                if( i->GetIsGroup() )
 
  834                    switch( i->GetGroupType() )
 
  837                        aOutValue = 
_( 
"Netclass" ) + 
": " + i->GetGroupName();
 
  840                        aOutValue = 
_( 
"Custom" ) + 
": " + i->GetGroupName();
 
  843                        aOutValue = i->GetGroupName();
 
  849                    aOutValue = i->GetNetName();
 
  854                aOutValue = i->GetNetclassName();
 
  858                aOutValue = 
m_parent.formatCount( i->GetPadCount() );
 
  862                aOutValue = 
m_parent.formatCount( i->GetViaCount() );
 
  867                    aOutValue = 
m_parent.formatDelay( i->GetViaDelay() );
 
  869                    aOutValue = 
m_parent.formatLength( i->GetViaLength() );
 
  874                    aOutValue = 
m_parent.formatDelay( i->GetBoardWireDelay() );
 
  876                    aOutValue = 
m_parent.formatLength( i->GetBoardWireLength() );
 
  881                    aOutValue = 
m_parent.formatDelay( i->GetPadDieDelay() );
 
  883                    aOutValue = 
m_parent.formatLength( i->GetPadDieLength() );
 
  888                    aOutValue = 
m_parent.formatDelay( i->GetTotalDelay() );
 
  890                    aOutValue = 
m_parent.formatLength( i->GetTotalLength() );
 
  895                    aOutValue = 
m_parent.formatDelay( i->GetLayerWireDelay( 
m_parent.m_columns[aCol].layer ) );
 
  897                    aOutValue = 
m_parent.formatLength( i->GetLayerWireLength( 
m_parent.m_columns[aCol].layer ) );
 
 
  906    static int compareUInt( int64_t aValue1, int64_t aValue2, 
bool aAsc )
 
  909            return aValue1 < aValue2 ? -1 : 1;
 
  911            return aValue2 < aValue1 ? -1 : 1;
 
 
  914    int Compare( 
const wxDataViewItem& aItem1, 
const wxDataViewItem& aItem2, 
unsigned int aCol,
 
  915                 bool aAsc )
 const override 
 1006        wxUIntPtr id1 = wxPtrToUInt( aItem1.GetID() );
 
 1007        wxUIntPtr id2 = wxPtrToUInt( aItem2.GetID() );
 
 1009        return aAsc ? id1 - id2 : id2 - id1;
 
 
 1012    bool SetValue( 
const wxVariant& aInValue, 
const wxDataViewItem& aItem,
 
 1013                   unsigned int aCol )
 override 
 
 1018    wxDataViewItem 
GetParent( 
const wxDataViewItem& aItem )
 const override 
 1021            return wxDataViewItem();
 
 1023        return wxDataViewItem( 
static_cast<const LIST_ITEM*
>( aItem.GetID() )->
Parent() );
 
 
 1040                              wxDataViewItemArray&  aChildren )
 const override 
 1044        if( !aParent.IsOk() )
 
 1046            aChildren.Alloc( 
m_items.size() );
 
 1048            for( 
const std::unique_ptr<LIST_ITEM>& i : 
m_items )
 
 1050                if( i->Parent() == 
nullptr )
 
 1051                    aChildren.Add( wxDataViewItem( &*i ) );
 
 1054            return aChildren.GetCount();
 
 1063            aChildren.Alloc( count );
 
 1066                aChildren.Add( wxDataViewItem( *i ) );
 
 1068            return aChildren.GetCount();
 
 
 1074    wxString 
GetColumnType( 
unsigned int  )
 const override { 
return wxS( 
"string" ); }
 
 
const wxString GetHumanReadableName() const
Gets the consolidated name of this netclass (which may be an aggregate).
 
Handle the data for a net.
 
const wxString & GetNetname() const
 
Data model for display in the Net Inspector panel.
 
std::unique_ptr< LIST_ITEM > deleteItem(const std::optional< LIST_ITEM_ITER > &aRow)
 
bool IsContainer(const wxDataViewItem &aItem) const override
 
void resortIfChanged(LIST_ITEM *aItem)
 
bool itemColumnChanged(const LIST_ITEM *aItem, unsigned int aCol) const
 
static int compareUInt(int64_t aValue1, int64_t aValue2, bool aAsc)
 
void addCustomGroups()
Adds all custom group-by entries to the items table.
 
unsigned int GetColumnCount() const override
 
wxString GetColumnType(unsigned int) const override
 
wxDataViewItem GetParent(const wxDataViewItem &aItem) const override
 
bool HasContainerColumns(const wxDataViewItem &aItem) const override
 
bool SetValue(const wxVariant &aInValue, const wxDataViewItem &aItem, unsigned int aCol) override
 
void GetValue(wxVariant &aOutValue, const wxDataViewItem &aItem, unsigned int aCol) const override
 
std::vector< std::pair< wxString, wxDataViewItem > > getGroupDataViewItems()
 
std::optional< LIST_ITEM_ITER > findItem(NETINFO_ITEM *aNet)
 
unsigned int GetChildren(const wxDataViewItem &aParent, wxDataViewItemArray &aChildren) const override
 
PCB_NET_INSPECTOR_PANEL & m_parent
 
std::optional< LIST_ITEM_ITER > findItem(int aNetCode)
 
unsigned int itemCount() const
 
std::map< wxString, LIST_ITEM * > m_custom_group_map
Map of custom group names to their representative list item.
 
wxVariant valueAt(unsigned int aCol, unsigned int aRow) const
 
unsigned int columnCount() const
 
void addItems(std::vector< std::unique_ptr< LIST_ITEM > > &aItems)
 
DATA_MODEL(PCB_NET_INSPECTOR_PANEL &parent)
 
int Compare(const wxDataViewItem &aItem1, const wxDataViewItem &aItem2, unsigned int aCol, bool aAsc) const override
 
void SetIsTimeDomain(const bool aIsTimeDomain)
 
std::optional< LIST_ITEM_ITER > findGroupItem(int aGroupNumber)
 
std::vector< std::unique_ptr< LIST_ITEM > > m_items
 
const LIST_ITEM & itemAt(unsigned int aRow) const
 
void updateItem(const std::optional< LIST_ITEM_ITER > &aRow)
 
bool m_show_time_domain_details
 
LIST_ITEM * addGroup(LIST_ITEM_ITER groupsBegin, LIST_ITEM_ITER groupsEnd, wxString groupName, LIST_ITEM::GROUP_TYPE groupType)
 
std::optional< LIST_ITEM_ITER > addItem(std::unique_ptr< LIST_ITEM > aItem)
 
Primary data item for entries in the Net Inspector list.
 
void AddViaCount(unsigned int aValue)
 
void SetLayerCount(unsigned int aValue)
 
bool PadCountChanged() const
 
LIST_ITEM(unsigned int aGroupNumber, const wxString &aGroupName, GROUP_TYPE aGroupType)
 
std::map< PCB_LAYER_ID, int64_t > m_layer_wire_length
 
void SetPadCount(unsigned int aValue)
 
void SetPadDieLength(int64_t aValue)
 
auto ChildrenBegin() const
 
unsigned long long int GetTotalDelay() const
 
unsigned int ChildrenCount() const
 
void AddViaDelay(unsigned int aValue)
 
void AddLayerWireDelay(const int64_t aValue, PCB_LAYER_ID aLayer)
 
void SubViaCount(unsigned int aValue)
 
unsigned GetViaCount() const
 
std::vector< LIST_ITEM * > m_children
 
void SubPadDieDelay(int64_t aValue)
 
void SubViaDelay(int64_t aValue)
 
void SetLayerWireLengths(const std::map< PCB_LAYER_ID, int64_t > &aValue)
 
void SetViaCount(unsigned int aValue)
 
void ResetColumnChangedBits()
 
LIST_ITEM * Parent() const
 
int64_t GetViaLength() const
 
void AddPadDieDelay(int64_t aValue)
 
bool BoardWireLengthChanged() const
 
const wxString & GetNetclassName() const
 
unsigned int GetPadCount() const
 
int64_t GetBoardWireLength() const
 
void AddLayerWireLength(const int64_t aValue, PCB_LAYER_ID aLayer)
 
void SetViaLength(unsigned int aValue)
 
void AddPadDieLength(int64_t aValue)
 
void SetViaDelay(unsigned int aValue)
 
int64_t GetViaDelay() const
 
unsigned long long int GetTotalLength() const
 
int64_t GetPadDieLength() const
 
void SetParent(LIST_ITEM *aParent)
 
int GetGroupNumber() const
 
std::map< PCB_LAYER_ID, int64_t > m_layer_wire_delay
 
bool ViaCountChanged() const
 
LIST_ITEM & operator=(const LIST_ITEM &)=delete
 
const wxString & GetGroupName() const
 
std::vector< int > m_column_changed
 
int64_t GetBoardWireDelay() const
 
LIST_ITEM(NETINFO_ITEM *aNet)
 
int64_t GetPadDieDelay() const
 
int64_t GetLayerWireDelay(PCB_LAYER_ID aLayer) const
 
const wxString & GetNetName() const
 
bool ViaLengthChanged() const
 
std::map< PCB_LAYER_ID, int64_t > GetLayerWireDelays() const
 
unsigned int m_group_number
 
std::map< PCB_LAYER_ID, int64_t > GetLayerWireLengths() const
 
bool PadDieLengthChanged() const
 
void SubViaLength(int64_t aValue)
 
NETINFO_ITEM * GetNet() const
 
void SubPadDieLength(int64_t aValue)
 
void AddPadCount(unsigned int aValue)
 
int64_t GetLayerWireLength(PCB_LAYER_ID aLayer) const
 
void SetLayerWireLength(const int64_t aValue, PCB_LAYER_ID aLayer)
 
bool TotalLengthChanged() const
 
GROUP_TYPE GetGroupType() const
 
void SetPadDieDelay(int64_t aValue)
 
void AddViaLength(unsigned int aValue)
 
void SubPadCount(unsigned int aValue)
 
void SubLayerWireDelay(const int64_t aValue, PCB_LAYER_ID aLayer)
 
void SetLayerWireDelays(const std::map< PCB_LAYER_ID, int64_t > &aValue)
 
void SubLayerWireLength(const int64_t aValue, PCB_LAYER_ID aLayer)
 
PCB_NET_INSPECTOR_PANEL(wxWindow *parent, PCB_EDIT_FRAME *aFrame)
 
std::vector< std::unique_ptr< LIST_ITEM > >::iterator LIST_ITEM_ITER
 
Abstract pattern-matching tool and implementations.
 
PCB_LAYER_ID
A quick note on layer IDs:
 
wxString UnescapeString(const wxString &aSource)
 
int ValueStringCompare(const wxString &strFWord, const wxString &strSWord)
Compare strings like the strcmp function but handle numbers and modifiers within the string text corr...
 
bool operator()(const T &a, const T &b) const
 
bool operator()(const T &a, int b) const
 
bool operator()(int a, const T &b) const
 
bool operator()(const T &a, const T &b) const
 
bool operator()(int a, const T &b) const
 
bool operator()(const T &a, int b) const