20#ifndef PCB_NET_INSPECTOR_PANEL_DATA_MODEL
21#define PCB_NET_INSPECTOR_PANEL_DATA_MODEL
343 template <
typename T>
346 return a->GetNetCode() < b->GetNetCode();
349 template <
typename T>
352 return a->GetNetCode() < b;
355 template <
typename T>
358 return a < b->GetNetCode();
365 template <
typename T>
368 return a->GetGroupNumber() < b->GetGroupNumber();
371 template <
typename T>
374 return a->GetGroupNumber() < b;
377 template <
typename T>
380 return a < b->GetGroupNumber();
397 wxVariant
valueAt(
unsigned int aCol,
unsigned int aRow )
const
408 std::vector<std::pair<wxString, wxDataViewItem>> ret;
410 for( std::unique_ptr<LIST_ITEM>& item :
m_items )
412 if( item->GetIsGroup() )
414 ret.push_back( std::make_pair( item->GetGroupName(),
415 wxDataViewItem( item.get() ) ) );
423 std::optional<LIST_ITEM_ITER>
findItem(
int aNetCode )
425 auto i = std::lower_bound(
m_items.begin(),
m_items.end(), aNetCode,
428 if( i ==
m_items.end() || ( *i )->GetNetCode() != aNetCode )
437 if( aNet !=
nullptr )
446 auto i = std::lower_bound(
m_items.begin(),
m_items.end(), aGroupNumber,
449 if( i ==
m_items.end() || ( *i )->GetGroupNumber() != aGroupNumber )
460 [&](
const std::unique_ptr<LIST_ITEM>& x )
462 return x->GetGroupName() == groupName
463 && x->GetGroupType() == groupType;
466 if(
group == groupsEnd )
468 int dist = std::distance( groupsBegin, groupsEnd );
469 std::unique_ptr<LIST_ITEM> groupItem = std::make_unique<LIST_ITEM>( dist, groupName,
471 group =
m_items.insert( groupsEnd, std::move( groupItem ) );
472 ItemAdded( wxDataViewItem( ( *group )->Parent() ), wxDataViewItem( &**
group ) );
479 std::optional<LIST_ITEM_ITER>
addItem( std::unique_ptr<LIST_ITEM> aItem )
481 if( aItem ==
nullptr )
484 bool groupMatched =
false;
489 wxString searchName = aItem->GetNetName().Upper();
493 if( rule->Find( searchName.Upper() ) )
507 [](
const std::unique_ptr<LIST_ITEM>& x )
509 return x->GetIsGroup();
512 wxString match_str = aItem->GetNetclassName();
515 aItem->SetParent( &**
group );
522 auto new_iter = std::lower_bound(
m_items.begin(),
m_items.end(), aItem->GetNetCode(),
525 new_iter =
m_items.insert( new_iter, std::move( aItem ) );
526 const std::unique_ptr<LIST_ITEM>& new_item = *new_iter;
528 ItemAdded( wxDataViewItem( new_item->Parent() ), wxDataViewItem( new_item.get() ) );
533 void addItems( std::vector<std::unique_ptr<LIST_ITEM>> aItems )
537 for( std::unique_ptr<LIST_ITEM>& i : aItems )
541 std::unique_ptr<LIST_ITEM>
deleteItem(
const std::optional<LIST_ITEM_ITER>& aRow )
546 std::unique_ptr<LIST_ITEM> i = std::move( **aRow );
552 ItemDeleted( wxDataViewItem( parent ), wxDataViewItem( &*i ) );
556 ItemChanged( wxDataViewItem( parent ) );
561 [&]( std::unique_ptr<LIST_ITEM>& x )
563 return x.get() == parent;
566 wxASSERT( p !=
m_items.end() );
569 ItemDeleted( wxDataViewItem( parent->
Parent() ), wxDataViewItem( parent ) );
590 std::unique_ptr<LIST_ITEM>&
group =
m_items.emplace_back( std::make_unique<LIST_ITEM>(
593 ItemAdded( wxDataViewItem(
group->Parent() ), wxDataViewItem(
group.get() ) );
610 const std::unique_ptr<LIST_ITEM>& listItem = *aRow.value();
612 if( listItem->Parent() )
613 ItemChanged( wxDataViewItem( listItem->Parent() ) );
615 ItemChanged( wxDataViewItem( listItem.get() ) );
622 for( std::unique_ptr<LIST_ITEM>& i :
m_items )
623 ItemChanged( wxDataViewItem( i.get() ) );
630 bool changed =
false;
636 i->ResetColumnChangedBits();
681 void GetValue( wxVariant& aOutValue,
const wxDataViewItem& aItem,
682 unsigned int aCol )
const override
686 if( i->GetIsGroup() )
690 switch( i->GetGroupType() )
693 aOutValue =
_(
"Netclass" ) +
": " + i->GetGroupName();
696 aOutValue =
_(
"Custom" ) +
": " + i->GetGroupName();
699 aOutValue = i->GetGroupName();
710 aOutValue = i->GetNetName();
713 aOutValue = i->GetNetclassName();
741 static int compareUInt( uint64_t aValue1, uint64_t aValue2,
bool aAsc )
744 return aValue1 < aValue2 ? -1 : 1;
746 return aValue2 < aValue1 ? -1 : 1;
749 int Compare(
const wxDataViewItem& aItem1,
const wxDataViewItem& aItem2,
unsigned int aCol,
750 bool aAsc )
const override
799 wxUIntPtr id1 = wxPtrToUInt( aItem1.GetID() );
800 wxUIntPtr id2 = wxPtrToUInt( aItem2.GetID() );
802 return aAsc ? id1 - id2 : id2 - id1;
805 bool SetValue(
const wxVariant& aInValue,
const wxDataViewItem& aItem,
806 unsigned int aCol )
override
811 wxDataViewItem
GetParent(
const wxDataViewItem& aItem )
const override
814 return wxDataViewItem();
816 return wxDataViewItem(
static_cast<const LIST_ITEM*
>( aItem.GetID() )->
Parent() );
824 return static_cast<const LIST_ITEM*
>( aItem.GetID() )->GetIsGroup();
833 wxDataViewItemArray& aChildren )
const override
837 if( !aParent.IsOk() )
839 aChildren.Alloc(
m_items.size() );
841 for(
const std::unique_ptr<LIST_ITEM>& i :
m_items )
843 if( i->Parent() == nullptr )
844 aChildren.Add( wxDataViewItem( &*i ) );
847 return aChildren.GetCount();
856 aChildren.Alloc( count );
859 aChildren.Add( wxDataViewItem( *i ) );
861 return aChildren.GetCount();
867 wxString
GetColumnType(
unsigned int )
const override {
return wxS(
"string" ); }
875 std::vector<std::unique_ptr<LIST_ITEM>>
m_items;
A collection of nets and the parameters used to route or test these nets.
const wxString GetName() const
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
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 addItems(std::vector< std::unique_ptr< LIST_ITEM > > aItems)
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)
static int compareUInt(uint64_t aValue1, uint64_t aValue2, bool aAsc)
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
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)
bool PadCountChanged() const
LIST_ITEM(unsigned int aGroupNumber, const wxString &aGroupName, GROUP_TYPE aGroupType)
void SetPadCount(unsigned int aValue)
auto ChildrenBegin() const
unsigned int ChildrenCount() const
void SubViaCount(unsigned int aValue)
unsigned GetViaCount() const
std::vector< LIST_ITEM * > m_children
void SetViaCount(unsigned int aValue)
uint64_t GetPadDieLength() const
void ResetColumnChangedBits()
uint64_t GetLayerWireLength(size_t aLayer) const
LIST_ITEM * Parent() const
uint64_t m_pad_die_length
bool BoardWireLengthChanged() const
const wxString & GetNetclassName() const
unsigned int GetPadCount() const
void SetViaLength(unsigned int aValue)
void SubLayerWireLength(const uint64_t aValue, size_t aLayer)
uint64_t GetViaLength() const
uint64_t GetBoardWireLength() const
void SubViaLength(uint64_t aValue)
unsigned long long int GetTotalLength() const
void SetParent(LIST_ITEM *aParent)
int GetGroupNumber() const
bool ViaCountChanged() const
LIST_ITEM & operator=(const LIST_ITEM &)=delete
void AddPadDieLength(uint64_t aValue)
const wxString & GetGroupName() const
std::vector< int > m_column_changed
void SetLayerWireLength(const uint64_t aValue, size_t aLayer)
LIST_ITEM(NETINFO_ITEM *aNet)
const wxString & GetNetName() const
void AddLayerWireLength(const uint64_t aValue, size_t aLayer)
bool ViaLengthChanged() const
unsigned int m_group_number
bool PadDieLengthChanged() const
NETINFO_ITEM * GetNet() const
void AddPadCount(unsigned int aValue)
void SetPadDieLength(uint64_t aValue)
bool TotalLengthChanged() const
GROUP_TYPE GetGroupType() const
void AddViaLength(unsigned int aValue)
void SubPadCount(unsigned int aValue)
void SubPadDieLength(uint64_t aValue)
std::array< uint64_t, MAX_CU_LAYERS > m_layer_wire_length
Net inspection panel for pcbnew.
std::vector< std::unique_ptr< LIST_ITEM > >::iterator LIST_ITEM_ITER
wxString formatCount(unsigned int aValue) const
std::vector< std::unique_ptr< EDA_COMBINED_MATCHER > > m_custom_group_rules
wxString formatLength(int64_t aValue) const
std::vector< COLUMN_DESC > m_columns
All displayed (or hidden) columns.
Abstract pattern-matching tool and implementations.
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