20#ifndef PCB_NET_INSPECTOR_PANEL_DATA_MODEL
21#define PCB_NET_INSPECTOR_PANEL_DATA_MODEL
210 auto& [
_, length] = *it;
231 for(
auto& [newLayer, newLength] : aValue )
366 template <
typename T>
369 return a->GetNetCode() < b->GetNetCode();
372 template <
typename T>
375 return a->GetNetCode() < b;
378 template <
typename T>
381 return a < b->GetNetCode();
388 template <
typename T>
391 return a->GetGroupNumber() < b->GetGroupNumber();
394 template <
typename T>
397 return a->GetGroupNumber() < b;
400 template <
typename T>
403 return a < b->GetGroupNumber();
420 wxVariant
valueAt(
unsigned int aCol,
unsigned int aRow )
const
431 std::vector<std::pair<wxString, wxDataViewItem>> ret;
433 for( std::unique_ptr<LIST_ITEM>& item :
m_items )
435 if( item->GetIsGroup() )
437 ret.push_back( std::make_pair( item->GetGroupName(),
438 wxDataViewItem( item.get() ) ) );
446 std::optional<LIST_ITEM_ITER>
findItem(
int aNetCode )
448 auto i = std::lower_bound(
m_items.begin(),
m_items.end(), aNetCode,
451 if( i ==
m_items.end() || ( *i )->GetNetCode() != aNetCode )
460 if( aNet !=
nullptr )
469 auto i = std::lower_bound(
m_items.begin(),
m_items.end(), aGroupNumber,
472 if( i ==
m_items.end() || ( *i )->GetGroupNumber() != aGroupNumber )
483 [&](
const std::unique_ptr<LIST_ITEM>& x )
485 return x->GetGroupName() == groupName
486 && x->GetGroupType() == groupType;
489 if(
group == groupsEnd )
491 int dist = std::distance( groupsBegin, groupsEnd );
492 std::unique_ptr<LIST_ITEM> groupItem = std::make_unique<LIST_ITEM>( dist, groupName,
494 group =
m_items.insert( groupsEnd, std::move( groupItem ) );
495 ItemAdded( wxDataViewItem( ( *group )->Parent() ), wxDataViewItem( &**
group ) );
502 std::optional<LIST_ITEM_ITER>
addItem( std::unique_ptr<LIST_ITEM> aItem )
504 if( aItem ==
nullptr )
507 bool groupMatched =
false;
512 wxString searchName = aItem->GetNetName();
516 if( rule->Find( searchName ) )
530 [](
const std::unique_ptr<LIST_ITEM>& x )
532 return x->GetIsGroup();
535 wxString match_str = aItem->GetNetclassName();
538 aItem->SetParent( &**
group );
545 auto new_iter = std::lower_bound(
m_items.begin(),
m_items.end(), aItem->GetNetCode(),
548 new_iter =
m_items.insert( new_iter, std::move( aItem ) );
549 const std::unique_ptr<LIST_ITEM>& new_item = *new_iter;
551 ItemAdded( wxDataViewItem( new_item->Parent() ), wxDataViewItem( new_item.get() ) );
556 void addItems( std::vector<std::unique_ptr<LIST_ITEM>>& aItems )
560 for( std::unique_ptr<LIST_ITEM>& i : aItems )
564 std::unique_ptr<LIST_ITEM>
deleteItem(
const std::optional<LIST_ITEM_ITER>& aRow )
569 std::unique_ptr<LIST_ITEM> i = std::move( **aRow );
575 ItemDeleted( wxDataViewItem( parent ), wxDataViewItem( &*i ) );
579 ItemChanged( wxDataViewItem( parent ) );
584 [&]( std::unique_ptr<LIST_ITEM>& x )
586 return x.get() == parent;
589 wxASSERT( p !=
m_items.end() );
592 ItemDeleted( wxDataViewItem( parent->
Parent() ), wxDataViewItem( parent ) );
613 std::unique_ptr<LIST_ITEM>&
group =
m_items.emplace_back( std::make_unique<LIST_ITEM>(
617 ItemAdded( wxDataViewItem(
group->Parent() ), wxDataViewItem(
group.get() ) );
634 const std::unique_ptr<LIST_ITEM>& listItem = *aRow.value();
636 if( listItem->Parent() )
637 ItemChanged( wxDataViewItem( listItem->Parent() ) );
639 ItemChanged( wxDataViewItem( listItem.get() ) );
646 for( std::unique_ptr<LIST_ITEM>& i :
m_items )
647 ItemChanged( wxDataViewItem( i.get() ) );
654 bool changed =
false;
660 i->ResetColumnChangedBits();
705 void GetValue( wxVariant& aOutValue,
const wxDataViewItem& aItem,
706 unsigned int aCol )
const override
712 if( i->GetIsGroup() )
714 switch( i->GetGroupType() )
717 aOutValue =
_(
"Netclass" ) +
": " + i->GetGroupName();
720 aOutValue =
_(
"Custom" ) +
": " + i->GetGroupName();
723 aOutValue = i->GetGroupName();
729 aOutValue = i->GetNetName();
734 aOutValue = i->GetNetclassName();
762 static int compareUInt( int64_t aValue1, int64_t aValue2,
bool aAsc )
765 return aValue1 < aValue2 ? -1 : 1;
767 return aValue2 < aValue1 ? -1 : 1;
770 int Compare(
const wxDataViewItem& aItem1,
const wxDataViewItem& aItem2,
unsigned int aCol,
771 bool aAsc )
const override
820 wxUIntPtr id1 = wxPtrToUInt( aItem1.GetID() );
821 wxUIntPtr id2 = wxPtrToUInt( aItem2.GetID() );
823 return aAsc ? id1 - id2 : id2 - id1;
826 bool SetValue(
const wxVariant& aInValue,
const wxDataViewItem& aItem,
827 unsigned int aCol )
override
832 wxDataViewItem
GetParent(
const wxDataViewItem& aItem )
const override
835 return wxDataViewItem();
837 return wxDataViewItem(
static_cast<const LIST_ITEM*
>( aItem.GetID() )->
Parent() );
845 return static_cast<const LIST_ITEM*
>( aItem.GetID() )->GetIsGroup();
854 wxDataViewItemArray& aChildren )
const override
858 if( !aParent.IsOk() )
860 aChildren.Alloc(
m_items.size() );
862 for(
const std::unique_ptr<LIST_ITEM>& i :
m_items )
864 if( i->Parent() == nullptr )
865 aChildren.Add( wxDataViewItem( &*i ) );
868 return aChildren.GetCount();
877 aChildren.Alloc( count );
880 aChildren.Add( wxDataViewItem( *i ) );
882 return aChildren.GetCount();
888 wxString
GetColumnType(
unsigned int )
const override {
return wxS(
"string" ); }
896 std::vector<std::unique_ptr<LIST_ITEM>>
m_items;
int GetCopperLayerCount() const
A collection of nets and the parameters used to route or test these nets.
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
wxDataViewCtrl * m_netsList
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
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)
LIST_ITEM_ITER 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 int ChildrenCount() const
void SubViaCount(unsigned int aValue)
unsigned GetViaCount() const
std::vector< LIST_ITEM * > m_children
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
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)
unsigned long long int GetTotalLength() const
int64_t GetPadDieLength() const
void SetParent(LIST_ITEM *aParent)
int GetGroupNumber() const
bool ViaCountChanged() const
LIST_ITEM & operator=(const LIST_ITEM &)=delete
const wxString & GetGroupName() const
std::vector< int > m_column_changed
LIST_ITEM(NETINFO_ITEM *aNet)
const wxString & GetNetName() const
bool ViaLengthChanged() 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 AddViaLength(unsigned int aValue)
void SubPadCount(unsigned int aValue)
void SubLayerWireLength(const int64_t aValue, PCB_LAYER_ID aLayer)
PCB net inspection panel.
std::vector< std::unique_ptr< LIST_ITEM > >::iterator LIST_ITEM_ITER
BOARD * m_board
Parent BOARD.
static wxString formatCount(unsigned int aValue)
std::vector< std::unique_ptr< EDA_COMBINED_MATCHER > > m_custom_group_rules
Custom net grouping rules.
wxString formatLength(int64_t aValue) const
std::vector< COLUMN_DESC > m_columns
All displayed (or hidden) columns.
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